From a937362ccca6d7ed786d22d52e2b0175f894fb2c Mon Sep 17 00:00:00 2001 From: bridgewaterrobbie Date: Wed, 19 Feb 2025 17:24:15 -0500 Subject: [PATCH] Update SPIR-V Dependencies to match Dawn requirements --- .../spirv-cross/.github/workflows/main.yml | 13 +- third_party/spirv-cross/.gitignore | 4 + third_party/spirv-cross/CMakeLists.txt | 20 +- .../spirv-cross/build_glslang_spirv_tools.sh | 2 +- .../checkout_glslang_spirv_tools.sh | 6 +- third_party/spirv-cross/main.cpp | 32 +- .../asm/comp/access-chain-invalidate.asm.comp | 12 +- .../asm/comp/atomic-decrement.asm.comp | 6 +- .../asm/comp/atomic-increment.asm.comp | 6 +- .../asm/frag/cbuffer-stripped.asm.frag | 14 +- .../asm/frag/image-extract-reuse.asm.frag | 4 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 20 +- .../asm/frag/line-directive.line.asm.frag | 4 +- .../frag/lut-promotion-initializer.asm.frag | 34 +- .../asm/frag/unreachable.asm.frag | 8 +- .../vert/spec-constant-op-composite.asm.vert | 32 +- .../shaders-hlsl/comp/ssbo-store-array.comp | 24 + .../frag/sample-mask-in-and-out.frag | 10 +- .../opt/shaders-hlsl/frag/sample-mask-in.frag | 6 +- .../shaders-hlsl/frag/sample-mask-out.frag | 6 +- .../asm/comp/atomic-decrement.asm.comp | 4 +- .../asm/comp/atomic-increment.asm.comp | 4 +- .../comp/buffer-write-relative-addr.asm.comp | 12 +- .../asm/comp/buffer-write.asm.comp | 4 +- ...e-load-store-short-vector.invalid.asm.comp | 1 + .../shaders-msl/asm/comp/quantize.asm.comp | 10 +- .../asm/comp/relaxed-block-layout.asm.comp | 10 +- ...specialization-constant-workgroup.asm.comp | 14 +- .../asm/comp/variable-pointers-2.asm.comp | 26 +- .../vector-builtin-type-cast-func.asm.comp | 8 +- .../comp/vector-builtin-type-cast.asm.comp | 8 +- ...grad.1d-as-2d.agx-cube-grad.msl23.asm.frag | 45 + .../frag/descriptor-array-unnamed.asm.frag | 32 +- .../extract-packed-from-composite.asm.frag | 6 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 20 +- .../asm/frag/line-directive.line.asm.frag | 4 +- .../asm/frag/locations-components.asm.frag | 20 +- .../frag/lut-promotion-initializer.asm.frag | 30 +- .../pull-model-interpolation.asm.msl23.frag | 28 +- .../shaders-msl/asm/frag/unreachable.asm.frag | 8 +- .../asm/frag/vector-shuffle-oom.asm.frag | 234 +- .../asm/vert/packed-bool-to-uint.asm.vert | 6 +- .../packed-bool2-to-packed_uint2.asm.vert | 6 +- .../vert/spec-constant-op-composite.asm.vert | 34 +- ...-argument-buffer.argument-tier-1.msl2.comp | 77 + ...-argument-buffer.argument-tier-1.msl2.comp | 109 + ...-argument-buffer.argument-tier-1.msl2.comp | 55 + .../opt/shaders-msl/comp/atomic-image.comp | 75 + .../shaders-msl/comp/atomic-image.msl31.comp | 72 + ...-vec-and-cast-to-and-from-uvec2.msl23.comp | 5 +- ...dress-recursive-struct-pointers.msl23.comp | 63 +- .../comp/buffer_device_address.msl2.comp | 33 +- .../comp/coherent-image-atomic.comp | 22 + .../coherent-image-atomic.msl2.argument.comp | 28 + .../comp/coherent-image-atomic.msl2.comp | 22 + .../coherent-image-atomic.msl31.argument.comp | 20 + .../comp/coherent-image-atomic.msl31.comp | 15 + .../shaders-msl/comp/complex-type-alias.comp | 43 +- ...n_patch.replace-recursive-inputs.msl3.comp | 27 + ...ray-query.spv14.vk.ios.msl24..invalid.comp | 30 +- .../shaders-msl/comp/shader_ballot.msl22.comp | 77 + .../comp/shader_group_vote.msl21.comp | 37 + .../comp/shared-array-of-arrays.comp | 43 +- .../opt/shaders-msl/comp/shared.comp | 43 +- .../comp/threadgroup-boolean-workaround.comp | 43 +- .../desktop-only/frag/image-ms.desktop.frag | 1 + .../tesc/basic.desktop.sso.multi-patch.tesc | 4 +- ...ag-demote-checks.discard-checks.msl23.frag | 16 +- ...ag-demote-checks.discard-checks.msl31.frag | 60 + ...s-continue-block.discard-checks.msl31.frag | 40 + ...g-discard-checks.discard-checks.msl23.frag | 16 +- ...g-discard-checks.discard-checks.msl31.frag | 59 + ...ixel-interlock-ordered.msl31.argument.frag | 45 + .../frag/pixel-interlock-ordered.msl31.frag | 34 + .../frag/post-depth-coverage.ios.msl2.frag | 2 +- .../frag/post-depth-coverage.msl23.frag | 2 +- ...ery-object-in-function.spv14.vk.msl24.frag | 28 +- ....msl3.argument-tier-1.rich-descriptor.frag | 159 + ....msl3.argument-tier-1.rich-descriptor.frag | 68 + ...nd-out.fixed-sample-mask.force-sample.frag | 2 +- ...ple-mask-in-and-out.fixed-sample-mask.frag | 2 +- .../frag/sampler-cube-grad.agx-cube-grad.frag | 44 + ...rays.mask-location-0.msl2.multi-patch.tesc | 114 +- .../copy-arrays.mask-location-0.msl2.tesc | 112 +- ...lock.mask-location-0.multi-patch.msl2.tesc | 2 +- ...te-outputs-block.mask-location-1.msl2.tesc | 43 +- ...lock.mask-location-1.multi-patch.msl2.tesc | 45 +- .../write-outputs.mask-location-0.msl2.tesc | 43 +- ...e-outputs.mask-location-0.multi-patch.tesc | 4 +- .../write-outputs.mask-location-0.tesc | 2 +- ...e-outputs.mask-location-1.multi-patch.tesc | 45 +- .../write-outputs.mask-location-1.tesc | 43 +- ...e-outputs.mask-point-size.multi-patch.tesc | 4 +- .../write-outputs.mask-point-size.tesc | 2 +- ...ite-outputs.mask-position.multi-patch.tesc | 4 +- .../masking/write-outputs.mask-position.tesc | 2 +- .../tesc/arrayed-block-io.multi-patch.tesc | 2 +- .../load-control-point-array.multi-patch.tesc | 2 +- .../tesc/matrix-output.multi-patch.tesc | 2 +- .../tesc/reload-tess-level.multi-patch.tesc | 4 +- .../tesc/struct-output.multi-patch.tesc | 2 +- .../tesc/water_tess.multi-patch.tesc | 2 +- ...ad-patch-vertices-in-func.raw-tess-in.tese | 18 + .../vert/buffer_device_address.msl2.vert | 27 +- ...lper-forwarding.asm.vk.nocompat.msl23.frag | 4 +- .../asm/frag/depth-compare.asm.frag | 2 +- .../asm/frag/global-constant-arrays.asm.frag | 34 +- .../padded-float-array-member-defef.asm.frag | 42 +- .../asm/frag/sample-mask-not-array.asm.frag | 45 +- .../hs-incorrect-base-type.invalid.asm.tesc | 128 +- .../hs-input-array-access.invalid.asm.tesc | 170 +- .../tesc/hs-texcoord-array.invalid.asm.tesc | 122 +- ...actor-must-be-threadgroup.invalid.asm.tesc | 40 +- .../asm/vert/array-missing-copies.asm.vert | 2 +- .../asm/comp/atomic-decrement.asm.comp | 4 +- .../asm/comp/atomic-increment.asm.comp | 4 +- .../asm/comp/builtin-compute-bitcast.asm.comp | 4 +- .../opt/shaders/asm/comp/quantize.asm.comp | 10 +- ...specialization-constant-workgroup.asm.comp | 4 +- .../comp/switch-break-ladder.asm.invalid.comp | 12 +- .../frag/complex-name-workarounds.asm.frag | 6 +- .../frag/for-loop-phi-only-continue.asm.frag | 12 +- .../frag/image-fetch-no-sampler.asm.vk.frag | 4 +- .../image-fetch-no-sampler.asm.vk.frag.vk | 4 +- ...etch-no-sampler.no-samplerless.asm.vk.frag | 4 +- ...h-no-sampler.no-samplerless.asm.vk.frag.vk | 4 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 20 +- .../asm/frag/line-directive.line.asm.frag | 4 +- .../asm/frag/locations-components.asm.frag | 20 +- ...op-body-dominator-continue-access.asm.frag | 50 +- .../asm/frag/loop-header-to-continue.asm.frag | 36 +- .../frag/lut-promotion-initializer.asm.frag | 30 +- .../frag/op-phi-swap-continue-block.asm.frag | 24 +- .../storage-class-output-initializer.asm.frag | 8 +- .../struct-composite-extract-swizzle.asm.frag | 4 +- .../frag/switch-label-shared-block.asm.frag | 10 +- .../asm/frag/temporary-phi-hoisting.asm.frag | 14 +- .../opt/shaders/asm/frag/unreachable.asm.frag | 8 +- .../asm/frag/vector-shuffle-oom.asm.frag | 238 +- .../asm/vert/invariant-block.sso.asm.vert | 4 +- .../shaders/asm/vert/invariant.sso.asm.vert | 4 +- .../spec-constant-op-composite.asm.vk.vert | 30 +- .../spec-constant-op-composite.asm.vk.vert.vk | 38 +- .../opt/shaders/frag/block-match-sad.frag | 26 + .../opt/shaders/frag/block-match-ssd.frag | 26 + .../opt/shaders/frag/box-filter.frag | 18 + .../opt/shaders/frag/sample-weighted.frag | 19 + .../tese/read-patch-vertices-in-func.tese | 8 + ...ay-of-buffer-reference.nocompat.vk.comp.vk | 2 +- ...uffer-reference-atomic.nocompat.vk.comp.vk | 2 +- ...base-alignment-promote.nocompat.vk.comp.vk | 3 +- ...itcast-uvec2-2.nocompat.invalid.vk.comp.vk | 2 +- ...eference-bitcast-uvec2.nocompat.vk.comp.vk | 2 +- ...ffer-reference-bitcast.nocompat.vk.comp.vk | 2 +- ...-reference-decorations.nocompat.vk.comp.vk | 2 +- .../comp/buffer-reference.nocompat.vk.comp.vk | 16 +- .../vulkan/comp/fp-atomic.nocompat.vk.comp.vk | 2 - .../shaders/vulkan/frag/block-match-sad.frag | 26 + .../shaders/vulkan/frag/block-match-ssd.frag | 26 + .../opt/shaders/vulkan/frag/box-filter.frag | 18 + ...-helper-forwarding.asm.vk.nocompat.frag.vk | 4 +- .../shaders/vulkan/frag/sample-weighted.frag | 19 + ...access-chain-load-store-composite.asm.comp | 24 +- ...ased-struct-divergent-member-name.asm.comp | 12 +- .../asm/comp/atomic-load-store.asm.comp | 10 +- .../asm/comp/atomic-result-temporary.asm.comp | 10 +- .../comp/bitfield-signed-operations.asm.comp | 30 +- .../asm/comp/bitscan.asm.comp | 30 +- ...onuniform.asm.sm51.nonuniformresource.comp | 4 +- .../comp/constant-lut-name-aliasing.asm.comp | 4 +- .../asm/comp/glsl-signed-operations.asm.comp | 70 +- ....std450.frexp-modf-struct.fxconly.asm.comp | 18 +- ...onuniform.asm.sm51.nonuniformresource.comp | 4 +- .../asm/comp/local-size-id-override.asm.comp | 14 +- ...sm.comp => local-size-id.asm.invalid.comp} | 16 +- .../asm/comp/num-workgroups.spv14.asm.comp | 6 +- .../comp/spec-constant-name-aliasing.asm.comp | 4 +- ...lization-constant-workgroup.nofxc.asm.comp | 10 +- .../comp/storage-buffer-basic.nofxc.asm.comp | 14 +- .../anonymous-inner-struct-names.asm.frag | 12 +- .../composite-insert-inheritance.asm.frag | 18 +- .../asm/frag/empty-struct-in-struct.asm.frag | 10 +- ...andling-2.nonuniformresource.sm51.asm.frag | 6 +- ...opagation.nonuniformresource.sm51.asm.frag | 22 +- ...form-ssbo.sm51.nonuniformresource.asm.frag | 22 +- .../asm/frag/phi.zero-initialize.asm.frag | 6 +- ...-interlock-callstack.sm51.fxconly.asm.frag | 12 +- ...terlock-control-flow.sm51.fxconly.asm.frag | 20 +- ...lock-split-functions.sm51.fxconly.asm.frag | 20 +- ...sample-mask-load-store-array-uint.asm.frag | 26 + .../sample-mask-load-store-array.asm.frag | 26 + .../asm/frag/scalar-select.spv14.asm.frag | 22 +- ...element-array-matrix-rule.invalid.asm.frag | 6 +- ...ch-block-case-fallthrough.asm.invalid.frag | 24 +- ...ip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh | 73 + ...builtin-outputs.spv14.asm.vk.nocompat.mesh | 42 +- .../asm/temporary.zero-initialize.asm.frag | 14 +- .../vert/block-struct-initializer.asm.vert | 12 +- .../asm/vert/empty-struct-composite.asm.vert | 4 +- .../comp/illegal-struct-name.asm.comp | 10 +- ...ct-cbuffer-packing-straddle-top-level.comp | 16 + .../substruct-cbuffer-packing-straddle.comp | 21 + ...e.spv14.vk.nocompat.nofxc.flip-vert-y.mesh | 84 + .../asm/comp/access-chain-invalidate.asm.comp | 12 +- .../asm/comp/atomic-decrement.asm.comp | 6 +- .../asm/comp/atomic-increment.asm.comp | 6 +- .../asm/frag/cbuffer-stripped.asm.frag | 20 +- .../asm/frag/empty-struct.asm.frag | 4 +- .../asm/frag/image-extract-reuse.asm.frag | 4 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 10 +- .../frag/lut-promotion-initializer.asm.frag | 22 +- .../asm/frag/unreachable.asm.frag | 14 +- .../vert/spec-constant-op-composite.asm.vert | 34 +- .../shaders-hlsl/comp/ssbo-store-array.comp | 22 + .../frag/sample-mask-in-and-out.frag | 10 +- .../shaders-hlsl/frag/sample-mask-in.frag | 6 +- .../shaders-hlsl/frag/sample-mask-out.frag | 6 +- ...ased-struct-divergent-member-name.asm.comp | 6 +- .../comp/arithmetic-conversion-signs.asm.comp | 50 +- .../asm/comp/atomic-load-store.asm.comp | 8 +- .../asm/comp/atomic-min-max-sign.asm.comp | 18 +- .../asm/comp/atomic-result-temporary.asm.comp | 8 +- .../asm/comp/bitcast-fp16-fp32.asm.comp | 6 +- .../comp/bitfield-signed-operations.asm.comp | 30 +- .../asm/comp/bitscan.asm.comp | 30 +- .../block-like-array-type-construct.asm.comp | 10 +- ...composite-construct-buffer-struct.asm.comp | 43 +- .../comp/constant-lut-name-aliasing.asm.comp | 4 +- .../asm/comp/copy-logical-2.spv14.asm.comp | 30 +- ...fset-and-array-stride-diffs.spv14.asm.comp | 50 +- .../asm/comp/copy-logical.spv14.asm.comp | 20 +- .../comp/device-array-load-temporary.asm.comp | 2 +- .../device-constant-array-load-store.asm.comp | 16 +- ...ray-load-store.force-native-array.asm.comp | 8 +- .../asm/comp/glsl-signed-operations.asm.comp | 70 +- .../glsl.std450.frexp-modf-struct.asm.comp | 20 +- ...shared-inner-array-of-struct-copy.asm.comp | 78 + .../asm/comp/local-size-id-override.asm.comp | 22 +- .../asm/comp/local-size-id.asm.comp | 26 - .../asm/comp/local-size-id.asm.invalid.comp | 26 + .../asm/comp/modf-storage-class.asm.comp | 34 +- .../comp/spec-constant-name-aliasing.asm.comp | 4 +- .../storage-buffer-basic.invalid.asm.comp | 18 +- .../storage-buffer-pointer-argument.asm.comp | 4 +- .../asm/comp/variable-pointers-2.asm.comp | 59 + .../asm/comp/variable-pointers-3.asm.comp | 55 + ...ariable-pointers-vector-to-scalar.asm.comp | 55 + .../asm/comp/variable-pointers.asm.comp | 69 +- ...t-to-uchar-alias-ptr-access-chain.asm.comp | 175 + .../composite-insert-inheritance.asm.frag | 18 +- ...py-memory-block-like-thread-local.asm.frag | 14 +- ...-frexp-scalar-access-chain-output.asm.frag | 8 +- .../asm/frag/phi.zero-initialize.asm.frag | 6 +- .../pixel-interlock-callstack.msl2.asm.frag | 18 +- ...pixel-interlock-control-flow.msl2.asm.frag | 26 +- ...el-interlock-split-functions.msl2.asm.frag | 26 +- ...sample-mask-load-store-array-uint.asm.frag | 59 + .../sample-mask-load-store-array.asm.frag | 59 + .../asm/frag/scalar-select.spv14.asm.frag | 10 +- ...up-arithmetic-cast.msl21.asm.invalid.frag} | 0 ...ch-block-case-fallthrough.asm.invalid.frag | 16 +- .../asm/frag/texture-access.swizzle.asm.frag | 12 +- ...lizers-block.mask-location-0.msl2.asm.tesc | 6 +- ....mask-location-0.multi-patch.msl2.asm.tesc | 8 +- ...lizers-block.mask-location-1.msl2.asm.tesc | 4 +- ....mask-location-1.multi-patch.msl2.asm.tesc | 6 +- ...lizers-block.mask-point-size.msl2.asm.tesc | 16 +- ....mask-point-size.multi-patch.msl2.asm.tesc | 18 +- ...ializers-block.mask-position.msl2.asm.tesc | 16 +- ...ck.mask-position.multi-patch.msl2.asm.tesc | 18 +- ...initializers.mask-location-0.msl2.asm.tesc | 16 +- ....mask-location-0.msl2.multi-patch.asm.tesc | 18 +- .../initializers.mask-location-1.asm.tesc | 14 +- ...izers.mask-location-1.multi-patch.asm.tesc | 16 +- ...initializers.mask-point-size.msl2.asm.tesc | 16 +- ....mask-point-size.msl2.multi-patch.asm.tesc | 18 +- .../initializers.mask-position.msl2.asm.tesc | 16 +- ...rs.mask-position.msl2.multi-patch.asm.tesc | 18 +- .../composite-extract-row-major.asm.comp | 4 +- .../load-packed-no-forwarding-2.asm.comp | 8 +- .../load-packed-no-forwarding-3.asm.comp | 10 +- .../load-packed-no-forwarding-4.asm.comp | 10 +- .../load-packed-no-forwarding-5.asm.comp | 10 +- .../load-packed-no-forwarding.asm.comp | 12 +- .../packed-vector-extract-insert.asm.comp | 8 +- .../row-major-split-access-chain.asm.comp | 4 +- .../asm/temporary.zero-initialize.asm.frag | 14 +- .../array-control-point-initializer.asm.tesc | 4 +- .../block-control-point-initializer.asm.tesc | 6 +- ...builtin-control-point-initializer.asm.tesc | 12 +- ...mposite-control-point-initializer.asm.tesc | 4 +- .../tesc/copy-memory-control-point.asm.tesc | 44 +- .../asm/tesc/copy-tess-level-tri.asm.tesc | 12 +- .../plain-control-point-initializer.asm.tesc | 4 +- ...builtin-array.invalid.multi-patch.asm.tesc | 2 +- .../tesc/tess-level-initializer-quad.asm.tesc | 4 +- .../tess-level-initializer-triangle.asm.tesc | 4 +- .../vert/block-io-use-in-function.asm.vert | 30 +- .../vert/block-struct-initializer.asm.vert | 10 +- .../comp/array-copy-threadgroup-memory.comp | 119 +- .../comp/extract-atomics-from-function.comp | 82 + .../shaders-msl-no-opt/comp/glsl.std450.comp | 2 +- .../comp/illegal-struct-name.asm.comp | 6 +- .../comp/image-array-atomic.msl31.comp | 19 + .../comp/integer-dot-product.comp | 65 + .../combined-sampler-parameter-names.asm.frag | 12 +- .../frag/fp16.desktop.invalid.frag | 2 +- .../ray-query-mutability.spv14.vk.msl24.frag | 70 + .../std140-half-matrix-and-array-write.frag | 64 + .../packing/std140-half-matrix-and-array.frag | 98 + .../passthrough-clip-cull.multi-patch.tesc | 4 +- .../asm/comp/atomic-decrement.asm.comp | 4 +- .../asm/comp/atomic-increment.asm.comp | 4 +- .../comp/buffer-write-relative-addr.asm.comp | 12 +- .../asm/comp/buffer-write.asm.comp | 4 +- ...e-load-store-short-vector.invalid.asm.comp | 1 + .../shaders-msl/asm/comp/quantize.asm.comp | 10 +- .../asm/comp/relaxed-block-layout.asm.comp | 10 +- ...specialization-constant-workgroup.asm.comp | 14 +- .../asm/comp/variable-pointers-2.asm.comp | 32 +- .../asm/frag/default-member-names.asm.frag | 10 +- ...grad.1d-as-2d.agx-cube-grad.msl23.asm.frag | 55 + .../depth-image-color-format-fetch.asm.frag | 18 +- .../depth-image-color-format-sampled.asm.frag | 16 +- .../frag/descriptor-array-unnamed.asm.frag | 32 +- .../extract-packed-from-composite.asm.frag | 14 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 10 +- .../asm/frag/locations-components.asm.frag | 20 +- .../frag/lut-promotion-initializer.asm.frag | 18 +- .../asm/frag/op-constant-null.asm.frag | 2 +- .../asm/frag/phi-loop-variable.asm.frag | 2 +- .../asm/frag/undef-variable-store.asm.frag | 18 +- .../shaders-msl/asm/frag/unreachable.asm.frag | 14 +- .../asm/frag/vector-shuffle-oom.asm.frag | 294 +- .../asm/vert/invariant.msl21.asm.vert | 4 +- .../asm/vert/packed-bool-to-uint.asm.vert | 6 +- .../packed-bool2-to-packed_uint2.asm.vert | 6 +- .../vert/spec-constant-op-composite.asm.vert | 40 +- ...-argument-buffer.argument-tier-1.msl2.comp | 83 + ...-argument-buffer.argument-tier-1.msl2.comp | 115 + ...-argument-buffer.argument-tier-1.msl2.comp | 61 + .../shaders-msl/comp/atomic-image.comp | 75 + .../shaders-msl/comp/atomic-image.msl31.comp | 72 + .../comp/coherent-image-atomic.comp | 38 + .../coherent-image-atomic.msl2.argument.comp | 44 + .../comp/coherent-image-atomic.msl2.comp | 38 + .../coherent-image-atomic.msl31.argument.comp | 37 + .../comp/coherent-image-atomic.msl31.comp | 32 + .../shaders-msl/comp/complex-type-alias.comp | 41 +- .../reference/shaders-msl/comp/functions.comp | 43 +- ...n_patch.replace-recursive-inputs.msl3.comp | 31 + ...ray-query.spv14.vk.ios.msl24..invalid.comp | 30 +- .../shaders-msl/comp/shader_ballot.msl22.comp | 80 + .../comp/shader_group_vote.msl21.comp | 41 + .../comp/shared-array-of-arrays.comp | 43 +- .../reference/shaders-msl/comp/shared.comp | 43 +- .../comp/threadgroup-boolean-workaround.comp | 43 +- .../desktop-only/frag/image-ms.desktop.frag | 1 + .../tesc/basic.desktop.sso.multi-patch.tesc | 4 +- ...ag-demote-checks.discard-checks.msl23.frag | 16 +- ...ag-demote-checks.discard-checks.msl31.frag | 67 + ...s-continue-block.discard-checks.msl31.frag | 49 + ...g-discard-checks.discard-checks.msl23.frag | 16 +- ...g-discard-checks.discard-checks.msl31.frag | 66 + ...ixel-interlock-ordered.msl31.argument.frag | 45 + .../frag/pixel-interlock-ordered.msl31.frag | 34 + .../frag/post-depth-coverage.ios.msl2.frag | 2 +- .../frag/post-depth-coverage.msl23.frag | 2 +- ...ery-object-in-function.spv14.vk.msl24.frag | 28 +- ....msl3.argument-tier-1.rich-descriptor.frag | 233 + ....msl3.argument-tier-1.rich-descriptor.frag | 68 + ...nd-out.fixed-sample-mask.force-sample.frag | 2 +- ...ple-mask-in-and-out.fixed-sample-mask.frag | 2 +- .../frag/sampler-cube-grad.agx-cube-grad.frag | 44 + ...rays.mask-location-0.msl2.multi-patch.tesc | 114 +- .../copy-arrays.mask-location-0.msl2.tesc | 112 +- ...lock.mask-location-0.multi-patch.msl2.tesc | 2 +- ...te-outputs-block.mask-location-1.msl2.tesc | 43 +- ...lock.mask-location-1.multi-patch.msl2.tesc | 45 +- .../write-outputs.mask-location-0.msl2.tesc | 43 +- ...e-outputs.mask-location-0.multi-patch.tesc | 6 +- .../write-outputs.mask-location-0.tesc | 4 +- ...e-outputs.mask-location-1.multi-patch.tesc | 45 +- .../write-outputs.mask-location-1.tesc | 43 +- ...e-outputs.mask-point-size.multi-patch.tesc | 6 +- .../write-outputs.mask-point-size.tesc | 4 +- ...ite-outputs.mask-position.multi-patch.tesc | 6 +- .../masking/write-outputs.mask-position.tesc | 4 +- .../tesc/arrayed-block-io.multi-patch.tesc | 2 +- .../load-control-point-array.multi-patch.tesc | 2 +- .../tesc/matrix-output.multi-patch.tesc | 2 +- .../tesc/reload-tess-level.multi-patch.tesc | 4 +- .../tesc/struct-output.multi-patch.tesc | 2 +- .../tesc/water_tess.multi-patch.tesc | 2 +- ...ad-patch-vertices-in-func.raw-tess-in.tese | 26 + ...lper-forwarding.asm.vk.nocompat.msl23.frag | 4 +- ...ss-chain-dominator-in-loop-body-2.asm.comp | 18 +- ...cess-chain-dominator-in-loop-body.asm.comp | 12 +- ...ased-struct-divergent-member-name.asm.comp | 8 +- ...c-conversion-signs.asm.nocompat.vk.comp.vk | 58 +- .../asm/comp/atomic-load-store.asm.comp | 8 +- .../asm/comp/atomic-result-temporary.asm.comp | 8 +- .../asm/comp/basic.spv16.asm.comp | 4 +- ...ay-in-buffer.asm.spv16.nocompat.vk.comp.vk | 11 +- .../asm/comp/bitcast-fp16-fp32.asm.vk.comp | 6 +- .../asm/comp/bitcast-fp16-fp32.asm.vk.comp.vk | 6 +- .../comp/bitfield-signed-operations.asm.comp | 30 +- .../shaders-no-opt/asm/comp/bitscan.asm.comp | 30 +- .../block-undef.noeliminate.invalid.asm.comp | 13 + ...-atomic-nonuniform.vk.nocompat.asm.comp.vk | 4 +- ...ddress-ptr-casting.vk.nocompat.asm.comp.vk | 2 +- ...aliased-block-name.nocompat.vk.asm.comp.vk | 14 +- ...ained-access.spv16.asm.nocompat.vk.comp.vk | 20 + ...er-to-plain-struct.asm.nocompat.vk.comp.vk | 28 + ...r-to-pod-in-buffer.asm.nocompat.vk.comp.vk | 7 +- ...std430-array.asm.spv16.nocompat.vk.comp.vk | 28 + ...used-pod-in-buffer.asm.nocompat.vk.comp.vk | 3 +- ...thesized-pointer-2.asm.nocompat.vk.comp.vk | 11 +- ...pointer-to-pointer.asm.nocompat.vk.comp.vk | 32 + ...ynthesized-pointer.asm.nocompat.vk.comp.vk | 13 +- .../comp/constant-lut-name-aliasing.asm.comp | 4 +- .../asm/comp/copy-logical.spv14.asm.comp | 20 +- .../comp/empty-ubo-block.noeliminate.asm.comp | 12 + .../comp/expression-nesting-limits.asm.comp | 8 +- .../asm/comp/glsl-signed-operations.asm.comp | 70 +- .../glsl.std450.frexp-modf-struct.asm.comp | 20 +- ...-atomic-nonuniform.vk.nocompat.asm.comp.vk | 4 +- .../comp/local-size-id-override.vk.asm.comp | 8 +- .../local-size-id-override.vk.asm.comp.vk | 8 +- .../asm/comp/local-size-id.vk.asm.comp | 12 +- .../asm/comp/local-size-id.vk.asm.comp.vk | 22 - .../comp/local-size-id.vk.invalid.asm.comp | 31 + .../comp/local-size-id.vk.invalid.asm.comp.vk | 22 + ...iable-early-read-with-initializer.asm.comp | 107 - ...rly-read-with-initializer.asm.invalid.comp | 107 + ...op-variable-early-read-with-undef.asm.comp | 108 - ...ble-early-read-with-undef.asm.invalid.comp | 108 + .../multi-break-switch-out-of-loop.asm.comp | 22 +- ...m-bracket-handling.vk.nocompat.asm.comp.vk | 58 +- ...mporary-rtas.spv14.asm.vk.nocompat.comp.vk | 12 +- .../spec-constant-name-aliasing.vk.asm.comp | 4 +- ...spec-constant-name-aliasing.vk.asm.comp.vk | 4 +- .../spec-constant-op-convert-sign.asm.comp | 14 +- .../asm/comp/storage-buffer-basic.asm.comp | 12 +- ...-access-terminator.vk.nocompat.asm.comp.vk | 28 +- .../degenerate-selection-constructs.asm.frag | 62 +- ...site-insert-hoisted-temporaries-1.asm.frag | 18 +- ...site-insert-hoisted-temporaries-2.asm.frag | 22 +- .../composite-insert-inheritance.asm.frag | 26 +- ...pure-function-call.vk.nocompat.asm.frag.vk | 2 +- .../discard-impure-function-call.asm.frag | 2 +- .../do-while-continue-phi.asm.invalid.frag | 8 +- .../asm/frag/empty-struct-in-struct.asm.frag | 4 +- ...ated-merge-block-inverted.asm.invalid.frag | 6 +- ...-merge-block-non-inverted.asm.invalid.frag | 6 +- .../asm/frag/for-loop-inverted-test.asm.frag | 6 +- .../inliner-dominator-inside-loop.asm.frag | 174 +- .../late-expression-invalidation-2.asm.frag | 154 +- .../asm/frag/ldexp-uint-exponent.asm.frag | 6 +- ...bracket-handling-2.vk.nocompat.asm.frag.vk | 6 +- ...lifier-propagation.vk.nocompat.asm.frag.vk | 22 +- .../nonuniform-ssbo.nocompat.vk.asm.frag.vk | 14 +- .../frag/only-initializer-frag-depth.asm.frag | 4 +- ...rnative-precision.asm..vk.nocompat.frag.vk | 22 +- .../asm/frag/phi.zero-initialize.asm.frag | 6 +- .../frag/pixel-interlock-callstack.asm.frag | 12 +- .../pixel-interlock-control-flow.asm.frag | 22 +- .../pixel-interlock-split-functions.asm.frag | 20 +- ...ritance-rules-hoisted-temporaries.asm.frag | 10 +- ...laxed-precision-inheritance-rules.asm.frag | 6 +- ...sample-mask-load-store-array-uint.asm.frag | 16 + .../sample-mask-load-store-array.asm.frag | 16 + .../asm/frag/scalar-select.spv14.asm.frag | 6 +- ...exture-feedback-uint-code.asm.desktop.frag | 6 +- ...etic-cast.nocompat.vk.asm.invalid.frag.vk} | 0 .../asm/frag/subgroup-ballot-only.vk.asm.frag | 10 +- .../frag/subgroup-ballot-only.vk.asm.frag.vk | 10 +- ...ch-block-case-fallthrough.asm.invalid.frag | 16 +- ...ch-non-default-fallthrough-no-phi.asm.frag | 66 +- ...tch-single-case-multiple-exit-cfg.asm.frag | 14 +- ...minate-impure-function-call.spv16.asm.frag | 2 +- .../frag/texel-fetch-ms-uint-sample.asm.frag | 10 +- .../loop-header-self-continue-break.asm.comp | 72 +- ...ion-dx-style.vk.nocompat.spv14.asm.mesh.vk | 49 + ...er-clip-cull.vk.nocompat.spv14.asm.mesh.vk | 35 + ...ltin-outputs.spv14.asm.vk.nocompat.mesh.vk | 38 +- ...n-nonuniform.spv14.vk.nocompat.asm.rgen.vk | 4 +- .../asm/temporary.zero-initialize.asm.frag | 14 +- ...array-of-block-output-initializer.asm.tesc | 50 +- .../tesc/copy-memory-control-point.asm.tesc | 32 +- .../asm/tesc/tess-level-initializer.asm.tesc | 8 +- .../vert/block-struct-initializer.asm.vert | 10 +- .../vert/debug-printf.asm.vk.nocompat.vert.vk | 2 +- .../asm/vert/empty-struct-composite.asm.vert | 4 +- .../comp/illegal-struct-name.asm.comp | 6 +- .../comp/loop-resolve-debug-semantics.gV.comp | 4 +- ...der-perprimitive.spv14.nocompat.vk.frag.vk | 11 + ...gle-case-multiple-exit-cfg.legacy.asm.frag | 14 +- ...nt-position-mesh.spv14.nocompat.vk.mesh.vk | 19 + .../comp/image-64bit.vk.nocompat.comp.vk | 22 + .../aliased-entry-point-names.asm.multi.json | 4 +- ...to-array-of-physical-pointer.asm.comp.json | 16 +- .../asm/op-source-glsl-ssbo-1.asm.comp.json | 4 +- .../asm/op-source-glsl-ssbo-2.asm.comp.json | 8 +- .../asm/op-source-hlsl-uav-1.asm.comp.json | 4 +- .../asm/op-source-hlsl-uav-2.asm.comp.json | 6 +- .../asm/op-source-none-ssbo-1.asm.comp.json | 4 +- .../asm/op-source-none-ssbo-2.asm.comp.json | 8 +- .../asm/op-source-none-uav-1.asm.comp.json | 4 +- .../asm/op-source-none-uav-2.asm.comp.json | 6 +- ...schain-invalid-expression.asm.invalid.frag | 2 +- .../asm/frag/depth-compare.asm.frag | 2 +- .../asm/frag/global-constant-arrays.asm.frag | 74 +- .../padded-float-array-member-defef.asm.frag | 82 +- .../asm/frag/sample-mask-not-array.asm.frag | 45 +- .../hs-incorrect-base-type.invalid.asm.tesc | 128 +- .../hs-input-array-access.invalid.asm.tesc | 170 +- .../tesc/hs-texcoord-array.invalid.asm.tesc | 122 +- ...actor-must-be-threadgroup.invalid.asm.tesc | 40 +- .../asm/vert/array-missing-copies.asm.vert | 2 +- .../asm/comp/atomic-decrement.asm.comp | 4 +- .../asm/comp/atomic-increment.asm.comp | 4 +- .../asm/comp/builtin-compute-bitcast.asm.comp | 4 +- .../asm/comp/hlsl-functionality.asm.comp | 4 +- .../shaders/asm/comp/logical.asm.comp | 4 +- .../shaders/asm/comp/quantize.asm.comp | 10 +- ...specialization-constant-workgroup.asm.comp | 4 +- .../comp/switch-break-ladder.asm.invalid.comp | 12 +- ...osite-construct-struct-no-swizzle.asm.frag | 4 +- .../asm/frag/default-member-names.asm.frag | 10 +- .../shaders/asm/frag/empty-struct.asm.frag | 4 +- .../frag/for-loop-phi-only-continue.asm.frag | 16 +- .../hlsl-sample-cmp-level-zero-cube.asm.frag | 4 +- .../frag/hlsl-sample-cmp-level-zero.asm.frag | 4 +- .../asm/frag/implicit-read-dep-phi.asm.frag | 10 +- .../shaders/asm/frag/invalidation.asm.frag | 4 +- .../asm/frag/locations-components.asm.frag | 20 +- ...op-body-dominator-continue-access.asm.frag | 8 +- .../asm/frag/loop-header-to-continue.asm.frag | 34 +- .../frag/lut-promotion-initializer.asm.frag | 18 +- .../asm/frag/op-constant-null.asm.frag | 2 +- .../frag/op-phi-swap-continue-block.asm.frag | 16 +- ...t-of-bounds-access-opspecconstant.asm.frag | 2 +- .../asm/frag/phi-loop-variable.asm.frag | 2 +- .../sampler-buffer-without-sampler.asm.frag | 4 +- .../storage-class-output-initializer.asm.frag | 8 +- .../struct-composite-extract-swizzle.asm.frag | 4 +- .../frag/switch-label-shared-block.asm.frag | 10 +- .../asm/frag/temporary-phi-hoisting.asm.frag | 14 +- .../asm/frag/undef-variable-store.asm.frag | 18 +- .../shaders/asm/frag/unreachable.asm.frag | 14 +- .../asm/frag/vector-shuffle-oom.asm.frag | 294 +- .../asm/geom/unroll-glposition-load.asm.geom | 6 +- .../asm/tese/unroll-input-array-load.asm.tese | 6 +- .../asm/vert/invariant-block.sso.asm.vert | 4 +- .../shaders/asm/vert/invariant.asm.vert | 4 +- .../shaders/asm/vert/invariant.sso.asm.vert | 8 +- .../spec-constant-op-composite.asm.vk.vert | 32 +- .../spec-constant-op-composite.asm.vk.vert.vk | 40 +- .../shaders/frag/block-match-sad.frag | 26 + .../shaders/frag/block-match-ssd.frag | 26 + .../reference/shaders/frag/box-filter.frag | 18 + .../frag/image-load-store-uint-coord.asm.frag | 4 +- .../shaders/frag/sample-weighted.frag | 19 + .../tese/read-patch-vertices-in-func.tese | 13 + ...ay-of-buffer-reference.nocompat.vk.comp.vk | 2 +- ...uffer-reference-atomic.nocompat.vk.comp.vk | 2 +- ...base-alignment-promote.nocompat.vk.comp.vk | 2 +- ...itcast-uvec2-2.nocompat.invalid.vk.comp.vk | 2 +- ...eference-bitcast-uvec2.nocompat.vk.comp.vk | 2 +- ...ffer-reference-bitcast.nocompat.vk.comp.vk | 2 +- ...-reference-decorations.nocompat.vk.comp.vk | 2 +- .../comp/buffer-reference.nocompat.vk.comp.vk | 2 +- .../shaders/vulkan/frag/block-match-sad.frag | 26 + .../shaders/vulkan/frag/block-match-ssd.frag | 26 + .../shaders/vulkan/frag/box-filter.frag | 18 + ...-helper-forwarding.asm.vk.nocompat.frag.vk | 4 +- .../shaders/vulkan/frag/sample-weighted.frag | 19 + ...sm.comp => local-size-id.asm.invalid.comp} | 0 ...sample-mask-load-store-array-uint.asm.frag | 40 + .../sample-mask-load-store-array.asm.frag | 45 + ...ip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh | 150 + ...ct-cbuffer-packing-straddle-top-level.comp | 12 + .../substruct-cbuffer-packing-straddle.comp | 17 + ...e.spv14.vk.nocompat.nofxc.flip-vert-y.mesh | 54 + .../shaders-hlsl/comp/ssbo-store-array.comp | 19 + ...-shader-basic-lines.spv14.vk.nocompat.mesh | 1 + ...ader-basic-triangle.spv14.vk.nocompat.mesh | 1 + ...shared-inner-array-of-struct-copy.asm.comp | 137 + ...sm.comp => local-size-id.asm.invalid.comp} | 0 .../asm/comp/variable-pointers-2.asm.comp | 71 + .../asm/comp/variable-pointers-3.asm.comp | 60 + ...ariable-pointers-vector-to-scalar.asm.comp | 60 + ...t-to-uchar-alias-ptr-access-chain.asm.comp | 214 + ...sample-mask-load-store-array-uint.asm.frag | 40 + .../sample-mask-load-store-array.asm.frag | 45 + ...up-arithmetic-cast.msl21.asm.invalid.frag} | 0 .../comp/extract-atomics-from-function.comp | 69 + .../comp/image-array-atomic.msl31.comp | 14 + .../comp/integer-dot-product.comp | 114 + .../ray-query-mutability.spv14.vk.msl24.frag | 26 + .../std140-half-matrix-and-array-write.frag | 51 + .../packing/std140-half-matrix-and-array.frag | 110 + ...grad.1d-as-2d.agx-cube-grad.msl23.asm.frag | 86 + ...-argument-buffer.argument-tier-1.msl2.comp | 28 + ...-argument-buffer.argument-tier-1.msl2.comp | 28 + ...-argument-buffer.argument-tier-1.msl2.comp | 25 + .../shaders-msl/comp/atomic-image.comp | 56 + .../shaders-msl/comp/atomic-image.msl31.comp | 56 + .../comp/coherent-image-atomic.comp | 20 + .../coherent-image-atomic.msl2.argument.comp | 20 + .../comp/coherent-image-atomic.msl2.comp | 20 + .../coherent-image-atomic.msl31.argument.comp | 20 + .../comp/coherent-image-atomic.msl31.comp | 20 + ...n_patch.replace-recursive-inputs.msl3.comp | 21 + .../shaders-msl/comp/shader_ballot.msl22.comp | 29 + .../comp/shader_group_vote.msl21.comp | 18 + ...ag-demote-checks.discard-checks.msl31.frag | 33 + ...s-continue-block.discard-checks.msl31.frag | 17 + ...g-discard-checks.discard-checks.msl31.frag | 32 + ...ixel-interlock-ordered.msl31.argument.frag | 36 + .../frag/pixel-interlock-ordered.msl31.frag | 36 + ....msl3.argument-tier-1.rich-descriptor.frag | 90 + ....msl3.argument-tier-1.rich-descriptor.frag | 15 + .../frag/sampler-cube-grad.agx-cube-grad.frag | 10 + ...ad-patch-vertices-in-func.raw-tess-in.tese | 12 + .../block-undef.noeliminate.invalid.asm.comp | 34 + ...-chained-access.spv16.asm.nocompat.vk.comp | 67 + ...inter-to-plain-struct.asm.nocompat.vk.comp | 59 + ...40-std430-array.asm.spv16.nocompat.vk.comp | 54 + ...ed-pointer-to-pointer.asm.nocompat.vk.comp | 46 + .../comp/empty-ubo-block.noeliminate.asm.comp | 21 + ...comp => local-size-id.vk.invalid.asm.comp} | 0 ...ly-read-with-initializer.asm.invalid.comp} | 0 ...le-early-read-with-undef.asm.invalid.comp} | 0 ...sample-mask-load-store-array-uint.asm.frag | 40 + .../sample-mask-load-store-array.asm.frag | 45 + ...thmetic-cast.nocompat.vk.asm.invalid.frag} | 0 ...sition-dx-style.vk.nocompat.spv14.asm.mesh | 151 + ...hader-clip-cull.vk.nocompat.spv14.asm.mesh | 104 + ...shader-perprimitive.spv14.nocompat.vk.frag | 10 + ...riant-position-mesh.spv14.nocompat.vk.mesh | 18 + .../vulkan/comp/image-64bit.vk.nocompat.comp | 16 + ...-shader-basic-lines.spv14.vk.nocompat.mesh | 1 + ...shader-basic-points.spv14.vk.nocompat.mesh | 1 + ...ader-basic-triangle.spv14.vk.nocompat.mesh | 1 + .../tese/read-patch-vertices-in-func.tese | 12 + .../shaders/vulkan/frag/block-match-sad.frag | 38 + .../shaders/vulkan/frag/block-match-ssd.frag | 38 + .../shaders/vulkan/frag/box-filter.frag | 32 + .../shaders/vulkan/frag/sample-weighted.frag | 32 + third_party/spirv-cross/spirv.h | 13 + third_party/spirv-cross/spirv.hpp | 13 + third_party/spirv-cross/spirv_common.hpp | 34 +- third_party/spirv-cross/spirv_common.hpp.orig | 34 +- third_party/spirv-cross/spirv_cross.cpp | 214 +- third_party/spirv-cross/spirv_cross.hpp | 11 +- third_party/spirv-cross/spirv_cross.natvis | 39 + third_party/spirv-cross/spirv_cross_c.cpp | 32 + third_party/spirv-cross/spirv_cross_c.h | 9 +- .../spirv-cross/spirv_cross_containers.hpp | 1 + .../spirv_cross_error_handling.hpp | 5 + third_party/spirv-cross/spirv_glsl.cpp | 590 +- third_party/spirv-cross/spirv_glsl.cpp.orig | 603 +- third_party/spirv-cross/spirv_glsl.hpp | 23 +- third_party/spirv-cross/spirv_hlsl.cpp | 133 +- third_party/spirv-cross/spirv_hlsl.hpp | 7 +- third_party/spirv-cross/spirv_msl.cpp | 1591 +- third_party/spirv-cross/spirv_msl.hpp | 51 +- third_party/spirv-cross/spirv_parser.cpp | 55 +- third_party/spirv-cross/spirv_reflect.cpp | 12 +- third_party/spirv-cross/test_shaders.py | 104 +- third_party/spirv-cross/tnt/README.md | 14 + third_party/spirv-headers/BUILD.bazel | 7 + third_party/spirv-headers/BUILD.gn | 3 +- third_party/spirv-headers/CMakeLists.txt | 136 +- third_party/spirv-headers/FILAMENT_README.md | 5 - third_party/spirv-headers/LICENSE | 80 +- third_party/spirv-headers/README.md | 2 +- third_party/spirv-headers/SECURITY.md | 13 + .../spirv-headers/cmake/Config.cmake.in | 4 - .../{ => cmake}/SPIRV-Headers.pc.in | 3 +- .../spirv-headers/example/CMakeLists.txt | 4 - .../filament-specific-changes.patch | 27 - .../spirv-headers/include/spirv/spir-v.xml | 45 +- .../include/spirv/unified1/AMD_gcn_shader.h | 2 +- .../spirv/unified1/AMD_shader_ballot.h | 2 +- .../AMD_shader_explicit_vertex_parameter.h | 2 +- .../unified1/AMD_shader_trinary_minmax.h | 2 +- .../include/spirv/unified1/DebugInfo.h | 2 +- .../include/spirv/unified1/GLSL.std.450.h | 2 +- .../unified1/NonSemanticClspvReflection.h | 17 +- .../spirv/unified1/NonSemanticDebugBreak.h | 50 + .../spirv/unified1/NonSemanticDebugPrintf.h | 2 +- .../unified1/NonSemanticShaderDebugInfo100.h | 2 +- .../unified1/NonSemanticVkspReflection.h | 57 + .../include/spirv/unified1/OpenCL.std.h | 2 +- .../spirv/unified1/OpenCLDebugInfo100.h | 2 +- .../unified1/extinst.debuginfo.grammar.json | 2 +- .../extinst.glsl.std.450.grammar.json | 2 +- ...t.nonsemantic.clspvreflection.grammar.json | 78 +- ...xtinst.nonsemantic.debugbreak.grammar.json | 9 + ...semantic.shader.debuginfo.100.grammar.json | 2 +- ...st.nonsemantic.vkspreflection.grammar.json | 138 + .../extinst.opencl.debuginfo.100.grammar.json | 2 +- .../extinst.opencl.std.100.grammar.json | 2 +- .../include/spirv/unified1/spirv.bf | 485 +- .../spirv/unified1/spirv.core.grammar.json | 5604 +++++-- .../include/spirv/unified1/spirv.cs | 485 +- .../include/spirv/unified1/spirv.h | 2446 ++- .../include/spirv/unified1/spirv.hpp | 2466 ++- .../include/spirv/unified1/spirv.hpp11 | 2546 +++- .../include/spirv/unified1/spirv.json | 436 +- .../include/spirv/unified1/spirv.lua | 464 +- .../include/spirv/unified1/spirv.py | 407 +- .../include/spirv/unified1/spv.d | 485 +- .../spirv-headers/tests/CMakeLists.txt | 54 + third_party/spirv-headers/tests/example.c | 37 + .../{example => tests}/example.cpp | 14 +- third_party/spirv-headers/tests/example11.cpp | 41 + .../tests/find_package/CMakeLists.txt | 23 + .../tests/pkg_config/CMakeLists.txt | 23 + .../bin/generate_language_headers.py | 4 +- .../buildHeaders/bin/makeExtinstHeaders.py | 2 + .../tools/buildHeaders/bin/makeHeaders | 2 + .../tools/buildHeaders/header.cpp | 186 +- .../spirv-headers/tools/buildHeaders/header.h | 2 +- .../tools/buildHeaders/jsonToSpirv.cpp | 347 +- .../tools/buildHeaders/jsonToSpirv.h | 53 +- .../spirv-headers/tools/buildHeaders/main.cpp | 2 +- third_party/spirv-tools/Android.mk | 17 +- third_party/spirv-tools/BUILD.bazel | 676 +- third_party/spirv-tools/BUILD.gn | 88 +- third_party/spirv-tools/CHANGES | 226 +- third_party/spirv-tools/CMakeLists.txt | 154 +- third_party/spirv-tools/CONTRIBUTING.md | 126 +- third_party/spirv-tools/DEPS | 22 +- third_party/spirv-tools/FILAMENT_README.md | 20 - third_party/spirv-tools/MODULE.bazel | 33 + third_party/spirv-tools/README.md | 76 +- third_party/spirv-tools/SECURITY.md | 13 + third_party/spirv-tools/WORKSPACE | 14 +- .../spirv-tools/android_test/Android.mk | 2 +- .../android_test/jni/Application.mk | 2 +- third_party/spirv-tools/build_defs.bzl | 432 +- third_party/spirv-tools/docs/downloads.md | 39 +- third_party/spirv-tools/docs/projects.md | 4 +- .../spirv-tools/external/CMakeLists.txt | 30 +- .../filament-specific-changes.patch | 162 - third_party/spirv-tools/filament-update.sh | 54 - .../include/spirv-tools/instrument.hpp | 268 - .../include/spirv-tools/libspirv.h | 134 + .../include/spirv-tools/libspirv.hpp | 45 +- .../include/spirv-tools/linker.hpp | 43 +- .../include/spirv-tools/linter.hpp | 4 +- .../include/spirv-tools/optimizer.hpp | 163 +- .../spirv-tools/kokoro/android/build.sh | 0 .../spirv-tools/kokoro/check-format/build.sh | 5 + .../kokoro/linux-clang-asan/build.sh | 0 .../kokoro/linux-clang-debug/build.sh | 0 .../kokoro/linux-clang-release-bazel/build.sh | 0 .../kokoro/linux-clang-release/build.sh | 0 .../kokoro/linux-gcc-debug/build.sh | 0 .../kokoro/linux-gcc-release/build.sh | 0 .../kokoro/macos-clang-debug/build.sh | 1 - .../kokoro/macos-clang-release-bazel/build.sh | 23 +- .../kokoro/macos-clang-release/build.sh | 1 - .../spirv-tools/kokoro/ndk-build/build.sh | 0 .../kokoro/scripts/linux/build-docker.sh | 50 +- .../spirv-tools/kokoro/scripts/linux/build.sh | 27 +- .../spirv-tools/kokoro/scripts/macos/build.sh | 12 +- .../kokoro/scripts/windows/build.bat | 41 +- .../kokoro/shaderc-smoketest/build.sh | 0 .../windows-msvc-2015-release-bazel/build.bat | 59 - .../presubmit.cfg | 16 - .../windows-msvc-2015-release/presubmit.cfg | 16 - .../windows-msvc-2017-release-bazel/build.bat | 57 - .../continuous.cfg | 16 - .../presubmit.cfg | 16 - .../windows-msvc-2017-release/build.bat | 24 - .../build.bat | 4 +- .../continuous.cfg | 4 +- .../presubmit.cfg | 4 +- .../build.bat | 4 +- .../continuous.cfg | 4 +- .../presubmit.cfg | 4 +- .../build.bat | 4 +- .../continuous.cfg | 10 +- .../presubmit.cfg | 4 +- third_party/spirv-tools/source/CMakeLists.txt | 46 +- .../spirv-tools/source/assembly_grammar.cpp | 21 +- third_party/spirv-tools/source/binary.cpp | 56 +- third_party/spirv-tools/source/cfa.h | 2 + .../spirv-tools/source/diff/CMakeLists.txt | 5 +- third_party/spirv-tools/source/diff/diff.cpp | 181 +- .../spirv-tools/source/disassemble.cpp | 670 +- third_party/spirv-tools/source/disassemble.h | 46 +- third_party/spirv-tools/source/enum_set.h | 560 +- third_party/spirv-tools/source/ext_inst.cpp | 11 +- third_party/spirv-tools/source/extensions.cpp | 5 +- third_party/spirv-tools/source/extensions.h | 3 +- .../spirv-tools/source/fuzz/CMakeLists.txt | 5 +- .../fuzz/protobufs/spirvfuzz_protobufs.h | 6 + ...ormation_add_no_contraction_decoration.cpp | 5 + .../transformation_add_relaxed_decoration.cpp | 6 + third_party/spirv-tools/source/libspirv.cpp | 34 + .../spirv-tools/source/link/CMakeLists.txt | 5 +- .../spirv-tools/source/link/linker.cpp | 157 +- .../spirv-tools/source/lint/CMakeLists.txt | 5 +- .../spirv-tools/source/name_mapper.cpp | 27 +- third_party/spirv-tools/source/opcode.cpp | 100 +- third_party/spirv-tools/source/opcode.h | 6 + third_party/spirv-tools/source/operand.cpp | 151 +- third_party/spirv-tools/source/operand.h | 8 +- .../spirv-tools/source/opt/CMakeLists.txt | 24 +- .../opt/aggressive_dead_code_elim_pass.cpp | 52 +- .../spirv-tools/source/opt/basic_block.cpp | 2 - .../source/opt/block_merge_pass.cpp | 3 - .../source/opt/block_merge_util.cpp | 11 + .../spirv-tools/source/opt/build_module.h | 4 +- .../spirv-tools/source/opt/ccp_pass.cpp | 1 - .../source/opt/cfg_cleanup_pass.cpp | 4 - .../spirv-tools/source/opt/code_sink.cpp | 2 - .../source/opt/const_folding_rules.cpp | 392 +- .../spirv-tools/source/opt/constants.cpp | 50 +- .../spirv-tools/source/opt/constants.h | 11 + .../source/opt/control_dependence.cpp | 2 - .../source/opt/convert_to_half_pass.cpp | 37 +- .../source/opt/convert_to_half_pass.h | 10 +- .../opt/convert_to_sampled_image_pass.cpp | 7 +- .../source/opt/copy_prop_arrays.cpp | 160 +- .../spirv-tools/source/opt/copy_prop_arrays.h | 17 +- .../spirv-tools/source/opt/dataflow.cpp | 1 - .../source/opt/dead_branch_elim_pass.cpp | 1 - .../source/opt/dead_insert_elim_pass.cpp | 3 +- .../source/opt/debug_info_manager.cpp | 20 +- .../source/opt/decoration_manager.cpp | 11 +- .../source/opt/decoration_manager.h | 9 +- .../spirv-tools/source/opt/def_use_manager.h | 22 - .../spirv-tools/source/opt/desc_sroa.cpp | 56 +- .../spirv-tools/source/opt/desc_sroa.h | 19 +- .../spirv-tools/source/opt/desc_sroa_util.cpp | 51 +- .../spirv-tools/source/opt/desc_sroa_util.h | 4 + .../opt/eliminate_dead_constant_pass.cpp | 1 - .../opt/eliminate_dead_functions_util.cpp | 4 +- .../opt/eliminate_dead_io_components_pass.cpp | 2 - .../opt/eliminate_dead_members_pass.cpp | 20 + .../opt/eliminate_dead_output_stores_pass.cpp | 15 +- .../opt/eliminate_dead_output_stores_pass.h | 6 - .../source/opt/feature_manager.cpp | 22 +- .../spirv-tools/source/opt/feature_manager.h | 47 +- .../source/opt/fix_storage_class.cpp | 62 +- third_party/spirv-tools/source/opt/fold.cpp | 128 +- third_party/spirv-tools/source/opt/fold.h | 8 + ...ld_spec_constant_op_and_composite_pass.cpp | 38 +- .../spirv-tools/source/opt/folding_rules.cpp | 380 +- .../spirv-tools/source/opt/function.cpp | 2 - .../opt/graphics_robust_access_pass.cpp | 12 +- .../spirv-tools/source/opt/inline_pass.cpp | 13 + .../source/opt/inst_bindless_check_pass.cpp | 845 -- .../source/opt/inst_bindless_check_pass.h | 209 - .../source/opt/inst_buff_addr_check_pass.cpp | 500 - .../source/opt/inst_buff_addr_check_pass.h | 135 - .../source/opt/inst_debug_printf_pass.cpp | 265 - .../source/opt/inst_debug_printf_pass.h | 95 - .../spirv-tools/source/opt/instruction.cpp | 28 +- .../spirv-tools/source/opt/instruction.h | 12 +- .../source/opt/instrument_pass.cpp | 1191 -- .../spirv-tools/source/opt/instrument_pass.h | 489 - .../source/opt/interface_var_sroa.h | 4 - .../source/opt/interp_fixup_pass.cpp | 1 - .../invocation_interlock_placement_pass.cpp | 493 + .../opt/invocation_interlock_placement_pass.h | 158 + .../spirv-tools/source/opt/ir_builder.h | 25 +- .../spirv-tools/source/opt/ir_context.cpp | 93 +- .../spirv-tools/source/opt/ir_context.h | 76 +- .../spirv-tools/source/opt/ir_loader.cpp | 10 +- .../spirv-tools/source/opt/licm_pass.cpp | 3 +- .../spirv-tools/source/opt/liveness.cpp | 108 +- third_party/spirv-tools/source/opt/liveness.h | 25 +- .../opt/local_access_chain_convert_pass.cpp | 92 +- .../opt/local_single_block_elim_pass.cpp | 121 +- .../opt/local_single_store_elim_pass.cpp | 117 +- third_party/spirv-tools/source/opt/log.h | 27 +- .../source/opt/loop_dependence.cpp | 2 - .../source/opt/loop_dependence_helpers.cpp | 4 +- .../source/opt/loop_descriptor.cpp | 26 +- .../spirv-tools/source/opt/loop_descriptor.h | 8 +- .../spirv-tools/source/opt/loop_fission.cpp | 1 + .../source/opt/loop_fusion_pass.cpp | 1 - .../spirv-tools/source/opt/loop_peeling.cpp | 5 +- .../spirv-tools/source/opt/loop_unroller.cpp | 1 - .../source/opt/loop_unswitch_pass.cpp | 2 - .../spirv-tools/source/opt/mem_pass.cpp | 10 +- .../opt/modify_maximal_reconvergence.cpp | 103 + .../source/opt/modify_maximal_reconvergence.h | 53 + third_party/spirv-tools/source/opt/module.h | 9 + .../opt/opextinst_forward_ref_fixup_pass.cpp | 112 + .../opt/opextinst_forward_ref_fixup_pass.h | 48 + .../spirv-tools/source/opt/optimizer.cpp | 364 +- third_party/spirv-tools/source/opt/pass.cpp | 105 +- third_party/spirv-tools/source/opt/pass.h | 3 +- third_party/spirv-tools/source/opt/passes.h | 9 +- third_party/spirv-tools/source/opt/reflect.h | 22 +- .../source/opt/remove_duplicates_pass.cpp | 3 - ...remove_unused_interface_variables_pass.cpp | 8 +- .../remove_unused_interface_variables_pass.h | 7 +- .../source/opt/replace_invalid_opc.cpp | 3 +- .../source/opt/scalar_analysis.cpp | 1 - .../opt/scalar_analysis_simplification.cpp | 5 +- .../source/opt/scalar_replacement_pass.cpp | 169 +- .../source/opt/scalar_replacement_pass.h | 17 + .../set_spec_constant_default_value_pass.cpp | 2 - .../source/opt/simplification_pass.cpp | 1 - .../source/opt/spread_volatile_semantics.cpp | 1 - .../source/opt/ssa_rewrite_pass.cpp | 1 - .../source/opt/strength_reduction_pass.cpp | 4 - .../source/opt/strip_debug_info_pass.cpp | 2 +- .../opt/strip_nonsemantic_info_pass.cpp | 3 +- .../source/opt/struct_packing_pass.cpp | 482 + .../source/opt/struct_packing_pass.h | 81 + .../source/opt/switch_descriptorset_pass.cpp | 46 + .../source/opt/switch_descriptorset_pass.h | 52 + .../source/opt/trim_capabilities_pass.cpp | 734 + .../source/opt/trim_capabilities_pass.h | 214 + .../spirv-tools/source/opt/type_manager.cpp | 214 +- .../spirv-tools/source/opt/type_manager.h | 15 +- third_party/spirv-tools/source/opt/types.cpp | 163 +- third_party/spirv-tools/source/opt/types.h | 161 +- .../source/opt/unify_const_pass.cpp | 1 - .../spirv-tools/source/parsed_operand.cpp | 1 + third_party/spirv-tools/source/print.cpp | 33 +- .../spirv-tools/source/reduce/CMakeLists.txt | 5 +- .../spirv-tools/source/spirv_target_env.cpp | 142 +- .../spirv-tools/source/spirv_target_env.h | 7 + .../source/spirv_validator_options.cpp | 5 + .../source/spirv_validator_options.h | 2 + third_party/spirv-tools/source/table.cpp | 1 + third_party/spirv-tools/source/table.h | 6 +- third_party/spirv-tools/source/text.cpp | 26 +- .../spirv-tools/source/text_handler.cpp | 3 +- third_party/spirv-tools/source/to_string.cpp | 44 + third_party/spirv-tools/source/to_string.h | 29 + .../spirv-tools/source/util/bitutils.h | 27 +- .../spirv-tools/source/util/hex_float.h | 75 +- .../spirv-tools/source/util/small_vector.h | 16 +- .../spirv-tools/source/val/basic_block.cpp | 1 - .../spirv-tools/source/val/construct.cpp | 1 - .../spirv-tools/source/val/decoration.h | 11 + .../spirv-tools/source/val/function.cpp | 1 - third_party/spirv-tools/source/val/function.h | 3 +- .../spirv-tools/source/val/instruction.h | 5 +- .../spirv-tools/source/val/validate.cpp | 18 +- third_party/spirv-tools/source/val/validate.h | 35 +- .../source/val/validate_adjacency.cpp | 15 +- .../source/val/validate_annotation.cpp | 58 +- .../source/val/validate_arithmetics.cpp | 330 +- .../source/val/validate_atomics.cpp | 93 +- .../source/val/validate_barriers.cpp | 3 - .../source/val/validate_bitwise.cpp | 21 +- .../source/val/validate_builtins.cpp | 588 +- .../source/val/validate_capability.cpp | 4 +- .../spirv-tools/source/val/validate_cfg.cpp | 141 +- .../source/val/validate_composites.cpp | 63 +- .../source/val/validate_constants.cpp | 21 +- .../source/val/validate_conversion.cpp | 177 +- .../spirv-tools/source/val/validate_debug.cpp | 4 +- .../source/val/validate_decorations.cpp | 628 +- .../source/val/validate_derivatives.cpp | 34 +- .../val/validate_execution_limitations.cpp | 2 - .../source/val/validate_extensions.cpp | 589 +- .../source/val/validate_function.cpp | 167 +- .../spirv-tools/source/val/validate_id.cpp | 63 +- .../spirv-tools/source/val/validate_image.cpp | 464 +- .../source/val/validate_instruction.cpp | 40 +- .../source/val/validate_interfaces.cpp | 148 +- .../source/val/validate_layout.cpp | 9 +- .../source/val/validate_literals.cpp | 5 +- .../source/val/validate_logicals.cpp | 8 +- .../source/val/validate_memory.cpp | 1557 +- .../source/val/validate_memory_semantics.cpp | 6 +- .../source/val/validate_mesh_shading.cpp | 49 + .../spirv-tools/source/val/validate_misc.cpp | 20 +- .../source/val/validate_mode_setting.cpp | 330 +- .../source/val/validate_non_uniform.cpp | 375 +- .../source/val/validate_primitives.cpp | 4 +- .../source/val/validate_ray_query.cpp | 94 + .../val/validate_ray_tracing_reorder.cpp | 107 + .../source/val/validate_scopes.cpp | 11 +- .../source/val/validate_tensor_layout.cpp | 184 + .../spirv-tools/source/val/validate_type.cpp | 359 +- .../source/val/validation_state.cpp | 475 +- .../spirv-tools/source/val/validation_state.h | 103 +- third_party/spirv-tools/source/wasm/build.sh | 11 +- .../{ => source/wasm}/docker-compose.yml | 2 +- third_party/spirv-tools/test/CMakeLists.txt | 29 +- .../spirv-tools/test/binary_parse_test.cpp | 305 +- .../test/binary_to_text.literal_test.cpp | 2 + .../spirv-tools/test/binary_to_text_test.cpp | 2135 ++- .../OpExtInst_in_src_only_autogen.cpp | 6 +- .../test/diff/diff_files/basic_autogen.cpp | 10 +- .../constant_array_size_autogen.cpp | 4 +- .../diff_files/diff_test_files_autogen.cmake | 1 + ...different_decorations_fragment_autogen.cpp | 44 +- .../different_decorations_vertex_autogen.cpp | 71 +- ...erent_function_parameter_count_autogen.cpp | 34 +- .../diff_files/extra_if_block_autogen.cpp | 68 +- .../int_vs_uint_constants_autogen.cpp | 6 +- .../multiple_same_entry_points_autogen.cpp | 9 +- .../diff_files/ray_query_types_autogen.cpp | 148 + .../diff_files/ray_query_types_dst.spvasm | 18 + .../diff_files/ray_query_types_src.spvasm | 16 + .../reordered_if_blocks_autogen.cpp | 6 +- .../reordered_switch_blocks_autogen.cpp | 6 +- .../spec_constant_array_size_autogen.cpp | 20 +- .../spirv-tools/test/diff/diff_test.cpp | 1 - .../spirv-tools/test/diff/diff_test_utils.cpp | 1 - .../spirv-tools/test/enum_set_test.cpp | 811 +- .../test/ext_inst.non_semantic_test.cpp | 3 +- .../spirv-tools/test/fuzz/CMakeLists.txt | 3 +- .../spirv-tools/test/fuzz/fuzz_test_util.cpp | 2 +- .../transformation_add_dead_block_test.cpp | 5 + .../transformation_add_dead_break_test.cpp | 10 + ...ion_add_no_contraction_decoration_test.cpp | 8 +- .../transformation_add_opphi_synonym_test.cpp | 6 +- ...sformation_add_relaxed_decoration_test.cpp | 6 +- .../transformation_add_type_float_test.cpp | 2 +- .../fuzz/transformation_add_type_int_test.cpp | 4 +- .../spirv-tools/test/hex_float_test.cpp | 197 +- .../spirv-tools/test/hex_to_text_test.cpp | 429 + .../spirv-tools/test/immediate_int_test.cpp | 34 +- .../test/link/binary_version_test.cpp | 16 + .../link/matching_imports_to_exports_test.cpp | 500 +- third_party/spirv-tools/test/log_test.cpp | 53 - .../test/opcode_require_capabilities_test.cpp | 29 +- .../test/operand_capabilities_test.cpp | 172 +- .../spirv-tools/test/opt/CMakeLists.txt | 19 +- .../opt/aggressive_dead_code_elim_test.cpp | 448 +- .../spirv-tools/test/opt/amd_ext_to_khr.cpp | 21 +- .../test/opt/analyze_live_input_test.cpp | 1 - .../spirv-tools/test/opt/block_merge_test.cpp | 142 + .../spirv-tools/test/opt/c_interface_test.cpp | 534 + third_party/spirv-tools/test/opt/ccp_test.cpp | 1 - .../spirv-tools/test/opt/code_sink_test.cpp | 1 - .../test/opt/combine_access_chains_test.cpp | 2 - .../spirv-tools/test/opt/compact_ids_test.cpp | 1 - .../test/opt/constant_manager_test.cpp | 2 - .../spirv-tools/test/opt/constants_test.cpp | 1 - .../test/opt/convert_relaxed_to_half_test.cpp | 212 + .../test/opt/copy_prop_array_test.cpp | 205 +- third_party/spirv-tools/test/opt/dataflow.cpp | 1 - .../test/opt/dead_insert_elim_test.cpp | 107 + .../test/opt/debug_info_manager_test.cpp | 81 +- .../test/opt/decoration_manager_test.cpp | 1 - .../spirv-tools/test/opt/def_use_test.cpp | 1 - .../spirv-tools/test/opt/desc_sroa_test.cpp | 295 +- .../opt/dominator_tree/common_dominators.cpp | 2 - .../test/opt/dominator_tree/generated.cpp | 1 - .../test/opt/dominator_tree/nested_ifs.cpp | 2 - .../opt/dominator_tree/nested_ifs_post.cpp | 1 - .../test/opt/dominator_tree/nested_loops.cpp | 1 - .../nested_loops_with_unreachables.cpp | 1 - .../test/opt/dominator_tree/post.cpp | 1 - .../test/opt/dominator_tree/simple.cpp | 1 - .../switch_case_fallthrough.cpp | 1 - .../opt/dominator_tree/unreachable_for.cpp | 1 - .../dominator_tree/unreachable_for_post.cpp | 1 - .../test/opt/eliminate_dead_const_test.cpp | 3 - .../opt/eliminate_dead_functions_test.cpp | 33 + .../opt/eliminate_dead_io_components_test.cpp | 1 - .../test/opt/eliminate_dead_member_test.cpp | 1 - .../opt/eliminate_dead_output_stores_test.cpp | 1 - .../test/opt/feature_manager_test.cpp | 39 +- .../test/opt/fix_func_call_arguments_test.cpp | 1 - .../test/opt/fix_storage_class_test.cpp | 160 +- .../test/opt/flatten_decoration_test.cpp | 1 - .../opt/fold_spec_const_op_composite_test.cpp | 130 +- .../spirv-tools/test/opt/fold_test.cpp | 1743 ++- .../test/opt/freeze_spec_const_test.cpp | 1 - .../spirv-tools/test/opt/function_test.cpp | 2 - .../test/opt/graphics_robust_access_test.cpp | 2 - .../test/opt/if_conversion_test.cpp | 2 - .../spirv-tools/test/opt/inline_test.cpp | 55 +- .../test/opt/inst_bindless_check_test.cpp | 5639 ------- .../test/opt/inst_buff_addr_check_test.cpp | 557 - .../test/opt/inst_debug_printf_test.cpp | 226 - .../spirv-tools/test/opt/instruction_test.cpp | 4 +- .../test/opt/interface_var_sroa_test.cpp | 2 - .../invocation_interlock_placement_test.cpp | 613 + .../spirv-tools/test/opt/ir_builder.cpp | 6 +- .../spirv-tools/test/opt/ir_context_test.cpp | 345 +- .../spirv-tools/test/opt/ir_loader_test.cpp | 1 - .../opt/local_access_chain_convert_test.cpp | 50 + .../opt/local_redundancy_elimination_test.cpp | 2 - .../test/opt/local_single_block_elim.cpp | 43 + .../test/opt/local_single_store_elim_test.cpp | 102 + .../opt/loop_optimizations/CMakeLists.txt | 1 + .../dependence_analysis.cpp | 6 - .../dependence_analysis_helpers.cpp | 6 - .../fusion_compatibility.cpp | 3 - .../opt/loop_optimizations/fusion_illegal.cpp | 3 - .../opt/loop_optimizations/fusion_legal.cpp | 3 - .../hoist_access_chains.cpp | 157 + .../test/opt/loop_optimizations/lcssa.cpp | 2 - .../loop_optimizations/loop_descriptions.cpp | 1 - .../opt/loop_optimizations/loop_fission.cpp | 6 +- .../test/opt/loop_optimizations/peeling.cpp | 1 - .../opt/loop_optimizations/peeling_pass.cpp | 1 - .../loop_optimizations/unroll_assumptions.cpp | 1 - .../opt/loop_optimizations/unroll_simple.cpp | 19 +- .../opt/modify_maximal_reconvergence_test.cpp | 312 + .../spirv-tools/test/opt/module_test.cpp | 6 +- .../spirv-tools/test/opt/module_utils.h | 1 + .../opextinst_forward_ref_fixup_pass_test.cpp | 338 + .../test/opt/pass_merge_return_test.cpp | 2 - .../test/opt/pass_remove_duplicates_test.cpp | 2 - .../test/opt/private_to_local_test.cpp | 1 - .../spirv-tools/test/opt/propagator_test.cpp | 7 +- .../test/opt/redundancy_elimination_test.cpp | 2 - .../test/opt/register_liveness.cpp | 1 - .../test/opt/relax_float_ops_test.cpp | 1 - ...remove_unused_interface_variables_test.cpp | 1 - ...desc_array_access_using_var_index_test.cpp | 2 - .../test/opt/replace_invalid_opc_test.cpp | 34 +- .../spirv-tools/test/opt/scalar_analysis.cpp | 8 +- .../test/opt/scalar_replacement_test.cpp | 52 +- .../test/opt/simplification_test.cpp | 1 - .../opt/spread_volatile_semantics_test.cpp | 7 +- .../test/opt/strength_reduction_test.cpp | 5 - .../test/opt/struct_cfg_analysis_test.cpp | 1 - .../test/opt/struct_packing_test.cpp | 242 + .../test/opt/switch_descriptorset_test.cpp | 193 + .../test/opt/trim_capabilities_pass_test.cpp | 3320 ++++ .../test/opt/type_manager_test.cpp | 63 +- .../spirv-tools/test/opt/types_test.cpp | 9 +- .../test/opt/upgrade_memory_model_test.cpp | 1 - .../spirv-tools/test/opt/value_table_test.cpp | 1 - .../test/opt/workaround1209_test.cpp | 6 - .../spirv-tools/test/opt/wrap_opkill_test.cpp | 1 - .../spirv-tools/test/reduce/CMakeLists.txt | 1 + .../test/scripts/test_compact_ids.py | 4 +- .../spirv-tools/test/target_env_test.cpp | 65 +- third_party/spirv-tools/test/test_fixture.h | 6 +- .../test/text_to_binary.annotation_test.cpp | 24 +- .../test/text_to_binary.composite_test.cpp | 3 +- .../test/text_to_binary.extension_test.cpp | 184 +- .../test/text_to_binary.memory_test.cpp | 84 +- .../test/text_to_binary.pipe_storage_test.cpp | 6 +- .../text_to_binary.type_declaration_test.cpp | 2 + .../spirv-tools/test/to_string_test.cpp | 28 + .../spirv-tools/test/tools/CMakeLists.txt | 14 +- .../spirv-tools/test/tools/flags_test.cpp | 415 + .../tools/objdump/CMakeLists.txt} | 15 +- .../tools/objdump/extract_source_test.cpp | 265 + .../spirv-tools/test/tools/opt/CMakeLists.txt | 4 +- third_party/spirv-tools/test/unit_spirv.h | 5 +- .../spirv-tools/test/util/bitutils_test.cpp | 40 + .../spirv-tools/test/val/CMakeLists.txt | 1 + .../test/val/val_annotation_test.cpp | 209 +- .../test/val/val_arithmetics_test.cpp | 559 +- .../spirv-tools/test/val/val_atomics_test.cpp | 270 +- .../test/val/val_barriers_test.cpp | 42 +- .../spirv-tools/test/val/val_bitwise_test.cpp | 26 + .../test/val/val_builtins_test.cpp | 1224 +- .../spirv-tools/test/val/val_cfg_test.cpp | 571 +- .../test/val/val_composites_test.cpp | 276 +- .../test/val/val_constants_test.cpp | 16 + .../test/val/val_conversion_test.cpp | 547 +- .../spirv-tools/test/val/val_data_test.cpp | 1 - .../test/val/val_decoration_test.cpp | 1607 +- .../test/val/val_derivatives_test.cpp | 9 +- .../test/val/val_ext_inst_debug_test.cpp | 1854 +-- .../test/val/val_ext_inst_test.cpp | 854 +- ...xtension_spv_khr_bit_instructions_test.cpp | 3 - ...l_extension_spv_khr_expect_assume_test.cpp | 3 - ...nsion_spv_khr_integer_dot_product_test.cpp | 5 +- ...al_extension_spv_khr_linkonce_odr_test.cpp | 3 - ..._spv_khr_subgroup_uniform_control_flow.cpp | 110 + ...khr_subgroup_uniform_control_flow_test.cpp | 3 - ...sion_spv_khr_terminate_invocation_test.cpp | 3 - ...val_extension_spv_nv_raw_access_chains.cpp | 510 + .../test/val/val_extensions_test.cpp | 251 +- .../spirv-tools/test/val/val_fixtures.h | 8 +- .../test/val/val_function_test.cpp | 109 +- .../spirv-tools/test/val/val_id_test.cpp | 330 +- .../spirv-tools/test/val/val_image_test.cpp | 4602 +++++- .../test/val/val_interfaces_test.cpp | 291 +- .../spirv-tools/test/val/val_layout_test.cpp | 9 - .../spirv-tools/test/val/val_limits_test.cpp | 1 - .../spirv-tools/test/val/val_memory_test.cpp | 3426 ++++- .../test/val/val_mesh_shading_test.cpp | 385 +- .../spirv-tools/test/val/val_misc_test.cpp | 163 +- .../spirv-tools/test/val/val_modes_test.cpp | 1459 +- .../test/val/val_non_uniform_test.cpp | 741 +- .../test/val/val_ray_query_test.cpp | 95 +- .../test/val/val_ray_tracing_reorder_test.cpp | 200 +- .../test/val/val_ray_tracing_test.cpp | 89 + .../spirv-tools/test/val/val_state_test.cpp | 6 +- .../spirv-tools/test/val/val_storage_test.cpp | 6 +- .../test/val/val_type_unique_test.cpp | 42 + .../spirv-tools/test/val/val_version_test.cpp | 36 +- third_party/spirv-tools/tools/CMakeLists.txt | 57 +- third_party/spirv-tools/tools/as/as.cpp | 145 +- third_party/spirv-tools/tools/cfg/cfg.cpp | 100 +- third_party/spirv-tools/tools/diff/diff.cpp | 173 +- third_party/spirv-tools/tools/dis/dis.cpp | 199 +- third_party/spirv-tools/tools/fuzz/fuzz.cpp | 20 +- third_party/spirv-tools/tools/io.cpp | 476 + third_party/spirv-tools/tools/io.h | 180 +- third_party/spirv-tools/tools/link/linker.cpp | 122 +- third_party/spirv-tools/tools/lint/lint.cpp | 81 +- .../tools/objdump/extract_source.cpp | 213 + .../tools/objdump/extract_source.h | 39 + .../spirv-tools/tools/objdump/objdump.cpp | 174 + third_party/spirv-tools/tools/opt/opt.cpp | 38 +- .../spirv-tools/tools/reduce/reduce.cpp | 15 +- .../spirv-tools/tools/sva/package.json | 10 +- .../spirv-tools/tools/sva/src/spirv.data.js | 3 + third_party/spirv-tools/tools/sva/yarn.lock | 2258 ++- third_party/spirv-tools/tools/util/flags.cpp | 243 + third_party/spirv-tools/tools/util/flags.h | 262 + third_party/spirv-tools/tools/val/val.cpp | 11 +- .../spirv-tools/utils/check_code_format.sh | 2 +- .../spirv-tools/utils/check_copyright.py | 9 +- .../spirv-tools/utils/check_symbol_exports.py | 4 +- .../spirv-tools/utils/fixup_fuzz_result.py | 2 +- .../spirv-tools/utils/generate_changelog.py | 98 + .../utils/generate_grammar_tables.py | 80 +- .../utils/generate_language_headers.py | 2 +- .../utils/generate_registry_tables.py | 18 +- third_party/spirv-tools/utils/git-sync-deps | 128 +- third_party/spirv-tools/utils/roll_deps.sh | 35 +- .../spirv-tools/utils/update_build_version.py | 139 +- third_party/spirv-tools/utils/vim/README.md | 87 + .../generate_syntax.py} | 8 +- .../spirv-tools/utils/vscode/README.md | 5 +- .../spirv-tools/utils/vscode/build_lsp.sh | 28 + .../{install.bat => install_vscode.bat} | 0 .../vscode/{install.sh => install_vscode.sh} | 0 .../spirv-tools/utils/vscode/spirv.json | 138 +- .../spirv-tools/utils/vscode/src/langsvr.go | 58 +- .../utils/vscode/src/schema/schema.go | 12508 ++++++++++++++-- 1242 files changed, 95189 insertions(+), 28682 deletions(-) create mode 100644 third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.msl31.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_group_vote.msl21.comp create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese create mode 100644 third_party/spirv-cross/reference/opt/shaders/frag/block-match-sad.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/frag/block-match-ssd.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/frag/box-filter.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/frag/sample-weighted.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/tese/read-patch-vertices-in-func.tese create mode 100644 third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-sad.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-ssd.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/vulkan/frag/box-filter.frag create mode 100644 third_party/spirv-cross/reference/opt/shaders/vulkan/frag/sample-weighted.frag rename third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/{local-size-id.asm.comp => local-size-id.asm.invalid.comp} (55%) create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp create mode 100644 third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh create mode 100644 third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp delete mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag rename third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/{subgroup-arithmetic-cast.msl21.asm.frag => subgroup-arithmetic-cast.msl21.asm.invalid.frag} (100%) create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/comp/extract-atomics-from-function.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.msl31.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/shader_ballot.msl22.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/comp/shader_group_vote.msl21.comp create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag create mode 100644 third_party/spirv-cross/reference/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp delete mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp.vk delete mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp delete mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag rename third_party/spirv-cross/reference/shaders-no-opt/asm/frag/{subgroup-arithmetic-cast.nocompat.vk.asm.frag.vk => subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag.vk} (100%) create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh.vk create mode 100644 third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp.vk create mode 100644 third_party/spirv-cross/reference/shaders/frag/block-match-sad.frag create mode 100644 third_party/spirv-cross/reference/shaders/frag/block-match-ssd.frag create mode 100644 third_party/spirv-cross/reference/shaders/frag/box-filter.frag create mode 100644 third_party/spirv-cross/reference/shaders/frag/sample-weighted.frag create mode 100644 third_party/spirv-cross/reference/shaders/tese/read-patch-vertices-in-func.tese create mode 100644 third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-sad.frag create mode 100644 third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-ssd.frag create mode 100644 third_party/spirv-cross/reference/shaders/vulkan/frag/box-filter.frag create mode 100644 third_party/spirv-cross/reference/shaders/vulkan/frag/sample-weighted.frag rename third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/{local-size-id.asm.comp => local-size-id.asm.invalid.comp} (100%) create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp create mode 100644 third_party/spirv-cross/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh create mode 100644 third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp rename third_party/spirv-cross/shaders-msl-no-opt/asm/comp/{local-size-id.asm.comp => local-size-id.asm.invalid.comp} (100%) create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag rename third_party/spirv-cross/shaders-msl-no-opt/asm/frag/{subgroup-arithmetic-cast.msl21.asm.frag => subgroup-arithmetic-cast.msl21.asm.invalid.frag} (100%) create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/comp/extract-atomics-from-function.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag create mode 100644 third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag create mode 100644 third_party/spirv-cross/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag create mode 100644 third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/atomic-image.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/atomic-image.msl31.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/shader_ballot.msl22.comp create mode 100644 third_party/spirv-cross/shaders-msl/comp/shader_group_vote.msl21.comp create mode 100644 third_party/spirv-cross/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag create mode 100644 third_party/spirv-cross/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag create mode 100644 third_party/spirv-cross/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp rename third_party/spirv-cross/shaders-no-opt/asm/comp/{local-size-id.vk.asm.comp => local-size-id.vk.invalid.asm.comp} (100%) rename third_party/spirv-cross/shaders-no-opt/asm/comp/{loop-variable-early-read-with-initializer.asm.comp => loop-variable-early-read-with-initializer.asm.invalid.comp} (100%) rename third_party/spirv-cross/shaders-no-opt/asm/comp/{loop-variable-early-read-with-undef.asm.comp => loop-variable-early-read-with-undef.asm.invalid.comp} (100%) create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag rename third_party/spirv-cross/shaders-no-opt/asm/frag/{subgroup-arithmetic-cast.nocompat.vk.asm.frag => subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag} (100%) create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh create mode 100644 third_party/spirv-cross/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh create mode 100644 third_party/spirv-cross/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag create mode 100644 third_party/spirv-cross/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh create mode 100644 third_party/spirv-cross/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp create mode 100644 third_party/spirv-cross/shaders/tese/read-patch-vertices-in-func.tese create mode 100644 third_party/spirv-cross/shaders/vulkan/frag/block-match-sad.frag create mode 100644 third_party/spirv-cross/shaders/vulkan/frag/block-match-ssd.frag create mode 100644 third_party/spirv-cross/shaders/vulkan/frag/box-filter.frag create mode 100644 third_party/spirv-cross/shaders/vulkan/frag/sample-weighted.frag create mode 100644 third_party/spirv-cross/spirv_cross.natvis delete mode 100644 third_party/spirv-headers/FILAMENT_README.md create mode 100644 third_party/spirv-headers/SECURITY.md delete mode 100644 third_party/spirv-headers/cmake/Config.cmake.in rename third_party/spirv-headers/{ => cmake}/SPIRV-Headers.pc.in (65%) delete mode 100644 third_party/spirv-headers/example/CMakeLists.txt delete mode 100644 third_party/spirv-headers/filament-specific-changes.patch create mode 100644 third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugBreak.h create mode 100644 third_party/spirv-headers/include/spirv/unified1/NonSemanticVkspReflection.h create mode 100644 third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugbreak.grammar.json create mode 100644 third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.vkspreflection.grammar.json create mode 100644 third_party/spirv-headers/tests/CMakeLists.txt create mode 100644 third_party/spirv-headers/tests/example.c rename third_party/spirv-headers/{example => tests}/example.cpp (94%) create mode 100644 third_party/spirv-headers/tests/example11.cpp create mode 100644 third_party/spirv-headers/tests/find_package/CMakeLists.txt create mode 100644 third_party/spirv-headers/tests/pkg_config/CMakeLists.txt mode change 100755 => 100644 third_party/spirv-tools/CMakeLists.txt delete mode 100644 third_party/spirv-tools/FILAMENT_README.md create mode 100644 third_party/spirv-tools/MODULE.bazel create mode 100644 third_party/spirv-tools/SECURITY.md delete mode 100644 third_party/spirv-tools/filament-specific-changes.patch delete mode 100644 third_party/spirv-tools/filament-update.sh delete mode 100644 third_party/spirv-tools/include/spirv-tools/instrument.hpp mode change 100644 => 100755 third_party/spirv-tools/kokoro/android/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-clang-asan/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-clang-debug/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-clang-release-bazel/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-clang-release/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-gcc-debug/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/linux-gcc-release/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/ndk-build/build.sh mode change 100644 => 100755 third_party/spirv-tools/kokoro/shaderc-smoketest/build.sh delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/presubmit.cfg delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2015-release/presubmit.cfg delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/build.bat delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/continuous.cfg delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/presubmit.cfg delete mode 100644 third_party/spirv-tools/kokoro/windows-msvc-2017-release/build.bat rename third_party/spirv-tools/kokoro/{windows-msvc-2013-release => windows-msvc-2019-release}/build.bat (95%) rename third_party/spirv-tools/kokoro/{windows-msvc-2017-release => windows-msvc-2019-release}/continuous.cfg (86%) rename third_party/spirv-tools/kokoro/{windows-msvc-2017-release => windows-msvc-2019-release}/presubmit.cfg (85%) rename third_party/spirv-tools/kokoro/{windows-msvc-2017-debug => windows-msvc-2022-debug}/build.bat (88%) rename third_party/spirv-tools/kokoro/{windows-msvc-2017-debug => windows-msvc-2022-debug}/continuous.cfg (86%) rename third_party/spirv-tools/kokoro/{windows-msvc-2017-debug => windows-msvc-2022-debug}/presubmit.cfg (85%) rename third_party/spirv-tools/kokoro/{windows-msvc-2015-release => windows-msvc-2022-release}/build.bat (95%) rename third_party/spirv-tools/kokoro/{windows-msvc-2015-release => windows-msvc-2022-release}/continuous.cfg (78%) rename third_party/spirv-tools/kokoro/{windows-msvc-2013-release => windows-msvc-2022-release}/presubmit.cfg (85%) delete mode 100644 third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp delete mode 100644 third_party/spirv-tools/source/opt/inst_bindless_check_pass.h delete mode 100644 third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.cpp delete mode 100644 third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.h delete mode 100644 third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp delete mode 100644 third_party/spirv-tools/source/opt/inst_debug_printf_pass.h delete mode 100644 third_party/spirv-tools/source/opt/instrument_pass.cpp delete mode 100644 third_party/spirv-tools/source/opt/instrument_pass.h create mode 100644 third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.cpp create mode 100644 third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.h create mode 100644 third_party/spirv-tools/source/opt/modify_maximal_reconvergence.cpp create mode 100644 third_party/spirv-tools/source/opt/modify_maximal_reconvergence.h create mode 100644 third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.cpp create mode 100644 third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.h create mode 100644 third_party/spirv-tools/source/opt/struct_packing_pass.cpp create mode 100644 third_party/spirv-tools/source/opt/struct_packing_pass.h create mode 100644 third_party/spirv-tools/source/opt/switch_descriptorset_pass.cpp create mode 100644 third_party/spirv-tools/source/opt/switch_descriptorset_pass.h create mode 100644 third_party/spirv-tools/source/opt/trim_capabilities_pass.cpp create mode 100644 third_party/spirv-tools/source/opt/trim_capabilities_pass.h create mode 100644 third_party/spirv-tools/source/to_string.cpp create mode 100644 third_party/spirv-tools/source/to_string.h create mode 100644 third_party/spirv-tools/source/val/validate_tensor_layout.cpp rename third_party/spirv-tools/{ => source/wasm}/docker-compose.yml (84%) create mode 100644 third_party/spirv-tools/test/diff/diff_files/ray_query_types_autogen.cpp create mode 100644 third_party/spirv-tools/test/diff/diff_files/ray_query_types_dst.spvasm create mode 100644 third_party/spirv-tools/test/diff/diff_files/ray_query_types_src.spvasm create mode 100644 third_party/spirv-tools/test/hex_to_text_test.cpp delete mode 100644 third_party/spirv-tools/test/log_test.cpp create mode 100644 third_party/spirv-tools/test/opt/c_interface_test.cpp delete mode 100644 third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp delete mode 100644 third_party/spirv-tools/test/opt/inst_buff_addr_check_test.cpp delete mode 100644 third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp create mode 100644 third_party/spirv-tools/test/opt/invocation_interlock_placement_test.cpp create mode 100644 third_party/spirv-tools/test/opt/loop_optimizations/hoist_access_chains.cpp create mode 100644 third_party/spirv-tools/test/opt/modify_maximal_reconvergence_test.cpp create mode 100644 third_party/spirv-tools/test/opt/opextinst_forward_ref_fixup_pass_test.cpp create mode 100644 third_party/spirv-tools/test/opt/struct_packing_test.cpp create mode 100644 third_party/spirv-tools/test/opt/switch_descriptorset_test.cpp create mode 100644 third_party/spirv-tools/test/opt/trim_capabilities_pass_test.cpp create mode 100644 third_party/spirv-tools/test/to_string_test.cpp create mode 100644 third_party/spirv-tools/test/tools/flags_test.cpp rename third_party/spirv-tools/{kokoro/windows-msvc-2015-release-bazel/continuous.cfg => test/tools/objdump/CMakeLists.txt} (53%) create mode 100644 third_party/spirv-tools/test/tools/objdump/extract_source_test.cpp create mode 100644 third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow.cpp create mode 100644 third_party/spirv-tools/test/val/val_extension_spv_nv_raw_access_chains.cpp create mode 100644 third_party/spirv-tools/tools/io.cpp create mode 100644 third_party/spirv-tools/tools/objdump/extract_source.cpp create mode 100644 third_party/spirv-tools/tools/objdump/extract_source.h create mode 100644 third_party/spirv-tools/tools/objdump/objdump.cpp create mode 100644 third_party/spirv-tools/tools/util/flags.cpp create mode 100644 third_party/spirv-tools/tools/util/flags.h create mode 100644 third_party/spirv-tools/utils/generate_changelog.py create mode 100644 third_party/spirv-tools/utils/vim/README.md rename third_party/spirv-tools/utils/{generate_vim_syntax.py => vim/generate_syntax.py} (96%) create mode 100755 third_party/spirv-tools/utils/vscode/build_lsp.sh rename third_party/spirv-tools/utils/vscode/{install.bat => install_vscode.bat} (100%) rename third_party/spirv-tools/utils/vscode/{install.sh => install_vscode.sh} (100%) diff --git a/third_party/spirv-cross/.github/workflows/main.yml b/third_party/spirv-cross/.github/workflows/main.yml index d7efc683ff..c2e81cb58b 100644 --- a/third_party/spirv-cross/.github/workflows/main.yml +++ b/third_party/spirv-cross/.github/workflows/main.yml @@ -26,15 +26,24 @@ jobs: with: python-version: '3.x' + - name: Cache glslang / SPIRV-Tools + id: cache-externals + uses: actions/cache@v3 + with: + path: external/*-build/output + key: ${{ matrix.platform }} externals ${{ hashFiles('checkout_glslang_spirv_tools.sh', 'build_glslang_spirv_tools.sh') }} + - name: Pull glslang / SPIRV-Tools + if: steps.cache-externals.outputs.cache-hit != 'true' shell: bash working-directory: ${{github.workspace}} run: ./checkout_glslang_spirv_tools.sh - name: Build glslang / SPIRV-Tools + if: steps.cache-externals.outputs.cache-hit != 'true' shell: bash working-directory: ${{github.workspace}} - run: ./build_glslang_spirv_tools.sh Release + run: ./build_glslang_spirv_tools.sh Release 4 - name: Configure SPIRV-Cross shell: bash @@ -47,7 +56,7 @@ jobs: shell: bash working-directory: ${{github.workspace}}/build run: | - cmake --build . --config Release + cmake --build . --config Release --parallel 4 cmake --build . --config Release --target install - uses: actions/upload-artifact@v3 diff --git a/third_party/spirv-cross/.gitignore b/third_party/spirv-cross/.gitignore index 8e91b32a38..3eea4d1569 100644 --- a/third_party/spirv-cross/.gitignore +++ b/third_party/spirv-cross/.gitignore @@ -4,6 +4,7 @@ *.o *.d *.txt +/build /test /spirv-cross /obj @@ -20,5 +21,8 @@ .vs/ *.vcxproj.user +# Mac OS X Finder +.DS_Store + !CMakeLists.txt !LICENSES/*.txt diff --git a/third_party/spirv-cross/CMakeLists.txt b/third_party/spirv-cross/CMakeLists.txt index dbf85d5d9f..f6019ab266 100644 --- a/third_party/spirv-cross/CMakeLists.txt +++ b/third_party/spirv-cross/CMakeLists.txt @@ -19,7 +19,7 @@ # 2. The MIT License, found at . # -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.6) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) @@ -77,7 +77,7 @@ set(spirv-cross-build-version "unknown") find_package(Git) if (GIT_FOUND) execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty=+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE spirv-cross-build-version ERROR_QUIET @@ -243,7 +243,7 @@ set(spirv-cross-util-sources ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.hpp) set(spirv-cross-abi-major 0) -set(spirv-cross-abi-minor 57) +set(spirv-cross-abi-minor 59) set(spirv-cross-abi-patch 0) set(SPIRV_CROSS_VERSION ${spirv-cross-abi-major}.${spirv-cross-abi-minor}.${spirv-cross-abi-patch}) @@ -465,7 +465,19 @@ if (SPIRV_CROSS_CLI) # - Update the reference files # - Get cycle counts from malisc # - Keep failing outputs - find_package(PythonInterp) + if (${CMAKE_VERSION} VERSION_GREATER "3.12") + find_package(Python3) + if (${PYTHON3_FOUND}) + set(PYTHONINTERP_FOUND ON) + set(PYTHON_VERSION_MAJOR 3) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + else() + set(PYTHONINTERP_FOUND OFF) + endif() + else() + find_package(PythonInterp) + endif() + find_program(spirv-cross-glslang NAMES glslangValidator PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/glslang-build/output/bin NO_DEFAULT_PATH) diff --git a/third_party/spirv-cross/build_glslang_spirv_tools.sh b/third_party/spirv-cross/build_glslang_spirv_tools.sh index f78640f35b..e25aa98e9c 100644 --- a/third_party/spirv-cross/build_glslang_spirv_tools.sh +++ b/third_party/spirv-cross/build_glslang_spirv_tools.sh @@ -15,7 +15,7 @@ fi echo "Building glslang." mkdir -p external/glslang-build cd external/glslang-build -cmake ../glslang -DCMAKE_BUILD_TYPE=$PROFILE -DCMAKE_INSTALL_PREFIX=output +cmake ../glslang -DCMAKE_BUILD_TYPE=$PROFILE -DCMAKE_INSTALL_PREFIX=output -DENABLE_OPT=OFF cmake --build . --config $PROFILE --target install ${NPROC} cd ../.. diff --git a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh index 8842939583..10d20b0a58 100755 --- a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh +++ b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh @@ -2,9 +2,9 @@ # Copyright 2016-2021 The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 -GLSLANG_REV=06a7078ce74ab5c7801a165b8145859678831fb8 -SPIRV_TOOLS_REV=f62e121b0df5374d1f043d1fbda98467406af0b1 -SPIRV_HEADERS_REV=d13b52222c39a7e9a401b44646f0ca3a640fbd47 +GLSLANG_REV=a7785ea1ff5b10bfc2d8ca77fdad5929562897b7 +SPIRV_TOOLS_REV=afaf8fda2ad0364655909b56c8b634ce89095bb5 +SPIRV_HEADERS_REV=e867c06631767a2d96424cbec530f9ee5e78180f PROTOCOL=https if [ -d external/glslang ]; then diff --git a/third_party/spirv-cross/main.cpp b/third_party/spirv-cross/main.cpp index 5e9b0168c9..7e14f11020 100644 --- a/third_party/spirv-cross/main.cpp +++ b/third_party/spirv-cross/main.cpp @@ -676,6 +676,10 @@ struct CLIArguments bool msl_manual_helper_invocation_updates = true; bool msl_check_discarded_frag_stores = false; bool msl_sample_dref_lod_array_as_grad = false; + bool msl_runtime_array_rich_descriptor = false; + bool msl_replace_recursive_inputs = false; + bool msl_readwrite_texture_fences = true; + bool msl_agx_manual_cube_grad_fixup = false; const char *msl_combined_sampler_suffix = nullptr; bool glsl_emit_push_constant_as_ubo = false; bool glsl_emit_ubo_as_plain_uniforms = false; @@ -864,7 +868,9 @@ static void print_help_msl() "\t\tRequires MSL 2.0 to be enabled.\n" "\t[--msl-argument-buffer-tier]:\n\t\tWhen using Metal argument buffers, indicate the Metal argument buffer tier level supported by the Metal platform.\n" "\t\tUses same values as Metal MTLArgumentBuffersTier enumeration (0 = Tier1, 1 = Tier2).\n" - "\t\tSetting this value also enables msl-argument-buffers.\n" + "\t\tNOTE: Setting this value no longer enables msl-argument-buffers implicitly.\n" + "\t[--msl-runtime-array-rich-descriptor]:\n\t\tWhen declaring a runtime array of SSBOs, declare an array of {ptr, len} pairs to support OpArrayLength.\n" + "\t[--msl-replace-recursive-inputs]:\n\t\tWorks around a Metal 3.1 regression bug, which causes an infinite recursion crash during Metal's analysis of an entry point input structure that itself contains internal recursion.\n" "\t[--msl-texture-buffer-native]:\n\t\tEnable native support for texel buffers. Otherwise, it is emulated as a normal texture.\n" "\t[--msl-framebuffer-fetch]:\n\t\tImplement subpass inputs with frame buffer fetch.\n" "\t\tEmits [[color(N)]] inputs in fragment stage.\n" @@ -954,6 +960,14 @@ static void print_help_msl() "\t\tSome Metal devices have a bug where the level() argument to\n" "\t\tdepth2d_array::sample_compare() in a fragment shader is biased by some\n" "\t\tunknown amount. This prevents the bias from being added.\n" + "\t[--msl-no-readwrite-texture-fences]:\n\t\tDo not insert fences before each read of a\n" + "\t\tread_write texture. MSL does not guarantee coherence between writes and later reads\n" + "\t\tof read_write textures. If you don't rely on this, you can disable this for a\n" + "\t\tpossible performance improvement.\n" + "\t[--msl-agx-manual-cube-grad-fixup]:\n\t\tManually transform cube texture gradients.\n" + "\t\tAll released Apple Silicon GPUs to date ignore one of the three partial derivatives\n" + "\t\tbased on the selected major axis, and expect the remaining derivatives to be\n" + "\t\tpartially transformed. This fixup gives correct results on Apple Silicon.\n" "\t[--msl-combined-sampler-suffix ]:\n\t\tUses a custom suffix for combined samplers.\n"); // clang-format on } @@ -1230,6 +1244,10 @@ static string compile_iteration(const CLIArguments &args, std::vector msl_opts.check_discarded_frag_stores = args.msl_check_discarded_frag_stores; msl_opts.sample_dref_lod_array_as_grad = args.msl_sample_dref_lod_array_as_grad; msl_opts.ios_support_base_vertex_instance = true; + msl_opts.runtime_array_rich_descriptor = args.msl_runtime_array_rich_descriptor; + msl_opts.replace_recursive_inputs = args.msl_replace_recursive_inputs; + msl_opts.readwrite_texture_fences = args.msl_readwrite_texture_fences; + msl_opts.agx_manual_cube_grad_fixup = args.msl_agx_manual_cube_grad_fixup; msl_comp->set_msl_options(msl_opts); for (auto &v : args.msl_discrete_descriptor_sets) msl_comp->add_discrete_descriptor_set(v); @@ -1636,10 +1654,8 @@ static int main_inner(int argc, char *argv[]) cbs.add("--msl-pad-fragment-output", [&args](CLIParser &) { args.msl_pad_fragment_output = true; }); cbs.add("--msl-domain-lower-left", [&args](CLIParser &) { args.msl_domain_lower_left = true; }); cbs.add("--msl-argument-buffers", [&args](CLIParser &) { args.msl_argument_buffers = true; }); - cbs.add("--msl-argument-buffer-tier", [&args](CLIParser &parser) { - args.msl_argument_buffers_tier = parser.next_uint(); - args.msl_argument_buffers = true; - }); + cbs.add("--msl-argument-buffer-tier", + [&args](CLIParser &parser) { args.msl_argument_buffers_tier = parser.next_uint(); }); cbs.add("--msl-discrete-descriptor-set", [&args](CLIParser &parser) { args.msl_discrete_descriptor_sets.push_back(parser.next_uint()); }); cbs.add("--msl-device-argument-buffer", @@ -1786,9 +1802,15 @@ static int main_inner(int argc, char *argv[]) cbs.add("--msl-check-discarded-frag-stores", [&args](CLIParser &) { args.msl_check_discarded_frag_stores = true; }); cbs.add("--msl-sample-dref-lod-array-as-grad", [&args](CLIParser &) { args.msl_sample_dref_lod_array_as_grad = true; }); + cbs.add("--msl-no-readwrite-texture-fences", [&args](CLIParser &) { args.msl_readwrite_texture_fences = false; }); + cbs.add("--msl-agx-manual-cube-grad-fixup", [&args](CLIParser &) { args.msl_agx_manual_cube_grad_fixup = true; }); cbs.add("--msl-combined-sampler-suffix", [&args](CLIParser &parser) { args.msl_combined_sampler_suffix = parser.next_string(); }); + cbs.add("--msl-runtime-array-rich-descriptor", + [&args](CLIParser &) { args.msl_runtime_array_rich_descriptor = true; }); + cbs.add("--msl-replace-recursive-inputs", + [&args](CLIParser &) { args.msl_replace_recursive_inputs = true; }); 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(); diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp index b8265fc99e..9e3b90fa6d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp @@ -1,15 +1,15 @@ -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - uint _21 = _4.Load(_4.Load(0) * 4 + 4); - for (uint _23 = 0u; _23 < 64u; ) + uint _21 = _6.Load(_6.Load(0) * 4 + 4); + for (uint _40 = 0u; _40 < 64u; ) { - _4.Store(_23 * 4 + 4, 0u); - _23++; + _6.Store(_40 * 4 + 4, 0u); + _40++; continue; } - _4.Store(_4.Load(0) * 4 + 4, _21); + _6.Store(_6.Load(0) * 4 + 4, _21); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp index c534ceaba1..0f56123d87 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp @@ -9,9 +9,9 @@ struct SPIRV_Cross_Input void comp_main() { - uint _29; - u0_counter.InterlockedAdd(0, -1, _29); - u0[asint(asfloat(_29))] = uint(int(gl_GlobalInvocationID.x)).x; + uint _24; + u0_counter.InterlockedAdd(0, -1, _24); + u0[asint(asfloat(_24))] = uint(int(gl_GlobalInvocationID.x)).x; } [numthreads(4, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp index 5e7d282d6e..bf1fdebe55 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp @@ -9,9 +9,9 @@ struct SPIRV_Cross_Input void comp_main() { - uint _29; - u0_counter.InterlockedAdd(0, 1, _29); - u0[asint(asfloat(_29))] = uint(int(gl_GlobalInvocationID.x)).x; + uint _24; + u0_counter.InterlockedAdd(0, 1, _24); + u0[asint(asfloat(_24))] = uint(int(gl_GlobalInvocationID.x)).x; } [numthreads(4, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag index b410010d22..b51bc9cc64 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag @@ -1,26 +1,26 @@ -cbuffer _4_5 : register(b0) +cbuffer _6_7 : register(b0) { - column_major float2x4 _5_m0 : packoffset(c0); - float4 _5_m1 : packoffset(c4); + column_major float2x4 _7_m0 : packoffset(c0); + float4 _7_m1 : packoffset(c4); }; -static float2 _3; +static float2 _4; struct SPIRV_Cross_Output { - float2 _3 : SV_Target0; + float2 _4 : SV_Target0; }; void frag_main() { - _3 = mul(_5_m0, _5_m1); + _4 = mul(_7_m0, _7_m1); } SPIRV_Cross_Output main() { frag_main(); SPIRV_Cross_Output stage_output; - stage_output._3 = _3; + stage_output._4 = _4; return stage_output; } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag index 2527d10fdc..0f858d2175 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag @@ -17,9 +17,9 @@ uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) void frag_main() { + uint _18_dummy_parameter; uint _19_dummy_parameter; - uint _20_dummy_parameter; - Size = int2(spvTextureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _20_dummy_parameter)); + Size = int2(spvTextureSize(uTexture, uint(0), _18_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _19_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag index 67f14fccae..a991b64cd8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag @@ -17,22 +17,22 @@ struct SPIRV_Cross_Output void frag_main() { float phi; - float4 _36; - int _51; - _51 = 0; + float4 _45; + int _57; + _57 = 0; phi = 1.0f; - _36 = float4(1.0f, 2.0f, 1.0f, 2.0f); + _45 = float4(1.0f, 2.0f, 1.0f, 2.0f); for (;;) { - FragColor = _36; - if (_51 < 4) + FragColor = _45; + if (_57 < 4) { - if (v0[_51] > 0.0f) + if (v0[_57] > 0.0f) { - float2 _48 = phi.xx; - _51++; + float2 _43 = phi.xx; + _57++; phi += 2.0f; - _36 = uImage.SampleLevel(_uImage_sampler, _48, 0.0f); + _45 = uImage.SampleLevel(_uImage_sampler, _43, 0.0f); continue; } else diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag index 4a1cf2ee54..413e17c8e5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag @@ -30,14 +30,14 @@ void frag_main() FragColor = 4.0f; } #line 19 "test.frag" - for (int _127 = 0; float(_127) < (40.0f + vColor); ) + for (int _131 = 0; float(_131) < (40.0f + vColor); ) { #line 21 "test.frag" FragColor += 0.20000000298023223876953125f; #line 22 "test.frag" FragColor += 0.300000011920928955078125f; #line 19 "test.frag" - _127 += (int(vColor) + 5); + _131 += (int(vColor) + 5); continue; } #line 25 "test.frag" diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag index 5deae3a569..c17bc403d2 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag @@ -1,6 +1,6 @@ -static const float _46[16] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f }; -static const float4 _76[4] = { 0.0f.xxxx, 1.0f.xxxx, 8.0f.xxxx, 5.0f.xxxx }; -static const float4 _90[4] = { 20.0f.xxxx, 30.0f.xxxx, 50.0f.xxxx, 60.0f.xxxx }; +static const float _16[16] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f }; +static const float4 _60[4] = { 0.0f.xxxx, 1.0f.xxxx, 8.0f.xxxx, 5.0f.xxxx }; +static const float4 _104[4] = { 20.0f.xxxx, 30.0f.xxxx, 50.0f.xxxx, 60.0f.xxxx }; static float FragColor; static int index; @@ -17,34 +17,34 @@ struct SPIRV_Cross_Output void frag_main() { - float4 foobar[4] = _76; - float4 baz[4] = _76; - FragColor = _46[index]; + float4 foobar[4] = _60; + float4 baz[4] = _60; + FragColor = _16[index]; if (index < 10) { - FragColor += _46[index ^ 1]; + FragColor += _16[index ^ 1]; } else { - FragColor += _46[index & 1]; + FragColor += _16[index & 1]; } - bool _99 = index > 30; - if (_99) + bool _63 = index > 30; + if (_63) { - FragColor += _76[index & 3].y; + FragColor += _60[index & 3].y; } else { - FragColor += _76[index & 1].x; + FragColor += _60[index & 1].x; } - if (_99) + if (_63) { foobar[1].z = 20.0f; } - int _37 = index & 3; - FragColor += foobar[_37].z; - baz = _90; - FragColor += baz[_37].z; + int _91 = index & 3; + FragColor += foobar[_91].z; + baz = _104; + FragColor += baz[_91].z; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag index 4a024c8ef1..9f51a1d6d1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -13,21 +13,21 @@ struct SPIRV_Cross_Output void frag_main() { - float4 _33; + float4 _46; for (;;) { if (counter == 10) { - _33 = 10.0f.xxxx; + _46 = 10.0f.xxxx; break; } else { - _33 = 30.0f.xxxx; + _46 = 30.0f.xxxx; break; } } - FragColor = _33; + FragColor = _46; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert index 3bccae3e0a..b09e78e8c1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert @@ -1,35 +1,35 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_201 #define SPIRV_CROSS_CONSTANT_ID_201 -10 #endif -static const int _7 = SPIRV_CROSS_CONSTANT_ID_201; -static const int _20 = (_7 + 2); +static const int _13 = SPIRV_CROSS_CONSTANT_ID_201; +static const int _15 = (_13 + 2); #ifndef SPIRV_CROSS_CONSTANT_ID_202 #define SPIRV_CROSS_CONSTANT_ID_202 100u #endif -static const uint _8 = SPIRV_CROSS_CONSTANT_ID_202; -static const uint _25 = (_8 % 5u); -static const int4 _30 = int4(20, 30, _20, _20); -static const int2 _32 = int2(_30.y, _30.x); -static const int _33 = _30.y; +static const uint _24 = SPIRV_CROSS_CONSTANT_ID_202; +static const uint _26 = (_24 % 5u); +static const int4 _36 = int4(20, 30, _15, _15); +static const int2 _41 = int2(_36.y, _36.x); +static const int _60 = _36.y; static float4 gl_Position; -static int _4; +static int _58; struct SPIRV_Cross_Output { - nointerpolation int _4 : TEXCOORD0; + nointerpolation int _58 : TEXCOORD0; float4 gl_Position : SV_Position; }; void vert_main() { float4 _63 = 0.0f.xxxx; - _63.y = float(_20); - _63.z = float(_25); - float4 _52 = _63 + float4(_30); - float2 _56 = _52.xy + float2(_32); - gl_Position = float4(_56.x, _56.y, _52.z, _52.w); - _4 = _33; + _63.y = float(_15); + _63.z = float(_26); + float4 _39 = _63 + float4(_36); + float2 _46 = _39.xy + float2(_41); + gl_Position = float4(_46.x, _46.y, _39.z, _39.w); + _58 = _60; } SPIRV_Cross_Output main() @@ -37,6 +37,6 @@ SPIRV_Cross_Output main() vert_main(); SPIRV_Cross_Output stage_output; stage_output.gl_Position = gl_Position; - stage_output._4 = _4; + stage_output._58 = _58; return stage_output; } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp new file mode 100644 index 0000000000..c3f5119b0a --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp @@ -0,0 +1,24 @@ +struct Data +{ + uint arr[3]; +}; + +static uint _33; + +RWByteAddressBuffer _13 : register(u0); + +void comp_main() +{ + uint _32[3] = { _33, _33, _33 }; + [unroll] + for (int _0ident = 0; _0ident < 3; _0ident++) + { + _13.Store(_0ident * 4 + 0, _32[_0ident]); + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in-and-out.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in-and-out.frag index 185a09821e..e2238828b2 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in-and-out.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in-and-out.frag @@ -1,5 +1,5 @@ -static int gl_SampleMaskIn; -static int gl_SampleMask; +static int gl_SampleMaskIn[1]; +static int gl_SampleMask[1]; static float4 FragColor; struct SPIRV_Cross_Input @@ -16,15 +16,15 @@ struct SPIRV_Cross_Output void frag_main() { FragColor = 1.0f.xxxx; - gl_SampleMask = gl_SampleMaskIn; + gl_SampleMask[0] = gl_SampleMaskIn[0]; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { - gl_SampleMaskIn = stage_input.gl_SampleMaskIn; + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; frag_main(); SPIRV_Cross_Output stage_output; - stage_output.gl_SampleMask = gl_SampleMask; + stage_output.gl_SampleMask = gl_SampleMask[0]; stage_output.FragColor = FragColor; return stage_output; } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in.frag index 8f6cfaf9e5..dfbe29b9c6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-in.frag @@ -1,5 +1,5 @@ static int gl_SampleID; -static int gl_SampleMaskIn; +static int gl_SampleMaskIn[1]; static float4 FragColor; struct SPIRV_Cross_Input @@ -15,7 +15,7 @@ struct SPIRV_Cross_Output void frag_main() { - if ((gl_SampleMaskIn & (1 << gl_SampleID)) != 0) + if ((gl_SampleMaskIn[0] & (1 << gl_SampleID)) != 0) { FragColor = 1.0f.xxxx; } @@ -24,7 +24,7 @@ void frag_main() SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { gl_SampleID = stage_input.gl_SampleID; - gl_SampleMaskIn = stage_input.gl_SampleMaskIn; + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; frag_main(); SPIRV_Cross_Output stage_output; stage_output.FragColor = FragColor; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-out.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-out.frag index a966c03218..14de570dfc 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-out.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/sample-mask-out.frag @@ -1,4 +1,4 @@ -static int gl_SampleMask; +static int gl_SampleMask[1]; static float4 FragColor; struct SPIRV_Cross_Output @@ -10,14 +10,14 @@ struct SPIRV_Cross_Output void frag_main() { FragColor = 1.0f.xxxx; - gl_SampleMask = 0; + gl_SampleMask[0] = 0; } SPIRV_Cross_Output main() { frag_main(); SPIRV_Cross_Output stage_output; - stage_output.gl_SampleMask = gl_SampleMask; + stage_output.gl_SampleMask = gl_SampleMask[0]; stage_output.FragColor = FragColor; return stage_output; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp index 513f8763a3..f51c0b3de5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp @@ -21,7 +21,7 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - uint _29 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); - u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_29)))); + uint _24 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); + u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_24)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp index 55c41374c3..c2da55f8af 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp @@ -21,7 +21,7 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - uint _29 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); - u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_29)))); + uint _24 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); + u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_24)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp index db0ade34b4..3935486a04 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp @@ -19,11 +19,11 @@ struct cb5_struct kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - uint _44 = as_type(as_type(int(gl_LocalInvocationID.x) << 4)) >> 2u; - uint4 _51 = as_type(cb0_5._m0[uint(as_type(as_type(int(gl_LocalInvocationID.x)))) + 1u]); - u0.write(_51.xxxx, spvTexelBufferCoord(_44)); - u0.write(_51.yyyy, spvTexelBufferCoord((_44 + 1u))); - u0.write(_51.zzzz, spvTexelBufferCoord((_44 + 2u))); - u0.write(_51.wwww, spvTexelBufferCoord((_44 + 3u))); + uint _41 = as_type(as_type(int(gl_LocalInvocationID.x) << 4)) >> 2u; + uint4 _50 = as_type(cb0_5._m0[uint(as_type(as_type(int(gl_LocalInvocationID.x)))) + 1u]); + u0.write(_50.xxxx, spvTexelBufferCoord(_41)); + u0.write(_50.yyyy, spvTexelBufferCoord((_41 + 1u))); + u0.write(_50.zzzz, spvTexelBufferCoord((_41 + 2u))); + u0.write(_50.wwww, spvTexelBufferCoord((_41 + 3u))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp index 89e8d83ea7..f464abf5c1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp @@ -17,8 +17,8 @@ struct cb float value; }; -kernel void main0(constant cb& _6 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +kernel void main0(constant cb& _8 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { - _buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); + _buffer.write(float4(_8.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp index 536556391e..346f40ee28 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp @@ -8,6 +8,7 @@ using namespace metal; static inline __attribute__((always_inline)) void _main(thread const uint3& id, texture2d TargetTexture) { + TargetTexture.fence(); float2 loaded = TargetTexture.read(uint2(id.xy)).xy; float2 storeTemp = loaded + float2(1.0); TargetTexture.write(storeTemp.xyyy, uint2((id.xy + uint2(1u)))); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp index 672c2b2088..461bf7b8b3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/quantize.asm.comp @@ -24,11 +24,11 @@ struct SSBO0 float4 vec4_val; }; -kernel void main0(device SSBO0& _4 [[buffer(0)]]) +kernel void main0(device SSBO0& _12 [[buffer(0)]]) { - _4.scalar = spvQuantizeToF16(_4.scalar); - _4.vec2_val = spvQuantizeToF16(_4.vec2_val); - _4.vec3_val = spvQuantizeToF16(_4.vec3_val); - _4.vec4_val = spvQuantizeToF16(_4.vec4_val); + _12.scalar = spvQuantizeToF16(_12.scalar); + _12.vec2_val = spvQuantizeToF16(_12.vec2_val); + _12.vec3_val = spvQuantizeToF16(_12.vec3_val); + _12.vec4_val = spvQuantizeToF16(_12.vec4_val); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/relaxed-block-layout.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/relaxed-block-layout.asm.comp index 6728a4e2d3..1464bd8e88 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/relaxed-block-layout.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/relaxed-block-layout.asm.comp @@ -12,11 +12,11 @@ struct foo packed_half2 wibble; }; -kernel void main0(device foo& _8 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]]) +kernel void main0(device foo& _10 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]]) { - _8.bar = gl_LocalInvocationID.x; - _8.baz = float3(gl_GlobalInvocationID); - _8.blah = uchar4(uint4(uint4(uchar4(_8.blah)).xyz + gl_WorkGroupID, 0u)); - _8.wibble = half2(float2(half2(_8.wibble)) * float2(gl_NumWorkGroups.xy)); + _10.bar = gl_LocalInvocationID.x; + _10.baz = float3(gl_GlobalInvocationID); + _10.blah = uchar4(uint4(uint4(uchar4(_10.blah)).xyz + gl_WorkGroupID, 0u)); + _10.wibble = half2(float2(half2(_10.wibble)) * float2(gl_NumWorkGroups.xy)); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp index 1e2880f4e8..eb13541c8b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp @@ -8,14 +8,14 @@ struct SSBO float a; }; -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 [[maybe_unused]] = uint3(_5, 20u, _6); +constant uint _19_tmp [[function_constant(10)]]; +constant uint _19 = is_function_constant_defined(_19_tmp) ? _19_tmp : 9u; +constant uint _21_tmp [[function_constant(12)]]; +constant uint _21 = is_function_constant_defined(_21_tmp) ? _21_tmp : 4u; +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_19, 20u, _21); -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - _4.a += 1.0; + _6.a += 1.0; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp index a276b400c0..fd34476a23 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp @@ -20,26 +20,26 @@ kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], bool _71 = cb.d != 0; device foo* _72 = _71 ? &buf : nullptr; device foo* _67 = _72; - device foo* _45 = _72; + device foo* _65 = _72; thread uint3* _79 = _71 ? &gl_GlobalInvocationID : &gl_LocalInvocationID; thread uint3* _74 = _79; + device int* _49; device int* _52; - device int* _55; - _52 = &_72->a[0u]; - _55 = &buf.a[0u]; - int _57; - int _58; + _49 = &_72->a[0u]; + _52 = &buf.a[0u]; + int _54; + int _55; for (;;) { - _57 = *_52; - _58 = *_55; - if (_57 != _58) + _54 = *_49; + _55 = *_52; + if (_54 != _55) { - int _66 = (_57 + _58) + int((*_79).x); - *_52 = _66; - *_55 = _66; + int _63 = (_54 + _55) + int((*_79).x); + *_49 = _63; + *_52 = _63; + _49 = &_49[1u]; _52 = &_52[1u]; - _55 = &_55[1u]; continue; } else diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp index afbcadd0b9..84aac2d46f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp @@ -12,14 +12,14 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 16u, 1u); kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - int2 _46 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); + int2 _37 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); int _98; _98 = 0; - for (; _98 < _46.y; _98++) + for (; _98 < _37.y; _98++) { - for (int _99 = 0; _99 < _46.x; ) + for (int _99 = 0; _99 < _37.x; ) { - u0.write(cb0_1._RESERVED_IDENTIFIER_FIXUP_m0[0].xxxx, uint2(((_46 * int3(gl_LocalInvocationID).xy) + int2(_98, _99)))); + u0.write(cb0_1._RESERVED_IDENTIFIER_FIXUP_m0[0].xxxx, uint2(((_37 * int3(gl_LocalInvocationID).xy) + int2(_98, _99)))); _99++; continue; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp index e572525ebd..19999fede1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp @@ -12,14 +12,14 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 16u, 1u); kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - int2 _40 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); + int2 _20 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); int _80; _80 = 0; - for (; _80 < _40.y; _80++) + for (; _80 < _20.y; _80++) { - for (int _81 = 0; _81 < _40.x; ) + for (int _81 = 0; _81 < _20.x; ) { - u0.write(cb0_1._RESERVED_IDENTIFIER_FIXUP_m0[0].xxxx, uint2(((_40 * int3(gl_LocalInvocationID).xy) + int2(_80, _81)))); + u0.write(cb0_1._RESERVED_IDENTIFIER_FIXUP_m0[0].xxxx, uint2(((_20 * int3(gl_LocalInvocationID).xy) + int2(_80, _81)))); _81++; continue; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag new file mode 100644 index 0000000000..090df2b2f3 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag @@ -0,0 +1,45 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) +{ + // Major axis selection + float3 absP = abs(P); + bool xMajor = absP.x >= max(absP.y, absP.z); + bool yMajor = absP.y >= absP.z; + float3 Q = xMajor ? P.yzx : (yMajor ? P.xzy : P); + float3 dQdx = xMajor ? dPdx.yzx : (yMajor ? dPdx.xzy : dPdx); + float3 dQdy = xMajor ? dPdy.yzx : (yMajor ? dPdy.xzy : dPdy); + + // Skip a couple of operations compared to usual projection + float4 d = float4(dQdx.xy, dQdy.xy) - (Q.xy / Q.z).xyxy * float4(dQdx.zz, dQdy.zz); + + // Final swizzle to put the intermediate values into non-ignored components + // X major: X and Z + // Y major: X and Y + // Z major: Y and Z + return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); +} + +struct main0_out +{ + float4 o_color [[color(0)]]; +}; + +struct main0_in +{ + float4 v_texCoord [[user(locn0)]]; + float2 v_drefLodBias [[user(locn1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depthcube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag index 58f02ad072..82cefddd7b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag @@ -3,46 +3,46 @@ using namespace metal; -struct _4 +struct _6 { float4 _m0; }; -struct _6 +struct _8 { int _m0; }; -struct _7 +struct _9 { float4 _m0; }; struct main0_out { - float4 m_3 [[color(0)]]; + float4 m_4 [[color(0)]]; }; -fragment main0_out main0(const device _4* _5_0 [[buffer(0)]], const device _4* _5_1 [[buffer(1)]], const device _4* _5_2 [[buffer(2)]], const device _4* _5_3 [[buffer(3)]], constant _6& _20 [[buffer(4)]], constant _7* _8_0 [[buffer(5)]], constant _7* _8_1 [[buffer(6)]], constant _7* _8_2 [[buffer(7)]], constant _7* _8_3 [[buffer(8)]]) +fragment main0_out main0(const device _6* _7_0 [[buffer(0)]], const device _6* _7_1 [[buffer(1)]], const device _6* _7_2 [[buffer(2)]], const device _6* _7_3 [[buffer(3)]], constant _8& _21 [[buffer(4)]], constant _9* _10_0 [[buffer(5)]], constant _9* _10_1 [[buffer(6)]], constant _9* _10_2 [[buffer(7)]], constant _9* _10_3 [[buffer(8)]]) { - const device _4* _5[] = + const device _6* _7[] = { - _5_0, - _5_1, - _5_2, - _5_3, + _7_0, + _7_1, + _7_2, + _7_3, }; - constant _7* _8[] = + constant _9* _10[] = { - _8_0, - _8_1, - _8_2, - _8_3, + _10_0, + _10_1, + _10_2, + _10_3, }; main0_out out = {}; - out.m_3 = fma(_8[_20._m0]->_m0, float4(0.20000000298023223876953125), _5[_20._m0]->_m0); + out.m_4 = fma(_10[_21._m0]->_m0, float4(0.20000000298023223876953125), _7[_21._m0]->_m0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag index 09f8ed8c0d..cc8e6ac95e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag @@ -20,11 +20,11 @@ struct main0_out float4 _entryPointOutput [[color(0)]]; }; -fragment main0_out main0(constant buf& _11 [[buffer(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant buf& _15 [[buffer(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - int _68 = int(gl_FragCoord.x) % 16; - out._entryPointOutput = float4(dot(float3(_11.results[_68].a), _11.bar.xyz), _11.results[_68].b, 0.0, 0.0); + int _70 = int(gl_FragCoord.x) % 16; + out._entryPointOutput = float4(dot(float3(_15.results[_70].a), _15.bar.xyz), _15.results[_70].b, 0.0, 0.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag index dd977a99da..b72c12f8bd 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag @@ -17,22 +17,22 @@ fragment main0_out main0(main0_in in [[stage_in]], texture2d uImage [[tex { main0_out out = {}; float phi; - float4 _36; - int _51; - _51 = 0; + float4 _45; + int _57; + _57 = 0; phi = 1.0; - _36 = float4(1.0, 2.0, 1.0, 2.0); + _45 = float4(1.0, 2.0, 1.0, 2.0); for (;;) { - out.FragColor = _36; - if (_51 < 4) + out.FragColor = _45; + if (_57 < 4) { - if (in.v0[_51] > 0.0) + if (in.v0[_57] > 0.0) { - float2 _48 = float2(phi); - _51++; + float2 _43 = float2(phi); + _57++; phi += 2.0; - _36 = uImage.sample(uImageSmplr, _48, level(0.0)); + _45 = uImage.sample(uImageSmplr, _43, level(0.0)); continue; } else diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag index 27b7d4771f..d7fac07cc3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag @@ -33,14 +33,14 @@ fragment main0_out main0(main0_in in [[stage_in]]) out.FragColor = 4.0; } #line 19 "test.frag" - for (int _127 = 0; float(_127) < (40.0 + in.vColor); ) + for (int _131 = 0; float(_131) < (40.0 + in.vColor); ) { #line 21 "test.frag" out.FragColor += 0.20000000298023223876953125; #line 22 "test.frag" out.FragColor += 0.300000011920928955078125; #line 19 "test.frag" - _127 += (int(in.vColor) + 5); + _131 += (int(in.vColor) + 5); continue; } #line 25 "test.frag" diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag index 07ab82ac1f..191adb4972 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag @@ -10,23 +10,23 @@ struct main0_out struct main0_in { - float2 m_2 [[user(locn1)]]; - float m_3 [[user(locn1_2)]]; - float m_4 [[user(locn2), flat]]; - uint m_5 [[user(locn2_1)]]; - uint m_6 [[user(locn2_2)]]; + float2 m_8 [[user(locn1)]]; + float m_16 [[user(locn1_2)]]; + float m_22 [[user(locn2), flat]]; + uint m_28 [[user(locn2_1)]]; + uint m_33 [[user(locn2_2)]]; }; fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; float4 v1; - v1 = float4(in.m_2.x, in.m_2.y, v1.z, v1.w); - v1.z = in.m_3; + v1 = float4(in.m_8.x, in.m_8.y, v1.z, v1.w); + v1.z = in.m_16; float4 v2; - v2.x = in.m_4; - v2.y = as_type(in.m_5); - v2.z = as_type(in.m_6); + v2.x = in.m_22; + v2.y = as_type(in.m_28); + v2.z = as_type(in.m_33); out.o0.y = float(as_type(as_type(as_type(v2.y) + as_type(v2.z)))); out.o0.x = v1.y + v2.x; out.o0 = float4(out.o0.x, out.o0.y, v1.z, v1.x); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag index 726976631a..d9851b6628 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag @@ -44,9 +44,9 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _46 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 }); -constant spvUnsafeArray _76 = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); -constant spvUnsafeArray _90 = spvUnsafeArray({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) }); +constant spvUnsafeArray _16 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 }); +constant spvUnsafeArray _60 = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); +constant spvUnsafeArray _104 = spvUnsafeArray({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) }); struct main0_out { @@ -63,32 +63,32 @@ fragment main0_out main0(main0_in in [[stage_in]]) spvUnsafeArray foobar = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); spvUnsafeArray baz = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); main0_out out = {}; - out.FragColor = _46[in.index]; + out.FragColor = _16[in.index]; if (in.index < 10) { - out.FragColor += _46[in.index ^ 1]; + out.FragColor += _16[in.index ^ 1]; } else { - out.FragColor += _46[in.index & 1]; + out.FragColor += _16[in.index & 1]; } - bool _99 = in.index > 30; - if (_99) + bool _63 = in.index > 30; + if (_63) { - out.FragColor += _76[in.index & 3].y; + out.FragColor += _60[in.index & 3].y; } else { - out.FragColor += _76[in.index & 1].x; + out.FragColor += _60[in.index & 1].x; } - if (_99) + if (_63) { foobar[1].z = 20.0; } - int _37 = in.index & 3; - out.FragColor += foobar[_37].z; - baz = _90; - out.FragColor += baz[_37].z; + int _91 = in.index & 3; + out.FragColor += foobar[_91].z; + baz = _104; + out.FragColor += baz[_91].z; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag index 6a6b1622d2..da79768b03 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag @@ -154,24 +154,24 @@ fragment main0_out main0(main0_in in [[stage_in]], uint gl_SampleID [[sample_id] out.FragColor.x += in.s_w_1.interpolate_at_centroid(); out.FragColor.x += in.s_w_0.interpolate_at_sample(2); out.FragColor.x += in.s_w_1.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375); - float2 _328 = out.FragColor.xy + in.baz.interpolate_at_sample(gl_SampleID); - out.FragColor = float4(_328.x, _328.y, out.FragColor.z, out.FragColor.w); + float2 _329 = out.FragColor.xy + in.baz.interpolate_at_sample(gl_SampleID); + out.FragColor = float4(_329.x, _329.y, out.FragColor.z, out.FragColor.w); out.FragColor.x += in.baz.interpolate_at_centroid().x; out.FragColor.y += in.baz.interpolate_at_sample(3).y; out.FragColor.z += in.baz.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375).y; - float2 _353 = out.FragColor.xy + in.a_1.interpolate_at_centroid(); - out.FragColor = float4(_353.x, _353.y, out.FragColor.z, out.FragColor.w); - float2 _360 = out.FragColor.xy + in.a_0.interpolate_at_sample(2); - out.FragColor = float4(_360.x, _360.y, out.FragColor.z, out.FragColor.w); - float2 _367 = out.FragColor.xy + in.a_1.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375); - out.FragColor = float4(_367.x, _367.y, out.FragColor.z, out.FragColor.w); + float2 _354 = out.FragColor.xy + in.a_1.interpolate_at_centroid(); + out.FragColor = float4(_354.x, _354.y, out.FragColor.z, out.FragColor.w); + float2 _361 = out.FragColor.xy + in.a_0.interpolate_at_sample(2); + out.FragColor = float4(_361.x, _361.y, out.FragColor.z, out.FragColor.w); + float2 _368 = out.FragColor.xy + in.a_1.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375); + out.FragColor = float4(_368.x, _368.y, out.FragColor.z, out.FragColor.w); out.FragColor += s.z; - float2 _379 = out.FragColor.xy + in.s_z.interpolate_at_centroid().yy; - out.FragColor = float4(_379.x, _379.y, out.FragColor.z, out.FragColor.w); - float2 _387 = out.FragColor.yz + in.s_z.interpolate_at_sample(3).xy; - out.FragColor = float4(out.FragColor.x, _387.x, _387.y, out.FragColor.w); - float2 _395 = out.FragColor.zw + in.s_z.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375).wx; - out.FragColor = float4(out.FragColor.x, out.FragColor.y, _395.x, _395.y); + float2 _380 = out.FragColor.xy + in.s_z.interpolate_at_centroid().yy; + out.FragColor = float4(_380.x, _380.y, out.FragColor.z, out.FragColor.w); + float2 _388 = out.FragColor.yz + in.s_z.interpolate_at_sample(3).xy; + out.FragColor = float4(out.FragColor.x, _388.x, _388.y, out.FragColor.w); + float2 _396 = out.FragColor.zw + in.s_z.interpolate_at_offset(float2(-0.100000001490116119384765625, 0.100000001490116119384765625) + 0.4375).wx; + out.FragColor = float4(out.FragColor.x, out.FragColor.y, _396.x, _396.y); out.FragColor += s.u[0]; out.FragColor += in.s_u_1.interpolate_at_centroid(); out.FragColor += in.s_u_0.interpolate_at_sample(2); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag index 918a0b9c13..750911f2fd 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unreachable.asm.frag @@ -16,21 +16,21 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; - float4 _33; + float4 _46; for (;;) { if (in.counter == 10) { - _33 = float4(10.0); + _46 = float4(10.0); break; } else { - _33 = float4(30.0); + _46 = float4(30.0); break; } } - out.FragColor = _33; + out.FragColor = _46; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 2031b335d4..4ac725ae73 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -3,19 +3,19 @@ using namespace metal; -struct _28 +struct _15 { float4 _m0; }; -struct _6 +struct _3 { float4 _m0; float _m1; float4 _m2; }; -struct _10 +struct _4 { float3 _m0; packed_float3 _m1; @@ -44,7 +44,7 @@ struct _10 float4 _m24; }; -struct _18 +struct _7 { float4x4 _m0; float4x4 _m1; @@ -90,188 +90,188 @@ struct _18 struct main0_out { - float4 m_5 [[color(0)]]; + float4 m_4317 [[color(0)]]; }; -fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant _3& _22044 [[buffer(0)]], constant _4& _12348 [[buffer(1)]], constant _7& _15259 [[buffer(2)]], texture2d _5785 [[texture(0)]], texture2d _3312 [[texture(1)]], texture2d _4862 [[texture(2)]], sampler _5688 [[sampler(0)]], sampler _4646 [[sampler(1)]], sampler _3594 [[sampler(2)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - float4 _88 = _7._m2 * _7._m0.xyxy; - float2 _95 = _88.xy; - float2 _96 = _88.zw; - float2 _97 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(0.0, -2.0) * _7._m0.xy), _95, _96); - float3 _109 = float3(_11._m5) * fast::clamp(_8.sample(_9, _97, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _113 = _12.sample(_13, _97, level(0.0)); - float _114 = _113.y; - float3 _129; - if (_114 > 0.0) + float4 _17581 = _22044._m2 * _22044._m0.xyxy; + float2 _7011 = _17581.xy; + float2 _21058 = _17581.zw; + float2 _13149 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(0.0, -2.0) * _22044._m0.xy), _7011, _21058); + float3 _12103 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13149, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17670 = _3312.sample(_4646, _13149, level(0.0)); + float _16938 = _17670.y; + float3 _7719; + if (_16938 > 0.0) { - _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * fast::clamp(_114 * _113.z, 0.0, 1.0)); + _7719 = _12103 + (_4862.sample(_3594, _13149, level(0.0)).xyz * fast::clamp(_16938 * _17670.z, 0.0, 1.0)); } else { - _129 = _109; + _7719 = _12103; } - float2 _144 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(-1.0) * _7._m0.xy), _95, _96); - float3 _156 = float3(_11._m5) * fast::clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _160 = _12.sample(_13, _144, level(0.0)); - float _161 = _160.y; - float3 _176; - if (_161 > 0.0) + float2 _13150 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(-1.0) * _22044._m0.xy), _7011, _21058); + float3 _12104 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13150, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17671 = _3312.sample(_4646, _13150, level(0.0)); + float _16939 = _17671.y; + float3 _7720; + if (_16939 > 0.0) { - _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * fast::clamp(_161 * _160.z, 0.0, 1.0)); + _7720 = _12104 + (_4862.sample(_3594, _13150, level(0.0)).xyz * fast::clamp(_16939 * _17671.z, 0.0, 1.0)); } else { - _176 = _156; + _7720 = _12104; } - float2 _191 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(0.0, -1.0) * _7._m0.xy), _95, _96); - float3 _203 = float3(_11._m5) * fast::clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _207 = _12.sample(_13, _191, level(0.0)); - float _208 = _207.y; - float3 _223; - if (_208 > 0.0) + float2 _13151 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(0.0, -1.0) * _22044._m0.xy), _7011, _21058); + float3 _12105 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13151, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17672 = _3312.sample(_4646, _13151, level(0.0)); + float _16940 = _17672.y; + float3 _7721; + if (_16940 > 0.0) { - _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * fast::clamp(_208 * _207.z, 0.0, 1.0)); + _7721 = _12105 + (_4862.sample(_3594, _13151, level(0.0)).xyz * fast::clamp(_16940 * _17672.z, 0.0, 1.0)); } else { - _223 = _203; + _7721 = _12105; } - float2 _238 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(1.0, -1.0) * _7._m0.xy), _95, _96); - float3 _250 = float3(_11._m5) * fast::clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _254 = _12.sample(_13, _238, level(0.0)); - float _255 = _254.y; - float3 _270; - if (_255 > 0.0) + float2 _13152 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(1.0, -1.0) * _22044._m0.xy), _7011, _21058); + float3 _12106 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13152, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17673 = _3312.sample(_4646, _13152, level(0.0)); + float _16941 = _17673.y; + float3 _7722; + if (_16941 > 0.0) { - _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * fast::clamp(_255 * _254.z, 0.0, 1.0)); + _7722 = _12106 + (_4862.sample(_3594, _13152, level(0.0)).xyz * fast::clamp(_16941 * _17673.z, 0.0, 1.0)); } else { - _270 = _250; + _7722 = _12106; } - float2 _285 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(-2.0, 0.0) * _7._m0.xy), _95, _96); - float3 _297 = float3(_11._m5) * fast::clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _301 = _12.sample(_13, _285, level(0.0)); - float _302 = _301.y; - float3 _317; - if (_302 > 0.0) + float2 _13153 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(-2.0, 0.0) * _22044._m0.xy), _7011, _21058); + float3 _12107 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13153, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17674 = _3312.sample(_4646, _13153, level(0.0)); + float _16942 = _17674.y; + float3 _7723; + if (_16942 > 0.0) { - _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * fast::clamp(_302 * _301.z, 0.0, 1.0)); + _7723 = _12107 + (_4862.sample(_3594, _13153, level(0.0)).xyz * fast::clamp(_16942 * _17674.z, 0.0, 1.0)); } else { - _317 = _297; + _7723 = _12107; } - float2 _332 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(-1.0, 0.0) * _7._m0.xy), _95, _96); - float3 _344 = float3(_11._m5) * fast::clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _348 = _12.sample(_13, _332, level(0.0)); - float _349 = _348.y; - float3 _364; - if (_349 > 0.0) + float2 _13154 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(-1.0, 0.0) * _22044._m0.xy), _7011, _21058); + float3 _12108 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13154, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17675 = _3312.sample(_4646, _13154, level(0.0)); + float _16943 = _17675.y; + float3 _7724; + if (_16943 > 0.0) { - _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * fast::clamp(_349 * _348.z, 0.0, 1.0)); + _7724 = _12108 + (_4862.sample(_3594, _13154, level(0.0)).xyz * fast::clamp(_16943 * _17675.z, 0.0, 1.0)); } else { - _364 = _344; + _7724 = _12108; } - float2 _379 = fast::clamp(gl_FragCoord.xy * _19._m23.xy, _95, _96); - float3 _391 = float3(_11._m5) * fast::clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _395 = _12.sample(_13, _379, level(0.0)); - float _396 = _395.y; - float3 _411; - if (_396 > 0.0) + float2 _13155 = fast::clamp(gl_FragCoord.xy * _15259._m23.xy, _7011, _21058); + float3 _12109 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13155, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17676 = _3312.sample(_4646, _13155, level(0.0)); + float _16944 = _17676.y; + float3 _7725; + if (_16944 > 0.0) { - _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * fast::clamp(_396 * _395.z, 0.0, 1.0)); + _7725 = _12109 + (_4862.sample(_3594, _13155, level(0.0)).xyz * fast::clamp(_16944 * _17676.z, 0.0, 1.0)); } else { - _411 = _391; + _7725 = _12109; } - float2 _426 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(1.0, 0.0) * _7._m0.xy), _95, _96); - float3 _438 = float3(_11._m5) * fast::clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _442 = _12.sample(_13, _426, level(0.0)); - float _443 = _442.y; - float3 _458; - if (_443 > 0.0) + float2 _13156 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(1.0, 0.0) * _22044._m0.xy), _7011, _21058); + float3 _12110 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13156, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17677 = _3312.sample(_4646, _13156, level(0.0)); + float _16945 = _17677.y; + float3 _7726; + if (_16945 > 0.0) { - _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * fast::clamp(_443 * _442.z, 0.0, 1.0)); + _7726 = _12110 + (_4862.sample(_3594, _13156, level(0.0)).xyz * fast::clamp(_16945 * _17677.z, 0.0, 1.0)); } else { - _458 = _438; + _7726 = _12110; } - float2 _473 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(2.0, 0.0) * _7._m0.xy), _95, _96); - float3 _485 = float3(_11._m5) * fast::clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _489 = _12.sample(_13, _473, level(0.0)); - float _490 = _489.y; - float3 _505; - if (_490 > 0.0) + float2 _13157 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(2.0, 0.0) * _22044._m0.xy), _7011, _21058); + float3 _12111 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13157, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17678 = _3312.sample(_4646, _13157, level(0.0)); + float _16946 = _17678.y; + float3 _7727; + if (_16946 > 0.0) { - _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * fast::clamp(_490 * _489.z, 0.0, 1.0)); + _7727 = _12111 + (_4862.sample(_3594, _13157, level(0.0)).xyz * fast::clamp(_16946 * _17678.z, 0.0, 1.0)); } else { - _505 = _485; + _7727 = _12111; } - float2 _520 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(-1.0, 1.0) * _7._m0.xy), _95, _96); - float3 _532 = float3(_11._m5) * fast::clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _536 = _12.sample(_13, _520, level(0.0)); - float _537 = _536.y; - float3 _552; - if (_537 > 0.0) + float2 _13158 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(-1.0, 1.0) * _22044._m0.xy), _7011, _21058); + float3 _12112 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13158, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17679 = _3312.sample(_4646, _13158, level(0.0)); + float _16947 = _17679.y; + float3 _7728; + if (_16947 > 0.0) { - _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * fast::clamp(_537 * _536.z, 0.0, 1.0)); + _7728 = _12112 + (_4862.sample(_3594, _13158, level(0.0)).xyz * fast::clamp(_16947 * _17679.z, 0.0, 1.0)); } else { - _552 = _532; + _7728 = _12112; } - float2 _567 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(0.0, 1.0) * _7._m0.xy), _95, _96); - float3 _579 = float3(_11._m5) * fast::clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _583 = _12.sample(_13, _567, level(0.0)); - float _584 = _583.y; - float3 _599; - if (_584 > 0.0) + float2 _13159 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(0.0, 1.0) * _22044._m0.xy), _7011, _21058); + float3 _12113 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13159, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17680 = _3312.sample(_4646, _13159, level(0.0)); + float _16948 = _17680.y; + float3 _7729; + if (_16948 > 0.0) { - _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * fast::clamp(_584 * _583.z, 0.0, 1.0)); + _7729 = _12113 + (_4862.sample(_3594, _13159, level(0.0)).xyz * fast::clamp(_16948 * _17680.z, 0.0, 1.0)); } else { - _599 = _579; + _7729 = _12113; } - float2 _614 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, _7._m0.xy), _95, _96); - float3 _626 = float3(_11._m5) * fast::clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _630 = _12.sample(_13, _614, level(0.0)); - float _631 = _630.y; - float3 _646; - if (_631 > 0.0) + float2 _13160 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, _22044._m0.xy), _7011, _21058); + float3 _12114 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13160, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17681 = _3312.sample(_4646, _13160, level(0.0)); + float _16949 = _17681.y; + float3 _7730; + if (_16949 > 0.0) { - _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * fast::clamp(_631 * _630.z, 0.0, 1.0)); + _7730 = _12114 + (_4862.sample(_3594, _13160, level(0.0)).xyz * fast::clamp(_16949 * _17681.z, 0.0, 1.0)); } else { - _646 = _626; + _7730 = _12114; } - float2 _661 = fast::clamp(fma(gl_FragCoord.xy, _19._m23.xy, float2(0.0, 2.0) * _7._m0.xy), _95, _96); - float3 _673 = float3(_11._m5) * fast::clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0); - float4 _677 = _12.sample(_13, _661, level(0.0)); - float _678 = _677.y; - float3 _693; - if (_678 > 0.0) + float2 _13161 = fast::clamp(fma(gl_FragCoord.xy, _15259._m23.xy, float2(0.0, 2.0) * _22044._m0.xy), _7011, _21058); + float3 _12115 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13161, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17682 = _3312.sample(_4646, _13161, level(0.0)); + float _16950 = _17682.y; + float3 _7731; + if (_16950 > 0.0) { - _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * fast::clamp(_678 * _677.z, 0.0, 1.0)); + _7731 = _12115 + (_4862.sample(_3594, _13161, level(0.0)).xyz * fast::clamp(_16950 * _17682.z, 0.0, 1.0)); } else { - _693 = _673; + _7731 = _12115; } - float3 _702 = (((((((((((((_129 * 0.5).xyz + (_176 * 0.5)).xyz + (_223 * 0.75)).xyz + (_270 * 0.5)).xyz + (_317 * 0.5)).xyz + (_364 * 0.75)).xyz + (_411 * 1.0)).xyz + (_458 * 0.75)).xyz + (_505 * 0.5)).xyz + (_552 * 0.5)).xyz + (_599 * 0.75)).xyz + (_646 * 0.5)).xyz + (_693 * 0.5)).xyz * float3(0.125); - _28 _750 = _28{ float4(_702.x, _702.y, _702.z, float4(0.0).w) }; - _750._m0.w = 1.0; - out.m_5 = _750._m0; + float3 _13750 = (((((((((((((_7719 * 0.5).xyz + (_7720 * 0.5)).xyz + (_7721 * 0.75)).xyz + (_7722 * 0.5)).xyz + (_7723 * 0.5)).xyz + (_7724 * 0.75)).xyz + (_7725 * 1.0)).xyz + (_7726 * 0.75)).xyz + (_7727 * 0.5)).xyz + (_7728 * 0.5)).xyz + (_7729 * 0.75)).xyz + (_7730 * 0.5)).xyz + (_7731 * 0.5)).xyz * float3(0.125); + _15 _25050 = _15{ float4(_13750.x, _13750.y, _13750.z, float4(0.0).w) }; + _25050._m0.w = 1.0; + out.m_4317 = _25050._m0; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert index 1926ff9e14..a0f383c9e9 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert @@ -25,11 +25,11 @@ struct main0_in float4 a_position [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _9 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) +vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _11 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; - out.gl_Position = _9.umatrix * float4(_9.uquad[int(gl_VertexIndex)].x, _9.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); - if (_9.flags.flags[0] != 0u) + out.gl_Position = _11.umatrix * float4(_11.uquad[int(gl_VertexIndex)].x, _11.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); + if (_11.flags.flags[0] != 0u) { out.gl_Position.z = 0.0; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert index ee20638574..4d137ebf1f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert @@ -25,11 +25,11 @@ struct main0_in float4 a_position [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _9 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) +vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _11 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; - out.gl_Position = _9.umatrix * float4(_9.uquad[int(gl_VertexIndex)].x, _9.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); - if (_9.flags.flags[0].x != 0u) + out.gl_Position = _11.umatrix * float4(_11.uquad[int(gl_VertexIndex)].x, _11.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); + if (_11.flags.flags[0].x != 0u) { out.gl_Position.z = 0.0; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert index 196057a79d..c48a426eb4 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert @@ -3,20 +3,20 @@ using namespace metal; -constant int _7_tmp [[function_constant(201)]]; -constant int _7 = is_function_constant_defined(_7_tmp) ? _7_tmp : -10; -constant int _20 = (_7 + 2); -constant uint _8_tmp [[function_constant(202)]]; -constant uint _8 = is_function_constant_defined(_8_tmp) ? _8_tmp : 100u; -constant uint _25 = (_8 % 5u); -constant int _30 = _7 - (-3) * (_7 / (-3)); -constant int4 _32 = int4(20, 30, _20, _30); -constant int2 _34 = int2(_32.y, _32.x); -constant int _35 = _32.y; +constant int _13_tmp [[function_constant(201)]]; +constant int _13 = is_function_constant_defined(_13_tmp) ? _13_tmp : -10; +constant int _15 = (_13 + 2); +constant uint _24_tmp [[function_constant(202)]]; +constant uint _24 = is_function_constant_defined(_24_tmp) ? _24_tmp : 100u; +constant uint _26 = (_24 % 5u); +constant int _61 = _13 - (-3) * (_13 / (-3)); +constant int4 _36 = int4(20, 30, _15, _61); +constant int2 _41 = int2(_36.y, _36.x); +constant int _62 = _36.y; struct main0_out { - int m_4 [[user(locn0)]]; + int m_58 [[user(locn0)]]; float4 gl_Position [[position]]; }; @@ -24,12 +24,12 @@ vertex main0_out main0() { main0_out out = {}; float4 _66 = float4(0.0); - _66.y = float(_20); - _66.z = float(_25); - float4 _55 = _66 + float4(_32); - float2 _59 = _55.xy + float2(_34); - out.gl_Position = float4(_59.x, _59.y, _55.z, _55.w); - out.m_4 = _35; + _66.y = float(_15); + _66.z = float(_26); + float4 _39 = _66 + float4(_36); + float2 _46 = _39.xy + float2(_41); + out.gl_Position = float4(_46.x, _46.y, _39.z, _39.w); + out.m_58 = _62; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..2673016328 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,77 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +struct UBO +{ + float4 v[1024]; +}; + +struct UBOs +{ + float4 v; +}; + +struct SSBOIn +{ + float4 v[1024]; +}; + +struct SSBOIns +{ + float4 v; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* o [[id(0)]]; + constant UBO* v [[id(1)]]; + spvDescriptor vs [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + device SSBOIn* w [[id(0)]]; + spvDescriptor ws [[id(1)]][1] /* unsized array hack */; +}; + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray vs {spvDescriptorSet0.vs}; + spvDescriptorArray ws {spvDescriptorSet1.ws}; + + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = (*spvDescriptorSet0.v).v[gl_WorkGroupID.x]; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x]->v; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = (*spvDescriptorSet1.w).v[gl_WorkGroupID.x]; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x]->v; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..2471c89400 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,109 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +struct UBO +{ + float4 v[1024]; +}; + +struct UBOs +{ + float4 v; +}; + +struct SSBOIn +{ + float4 v[1024]; +}; + +struct SSBOIns +{ + float4 v; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* o [[id(0)]]; + constant UBO* v [[id(1)]]; + spvDescriptor vs [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + device SSBOIn* w [[id(0)]]; + spvBufferDescriptor ws [[id(1)]][1] /* unsized array hack */; +}; + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray vs {spvDescriptorSet0.vs}; + spvDescriptorArray ws {spvDescriptorSet1.ws}; + + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = (*spvDescriptorSet0.v).v[gl_WorkGroupID.x]; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x]->v; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = (*spvDescriptorSet1.w).v[gl_WorkGroupID.x]; + (*spvDescriptorSet0.o).v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x]->v; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..932cc19d4a --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,55 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* m_13 [[id(0)]]; + texture2d T [[id(1)]]; + spvDescriptor> Ts [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + sampler S [[id(0)]]; + spvDescriptor Ss [[id(1)]][1] /* unsized array hack */; +}; + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray> Ts {spvDescriptorSet0.Ts}; + spvDescriptorArray Ss {spvDescriptorSet1.Ss}; + + (*spvDescriptorSet0.m_13).v[gl_GlobalInvocationID.x] = spvDescriptorSet0.T.sample(spvDescriptorSet1.S, float2(0.5), level(0.0)); + (*spvDescriptorSet0.m_13).v[gl_GlobalInvocationID.x] = Ts[gl_WorkGroupID.x].sample(Ss[gl_WorkGroupID.x], float2(0.5), level(0.0)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.comp new file mode 100644 index 0000000000..466afa3d2c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.comp @@ -0,0 +1,75 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +struct SSBO +{ + uint u32; + int i32; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device SSBO& ssbo [[buffer(2)]], texture2d uImage [[texture(0)]], device atomic_uint* uImage_atomic [[buffer(0)]], texture2d iImage [[texture(1)]], device atomic_int* iImage_atomic [[buffer(1)]]) +{ + uint _19 = atomic_fetch_add_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _27 = atomic_fetch_add_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + iImage.write(int4(int(_27)), uint2(int2(1, 6))); + uint _32 = atomic_fetch_or_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _34 = atomic_fetch_xor_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _36 = atomic_fetch_and_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _38 = atomic_fetch_min_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _40 = atomic_fetch_max_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _44; + do + { + _44 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], &_44, 2u, memory_order_relaxed, memory_order_relaxed) && _44 == 10u); + int _47 = atomic_fetch_add_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _49 = atomic_fetch_or_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _51 = atomic_fetch_xor_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _53 = atomic_fetch_and_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _55 = atomic_fetch_min_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _57 = atomic_fetch_max_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _61; + do + { + _61 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 5), iImage)], &_61, 2, memory_order_relaxed, memory_order_relaxed) && _61 == 10); + uint _68 = atomic_fetch_add_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _70 = atomic_fetch_or_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _72 = atomic_fetch_xor_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _74 = atomic_fetch_and_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _76 = atomic_fetch_min_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _78 = atomic_fetch_max_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _80 = atomic_exchange_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _82; + do + { + _82 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&ssbo.u32, &_82, 2u, memory_order_relaxed, memory_order_relaxed) && _82 == 10u); + int _85 = atomic_fetch_add_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _87 = atomic_fetch_or_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _89 = atomic_fetch_xor_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _91 = atomic_fetch_and_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _93 = atomic_fetch_min_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _95 = atomic_fetch_max_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _97 = atomic_exchange_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _99; + do + { + _99 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&ssbo.i32, &_99, 2, memory_order_relaxed, memory_order_relaxed) && _99 == 10); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.msl31.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.msl31.comp new file mode 100644 index 0000000000..1fefb3a7ee --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/atomic-image.msl31.comp @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + uint u32; + int i32; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device SSBO& ssbo [[buffer(0)]], texture2d uImage [[texture(0)]], texture2d iImage [[texture(1)]]) +{ + uint _19 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x; + uint _27 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x; + iImage.write(int4(int(_27)), uint2(int2(1, 6))); + uint _32 = uImage.atomic_fetch_or(uint2(int2(1, 5)), 1u).x; + uint _34 = uImage.atomic_fetch_xor(uint2(int2(1, 5)), 1u).x; + uint _36 = uImage.atomic_fetch_and(uint2(int2(1, 5)), 1u).x; + uint _38 = uImage.atomic_fetch_min(uint2(int2(1, 5)), 1u).x; + uint _40 = uImage.atomic_fetch_max(uint2(int2(1, 5)), 1u).x; + uint _44; + uint4 _102; + do + { + _102.x = 10u; + } while (!uImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_102, 2u) && _102.x == 10u); + _44 = _102.x; + int _47 = iImage.atomic_fetch_add(uint2(int2(1, 6)), 1).x; + int _49 = iImage.atomic_fetch_or(uint2(int2(1, 6)), 1).x; + int _51 = iImage.atomic_fetch_xor(uint2(int2(1, 6)), 1).x; + int _53 = iImage.atomic_fetch_and(uint2(int2(1, 6)), 1).x; + int _55 = iImage.atomic_fetch_min(uint2(int2(1, 6)), 1).x; + int _57 = iImage.atomic_fetch_max(uint2(int2(1, 6)), 1).x; + int _61; + int4 _104; + do + { + _104.x = 10; + } while (!iImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_104, 2) && _104.x == 10); + _61 = _104.x; + uint _68 = atomic_fetch_add_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _70 = atomic_fetch_or_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _72 = atomic_fetch_xor_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _74 = atomic_fetch_and_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _76 = atomic_fetch_min_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _78 = atomic_fetch_max_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _80 = atomic_exchange_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _82; + do + { + _82 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&ssbo.u32, &_82, 2u, memory_order_relaxed, memory_order_relaxed) && _82 == 10u); + int _85 = atomic_fetch_add_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _87 = atomic_fetch_or_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _89 = atomic_fetch_xor_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _91 = atomic_fetch_and_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _93 = atomic_fetch_min_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _95 = atomic_fetch_max_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _97 = atomic_exchange_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _99; + do + { + _99 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&ssbo.i32, &_99, 2, memory_order_relaxed, memory_order_relaxed) && _99 == 10); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp index fb561482ab..30e89455d7 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp @@ -19,10 +19,7 @@ struct SSBO kernel void main0(constant UBO& _10 [[buffer(0)]]) { (reinterpret_cast(as_type(_10.b)))->a1 = float3(1.0, 2.0, 3.0); - uint2 _35 = as_type(reinterpret_cast(reinterpret_cast(as_type(_10.b + uint2(32u))))); - uint2 v2 = _35; - device SSBO* _39 = reinterpret_cast(as_type(_35)); - float3 v3 = float3(_39->a1); + device SSBO* _39 = reinterpret_cast(as_type(as_type(reinterpret_cast(reinterpret_cast(as_type(_10.b + uint2(32u))))))); _39->a1 = float3(_39->a1) + float3(1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-recursive-struct-pointers.msl23.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-recursive-struct-pointers.msl23.comp index d66154b549..0d025586ea 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-recursive-struct-pointers.msl23.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-recursive-struct-pointers.msl23.comp @@ -32,65 +32,8 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); kernel void main0(constant t24& u24 [[buffer(0)]], constant t35& u35 [[buffer(1)]], texture2d v295 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - int v8 = 0; - int _30 = 0 | (u24.m0[0].x - 0); - v8 = _30; - int _44 = _30 | (u24.m0[u35.m0[1]].x - 1); - v8 = _44; - int _50 = _44 | (u24.m1 - 2); - v8 = _50; - int _60 = _50 | int(u24.m4[0u][0] - 3.0); - v8 = _60; - int _68 = _60 | int(u24.m4[1u][0] - 5.0); - v8 = _68; - int _75 = _68 | int(u24.m4[0u][1] - 4.0); - v8 = _75; - int _82 = _75 | int(u24.m4[1u][1] - 6.0); - v8 = _82; - int _92 = _82 | (((device t21*)u24.m2[0].x)->m0[0].x - 3); - v8 = _92; - int _101 = _92 | (((device t21*)u24.m2[0].x)->m0[u35.m0[1]].x - 4); - v8 = _101; - int _109 = _101 | (((device t21*)u24.m2[0].x)->m1 - 5); - v8 = _109; - int _118 = _109 | int(((device t21*)u24.m2[0].x)->m4[0u][0] - 6.0); - v8 = _118; - int _127 = _118 | int(((device t21*)u24.m2[0].x)->m4[1u][0] - 8.0); - v8 = _127; - int _136 = _127 | int(((device t21*)u24.m2[0].x)->m4[0u][1] - 7.0); - v8 = _136; - int _145 = _136 | int(((device t21*)u24.m2[0].x)->m4[1u][1] - 9.0); - v8 = _145; - int _155 = _145 | (((device t21*)u24.m2[u35.m0[1]].x)->m0[0].x - 6); - v8 = _155; - int _167 = _155 | (((device t21*)u24.m2[u35.m0[1]].x)->m0[u35.m0[1]].x - 7); - v8 = _167; - int _177 = _167 | (((device t21*)u24.m2[u35.m0[1]].x)->m1 - 8); - v8 = _177; - int _187 = _177 | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[0u][0] - 9.0); - v8 = _187; - int _198 = _187 | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[1u][0] - 11.0); - v8 = _198; - int _209 = _198 | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[0u][1] - 10.0); - v8 = _209; - int _220 = _209 | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[1u][1] - 12.0); - v8 = _220; - int _228 = _220 | (u24.m3->m0[0].x - 9); - v8 = _228; - int _238 = _228 | (u24.m3->m0[u35.m0[1]].x - 10); - v8 = _238; - int _246 = _238 | (u24.m3->m1 - 11); - v8 = _246; - int _254 = _246 | int(u24.m3->m4[0u][0] - 12.0); - v8 = _254; - int _263 = _254 | int(u24.m3->m4[1u][0] - 14.0); - v8 = _263; - int _272 = _263 | int(u24.m3->m4[0u][1] - 13.0); - v8 = _272; - int _281 = _272 | int(u24.m3->m4[1u][1] - 15.0); - v8 = _281; - uint4 _292 = select(uint4(1u, 0u, 0u, 1u), uint4(0u), bool4(_281 != 0)); - uint4 v284 = _292; - v295.write(_292, uint2(int2(gl_GlobalInvocationID.xy))); + int _155 = ((((((((((((((0 | (u24.m0[0].x - 0)) | (u24.m0[u35.m0[1]].x - 1)) | (u24.m1 - 2)) | int(u24.m4[0u][0] - 3.0)) | int(u24.m4[1u][0] - 5.0)) | int(u24.m4[0u][1] - 4.0)) | int(u24.m4[1u][1] - 6.0)) | (((device t21*)u24.m2[0].x)->m0[0].x - 3)) | (((device t21*)u24.m2[0].x)->m0[u35.m0[1]].x - 4)) | (((device t21*)u24.m2[0].x)->m1 - 5)) | int(((device t21*)u24.m2[0].x)->m4[0u][0] - 6.0)) | int(((device t21*)u24.m2[0].x)->m4[1u][0] - 8.0)) | int(((device t21*)u24.m2[0].x)->m4[0u][1] - 7.0)) | int(((device t21*)u24.m2[0].x)->m4[1u][1] - 9.0)) | (((device t21*)u24.m2[u35.m0[1]].x)->m0[0].x - 6); + bool _289 = (((((((((((((_155 | (((device t21*)u24.m2[u35.m0[1]].x)->m0[u35.m0[1]].x - 7)) | (((device t21*)u24.m2[u35.m0[1]].x)->m1 - 8)) | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[0u][0] - 9.0)) | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[1u][0] - 11.0)) | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[0u][1] - 10.0)) | int(((device t21*)u24.m2[u35.m0[1]].x)->m4[1u][1] - 12.0)) | (u24.m3->m0[0].x - 9)) | (u24.m3->m0[u35.m0[1]].x - 10)) | (u24.m3->m1 - 11)) | int(u24.m3->m4[0u][0] - 12.0)) | int(u24.m3->m4[1u][0] - 14.0)) | int(u24.m3->m4[0u][1] - 13.0)) | int(u24.m3->m4[1u][1] - 15.0)) != 0; + v295.write(select(uint4(1u, 0u, 0u, 1u), uint4(0u), bool4(_289)), uint2(int2(gl_GlobalInvocationID.xy))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address.msl2.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address.msl2.comp index d85fa356b8..b6b19c19b3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address.msl2.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address.msl2.comp @@ -27,30 +27,15 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(8u, 8u, 1u); kernel void main0(constant Registers& registers [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) { uint2 local_offset = gl_GlobalInvocationID.xy; - uint _19 = local_offset.y; - uint _29 = local_offset.x; - uint _30 = ((_19 * 8u) * gl_NumWorkGroups.x) + _29; - uint local_index = _30; - uint slice = gl_WorkGroupID.z; - device Position* __restrict positions = registers.references->buffers[gl_WorkGroupID.z]; - float _66 = float(gl_WorkGroupID.z); - float _70 = fract(fma(_66, 0.100000001490116119384765625, registers.fract_time)); + float _70 = fract(fma(float(gl_WorkGroupID.z), 0.100000001490116119384765625, registers.fract_time)); float _71 = 6.283125400543212890625 * _70; - float offset = _71; - float2 pos = float2(local_offset); - float _83 = sin(fma(2.2000000476837158203125, pos.x, _71)); - pos.x = fma(0.20000000298023223876953125, _83, pos.x); - float _97 = sin(fma(2.25, pos.y, _70 * 12.56625080108642578125)); - pos.y = fma(0.20000000298023223876953125, _97, pos.y); - float _111 = cos(fma(1.7999999523162841796875, pos.y, _70 * 18.849376678466796875)); - pos.x = fma(0.20000000298023223876953125, _111, pos.x); - float _125 = cos(fma(2.849999904632568359375, pos.x, _70 * 25.1325016021728515625)); - pos.y = fma(0.20000000298023223876953125, _125, pos.y); - float _133 = sin(_71); - pos.x = fma(0.5, _133, pos.x); - float _142 = sin(fma(6.283125400543212890625, _70, 0.300000011920928955078125)); - pos.y = fma(0.5, _142, pos.y); - float2 _155 = float2(gl_NumWorkGroups.xy); - registers.references->buffers[gl_WorkGroupID.z]->positions[_30] = (pos / fma(float2(8.0), _155, float2(-1.0))) - float2(0.5); + float2 pos = float2(gl_GlobalInvocationID.xy); + pos.x = fma(0.20000000298023223876953125, sin(fma(2.2000000476837158203125, pos.x, _71)), pos.x); + pos.y = fma(0.20000000298023223876953125, sin(fma(2.25, pos.y, _70 * 12.56625080108642578125)), pos.y); + pos.x = fma(0.20000000298023223876953125, cos(fma(1.7999999523162841796875, pos.y, _70 * 18.849376678466796875)), pos.x); + pos.y = fma(0.20000000298023223876953125, cos(fma(2.849999904632568359375, pos.x, _70 * 25.1325016021728515625)), pos.y); + pos.x = fma(0.5, sin(_71), pos.x); + pos.y = fma(0.5, sin(fma(6.283125400543212890625, _70, 0.300000011920928955078125)), pos.y); + registers.references->buffers[gl_WorkGroupID.z]->positions[((local_offset.y * 8u) * gl_NumWorkGroups.x) + local_offset.x] = (pos / fma(float2(8.0), float2(gl_NumWorkGroups.xy), float2(-1.0))) - float2(0.5); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.comp new file mode 100644 index 0000000000..2fefd818b4 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.comp @@ -0,0 +1,22 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]], volatile device atomic_uint* rw_spd_global_atomic_atomic [[buffer(0)]]) +{ + uint _43 = atomic_fetch_add_explicit((volatile device atomic_uint*)&rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), rw_spd_global_atomic)], 1u, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp new file mode 100644 index 0000000000..9bed397481 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp @@ -0,0 +1,28 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +struct spvDescriptorSetBuffer1 +{ + texture2d rw_spd_global_atomic [[id(0)]]; + volatile device atomic_uint* rw_spd_global_atomic_atomic [[id(1)]]; +}; + +kernel void main0(constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]]) +{ + uint _43 = atomic_fetch_add_explicit((volatile device atomic_uint*)&spvDescriptorSet1.rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), spvDescriptorSet1.rw_spd_global_atomic)], 1u, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.comp new file mode 100644 index 0000000000..2fefd818b4 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl2.comp @@ -0,0 +1,22 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]], volatile device atomic_uint* rw_spd_global_atomic_atomic [[buffer(0)]]) +{ + uint _43 = atomic_fetch_add_explicit((volatile device atomic_uint*)&rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), rw_spd_global_atomic)], 1u, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp new file mode 100644 index 0000000000..42fd3d88ce --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp @@ -0,0 +1,20 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +struct spvDescriptorSetBuffer1 +{ + texture2d rw_spd_global_atomic [[id(0)]]; +}; + +kernel void main0(constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]]) +{ + uint _43 = spvDescriptorSet1.rw_spd_global_atomic.atomic_fetch_add(uint2(int2(0)), 1u).x; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.comp new file mode 100644 index 0000000000..0c7175da6c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/coherent-image-atomic.msl31.comp @@ -0,0 +1,15 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]]) +{ + uint _43 = rw_spd_global_atomic.atomic_fetch_add(uint2(int2(0)), 1u).x; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/complex-type-alias.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/complex-type-alias.comp index 43e1297585..532e85115f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/complex-type-alias.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/complex-type-alias.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct Foo0 { float a; @@ -44,7 +85,7 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(8u, 8u, 1u); kernel void main0(device SSBO& _53 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) { - threadgroup Foo2 coeffs[64]; + threadgroup spvUnsafeArray coeffs; coeffs[gl_LocalInvocationIndex] = Foo2{ Foo1{ Foo0{ 0.0 } }, 0.0 }; threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_LocalInvocationIndex == 0u) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp new file mode 100644 index 0000000000..9e8c4bf0b0 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +struct recurs; + +struct recurs +{ + int m1; + device recurs* m2; +}; + +struct recurs_1 +{ + int m1; + device recurs_1* m2; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device void* nums_vp [[buffer(0)]], texture2d tex [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + device auto& nums = *(device recurs*)nums_vp; + tex.write(uint4(uint((nums.m1 + nums.m2->m1) + nums.m2->m2->m1), 0u, 0u, 1u), uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp index dde7f47b08..09802dd262 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include #if __METAL_VERSION__ >= 230 @@ -7,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct Params { uint ray_flags; @@ -22,9 +48,9 @@ struct Params kernel void main0(constant Params& _18 [[buffer(1)]], raytracing::acceleration_structure AS0 [[buffer(0)]], raytracing::acceleration_structure AS1 [[buffer(2)]]) { raytracing::intersection_query q; - q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, intersection_params()); + q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, _18.cull_mask, spvMakeIntersectionParams(_18.ray_flags)); raytracing::intersection_query q2[2]; - q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, intersection_params()); + q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, _18.cull_mask, spvMakeIntersectionParams(_18.ray_flags)); bool _63 = q.next(); bool res = _63; q2[0].abort(); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp new file mode 100644 index 0000000000..a1bd55247d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp @@ -0,0 +1,77 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +inline T spvSubgroupBroadcast(T value, ushort lane) +{ + return simd_broadcast(value, lane); +} + +template<> +inline bool spvSubgroupBroadcast(bool value, ushort lane) +{ + return !!simd_broadcast((ushort)value, lane); +} + +template +inline vec spvSubgroupBroadcast(vec value, ushort lane) +{ + return (vec)simd_broadcast((vec)value, lane); +} + +template +inline T spvSubgroupBroadcastFirst(T value) +{ + return simd_broadcast_first(value); +} + +template<> +inline bool spvSubgroupBroadcastFirst(bool value) +{ + return !!simd_broadcast_first((ushort)value); +} + +template +inline vec spvSubgroupBroadcastFirst(vec value) +{ + return (vec)simd_broadcast_first((vec)value); +} + +inline uint4 spvSubgroupBallot(bool value) +{ + simd_vote vote = simd_ballot(value); + // simd_ballot() returns a 64-bit integer-like object, but + // SPIR-V callers expect a uint4. We must convert. + // FIXME: This won't include higher bits if Apple ever supports + // 128 lanes in an SIMD-group. + return uint4(as_type((simd_vote::vote_t)vote), 0, 0); +} + +struct inputData +{ + float inputDataArray[1]; +}; + +struct outputData +{ + float outputDataArray[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(device inputData& _12 [[buffer(0)]], device outputData& _87 [[buffer(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + bool _31 = _12.inputDataArray[gl_LocalInvocationID.x] > 0.0; + uint4 _52 = spvSubgroupBallot(_31); + uint4 _66 = uint4(int4(popcount(uint4(as_type(as_type(uint2(gl_SubgroupLtMask.xy))), 0u, 0u) & uint4(as_type(as_type(uint2(_52.xy))), 0u, 0u)))); + if (_31) + { + _87.outputDataArray[_66.x + _66.y] = _12.inputDataArray[gl_LocalInvocationID.x]; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_group_vote.msl21.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_group_vote.msl21.comp new file mode 100644 index 0000000000..f7e708d580 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_group_vote.msl21.comp @@ -0,0 +1,37 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(all(value == simd_broadcast_first(value))); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +template +inline bool spvSubgroupAllEqual(vec value) +{ + return simd_all(all(value == (vec)simd_broadcast_first((vec)value))); +} + +struct inputData +{ + float inputDataArray[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(device inputData& _12 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +{ + bool _31 = _12.inputDataArray[gl_LocalInvocationID.x] > 0.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp index ddb8c9629d..69376895a6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-array-of-arrays.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float out_data[1]; @@ -12,7 +53,7 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 4u, 1u); kernel void main0(device SSBO& _67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - threadgroup float foo[4][4]; + threadgroup spvUnsafeArray, 4> foo; foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex); threadgroup_barrier(mem_flags::mem_threadgroup); _67.out_data[gl_GlobalInvocationID.x] = ((foo[gl_LocalInvocationID.x][0] + foo[gl_LocalInvocationID.x][1]) + foo[gl_LocalInvocationID.x][2]) + foo[gl_LocalInvocationID.x][3]; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared.comp index 029ab539fd..aefe89488c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float in_data[1]; @@ -17,7 +58,7 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u); kernel void main0(const device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { - threadgroup float sShared[4]; + threadgroup spvUnsafeArray sShared; sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; threadgroup_barrier(mem_flags::mem_threadgroup); _44.out_data[gl_GlobalInvocationID.x] = sShared[3u - gl_LocalInvocationIndex]; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/threadgroup-boolean-workaround.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/threadgroup-boolean-workaround.comp index c1eccf2780..c4aa12f50f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/threadgroup-boolean-workaround.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/threadgroup-boolean-workaround.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float4 values[1]; @@ -12,7 +53,7 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u); kernel void main0(device SSBO& _23 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - threadgroup short4 foo[4]; + threadgroup spvUnsafeArray foo; foo[gl_LocalInvocationIndex] = short4(_23.values[gl_GlobalInvocationID.x] != float4(10.0)); threadgroup_barrier(mem_flags::mem_threadgroup); _23.values[gl_GlobalInvocationID.x] = select(float4(40.0), float4(30.0), bool4(foo[gl_LocalInvocationIndex ^ 3u])); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag index 4083e4ea16..30046a1f28 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -5,6 +5,7 @@ using namespace metal; fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) { + uImageArray.fence(); 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/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc index 8ebde9d9d7..ab30b71d40 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc @@ -15,8 +15,8 @@ struct main0_patchOut struct main0_in { - uint3 m_86; - ushort2 m_90; + uint3 m_87; + ushort2 m_92; float4 gl_Position; }; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag index 25c6244894..beed4c25e1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag @@ -33,19 +33,19 @@ fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d +#include +#include + +using namespace metal; + +struct foo_t +{ + float x; + uint y; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d bar [[texture(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + if (!gl_HelperInvocation) + { + foo.x = 1.0; + } + uint _91 = (!gl_HelperInvocation ? atomic_exchange_explicit((device atomic_uint*)&foo.y, 0u, memory_order_relaxed) : uint{}); + if (int(gl_FragCoord.x) == 3) + { + gl_HelperInvocation = true, discard_fragment(); + } + int2 _101 = int2(gl_FragCoord.xy); + (gl_HelperInvocation ? ((void)0) : bar.write(uint4(1u), uint2(_101))); + uint _103 = (!gl_HelperInvocation ? atomic_fetch_add_explicit((device atomic_uint*)&foo.y, 42u, memory_order_relaxed) : uint{}); + uint _108 = (!gl_HelperInvocation ? bar.atomic_fetch_or(uint2(_101), 62u).x : uint{}); + uint _110 = (!gl_HelperInvocation ? atomic_fetch_and_explicit((device atomic_uint*)&foo.y, 65535u, memory_order_relaxed) : uint{}); + uint _112 = (!gl_HelperInvocation ? atomic_fetch_xor_explicit((device atomic_uint*)&foo.y, 4294967040u, memory_order_relaxed) : uint{}); + uint _114 = (!gl_HelperInvocation ? atomic_fetch_min_explicit((device atomic_uint*)&foo.y, 1u, memory_order_relaxed) : uint{}); + uint _119 = (!gl_HelperInvocation ? bar.atomic_fetch_max(uint2(_101), 100u).x : uint{}); + uint _124; + uint4 _135; + if (!gl_HelperInvocation) + { + do + { + _135.x = 100u; + } while (!bar.atomic_compare_exchange_weak(uint2(_101), &_135, 42u) && _135.x == 100u); + _124 = _135.x; + } + else + { + _124 = {}; + } + bool _125 = gl_HelperInvocation; + out.fragColor = float4(1.0, float(_125), 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag new file mode 100644 index 0000000000..541096a1fa --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +struct foo +{ + int x; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +fragment main0_out main0(device foo& _24 [[buffer(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + if (gl_FragCoord.y == 7.0) + { + gl_HelperInvocation = true, discard_fragment(); + } + if (!gl_HelperInvocation) + { + _24.x = 0; + } + for (; float(_24.x) < gl_FragCoord.x; ) + { + if (!gl_HelperInvocation) + { + _24.x++; + } + continue; + } + out.fragColor = float4(float(_24.x), 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag index 2b2e085389..ca109d12fd 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag @@ -33,19 +33,19 @@ fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d +#include +#include + +using namespace metal; + +struct foo_t +{ + float x; + uint y; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d bar [[texture(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + if (!gl_HelperInvocation) + { + foo.x = 1.0; + } + uint _90 = (!gl_HelperInvocation ? atomic_exchange_explicit((device atomic_uint*)&foo.y, 0u, memory_order_relaxed) : uint{}); + if (int(gl_FragCoord.x) == 3) + { + gl_HelperInvocation = true, discard_fragment(); + } + int2 _100 = int2(gl_FragCoord.xy); + (gl_HelperInvocation ? ((void)0) : bar.write(uint4(1u), uint2(_100))); + uint _102 = (!gl_HelperInvocation ? atomic_fetch_add_explicit((device atomic_uint*)&foo.y, 42u, memory_order_relaxed) : uint{}); + uint _107 = (!gl_HelperInvocation ? bar.atomic_fetch_or(uint2(_100), 62u).x : uint{}); + uint _109 = (!gl_HelperInvocation ? atomic_fetch_and_explicit((device atomic_uint*)&foo.y, 65535u, memory_order_relaxed) : uint{}); + uint _111 = (!gl_HelperInvocation ? atomic_fetch_xor_explicit((device atomic_uint*)&foo.y, 4294967040u, memory_order_relaxed) : uint{}); + uint _113 = (!gl_HelperInvocation ? atomic_fetch_min_explicit((device atomic_uint*)&foo.y, 1u, memory_order_relaxed) : uint{}); + uint _118 = (!gl_HelperInvocation ? bar.atomic_fetch_max(uint2(_100), 100u).x : uint{}); + uint _123; + uint4 _131; + if (!gl_HelperInvocation) + { + do + { + _131.x = 100u; + } while (!bar.atomic_compare_exchange_weak(uint2(_100), &_131, 42u) && _131.x == 100u); + _123 = _131.x; + } + else + { + _123 = {}; + } + out.fragColor = float4(1.0, 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag new file mode 100644 index 0000000000..e90faef7e9 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag @@ -0,0 +1,45 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct Buffer3 +{ + int baz; +}; + +struct Buffer +{ + int foo; + uint bar; +}; + +struct Buffer2 +{ + uint quux; +}; + +struct spvDescriptorSetBuffer0 +{ + device Buffer3* m_9 [[id(0)]]; + texture2d img4 [[id(1)]]; + texture2d img [[id(2), raster_order_group(0)]]; + texture2d img3 [[id(3), raster_order_group(0)]]; + texture2d img2 [[id(4), raster_order_group(0)]]; + volatile device Buffer* m_42 [[id(5), raster_order_group(0)]]; + device Buffer2* m_52 [[id(6), raster_order_group(0)]]; +}; + +fragment void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]]) +{ + (*spvDescriptorSet0.m_9).baz = 0; + spvDescriptorSet0.img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1))); + spvDescriptorSet0.img.write(spvDescriptorSet0.img3.read(uint2(int2(0))), uint2(int2(0))); + uint _39 = spvDescriptorSet0.img2.atomic_fetch_add(uint2(int2(0)), 1u).x; + (*spvDescriptorSet0.m_42).foo += 42; + uint _55 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(*spvDescriptorSet0.m_42).bar, (*spvDescriptorSet0.m_52).quux, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.frag new file mode 100644 index 0000000000..73afda48e2 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl31.frag @@ -0,0 +1,34 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct Buffer3 +{ + int baz; +}; + +struct Buffer +{ + int foo; + uint bar; +}; + +struct Buffer2 +{ + uint quux; +}; + +fragment void main0(device Buffer3& _9 [[buffer(0)]], volatile device Buffer& _42 [[buffer(1), raster_order_group(0)]], device Buffer2& _52 [[buffer(2), raster_order_group(0)]], texture2d img4 [[texture(0)]], texture2d img [[texture(1), raster_order_group(0)]], texture2d img3 [[texture(2), raster_order_group(0)]], texture2d img2 [[texture(3), raster_order_group(0)]]) +{ + _9.baz = 0; + img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1))); + img.write(img3.read(uint2(int2(0))), uint2(int2(0))); + uint _39 = img2.atomic_fetch_add(uint2(int2(0)), 1u).x; + _42.foo += 42; + uint _55 = atomic_fetch_and_explicit((volatile device atomic_uint*)&_42.bar, _52.quux, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.ios.msl2.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.ios.msl2.frag index 3b2885e2e2..d40e2a344c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.ios.msl2.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.ios.msl2.frag @@ -11,7 +11,7 @@ struct main0_out [[ early_fragment_tests ]] fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask, post_depth_coverage]]) { main0_out out = {}; - out.FragColor = float4(float(gl_SampleMaskIn)); + out.FragColor = float4(float(int(gl_SampleMaskIn))); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.msl23.frag index 3b2885e2e2..d40e2a344c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/post-depth-coverage.msl23.frag @@ -11,7 +11,7 @@ struct main0_out [[ early_fragment_tests ]] fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask, post_depth_coverage]]) { main0_out out = {}; - out.FragColor = float4(float(gl_SampleMaskIn)); + out.FragColor = float4(float(int(gl_SampleMaskIn))); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag index 859ace2cd4..dabcbd3615 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include #if __METAL_VERSION__ >= 230 @@ -7,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct main0_out { float4 outColor [[color(0)]]; @@ -21,7 +47,7 @@ fragment main0_out main0(main0_in in [[stage_in]], raytracing::acceleration_stru { main0_out out = {}; raytracing::intersection_query rayQuery; - rayQuery.reset(ray(float3((in.inPos.xy * 4.0) - float2(2.0), 1.0), float3(0.0, 0.0, -1.0), 0.001000000047497451305389404296875, 2.0), topLevelAS, intersection_params()); + rayQuery.reset(ray(float3((in.inPos.xy * 4.0) - float2(2.0), 1.0), float3(0.0, 0.0, -1.0), 0.001000000047497451305389404296875, 2.0), topLevelAS, 255u, spvMakeIntersectionParams(4u)); for (;;) { bool _88 = rayQuery.next(); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..b58e9e22e2 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,159 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include +#if __METAL_VERSION__ >= 230 +#include +using namespace metal::raytracing; +#endif + +using namespace metal; + +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct Ssbo +{ + uint val; + uint data[1]; +}; + +struct Ubo +{ + uint val; +}; + +struct main0_in +{ + uint inputId [[user(locn0)]]; +}; + +fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor* ssbo_ [[buffer(4)]], const device spvDescriptor* ubo_ [[buffer(5)]], const device spvDescriptor>* smp_textures_ [[buffer(0)]], const device spvDescriptor>* textures_ [[buffer(2)]], const device spvDescriptor>* images_ [[buffer(6)]], const device spvDescriptor* smp_texturesSmplr_ [[buffer(1)]], const device spvDescriptor* smp_ [[buffer(3)]], const device spvDescriptor>* tlas_ [[buffer(7)]]) +{ + spvDescriptorArray> smp_textures {smp_textures_}; + spvDescriptorArray smp_texturesSmplr {smp_texturesSmplr_}; + spvDescriptorArray> textures {textures_}; + spvDescriptorArray smp {smp_}; + spvDescriptorArray ssbo {ssbo_}; + spvDescriptorArray ubo {ubo_}; + spvDescriptorArray> images {images_}; + spvDescriptorArray> tlas {tlas_}; + + uint _231 = in.inputId; + raytracing::intersection_query rayQuery; + raytracing::intersection_query rayQuery_1; + if (smp_textures[_231].sample(smp_texturesSmplr[_231], float2(0.0), level(0.0)).w > 0.5) + { + discard_fragment(); + } + uint _249 = in.inputId + 8u; + if (textures[_231].sample(smp[_249], float2(0.0), level(0.0)).w > 0.5) + { + discard_fragment(); + } + if (ssbo[_231]->val == 2u) + { + discard_fragment(); + } + if (int((ssbo.length(123) - 4) / 4) == 25) + { + discard_fragment(); + } + if (ubo[_231]->val == 2u) + { + discard_fragment(); + } + if (images[_231].read(uint2(int2(0))).w > 0.5) + { + discard_fragment(); + } + rayQuery.reset(ray(float3(0.0), float3(1.0), 0.00999999977648258209228515625, 1.0), tlas[in.inputId], 255u, spvMakeIntersectionParams(0u)); + bool _301 = rayQuery.next(); + if (smp_textures[_231].sample(smp_texturesSmplr[_231], float2(0.0), level(0.0)).w > 0.5) + { + discard_fragment(); + } + if (textures[_231].sample(smp[_231], float2(0.0), level(0.0)).w > 0.5) + { + discard_fragment(); + } + if (images[_231].read(uint2(int2(0))).w > 0.5) + { + discard_fragment(); + } + rayQuery_1.reset(ray(float3(0.0), float3(1.0), 0.00999999977648258209228515625, 1.0), tlas[in.inputId], 255u, spvMakeIntersectionParams(0u)); + bool _336 = rayQuery_1.next(); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..8651782008 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct Ssbo +{ + uint val; + uint data[1]; +}; + +struct main0_in +{ + uint inputId [[user(locn0)]]; +}; + +fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor* ssbo_ [[buffer(0)]]) +{ + spvDescriptorArray ssbo {ssbo_}; + + uint _15 = in.inputId; + if (ssbo[_15]->val == 2u) + { + discard_fragment(); + } + if (int((ssbo.length(123) - 4) / 4) == 25) + { + discard_fragment(); + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag index 626fe4c79c..aab186ed02 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag @@ -13,7 +13,7 @@ fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]], uint gl_SampleID { main0_out out = {}; out.FragColor = float4(1.0); - out.gl_SampleMask = (gl_SampleMaskIn & 0x22 & (1 << gl_SampleID)); + out.gl_SampleMask = int((gl_SampleMaskIn & 0x22 & (1 << gl_SampleID))); out.gl_SampleMask &= 0x22; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag index f478901b6b..0f18da5de7 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag @@ -13,7 +13,7 @@ fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]]) { main0_out out = {}; out.FragColor = float4(1.0); - out.gl_SampleMask = (gl_SampleMaskIn & 0x22); + out.gl_SampleMask = int((gl_SampleMaskIn & 0x22)); out.gl_SampleMask &= 0x22; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag new file mode 100644 index 0000000000..35597e470b --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag @@ -0,0 +1,44 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) +{ + // Major axis selection + float3 absP = abs(P); + bool xMajor = absP.x >= max(absP.y, absP.z); + bool yMajor = absP.y >= absP.z; + float3 Q = xMajor ? P.yzx : (yMajor ? P.xzy : P); + float3 dQdx = xMajor ? dPdx.yzx : (yMajor ? dPdx.xzy : dPdx); + float3 dQdy = xMajor ? dPdy.yzx : (yMajor ? dPdy.xzy : dPdy); + + // Skip a couple of operations compared to usual projection + float4 d = float4(dQdx.xy, dQdy.xy) - (Q.xy / Q.z).xyxy * float4(dQdx.zz, dQdy.zz); + + // Final swizzle to put the intermediate values into non-ignored components + // X major: X and Z + // Y major: X and Y + // Z major: Y and Z + return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); +} + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vTex [[user(locn0), flat]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texturecube uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor += uSampler.sample(uSamplerSmplr, in.vTex, spvGradientCube(in.vTex, float3(5.0), float3(8.0))); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc index 24928da01d..bf84a77ce0 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc @@ -44,114 +44,6 @@ struct spvUnsafeArray } }; -template -inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - struct main0_out { float4 gl_Position; @@ -171,14 +63,14 @@ struct main0_in kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup float4 spvStorageFoo[8][4][2]; - threadgroup float4 (&Foo)[4][2] = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray, 4> spvStorageFoo[8]; + threadgroup auto &Foo = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); gl_out[gl_InvocationID].gl_Position = float4(1.0); - spvArrayCopyFromDeviceToThreadGroup1(Foo[gl_InvocationID], gl_in[gl_InvocationID].iFoo.elements); + Foo[gl_InvocationID] = gl_in[gl_InvocationID].iFoo; if (gl_InvocationID == 0) { spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc index a08364e2b3..ec2316b4f4 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc @@ -44,114 +44,6 @@ struct spvUnsafeArray } }; -template -inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - struct main0_out { float4 gl_Position; @@ -171,7 +63,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup float4 Foo[4][2]; + threadgroup spvUnsafeArray, 4> Foo; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -181,7 +73,7 @@ kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_ return; gl_out[gl_InvocationID].gl_Position = float4(1.0); spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); - spvArrayCopyFromStackToThreadGroup1(Foo[gl_InvocationID], _38.elements); + Foo[gl_InvocationID] = _38; if (gl_InvocationID == 0) { spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc index f2f17bad37..ed7df5bdbb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc @@ -32,7 +32,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; threadgroup P spvStorage_11[8]; - threadgroup P (&_11) = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup auto &_11 = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); _11.a = 1.0; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc index 7db78a9ba5..d524780f9b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct P { float a; @@ -29,7 +70,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup C c[4]; + threadgroup spvUnsafeArray c; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.m_11_a = 1.0; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc index ad793918e2..a6ca377a19 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct P { float a; @@ -30,8 +71,8 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup C spvStoragec[8][4]; - threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragec[8]; + threadgroup auto &c = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc index 7c8e387824..cac58f6411 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position; @@ -16,7 +57,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v0[4]; + threadgroup spvUnsafeArray v0; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; v0[gl_InvocationID] = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc index 7a5e183a26..b68966933d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc @@ -59,8 +59,8 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup float4 spvStoragev0[8][4]; - threadgroup float4 (&v0)[4] = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragev0[8]; + threadgroup auto &v0 = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc index ef3ff9c221..a04778d522 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc @@ -58,7 +58,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v0[4]; + threadgroup spvUnsafeArray v0; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; v0[gl_InvocationID] = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc index 28ec0be0c6..c4533a7261 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 v0; @@ -19,8 +60,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; - threadgroup float4 spvStoragev1[8][2]; - threadgroup float4 (&v1)[2] = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragev1[8]; + threadgroup auto &v1 = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); gl_out[gl_InvocationID].v0 = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc index 1673d52329..7c0b39cb14 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 v0; @@ -17,7 +58,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v1[2]; + threadgroup spvUnsafeArray v1; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; gl_out[gl_InvocationID].v0 = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc index 694cdbb7ff..152cebf20e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc @@ -67,8 +67,8 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc index da976c9a8a..da8ccb6328 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc @@ -66,7 +66,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; gl_out[gl_InvocationID].v0 = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc index c55e337682..deb67c9f4f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc @@ -67,8 +67,8 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc index 04584de49f..6816cbd6f2 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc @@ -66,7 +66,7 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; gl_out[gl_InvocationID].v0 = float4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc index 1618eaa627..18f3824f3f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc @@ -68,7 +68,7 @@ struct main0_patchOut struct main0_in { float3 in_tc_attr; - ushort2 m_196; + ushort2 m_197; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc index ddf142ccba..f4e1a565dc 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc @@ -11,7 +11,7 @@ struct main0_out struct main0_in { float4 vInputs; - ushort2 m_44; + ushort2 m_45; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc index 28fff01555..53604a6b45 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc @@ -13,7 +13,7 @@ struct main0_out struct main0_in { float3 in_tc_attr; - ushort2 m_104; + ushort2 m_105; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc index ae33de517a..7e34079598 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc @@ -10,8 +10,8 @@ struct main0_out struct main0_in { - uint3 m_82; - ushort2 m_86; + uint3 m_83; + ushort2 m_88; float4 gl_Position; }; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc index 6c52654615..e963dd8d8c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc @@ -20,7 +20,7 @@ struct main0_out struct main0_in { float3 in_tc_attr; - ushort2 m_119; + ushort2 m_120; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc index 356a963d68..cdd7ada79e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc @@ -22,7 +22,7 @@ struct main0_patchOut struct main0_in { float3 vPatchPosBase; - ushort2 m_996; + ushort2 m_997; }; kernel void main0(constant UBO& _41 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese new file mode 100644 index 0000000000..aa9566d605 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(uint gl_PrimitiveID [[patch_id]]) +{ + main0_out out = {}; + uint gl_PatchVerticesIn = 0; + out.gl_Position = float4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/buffer_device_address.msl2.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/buffer_device_address.msl2.vert index 3844298695..6f251d927d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/vert/buffer_device_address.msl2.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/buffer_device_address.msl2.vert @@ -31,32 +31,11 @@ struct main0_out vertex main0_out main0(constant Registers& registers [[buffer(0)]], uint gl_InstanceIndex [[instance_id]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; - int slice = int(gl_InstanceIndex); - const device Position* __restrict positions = registers.references->buffers[int(gl_InstanceIndex)]; - float2 _45 = registers.references->buffers[int(gl_InstanceIndex)]->positions[int(gl_VertexIndex)] * 2.5; - float2 pos = _45; - float2 _60 = _45 + ((float2(float(int(gl_InstanceIndex) % 8), float(int(gl_InstanceIndex) / 8)) - float2(3.5)) * 3.0); - pos = _60; - out.gl_Position = registers.view_projection * float4(_60, 0.0, 1.0); + out.gl_Position = registers.view_projection * float4((registers.references->buffers[int(gl_InstanceIndex)]->positions[int(gl_VertexIndex)] * 2.5) + ((float2(float(int(gl_InstanceIndex) % 8), float(int(gl_InstanceIndex) / 8)) - float2(3.5)) * 3.0), 0.0, 1.0); int _82 = int(gl_VertexIndex) % 16; - int index_x = _82; int _85 = int(gl_VertexIndex) / 16; - int index_y = _85; - float _92 = sin(float(_82)); - float _94 = fma(0.300000011920928955078125, _92, 0.5); - float r = _94; - float _98 = sin(float(_85)); - float _100 = fma(0.300000011920928955078125, _98, 0.5); - float g = _100; - int _105 = (_82 ^ _85) & 1; - int checkerboard = _105; - float _107 = float(_105); - float _111 = fma(_107, 0.800000011920928955078125, 0.20000000298023223876953125); - float _113 = _94 * _111; - r = _113; - float _119 = _100 * _111; - g = _119; - out.out_color = float4(_113, _119, 0.1500000059604644775390625, 1.0); + float _111 = fma(float((_82 ^ _85) & 1), 0.800000011920928955078125, 0.20000000298023223876953125); + out.out_color = float4(fma(0.300000011920928955078125, sin(float(_82)), 0.5) * _111, fma(0.300000011920928955078125, sin(float(_85)), 0.5) * _111, 0.1500000059604644775390625, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag index 274cea2de1..05d5eb4a82 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag @@ -13,9 +13,9 @@ fragment main0_out main0() main0_out out = {}; bool gl_HelperInvocation = {}; gl_HelperInvocation = simd_is_helper_thread(); - bool _15 = gl_HelperInvocation; + bool _9 = gl_HelperInvocation; gl_HelperInvocation = true, discard_fragment(); - if (!_15) + if (!_9) { out.FragColor = float4(1.0, 0.0, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag index a7b390a8cf..faf2b808d0 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag @@ -256,7 +256,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G float4 _260 = SSProfilesTexture.read(uint2(int3(1, int(uint(fma(select(float4(0.0), SceneTexturesStruct_GBufferDTexture.sample(SceneTexturesStruct_GBufferDTextureSampler, _114, level(0.0)), bool4(!(((_240 & 4294967280u) & 16u) != 0u))).x, 255.0, 0.5))), 0).xy), 0); float _263 = _260.y * 0.5; float3 _266 = fma(-_236, float3(_263), _148); - float _274 = pow(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0); + float _274 = powr(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0); float _445; if (_160) { diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/global-constant-arrays.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/global-constant-arrays.asm.frag index 192c0b411b..6543df88a5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/global-constant-arrays.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/global-constant-arrays.asm.frag @@ -161,8 +161,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float3 _599; if (_Globals.OutputDevice >= 3u) { - float3 _591 = pow(_577, float3(0.0126833133399486541748046875)); - _599 = pow(fast::max(float3(0.0), _591 - float3(0.8359375)) / fma(float3(-18.6875), _591, float3(18.8515625)), float3(6.277394771575927734375)) * float3(10000.0); + float3 _591 = powr(_577, float3(0.0126833133399486541748046875)); + _599 = powr(fast::max(float3(0.0), _591 - float3(0.8359375)) / fma(float3(-18.6875), _591, float3(18.8515625)), float3(6.277394771575927734375)) * float3(10000.0); } else { @@ -212,7 +212,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _861 = _Globals.ColorGammaMidtones * _Globals.ColorGamma; float4 _864 = _Globals.ColorGainMidtones * _Globals.ColorGain; float4 _867 = _Globals.ColorOffsetMidtones + _Globals.ColorOffset; - float3 _905 = fma(fma(pow(pow(fast::max(float3(0.0), mix(_772, _745, _808.xyz * float3(_808.w))) * float3(5.5555553436279296875), _811.xyz * float3(_811.w)) * float3(0.180000007152557373046875), float3(1.0) / (_814.xyz * float3(_814.w))), _817.xyz * float3(_817.w), _820.xyz + float3(_820.w)), float3(_852), fma(fma(pow(pow(fast::max(float3(0.0), mix(_772, _745, _751.xyz * float3(_751.w))) * float3(5.5555553436279296875), _756.xyz * float3(_756.w)) * float3(0.180000007152557373046875), float3(1.0) / (_761.xyz * float3(_761.w))), _766.xyz * float3(_766.w), _771.xyz + float3(_771.w)), float3(1.0 - _804), fma(pow(pow(fast::max(float3(0.0), mix(_772, _745, _855.xyz * float3(_855.w))) * float3(5.5555553436279296875), _858.xyz * float3(_858.w)) * float3(0.180000007152557373046875), float3(1.0) / (_861.xyz * float3(_861.w))), _864.xyz * float3(_864.w), _867.xyz + float3(_867.w)) * float3(_804 - _852))); + float3 _905 = fma(fma(powr(powr(fast::max(float3(0.0), mix(_772, _745, _808.xyz * float3(_808.w))) * float3(5.5555553436279296875), _811.xyz * float3(_811.w)) * float3(0.180000007152557373046875), float3(1.0) / (_814.xyz * float3(_814.w))), _817.xyz * float3(_817.w), _820.xyz + float3(_820.w)), float3(_852), fma(fma(powr(powr(fast::max(float3(0.0), mix(_772, _745, _751.xyz * float3(_751.w))) * float3(5.5555553436279296875), _756.xyz * float3(_756.w)) * float3(0.180000007152557373046875), float3(1.0) / (_761.xyz * float3(_761.w))), _766.xyz * float3(_766.w), _771.xyz + float3(_771.w)), float3(1.0 - _804), fma(powr(powr(fast::max(float3(0.0), mix(_772, _745, _855.xyz * float3(_855.w))) * float3(5.5555553436279296875), _858.xyz * float3(_858.w)) * float3(0.180000007152557373046875), float3(1.0) / (_861.xyz * float3(_861.w))), _864.xyz * float3(_864.w), _867.xyz + float3(_867.w)) * float3(_804 - _852))); float3 _906 = _905 * _549; float3 _914 = float3(_Globals.BlueCorrection); float3 _916 = mix(_905, _905 * ((_551 * float3x3(float3(0.940437257289886474609375, -0.01830687932670116424560546875, 0.07786960899829864501953125), float3(0.008378696627914905548095703125, 0.82866001129150390625, 0.162961304187774658203125), float3(0.0005471261101774871349334716796875, -0.00088337459601461887359619140625, 1.00033628940582275390625))) * _550), _914) * _551; @@ -316,7 +316,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa { _1189 = fast::max(float3(0.0), mix(_1119, _1119 * ((_551 * float3x3(float3(1.06317996978759765625, 0.02339559979736804962158203125, -0.08657260239124298095703125), float3(-0.010633699595928192138671875, 1.2063200473785400390625, -0.1956900060176849365234375), float3(-0.0005908869788981974124908447265625, 0.00105247995816171169281005859375, 0.999538004398345947265625))) * _550), _914) * _549); } - float3 _1218 = pow(fast::max(float3(0.0), mix((fma(float3(_Globals.MappingPolynomial.x), _1189 * _1189, float3(_Globals.MappingPolynomial.y) * _1189) + float3(_Globals.MappingPolynomial.z)) * float3(_Globals.ColorScale), _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); + float3 _1218 = powr(fast::max(float3(0.0), mix((fma(float3(_Globals.MappingPolynomial.x), _1189 * _1189, float3(_Globals.MappingPolynomial.y) * _1189) + float3(_Globals.MappingPolynomial.z)) * float3(_Globals.ColorScale), _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); float3 _3001; if (_Globals.OutputDevice == 0u) { @@ -329,7 +329,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2973 = _2961 * 12.9200000762939453125; break; } - _2973 = fma(pow(_2961, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _2973 = fma(powr(_2961, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _2974 = _1218.y; @@ -341,7 +341,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2986 = _2974 * 12.9200000762939453125; break; } - _2986 = fma(pow(_2974, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _2986 = fma(powr(_2974, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _2987 = _1218.z; @@ -353,7 +353,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2999 = _2987 * 12.9200000762939453125; break; } - _2999 = fma(pow(_2987, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _2999 = fma(powr(_2987, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } _3001 = float3(_2973, _2986, _2999); @@ -364,7 +364,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa if (_Globals.OutputDevice == 1u) { float3 _2953 = fast::max(float3(6.1035199905745685100555419921875e-05), (_1218 * _547) * _576); - _2960 = fast::min(_2953 * float3(4.5), fma(pow(fast::max(_2953, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)), float3(1.09899997711181640625), float3(-0.098999999463558197021484375))); + _2960 = fast::min(_2953 * float3(4.5), fma(powr(fast::max(_2953, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)), float3(1.09899997711181640625), float3(-0.098999999463558197021484375))); } else { @@ -593,7 +593,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2475 = _2472; } - float3 _2479 = (float3(pow(10.0, _2327), pow(10.0, _2401), pow(10.0, _2475)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); + float3 _2479 = (float3(powr(10.0, _2327), powr(10.0, _2401), powr(10.0, _2475)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); float _2685 = _2479.x; float _2688 = log((_2685 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2685); float _2689 = _2688 * 0.4342944622039794921875; @@ -702,8 +702,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2936 = _2928; } - float3 _2942 = pow(((float3(pow(10.0, _2768), pow(10.0, _2852), pow(10.0, _2936)) - float3(3.5073844628641381859779357910156e-05)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2950 = pow(fma(float3(18.8515625), _2942, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2942, float3(1.0))), float3(78.84375)); + float3 _2942 = powr(((float3(powr(10.0, _2768), powr(10.0, _2852), powr(10.0, _2936)) - float3(3.5073844628641381859779357910156e-05)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2950 = powr(fma(float3(18.8515625), _2942, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2942, float3(1.0))), float3(78.84375)); } else { @@ -932,7 +932,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1638 = _1635; } - float3 _1642 = (float3(pow(10.0, _1490), pow(10.0, _1564), pow(10.0, _1638)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); + float3 _1642 = (float3(powr(10.0, _1490), powr(10.0, _1564), powr(10.0, _1638)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); float _1848 = _1642.x; float _1851 = log((_1848 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _1848); float _1852 = _1851 * 0.4342944622039794921875; @@ -1041,20 +1041,20 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2084 = _2081; } - float3 _2089 = pow((float3(pow(10.0, _1926), pow(10.0, _2005), pow(10.0, _2084)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2097 = pow(fma(float3(18.8515625), _2089, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2089, float3(1.0))), float3(78.84375)); + float3 _2089 = powr((float3(powr(10.0, _1926), powr(10.0, _2005), powr(10.0, _2084)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2097 = powr(fma(float3(18.8515625), _2089, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2089, float3(1.0))), float3(78.84375)); } else { float3 _1260; if (_Globals.OutputDevice == 7u) { - float3 _1252 = pow(((_906 * _547) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _1260 = pow(fma(float3(18.8515625), _1252, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _1252, float3(1.0))), float3(78.84375)); + float3 _1252 = powr(((_906 * _547) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _1260 = powr(fma(float3(18.8515625), _1252, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _1252, float3(1.0))), float3(78.84375)); } else { - _1260 = pow((_1218 * _547) * _576, float3(_Globals.InverseGamma.z)); + _1260 = powr((_1218 * _547) * _576, float3(_Globals.InverseGamma.z)); } _2097 = _1260; } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag index 8b53cca3ad..31ef22892d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag @@ -162,8 +162,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float3 _625; if (_Globals.OutputDevice >= 3u) { - float3 _617 = pow(_603, float3(0.0126833133399486541748046875)); - _625 = pow(fast::max(float3(0.0), _617 - float3(0.8359375)) / fma(float3(-18.6875), _617, float3(18.8515625)), float3(6.277394771575927734375)) * float3(10000.0); + float3 _617 = powr(_603, float3(0.0126833133399486541748046875)); + _625 = powr(fast::max(float3(0.0), _617 - float3(0.8359375)) / fma(float3(-18.6875), _617, float3(18.8515625)), float3(6.277394771575927734375)) * float3(10000.0); } else { @@ -213,7 +213,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _887 = _Globals.ColorGammaMidtones * _Globals.ColorGamma; float4 _890 = _Globals.ColorGainMidtones * _Globals.ColorGain; float4 _893 = _Globals.ColorOffsetMidtones + _Globals.ColorOffset; - float3 _931 = fma(fma(pow(pow(fast::max(float3(0.0), mix(_798, _771, _834.xyz * float3(_834.w))) * float3(5.5555553436279296875), _837.xyz * float3(_837.w)) * float3(0.180000007152557373046875), float3(1.0) / (_840.xyz * float3(_840.w))), _843.xyz * float3(_843.w), _846.xyz + float3(_846.w)), float3(_878), fma(fma(pow(pow(fast::max(float3(0.0), mix(_798, _771, _777.xyz * float3(_777.w))) * float3(5.5555553436279296875), _782.xyz * float3(_782.w)) * float3(0.180000007152557373046875), float3(1.0) / (_787.xyz * float3(_787.w))), _792.xyz * float3(_792.w), _797.xyz + float3(_797.w)), float3(1.0 - _830), fma(pow(pow(fast::max(float3(0.0), mix(_798, _771, _881.xyz * float3(_881.w))) * float3(5.5555553436279296875), _884.xyz * float3(_884.w)) * float3(0.180000007152557373046875), float3(1.0) / (_887.xyz * float3(_887.w))), _890.xyz * float3(_890.w), _893.xyz + float3(_893.w)) * float3(_830 - _878))); + float3 _931 = fma(fma(powr(powr(fast::max(float3(0.0), mix(_798, _771, _834.xyz * float3(_834.w))) * float3(5.5555553436279296875), _837.xyz * float3(_837.w)) * float3(0.180000007152557373046875), float3(1.0) / (_840.xyz * float3(_840.w))), _843.xyz * float3(_843.w), _846.xyz + float3(_846.w)), float3(_878), fma(fma(powr(powr(fast::max(float3(0.0), mix(_798, _771, _777.xyz * float3(_777.w))) * float3(5.5555553436279296875), _782.xyz * float3(_782.w)) * float3(0.180000007152557373046875), float3(1.0) / (_787.xyz * float3(_787.w))), _792.xyz * float3(_792.w), _797.xyz + float3(_797.w)), float3(1.0 - _830), fma(powr(powr(fast::max(float3(0.0), mix(_798, _771, _881.xyz * float3(_881.w))) * float3(5.5555553436279296875), _884.xyz * float3(_884.w)) * float3(0.180000007152557373046875), float3(1.0) / (_887.xyz * float3(_887.w))), _890.xyz * float3(_890.w), _893.xyz + float3(_893.w)) * float3(_830 - _878))); float3 _932 = _931 * _575; float3 _940 = float3(_Globals.BlueCorrection); float3 _942 = mix(_931, _931 * ((_577 * float3x3(float3(0.940437257289886474609375, -0.01830687932670116424560546875, 0.07786960899829864501953125), float3(0.008378696627914905548095703125, 0.82866001129150390625, 0.162961304187774658203125), float3(0.0005471261101774871349334716796875, -0.00088337459601461887359619140625, 1.00033628940582275390625))) * _576), _940) * _577; @@ -327,7 +327,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1229 = _1217 * 12.9200000762939453125; break; } - _1229 = fma(pow(_1217, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _1229 = fma(powr(_1217, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _1230 = _1216.y; @@ -339,7 +339,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1242 = _1230 * 12.9200000762939453125; break; } - _1242 = fma(pow(_1230, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _1242 = fma(powr(_1230, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _1243 = _1216.z; @@ -351,7 +351,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1255 = _1243 * 12.9200000762939453125; break; } - _1255 = fma(pow(_1243, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _1255 = fma(powr(_1243, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float3 _1256 = float3(_1229, _1242, _1255); @@ -363,8 +363,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _1279 = Texture1.sample(Texture1Sampler, float2(_1274 * 0.0625, _1276)); float4 _1283 = Texture1.sample(Texture1Sampler, float2(fma(_1274, 0.0625, 0.0625), _1276)); float3 _1289 = fast::max(float3(6.1035199905745685100555419921875e-05), fma(float3(_Globals.LUTWeights[0].x), _1256, float3(_Globals.LUTWeights[1].x) * mix(_1279, _1283, float4(_1270 - _1271)).xyz)); - float3 _1295 = select(_1289 * float3(0.077399380505084991455078125), pow(fma(_1289, float3(0.94786727428436279296875), float3(0.0521326996386051177978515625)), float3(2.400000095367431640625)), _1289 > float3(0.040449999272823333740234375)); - float3 _1324 = pow(fast::max(float3(0.0), mix((fma(float3(_Globals.MappingPolynomial.x), _1295 * _1295, float3(_Globals.MappingPolynomial.y) * _1295) + float3(_Globals.MappingPolynomial.z)) * _Globals.ColorScale, _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); + float3 _1295 = select(_1289 * float3(0.077399380505084991455078125), powr(fma(_1289, float3(0.94786727428436279296875), float3(0.0521326996386051177978515625)), float3(2.400000095367431640625)), _1289 > float3(0.040449999272823333740234375)); + float3 _1324 = powr(fast::max(float3(0.0), mix((fma(float3(_Globals.MappingPolynomial.x), _1295 * _1295, float3(_Globals.MappingPolynomial.y) * _1295) + float3(_Globals.MappingPolynomial.z)) * _Globals.ColorScale, _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); float3 _3103; if (_Globals.OutputDevice == 0u) { @@ -377,7 +377,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3075 = _3063 * 12.9200000762939453125; break; } - _3075 = fma(pow(_3063, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _3075 = fma(powr(_3063, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _3076 = _1324.y; @@ -389,7 +389,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3088 = _3076 * 12.9200000762939453125; break; } - _3088 = fma(pow(_3076, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _3088 = fma(powr(_3076, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } float _3089 = _1324.z; @@ -401,7 +401,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3101 = _3089 * 12.9200000762939453125; break; } - _3101 = fma(pow(_3089, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); + _3101 = fma(powr(_3089, 0.4166666567325592041015625), 1.05499994754791259765625, -0.054999999701976776123046875); break; } _3103 = float3(_3075, _3088, _3101); @@ -412,7 +412,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa if (_Globals.OutputDevice == 1u) { float3 _3055 = fast::max(float3(6.1035199905745685100555419921875e-05), (_1324 * _573) * _602); - _3062 = fast::min(_3055 * float3(4.5), fma(pow(fast::max(_3055, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)), float3(1.09899997711181640625), float3(-0.098999999463558197021484375))); + _3062 = fast::min(_3055 * float3(4.5), fma(powr(fast::max(_3055, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)), float3(1.09899997711181640625), float3(-0.098999999463558197021484375))); } else { @@ -641,7 +641,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2579 = _2576; } - float3 _2583 = (float3(pow(10.0, _2431), pow(10.0, _2505), pow(10.0, _2579)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); + float3 _2583 = (float3(powr(10.0, _2431), powr(10.0, _2505), powr(10.0, _2579)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); float _2787 = _2583.x; float _2790 = log((_2787 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2787); float _2791 = _2790 * 0.4342944622039794921875; @@ -750,8 +750,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _3038 = _3030; } - float3 _3044 = pow(((float3(pow(10.0, _2870), pow(10.0, _2954), pow(10.0, _3038)) - float3(3.5073844628641381859779357910156e-05)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _3052 = pow(fma(float3(18.8515625), _3044, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _3044, float3(1.0))), float3(78.84375)); + float3 _3044 = powr(((float3(powr(10.0, _2870), powr(10.0, _2954), powr(10.0, _3038)) - float3(3.5073844628641381859779357910156e-05)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _3052 = powr(fma(float3(18.8515625), _3044, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _3044, float3(1.0))), float3(78.84375)); } else { @@ -980,7 +980,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1744 = _1741; } - float3 _1748 = (float3(pow(10.0, _1596), pow(10.0, _1670), pow(10.0, _1744)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); + float3 _1748 = (float3(powr(10.0, _1596), powr(10.0, _1670), powr(10.0, _1744)) * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); float _1952 = _1748.x; float _1955 = log((_1952 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _1952); float _1956 = _1955 * 0.4342944622039794921875; @@ -1089,20 +1089,20 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2188 = _2185; } - float3 _2193 = pow((float3(pow(10.0, _2030), pow(10.0, _2109), pow(10.0, _2188)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2201 = pow(fma(float3(18.8515625), _2193, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2193, float3(1.0))), float3(78.84375)); + float3 _2193 = powr((float3(powr(10.0, _2030), powr(10.0, _2109), powr(10.0, _2188)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2201 = powr(fma(float3(18.8515625), _2193, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _2193, float3(1.0))), float3(78.84375)); } else { float3 _1366; if (_Globals.OutputDevice == 7u) { - float3 _1358 = pow(((_932 * _573) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _1366 = pow(fma(float3(18.8515625), _1358, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _1358, float3(1.0))), float3(78.84375)); + float3 _1358 = powr(((_932 * _573) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _1366 = powr(fma(float3(18.8515625), _1358, float3(0.8359375)) * (float3(1.0) / fma(float3(18.6875), _1358, float3(1.0))), float3(78.84375)); } else { - _1366 = pow((_1324 * _573) * _602, float3(_Globals.InverseGamma.z)); + _1366 = powr((_1324 * _573) * _602, float3(_Globals.InverseGamma.z)); } _2201 = _1366; } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag index 790ad27a1d..cbd9124ccb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct type_View { float4x4 View_TranslatedWorldToClip; @@ -489,12 +530,12 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_View& View [[bu if (View.View_NumSceneColorMSAASamples > 1) { _268 = _255 * float4(float(View.View_NumSceneColorMSAASamples) * 0.25); - _269 = gl_SampleMaskIn & 15u; + _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0] & 15u; } else { _268 = _255; - _269 = gl_SampleMaskIn; + _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0]; } out.out_var_SV_Target0 = _268; out.gl_SampleMask = _269; diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc index 84540d3592..c2d047a7c5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc @@ -263,7 +263,7 @@ struct type_StructuredBuffer_v4float float4 _m0[1]; }; -constant float4 _142 = {}; +constant float4 _140 = {}; struct main0_out { @@ -300,7 +300,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], const device type_StructuredBuffer_v4float& View_PrimitiveSceneData [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -308,26 +308,26 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _144 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _145 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _146 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); - spvUnsafeArray, 12> _147 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0 }) }); - spvUnsafeArray _148 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD4, gl_in[1].in_var_TEXCOORD4, gl_in[2].in_var_TEXCOORD4, gl_in[3].in_var_TEXCOORD4, gl_in[4].in_var_TEXCOORD4, gl_in[5].in_var_TEXCOORD4, gl_in[6].in_var_TEXCOORD4, gl_in[7].in_var_TEXCOORD4, gl_in[8].in_var_TEXCOORD4, gl_in[9].in_var_TEXCOORD4, gl_in[10].in_var_TEXCOORD4, gl_in[11].in_var_TEXCOORD4 }); - spvUnsafeArray _149 = spvUnsafeArray({ gl_in[0].in_var_PRIMITIVE_ID, gl_in[1].in_var_PRIMITIVE_ID, gl_in[2].in_var_PRIMITIVE_ID, gl_in[3].in_var_PRIMITIVE_ID, gl_in[4].in_var_PRIMITIVE_ID, gl_in[5].in_var_PRIMITIVE_ID, gl_in[6].in_var_PRIMITIVE_ID, gl_in[7].in_var_PRIMITIVE_ID, gl_in[8].in_var_PRIMITIVE_ID, gl_in[9].in_var_PRIMITIVE_ID, gl_in[10].in_var_PRIMITIVE_ID, gl_in[11].in_var_PRIMITIVE_ID }); - spvUnsafeArray _150 = spvUnsafeArray({ gl_in[0].in_var_LIGHTMAP_ID, gl_in[1].in_var_LIGHTMAP_ID, gl_in[2].in_var_LIGHTMAP_ID, gl_in[3].in_var_LIGHTMAP_ID, gl_in[4].in_var_LIGHTMAP_ID, gl_in[5].in_var_LIGHTMAP_ID, gl_in[6].in_var_LIGHTMAP_ID, gl_in[7].in_var_LIGHTMAP_ID, gl_in[8].in_var_LIGHTMAP_ID, gl_in[9].in_var_LIGHTMAP_ID, gl_in[10].in_var_LIGHTMAP_ID, gl_in[11].in_var_LIGHTMAP_ID }); - spvUnsafeArray _259 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _284 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[0], _145[0], _146[0], _147[0], _148[0], _149[0], _150[0] } }, FBasePassInterpolantsVSToDS{ { } }, _259[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[1], _145[1], _146[1], _147[1], _148[1], _149[1], _150[1] } }, FBasePassInterpolantsVSToDS{ { } }, _259[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[2], _145[2], _146[2], _147[2], _148[2], _149[2], _150[2] } }, FBasePassInterpolantsVSToDS{ { } }, _259[2] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[3], _145[3], _146[3], _147[3], _148[3], _149[3], _150[3] } }, FBasePassInterpolantsVSToDS{ { } }, _259[3] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[4], _145[4], _146[4], _147[4], _148[4], _149[4], _150[4] } }, FBasePassInterpolantsVSToDS{ { } }, _259[4] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[5], _145[5], _146[5], _147[5], _148[5], _149[5], _150[5] } }, FBasePassInterpolantsVSToDS{ { } }, _259[5] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[6], _145[6], _146[6], _147[6], _148[6], _149[6], _150[6] } }, FBasePassInterpolantsVSToDS{ { } }, _259[6] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[7], _145[7], _146[7], _147[7], _148[7], _149[7], _150[7] } }, FBasePassInterpolantsVSToDS{ { } }, _259[7] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[8], _145[8], _146[8], _147[8], _148[8], _149[8], _150[8] } }, FBasePassInterpolantsVSToDS{ { } }, _259[8] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[9], _145[9], _146[9], _147[9], _148[9], _149[9], _150[9] } }, FBasePassInterpolantsVSToDS{ { } }, _259[9] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[10], _145[10], _146[10], _147[10], _148[10], _149[10], _150[10] } }, FBasePassInterpolantsVSToDS{ { } }, _259[10] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[11], _145[11], _146[11], _147[11], _148[11], _149[11], _150[11] } }, FBasePassInterpolantsVSToDS{ { } }, _259[11] } }); - spvUnsafeArray param_var_I = _284; - float4 _301 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _310 = View_PrimitiveSceneData._m0[(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId * 26u) + 22u].xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _313 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _314 = 2u * gl_InvocationID; - uint _315 = 3u + _314; - uint _316 = _314 + 4u; - float4 _328 = float4(param_var_I[_313].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _336 = float4(param_var_I[_315].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _344 = float4(param_var_I[_316].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _392 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_313].Position) - (float4(dot(param_var_I[_313].Position - param_var_I[gl_InvocationID].Position, _301)) * _301)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_315].Position) + param_var_I[_316].Position) - (float4(dot(param_var_I[_316].Position - param_var_I[_315].Position, _336)) * _336)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_313].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_313].Position, _328)) * _328)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_316].Position) + param_var_I[_315].Position) - (float4(dot(param_var_I[_315].Position - param_var_I[_316].Position, _344)) * _344)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + spvUnsafeArray _142 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _143 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _144 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); + spvUnsafeArray, 12> _145 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0 }) }); + spvUnsafeArray _146 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD4, gl_in[1].in_var_TEXCOORD4, gl_in[2].in_var_TEXCOORD4, gl_in[3].in_var_TEXCOORD4, gl_in[4].in_var_TEXCOORD4, gl_in[5].in_var_TEXCOORD4, gl_in[6].in_var_TEXCOORD4, gl_in[7].in_var_TEXCOORD4, gl_in[8].in_var_TEXCOORD4, gl_in[9].in_var_TEXCOORD4, gl_in[10].in_var_TEXCOORD4, gl_in[11].in_var_TEXCOORD4 }); + spvUnsafeArray _147 = spvUnsafeArray({ gl_in[0].in_var_PRIMITIVE_ID, gl_in[1].in_var_PRIMITIVE_ID, gl_in[2].in_var_PRIMITIVE_ID, gl_in[3].in_var_PRIMITIVE_ID, gl_in[4].in_var_PRIMITIVE_ID, gl_in[5].in_var_PRIMITIVE_ID, gl_in[6].in_var_PRIMITIVE_ID, gl_in[7].in_var_PRIMITIVE_ID, gl_in[8].in_var_PRIMITIVE_ID, gl_in[9].in_var_PRIMITIVE_ID, gl_in[10].in_var_PRIMITIVE_ID, gl_in[11].in_var_PRIMITIVE_ID }); + spvUnsafeArray _148 = spvUnsafeArray({ gl_in[0].in_var_LIGHTMAP_ID, gl_in[1].in_var_LIGHTMAP_ID, gl_in[2].in_var_LIGHTMAP_ID, gl_in[3].in_var_LIGHTMAP_ID, gl_in[4].in_var_LIGHTMAP_ID, gl_in[5].in_var_LIGHTMAP_ID, gl_in[6].in_var_LIGHTMAP_ID, gl_in[7].in_var_LIGHTMAP_ID, gl_in[8].in_var_LIGHTMAP_ID, gl_in[9].in_var_LIGHTMAP_ID, gl_in[10].in_var_LIGHTMAP_ID, gl_in[11].in_var_LIGHTMAP_ID }); + spvUnsafeArray _257 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _282 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[0], _143[0], _144[0], _145[0], _146[0], _147[0], _148[0] } }, FBasePassInterpolantsVSToDS{ { } }, _257[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[1], _143[1], _144[1], _145[1], _146[1], _147[1], _148[1] } }, FBasePassInterpolantsVSToDS{ { } }, _257[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[2], _143[2], _144[2], _145[2], _146[2], _147[2], _148[2] } }, FBasePassInterpolantsVSToDS{ { } }, _257[2] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[3], _143[3], _144[3], _145[3], _146[3], _147[3], _148[3] } }, FBasePassInterpolantsVSToDS{ { } }, _257[3] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[4], _143[4], _144[4], _145[4], _146[4], _147[4], _148[4] } }, FBasePassInterpolantsVSToDS{ { } }, _257[4] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[5], _143[5], _144[5], _145[5], _146[5], _147[5], _148[5] } }, FBasePassInterpolantsVSToDS{ { } }, _257[5] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[6], _143[6], _144[6], _145[6], _146[6], _147[6], _148[6] } }, FBasePassInterpolantsVSToDS{ { } }, _257[6] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[7], _143[7], _144[7], _145[7], _146[7], _147[7], _148[7] } }, FBasePassInterpolantsVSToDS{ { } }, _257[7] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[8], _143[8], _144[8], _145[8], _146[8], _147[8], _148[8] } }, FBasePassInterpolantsVSToDS{ { } }, _257[8] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[9], _143[9], _144[9], _145[9], _146[9], _147[9], _148[9] } }, FBasePassInterpolantsVSToDS{ { } }, _257[9] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[10], _143[10], _144[10], _145[10], _146[10], _147[10], _148[10] } }, FBasePassInterpolantsVSToDS{ { } }, _257[10] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[11], _143[11], _144[11], _145[11], _146[11], _147[11], _148[11] } }, FBasePassInterpolantsVSToDS{ { } }, _257[11] } }); + spvUnsafeArray param_var_I = _282; + float4 _299 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _308 = View_PrimitiveSceneData._m0[(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId * 26u) + 22u].xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _311 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _312 = 2u * gl_InvocationID; + uint _313 = 3u + _312; + uint _314 = _312 + 4u; + float4 _326 = float4(param_var_I[_311].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _334 = float4(param_var_I[_313].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _342 = float4(param_var_I[_314].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _390 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_311].Position) - (float4(dot(param_var_I[_311].Position - param_var_I[gl_InvocationID].Position, _299)) * _299)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_313].Position) + param_var_I[_314].Position) - (float4(dot(param_var_I[_314].Position - param_var_I[_313].Position, _334)) * _334)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_311].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_311].Position, _326)) * _326)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_314].Position) + param_var_I[_313].Position) - (float4(dot(param_var_I[_313].Position - param_var_I[_314].Position, _342)) * _342)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_COLOR0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.Color; @@ -336,60 +336,60 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) gl_out[gl_InvocationID].out_var_PRIMITIVE_ID = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId; gl_out[gl_InvocationID].out_var_LIGHTMAP_ID = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.LightmapDataIndex; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_PN_POSITION = _392; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _310; + gl_out[gl_InvocationID].out_var_PN_POSITION = _390; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _308; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _392, _310, 1.0, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _390, _308, 1.0, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _450 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _463; - _463.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _463.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _463.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _463.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _589; + float4 _448 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _461; + _461.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _461.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _461.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _461.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _587; for (;;) { - float4 _489 = View.View_ViewToClip * float4(0.0); - float4 _494 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _495 = _494.xyz; - float3 _496 = _489.xyz; - float _498 = _494.w; - float _499 = _489.w; - float4 _516 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _517 = _516.xyz; - float _519 = _516.w; - float4 _537 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _538 = _537.xyz; - float _540 = _537.w; - if (any((((int3((_495 - _496) < float3(_498 + _499)) + (int3(2) * int3((_495 + _496) > float3((-_498) - _499)))) | (int3((_517 - _496) < float3(_519 + _499)) + (int3(2) * int3((_517 + _496) > float3((-_519) - _499))))) | (int3((_538 - _496) < float3(_540 + _499)) + (int3(2) * int3((_538 + _496) > float3((-_540) - _499))))) != int3(3))) + float4 _487 = View.View_ViewToClip * float4(0.0); + float4 _492 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _493 = _492.xyz; + float3 _494 = _487.xyz; + float _496 = _492.w; + float _497 = _487.w; + float4 _514 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _515 = _514.xyz; + float _517 = _514.w; + float4 _535 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _536 = _535.xyz; + float _538 = _535.w; + if (any((((int3((_493 - _494) < float3(_496 + _497)) + (int3(2) * int3((_493 + _494) > float3((-_496) - _497)))) | (int3((_515 - _494) < float3(_517 + _497)) + (int3(2) * int3((_515 + _494) > float3((-_517) - _497))))) | (int3((_536 - _494) < float3(_538 + _497)) + (int3(2) * int3((_536 + _494) > float3((-_538) - _497))))) != int3(3))) { - _589 = float4(0.0); + _587 = float4(0.0); break; } - float3 _558 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _559 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _560 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _563 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _566 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _569 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _573 = sqrt(dot(_559, _559) / dot(_566, _566)); - float _577 = sqrt(dot(_560, _560) / dot(_569, _569)); - float _581 = sqrt(dot(_558, _558) / dot(_563, _563)); - float4 _582 = float4(_573, _577, _581, 1.0); - _582.w = 0.333000004291534423828125 * ((_573 + _577) + _581); - _589 = float4(View.View_AdaptiveTessellationFactor) * _582; + float3 _556 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _557 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _558 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _561 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _564 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _567 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _571 = sqrt(dot(_557, _557) / dot(_564, _564)); + float _575 = sqrt(dot(_558, _558) / dot(_567, _567)); + float _579 = sqrt(dot(_556, _556) / dot(_561, _561)); + float4 _580 = float4(_571, _575, _579, 1.0); + _580.w = 0.333000004291534423828125 * ((_571 + _575) + _579); + _587 = float4(View.View_AdaptiveTessellationFactor) * _580; break; } - float4 _591 = fast::clamp(_463 * _589, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_591.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_591.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_591.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_591.w); - patchOut.out_var_PN_POSITION9 = _450 + ((_450 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _589 = fast::clamp(_461 * _587, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_589.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_589.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_589.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_589.w); + patchOut.out_var_PN_POSITION9 = _448 + ((_448 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc index 3bfbb69cde..61fe177287 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc @@ -304,7 +304,7 @@ struct type_Primitive float4 Primitive_CustomPrimitiveData[4]; }; -constant float4 _140 = {}; +constant float4 _136 = {}; struct main0_out { @@ -342,7 +342,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], constant type_Primitive& Primitive [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -350,114 +350,114 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _142 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _143 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _192 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _193 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_VertexID, gl_in[1].in_var_VS_To_DS_VertexID, gl_in[2].in_var_VS_To_DS_VertexID, gl_in[3].in_var_VS_To_DS_VertexID, gl_in[4].in_var_VS_To_DS_VertexID, gl_in[5].in_var_VS_To_DS_VertexID, gl_in[6].in_var_VS_To_DS_VertexID, gl_in[7].in_var_VS_To_DS_VertexID, gl_in[8].in_var_VS_To_DS_VertexID, gl_in[9].in_var_VS_To_DS_VertexID, gl_in[10].in_var_VS_To_DS_VertexID, gl_in[11].in_var_VS_To_DS_VertexID }); - spvUnsafeArray _230 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[0], _143[0] } }, _192[0], _193[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[1], _143[1] } }, _192[1], _193[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[2], _143[2] } }, _192[2], _193[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[3], _143[3] } }, _192[3], _193[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[4], _143[4] } }, _192[4], _193[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[5], _143[5] } }, _192[5], _193[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[6], _143[6] } }, _192[6], _193[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[7], _143[7] } }, _192[7], _193[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[8], _143[8] } }, _192[8], _193[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[9], _143[9] } }, _192[9], _193[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[10], _143[10] } }, _192[10], _193[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[11], _143[11] } }, _192[11], _193[11] } }); - spvUnsafeArray param_var_I = _230; - float4 _247 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _251 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _254 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _255 = 2u * gl_InvocationID; - uint _256 = 3u + _255; - uint _257 = _255 + 4u; - uint _264 = (_254 < 2u) ? (_254 + 1u) : 0u; - uint _265 = 2u * _254; - uint _266 = 3u + _265; - uint _267 = _265 + 4u; - float4 _279 = float4(param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _315; - float4 _316; - float4 _317; - float4 _318; - if ((param_var_I[_266].VertexID < param_var_I[_254].VertexID) || ((param_var_I[_266].VertexID == param_var_I[_254].VertexID) && (param_var_I[_267].VertexID < param_var_I[_264].VertexID))) + spvUnsafeArray _138 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _139 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _188 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _189 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_VertexID, gl_in[1].in_var_VS_To_DS_VertexID, gl_in[2].in_var_VS_To_DS_VertexID, gl_in[3].in_var_VS_To_DS_VertexID, gl_in[4].in_var_VS_To_DS_VertexID, gl_in[5].in_var_VS_To_DS_VertexID, gl_in[6].in_var_VS_To_DS_VertexID, gl_in[7].in_var_VS_To_DS_VertexID, gl_in[8].in_var_VS_To_DS_VertexID, gl_in[9].in_var_VS_To_DS_VertexID, gl_in[10].in_var_VS_To_DS_VertexID, gl_in[11].in_var_VS_To_DS_VertexID }); + spvUnsafeArray _226 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[0], _139[0] } }, _188[0], _189[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[1], _139[1] } }, _188[1], _189[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[2], _139[2] } }, _188[2], _189[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[3], _139[3] } }, _188[3], _189[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[4], _139[4] } }, _188[4], _189[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[5], _139[5] } }, _188[5], _189[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[6], _139[6] } }, _188[6], _189[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[7], _139[7] } }, _188[7], _189[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[8], _139[8] } }, _188[8], _189[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[9], _139[9] } }, _188[9], _189[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[10], _139[10] } }, _188[10], _189[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[11], _139[11] } }, _188[11], _189[11] } }); + spvUnsafeArray param_var_I = _226; + float4 _243 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _247 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _250 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _251 = 2u * gl_InvocationID; + uint _252 = 3u + _251; + uint _253 = _251 + 4u; + uint _260 = (_250 < 2u) ? (_250 + 1u) : 0u; + uint _261 = 2u * _250; + uint _262 = 3u + _261; + uint _263 = _261 + 4u; + float4 _275 = float4(param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _311; + float4 _312; + float4 _313; + float4 _314; + if ((param_var_I[_262].VertexID < param_var_I[_250].VertexID) || ((param_var_I[_262].VertexID == param_var_I[_250].VertexID) && (param_var_I[_263].VertexID < param_var_I[_260].VertexID))) { - _315 = param_var_I[_267].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _316 = param_var_I[_267].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; - _317 = param_var_I[_266].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _318 = param_var_I[_266].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _311 = param_var_I[_263].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _312 = param_var_I[_263].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _313 = param_var_I[_262].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _314 = param_var_I[_262].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; } else { - _315 = param_var_I[_264].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _316 = param_var_I[_264].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; - _317 = param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _318 = param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _311 = param_var_I[_260].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _312 = param_var_I[_260].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _313 = param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _314 = param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; } - float4 _324 = float4(_318.xyz, 0.0); - float4 _328 = float4(_316.xyz, 0.0); - float4 _336 = float4(param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _344 = float4(param_var_I[_256].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _352 = float4(param_var_I[_257].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _402 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_254].Position) - (float4(dot(param_var_I[_254].Position - param_var_I[gl_InvocationID].Position, _247)) * _247)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_256].Position) + param_var_I[_257].Position) - (float4(dot(param_var_I[_257].Position - param_var_I[_256].Position, _344)) * _344)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_254].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_254].Position, _336)) * _336)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_257].Position) + param_var_I[_256].Position) - (float4(dot(param_var_I[_256].Position - param_var_I[_257].Position, _352)) * _352)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + float4 _320 = float4(_314.xyz, 0.0); + float4 _324 = float4(_312.xyz, 0.0); + float4 _332 = float4(param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _340 = float4(param_var_I[_252].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _348 = float4(param_var_I[_253].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _398 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_250].Position) - (float4(dot(param_var_I[_250].Position - param_var_I[gl_InvocationID].Position, _243)) * _243)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_252].Position) + param_var_I[_253].Position) - (float4(dot(param_var_I[_253].Position - param_var_I[_252].Position, _340)) * _340)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_250].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_250].Position, _332)) * _332)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_253].Position) + param_var_I[_252].Position) - (float4(dot(param_var_I[_252].Position - param_var_I[_253].Position, _348)) * _348)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; gl_out[gl_InvocationID].out_var_VS_To_DS_VertexID = param_var_I[gl_InvocationID].VertexID; - gl_out[gl_InvocationID].out_var_PN_POSITION = _402; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _251; + gl_out[gl_InvocationID].out_var_PN_POSITION = _398; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _247; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_DominantVertex = float2(0.0); - gl_out[gl_InvocationID].out_var_PN_DominantVertex1 = _279; + gl_out[gl_InvocationID].out_var_PN_DominantVertex1 = _275; gl_out[gl_InvocationID].out_var_PN_DominantVertex2 = param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz; gl_out[gl_InvocationID].out_var_PN_DominantEdge = float2(0.0); gl_out[gl_InvocationID].out_var_PN_DominantEdge1 = float2(0.0); - gl_out[gl_InvocationID].out_var_PN_DominantEdge2 = _324; - gl_out[gl_InvocationID].out_var_PN_DominantEdge3 = _328; - gl_out[gl_InvocationID].out_var_PN_DominantEdge4 = _317.xyz; - gl_out[gl_InvocationID].out_var_PN_DominantEdge5 = _315.xyz; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _402, _251, 1.0, 1.0, FHullShaderConstantDominantVertexData{ float2(0.0), _279, param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz }, FHullShaderConstantDominantEdgeData{ float2(0.0), float2(0.0), _324, _328, _317.xyz, _315.xyz } }; + gl_out[gl_InvocationID].out_var_PN_DominantEdge2 = _320; + gl_out[gl_InvocationID].out_var_PN_DominantEdge3 = _324; + gl_out[gl_InvocationID].out_var_PN_DominantEdge4 = _313.xyz; + gl_out[gl_InvocationID].out_var_PN_DominantEdge5 = _311.xyz; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _398, _247, 1.0, 1.0, FHullShaderConstantDominantVertexData{ float2(0.0), _275, param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz }, FHullShaderConstantDominantEdgeData{ float2(0.0), float2(0.0), _320, _324, _313.xyz, _311.xyz } }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _461 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _474; - _474.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _474.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _474.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _474.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _600; + float4 _457 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _470; + _470.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _470.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _470.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _470.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _596; for (;;) { - float4 _500 = View.View_ViewToClip * float4(0.0); - float4 _505 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _506 = _505.xyz; - float3 _507 = _500.xyz; - float _509 = _505.w; - float _510 = _500.w; - float4 _527 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _528 = _527.xyz; - float _530 = _527.w; - float4 _548 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _549 = _548.xyz; - float _551 = _548.w; - if (any((((int3((_506 - _507) < float3(_509 + _510)) + (int3(2) * int3((_506 + _507) > float3((-_509) - _510)))) | (int3((_528 - _507) < float3(_530 + _510)) + (int3(2) * int3((_528 + _507) > float3((-_530) - _510))))) | (int3((_549 - _507) < float3(_551 + _510)) + (int3(2) * int3((_549 + _507) > float3((-_551) - _510))))) != int3(3))) + float4 _496 = View.View_ViewToClip * float4(0.0); + float4 _501 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _502 = _501.xyz; + float3 _503 = _496.xyz; + float _505 = _501.w; + float _506 = _496.w; + float4 _523 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _524 = _523.xyz; + float _526 = _523.w; + float4 _544 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _545 = _544.xyz; + float _547 = _544.w; + if (any((((int3((_502 - _503) < float3(_505 + _506)) + (int3(2) * int3((_502 + _503) > float3((-_505) - _506)))) | (int3((_524 - _503) < float3(_526 + _506)) + (int3(2) * int3((_524 + _503) > float3((-_526) - _506))))) | (int3((_545 - _503) < float3(_547 + _506)) + (int3(2) * int3((_545 + _503) > float3((-_547) - _506))))) != int3(3))) { - _600 = float4(0.0); + _596 = float4(0.0); break; } - float3 _569 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _570 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _571 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _574 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _577 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _580 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _584 = sqrt(dot(_570, _570) / dot(_577, _577)); - float _588 = sqrt(dot(_571, _571) / dot(_580, _580)); - float _592 = sqrt(dot(_569, _569) / dot(_574, _574)); - float4 _593 = float4(_584, _588, _592, 1.0); - _593.w = 0.333000004291534423828125 * ((_584 + _588) + _592); - _600 = float4(View.View_AdaptiveTessellationFactor) * _593; + float3 _565 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _566 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _567 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _570 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _573 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _576 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _580 = sqrt(dot(_566, _566) / dot(_573, _573)); + float _584 = sqrt(dot(_567, _567) / dot(_576, _576)); + float _588 = sqrt(dot(_565, _565) / dot(_570, _570)); + float4 _589 = float4(_580, _584, _588, 1.0); + _589.w = 0.333000004291534423828125 * ((_580 + _584) + _588); + _596 = float4(View.View_AdaptiveTessellationFactor) * _589; break; } - float4 _602 = fast::clamp(_474 * _600, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_602.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_602.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_602.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_602.w); - patchOut.out_var_PN_POSITION9 = _461 + ((_461 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _598 = fast::clamp(_470 * _596, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_598.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_598.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_598.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_598.w); + patchOut.out_var_PN_POSITION9 = _457 + ((_457 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc index 23859bc5bb..f94e610405 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc @@ -286,7 +286,7 @@ struct type_Primitive float4 Primitive_CustomPrimitiveData[4]; }; -constant float4 _127 = {}; +constant float4 _123 = {}; struct main0_out { @@ -318,7 +318,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], constant type_Primitive& Primitive [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -326,82 +326,82 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _129 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _130 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _131 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); - spvUnsafeArray, 12> _132 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0, gl_in[0].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0, gl_in[1].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0, gl_in[2].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0, gl_in[3].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0, gl_in[4].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0, gl_in[5].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0, gl_in[6].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0, gl_in[7].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0, gl_in[8].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0, gl_in[9].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0, gl_in[10].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0, gl_in[11].in_var_TEXCOORD0_1 }) }); - spvUnsafeArray _205 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _230 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[0], _130[0], _131[0], _132[0] } }, _205[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[1], _130[1], _131[1], _132[1] } }, _205[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[2], _130[2], _131[2], _132[2] } }, _205[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[3], _130[3], _131[3], _132[3] } }, _205[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[4], _130[4], _131[4], _132[4] } }, _205[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[5], _130[5], _131[5], _132[5] } }, _205[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[6], _130[6], _131[6], _132[6] } }, _205[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[7], _130[7], _131[7], _132[7] } }, _205[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[8], _130[8], _131[8], _132[8] } }, _205[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[9], _130[9], _131[9], _132[9] } }, _205[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[10], _130[10], _131[10], _132[10] } }, _205[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[11], _130[11], _131[11], _132[11] } }, _205[11] } }); - spvUnsafeArray param_var_I = _230; - float4 _247 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _251 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _254 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _255 = 2u * gl_InvocationID; - uint _256 = 3u + _255; - uint _257 = _255 + 4u; - float4 _269 = float4(param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _277 = float4(param_var_I[_256].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _285 = float4(param_var_I[_257].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _333 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_254].Position) - (float4(dot(param_var_I[_254].Position - param_var_I[gl_InvocationID].Position, _247)) * _247)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_256].Position) + param_var_I[_257].Position) - (float4(dot(param_var_I[_257].Position - param_var_I[_256].Position, _277)) * _277)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_254].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_254].Position, _269)) * _269)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_257].Position) + param_var_I[_256].Position) - (float4(dot(param_var_I[_256].Position - param_var_I[_257].Position, _285)) * _285)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + spvUnsafeArray _125 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _126 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _127 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); + spvUnsafeArray, 12> _128 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0, gl_in[0].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0, gl_in[1].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0, gl_in[2].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0, gl_in[3].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0, gl_in[4].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0, gl_in[5].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0, gl_in[6].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0, gl_in[7].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0, gl_in[8].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0, gl_in[9].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0, gl_in[10].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0, gl_in[11].in_var_TEXCOORD0_1 }) }); + spvUnsafeArray _201 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _226 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[0], _126[0], _127[0], _128[0] } }, _201[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[1], _126[1], _127[1], _128[1] } }, _201[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[2], _126[2], _127[2], _128[2] } }, _201[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[3], _126[3], _127[3], _128[3] } }, _201[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[4], _126[4], _127[4], _128[4] } }, _201[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[5], _126[5], _127[5], _128[5] } }, _201[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[6], _126[6], _127[6], _128[6] } }, _201[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[7], _126[7], _127[7], _128[7] } }, _201[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[8], _126[8], _127[8], _128[8] } }, _201[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[9], _126[9], _127[9], _128[9] } }, _201[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[10], _126[10], _127[10], _128[10] } }, _201[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[11], _126[11], _127[11], _128[11] } }, _201[11] } }); + spvUnsafeArray param_var_I = _226; + float4 _243 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _247 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _250 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _251 = 2u * gl_InvocationID; + uint _252 = 3u + _251; + uint _253 = _251 + 4u; + float4 _265 = float4(param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _273 = float4(param_var_I[_252].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _281 = float4(param_var_I[_253].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _329 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_250].Position) - (float4(dot(param_var_I[_250].Position - param_var_I[gl_InvocationID].Position, _243)) * _243)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_252].Position) + param_var_I[_253].Position) - (float4(dot(param_var_I[_253].Position - param_var_I[_252].Position, _273)) * _273)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_250].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_250].Position, _265)) * _265)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_253].Position) + param_var_I[_252].Position) - (float4(dot(param_var_I[_252].Position - param_var_I[_253].Position, _281)) * _281)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_COLOR0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.Color; gl_out[gl_InvocationID].out_var_TEXCOORD0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TexCoords; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_PN_POSITION = _333; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _251; + gl_out[gl_InvocationID].out_var_PN_POSITION = _329; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _247; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _333, _251, 1.0, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _329, _247, 1.0, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _385 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _398; - _398.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _398.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _398.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _398.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _524; + float4 _381 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _394; + _394.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _394.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _394.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _394.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _520; for (;;) { - float4 _424 = View.View_ViewToClip * float4(0.0); - float4 _429 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _430 = _429.xyz; - float3 _431 = _424.xyz; - float _433 = _429.w; - float _434 = _424.w; - float4 _451 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _452 = _451.xyz; - float _454 = _451.w; - float4 _472 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _473 = _472.xyz; - float _475 = _472.w; - if (any((((int3((_430 - _431) < float3(_433 + _434)) + (int3(2) * int3((_430 + _431) > float3((-_433) - _434)))) | (int3((_452 - _431) < float3(_454 + _434)) + (int3(2) * int3((_452 + _431) > float3((-_454) - _434))))) | (int3((_473 - _431) < float3(_475 + _434)) + (int3(2) * int3((_473 + _431) > float3((-_475) - _434))))) != int3(3))) + float4 _420 = View.View_ViewToClip * float4(0.0); + float4 _425 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _426 = _425.xyz; + float3 _427 = _420.xyz; + float _429 = _425.w; + float _430 = _420.w; + float4 _447 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _448 = _447.xyz; + float _450 = _447.w; + float4 _468 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _469 = _468.xyz; + float _471 = _468.w; + if (any((((int3((_426 - _427) < float3(_429 + _430)) + (int3(2) * int3((_426 + _427) > float3((-_429) - _430)))) | (int3((_448 - _427) < float3(_450 + _430)) + (int3(2) * int3((_448 + _427) > float3((-_450) - _430))))) | (int3((_469 - _427) < float3(_471 + _430)) + (int3(2) * int3((_469 + _427) > float3((-_471) - _430))))) != int3(3))) { - _524 = float4(0.0); + _520 = float4(0.0); break; } - float3 _493 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _494 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _495 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _498 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _501 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _504 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _508 = sqrt(dot(_494, _494) / dot(_501, _501)); - float _512 = sqrt(dot(_495, _495) / dot(_504, _504)); - float _516 = sqrt(dot(_493, _493) / dot(_498, _498)); - float4 _517 = float4(_508, _512, _516, 1.0); - _517.w = 0.333000004291534423828125 * ((_508 + _512) + _516); - _524 = float4(View.View_AdaptiveTessellationFactor) * _517; + float3 _489 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _490 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _491 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _494 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _497 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _500 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _504 = sqrt(dot(_490, _490) / dot(_497, _497)); + float _508 = sqrt(dot(_491, _491) / dot(_500, _500)); + float _512 = sqrt(dot(_489, _489) / dot(_494, _494)); + float4 _513 = float4(_504, _508, _512, 1.0); + _513.w = 0.333000004291534423828125 * ((_504 + _508) + _512); + _520 = float4(View.View_AdaptiveTessellationFactor) * _513; break; } - float4 _526 = fast::clamp(_398 * _524, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_526.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_526.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_526.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_526.w); - patchOut.out_var_PN_POSITION9 = _385 + ((_385 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _522 = fast::clamp(_394 * _520, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_522.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_522.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_522.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_522.w); + patchOut.out_var_PN_POSITION9 = _381 + ((_381 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc index cab75e39bd..fb6559d196 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc @@ -115,7 +115,7 @@ struct type_Material float4 Material_ScalarExpressions[1]; }; -constant float4 _88 = {}; +constant float4 _85 = {}; struct main0_out { @@ -136,39 +136,39 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_Primitive& Primitive [[buffer(0)]], constant type_Material& Material [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FFlatTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; if (gl_InvocationID < spvIndirectParams[0]) gl_in[gl_InvocationID] = in; threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _90 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _91 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _104 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position }); - spvUnsafeArray _111 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[0], _91[0] } }, FBasePassInterpolantsVSToDS{ { } }, _104[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[1], _91[1] } }, FBasePassInterpolantsVSToDS{ { } }, _104[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[2], _91[2] } }, FBasePassInterpolantsVSToDS{ { } }, _104[2] } }); - spvUnsafeArray param_var_I = _111; - float3 _128 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + spvUnsafeArray _87 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _88 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _101 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position }); + spvUnsafeArray _108 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[0], _88[0] } }, FBasePassInterpolantsVSToDS{ { } }, _101[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[1], _88[1] } }, FBasePassInterpolantsVSToDS{ { } }, _101[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[2], _88[2] } }, FBasePassInterpolantsVSToDS{ { } }, _101[2] } }); + spvUnsafeArray param_var_I = _108; + float3 _125 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_Flat_DisplacementScales = _128; + gl_out[gl_InvocationID].out_var_Flat_DisplacementScales = _125; gl_out[gl_InvocationID].out_var_Flat_TessellationMultiplier = Material.Material_ScalarExpressions[0].x; gl_out[gl_InvocationID].out_var_Flat_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FFlatTessellationHSToDS{ param_var_I[gl_InvocationID], _128, Material.Material_ScalarExpressions[0].x, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FFlatTessellationHSToDS{ param_var_I[gl_InvocationID], _125, Material.Material_ScalarExpressions[0].x, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _154; - _154.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _154.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _154.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _154.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _173 = fast::clamp(_154, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_173.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_173.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_173.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_173.w); + float4 _151; + _151.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _151.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _151.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _151.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _170 = fast::clamp(_151, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_170.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_170.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_170.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_170.w); } } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert index 1f47ec47e3..fa63cd2b4b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert @@ -435,7 +435,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant type_View& View [[buff float3 _459; if (MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w >= 0.0) { - _459 = (MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.xyz * float3(pow(fast::clamp(dot(_341 * float3(_346), MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.xyz), 0.0, 1.0), MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.w))) * float3(1.0 - fast::clamp(exp2(-(_428 * fast::max(_393 - MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w, 0.0))), 0.0, 1.0)); + _459 = (MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.xyz * float3(powr(fast::clamp(dot(_341 * float3(_346), MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.xyz), 0.0, 1.0), MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.w))) * float3(1.0 - fast::clamp(exp2(-(_428 * fast::max(_393 - MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w, 0.0))), 0.0, 1.0)); } else { diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp index 673ca715b6..87035744d5 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp @@ -10,7 +10,7 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { - uint _29 = atomicAdd(u0_counter.c, uint(-1)); - imageStore(u0, floatBitsToInt(uintBitsToFloat(_29)), uvec4(uint(int(gl_GlobalInvocationID.x)))); + uint _24 = atomicAdd(u0_counter.c, uint(-1)); + imageStore(u0, floatBitsToInt(uintBitsToFloat(_24)), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp index e45ae59263..ded7dcd742 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp @@ -10,7 +10,7 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { - uint _29 = atomicAdd(u0_counter.c, 1u); - imageStore(u0, floatBitsToInt(uintBitsToFloat(_29)), uvec4(uint(int(gl_GlobalInvocationID.x)))); + uint _24 = atomicAdd(u0_counter.c, 1u); + imageStore(u0, floatBitsToInt(uintBitsToFloat(_24)), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/builtin-compute-bitcast.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/builtin-compute-bitcast.asm.comp index abb8a7976c..0b89fa5c64 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/builtin-compute-bitcast.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/builtin-compute-bitcast.asm.comp @@ -4,10 +4,10 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer BUF { int values[]; -} _6; +} _8; void main() { - _6.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z); + _8.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/quantize.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/quantize.asm.comp index c089213800..6930e5f412 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/quantize.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/quantize.asm.comp @@ -7,13 +7,13 @@ layout(binding = 0, std430) buffer SSBO0 vec2 vec2_val; vec3 vec3_val; vec4 vec4_val; -} _4; +} _12; 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))); + _12.scalar = unpackHalf2x16(packHalf2x16(vec2(_12.scalar))).x; + _12.vec2_val = unpackHalf2x16(packHalf2x16(_12.vec2_val)); + _12.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_12.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_12.vec3_val.zz)).x); + _12.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_12.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_12.vec4_val.zw))); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp index 8016ebaf9f..e16bd191fd 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -12,10 +12,10 @@ layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_ layout(binding = 0, std430) buffer SSBO { float a; -} _4; +} _6; void main() { - _4.a += 1.0; + _6.a += 1.0; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/switch-break-ladder.asm.invalid.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/switch-break-ladder.asm.invalid.comp index f326869cef..a22f3c43e5 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/switch-break-ladder.asm.invalid.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/switch-break-ladder.asm.invalid.comp @@ -14,21 +14,21 @@ void main() int a; for (;;) { - bool _22_ladder_break = false; + bool _17_ladder_break = false; switch (c) { case 5: { for (;;) { - bool _30_ladder_break = false; + bool _25_ladder_break = false; switch (o.d) { case 10: case 20: { c += c; - _30_ladder_break = true; + _25_ladder_break = true; break; } default: @@ -36,7 +36,7 @@ void main() continue; } } - if (_30_ladder_break) + if (_25_ladder_break) { break; } @@ -48,11 +48,11 @@ void main() case 3: { a = c; - _22_ladder_break = true; + _17_ladder_break = true; break; } } - if (_22_ladder_break) + if (_17_ladder_break) { break; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/complex-name-workarounds.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/complex-name-workarounds.asm.frag index d68f84b48e..507e1787dd 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/complex-name-workarounds.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/complex-name-workarounds.asm.frag @@ -6,10 +6,10 @@ layout(location = 0) out vec4 b; void main() { - vec4 _28 = (_ + a) + _; - b = _28; + vec4 _32 = (_ + a) + _; + b = _32; b = _; - b = _28; + b = _32; b = _; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/for-loop-phi-only-continue.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/for-loop-phi-only-continue.asm.frag index 7a78d00b1c..3d6484d463 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/for-loop-phi-only-continue.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/for-loop-phi-only-continue.asm.frag @@ -4,14 +4,14 @@ layout(location = 0) out vec4 FragColor; void main() { - float _19; - _19 = 0.0; - for (int _22 = 0; _22 < 16; ) + float _50; + _50 = 0.0; + for (int _47 = 0; _47 < 16; ) { - _19 += 1.0; - _22++; + _50 += 1.0; + _47++; continue; } - FragColor = vec4(_19); + FragColor = vec4(_50); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag index 350142d4b7..fe3bedec98 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag @@ -7,7 +7,7 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - ivec2 _154 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; - _entryPointOutput = ((texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _154, 0) + texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _154, 0)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy); + ivec2 _160 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; + _entryPointOutput = ((texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _160, 0) + texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _160, 0)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag.vk b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag.vk index b898b01bc0..87328809a3 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag.vk +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.asm.vk.frag.vk @@ -8,7 +8,7 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - ivec2 _154 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; - _entryPointOutput = ((texelFetch(SampledImage, _154, 0) + texelFetch(SampledImage, _154, 0)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy); + ivec2 _160 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; + _entryPointOutput = ((texelFetch(SampledImage, _160, 0) + texelFetch(SampledImage, _160, 0)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag index 350142d4b7..fe3bedec98 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag @@ -7,7 +7,7 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - ivec2 _154 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; - _entryPointOutput = ((texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _154, 0) + texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _154, 0)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy); + ivec2 _160 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; + _entryPointOutput = ((texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _160, 0) + texelFetch(SPIRV_Cross_CombinedSampledImageSPIRV_Cross_DummySampler, _160, 0)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy)) + texture(SPIRV_Cross_CombinedSampledImageSampler, gl_FragCoord.xy); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag.vk b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag.vk index 21797b4cf3..020988f1c4 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag.vk +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag.vk @@ -8,7 +8,7 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - ivec2 _154 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; - _entryPointOutput = ((texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _154, 0) + texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _154, 0)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy); + ivec2 _160 = ivec3(int(gl_FragCoord.x * 1280.0), int(gl_FragCoord.y * 720.0), 0).xy; + _entryPointOutput = ((texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _160, 0) + texelFetch(sampler2D(SampledImage, SPIRV_Cross_DummySampler), _160, 0)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy)) + texture(sampler2D(SampledImage, Sampler), gl_FragCoord.xy); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag index 8a7f64d7f7..e2bac3f91c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag @@ -8,22 +8,22 @@ layout(location = 0) out vec4 FragColor; void main() { float phi; - vec4 _36; - int _51; - _51 = 0; + vec4 _45; + int _57; + _57 = 0; phi = 1.0; - _36 = vec4(1.0, 2.0, 1.0, 2.0); + _45 = vec4(1.0, 2.0, 1.0, 2.0); for (;;) { - FragColor = _36; - if (_51 < 4) + FragColor = _45; + if (_57 < 4) { - if (v0[_51] > 0.0) + if (v0[_57] > 0.0) { - vec2 _48 = vec2(phi); - _51++; + vec2 _43 = vec2(phi); + _57++; phi += 2.0; - _36 = textureLod(uImage, _48, 0.0); + _45 = textureLod(uImage, _43, 0.0); continue; } else diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag index 4682d79e80..f3ee0d6a55 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag @@ -23,14 +23,14 @@ void main() FragColor = 4.0; } #line 19 "test.frag" - for (int _127 = 0; float(_127) < (40.0 + vColor); ) + for (int _131 = 0; float(_131) < (40.0 + vColor); ) { #line 21 "test.frag" FragColor += 0.20000000298023223876953125; #line 22 "test.frag" FragColor += 0.300000011920928955078125; #line 19 "test.frag" - _127 += (int(vColor) + 5); + _131 += (int(vColor) + 5); continue; } #line 25 "test.frag" diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag index b1e3784309..ed8112d98e 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag @@ -1,21 +1,21 @@ #version 450 -layout(location = 1) in vec2 _2; -layout(location = 1, component = 2) in float _3; -layout(location = 2) flat in float _4; -layout(location = 2, component = 1) flat in uint _5; -layout(location = 2, component = 2) flat in uint _6; +layout(location = 1) in vec2 _8; +layout(location = 1, component = 2) in float _16; +layout(location = 2) flat in float _22; +layout(location = 2, component = 1) flat in uint _28; +layout(location = 2, component = 2) flat in uint _33; layout(location = 0) out vec4 o0; vec4 v1; vec4 v2; void main() { - v1 = vec4(_2.x, _2.y, v1.z, v1.w); - v1.z = _3; - v2.x = _4; - v2.y = uintBitsToFloat(_5); - v2.z = uintBitsToFloat(_6); + v1 = vec4(_8.x, _8.y, v1.z, v1.w); + v1.z = _16; + v2.x = _22; + v2.y = uintBitsToFloat(_28); + v2.z = uintBitsToFloat(_33); o0.y = float(floatBitsToUint(intBitsToFloat(floatBitsToInt(v2.y) + floatBitsToInt(v2.z)))); o0.x = v1.y + v2.x; o0 = vec4(o0.x, o0.y, v1.z, v1.x); diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag index eb16828e67..7cad91c77a 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -12,14 +12,14 @@ #define SPIRV_CROSS_LOOP #endif -int _231; +int _239; layout(binding = 0, std140) uniform Foo { layout(row_major) mat4 lightVP[64]; uint shadowCascadesNum; int test; -} _11; +} _16; layout(location = 0) in vec3 fragWorld; layout(location = 0) out int _entryPointOutput; @@ -28,56 +28,56 @@ mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } void main() { - int _228; + int _236; do { - bool _225; - int _229; - uint _222 = 0u; + bool _233; + int _237; + uint _230 = 0u; SPIRV_CROSS_UNROLL for (;;) { - if (_222 < _11.shadowCascadesNum) + if (_230 < _16.shadowCascadesNum) { - mat4 _223; + mat4 _231; do { - if (_11.test == 0) + if (_16.test == 0) { - _223 = 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)); + _231 = 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; } - _223 = 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)); + _231 = 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; } while(false); - vec4 _170 = (_223 * spvWorkaroundRowMajor(_11.lightVP[_222])) * vec4(fragWorld, 1.0); - float _172 = _170.z; - float _179 = _170.x; - float _181 = _170.y; - if ((((_172 >= 0.0) && (_172 <= 1.0)) && (max(_179, _181) <= 1.0)) && (min(_179, _181) >= 0.0)) + vec4 _178 = (_231 * spvWorkaroundRowMajor(_16.lightVP[_230])) * vec4(fragWorld, 1.0); + float _180 = _178.z; + float _187 = _178.x; + float _189 = _178.y; + if ((((_180 >= 0.0) && (_180 <= 1.0)) && (max(_187, _189) <= 1.0)) && (min(_187, _189) >= 0.0)) { - _229 = int(_222); - _225 = true; + _237 = int(_230); + _233 = true; break; } - _222++; + _230++; continue; } else { - _229 = _231; - _225 = false; + _237 = _239; + _233 = false; break; } } - if (_225) + if (_233) { - _228 = _229; + _236 = _237; break; } - _228 = -1; + _236 = -1; break; } while(false); - _entryPointOutput = _228; + _entryPointOutput = _236; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag index 97d3b74f02..55e226d0b5 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-header-to-continue.asm.frag @@ -13,7 +13,7 @@ struct Params layout(binding = 1, std140) uniform CB1 { Params CB1; -} _8; +} _12; uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler; @@ -22,25 +22,25 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - vec2 _45 = vec2(0.0, _8.CB1.TextureSize.w); - vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); - float _50 = _49.y; - float _53 = clamp(_50 * 0.06399999558925628662109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375); - float _55; - float _58; - _55 = 0.0; - _58 = 0.0; - for (int _60 = -3; _60 <= 3; ) + vec2 _180 = vec2(0.0, _12.CB1.TextureSize.w); + vec4 _206 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); + float _207 = _206.y; + float _211 = clamp(_207 * 0.06399999558925628662109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375); + float _276; + float _277; + _276 = 0.0; + _277 = 0.0; + for (int _278 = -3; _278 <= 3; ) { - float _64 = float(_60); - float _68 = exp(((-_64) * _64) * 0.2222220003604888916015625); - vec4 _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (_45 * _64)); - float _77 = float(abs(_72.y - _50) < _53); - _55 = fma(_72.x, _68 * _77, _55); - _58 = fma(_68, _77, _58); - _60++; + float _220 = float(_278); + float _227 = exp(((-_220) * _220) * 0.2222220003604888916015625); + vec4 _236 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (_180 * _220)); + float _245 = float(abs(_236.y - _207) < _211); + _276 = fma(_236.x, _227 * _245, _276); + _277 = fma(_227, _245, _277); + _278++; continue; } - _entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0); + _entryPointOutput = vec4(_276 / _277, _207, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/lut-promotion-initializer.asm.frag index d88c0e36d9..e52b457582 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/lut-promotion-initializer.asm.frag @@ -2,41 +2,41 @@ precision mediump float; precision highp int; -const float _46[16] = float[](1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0); -const vec4 _76[4] = vec4[](vec4(0.0), vec4(1.0), vec4(8.0), vec4(5.0)); +const float _16[16] = float[](1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0); +const vec4 _60[4] = vec4[](vec4(0.0), vec4(1.0), vec4(8.0), vec4(5.0)); layout(location = 0) out float FragColor; layout(location = 0) flat in mediump int index; void main() { - vec4 foobar[4] = _76; - vec4 baz[4] = _76; - FragColor = _46[index]; + vec4 foobar[4] = _60; + vec4 baz[4] = _60; + FragColor = _16[index]; if (index < 10) { - FragColor += _46[index ^ 1]; + FragColor += _16[index ^ 1]; } else { - FragColor += _46[index & 1]; + FragColor += _16[index & 1]; } - bool _99 = index > 30; - if (_99) + bool _63 = index > 30; + if (_63) { - FragColor += _76[index & 3].y; + FragColor += _60[index & 3].y; } else { - FragColor += _76[index & 1].x; + FragColor += _60[index & 1].x; } - if (_99) + if (_63) { foobar[1].z = 20.0; } - mediump int _37 = index & 3; - FragColor += foobar[_37].z; + mediump int _91 = index & 3; + FragColor += foobar[_91].z; baz = vec4[](vec4(20.0), vec4(30.0), vec4(50.0), vec4(60.0)); - FragColor += baz[_37].z; + FragColor += baz[_91].z; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/op-phi-swap-continue-block.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/op-phi-swap-continue-block.asm.frag index ee45619a86..4de1702f3c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/op-phi-swap-continue-block.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/op-phi-swap-continue-block.asm.frag @@ -5,25 +5,25 @@ layout(binding = 0, std140) uniform UBO int uCount; int uJ; int uK; -} _5; +} _7; layout(location = 0) out float FragColor; void main() { - int _23; - int _23_copy; - int _24; - _23 = _5.uK; - _24 = _5.uJ; - for (int _26 = 0; _26 < _5.uCount; ) + int _53; + int _54; + int _54_copy; + _54 = _7.uK; + _53 = _7.uJ; + for (int _52 = 0; _52 < _7.uCount; ) { - _23_copy = _23; - _23 = _24; - _24 = _23_copy; - _26++; + _54_copy = _54; + _54 = _53; + _53 = _54_copy; + _52++; continue; } - FragColor = float(_24 - _23) * float(_5.uJ * _5.uK); + FragColor = float(_53 - _54) * float(_7.uJ * _7.uK); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag index a5faaefb30..b839921a51 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag @@ -2,12 +2,12 @@ layout(location = 0) out vec4 FragColors[2]; layout(location = 2) out vec4 FragColor; -const vec4 _3_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); -const vec4 _4_init = vec4(5.0); +const vec4 _4_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); +const vec4 _6_init = vec4(5.0); void main() { - FragColors = _3_init; - FragColor = _4_init; + FragColors = _4_init; + FragColor = _6_init; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag index 7930ca3b4a..396b98138b 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag @@ -8,7 +8,7 @@ struct Foo float var2; }; -Foo _22; +Foo _33; layout(binding = 0) uniform mediump sampler2D uSampler; @@ -16,6 +16,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); + FragColor = texture(uSampler, vec2(_33.var1, _33.var2)); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag index 748f96c8b0..61b45c6dbd 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag @@ -7,26 +7,26 @@ layout(location = 0) out float FragColor; void main() { - highp float _19; + highp float _27; switch (vIndex) { case 0: case 2: { - _19 = 1.0; + _27 = 1.0; break; } default: { - _19 = 3.0; + _27 = 3.0; break; } case 8: { - _19 = 8.0; + _27 = 8.0; break; } } - FragColor = _19; + FragColor = _27; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag index ade51d4a86..01fd21574a 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -8,20 +8,20 @@ struct MyStruct layout(binding = 0, std140) uniform MyStruct_CB { MyStruct g_MyStruct[4]; -} _6; +} _8; layout(location = 0) out vec4 _entryPointOutput; void main() { - vec3 _28; - _28 = vec3(0.0); - for (int _31 = 0; _31 < 4; ) + vec3 _85; + _85 = vec3(0.0); + for (int _86 = 0; _86 < 4; ) { - _28 += _6.g_MyStruct[_31].color.xyz; - _31++; + _85 += _8.g_MyStruct[_86].color.xyz; + _86++; continue; } - _entryPointOutput = vec4(_28, 1.0); + _entryPointOutput = vec4(_85, 1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/unreachable.asm.frag index c8986c1210..2459d648d5 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/unreachable.asm.frag @@ -5,20 +5,20 @@ layout(location = 0) out vec4 FragColor; void main() { - vec4 _33; + vec4 _46; for (;;) { if (counter == 10) { - _33 = vec4(10.0); + _46 = vec4(10.0); break; } else { - _33 = vec4(30.0); + _46 = vec4(30.0); break; } } - FragColor = _33; + FragColor = _46; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag index fcad3fbf0d..5224748fb8 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -12,19 +12,19 @@ #define SPIRV_CROSS_LOOP #endif -struct _28 +struct _15 { vec4 _m0; }; -layout(binding = 0, std140) uniform _6_7 +layout(binding = 0, std140) uniform _3_22044 { vec4 _m0; float _m1; vec4 _m2; -} _7; +} _22044; -layout(binding = 2, std140) uniform _10_11 +layout(binding = 2, std140) uniform _4_12348 { vec3 _m0; vec3 _m1; @@ -51,9 +51,9 @@ layout(binding = 2, std140) uniform _10_11 vec4 _m22; layout(row_major) mat4 _m23; vec4 _m24; -} _11; +} _12348; -layout(binding = 1, std140) uniform _18_19 +layout(binding = 1, std140) uniform _7_15259 { layout(row_major) mat4 _m0; layout(row_major) mat4 _m1; @@ -94,204 +94,204 @@ layout(binding = 1, std140) uniform _18_19 vec3 _m36; layout(row_major) mat4 _m37[2]; vec4 _m38[2]; -} _19; +} _15259; uniform sampler2D SPIRV_Cross_Combined; uniform sampler2D SPIRV_Cross_Combined_1; uniform sampler2D SPIRV_Cross_Combined_2; -layout(location = 0) out vec4 _5; +layout(location = 0) out vec4 _4317; void main() { - vec4 _88 = _7._m2 * _7._m0.xyxy; - vec2 _95 = _88.xy; - vec2 _96 = _88.zw; - vec2 _97 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(0.0, -2.0) * _7._m0.xy), _95, _96); - 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); - float _114 = _113.y; - vec3 _129; + vec4 _17581 = _22044._m2 * _22044._m0.xyxy; + vec2 _7011 = _17581.xy; + vec2 _21058 = _17581.zw; + vec2 _13149 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(0.0, -2.0) * _22044._m0.xy), _7011, _21058); + vec3 _12103 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13149, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17670 = textureLod(SPIRV_Cross_Combined_1, _13149, 0.0); + float _16938 = _17670.y; + vec3 _7719; SPIRV_CROSS_BRANCH - if (_114 > 0.0) + if (_16938 > 0.0) { - _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_114 * _113.z, 0.0, 1.0)); + _7719 = _12103 + (textureLod(SPIRV_Cross_Combined_2, _13149, 0.0).xyz * clamp(_16938 * _17670.z, 0.0, 1.0)); } else { - _129 = _109; + _7719 = _12103; } - vec2 _144 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(-1.0) * _7._m0.xy), _95, _96); - 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); - float _161 = _160.y; - vec3 _176; + vec2 _13150 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(-1.0) * _22044._m0.xy), _7011, _21058); + vec3 _12104 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13150, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17671 = textureLod(SPIRV_Cross_Combined_1, _13150, 0.0); + float _16939 = _17671.y; + vec3 _7720; SPIRV_CROSS_BRANCH - if (_161 > 0.0) + if (_16939 > 0.0) { - _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_161 * _160.z, 0.0, 1.0)); + _7720 = _12104 + (textureLod(SPIRV_Cross_Combined_2, _13150, 0.0).xyz * clamp(_16939 * _17671.z, 0.0, 1.0)); } else { - _176 = _156; + _7720 = _12104; } - vec2 _191 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(0.0, -1.0) * _7._m0.xy), _95, _96); - 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); - float _208 = _207.y; - vec3 _223; + vec2 _13151 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(0.0, -1.0) * _22044._m0.xy), _7011, _21058); + vec3 _12105 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13151, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17672 = textureLod(SPIRV_Cross_Combined_1, _13151, 0.0); + float _16940 = _17672.y; + vec3 _7721; SPIRV_CROSS_BRANCH - if (_208 > 0.0) + if (_16940 > 0.0) { - _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_208 * _207.z, 0.0, 1.0)); + _7721 = _12105 + (textureLod(SPIRV_Cross_Combined_2, _13151, 0.0).xyz * clamp(_16940 * _17672.z, 0.0, 1.0)); } else { - _223 = _203; + _7721 = _12105; } - vec2 _238 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(1.0, -1.0) * _7._m0.xy), _95, _96); - 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); - float _255 = _254.y; - vec3 _270; + vec2 _13152 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(1.0, -1.0) * _22044._m0.xy), _7011, _21058); + vec3 _12106 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13152, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17673 = textureLod(SPIRV_Cross_Combined_1, _13152, 0.0); + float _16941 = _17673.y; + vec3 _7722; SPIRV_CROSS_BRANCH - if (_255 > 0.0) + if (_16941 > 0.0) { - _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_255 * _254.z, 0.0, 1.0)); + _7722 = _12106 + (textureLod(SPIRV_Cross_Combined_2, _13152, 0.0).xyz * clamp(_16941 * _17673.z, 0.0, 1.0)); } else { - _270 = _250; + _7722 = _12106; } - vec2 _285 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(-2.0, 0.0) * _7._m0.xy), _95, _96); - 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); - float _302 = _301.y; - vec3 _317; + vec2 _13153 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(-2.0, 0.0) * _22044._m0.xy), _7011, _21058); + vec3 _12107 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13153, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17674 = textureLod(SPIRV_Cross_Combined_1, _13153, 0.0); + float _16942 = _17674.y; + vec3 _7723; SPIRV_CROSS_BRANCH - if (_302 > 0.0) + if (_16942 > 0.0) { - _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_302 * _301.z, 0.0, 1.0)); + _7723 = _12107 + (textureLod(SPIRV_Cross_Combined_2, _13153, 0.0).xyz * clamp(_16942 * _17674.z, 0.0, 1.0)); } else { - _317 = _297; + _7723 = _12107; } - vec2 _332 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(-1.0, 0.0) * _7._m0.xy), _95, _96); - 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); - float _349 = _348.y; - vec3 _364; + vec2 _13154 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(-1.0, 0.0) * _22044._m0.xy), _7011, _21058); + vec3 _12108 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13154, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17675 = textureLod(SPIRV_Cross_Combined_1, _13154, 0.0); + float _16943 = _17675.y; + vec3 _7724; SPIRV_CROSS_BRANCH - if (_349 > 0.0) + if (_16943 > 0.0) { - _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_349 * _348.z, 0.0, 1.0)); + _7724 = _12108 + (textureLod(SPIRV_Cross_Combined_2, _13154, 0.0).xyz * clamp(_16943 * _17675.z, 0.0, 1.0)); } else { - _364 = _344; + _7724 = _12108; } - vec2 _379 = clamp(gl_FragCoord.xy * _19._m23.xy, _95, _96); - 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); - float _396 = _395.y; - vec3 _411; + vec2 _13155 = clamp(gl_FragCoord.xy * _15259._m23.xy, _7011, _21058); + vec3 _12109 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13155, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17676 = textureLod(SPIRV_Cross_Combined_1, _13155, 0.0); + float _16944 = _17676.y; + vec3 _7725; SPIRV_CROSS_BRANCH - if (_396 > 0.0) + if (_16944 > 0.0) { - _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_396 * _395.z, 0.0, 1.0)); + _7725 = _12109 + (textureLod(SPIRV_Cross_Combined_2, _13155, 0.0).xyz * clamp(_16944 * _17676.z, 0.0, 1.0)); } else { - _411 = _391; + _7725 = _12109; } - vec2 _426 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(1.0, 0.0) * _7._m0.xy), _95, _96); - 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); - float _443 = _442.y; - vec3 _458; + vec2 _13156 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(1.0, 0.0) * _22044._m0.xy), _7011, _21058); + vec3 _12110 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13156, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17677 = textureLod(SPIRV_Cross_Combined_1, _13156, 0.0); + float _16945 = _17677.y; + vec3 _7726; SPIRV_CROSS_BRANCH - if (_443 > 0.0) + if (_16945 > 0.0) { - _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_443 * _442.z, 0.0, 1.0)); + _7726 = _12110 + (textureLod(SPIRV_Cross_Combined_2, _13156, 0.0).xyz * clamp(_16945 * _17677.z, 0.0, 1.0)); } else { - _458 = _438; + _7726 = _12110; } - vec2 _473 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(2.0, 0.0) * _7._m0.xy), _95, _96); - 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); - float _490 = _489.y; - vec3 _505; + vec2 _13157 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(2.0, 0.0) * _22044._m0.xy), _7011, _21058); + vec3 _12111 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13157, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17678 = textureLod(SPIRV_Cross_Combined_1, _13157, 0.0); + float _16946 = _17678.y; + vec3 _7727; SPIRV_CROSS_BRANCH - if (_490 > 0.0) + if (_16946 > 0.0) { - _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_490 * _489.z, 0.0, 1.0)); + _7727 = _12111 + (textureLod(SPIRV_Cross_Combined_2, _13157, 0.0).xyz * clamp(_16946 * _17678.z, 0.0, 1.0)); } else { - _505 = _485; + _7727 = _12111; } - vec2 _520 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(-1.0, 1.0) * _7._m0.xy), _95, _96); - 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); - float _537 = _536.y; - vec3 _552; + vec2 _13158 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(-1.0, 1.0) * _22044._m0.xy), _7011, _21058); + vec3 _12112 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13158, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17679 = textureLod(SPIRV_Cross_Combined_1, _13158, 0.0); + float _16947 = _17679.y; + vec3 _7728; SPIRV_CROSS_BRANCH - if (_537 > 0.0) + if (_16947 > 0.0) { - _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_537 * _536.z, 0.0, 1.0)); + _7728 = _12112 + (textureLod(SPIRV_Cross_Combined_2, _13158, 0.0).xyz * clamp(_16947 * _17679.z, 0.0, 1.0)); } else { - _552 = _532; + _7728 = _12112; } - vec2 _567 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(0.0, 1.0) * _7._m0.xy), _95, _96); - 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); - float _584 = _583.y; - vec3 _599; + vec2 _13159 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(0.0, 1.0) * _22044._m0.xy), _7011, _21058); + vec3 _12113 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13159, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17680 = textureLod(SPIRV_Cross_Combined_1, _13159, 0.0); + float _16948 = _17680.y; + vec3 _7729; SPIRV_CROSS_BRANCH - if (_584 > 0.0) + if (_16948 > 0.0) { - _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_584 * _583.z, 0.0, 1.0)); + _7729 = _12113 + (textureLod(SPIRV_Cross_Combined_2, _13159, 0.0).xyz * clamp(_16948 * _17680.z, 0.0, 1.0)); } else { - _599 = _579; + _7729 = _12113; } - vec2 _614 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, _7._m0.xy), _95, _96); - 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); - float _631 = _630.y; - vec3 _646; + vec2 _13160 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, _22044._m0.xy), _7011, _21058); + vec3 _12114 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13160, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17681 = textureLod(SPIRV_Cross_Combined_1, _13160, 0.0); + float _16949 = _17681.y; + vec3 _7730; SPIRV_CROSS_BRANCH - if (_631 > 0.0) + if (_16949 > 0.0) { - _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_631 * _630.z, 0.0, 1.0)); + _7730 = _12114 + (textureLod(SPIRV_Cross_Combined_2, _13160, 0.0).xyz * clamp(_16949 * _17681.z, 0.0, 1.0)); } else { - _646 = _626; + _7730 = _12114; } - vec2 _661 = clamp(fma(gl_FragCoord.xy, _19._m23.xy, vec2(0.0, 2.0) * _7._m0.xy), _95, _96); - 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); - float _678 = _677.y; - vec3 _693; + vec2 _13161 = clamp(fma(gl_FragCoord.xy, _15259._m23.xy, vec2(0.0, 2.0) * _22044._m0.xy), _7011, _21058); + vec3 _12115 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13161, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17682 = textureLod(SPIRV_Cross_Combined_1, _13161, 0.0); + float _16950 = _17682.y; + vec3 _7731; SPIRV_CROSS_BRANCH - if (_678 > 0.0) + if (_16950 > 0.0) { - _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_678 * _677.z, 0.0, 1.0)); + _7731 = _12115 + (textureLod(SPIRV_Cross_Combined_2, _13161, 0.0).xyz * clamp(_16950 * _17682.z, 0.0, 1.0)); } else { - _693 = _673; + _7731 = _12115; } - vec3 _702 = (((((((((((((_129 * 0.5).xyz + (_176 * 0.5)).xyz + (_223 * 0.75)).xyz + (_270 * 0.5)).xyz + (_317 * 0.5)).xyz + (_364 * 0.75)).xyz + (_411 * 1.0)).xyz + (_458 * 0.75)).xyz + (_505 * 0.5)).xyz + (_552 * 0.5)).xyz + (_599 * 0.75)).xyz + (_646 * 0.5)).xyz + (_693 * 0.5)).xyz * vec3(0.125); - _28 _750 = _28(vec4(_702.x, _702.y, _702.z, vec4(0.0).w)); - _750._m0.w = 1.0; - _5 = _750._m0; + vec3 _13750 = (((((((((((((_7719 * 0.5).xyz + (_7720 * 0.5)).xyz + (_7721 * 0.75)).xyz + (_7722 * 0.5)).xyz + (_7723 * 0.5)).xyz + (_7724 * 0.75)).xyz + (_7725 * 1.0)).xyz + (_7726 * 0.75)).xyz + (_7727 * 0.5)).xyz + (_7728 * 0.5)).xyz + (_7729 * 0.75)).xyz + (_7730 * 0.5)).xyz + (_7731 * 0.5)).xyz * vec3(0.125); + _15 _25050 = _15(vec4(_13750.x, _13750.y, _13750.z, vec4(0.0).w)); + _25050._m0.w = 1.0; + _4317 = _25050._m0; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert b/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert index eb88694196..a89e336283 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant-block.sso.asm.vert @@ -2,14 +2,12 @@ out gl_PerVertex { - vec4 gl_Position; + invariant vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[1]; float gl_CullDistance[1]; }; -invariant gl_Position; - void main() { gl_Position = vec4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant.sso.asm.vert b/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant.sso.asm.vert index 4f7e2f5f67..7f9221d3a4 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant.sso.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/invariant.sso.asm.vert @@ -2,11 +2,9 @@ out gl_PerVertex { - vec4 gl_Position; + invariant vec4 gl_Position; }; -invariant gl_Position; - void main() { gl_Position = vec4(1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert b/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert index 3d9ad3b486..00ef42d81b 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert @@ -3,28 +3,28 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_201 #define SPIRV_CROSS_CONSTANT_ID_201 -10 #endif -const int _7 = SPIRV_CROSS_CONSTANT_ID_201; -const int _20 = (_7 + 2); +const int _13 = SPIRV_CROSS_CONSTANT_ID_201; +const int _15 = (_13 + 2); #ifndef SPIRV_CROSS_CONSTANT_ID_202 #define SPIRV_CROSS_CONSTANT_ID_202 100u #endif -const uint _8 = SPIRV_CROSS_CONSTANT_ID_202; -const uint _25 = (_8 % 5u); -const int _30 = _7 - (-3) * (_7 / (-3)); -const ivec4 _32 = ivec4(20, 30, _20, _30); -const ivec2 _34 = ivec2(_32.y, _32.x); -const int _35 = _32.y; +const uint _24 = SPIRV_CROSS_CONSTANT_ID_202; +const uint _26 = (_24 % 5u); +const int _61 = _13 - (-3) * (_13 / (-3)); +const ivec4 _36 = ivec4(20, 30, _15, _61); +const ivec2 _41 = ivec2(_36.y, _36.x); +const int _62 = _36.y; -layout(location = 0) flat out int _4; +layout(location = 0) flat out int _58; void main() { vec4 _65 = vec4(0.0); - _65.y = float(_20); - _65.z = float(_25); - vec4 _54 = _65 + vec4(_32); - vec2 _58 = _54.xy + vec2(_34); - gl_Position = vec4(_58.x, _58.y, _54.z, _54.w); - _4 = _35; + _65.y = float(_15); + _65.z = float(_26); + vec4 _39 = _65 + vec4(_36); + vec2 _46 = _39.xy + vec2(_41); + gl_Position = vec4(_46.x, _46.y, _39.z, _39.w); + _58 = _62; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk b/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk index ed9d98e9de..3c38b68ebb 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk @@ -1,28 +1,28 @@ #version 450 -layout(constant_id = 201) const int _7 = -10; -const int _20 = (_7 + 2); -layout(constant_id = 202) const uint _8 = 100u; -const uint _25 = (_8 % 5u); -const int _30 = _7 - (-3) * (_7 / (-3)); -const ivec4 _32 = ivec4(20, 30, _20, _30); -const ivec2 _34 = ivec2(_32.y, _32.x); -const int _35 = _32.y; +layout(constant_id = 201) const int _13 = -10; +const int _15 = (_13 + 2); +layout(constant_id = 202) const uint _24 = 100u; +const uint _26 = (_24 % 5u); +const int _61 = _13 - (-3) * (_13 / (-3)); +const ivec4 _36 = ivec4(20, 30, _15, _61); +const ivec2 _41 = ivec2(_36.y, _36.x); +const int _62 = _36.y; -layout(location = 0) flat out int _4; +layout(location = 0) flat out int _58; void main() { - float _42 = float(_20); + float _16 = float(_15); vec4 _65 = vec4(0.0); - _65.y = _42; - float _47 = float(_25); - _65.z = _47; - vec4 _52 = vec4(_32); - vec4 _54 = _65 + _52; - vec2 _55 = vec2(_34); - vec2 _58 = _54.xy + _55; - gl_Position = vec4(_58.x, _58.y, _54.z, _54.w); - _4 = _35; + _65.y = _16; + float _27 = float(_26); + _65.z = _27; + vec4 _37 = vec4(_36); + vec4 _39 = _65 + _37; + vec2 _43 = vec2(_41); + vec2 _46 = _39.xy + _43; + gl_Position = vec4(_46.x, _46.y, _39.z, _39.w); + _58 = _62; } diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/block-match-sad.frag b/third_party/spirv-cross/reference/opt/shaders/frag/block-match-sad.frag new file mode 100644 index 0000000000..e538a2c132 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/block-match-sad.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSADQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, uvec2(4u)); + fragColor = _59; + vec4 _68 = textureBlockMatchSADQCOM(target_samp, tgt_coords, ref_samp, ref_coords, uvec2(4u)); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/block-match-ssd.frag b/third_party/spirv-cross/reference/opt/shaders/frag/block-match-ssd.frag new file mode 100644 index 0000000000..0d394334dd --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/block-match-ssd.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSSDQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, uvec2(4u)); + fragColor = _59; + vec4 _68 = textureBlockMatchSSDQCOM(target_samp, tgt_coords, ref_samp, ref_coords, uvec2(4u)); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/box-filter.frag b/third_party/spirv-cross/reference/opt/shaders/frag/box-filter.frag new file mode 100644 index 0000000000..9348653498 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/box-filter.frag @@ -0,0 +1,18 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec2 boxSize = vec2(2.5, 4.5); + vec4 _31 = textureBoxFilterQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, vec2(2.5, 4.5)); + fragColor = _31; + vec4 _38 = textureBoxFilterQCOM(tex_samp, v_texcoord.xy, vec2(2.5, 4.5)); + fragColor = _38; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/sample-weighted.frag b/third_party/spirv-cross/reference/opt/shaders/frag/sample-weighted.frag new file mode 100644 index 0000000000..7d1c35e241 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/sample-weighted.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +layout(binding = 5) uniform sampler2DArray tex_samp_array; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2DArray SPIRV_Cross_Combinedtex2DArray_weightssamp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec4 _32 = textureWeightedQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, SPIRV_Cross_Combinedtex2DArray_weightssamp); + fragColor = _32; + vec4 _41 = textureWeightedQCOM(tex_samp, v_texcoord.xy, tex_samp_array); + fragColor = _41; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/tese/read-patch-vertices-in-func.tese b/third_party/spirv-cross/reference/opt/shaders/tese/read-patch-vertices-in-func.tese new file mode 100644 index 0000000000..74dfad90da --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/tese/read-patch-vertices-in-func.tese @@ -0,0 +1,8 @@ +#version 450 +layout(quads, ccw, equal_spacing) in; + +void main() +{ + gl_Position = vec4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk index 771d049644..a76f8ccb80 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Block; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk index f5907d3e2c..c9b2bbcfad 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Bar; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk index 1808beecbb..ab1565f88f 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Bar; @@ -23,7 +23,6 @@ layout(push_constant, std430) uniform Push void main() { - uint v = _15.bar.b; uint _31 = atomicAdd(_15.bar.a, _15.bar.b); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk index 20a4f1b423..835eae4104 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_buffer_reference_uvec2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk index 5cf6e2df36..b99ace3f17 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_buffer_reference_uvec2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk index 8923d21d78..4b59857a3e 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer PtrUint; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk index b7e88062a0..92a8bcb1b1 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer RO; diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk index c3855cf634..a8ac9839c0 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk @@ -4,7 +4,7 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Node; @@ -23,31 +23,17 @@ layout(set = 0, binding = 0, std430) restrict buffer LinkedList void main() { - Node _45; Node _114; if (gl_WorkGroupID.x < 4u) { - _45 = _50.head1; _114 = _50.head1; } else { - _45 = _50.head2; _114 = _50.head2; } - restrict Node n = _114; - Node param = _114.next; - Node param_1 = _50.head1; - Node param_2 = _50.head2; _114.next.value = _50.head1.value + _50.head2.value; - Node param_4 = _50.head1; - Node param_3 = _50.head1; - n = _50.head1; - int v = _50.head2.value; _50.head1.value = 20; _50.head1.value = _50.head2.value * 10; - uint64_t _98 = uint64_t(_50.head2.next); - uint64_t uptr = _98; - Node unode = Node(_98); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/fp-atomic.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/fp-atomic.nocompat.vk.comp.vk index b700474622..0bd6e1861f 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/fp-atomic.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/fp-atomic.nocompat.vk.comp.vk @@ -14,10 +14,8 @@ shared float shared_v; void main() { float _15 = atomicAdd(shared_v, 2.0); - float value = _15; float _24 = atomicAdd(_18.v, _15); float _39 = imageAtomicAdd(uImage, ivec2(gl_GlobalInvocationID.xy), _15); float _45 = imageAtomicExchange(uImage, ivec2(gl_GlobalInvocationID.xy), _15); - value = _45; } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-sad.frag b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-sad.frag new file mode 100644 index 0000000000..e538a2c132 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-sad.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSADQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, uvec2(4u)); + fragColor = _59; + vec4 _68 = textureBlockMatchSADQCOM(target_samp, tgt_coords, ref_samp, ref_coords, uvec2(4u)); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-ssd.frag b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-ssd.frag new file mode 100644 index 0000000000..0d394334dd --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/block-match-ssd.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSSDQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, uvec2(4u)); + fragColor = _59; + vec4 _68 = textureBlockMatchSSDQCOM(target_samp, tgt_coords, ref_samp, ref_coords, uvec2(4u)); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/box-filter.frag b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/box-filter.frag new file mode 100644 index 0000000000..9348653498 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/box-filter.frag @@ -0,0 +1,18 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec2 boxSize = vec2(2.5, 4.5); + vec4 _31 = textureBoxFilterQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, vec2(2.5, 4.5)); + fragColor = _31; + vec4 _38 = textureBoxFilterQCOM(tex_samp, v_texcoord.xy, vec2(2.5, 4.5)); + fragColor = _38; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk index 153164920f..92209f2a5c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk @@ -5,9 +5,9 @@ layout(location = 0) out vec4 FragColor; void main() { - bool _15 = helperInvocationEXT(); + bool _9 = helperInvocationEXT(); demote; - if (!_15) + if (!_9) { FragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/sample-weighted.frag b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/sample-weighted.frag new file mode 100644 index 0000000000..7d1c35e241 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/sample-weighted.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +layout(binding = 5) uniform sampler2DArray tex_samp_array; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2DArray SPIRV_Cross_Combinedtex2DArray_weightssamp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec4 _32 = textureWeightedQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, SPIRV_Cross_Combinedtex2DArray_weightssamp); + fragColor = _32; + vec4 _41 = textureWeightedQCOM(tex_samp, v_texcoord.xy, tex_samp_array); + fragColor = _41; +} + diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/access-chain-load-store-composite.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/access-chain-load-store-composite.asm.comp index 986cc6289f..08ff71dc68 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/access-chain-load-store-composite.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/access-chain-load-store-composite.asm.comp @@ -18,13 +18,13 @@ struct Foo static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); -RWByteAddressBuffer _10 : register(u0); +RWByteAddressBuffer _12 : register(u0); void comp_main() { Foo _64; - _64.a = asfloat(uint2x2(_10.Load(0), _10.Load(8), _10.Load(4), _10.Load(12))); - _64.b = asfloat(_10.Load2(16)); + _64.a = asfloat(uint2x2(_12.Load(0), _12.Load(8), _12.Load(4), _12.Load(12))); + _64.b = asfloat(_12.Load2(16)); [unroll] for (int _0ident = 0; _0ident < 5; _0ident++) { @@ -34,20 +34,20 @@ void comp_main() [unroll] for (int _2ident = 0; _2ident < 4; _2ident++) { - _64.c[_0ident].d[_1ident][_2ident] = asfloat(_10.Load(_2ident * 4 + _1ident * 16 + _0ident * 40 + 24)); + _64.c[_0ident].d[_1ident][_2ident] = asfloat(_12.Load(_2ident * 4 + _1ident * 16 + _0ident * 40 + 24)); } } [unroll] for (int _3ident = 0; _3ident < 2; _3ident++) { - _64.c[_0ident].baz[_3ident].c = asfloat(_10.Load(_3ident * 4 + _0ident * 40 + 56)); + _64.c[_0ident].baz[_3ident].c = asfloat(_12.Load(_3ident * 4 + _0ident * 40 + 56)); } } - _10.Store(224, asuint(_64.a[0].x)); - _10.Store(228, asuint(_64.a[1].x)); - _10.Store(232, asuint(_64.a[0].y)); - _10.Store(236, asuint(_64.a[1].y)); - _10.Store2(240, asuint(_64.b)); + _12.Store(224, asuint(_64.a[0].x)); + _12.Store(228, asuint(_64.a[1].x)); + _12.Store(232, asuint(_64.a[0].y)); + _12.Store(236, asuint(_64.a[1].y)); + _12.Store2(240, asuint(_64.b)); [unroll] for (int _4ident = 0; _4ident < 5; _4ident++) { @@ -57,13 +57,13 @@ void comp_main() [unroll] for (int _6ident = 0; _6ident < 4; _6ident++) { - _10.Store(_6ident * 4 + _5ident * 16 + _4ident * 40 + 248, asuint(_64.c[_4ident].d[_5ident][_6ident])); + _12.Store(_6ident * 4 + _5ident * 16 + _4ident * 40 + 248, asuint(_64.c[_4ident].d[_5ident][_6ident])); } } [unroll] for (int _7ident = 0; _7ident < 2; _7ident++) { - _10.Store(_7ident * 4 + _4ident * 40 + 280, asuint(_64.c[_4ident].baz[_7ident].c)); + _12.Store(_7ident * 4 + _4ident * 40 + 280, asuint(_64.c[_4ident].baz[_7ident].c)); } } } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp index b75157162d..74f3e72307 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp @@ -3,16 +3,16 @@ struct T float c; }; -static const T _18 = { 40.0f }; +static const T _11 = { 40.0f }; -RWByteAddressBuffer _7 : register(u0); -RWByteAddressBuffer _10 : register(u1); +RWByteAddressBuffer _9 : register(u0); +RWByteAddressBuffer _13 : register(u1); void comp_main() { - T v = _18; - _7.Store(40, asuint(v.c)); - _10.Store(480, asuint(v.c)); + T v = _11; + _9.Store(40, asuint(v.c)); + _13.Store(480, asuint(v.c)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-load-store.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-load-store.asm.comp index 4f6a3e34c2..9bbfb07f10 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-load-store.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-load-store.asm.comp @@ -1,14 +1,14 @@ static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); -RWByteAddressBuffer _5 : register(u0); +RWByteAddressBuffer _7 : register(u0); void comp_main() { - uint _20; - _5.InterlockedAdd(4, 0, _20); - uint c = _20; + uint _16; + _7.InterlockedAdd(4, 0, _16); + uint c = _16; uint _23; - _5.InterlockedExchange(0, c, _23); + _7.InterlockedExchange(0, c, _23); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-result-temporary.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-result-temporary.asm.comp index 3a03fafe63..bad006c58e 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-result-temporary.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/atomic-result-temporary.asm.comp @@ -1,4 +1,4 @@ -RWByteAddressBuffer _5 : register(u0); +RWByteAddressBuffer _7 : register(u0); static uint3 gl_GlobalInvocationID; struct SPIRV_Cross_Input @@ -8,11 +8,11 @@ struct SPIRV_Cross_Input void comp_main() { - uint _24; - _5.InterlockedAdd(0, 1u, _24); - if (_24 < 1024u) + uint _19; + _7.InterlockedAdd(0, 1u, _19); + if (_19 < 1024u) { - _5.Store(_24 * 4 + 4, gl_GlobalInvocationID.x); + _7.Store(_19 * 4 + 4, gl_GlobalInvocationID.x); } } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp index ebc431b3ed..24bdea176f 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp @@ -1,4 +1,4 @@ -RWByteAddressBuffer _3 : register(u0); +RWByteAddressBuffer _4 : register(u0); uint spvBitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) { @@ -82,20 +82,20 @@ int4 spvBitfieldSExtract(int4 Base, int Offset, int Count) void comp_main() { - int4 _19 = int4(_3.Load4(0)); - uint4 _20 = _3.Load4(16); - _3.Store4(0, uint4(countbits(_19))); - _3.Store4(16, uint4(countbits(_19))); - _3.Store4(0, uint4(int4(countbits(_20)))); - _3.Store4(16, countbits(_20)); - _3.Store4(0, uint4(reversebits(_19))); - _3.Store4(16, reversebits(_20)); - _3.Store4(0, uint4(spvBitfieldSExtract(_19, 1, 11u))); - _3.Store4(16, spvBitfieldSExtract(_20, 11u, 1)); - _3.Store4(0, uint4(spvBitfieldUExtract(_19, 1, 11u))); - _3.Store4(16, spvBitfieldUExtract(_20, 11u, 1)); - _3.Store4(0, uint4(int4(spvBitfieldInsert(_19, _19.wzyx, 1, 11u)))); - _3.Store4(16, spvBitfieldInsert(_20, _20.wzyx, 11u, 1)); + int4 _19 = int4(_4.Load4(0)); + uint4 _20 = _4.Load4(16); + _4.Store4(0, uint4(countbits(_19))); + _4.Store4(16, uint4(countbits(_19))); + _4.Store4(0, uint4(int4(countbits(_20)))); + _4.Store4(16, countbits(_20)); + _4.Store4(0, uint4(reversebits(_19))); + _4.Store4(16, reversebits(_20)); + _4.Store4(0, uint4(spvBitfieldSExtract(_19, 1, 11u))); + _4.Store4(16, spvBitfieldSExtract(_20, 11u, 1)); + _4.Store4(0, uint4(spvBitfieldUExtract(_19, 1, 11u))); + _4.Store4(16, spvBitfieldUExtract(_20, 11u, 1)); + _4.Store4(0, uint4(int4(spvBitfieldInsert(_19, _19.wzyx, 1, 11u)))); + _4.Store4(16, spvBitfieldInsert(_20, _20.wzyx, 11u, 1)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitscan.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitscan.asm.comp index f8a5fb6fa3..8ef4eab8ad 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitscan.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitscan.asm.comp @@ -1,21 +1,21 @@ -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - uint4 _19 = _4.Load4(0); - int4 _20 = int4(_4.Load4(16)); - _4.Store4(0, firstbitlow(_19)); - _4.Store4(16, uint4(int4(firstbitlow(_19)))); - _4.Store4(0, uint4(firstbitlow(_20))); - _4.Store4(16, uint4(firstbitlow(_20))); - _4.Store4(0, firstbithigh(_19)); - _4.Store4(16, uint4(int4(firstbithigh(_19)))); - _4.Store4(0, firstbithigh(uint4(_20))); - _4.Store4(16, uint4(int4(firstbithigh(uint4(_20))))); - _4.Store4(0, uint4(firstbithigh(int4(_19)))); - _4.Store4(16, uint4(firstbithigh(int4(_19)))); - _4.Store4(0, uint4(firstbithigh(_20))); - _4.Store4(16, uint4(firstbithigh(_20))); + uint4 _19 = _6.Load4(0); + int4 _20 = int4(_6.Load4(16)); + _6.Store4(0, firstbitlow(_19)); + _6.Store4(16, uint4(int4(firstbitlow(_19)))); + _6.Store4(0, uint4(firstbitlow(_20))); + _6.Store4(16, uint4(firstbitlow(_20))); + _6.Store4(0, firstbithigh(_19)); + _6.Store4(16, uint4(int4(firstbithigh(_19)))); + _6.Store4(0, firstbithigh(uint4(_20))); + _6.Store4(16, uint4(int4(firstbithigh(uint4(_20))))); + _6.Store4(0, uint4(firstbithigh(int4(_19)))); + _6.Store4(16, uint4(firstbithigh(int4(_19)))); + _6.Store4(0, uint4(firstbithigh(_20))); + _6.Store4(16, uint4(firstbithigh(_20))); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/buffer-atomic-nonuniform.asm.sm51.nonuniformresource.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/buffer-atomic-nonuniform.asm.sm51.nonuniformresource.comp index 0b6d93e48f..1891581a40 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/buffer-atomic-nonuniform.asm.sm51.nonuniformresource.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/buffer-atomic-nonuniform.asm.sm51.nonuniformresource.comp @@ -8,9 +8,9 @@ struct SPIRV_Cross_Input void comp_main() { - uint _24 = gl_GlobalInvocationID.z; + uint _18 = gl_GlobalInvocationID.z; uint _25; - ssbos[NonUniformResourceIndex(_24)].InterlockedAdd(0, 1u, _25); + ssbos[NonUniformResourceIndex(_18)].InterlockedAdd(0, 1u, _25); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp index d3dc533753..be2e503b3e 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp @@ -3,7 +3,7 @@ static const uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u); static const int indexable[4] = { 0, 1, 2, 3 }; static const int indexable_1[4] = { 4, 5, 6, 7 }; -RWByteAddressBuffer _6 : register(u0); +RWByteAddressBuffer _8 : register(u0); static uint3 gl_LocalInvocationID; static uint3 gl_GlobalInvocationID; @@ -15,7 +15,7 @@ struct SPIRV_Cross_Input void comp_main() { - _6.Store(gl_GlobalInvocationID.x * 4 + 0, uint(indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y])); + _8.Store(gl_GlobalInvocationID.x * 4 + 0, uint(indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y])); } [numthreads(4, 4, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl-signed-operations.asm.comp index db16cf60ed..43fb1ed232 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl-signed-operations.asm.comp @@ -1,41 +1,41 @@ -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - int4 _19 = int4(_4.Load4(0)); - uint4 _20 = _4.Load4(16); - _4.Store4(0, uint4(abs(_19))); - _4.Store4(16, uint4(abs(_19))); - _4.Store4(0, uint4(abs(int4(_20)))); - _4.Store4(16, uint4(abs(int4(_20)))); - _4.Store4(0, uint4(sign(_19))); - _4.Store4(16, uint4(sign(_19))); - _4.Store4(0, uint4(sign(int4(_20)))); - _4.Store4(16, uint4(sign(int4(_20)))); - _4.Store4(0, uint4(firstbithigh(int4(_20)))); - _4.Store4(16, uint4(firstbithigh(int4(_20)))); - _4.Store4(0, uint4(int4(firstbithigh(uint4(_19))))); - _4.Store4(16, firstbithigh(uint4(_19))); - _4.Store4(0, uint4(min(_19, _19))); - _4.Store4(16, uint4(min(_19, int4(_20)))); - _4.Store4(0, uint4(min(int4(_20), int4(_20)))); - _4.Store4(16, uint4(min(int4(_20), _19))); - _4.Store4(0, uint4(int4(min(uint4(_19), _20)))); - _4.Store4(16, min(uint4(_19), _20)); - _4.Store4(0, uint4(int4(min(_20, uint4(_19))))); - _4.Store4(16, min(_20, uint4(_19))); - _4.Store4(0, uint4(max(_19, _19))); - _4.Store4(16, uint4(max(_19, _19))); - _4.Store4(0, uint4(max(int4(_20), _19))); - _4.Store4(16, uint4(max(int4(_20), _19))); - _4.Store4(0, uint4(int4(max(uint4(_19), _20)))); - _4.Store4(16, max(uint4(_19), uint4(_19))); - _4.Store4(0, uint4(int4(max(_20, uint4(_19))))); - _4.Store4(16, max(_20, uint4(_19))); - _4.Store4(0, uint4(clamp(int4(_20), int4(_20), int4(_20)))); - _4.Store4(16, uint4(clamp(int4(_20), int4(_20), int4(_20)))); - _4.Store4(0, uint4(int4(clamp(uint4(_19), uint4(_19), uint4(_19))))); - _4.Store4(16, clamp(uint4(_19), uint4(_19), uint4(_19))); + int4 _19 = int4(_6.Load4(0)); + uint4 _20 = _6.Load4(16); + _6.Store4(0, uint4(abs(_19))); + _6.Store4(16, uint4(abs(_19))); + _6.Store4(0, uint4(abs(int4(_20)))); + _6.Store4(16, uint4(abs(int4(_20)))); + _6.Store4(0, uint4(sign(_19))); + _6.Store4(16, uint4(sign(_19))); + _6.Store4(0, uint4(sign(int4(_20)))); + _6.Store4(16, uint4(sign(int4(_20)))); + _6.Store4(0, uint4(firstbithigh(int4(_20)))); + _6.Store4(16, uint4(firstbithigh(int4(_20)))); + _6.Store4(0, uint4(int4(firstbithigh(uint4(_19))))); + _6.Store4(16, firstbithigh(uint4(_19))); + _6.Store4(0, uint4(min(_19, _19))); + _6.Store4(16, uint4(min(_19, int4(_20)))); + _6.Store4(0, uint4(min(int4(_20), int4(_20)))); + _6.Store4(16, uint4(min(int4(_20), _19))); + _6.Store4(0, uint4(int4(min(uint4(_19), _20)))); + _6.Store4(16, min(uint4(_19), _20)); + _6.Store4(0, uint4(int4(min(_20, uint4(_19))))); + _6.Store4(16, min(_20, uint4(_19))); + _6.Store4(0, uint4(max(_19, _19))); + _6.Store4(16, uint4(max(_19, _19))); + _6.Store4(0, uint4(max(int4(_20), _19))); + _6.Store4(16, uint4(max(int4(_20), _19))); + _6.Store4(0, uint4(int4(max(uint4(_19), _20)))); + _6.Store4(16, max(uint4(_19), uint4(_19))); + _6.Store4(0, uint4(int4(max(_20, uint4(_19))))); + _6.Store4(16, max(_20, uint4(_19))); + _6.Store4(0, uint4(clamp(int4(_20), int4(_20), int4(_20)))); + _6.Store4(16, uint4(clamp(int4(_20), int4(_20), int4(_20)))); + _6.Store4(0, uint4(int4(clamp(uint4(_19), uint4(_19), uint4(_19))))); + _6.Store4(16, clamp(uint4(_19), uint4(_19), uint4(_19))); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.fxconly.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.fxconly.asm.comp index b1232635ea..14c0a61136 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.fxconly.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.fxconly.asm.comp @@ -1,27 +1,27 @@ -struct _8 +struct _9 { float _m0; float _m1; }; -struct _15 +struct _16 { float _m0; int _m1; }; -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - _8 _23; + _9 _23; _23._m0 = modf(20.0f, _23._m1); - _15 _24; + _16 _24; _24._m0 = frexp(40.0f, _24._m1); - _4.Store(0, asuint(_23._m0)); - _4.Store(0, asuint(_23._m1)); - _4.Store(0, asuint(_24._m0)); - _4.Store(4, uint(_24._m1)); + _6.Store(0, asuint(_23._m0)); + _6.Store(0, asuint(_23._m1)); + _6.Store(0, asuint(_24._m0)); + _6.Store(4, uint(_24._m1)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/image-atomic-nonuniform.asm.sm51.nonuniformresource.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/image-atomic-nonuniform.asm.sm51.nonuniformresource.comp index 07f87ca9e6..9209e41fae 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/image-atomic-nonuniform.asm.sm51.nonuniformresource.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/image-atomic-nonuniform.asm.sm51.nonuniformresource.comp @@ -8,9 +8,9 @@ struct SPIRV_Cross_Input void comp_main() { - uint _26 = gl_GlobalInvocationID.z; + uint _18 = gl_GlobalInvocationID.z; uint _31; - InterlockedAdd(uImage[NonUniformResourceIndex(_26)][int2(gl_GlobalInvocationID.xy)], 1u, _31); + InterlockedAdd(uImage[NonUniformResourceIndex(_18)][int2(gl_GlobalInvocationID.xy)], 1u, _31); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id-override.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id-override.asm.comp index dbc881f998..71431dd2b5 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id-override.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id-override.asm.comp @@ -1,22 +1,22 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_1 #define SPIRV_CROSS_CONSTANT_ID_1 11u #endif -static const uint _10 = SPIRV_CROSS_CONSTANT_ID_1; +static const uint _12 = SPIRV_CROSS_CONSTANT_ID_1; #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 12u #endif -static const uint _11 = SPIRV_CROSS_CONSTANT_ID_2; +static const uint _13 = SPIRV_CROSS_CONSTANT_ID_2; #ifndef SPIRV_CROSS_CONSTANT_ID_3 #define SPIRV_CROSS_CONSTANT_ID_3 13u #endif -static const uint _4 = SPIRV_CROSS_CONSTANT_ID_3; +static const uint _6 = SPIRV_CROSS_CONSTANT_ID_3; #ifndef SPIRV_CROSS_CONSTANT_ID_4 #define SPIRV_CROSS_CONSTANT_ID_4 14u #endif -static const uint _5 = SPIRV_CROSS_CONSTANT_ID_4; -static const uint3 gl_WorkGroupSize = uint3(3u, _10, _11); +static const uint _7 = SPIRV_CROSS_CONSTANT_ID_4; +static const uint3 gl_WorkGroupSize = uint3(3u, _12, _13); -RWByteAddressBuffer _8 : register(u0); +RWByteAddressBuffer _10 : register(u0); static uint3 gl_GlobalInvocationID; struct SPIRV_Cross_Input @@ -26,7 +26,7 @@ struct SPIRV_Cross_Input void comp_main() { - _8.Store4(gl_GlobalInvocationID.x * 16 + 0, asuint(asfloat(_8.Load4(gl_GlobalInvocationID.x * 16 + 0)) + 2.0f.xxxx)); + _10.Store4(gl_GlobalInvocationID.x * 16 + 0, asuint(asfloat(_10.Load4(gl_GlobalInvocationID.x * 16 + 0)) + 2.0f.xxxx)); } [numthreads(3, SPIRV_CROSS_CONSTANT_ID_1, SPIRV_CROSS_CONSTANT_ID_2)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.invalid.comp similarity index 55% rename from third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.comp rename to third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.invalid.comp index 157f9e9921..84d7a59508 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.invalid.comp @@ -1,23 +1,23 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_1 #define SPIRV_CROSS_CONSTANT_ID_1 11 #endif -static const int _10 = SPIRV_CROSS_CONSTANT_ID_1; +static const int _12 = SPIRV_CROSS_CONSTANT_ID_1; #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 12 #endif -static const int _11 = SPIRV_CROSS_CONSTANT_ID_2; +static const int _13 = SPIRV_CROSS_CONSTANT_ID_2; #ifndef SPIRV_CROSS_CONSTANT_ID_3 #define SPIRV_CROSS_CONSTANT_ID_3 13 #endif -static const int _4 = SPIRV_CROSS_CONSTANT_ID_3; +static const int _6 = SPIRV_CROSS_CONSTANT_ID_3; #ifndef SPIRV_CROSS_CONSTANT_ID_4 #define SPIRV_CROSS_CONSTANT_ID_4 14 #endif -static const int _5 = SPIRV_CROSS_CONSTANT_ID_4; -static const uint _29 = (uint(_4) + 3u); -static const uint3 _30 = uint3(_29, _5, 2u); +static const int _7 = SPIRV_CROSS_CONSTANT_ID_4; +static const uint _37 = (uint(_6) + 3u); +static const uint3 _38 = uint3(_37, _7, 2u); -RWByteAddressBuffer _8 : register(u0); +RWByteAddressBuffer _10 : register(u0); static uint3 gl_GlobalInvocationID; struct SPIRV_Cross_Input @@ -27,7 +27,7 @@ struct SPIRV_Cross_Input void comp_main() { - _8.Store4(gl_GlobalInvocationID.x * 16 + 0, asuint(((((asfloat(_8.Load4(gl_GlobalInvocationID.x * 16 + 0)) + 2.0f.xxxx) + float3(_30).xyzz) * float(_4)) * float(_5)) * float(int(2u)))); + _10.Store4(gl_GlobalInvocationID.x * 16 + 0, asuint(((((asfloat(_10.Load4(gl_GlobalInvocationID.x * 16 + 0)) + 2.0f.xxxx) + float3(_38).xyzz) * float(_6)) * float(_7)) * float(int(2u)))); } [numthreads(SPIRV_CROSS_CONSTANT_ID_3, SPIRV_CROSS_CONSTANT_ID_4, 2)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/num-workgroups.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/num-workgroups.spv14.asm.comp index e771d77bb8..1bb3b0df26 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/num-workgroups.spv14.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/num-workgroups.spv14.asm.comp @@ -1,9 +1,9 @@ static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); -RWByteAddressBuffer _3 : register(u1); +RWByteAddressBuffer _4 : register(u1); cbuffer UBO : register(b0) { - uint3 _5_w : packoffset(c0); + uint3 _7_w : packoffset(c0); }; cbuffer SPIRV_Cross_NumWorkgroups @@ -14,7 +14,7 @@ cbuffer SPIRV_Cross_NumWorkgroups void comp_main() { - _3.Store3(0, SPIRV_Cross_NumWorkgroups_1_count + _5_w); + _4.Store3(0, SPIRV_Cross_NumWorkgroups_1_count + _7_w); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp index 423beee63f..983a4932cc 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp @@ -30,7 +30,7 @@ static const int A_10 = (A_9 - A_5); static const int A_11 = (A_10 + A_5); static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); -RWByteAddressBuffer _5 : register(u0); +RWByteAddressBuffer _7 : register(u0); static uint3 gl_GlobalInvocationID; struct SPIRV_Cross_Input @@ -40,7 +40,7 @@ struct SPIRV_Cross_Input void comp_main() { - _5.Store(gl_GlobalInvocationID.x * 4 + 0, uint(A_11)); + _7.Store(gl_GlobalInvocationID.x * 4 + 0, uint(A_11)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/specialization-constant-workgroup.nofxc.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/specialization-constant-workgroup.nofxc.asm.comp index 8c239b3198..bdb8692d0b 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/specialization-constant-workgroup.nofxc.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/specialization-constant-workgroup.nofxc.asm.comp @@ -1,18 +1,18 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_10 #define SPIRV_CROSS_CONSTANT_ID_10 9u #endif -static const uint _5 = SPIRV_CROSS_CONSTANT_ID_10; +static const uint _19 = SPIRV_CROSS_CONSTANT_ID_10; #ifndef SPIRV_CROSS_CONSTANT_ID_12 #define SPIRV_CROSS_CONSTANT_ID_12 4u #endif -static const uint _6 = SPIRV_CROSS_CONSTANT_ID_12; -static const uint3 gl_WorkGroupSize = uint3(_5, 20u, _6); +static const uint _21 = SPIRV_CROSS_CONSTANT_ID_12; +static const uint3 gl_WorkGroupSize = uint3(_19, 20u, _21); -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - _4.Store(0, asuint(asfloat(_4.Load(0)) + 1.0f)); + _6.Store(0, asuint(asfloat(_6.Load(0)) + 1.0f)); } [numthreads(SPIRV_CROSS_CONSTANT_ID_10, 20, SPIRV_CROSS_CONSTANT_ID_12)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp index c567fbaf14..5e569dd0bb 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp @@ -1,15 +1,15 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_0 #define SPIRV_CROSS_CONSTANT_ID_0 1u #endif -static const uint _3 = SPIRV_CROSS_CONSTANT_ID_0; +static const uint _15 = SPIRV_CROSS_CONSTANT_ID_0; #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 3u #endif -static const uint _4 = SPIRV_CROSS_CONSTANT_ID_2; -static const uint3 gl_WorkGroupSize = uint3(_3, 2u, _4); +static const uint _17 = SPIRV_CROSS_CONSTANT_ID_2; +static const uint3 gl_WorkGroupSize = uint3(_15, 2u, _17); -RWByteAddressBuffer _8 : register(u0); -RWByteAddressBuffer _9 : register(u1); +RWByteAddressBuffer _20 : register(u0); +RWByteAddressBuffer _21 : register(u1); static uint3 gl_WorkGroupID; struct SPIRV_Cross_Input @@ -17,11 +17,11 @@ struct SPIRV_Cross_Input uint3 gl_WorkGroupID : SV_GroupID; }; -static uint3 _22 = gl_WorkGroupSize; +static uint3 _19 = 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)))); + _20.Store(gl_WorkGroupID.x * 4 + 0, asuint(asfloat(_21.Load(gl_WorkGroupID.x * 4 + 0)) + asfloat(_20.Load(gl_WorkGroupID.x * 4 + 0)))); } [numthreads(SPIRV_CROSS_CONSTANT_ID_0, 2, SPIRV_CROSS_CONSTANT_ID_2)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/anonymous-inner-struct-names.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/anonymous-inner-struct-names.asm.frag index 128a8c52f9..0a2038db16 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/anonymous-inner-struct-names.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/anonymous-inner-struct-names.asm.frag @@ -63,13 +63,13 @@ struct anon_e cbuffer UBO : register(b0) { - anon_c _16_c : packoffset(c0); - anon_d _16_d : packoffset(c1); + anon_c _18_c : packoffset(c0); + anon_d _18_d : packoffset(c1); }; -RWByteAddressBuffer _19 : register(u1); +RWByteAddressBuffer _21 : register(u1); -static VertexData _3; +static VertexData _4; struct SPIRV_Cross_Input { @@ -83,7 +83,7 @@ void frag_main() void main(SPIRV_Cross_Input stage_input) { - _3._a = stage_input.VertexData__a; - _3.b = stage_input.VertexData_b; + _4._a = stage_input.VertexData__a; + _4.b = stage_input.VertexData_b; frag_main(); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/composite-insert-inheritance.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/composite-insert-inheritance.asm.frag index 8c61e61b5f..aa504a99e3 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/composite-insert-inheritance.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/composite-insert-inheritance.asm.frag @@ -1,6 +1,6 @@ -static float4 _32; +static float4 _33; -static const float4 _34[2] = { 0.0f.xxxx, 0.0f.xxxx }; +static const float4 _35[2] = { 0.0f.xxxx, 0.0f.xxxx }; static float4 vInput; static float4 FragColor; @@ -24,12 +24,12 @@ void frag_main() _38.z = 3.0f; _38.w = 4.0f; FragColor = _38; - float4 _6 = _37; - _6.x = 1.0f; - _6.y = 2.0f; - _6.z = 3.0f; - _6.w = 4.0f; - FragColor = _6; + float4 _8 = _37; + _8.x = 1.0f; + _8.y = 2.0f; + _8.z = 3.0f; + _8.w = 4.0f; + FragColor = _8; float4 _42 = _37; _42.x = 1.0f; _42.y = 2.0f; @@ -55,7 +55,7 @@ void frag_main() float4 _53 = 0.0f.xxxx; _53.x = 1.0f; FragColor = _53; - float4 _54[2] = _34; + float4 _54[2] = _35; _54[1].z = 1.0f; _54[0].w = 2.0f; FragColor = _54[0]; diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/empty-struct-in-struct.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/empty-struct-in-struct.asm.frag index e7ffd8d606..660090363a 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/empty-struct-in-struct.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/empty-struct-in-struct.asm.frag @@ -8,8 +8,8 @@ struct EmptyStruct2Test EmptyStructTest _m0; }; -static const EmptyStructTest _30 = { 0 }; -static const EmptyStruct2Test _20 = { { 0 } }; +static const EmptyStructTest _38 = { 0 }; +static const EmptyStruct2Test _26 = { { 0 } }; float GetValue(EmptyStruct2Test self) { @@ -23,12 +23,12 @@ float GetValue_1(EmptyStruct2Test self) void frag_main() { - EmptyStructTest _25 = { 0 }; - EmptyStruct2Test _26 = { _25 }; + EmptyStructTest _27 = { 0 }; + EmptyStruct2Test _28 = { _27 }; EmptyStruct2Test emptyStruct; float value = GetValue(emptyStruct); + value = GetValue_1(_28); value = GetValue_1(_26); - value = GetValue_1(_20); } void main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag index fd758b17d7..70567a71ec 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag @@ -1,4 +1,4 @@ -ByteAddressBuffer _8 : register(t0, space2); +ByteAddressBuffer _12 : register(t0, space2); Texture2D uSamplers[] : register(t0, space0); SamplerState _uSamplers_sampler[] : register(s0, space0); Texture2D uSampler : register(t1, space1); @@ -21,8 +21,8 @@ struct SPIRV_Cross_Output void frag_main() { - FragColor = uSamplers[NonUniformResourceIndex(_8.Load(40))].SampleLevel(_uSamplers_sampler[NonUniformResourceIndex(_8.Load(40))], vUV, 0.0f); - FragColor += uSampler.SampleLevel(_uSampler_sampler, vUV, float(_8.Load(int(gl_FragCoord.y) * 4 + 0))); + FragColor = uSamplers[NonUniformResourceIndex(_12.Load(40))].SampleLevel(_uSamplers_sampler[NonUniformResourceIndex(_12.Load(40))], vUV, 0.0f); + FragColor += uSampler.SampleLevel(_uSampler_sampler, vUV, float(_12.Load(int(gl_FragCoord.y) * 4 + 0))); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag index 0356cf58d9..40635032da 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag @@ -28,17 +28,17 @@ struct SPIRV_Cross_Output void frag_main() { int i = vIndex; - int _59 = i + 10; - int _64 = i + 40; - FragColor = uSamplers[NonUniformResourceIndex(_59)].Sample(uSamps[NonUniformResourceIndex(_64)], vUV); - int _71 = i + 10; - FragColor = uCombinedSamplers[NonUniformResourceIndex(_71)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_71)], vUV); - int _77 = i + 20; - int _80 = i + 40; - FragColor += ubos[NonUniformResourceIndex(_77)].v[_80]; - int _87 = i + 50; - int _90 = i + 60; - FragColor += asfloat(ssbos[NonUniformResourceIndex(_87)].Load4(_90 * 16 + 0)); + int _23 = i + 10; + int _34 = i + 40; + FragColor = uSamplers[NonUniformResourceIndex(_23)].Sample(uSamps[NonUniformResourceIndex(_34)], vUV); + int _50 = i + 10; + FragColor = uCombinedSamplers[NonUniformResourceIndex(_50)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_50)], vUV); + int _66 = i + 20; + int _70 = i + 40; + FragColor += ubos[NonUniformResourceIndex(_66)].v[_70]; + int _84 = i + 50; + int _88 = i + 60; + FragColor += asfloat(ssbos[NonUniformResourceIndex(_84)].Load4(_88 * 16 + 0)); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag index a692cdcf40..4c69c490de 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag @@ -16,17 +16,17 @@ struct SPIRV_Cross_Output void frag_main() { int i = vIndex; - int _42 = i + 60; - int _45 = i + 70; - ssbos[NonUniformResourceIndex(_42)].Store4(_45 * 16 + 16, asuint(20.0f.xxxx)); - int _48 = i + 100; - uint _49; - ssbos[NonUniformResourceIndex(_48)].InterlockedAdd(0, 100u, _49); - int _51 = i; - uint _52; - ssbos[NonUniformResourceIndex(_51)].GetDimensions(_52); - _52 = (_52 - 16) / 16; - FragColor.z += float(int(_52)); + int _23 = i + 60; + int _28 = i + 70; + ssbos[NonUniformResourceIndex(_23)].Store4(_28 * 16 + 16, asuint(20.0f.xxxx)); + int _36 = i + 100; + uint _43; + ssbos[NonUniformResourceIndex(_36)].InterlockedAdd(0, 100u, _43); + int _47 = i; + uint _50; + ssbos[NonUniformResourceIndex(_47)].GetDimensions(_50); + _50 = (_50 - 16) / 16; + FragColor.z += float(int(_50)); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/phi.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/phi.zero-initialize.asm.frag index 2ce5fd41cf..bd25fdd9d3 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/phi.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/phi.zero-initialize.asm.frag @@ -24,14 +24,14 @@ struct SPIRV_Cross_Output void frag_main() { - int _39 = 0; + int _27 = 0; if (vColor.x > 10.0f) { - _39 = 10; + _27 = 10; } else { - _39 = 20; + _27 = 20; } FragColor = vColor; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-callstack.sm51.fxconly.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-callstack.sm51.fxconly.asm.frag index 8a47b91bf9..d2d0161996 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-callstack.sm51.fxconly.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-callstack.sm51.fxconly.asm.frag @@ -1,5 +1,5 @@ -RasterizerOrderedByteAddressBuffer _7 : register(u1, space0); -RWByteAddressBuffer _9 : register(u0, space0); +RasterizerOrderedByteAddressBuffer _11 : register(u1, space0); +RWByteAddressBuffer _13 : register(u0, space0); static float4 gl_FragCoord; struct SPIRV_Cross_Input @@ -9,14 +9,14 @@ struct SPIRV_Cross_Input void callee2() { - int _31 = int(gl_FragCoord.x); - _7.Store(_31 * 4 + 0, _7.Load(_31 * 4 + 0) + 1u); + int _25 = int(gl_FragCoord.x); + _11.Store(_25 * 4 + 0, _11.Load(_25 * 4 + 0) + 1u); } void callee() { - int _39 = int(gl_FragCoord.x); - _9.Store(_39 * 4 + 0, _9.Load(_39 * 4 + 0) + 1u); + int _38 = int(gl_FragCoord.x); + _13.Store(_38 * 4 + 0, _13.Load(_38 * 4 + 0) + 1u); callee2(); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-control-flow.sm51.fxconly.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-control-flow.sm51.fxconly.asm.frag index 01bbe7ddc2..2c0a2cdd9f 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-control-flow.sm51.fxconly.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-control-flow.sm51.fxconly.asm.frag @@ -1,6 +1,6 @@ -RasterizerOrderedByteAddressBuffer _7 : register(u1, space0); -RWByteAddressBuffer _13 : register(u2, space0); -RasterizerOrderedByteAddressBuffer _9 : register(u0, space0); +RasterizerOrderedByteAddressBuffer _11 : register(u1, space0); +RWByteAddressBuffer _17 : register(u2, space0); +RasterizerOrderedByteAddressBuffer _13 : register(u0, space0); static float4 gl_FragCoord; struct SPIRV_Cross_Input @@ -10,29 +10,29 @@ struct SPIRV_Cross_Input void callee2() { - int _44 = int(gl_FragCoord.x); - _7.Store(_44 * 4 + 0, _7.Load(_44 * 4 + 0) + 1u); + int _25 = int(gl_FragCoord.x); + _11.Store(_25 * 4 + 0, _11.Load(_25 * 4 + 0) + 1u); } void callee() { - int _52 = int(gl_FragCoord.x); - _9.Store(_52 * 4 + 0, _9.Load(_52 * 4 + 0) + 1u); + int _38 = int(gl_FragCoord.x); + _13.Store(_38 * 4 + 0, _13.Load(_38 * 4 + 0) + 1u); callee2(); if (true) { } } -void _35() +void _52() { - _13.Store(int(gl_FragCoord.x) * 4 + 0, 4u); + _17.Store(int(gl_FragCoord.x) * 4 + 0, 4u); } void frag_main() { callee(); - _35(); + _52(); } void main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-split-functions.sm51.fxconly.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-split-functions.sm51.fxconly.asm.frag index c1fb6ebbc2..dc6f33dbef 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-split-functions.sm51.fxconly.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/pixel-interlock-split-functions.sm51.fxconly.asm.frag @@ -1,5 +1,5 @@ -RasterizerOrderedByteAddressBuffer _7 : register(u1, space0); -RasterizerOrderedByteAddressBuffer _9 : register(u0, space0); +RasterizerOrderedByteAddressBuffer _11 : register(u1, space0); +RasterizerOrderedByteAddressBuffer _13 : register(u0, space0); static float4 gl_FragCoord; struct SPIRV_Cross_Input @@ -9,30 +9,30 @@ struct SPIRV_Cross_Input void callee2() { - int _37 = int(gl_FragCoord.x); - _7.Store(_37 * 4 + 0, _7.Load(_37 * 4 + 0) + 1u); + int _25 = int(gl_FragCoord.x); + _11.Store(_25 * 4 + 0, _11.Load(_25 * 4 + 0) + 1u); } void callee() { - int _45 = int(gl_FragCoord.x); - _9.Store(_45 * 4 + 0, _9.Load(_45 * 4 + 0) + 1u); + int _38 = int(gl_FragCoord.x); + _13.Store(_38 * 4 + 0, _13.Load(_38 * 4 + 0) + 1u); callee2(); } -void _29() +void _46() { } -void _31() +void _48() { } void frag_main() { callee(); - _29(); - _31(); + _46(); + _48(); } void main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..8c9650245e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,26 @@ +static uint gl_SampleMaskIn[1]; +static uint gl_SampleMask[1]; +struct SPIRV_Cross_Input +{ + uint gl_SampleMaskIn : SV_Coverage; +}; + +struct SPIRV_Cross_Output +{ + uint gl_SampleMask : SV_Coverage; +}; + +void frag_main() +{ + uint copy_sample_mask[1] = gl_SampleMaskIn; + gl_SampleMask = copy_sample_mask; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_SampleMask = gl_SampleMask[0]; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..e35a42ae71 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,26 @@ +static int gl_SampleMaskIn[1]; +static int gl_SampleMask[1]; +struct SPIRV_Cross_Input +{ + uint gl_SampleMaskIn : SV_Coverage; +}; + +struct SPIRV_Cross_Output +{ + uint gl_SampleMask : SV_Coverage; +}; + +void frag_main() +{ + int copy_sample_mask[1] = gl_SampleMaskIn; + gl_SampleMask = copy_sample_mask; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_SampleMask = gl_SampleMask[0]; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/scalar-select.spv14.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/scalar-select.spv14.asm.frag index b6d1a90242..d0e43211b8 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/scalar-select.spv14.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/scalar-select.spv14.asm.frag @@ -1,12 +1,12 @@ -struct _15 +struct _16 { float _m0; }; -static const _15 _25 = { 0.0f }; -static const _15 _26 = { 1.0f }; -static const float _29[2] = { 0.0f, 1.0f }; -static const float _30[2] = { 1.0f, 0.0f }; +static const _16 _30 = { 0.0f }; +static const _16 _31 = { 1.0f }; +static const float _34[2] = { 0.0f, 1.0f }; +static const float _35[2] = { 1.0f, 0.0f }; static float4 FragColor; @@ -15,7 +15,7 @@ struct SPIRV_Cross_Output float4 FragColor : SV_Target0; }; -void spvSelectComposite(out _15 out_value, bool cond, _15 true_val, _15 false_val) +void spvSelectComposite(out _16 out_value, bool cond, _16 true_val, _16 false_val) { if (cond) { @@ -45,12 +45,12 @@ void frag_main() FragColor = false ? 1.0f.xxxx : 0.0f.xxxx; FragColor = float4(bool4(false, true, false, true).x ? float4(1.0f, 1.0f, 0.0f, 1.0f).x : float4(0.0f, 0.0f, 0.0f, 1.0f).x, bool4(false, true, false, true).y ? float4(1.0f, 1.0f, 0.0f, 1.0f).y : float4(0.0f, 0.0f, 0.0f, 1.0f).y, bool4(false, true, false, true).z ? float4(1.0f, 1.0f, 0.0f, 1.0f).z : float4(0.0f, 0.0f, 0.0f, 1.0f).z, bool4(false, true, false, true).w ? float4(1.0f, 1.0f, 0.0f, 1.0f).w : float4(0.0f, 0.0f, 0.0f, 1.0f).w); FragColor = float4(bool4(false, true, false, true)); - _15 _38; - spvSelectComposite(_38, false, _25, _26); - _15 _32 = _38; + _16 _38; + spvSelectComposite(_38, false, _30, _31); + _16 _36 = _38; float _39[2]; - spvSelectComposite(_39, true, _29, _30); - float _33[2] = _39; + spvSelectComposite(_39, true, _34, _35); + float _37[2] = _39; } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/struct-packing-last-element-array-matrix-rule.invalid.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/struct-packing-last-element-array-matrix-rule.invalid.asm.frag index b88ac0dd72..7372d75322 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/struct-packing-last-element-array-matrix-rule.invalid.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/struct-packing-last-element-array-matrix-rule.invalid.asm.frag @@ -12,12 +12,12 @@ struct Bar cbuffer FooUBO : register(b0) { - Foo _6_foo : packoffset(c0); + Foo _8_foo : packoffset(c0); }; cbuffer BarUBO : register(b1) { - Bar _9_bar : packoffset(c0); + Bar _11_bar : packoffset(c0); }; @@ -30,7 +30,7 @@ struct SPIRV_Cross_Output void frag_main() { - FragColor = (_6_foo.v + _9_bar.v).xxxx; + FragColor = (_8_foo.v + _11_bar.v).xxxx; } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag index 19af59d3bf..5ac03c2324 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag @@ -15,31 +15,31 @@ void frag_main() { int i = 0; int j; - int _30; - int _31; + int _33; + int _34; switch (vIndex) { case 0: { - _30 = 3; - j = _30; - _31 = 0; - j = _31; + _33 = 3; + j = _33; + _34 = 0; + j = _34; break; } default: { - _30 = 2; - j = _30; - _31 = 0; - j = _31; + _33 = 2; + j = _33; + _34 = 0; + j = _34; break; } case 1: case 11: { - _31 = 1; - j = _31; + _34 = 1; + j = _34; break; } case 2: diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh new file mode 100644 index 0000000000..74e6189a3b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh @@ -0,0 +1,73 @@ +struct _12 +{ + float _m0; +}; + +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +struct gl_MeshPerVertexEXT +{ + float4 B : TEXCOORD1; + float4 gl_Position : SV_Position; +}; + +struct gl_MeshPerPrimitiveEXT +{ + float4 C : TEXCOORD3; + uint gl_PrimitiveID : SV_PrimitiveID; + uint gl_Layer : SV_RenderTargetArrayIndex; + bool gl_CullPrimitiveEXT : SV_CullPrimitive; +}; + +groupshared float _32[64]; + +float4 spvFlipVertY(float4 v) +{ + return float4(v.x, -v.y, v.z, v.w); +} + +float spvFlipVertY(float v) +{ + return -v; +} + +void mesh_main(inout gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], _12 _38, inout uint3 gl_PrimitiveTriangleIndicesEXT[8], inout gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) +{ + _32[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); + GroupMemoryBarrierWithGroupSync(); + SetMeshOutputCounts(24u, 8u); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = spvFlipVertY(_32[gl_LocalInvocationIndex]); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _32[gl_LocalInvocationIndex]; + float _59 = _38._m0 + _32[gl_LocalInvocationIndex ^ 1u]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.x = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.y = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.z = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.w = _59; + if (gl_LocalInvocationIndex < 8u) + { + uint _65 = gl_LocalInvocationIndex * 3u; + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uint3(_65, _65 + 1u, _65 + 2u); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_LocalInvocationIndex & 1u) != 0u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = int(gl_LocalInvocationIndex); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = int(gl_LocalInvocationIndex); + uint _78 = gl_LocalInvocationIndex ^ 2u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.x = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.y = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.z = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.w = _32[_78]; + } +} + +[outputtopology("triangle")] +[numthreads(2, 3, 4)] +void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], in payload _12 _38, out indices uint3 gl_PrimitiveTriangleIndicesEXT[8], out primitives gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) +{ + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + mesh_main(gl_MeshVerticesEXT, _38, gl_PrimitiveTriangleIndicesEXT, gl_MeshPrimitivesEXT); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh index 8fbd2915ae..ec882be5f8 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh @@ -23,41 +23,41 @@ struct gl_MeshPerPrimitiveEXT bool gl_CullPrimitiveEXT : SV_CullPrimitive; }; -groupshared float _9[64]; +groupshared float _32[64]; -void mesh_main(inout gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], _12 _11, inout uint3 gl_PrimitiveTriangleIndicesEXT[8], inout gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) +void mesh_main(inout gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], _12 _38, inout uint3 gl_PrimitiveTriangleIndicesEXT[8], inout gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) { - _9[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); + _32[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); GroupMemoryBarrierWithGroupSync(); SetMeshOutputCounts(24u, 8u); - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _9[gl_LocalInvocationIndex]; - float _63 = _11._m0 + _9[gl_LocalInvocationIndex ^ 1u]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.x = _63; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.y = _63; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.z = _63; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.w = _63; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _32[gl_LocalInvocationIndex]; + float _59 = _38._m0 + _32[gl_LocalInvocationIndex ^ 1u]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.x = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.y = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.z = _59; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].B.w = _59; if (gl_LocalInvocationIndex < 8u) { - uint _71 = gl_LocalInvocationIndex * 3u; - gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uint3(_71, _71 + 1u, _71 + 2u); + uint _65 = gl_LocalInvocationIndex * 3u; + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uint3(_65, _65 + 1u, _65 + 2u); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_LocalInvocationIndex & 1u) != 0u; gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = int(gl_LocalInvocationIndex); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = int(gl_LocalInvocationIndex); - uint _81 = gl_LocalInvocationIndex ^ 2u; - gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.x = _9[_81]; - gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.y = _9[_81]; - gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.z = _9[_81]; - gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.w = _9[_81]; + uint _78 = gl_LocalInvocationIndex ^ 2u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.x = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.y = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.z = _32[_78]; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].C.w = _32[_78]; } } [outputtopology("triangle")] [numthreads(2, 3, 4)] -void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], in payload _12 _11, out indices uint3 gl_PrimitiveTriangleIndicesEXT[8], out primitives gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) +void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], in payload _12 _38, out indices uint3 gl_PrimitiveTriangleIndicesEXT[8], out primitives gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[8]) { gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; - mesh_main(gl_MeshVerticesEXT, _11, gl_PrimitiveTriangleIndicesEXT, gl_MeshPrimitivesEXT); + mesh_main(gl_MeshVerticesEXT, _38, gl_PrimitiveTriangleIndicesEXT, gl_MeshPrimitivesEXT); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag index dbdd784529..040cae6d80 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag @@ -16,19 +16,19 @@ struct SPIRV_Cross_Output void frag_main() { FragColor = 0.0f.xxxx; - int _10 = 0; - int _15 = 0; - for (int _16 = 0, _17 = 0; _16 < vA; _17 = _15, _16 += _10) + int _49 = 0; + int _58 = 0; + for (int _57 = 0, _60 = 0; _57 < vA; _60 = _58, _57 += _49) { - if ((vA + _16) == 20) + if ((vA + _57) == 20) { - _15 = 50; + _58 = 50; } else { - _15 = ((vB + _16) == 40) ? 60 : _17; + _58 = ((vB + _57) == 40) ? 60 : _60; } - _10 = _15 + 10; + _49 = _58 + 10; FragColor += 1.0f.xxxx; } } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert index 72a86d2d44..990b2506bc 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -10,11 +10,11 @@ struct Foo float d; }; -static const Vert _11 = { 0.0f, 0.0f }; -static const Foo _13 = { 0.0f, 0.0f }; +static const Vert _12 = { 0.0f, 0.0f }; +static const Foo _14 = { 0.0f, 0.0f }; -static Vert _3 = { 0.0f, 0.0f }; -static Foo foo = _13; +static Vert _4 = { 0.0f, 0.0f }; +static Foo foo = _14; struct SPIRV_Cross_Output { @@ -31,8 +31,8 @@ SPIRV_Cross_Output main() { vert_main(); SPIRV_Cross_Output stage_output; - stage_output.Vert_a = _3.a; - stage_output.Vert_b = _3.b; + stage_output.Vert_a = _4.a; + stage_output.Vert_b = _4.b; stage_output.foo = foo; return stage_output; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/empty-struct-composite.asm.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/empty-struct-composite.asm.vert index ba1f576748..8574005fd9 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/empty-struct-composite.asm.vert +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/empty-struct-composite.asm.vert @@ -5,8 +5,8 @@ struct Test void vert_main() { - Test _14 = { 0 }; - Test t = _14; + Test _13 = { 0 }; + Test t = _13; } void main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/illegal-struct-name.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/illegal-struct-name.asm.comp index dc972bdda8..15b8a00e1b 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/illegal-struct-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/illegal-struct-name.asm.comp @@ -3,16 +3,16 @@ struct Foo float _abs; }; -RWByteAddressBuffer _7 : register(u0); +RWByteAddressBuffer _9 : register(u0); void comp_main() { - Foo _24; - _24._abs = asfloat(_7.Load(0)); + Foo _18; + _18._abs = asfloat(_9.Load(0)); Foo f; - f._abs = _24._abs; + f._abs = _18._abs; int _abs = 10; - _7.Store(4, asuint(f._abs)); + _9.Store(4, asuint(f._abs)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp new file mode 100644 index 0000000000..64e92a6760 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp @@ -0,0 +1,16 @@ +cbuffer UboData : register(b0) +{ + float3 _12_data0 : packoffset(c0); + int2 _12_data1 : packoffset(c1); +}; + + +void comp_main() +{ +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp new file mode 100644 index 0000000000..cdea108bb7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp @@ -0,0 +1,21 @@ +struct Data +{ + float3 data0; + int2 data1; +}; + +cbuffer UboData : register(b0) +{ + Data _13_scene : packoffset(c0); +}; + + +void comp_main() +{ +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh new file mode 100644 index 0000000000..98be415c2f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh @@ -0,0 +1,84 @@ +#ifndef SPIRV_CROSS_CONSTANT_ID_0 +#define SPIRV_CROSS_CONSTANT_ID_0 1 +#endif +static const int spec_const_index = SPIRV_CROSS_CONSTANT_ID_0; +static const uint3 gl_WorkGroupSize = uint3(2u, 3u, 4u); + +struct BlockOut +{ + float4 a; + float4 b; +}; + +struct TaskPayload +{ + float a; + float b; + int c; +}; + +static uint3 gl_WorkGroupID; +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +struct gl_MeshPerVertexEXT +{ + float4 vOut : TEXCOORD0; + BlockOut outputs : TEXCOORD2; + float4 gl_Position : SV_Position; + float gl_ClipDistance[1] : SV_ClipDistance; + float2 gl_CullDistance : SV_CullDistance; +}; + +struct gl_MeshPerPrimitiveEXT +{ +}; + +groupshared float shared_float[16]; + +float4 spvFlipVertY(float4 v) +{ + return float4(v.x, -v.y, v.z, v.w); +} + +float spvFlipVertY(float v) +{ + return -v; +} + +void mesh_main(inout gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], inout uint3 gl_PrimitiveTriangleIndicesEXT[22]) +{ + SetMeshOutputCounts(24u, 22u); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = spvFlipVertY(float4(float3(gl_GlobalInvocationID), 1.0f)); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = spvFlipVertY(float3(gl_WorkGroupID).x); + float3 _46 = float3(gl_GlobalInvocationID); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _46.x; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _46.y; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _46.z; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position[gl_LocalInvocationIndex % 4u] = float(gl_GlobalInvocationID.z); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position[spec_const_index] = spvFlipVertY(float(gl_GlobalInvocationID.z)); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0] = 4.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[0] = 3.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[1] = 5.0f; + GroupMemoryBarrierWithGroupSync(); + if (gl_LocalInvocationIndex < 22u) + { + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uint3(0u, 1u, 2u) + gl_LocalInvocationIndex.xxx; + } +} + +[outputtopology("triangle")] +[numthreads(2, 3, 4)] +void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out indices uint3 gl_PrimitiveTriangleIndicesEXT[22]) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + mesh_main(gl_MeshVerticesEXT, gl_PrimitiveTriangleIndicesEXT); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp index b8265fc99e..9e3b90fa6d 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp @@ -1,15 +1,15 @@ -RWByteAddressBuffer _4 : register(u0); +RWByteAddressBuffer _6 : register(u0); void comp_main() { - uint _21 = _4.Load(_4.Load(0) * 4 + 4); - for (uint _23 = 0u; _23 < 64u; ) + uint _21 = _6.Load(_6.Load(0) * 4 + 4); + for (uint _40 = 0u; _40 < 64u; ) { - _4.Store(_23 * 4 + 4, 0u); - _23++; + _6.Store(_40 * 4 + 4, 0u); + _40++; continue; } - _4.Store(_4.Load(0) * 4 + 4, _21); + _6.Store(_6.Load(0) * 4 + 4, _21); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-decrement.asm.comp index 919fe9bab5..97af5ba0e3 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-decrement.asm.comp @@ -9,10 +9,10 @@ struct SPIRV_Cross_Input void comp_main() { - uint _29; - u0_counter.InterlockedAdd(0, -1, _29); + uint _24; + u0_counter.InterlockedAdd(0, -1, _24); float4 r0; - r0.x = asfloat(_29); + r0.x = asfloat(_24); u0[(uint(asint(r0.x)) * 1u) + (uint(0) >> 2u)] = uint(int(gl_GlobalInvocationID.x)).x; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-increment.asm.comp index 35960b0a69..6b9646ed04 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/atomic-increment.asm.comp @@ -9,10 +9,10 @@ struct SPIRV_Cross_Input void comp_main() { - uint _29; - u0_counter.InterlockedAdd(0, 1, _29); + uint _24; + u0_counter.InterlockedAdd(0, 1, _24); float4 r0; - r0.x = asfloat(_29); + r0.x = asfloat(_24); u0[(uint(asint(r0.x)) * 1u) + (uint(0) >> 2u)] = uint(int(gl_GlobalInvocationID.x)).x; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag index 3d5d6288f8..dad443699d 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/cbuffer-stripped.asm.frag @@ -1,32 +1,32 @@ -cbuffer _4_5 : register(b0) +cbuffer _6_7 : register(b0) { - column_major float2x4 _5_m0 : packoffset(c0); - float4 _5_m1 : packoffset(c4); + column_major float2x4 _7_m0 : packoffset(c0); + float4 _7_m1 : packoffset(c4); }; -static float2 _3; +static float2 _4; struct SPIRV_Cross_Output { - float2 _3 : SV_Target0; + float2 _4 : SV_Target0; }; -float2 _23() +float2 _29() { - float2 _25 = mul(_5_m0, _5_m1); - return _25; + float2 _30 = mul(_7_m0, _7_m1); + return _30; } void frag_main() { - _3 = _23(); + _4 = _29(); } SPIRV_Cross_Output main() { frag_main(); SPIRV_Cross_Output stage_output; - stage_output._3 = _3; + stage_output._4 = _4; return stage_output; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/empty-struct.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/empty-struct.asm.frag index 38d12cd630..92b823c17f 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/empty-struct.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/empty-struct.asm.frag @@ -15,10 +15,10 @@ float GetValue_1(EmptyStructTest self) void frag_main() { - EmptyStructTest _23 = { 0 }; + EmptyStructTest _24 = { 0 }; EmptyStructTest emptyStruct; float value = GetValue(emptyStruct); - value = GetValue_1(_23); + value = GetValue_1(_24); } void main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag index 2527d10fdc..0f858d2175 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag @@ -17,9 +17,9 @@ uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) void frag_main() { + uint _18_dummy_parameter; uint _19_dummy_parameter; - uint _20_dummy_parameter; - Size = int2(spvTextureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _20_dummy_parameter)); + Size = int2(spvTextureSize(uTexture, uint(0), _18_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _19_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag index f668d63440..3e87d2549c 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag @@ -18,20 +18,20 @@ void frag_main() { int i = 0; float phi; - float4 _36; + float4 _45; phi = 1.0f; - _36 = float4(1.0f, 2.0f, 1.0f, 2.0f); + _45 = float4(1.0f, 2.0f, 1.0f, 2.0f); for (;;) { - FragColor = _36; + FragColor = _45; if (i < 4) { if (v0[i] > 0.0f) { - float2 _48 = phi.xx; + float2 _43 = phi.xx; i++; phi += 2.0f; - _36 = uImage.SampleLevel(_uImage_sampler, _48, 0.0f); + _45 = uImage.SampleLevel(_uImage_sampler, _43, 0.0f); continue; } else diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag index a7aec01bad..ee01ba28c9 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/lut-promotion-initializer.asm.frag @@ -1,6 +1,6 @@ -static const float _46[16] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f }; -static const float4 _76[4] = { 0.0f.xxxx, 1.0f.xxxx, 8.0f.xxxx, 5.0f.xxxx }; -static const float4 _90[4] = { 20.0f.xxxx, 30.0f.xxxx, 50.0f.xxxx, 60.0f.xxxx }; +static const float _16[16] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f }; +static const float4 _60[4] = { 0.0f.xxxx, 1.0f.xxxx, 8.0f.xxxx, 5.0f.xxxx }; +static const float4 _104[4] = { 20.0f.xxxx, 30.0f.xxxx, 50.0f.xxxx, 60.0f.xxxx }; static float FragColor; static int index; @@ -17,31 +17,31 @@ struct SPIRV_Cross_Output void frag_main() { - float4 foobar[4] = _76; - float4 baz[4] = _76; - FragColor = _46[index]; + float4 foobar[4] = _60; + float4 baz[4] = _60; + FragColor = _16[index]; if (index < 10) { - FragColor += _46[index ^ 1]; + FragColor += _16[index ^ 1]; } else { - FragColor += _46[index & 1]; + FragColor += _16[index & 1]; } if (index > 30) { - FragColor += _76[index & 3].y; + FragColor += _60[index & 3].y; } else { - FragColor += _76[index & 1].x; + FragColor += _60[index & 1].x; } if (index > 30) { foobar[1].z = 20.0f; } FragColor += foobar[index & 3].z; - baz = _90; + baz = _104; FragColor += baz[index & 3].z; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag index 5eb70adf81..2070215de1 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/unreachable.asm.frag @@ -1,4 +1,4 @@ -static float4 _21; +static float4 _44; static int counter; static float4 FragColor; @@ -15,23 +15,23 @@ struct SPIRV_Cross_Output void frag_main() { - float4 _24; - _24 = _21; - float4 _33; + float4 _45; + _45 = _44; + float4 _46; for (;;) { if (counter == 10) { - _33 = 10.0f.xxxx; + _46 = 10.0f.xxxx; break; } else { - _33 = 30.0f.xxxx; + _46 = 30.0f.xxxx; break; } } - FragColor = _33; + FragColor = _46; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert b/third_party/spirv-cross/reference/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert index 2a332551f3..10fae807b7 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/vert/spec-constant-op-composite.asm.vert @@ -1,40 +1,40 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_201 #define SPIRV_CROSS_CONSTANT_ID_201 -10 #endif -static const int _7 = SPIRV_CROSS_CONSTANT_ID_201; -static const int _20 = (_7 + 2); +static const int _13 = SPIRV_CROSS_CONSTANT_ID_201; +static const int _15 = (_13 + 2); #ifndef SPIRV_CROSS_CONSTANT_ID_202 #define SPIRV_CROSS_CONSTANT_ID_202 100u #endif -static const uint _8 = SPIRV_CROSS_CONSTANT_ID_202; -static const uint _25 = (_8 % 5u); -static const int4 _30 = int4(20, 30, _20, _20); -static const int2 _32 = int2(_30.y, _30.x); -static const int _33 = _30.y; +static const uint _24 = SPIRV_CROSS_CONSTANT_ID_202; +static const uint _26 = (_24 % 5u); +static const int4 _36 = int4(20, 30, _15, _15); +static const int2 _41 = int2(_36.y, _36.x); +static const int _60 = _36.y; #ifndef SPIRV_CROSS_CONSTANT_ID_200 #define SPIRV_CROSS_CONSTANT_ID_200 3.141590118408203125f #endif -static const float _9 = SPIRV_CROSS_CONSTANT_ID_200; +static const float _57 = SPIRV_CROSS_CONSTANT_ID_200; static float4 gl_Position; -static int _4; +static int _58; struct SPIRV_Cross_Output { - nointerpolation int _4 : TEXCOORD0; + nointerpolation int _58 : TEXCOORD0; float4 gl_Position : SV_Position; }; void vert_main() { float4 pos = 0.0f.xxxx; - pos.y += float(_20); - pos.z += float(_25); - pos += float4(_30); - float2 _56 = pos.xy + float2(_32); - pos = float4(_56.x, _56.y, pos.z, pos.w); + pos.y += float(_15); + pos.z += float(_26); + pos += float4(_36); + float2 _46 = pos.xy + float2(_41); + pos = float4(_46.x, _46.y, pos.z, pos.w); gl_Position = pos; - _4 = _33; + _58 = _60; } SPIRV_Cross_Output main() @@ -42,6 +42,6 @@ SPIRV_Cross_Output main() vert_main(); SPIRV_Cross_Output stage_output; stage_output.gl_Position = gl_Position; - stage_output._4 = _4; + stage_output._58 = _58; return stage_output; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp new file mode 100644 index 0000000000..d078a38066 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp @@ -0,0 +1,22 @@ +struct Data +{ + uint arr[3]; +}; + +RWByteAddressBuffer _13 : register(u0); + +void comp_main() +{ + Data d1; + [unroll] + for (int _0ident = 0; _0ident < 3; _0ident++) + { + _13.Store(_0ident * 4 + 0, d1.arr[_0ident]); + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in-and-out.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in-and-out.frag index 185a09821e..e2238828b2 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in-and-out.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in-and-out.frag @@ -1,5 +1,5 @@ -static int gl_SampleMaskIn; -static int gl_SampleMask; +static int gl_SampleMaskIn[1]; +static int gl_SampleMask[1]; static float4 FragColor; struct SPIRV_Cross_Input @@ -16,15 +16,15 @@ struct SPIRV_Cross_Output void frag_main() { FragColor = 1.0f.xxxx; - gl_SampleMask = gl_SampleMaskIn; + gl_SampleMask[0] = gl_SampleMaskIn[0]; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { - gl_SampleMaskIn = stage_input.gl_SampleMaskIn; + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; frag_main(); SPIRV_Cross_Output stage_output; - stage_output.gl_SampleMask = gl_SampleMask; + stage_output.gl_SampleMask = gl_SampleMask[0]; stage_output.FragColor = FragColor; return stage_output; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in.frag index 8f6cfaf9e5..dfbe29b9c6 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-in.frag @@ -1,5 +1,5 @@ static int gl_SampleID; -static int gl_SampleMaskIn; +static int gl_SampleMaskIn[1]; static float4 FragColor; struct SPIRV_Cross_Input @@ -15,7 +15,7 @@ struct SPIRV_Cross_Output void frag_main() { - if ((gl_SampleMaskIn & (1 << gl_SampleID)) != 0) + if ((gl_SampleMaskIn[0] & (1 << gl_SampleID)) != 0) { FragColor = 1.0f.xxxx; } @@ -24,7 +24,7 @@ void frag_main() SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { gl_SampleID = stage_input.gl_SampleID; - gl_SampleMaskIn = stage_input.gl_SampleMaskIn; + gl_SampleMaskIn[0] = stage_input.gl_SampleMaskIn; frag_main(); SPIRV_Cross_Output stage_output; stage_output.FragColor = FragColor; diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-out.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-out.frag index a966c03218..14de570dfc 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-out.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/sample-mask-out.frag @@ -1,4 +1,4 @@ -static int gl_SampleMask; +static int gl_SampleMask[1]; static float4 FragColor; struct SPIRV_Cross_Output @@ -10,14 +10,14 @@ struct SPIRV_Cross_Output void frag_main() { FragColor = 1.0f.xxxx; - gl_SampleMask = 0; + gl_SampleMask[0] = 0; } SPIRV_Cross_Output main() { frag_main(); SPIRV_Cross_Output stage_output; - stage_output.gl_SampleMask = gl_SampleMask; + stage_output.gl_SampleMask = gl_SampleMask[0]; stage_output.FragColor = FragColor; return stage_output; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp index d24b9666fa..4151832e84 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp @@ -29,10 +29,10 @@ struct SSBO2 T_2 bar[1]; }; -kernel void main0(device SSBO1& _7 [[buffer(0)]], device SSBO2& _10 [[buffer(1)]]) +kernel void main0(device SSBO1& _9 [[buffer(0)]], device SSBO2& _13 [[buffer(1)]]) { T v = T{ 40.0 }; - _7.foo[10].b = v.a; - _10.bar[30].c = v.a; + _9.foo[10].b = v.a; + _13.bar[30].c = v.a; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/arithmetic-conversion-signs.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/arithmetic-conversion-signs.asm.comp index c3f9f5e14e..c4c9b8bb69 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/arithmetic-conversion-signs.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/arithmetic-conversion-signs.asm.comp @@ -12,31 +12,31 @@ struct SSBO float f32; }; -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - int _29 = _4.s32; - uint _30 = _4.u32; - short _31 = _4.s16; - ushort _32 = _4.u16; - float _33 = _4.f32; - _4.s32 = int(_31); - _4.u32 = uint(_31); - _4.s32 = int(short(_32)); - _4.u32 = uint(short(_32)); - _4.u32 = uint(ushort(_31)); - _4.u32 = uint(_32); - _4.s16 = short(_29); - _4.u16 = ushort(_29); - _4.s16 = short(_30); - _4.u16 = ushort(_30); - _4.u16 = ushort(_29); - _4.u16 = ushort(_30); - _4.f32 = float(_31); - _4.f32 = float(short(_32)); - _4.f32 = float(ushort(_31)); - _4.f32 = float(_32); - _4.s16 = short(_33); - _4.u16 = ushort(short(_33)); - _4.u16 = ushort(_33); + int _29 = _6.s32; + uint _30 = _6.u32; + short _31 = _6.s16; + ushort _32 = _6.u16; + float _33 = _6.f32; + _6.s32 = int(_31); + _6.u32 = uint(_31); + _6.s32 = int(short(_32)); + _6.u32 = uint(short(_32)); + _6.u32 = uint(ushort(_31)); + _6.u32 = uint(_32); + _6.s16 = short(_29); + _6.u16 = ushort(_29); + _6.s16 = short(_30); + _6.u16 = ushort(_30); + _6.u16 = ushort(_29); + _6.u16 = ushort(_30); + _6.f32 = float(_31); + _6.f32 = float(short(_32)); + _6.f32 = float(ushort(_31)); + _6.f32 = float(_32); + _6.s16 = short(_33); + _6.u16 = ushort(short(_33)); + _6.u16 = ushort(_33); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-load-store.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-load-store.asm.comp index 1015d2a5ee..51aefcc8e5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-load-store.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-load-store.asm.comp @@ -14,10 +14,10 @@ struct SSBO constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); -kernel void main0(device SSBO& _5 [[buffer(0)]]) +kernel void main0(device SSBO& _7 [[buffer(0)]]) { - uint _20 = atomic_load_explicit((device atomic_uint*)&_5.b, memory_order_relaxed); - uint c = _20; - atomic_store_explicit((device atomic_uint*)&_5.a, c, memory_order_relaxed); + uint _16 = atomic_load_explicit((device atomic_uint*)&_7.b, memory_order_relaxed); + uint c = _16; + atomic_store_explicit((device atomic_uint*)&_7.a, c, memory_order_relaxed); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-min-max-sign.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-min-max-sign.asm.comp index 3fdf46bbc5..e1ce0b8696 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-min-max-sign.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-min-max-sign.asm.comp @@ -14,15 +14,15 @@ struct SSBO constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - uint _26 = atomic_fetch_max_explicit((device atomic_uint*)&_4.a, 1u, memory_order_relaxed); - uint _27 = uint(atomic_fetch_min_explicit((device atomic_int*)&_4.a, int(1u), memory_order_relaxed)); - uint _28 = atomic_fetch_min_explicit((device atomic_uint*)&_4.a, 4294967295u, memory_order_relaxed); - uint _29 = uint(atomic_fetch_max_explicit((device atomic_int*)&_4.a, int(4294967295u), memory_order_relaxed)); - int _30 = atomic_fetch_max_explicit((device atomic_int*)&_4.b, -3, memory_order_relaxed); - int _31 = int(atomic_fetch_min_explicit((device atomic_uint*)&_4.b, uint(-3), memory_order_relaxed)); - int _32 = atomic_fetch_min_explicit((device atomic_int*)&_4.b, 4, memory_order_relaxed); - int _33 = int(atomic_fetch_max_explicit((device atomic_uint*)&_4.b, uint(4), memory_order_relaxed)); + uint _30 = atomic_fetch_max_explicit((device atomic_uint*)&_6.a, 1u, memory_order_relaxed); + uint _31 = uint(atomic_fetch_min_explicit((device atomic_int*)&_6.a, int(1u), memory_order_relaxed)); + uint _32 = atomic_fetch_min_explicit((device atomic_uint*)&_6.a, 4294967295u, memory_order_relaxed); + uint _33 = uint(atomic_fetch_max_explicit((device atomic_int*)&_6.a, int(4294967295u), memory_order_relaxed)); + int _34 = atomic_fetch_max_explicit((device atomic_int*)&_6.b, -3, memory_order_relaxed); + int _35 = int(atomic_fetch_min_explicit((device atomic_uint*)&_6.b, uint(-3), memory_order_relaxed)); + int _36 = atomic_fetch_min_explicit((device atomic_int*)&_6.b, 4, memory_order_relaxed); + int _37 = int(atomic_fetch_max_explicit((device atomic_uint*)&_6.b, uint(4), memory_order_relaxed)); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-result-temporary.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-result-temporary.asm.comp index 4624ef0b7c..2ac0626e38 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-result-temporary.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/atomic-result-temporary.asm.comp @@ -12,12 +12,12 @@ struct SSBO uint data[1]; }; -kernel void main0(device SSBO& _5 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO& _7 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - uint _24 = atomic_fetch_add_explicit((device atomic_uint*)&_5.count, 1u, memory_order_relaxed); - if (_24 < 1024u) + uint _19 = atomic_fetch_add_explicit((device atomic_uint*)&_7.count, 1u, memory_order_relaxed); + if (_19 < 1024u) { - _5.data[_24] = gl_GlobalInvocationID.x; + _7.data[_19] = gl_GlobalInvocationID.x; } } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitcast-fp16-fp32.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitcast-fp16-fp32.asm.comp index 0d63f5fa75..2a692f63c5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitcast-fp16-fp32.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitcast-fp16-fp32.asm.comp @@ -13,9 +13,9 @@ struct SSBO constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - _4.b = as_type(_4.a); - _4.d = as_type(_4.c); + _6.b = as_type(_6.a); + _6.d = as_type(_6.c); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitfield-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitfield-signed-operations.asm.comp index 8e198a94df..cbf0b5134e 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitfield-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitfield-signed-operations.asm.comp @@ -9,21 +9,21 @@ struct SSBO uint4 uints; }; -kernel void main0(device SSBO& _3 [[buffer(0)]]) +kernel void main0(device SSBO& _4 [[buffer(0)]]) { - int4 _19 = _3.ints; - uint4 _20 = _3.uints; - _3.ints = popcount(_19); - _3.uints = uint4(popcount(_19)); - _3.ints = int4(popcount(_20)); - _3.uints = popcount(_20); - _3.ints = reverse_bits(_19); - _3.uints = reverse_bits(_20); - _3.ints = extract_bits(_19, uint(1), 11u); - _3.uints = uint4(extract_bits(int4(_20), 11u, uint(1))); - _3.ints = int4(extract_bits(uint4(_19), uint(1), 11u)); - _3.uints = extract_bits(_20, 11u, uint(1)); - _3.ints = insert_bits(_19, _19.wzyx, uint(1), 11u); - _3.uints = insert_bits(_20, _20.wzyx, 11u, uint(1)); + int4 _19 = _4.ints; + uint4 _20 = _4.uints; + _4.ints = popcount(_19); + _4.uints = uint4(popcount(_19)); + _4.ints = int4(popcount(_20)); + _4.uints = popcount(_20); + _4.ints = reverse_bits(_19); + _4.uints = reverse_bits(_20); + _4.ints = extract_bits(_19, uint(1), 11u); + _4.uints = uint4(extract_bits(int4(_20), 11u, uint(1))); + _4.ints = int4(extract_bits(uint4(_19), uint(1), 11u)); + _4.uints = extract_bits(_20, 11u, uint(1)); + _4.ints = insert_bits(_19, _19.wzyx, uint(1), 11u); + _4.uints = insert_bits(_20, _20.wzyx, 11u, uint(1)); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitscan.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitscan.asm.comp index 1be65ec7cd..1eaa940d4d 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitscan.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bitscan.asm.comp @@ -33,21 +33,21 @@ struct SSBO int4 i; }; -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - uint4 _19 = _4.u; - int4 _20 = _4.i; - _4.u = spvFindLSB(_19); - _4.i = int4(spvFindLSB(_19)); - _4.u = uint4(spvFindLSB(_20)); - _4.i = spvFindLSB(_20); - _4.u = spvFindUMSB(_19); - _4.i = int4(spvFindUMSB(_19)); - _4.u = spvFindUMSB(uint4(_20)); - _4.i = int4(spvFindUMSB(uint4(_20))); - _4.u = uint4(spvFindSMSB(int4(_19))); - _4.i = spvFindSMSB(int4(_19)); - _4.u = uint4(spvFindSMSB(_20)); - _4.i = spvFindSMSB(_20); + uint4 _19 = _6.u; + int4 _20 = _6.i; + _6.u = spvFindLSB(_19); + _6.i = int4(spvFindLSB(_19)); + _6.u = uint4(spvFindLSB(_20)); + _6.i = spvFindLSB(_20); + _6.u = spvFindUMSB(_19); + _6.i = int4(spvFindUMSB(_19)); + _6.u = spvFindUMSB(uint4(_20)); + _6.i = int4(spvFindUMSB(uint4(_20))); + _6.u = uint4(spvFindSMSB(int4(_19))); + _6.i = spvFindSMSB(int4(_19)); + _6.u = uint4(spvFindSMSB(_20)); + _6.i = spvFindSMSB(_20); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/block-like-array-type-construct.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/block-like-array-type-construct.asm.comp index f3f73fbd98..8c886bb669 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/block-like-array-type-construct.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/block-like-array-type-construct.asm.comp @@ -44,7 +44,7 @@ struct spvUnsafeArray } }; -struct _10 +struct _12 { float _m0[4]; float _m1[4]; @@ -58,19 +58,19 @@ struct SSBO int b; }; -constant spvUnsafeArray _31 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); +constant spvUnsafeArray _36 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); kernel void main0() { - spvUnsafeArray<_10, 2> _34 = spvUnsafeArray<_10, 2>({ _10{ { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 } }, _10{ { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 } } }); + spvUnsafeArray<_12, 2> _39 = spvUnsafeArray<_12, 2>({ _12{ { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 } }, _12{ { 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 } } }); spvUnsafeArray foo; foo[0] = 1.0; - foo = _31; + foo = _36; foo[1] = 2.0; foo[2] = 3.0; foo[3] = 4.0; spvUnsafeArray foo2 = foo; - _10 _37 = _10{ { foo[0], foo[1], foo[2], foo[3] }, { foo2[0], foo2[1], foo2[2], foo2[3] } }; + _12 _41 = _12{ { foo[0], foo[1], foo[2], foo[3] }, { foo2[0], foo2[1], foo2[2], foo2[3] } }; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp index 2fe09814bf..8bbcb76f7d 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct Block { uint2 _m0[2]; @@ -16,7 +57,7 @@ struct SSBO kernel void main0(device SSBO& ssbo [[buffer(0)]]) { - threadgroup uint2 _18[2]; + threadgroup spvUnsafeArray _18; ssbo._m0[0u] = Block{ { ssbo._m0[0u]._m1[0], ssbo._m0[0u]._m1[1] }, { ssbo._m0[0u]._m1[0], ssbo._m0[0u]._m1[1] } }; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp index a5b6fc32ce..e9f2ba7930 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp @@ -54,8 +54,8 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 4u, 1u); constant spvUnsafeArray indexable = spvUnsafeArray({ 0, 1, 2, 3 }); constant spvUnsafeArray indexable_1 = spvUnsafeArray({ 4, 5, 6, 7 }); -kernel void main0(device SSBO& _6 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(device SSBO& _8 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - _6.values[gl_GlobalInvocationID.x] = indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y]; + _8.values[gl_GlobalInvocationID.x] = indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y]; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp index 09a31d68a8..e0f21144a4 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp @@ -3,12 +3,12 @@ using namespace metal; -struct _11 +struct _13 { float2x2 _m0; }; -struct _12 +struct _14 { float2x4 _m0; }; @@ -23,7 +23,7 @@ struct C float4 c; B2 b2; B2 b2_array[4]; - _12 _m3; + _14 _m3; }; struct B1 @@ -36,25 +36,25 @@ struct A float4 a; B1 b1; B1 b1_array[4]; - _11 _m3; + _13 _m3; }; -struct _8 +struct _10 { A a_block; C c_block; }; -kernel void main0(device _8& _3 [[buffer(0)]]) +kernel void main0(device _10& _4 [[buffer(0)]]) { - A _31; - _31.a = _3.c_block.c; - _31.b1.elem1 = _3.c_block.b2.elem2; - _31.b1_array[0].elem1 = _3.c_block.b2_array[0].elem2; - _31.b1_array[1].elem1 = _3.c_block.b2_array[1].elem2; - _31.b1_array[2].elem1 = _3.c_block.b2_array[2].elem2; - _31.b1_array[3].elem1 = _3.c_block.b2_array[3].elem2; - _31._m3._m0 = transpose(float2x2(_3.c_block._m3._m0[0].xy, _3.c_block._m3._m0[1].xy)); - _3.a_block = _31; + A _24; + _24.a = _4.c_block.c; + _24.b1.elem1 = _4.c_block.b2.elem2; + _24.b1_array[0].elem1 = _4.c_block.b2_array[0].elem2; + _24.b1_array[1].elem1 = _4.c_block.b2_array[1].elem2; + _24.b1_array[2].elem1 = _4.c_block.b2_array[2].elem2; + _24.b1_array[3].elem1 = _4.c_block.b2_array[3].elem2; + _24._m3._m0 = transpose(float2x2(_4.c_block._m3._m0[0].xy, _4.c_block._m3._m0[1].xy)); + _4.a_block = _24; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-offset-and-array-stride-diffs.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-offset-and-array-stride-diffs.spv14.asm.comp index 54087ddc51..ac81909589 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-offset-and-array-stride-diffs.spv14.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical-offset-and-array-stride-diffs.spv14.asm.comp @@ -3,52 +3,52 @@ using namespace metal; -struct _8 +struct _9 { char _m0_pad[4]; uint _m0; }; -struct _9 +struct _10 { char _m0_pad[8]; uint _m0; }; -struct _4 +struct _5 { uint _m0; uint4 _m1[2]; uint _m2; char _m3_pad[12]; - _8 _m3; - float4 _m4; - float3 _m5; - float2 _m6; -}; - -struct _5 -{ - uint _m0; - uint _m1[2]; - uint _m2; _9 _m3; float4 _m4; float3 _m5; float2 _m6; }; -kernel void main0(device _5& _2 [[buffer(0)]], device _4& _3 [[buffer(1)]]) +struct _6 { - _4 _23; - _23._m0 = _2._m0; - (thread uint&)_23._m1[0] = _2._m1[0]; - (thread uint&)_23._m1[1] = _2._m1[1]; - _23._m2 = _2._m2; - _23._m3._m0 = _2._m3._m0; - _23._m4 = _2._m4; - _23._m5 = _2._m5; - _23._m6 = _2._m6; - _3 = _23; + uint _m0; + uint _m1[2]; + uint _m2; + _10 _m3; + float4 _m4; + float3 _m5; + float2 _m6; +}; + +kernel void main0(device _6& _3 [[buffer(0)]], device _5& _4 [[buffer(1)]]) +{ + _5 _23; + _23._m0 = _3._m0; + (thread uint&)_23._m1[0] = _3._m1[0]; + (thread uint&)_23._m1[1] = _3._m1[1]; + _23._m2 = _3._m2; + _23._m3._m0 = _3._m3._m0; + _23._m4 = _3._m4; + _23._m5 = _3._m5; + _23._m6 = _3._m6; + _4 = _23; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp index 2225981524..4d39ef50e7 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp @@ -27,21 +27,21 @@ struct A B1 b1_array[4]; }; -struct _8 +struct _10 { A a_block; C c_block; }; -kernel void main0(device _8& _3 [[buffer(0)]]) +kernel void main0(device _10& _4 [[buffer(0)]]) { - A _27; - _27.a = _3.c_block.c; - _27.b1.elem1 = _3.c_block.b2.elem2; - _27.b1_array[0].elem1 = _3.c_block.b2_array[0].elem2; - _27.b1_array[1].elem1 = _3.c_block.b2_array[1].elem2; - _27.b1_array[2].elem1 = _3.c_block.b2_array[2].elem2; - _27.b1_array[3].elem1 = _3.c_block.b2_array[3].elem2; - _3.a_block = _27; + A _24; + _24.a = _4.c_block.c; + _24.b1.elem1 = _4.c_block.b2.elem2; + _24.b1_array[0].elem1 = _4.c_block.b2_array[0].elem2; + _24.b1_array[1].elem1 = _4.c_block.b2_array[1].elem2; + _24.b1_array[2].elem1 = _4.c_block.b2_array[2].elem2; + _24.b1_array[3].elem1 = _4.c_block.b2_array[3].elem2; + _4.a_block = _24; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp index b024b5539d..839470b964 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp @@ -165,7 +165,7 @@ struct SSBO kernel void main0(device SSBO& ssbo [[buffer(0)]]) { - threadgroup uint2 _18[2]; + threadgroup spvUnsafeArray _18; spvUnsafeArray _27; spvArrayCopyFromDeviceToStack1(_27.elements, ssbo._m0[0u]._m1); spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _27.elements); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp index 3ebc0d9128..acd10d7d48 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp @@ -165,15 +165,15 @@ struct SSBO kernel void main0(device SSBO& ssbo [[buffer(0)]], constant SSBO& ubo [[buffer(1)]]) { - threadgroup uint2 _18[2]; + threadgroup spvUnsafeArray _18; spvArrayCopyFromDeviceToDevice1(ssbo._m0[0u]._m0, ssbo._m0[0u]._m1); spvArrayCopyFromConstantToDevice1(ssbo._m0[0u]._m0, ubo._m0[0u]._m1); - spvUnsafeArray _24; - spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _24.elements); - spvArrayCopyFromThreadGroupToDevice1(ssbo._m0[0u]._m0, _18); - spvArrayCopyFromDeviceToThreadGroup1(_18, ssbo._m0[0u]._m1); - spvArrayCopyFromDeviceToStack1(_24.elements, ssbo._m0[0u]._m1); - spvArrayCopyFromConstantToThreadGroup1(_18, ubo._m0[0u]._m1); - spvArrayCopyFromConstantToStack1(_24.elements, ubo._m0[0u]._m1); + spvUnsafeArray _23; + spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _23.elements); + spvArrayCopyFromThreadGroupToDevice1(ssbo._m0[0u]._m0, _18.elements); + spvArrayCopyFromDeviceToThreadGroup1(_18.elements, ssbo._m0[0u]._m1); + spvArrayCopyFromDeviceToStack1(_23.elements, ssbo._m0[0u]._m1); + spvArrayCopyFromConstantToThreadGroup1(_18.elements, ubo._m0[0u]._m1); + spvArrayCopyFromConstantToStack1(_23.elements, ubo._m0[0u]._m1); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp index 6f63d36e6d..599efb4b2c 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp @@ -129,12 +129,12 @@ kernel void main0(device SSBO& ssbo [[buffer(0)]], constant SSBO& ubo [[buffer(1 threadgroup uint2 _18[2]; spvArrayCopyFromDeviceToDevice1(ssbo._m0[0u]._m0, ssbo._m0[0u]._m1); spvArrayCopyFromConstantToDevice1(ssbo._m0[0u]._m0, ubo._m0[0u]._m1); - uint2 _24[2]; - spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _24); + uint2 _23[2]; + spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _23); spvArrayCopyFromThreadGroupToDevice1(ssbo._m0[0u]._m0, _18); spvArrayCopyFromDeviceToThreadGroup1(_18, ssbo._m0[0u]._m1); - spvArrayCopyFromDeviceToStack1(_24, ssbo._m0[0u]._m1); + spvArrayCopyFromDeviceToStack1(_23, ssbo._m0[0u]._m1); spvArrayCopyFromConstantToThreadGroup1(_18, ubo._m0[0u]._m1); - spvArrayCopyFromConstantToStack1(_24, ubo._m0[0u]._m1); + spvArrayCopyFromConstantToStack1(_23, ubo._m0[0u]._m1); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl-signed-operations.asm.comp index ab7a336327..8a5d965b44 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl-signed-operations.asm.comp @@ -33,41 +33,41 @@ struct SSBO uint4 uints; }; -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - int4 _19 = _4.ints; - uint4 _20 = _4.uints; - _4.ints = abs(_19); - _4.uints = uint4(abs(_19)); - _4.ints = abs(int4(_20)); - _4.uints = uint4(abs(int4(_20))); - _4.ints = sign(_19); - _4.uints = uint4(sign(_19)); - _4.ints = sign(int4(_20)); - _4.uints = uint4(sign(int4(_20))); - _4.ints = spvFindSMSB(int4(_20)); - _4.uints = uint4(spvFindSMSB(int4(_20))); - _4.ints = int4(spvFindUMSB(uint4(_19))); - _4.uints = spvFindUMSB(uint4(_19)); - _4.ints = min(_19, _19); - _4.uints = uint4(min(_19, int4(_20))); - _4.ints = min(int4(_20), int4(_20)); - _4.uints = uint4(min(int4(_20), _19)); - _4.ints = int4(min(uint4(_19), _20)); - _4.uints = min(uint4(_19), _20); - _4.ints = int4(min(_20, uint4(_19))); - _4.uints = min(_20, uint4(_19)); - _4.ints = max(_19, _19); - _4.uints = uint4(max(_19, _19)); - _4.ints = max(int4(_20), _19); - _4.uints = uint4(max(int4(_20), _19)); - _4.ints = int4(max(uint4(_19), _20)); - _4.uints = max(uint4(_19), uint4(_19)); - _4.ints = int4(max(_20, uint4(_19))); - _4.uints = max(_20, uint4(_19)); - _4.ints = clamp(int4(_20), int4(_20), int4(_20)); - _4.uints = uint4(clamp(int4(_20), int4(_20), int4(_20))); - _4.ints = int4(clamp(uint4(_19), uint4(_19), uint4(_19))); - _4.uints = clamp(uint4(_19), uint4(_19), uint4(_19)); + int4 _19 = _6.ints; + uint4 _20 = _6.uints; + _6.ints = abs(_19); + _6.uints = uint4(abs(_19)); + _6.ints = abs(int4(_20)); + _6.uints = uint4(abs(int4(_20))); + _6.ints = sign(_19); + _6.uints = uint4(sign(_19)); + _6.ints = sign(int4(_20)); + _6.uints = uint4(sign(int4(_20))); + _6.ints = spvFindSMSB(int4(_20)); + _6.uints = uint4(spvFindSMSB(int4(_20))); + _6.ints = int4(spvFindUMSB(uint4(_19))); + _6.uints = spvFindUMSB(uint4(_19)); + _6.ints = min(_19, _19); + _6.uints = uint4(min(_19, int4(_20))); + _6.ints = min(int4(_20), int4(_20)); + _6.uints = uint4(min(int4(_20), _19)); + _6.ints = int4(min(uint4(_19), _20)); + _6.uints = min(uint4(_19), _20); + _6.ints = int4(min(_20, uint4(_19))); + _6.uints = min(_20, uint4(_19)); + _6.ints = max(_19, _19); + _6.uints = uint4(max(_19, _19)); + _6.ints = max(int4(_20), _19); + _6.uints = uint4(max(int4(_20), _19)); + _6.ints = int4(max(uint4(_19), _20)); + _6.uints = max(uint4(_19), uint4(_19)); + _6.ints = int4(max(_20, uint4(_19))); + _6.uints = max(_20, uint4(_19)); + _6.ints = clamp(int4(_20), int4(_20), int4(_20)); + _6.uints = uint4(clamp(int4(_20), int4(_20), int4(_20))); + _6.ints = int4(clamp(uint4(_19), uint4(_19), uint4(_19))); + _6.uints = clamp(uint4(_19), uint4(_19), uint4(_19)); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp index 0063faceaa..11777d07eb 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp @@ -3,33 +3,33 @@ using namespace metal; -struct _8 +struct _9 { float _m0; float _m1; }; -struct _15 +struct _16 { float _m0; int _m1; }; -struct _3 +struct _4 { float _m0; int _m1; }; -kernel void main0(device _3& _4 [[buffer(0)]]) +kernel void main0(device _4& _6 [[buffer(0)]]) { - _8 _23; + _9 _23; _23._m0 = modf(20.0, _23._m1); - _15 _24; + _16 _24; _24._m0 = frexp(40.0, _24._m1); - _4._m0 = _23._m0; - _4._m0 = _23._m1; - _4._m0 = _24._m0; - _4._m1 = _24._m1; + _6._m0 = _23._m0; + _6._m0 = _23._m1; + _6._m0 = _24._m0; + _6._m1 = _24._m1; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp new file mode 100644 index 0000000000..59be21bfec --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Data +{ + spvUnsafeArray sourceData; +}; + +kernel void main0(texture2d g_inputTexture [[texture(0)]], texture2d g_output [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup spvUnsafeArray g_data; + uint _49; + _49 = 0u; + for (; _49 < 4u; _49++) + { + for (uint _56 = 0u; _56 < 4u; ) + { + int3 _65 = int3(gl_GlobalInvocationID) + int3(int(_56), int(_49), 0); + g_data[gl_GlobalInvocationID.x].sourceData[(_49 * 4u) + _56] = g_inputTexture.read(uint2(_65.xy), _65.z).xyz; + _56++; + continue; + } + } + spvUnsafeArray _45 = g_data[gl_GlobalInvocationID.x].sourceData; + uint _77; + _77 = 0u; + for (int _80 = 0; _80 < 16; ) + { + _77 |= uint(fast::clamp(dot(_45[_80], float3(-1.0)), 0.0, 1.0)); + _80++; + continue; + } + g_output.write(uint4(_77), uint2(gl_GlobalInvocationID.xy)); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp index 365f89f74f..e3a6b35267 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id-override.asm.comp @@ -8,18 +8,18 @@ struct SSBO float4 values[1]; }; -constant uint _10_tmp [[function_constant(1)]]; -constant uint _10 = is_function_constant_defined(_10_tmp) ? _10_tmp : 11u; -constant uint _11_tmp [[function_constant(2)]]; -constant uint _11 = is_function_constant_defined(_11_tmp) ? _11_tmp : 12u; -constant uint _4_tmp [[function_constant(3)]]; -constant uint _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 13u; -constant uint _5_tmp [[function_constant(4)]]; -constant uint _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 14u; -constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(3u, _10, _11); +constant uint _12_tmp [[function_constant(1)]]; +constant uint _12 = is_function_constant_defined(_12_tmp) ? _12_tmp : 11u; +constant uint _13_tmp [[function_constant(2)]]; +constant uint _13 = is_function_constant_defined(_13_tmp) ? _13_tmp : 12u; +constant uint _6_tmp [[function_constant(3)]]; +constant uint _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 13u; +constant uint _7_tmp [[function_constant(4)]]; +constant uint _7 = is_function_constant_defined(_7_tmp) ? _7_tmp : 14u; +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(3u, _12, _13); -kernel void main0(device SSBO& _8 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - _8.values[gl_GlobalInvocationID.x] += float4(2.0); + _10.values[gl_GlobalInvocationID.x] += float4(2.0); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp deleted file mode 100644 index 2dcff36923..0000000000 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -using namespace metal; - -struct SSBO -{ - float4 values[1]; -}; - -constant int _10_tmp [[function_constant(1)]]; -constant int _10 = is_function_constant_defined(_10_tmp) ? _10_tmp : 11; -constant int _11_tmp [[function_constant(2)]]; -constant int _11 = is_function_constant_defined(_11_tmp) ? _11_tmp : 12; -constant int _4_tmp [[function_constant(3)]]; -constant int _4 = is_function_constant_defined(_4_tmp) ? _4_tmp : 13; -constant int _5_tmp [[function_constant(4)]]; -constant int _5 = is_function_constant_defined(_5_tmp) ? _5_tmp : 14; -constant uint _29 = (uint(_4) + 3u); -constant uint3 _30 = uint3(_29, _5, 2u); - -kernel void main0(device SSBO& _8 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) -{ - _8.values[gl_GlobalInvocationID.x] = ((((_8.values[gl_GlobalInvocationID.x] + float4(2.0)) + float3(_30).xyzz) * float(_4)) * float(_5)) * float(int(2u)); -} - diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp new file mode 100644 index 0000000000..cbca58a72f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float4 values[1]; +}; + +constant int _12_tmp [[function_constant(1)]]; +constant int _12 = is_function_constant_defined(_12_tmp) ? _12_tmp : 11; +constant int _13_tmp [[function_constant(2)]]; +constant int _13 = is_function_constant_defined(_13_tmp) ? _13_tmp : 12; +constant int _6_tmp [[function_constant(3)]]; +constant int _6 = is_function_constant_defined(_6_tmp) ? _6_tmp : 13; +constant int _7_tmp [[function_constant(4)]]; +constant int _7 = is_function_constant_defined(_7_tmp) ? _7_tmp : 14; +constant uint _37 = (uint(_6) + 3u); +constant uint3 _38 = uint3(_37, _7, 2u); + +kernel void main0(device SSBO& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + _10.values[gl_GlobalInvocationID.x] = ((((_10.values[gl_GlobalInvocationID.x] + float4(2.0)) + float3(_38).xyzz) * float(_6)) * float(_7)) * float(int(2u)); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/modf-storage-class.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/modf-storage-class.asm.comp index 3c00707f2e..0f97633399 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/modf-storage-class.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/modf-storage-class.asm.comp @@ -3,42 +3,42 @@ using namespace metal; -struct _17 +struct _19 { float2 _m0; float2 _m1; }; -struct _4 +struct _6 { uint2 _m0[324]; }; -struct _7 +struct _9 { float2 _m0[648]; }; -struct _10 +struct _13 { float2 _m0[648]; }; -kernel void main0(const device _4& _5 [[buffer(0)]], device _7& _8 [[buffer(1)]], device _10& _11 [[buffer(2)]]) +kernel void main0(const device _6& _7 [[buffer(0)]], device _9& _11 [[buffer(1)]], device _13& _14 [[buffer(2)]]) { - for (uint _39 = 0u; _39 < 648u; _39 += 2u) + for (uint _46 = 0u; _46 < 648u; _46 += 2u) { - uint2 _40 = _5._m0[_39 / 2u]; - float2 _41 = as_type(_40); - float2 _76; - float2 _61 = modf(_41, _76); - _8._m0[_39] = _76; - _8._m0[_39 + 1u] = _61; - _17 _64; - _64._m0 = modf(_41, _64._m1); - _17 _42 = _64; - _11._m0[_39] = _42._m1; - _11._m0[_39 + 1u] = _42._m0; + uint2 _47 = _7._m0[_46 / 2u]; + float2 _48 = as_type(_47); + float2 _91; + float2 _69 = modf(_48, _91); + _11._m0[_46] = _91; + _11._m0[_46 + 1u] = _69; + _19 _74; + _74._m0 = modf(_48, _74._m1); + _19 _50 = _74; + _14._m0[_46] = _50._m1; + _14._m0[_46 + 1u] = _50._m0; } } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp index dda8505099..7f1494a902 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/spec-constant-name-aliasing.asm.comp @@ -28,8 +28,8 @@ constant int A_10 = (A_9 - A_5); constant int A_11 = (A_10 + A_5); constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); -kernel void main0(device SSBO& _5 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO& _7 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - _5.values[gl_GlobalInvocationID.x] = A_11; + _7.values[gl_GlobalInvocationID.x] = A_11; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp index 5b1ed8ae24..6a8538f0c7 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp @@ -3,20 +3,20 @@ using namespace metal; -struct _6 +struct _3 { float _m0[1]; }; -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 [[maybe_unused]] = uint3(_3, 2u, _4); +constant uint _15_tmp [[function_constant(0)]]; +constant uint _15 = is_function_constant_defined(_15_tmp) ? _15_tmp : 1u; +constant uint _17_tmp [[function_constant(2)]]; +constant uint _17 = is_function_constant_defined(_17_tmp) ? _17_tmp : 3u; +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_15, 2u, _17); -kernel void main0(device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +kernel void main0(device _3& _20 [[buffer(0)]], device _3& _21 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) { - uint3 _23 = gl_WorkGroupSize; - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; + uint3 _19 = gl_WorkGroupSize; + _20._m0[gl_WorkGroupID.x] = _21._m0[gl_WorkGroupID.x] + _20._m0[gl_WorkGroupID.x]; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-pointer-argument.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-pointer-argument.asm.comp index 6e9768540b..beab3e7b68 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-pointer-argument.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/storage-buffer-pointer-argument.asm.comp @@ -21,8 +21,8 @@ void copy_out(device float& A, device const float& B) A = B; } -kernel void main0(device SSBO& _7 [[buffer(0)]], const device SSBORead& _9 [[buffer(1)]]) +kernel void main0(device SSBO& _10 [[buffer(0)]], const device SSBORead& _14 [[buffer(1)]]) { - copy_out(_7.a, _9.b); + copy_out(_10.a, _14.b); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp new file mode 100644 index 0000000000..da4549fa54 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp @@ -0,0 +1,59 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup spvUnsafeArray test; + float _21 = float(gl_GlobalInvocationID.x); + float2 _22 = float2(_21); + ((&((&test)[0u]))[0u])[1u + 2u] = _22; + ((&test)[0u])[1u + 2u] = _22; + ((&test)[0u])[3u] = _22; + ((threadgroup float*)&((&test)[0u])[2u])[0u + 1u] = _21; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp new file mode 100644 index 0000000000..10562f6003 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp @@ -0,0 +1,55 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup spvUnsafeArray test; + float _21 = float(gl_GlobalInvocationID.x); + (true ? &((threadgroup float*)&((&test)[0u])[2u])[0u] : &((threadgroup float*)&((&test)[0u])[2u])[0u])[1u] = _21; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp new file mode 100644 index 0000000000..cf92082bd6 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp @@ -0,0 +1,55 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + threadgroup spvUnsafeArray test; + float _21 = float(gl_GlobalInvocationID.x); + ((threadgroup float*)&(*(true ? &test[1u] : &test[2u])))[1u] = _21; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp index 7c9718d1c9..c46eee86fd 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct foo { int a[128]; @@ -35,34 +74,34 @@ device int* select_buffer_null(device foo& buf, constant bar& cb) } static inline __attribute__((always_inline)) -threadgroup int* select_tgsm(constant bar& cb, threadgroup int (&tgsm)[128]) +threadgroup int* select_tgsm(constant bar& cb, threadgroup spvUnsafeArray& tgsm) { return (cb.d != 0) ? &tgsm[0u] : nullptr; } kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], device baz& buf2 [[buffer(2)]]) { - threadgroup int tgsm[128]; + threadgroup spvUnsafeArray tgsm; device int* sbuf = select_buffer(buf, buf2, cb); device int* sbuf2 = select_buffer_null(buf, cb); threadgroup int* stgsm = select_tgsm(cb, tgsm); threadgroup int* cur = stgsm; - device int* _73; - _73 = &buf.a[0u]; - threadgroup int* _76; - int _77; + device int* _78; + _78 = &buf.a[0u]; + threadgroup int* _81; + int _82; for (;;) { - _76 = cur; - _77 = *_73; - if (_77 != 0) + _81 = cur; + _82 = *_78; + if (_82 != 0) { - int _81 = *_76; - int _82 = _77 + _81; - *_73 = _82; - *_76 = _82; - cur = &_76[1u]; - _73 = &_73[1u]; + int _86 = *_81; + int _87 = _82 + _86; + *_78 = _87; + *_81 = _87; + cur = &_81[1u]; + _78 = &_78[1u]; continue; } else diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp new file mode 100644 index 0000000000..f02e27c535 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp @@ -0,0 +1,175 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant uint _15_tmp [[function_constant(0)]]; +constant uint _15 = is_function_constant_defined(_15_tmp) ? _15_tmp : 1u; +constant uint _16_tmp [[function_constant(1)]]; +constant uint _16 = is_function_constant_defined(_16_tmp) ? _16_tmp : 1u; +constant uint _17_tmp [[function_constant(2)]]; +constant uint _17 = is_function_constant_defined(_17_tmp) ? _17_tmp : 1u; +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_15, _16, _17); + +struct _6 +{ + uint4 _m0[1]; +}; + +struct _7 +{ + uint _m0; +}; + +struct _8 +{ + _7 _m0; +}; + +constant uchar4 _137 = {}; + +kernel void main0(device _6& _25 [[buffer(0)]], constant _8& _29 [[buffer(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + threadgroup spvUnsafeArray _5; + threadgroup spvUnsafeArray _10; + uint3 _20 = gl_WorkGroupSize; + bool _40 = _29._m0._m0 != 0u; + if (_40) + { + uchar _58 = uchar(((gl_LocalInvocationID.y * gl_LocalInvocationID.x) / gl_WorkGroupID.y) % 255u); + uint _66; + uint _61 = 0u; + uint _62; + for (;;) + { + _62 = _61 * _29._m0._m0; + _66 = 0u; + for (;;) + { + uint _67 = _66 + _62; + uint _68 = _66 * _61; + _5[_67] = gl_WorkGroupID.x + _68; + uint _74 = _67 << 2u; + uint _76 = _74 >> 10u; + uint _78 = _74 & 1020u; + uchar4 _80 = as_type(gl_WorkGroupID.y + _68); + ((&_10)[_76])[_78 | 1u] = _80.y; + ((&_10)[_76])[_78 | 2u] = _80.z; + ((&_10)[_76])[_78 | 3u] = _80.w; + ((&_10)[_76])[_78] = _58; + uint _93 = _66 + 1u; + if (_93 >= _29._m0._m0) + { + break; + } + else + { + _66 = _93; + } + } + uint _100 = _61 + 1u; + if (_100 >= _29._m0._m0) + { + break; + } + else + { + _61 = _100; + continue; + } + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + uint _112; + if (_40) + { + _112 = 0u; + uint _117; + uint _113; + for (;;) + { + _113 = _112 * _29._m0._m0; + _117 = 0u; + for (;;) + { + uint _118 = _117 + _113; + uint _123 = _118 << 2u; + uint _124 = _123 >> 10u; + uint _125 = _123 & 1020u; + uchar4 _138; + _138.x = ((&_10)[_124])[_125]; + _138.y = ((&_10)[_124])[_125 | 1u]; + _138.z = ((&_10)[_124])[_125 | 2u]; + _138.w = ((&_10)[_124])[_125 | 3u]; + uint _143 = _5[_118] + as_type(_138); + uint4 _144 = _25._m0[_118]; + _144.x = _143; + _144.y = _143 >> 2u; + _144.w = _143 >> 3u; + _25._m0[_118] = _144; + uint _150 = _117 + 1u; + if (_150 >= _29._m0._m0) + { + break; + } + else + { + _117 = _150; + } + } + uint _157 = _112 + 1u; + if (_157 >= _29._m0._m0) + { + break; + } + else + { + _112 = _157; + continue; + } + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/composite-insert-inheritance.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/composite-insert-inheritance.asm.frag index a4bb56283a..6c28fe9392 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/composite-insert-inheritance.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/composite-insert-inheritance.asm.frag @@ -44,9 +44,9 @@ struct spvUnsafeArray } }; -constant float4 _32 = {}; +constant float4 _33 = {}; -constant spvUnsafeArray _34 = spvUnsafeArray({ float4(0.0), float4(0.0) }); +constant spvUnsafeArray _35 = spvUnsafeArray({ float4(0.0), float4(0.0) }); struct main0_out { @@ -68,12 +68,12 @@ fragment main0_out main0(main0_in in [[stage_in]]) _38.z = 3.0; _38.w = 4.0; out.FragColor = _38; - float4 _6 = _37; - _6.x = 1.0; - _6.y = 2.0; - _6.z = 3.0; - _6.w = 4.0; - out.FragColor = _6; + float4 _8 = _37; + _8.x = 1.0; + _8.y = 2.0; + _8.z = 3.0; + _8.w = 4.0; + out.FragColor = _8; float4 _42 = _37; _42.x = 1.0; _42.y = 2.0; @@ -99,7 +99,7 @@ fragment main0_out main0(main0_in in [[stage_in]]) float4 _53 = float4(0.0); _53.x = 1.0; out.FragColor = _53; - spvUnsafeArray _54 = _34; + spvUnsafeArray _54 = _35; _54[1].z = 1.0; _54[0].w = 2.0; out.FragColor = _54[0]; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/copy-memory-block-like-thread-local.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/copy-memory-block-like-thread-local.asm.frag index faa528bc32..21a631a80c 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/copy-memory-block-like-thread-local.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/copy-memory-block-like-thread-local.asm.frag @@ -159,12 +159,12 @@ struct _3 fragment void main0() { - spvUnsafeArray _20; - _20[0u] = 0.0; - _20[1u] = 0.0; - _20[2u] = 0.0; - _20[3u] = 0.0; - _3 _19; - spvArrayCopyFromStackToStack1(_19._m0, _20.elements); + spvUnsafeArray _34; + _34[0u] = 0.0; + _34[1u] = 0.0; + _34[2u] = 0.0; + _34[3u] = 0.0; + _3 _33; + spvArrayCopyFromStackToStack1(_33._m0, _34.elements); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/modf-frexp-scalar-access-chain-output.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/modf-frexp-scalar-access-chain-output.asm.frag index 910c8fa734..4b17f53d62 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/modf-frexp-scalar-access-chain-output.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/modf-frexp-scalar-access-chain-output.asm.frag @@ -6,12 +6,12 @@ using namespace metal; fragment void main0() { float3 col; - int2 _18; + int2 _20; float _23; - float _21 = modf(0.1500000059604644775390625, _23); + float _16 = modf(0.1500000059604644775390625, _23); col.x = _23; int _24; - float _22 = frexp(0.1500000059604644775390625, _24); - _18.y = _24; + float _17 = frexp(0.1500000059604644775390625, _24); + _20.y = _24; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag index cffd0bd1af..9a506203b2 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag @@ -27,14 +27,14 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; - int _39 = {}; + int _27 = {}; if (in.vColor.x > 10.0) { - _39 = 10; + _27 = 10; } else { - _39 = 20; + _27 = 20; } out.FragColor = in.vColor; return out; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-callstack.msl2.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-callstack.msl2.asm.frag index 09c740694a..4c85b65ef0 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-callstack.msl2.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-callstack.msl2.asm.frag @@ -16,22 +16,22 @@ struct SSBO0 }; static inline __attribute__((always_inline)) -void callee2(thread float4& gl_FragCoord, device SSBO1& _7) +void callee2(thread float4& gl_FragCoord, device SSBO1& _11) { - int _31 = int(gl_FragCoord.x); - _7.values1[_31]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } static inline __attribute__((always_inline)) -void callee(thread float4& gl_FragCoord, device SSBO1& _7, device SSBO0& _9) +void callee(thread float4& gl_FragCoord, device SSBO1& _11, device SSBO0& _13) { - int _39 = int(gl_FragCoord.x); - _9.values0[_39]++; - callee2(gl_FragCoord, _7); + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; + callee2(gl_FragCoord, _11); } -fragment void main0(device SSBO1& _7 [[buffer(0), raster_order_group(0)]], device SSBO0& _9 [[buffer(1)]], float4 gl_FragCoord [[position]]) +fragment void main0(device SSBO1& _11 [[buffer(0), raster_order_group(0)]], device SSBO0& _13 [[buffer(1)]], float4 gl_FragCoord [[position]]) { - callee(gl_FragCoord, _7, _9); + callee(gl_FragCoord, _11, _13); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-control-flow.msl2.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-control-flow.msl2.asm.frag index 692e391bc8..56bdcc7a0d 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-control-flow.msl2.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-control-flow.msl2.asm.frag @@ -10,7 +10,7 @@ struct SSBO1 uint values1[1]; }; -struct _12 +struct _16 { uint _m0[1]; }; @@ -21,32 +21,32 @@ struct SSBO0 }; static inline __attribute__((always_inline)) -void callee2(thread float4& gl_FragCoord, device SSBO1& _7) +void callee2(thread float4& gl_FragCoord, device SSBO1& _11) { - int _44 = int(gl_FragCoord.x); - _7.values1[_44]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } static inline __attribute__((always_inline)) -void callee(thread float4& gl_FragCoord, device SSBO1& _7, device SSBO0& _9) +void callee(thread float4& gl_FragCoord, device SSBO1& _11, device SSBO0& _13) { - int _52 = int(gl_FragCoord.x); - _9.values0[_52]++; - callee2(gl_FragCoord, _7); + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; + callee2(gl_FragCoord, _11); if (true) { } } static inline __attribute__((always_inline)) -void _35(thread float4& gl_FragCoord, device _12& _13) +void _52(thread float4& gl_FragCoord, device _16& _17) { - _13._m0[int(gl_FragCoord.x)] = 4u; + _17._m0[int(gl_FragCoord.x)] = 4u; } -fragment void main0(device SSBO1& _7 [[buffer(0), raster_order_group(0)]], device _12& _13 [[buffer(1)]], device SSBO0& _9 [[buffer(2), raster_order_group(0)]], float4 gl_FragCoord [[position]]) +fragment void main0(device SSBO1& _11 [[buffer(0), raster_order_group(0)]], device _16& _17 [[buffer(1)]], device SSBO0& _13 [[buffer(2), raster_order_group(0)]], float4 gl_FragCoord [[position]]) { - callee(gl_FragCoord, _7, _9); - _35(gl_FragCoord, _13); + callee(gl_FragCoord, _11, _13); + _52(gl_FragCoord, _17); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-split-functions.msl2.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-split-functions.msl2.asm.frag index 659e97602b..f405a71669 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-split-functions.msl2.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/pixel-interlock-split-functions.msl2.asm.frag @@ -16,34 +16,34 @@ struct SSBO0 }; static inline __attribute__((always_inline)) -void callee2(thread float4& gl_FragCoord, device SSBO1& _7) +void callee2(thread float4& gl_FragCoord, device SSBO1& _11) { - int _37 = int(gl_FragCoord.x); - _7.values1[_37]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } static inline __attribute__((always_inline)) -void callee(thread float4& gl_FragCoord, device SSBO1& _7, device SSBO0& _9) +void callee(thread float4& gl_FragCoord, device SSBO1& _11, device SSBO0& _13) { - int _45 = int(gl_FragCoord.x); - _9.values0[_45]++; - callee2(gl_FragCoord, _7); + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; + callee2(gl_FragCoord, _11); } static inline __attribute__((always_inline)) -void _29() +void _46() { } static inline __attribute__((always_inline)) -void _31() +void _48() { } -fragment void main0(device SSBO1& _7 [[buffer(0), raster_order_group(0)]], device SSBO0& _9 [[buffer(1), raster_order_group(0)]], float4 gl_FragCoord [[position]]) +fragment void main0(device SSBO1& _11 [[buffer(0), raster_order_group(0)]], device SSBO0& _13 [[buffer(1), raster_order_group(0)]], float4 gl_FragCoord [[position]]) { - callee(gl_FragCoord, _7, _9); - _29(); - _31(); + callee(gl_FragCoord, _11, _13); + _46(); + _48(); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..083e365154 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,59 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + uint gl_SampleMask [[sample_mask]]; +}; + +fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]]) +{ + main0_out out = {}; + spvUnsafeArray copy_sample_mask = spvUnsafeArray({ uint(gl_SampleMaskIn) }); + out.gl_SampleMask = copy_sample_mask[0]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..6eb5ae7106 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,59 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + uint gl_SampleMask [[sample_mask]]; +}; + +fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]]) +{ + main0_out out = {}; + spvUnsafeArray copy_sample_mask = spvUnsafeArray({ int(gl_SampleMaskIn) }); + out.gl_SampleMask = copy_sample_mask[0]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/scalar-select.spv14.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/scalar-select.spv14.asm.frag index 7fa8233db0..bb2ede1847 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/scalar-select.spv14.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/scalar-select.spv14.asm.frag @@ -44,13 +44,13 @@ struct spvUnsafeArray } }; -struct _15 +struct _16 { float _m0; }; -constant spvUnsafeArray _29 = spvUnsafeArray({ 0.0, 1.0 }); -constant spvUnsafeArray _30 = spvUnsafeArray({ 1.0, 0.0 }); +constant spvUnsafeArray _34 = spvUnsafeArray({ 0.0, 1.0 }); +constant spvUnsafeArray _35 = spvUnsafeArray({ 1.0, 0.0 }); struct main0_out { @@ -64,8 +64,8 @@ fragment main0_out main0() out.FragColor = float4(false); out.FragColor = select(float4(0.0, 0.0, 0.0, 1.0), float4(1.0, 1.0, 0.0, 1.0), bool4(false, true, false, true)); out.FragColor = float4(bool4(false, true, false, true)); - _15 _32 = false ? (_15{ 0.0 }) : (_15{ 1.0 }); - spvUnsafeArray _33 = true ? _29 : _30; + _16 _36 = false ? (_16{ 0.0 }) : (_16{ 1.0 }); + spvUnsafeArray _37 = true ? _34 : _35; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.frag rename to third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag index e179b7e233..bd85aecd34 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag @@ -18,31 +18,31 @@ fragment main0_out main0(main0_in in [[stage_in]]) int i = 0; main0_out out = {}; int j; - int _30; - int _31; + int _33; + int _34; if (in.vIndex != 0 && in.vIndex != 1 && in.vIndex != 11 && in.vIndex != 2 && in.vIndex != 3 && in.vIndex != 4 && in.vIndex != 5) { - _30 = 2; + _33 = 2; } if (in.vIndex == 1 || in.vIndex == 11) { - _31 = 1; + _34 = 1; } switch (in.vIndex) { case 0: { - _30 = 3; + _33 = 3; } default: { - j = _30; - _31 = 0; + j = _33; + _34 = 0; } case 1: case 11: { - j = _31; + j = _34; } case 2: { diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag index 32fdc2975a..48d34df3e0 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag @@ -157,9 +157,9 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvTextureSwizzle(tex1d.sample(tex1dSamp, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl); - float4 _152 = float4(0.0, 0.0, 1.0, 1.0); - _152.z = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _152.xy / _152.z, 1.0 / _152.z), depth2dSwzl); + float4 _108 = float4(0.0, 0.0, 1.0, 1.0); + _108.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _108.xy / _108.z, 1.0 / _108.z), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSamp, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float2(0.0), level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float3(0.0), level(0.0)), tex3dSwzl); @@ -170,9 +170,9 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvTextureSwizzle(tex1d.sample(tex1dSamp, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z, level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl); - float4 _202 = float4(0.0, 0.0, 1.0, 1.0); - _202.z = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _202.xy / _202.z, 1.0 / _202.z, level(0.0)), depth2dSwzl); + float4 _161 = float4(0.0, 0.0, 1.0, 1.0); + _161.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _161.xy / _161.z, 1.0 / _161.z, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl); c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl); c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc index 3872124d5c..e8b3c33eab 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc @@ -67,11 +67,11 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); - threadgroup C c[4]; + threadgroup spvUnsafeArray c; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - c[gl_InvocationID] = _18[gl_InvocationID]; + c[gl_InvocationID] = _21[gl_InvocationID]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.p_v = float4(0.0); c[gl_InvocationID].v = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc index e576472f37..60a4757c73 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc @@ -67,12 +67,12 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup C spvStoragec[8][4]; - threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; - c[gl_GlobalInvocationID.x % 4] = _18[gl_GlobalInvocationID.x % 4]; + threadgroup spvUnsafeArray spvStoragec[8]; + threadgroup auto &c = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + c[gl_GlobalInvocationID.x % 4] = _21[gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.p_v = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc index 5c6ad2a8be..f94c910d08 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc @@ -66,11 +66,11 @@ struct main0_patchOut }; kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); threadgroup P p; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].c_v = _18[gl_InvocationID].v; + gl_out[gl_InvocationID].c_v = _21[gl_InvocationID].v; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; p = P{ float4(0.0) }; gl_out[gl_InvocationID].c_v = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc index 12295e778e..3dce9b7940 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc @@ -66,13 +66,13 @@ struct main0_patchOut }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].c_v = _18[gl_GlobalInvocationID.x % 4].v; + gl_out[gl_GlobalInvocationID.x % 4].c_v = _21[gl_GlobalInvocationID.x % 4].v; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; threadgroup P spvStoragep[8]; - threadgroup P (&p) = spvStoragep[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup auto &p = spvStoragep[(gl_GlobalInvocationID.x / 4) % 8]; p = P{ float4(0.0) }; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc index d5ff9d0bd2..10f6397ccd 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc @@ -80,16 +80,16 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); - spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _39 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].c_v = _18[gl_InvocationID].v; - gl_out[gl_InvocationID].gl_Position = _33[gl_InvocationID].gl_Position; - gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance; - gl_out_masked[gl_InvocationID] = _33[gl_InvocationID]; + gl_out[gl_InvocationID].c_v = _21[gl_InvocationID].v; + gl_out[gl_InvocationID].gl_Position = _39[gl_InvocationID].gl_Position; + gl_out[gl_InvocationID].gl_ClipDistance = _39[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _39[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _39[gl_InvocationID]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.p_v = float4(0.0); gl_out[gl_InvocationID].c_v = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc index 32fb659893..e54d26d541 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc @@ -80,17 +80,17 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); - spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _39 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].c_v = _18[gl_GlobalInvocationID.x % 4].v; - gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _33[gl_GlobalInvocationID.x % 4].gl_Position; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _33[gl_GlobalInvocationID.x % 4].gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _33[gl_GlobalInvocationID.x % 4].gl_CullDistance; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; - gl_out_masked[gl_GlobalInvocationID.x % 4] = _33[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].c_v = _21[gl_GlobalInvocationID.x % 4].v; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _39[gl_GlobalInvocationID.x % 4].gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _39[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _39[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _39[gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.p_v = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc index ce16f37975..2140430ad5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc @@ -80,16 +80,16 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); - spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _39 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].c_v = _18[gl_InvocationID].v; - gl_out[gl_InvocationID].gl_PointSize = _33[gl_InvocationID].gl_PointSize; - gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance; - gl_out_masked[gl_InvocationID] = _33[gl_InvocationID]; + gl_out[gl_InvocationID].c_v = _21[gl_InvocationID].v; + gl_out[gl_InvocationID].gl_PointSize = _39[gl_InvocationID].gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _39[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _39[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _39[gl_InvocationID]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.p_v = float4(0.0); gl_out[gl_InvocationID].c_v = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc index 671aa25a02..02a4904acd 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc @@ -80,17 +80,17 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); - spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _21 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _39 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].c_v = _18[gl_GlobalInvocationID.x % 4].v; - gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _33[gl_GlobalInvocationID.x % 4].gl_PointSize; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _33[gl_GlobalInvocationID.x % 4].gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _33[gl_GlobalInvocationID.x % 4].gl_CullDistance; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; - gl_out_masked[gl_GlobalInvocationID.x % 4] = _33[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].c_v = _21[gl_GlobalInvocationID.x % 4].v; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _39[gl_GlobalInvocationID.x % 4].gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _39[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _39[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _39[gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.p_v = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc index 25fe13bf67..d7c92672dd 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc @@ -52,7 +52,7 @@ struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,15 +71,15 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _32 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); - threadgroup float4 foo[4]; + threadgroup spvUnsafeArray foo; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - foo[gl_InvocationID] = _15[gl_InvocationID]; - gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; - gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + foo[gl_InvocationID] = _17[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.foo_patch = float4(0.0); foo[gl_InvocationID] = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc index 750ef96d17..0b42f02a1f 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc @@ -52,7 +52,7 @@ struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,16 +71,16 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _32 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup float4 spvStoragefoo[8][4]; - threadgroup float4 (&foo)[4] = spvStoragefoo[(gl_GlobalInvocationID.x / 4) % 8]; - foo[gl_GlobalInvocationID.x % 4] = _15[gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; - gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + threadgroup spvUnsafeArray spvStoragefoo[8]; + threadgroup auto &foo = spvStoragefoo[(gl_GlobalInvocationID.x / 4) % 8]; + foo[gl_GlobalInvocationID.x % 4] = _17[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.foo_patch = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc index e8f1146b42..b55bf7c6c3 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc @@ -52,7 +52,7 @@ struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -70,15 +70,15 @@ struct main0_patchOut }; kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _32 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); threadgroup float4 foo_patch; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; - gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; - gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + gl_out[gl_InvocationID].foo = _17[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _32[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; foo_patch = float4(0.0); gl_out[gl_InvocationID].foo = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc index a7c1e5d617..cec57b4a26 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc @@ -52,7 +52,7 @@ struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -70,17 +70,17 @@ struct main0_patchOut }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _32 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; - gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + gl_out[gl_GlobalInvocationID.x % 4].foo = _17[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _32[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; threadgroup float4 spvStoragefoo_patch[8]; - threadgroup float4 (&foo_patch) = spvStoragefoo_patch[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup auto &foo_patch = spvStoragefoo_patch[(gl_GlobalInvocationID.x / 4) % 8]; foo_patch = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc index 344751b04c..67c87c973c 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc @@ -52,7 +52,7 @@ struct gl_PerVertex spvUnsafeArray gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,15 +71,15 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _32 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; - gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID].gl_Position; - gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance; - gl_out_masked[gl_InvocationID] = _29[gl_InvocationID]; + gl_out[gl_InvocationID].foo = _17[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _32[gl_InvocationID].gl_Position; + gl_out[gl_InvocationID].gl_ClipDistance = _32[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _32[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _32[gl_InvocationID]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.foo_patch = float4(0.0); gl_out[gl_InvocationID].foo = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc index 92731ec03a..3bdc473dd2 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc @@ -52,7 +52,7 @@ struct gl_PerVertex spvUnsafeArray gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,16 +71,16 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _32 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4].gl_Position; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4].gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4].gl_CullDistance; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; - gl_out_masked[gl_GlobalInvocationID.x % 4] = _29[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].foo = _17[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _32[gl_GlobalInvocationID.x % 4].gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _32[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _32[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _32[gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.foo_patch = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc index 2f11636a0c..33d4ce5f96 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc @@ -52,7 +52,7 @@ struct gl_PerVertex spvUnsafeArray gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,15 +71,15 @@ struct main0_patchOut kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _32 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; - gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID].gl_PointSize; - gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance; - gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance; - gl_out_masked[gl_InvocationID] = _29[gl_InvocationID]; + gl_out[gl_InvocationID].foo = _17[gl_InvocationID]; + gl_out[gl_InvocationID].gl_PointSize = _32[gl_InvocationID].gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _32[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _32[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _32[gl_InvocationID]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; patchOut.foo_patch = float4(0.0); gl_out[gl_InvocationID].foo = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc index 7283eddb1f..d0f5695ec6 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc @@ -52,7 +52,7 @@ struct gl_PerVertex spvUnsafeArray gl_CullDistance; }; -constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _17 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); @@ -71,16 +71,16 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + spvUnsafeArray _32 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; - gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4].gl_PointSize; - gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4].gl_ClipDistance; - gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4].gl_CullDistance; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; - gl_out_masked[gl_GlobalInvocationID.x % 4] = _29[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].foo = _17[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _32[gl_GlobalInvocationID.x % 4].gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _32[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _32[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _32[gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; patchOut.foo_patch = float4(0.0); uint gl_InvocationID = gl_GlobalInvocationID.x % 4; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/composite-extract-row-major.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/composite-extract-row-major.asm.comp index d2c368b8ed..7787da89a8 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/composite-extract-row-major.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/composite-extract-row-major.asm.comp @@ -9,8 +9,8 @@ struct SSBORow float4x4 row_major0; }; -kernel void main0(device SSBORow& _4 [[buffer(0)]]) +kernel void main0(device SSBORow& _6 [[buffer(0)]]) { - _4.v = _4.row_major0[2][1]; + _6.v = _6.row_major0[2][1]; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-2.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-2.asm.comp index 0ae12f0858..6aad2ed00c 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-2.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-2.asm.comp @@ -10,10 +10,10 @@ struct SSBOScalar float3x3 c; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float3x3 _20 = transpose(_4.b); - _4.b = _4.c; - _4.a = _20 * _4.a; + float3x3 _24 = transpose(_6.b); + _6.b = _6.c; + _6.a = _24 * _6.a; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-3.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-3.asm.comp index 86bdd45279..76751d5ba9 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-3.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-3.asm.comp @@ -10,11 +10,11 @@ struct SSBOScalar packed_float3 c; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float3 _17 = float3(_4.b); - float3 _19 = float3(_4.c); - _4.c = _17; - _4.a = _17 * _19; + float3 _16 = float3(_6.b); + float3 _19 = float3(_6.c); + _6.c = _16; + _6.a = _16 * _19; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-4.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-4.asm.comp index 669420436b..229ab2b681 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-4.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-4.asm.comp @@ -10,11 +10,11 @@ struct SSBOScalar float4 c[16]; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float2 _27 = _4.b[10].xy; - float _29 = _4.c[10].x; - (device float2&)_4.b[10] = float2(10.0, 11.0); - (device float2&)_4.a[10] = _27 * _29; + float2 _22 = _6.b[10].xy; + float _26 = _6.c[10].x; + (device float2&)_6.b[10] = float2(10.0, 11.0); + (device float2&)_6.a[10] = _22 * _26; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-5.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-5.asm.comp index 23d25b8286..24be411508 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-5.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-5.asm.comp @@ -10,11 +10,11 @@ struct SSBOScalar packed_float3 c; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float3 _21 = float3(_4.b); - float3 _24 = float3(_4.c); - _4.b = float3(1.0); - _4.a = _21.xy * _24.yz; + float3 _17 = float3(_6.b); + float3 _21 = float3(_6.c); + _6.b = float3(1.0); + _6.a = _17.xy * _21.yz; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding.asm.comp index c21fcc7ffc..04e12948dc 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/load-packed-no-forwarding.asm.comp @@ -12,12 +12,12 @@ struct SSBOScalar packed_rm_float3x3 c; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float3x3 _20 = transpose(float3x3(float3(_4.b[0]), float3(_4.b[1]), float3(_4.b[2]))); - _4.b[0] = float3x3(float3(_4.c[0]), float3(_4.c[1]), float3(_4.c[2]))[0]; - _4.b[1] = float3x3(float3(_4.c[0]), float3(_4.c[1]), float3(_4.c[2]))[1]; - _4.b[2] = float3x3(float3(_4.c[0]), float3(_4.c[1]), float3(_4.c[2]))[2]; - _4.a = _20 * float3(_4.a); + float3x3 _24 = transpose(float3x3(float3(_6.b[0]), float3(_6.b[1]), float3(_6.b[2]))); + _6.b[0] = float3x3(float3(_6.c[0]), float3(_6.c[1]), float3(_6.c[2]))[0]; + _6.b[1] = float3x3(float3(_6.c[0]), float3(_6.c[1]), float3(_6.c[2]))[1]; + _6.b[2] = float3x3(float3(_6.c[0]), float3(_6.c[1]), float3(_6.c[2]))[2]; + _6.a = _24 * float3(_6.a); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/packed-vector-extract-insert.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/packed-vector-extract-insert.asm.comp index 4c70aede48..d2ecc3a20f 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/packed-vector-extract-insert.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/packed-vector-extract-insert.asm.comp @@ -11,12 +11,12 @@ struct SSBOScalar float3 d; }; -kernel void main0(device SSBOScalar& _4 [[buffer(0)]]) +kernel void main0(device SSBOScalar& _6 [[buffer(0)]]) { - float3 _23 = float3(_4.b); + float3 _23 = float3(_6.b); float3 _24 = _23; _24.z = 2.0; - _4.a = _23.xy * _23.z; - _4.b = _24; + _6.a = _23.xy * _23.z; + _6.b = _24; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/row-major-split-access-chain.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/row-major-split-access-chain.asm.comp index f12092cf8f..88dba735cb 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/row-major-split-access-chain.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/packing/row-major-split-access-chain.asm.comp @@ -9,8 +9,8 @@ struct SSBORow float4x4 row_major0; }; -kernel void main0(device SSBORow& _4 [[buffer(0)]]) +kernel void main0(device SSBORow& _6 [[buffer(0)]]) { - _4.v = ((device float*)&_4.row_major0[2u])[1]; + _6.v = ((device float*)&_6.row_major0[2u])[1]; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/temporary.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/temporary.zero-initialize.asm.frag index 6fbf2ff70f..8e5f6b8ea6 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/temporary.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/temporary.zero-initialize.asm.frag @@ -18,19 +18,19 @@ fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; out.FragColor = float4(0.0); - int _10 = {}; - int _15 = {}; - for (int _16 = 0, _17 = 0; _16 < in.vA; _17 = _15, _16 += _10) + int _49 = {}; + int _58 = {}; + for (int _57 = 0, _60 = 0; _57 < in.vA; _60 = _58, _57 += _49) { - if ((in.vA + _16) == 20) + if ((in.vA + _57) == 20) { - _15 = 50; + _58 = 50; } else { - _15 = ((in.vB + _16) == 40) ? 60 : _17; + _58 = ((in.vB + _57) == 40) ? 60 : _60; } - _10 = _15 + 10; + _49 = _58 + 10; out.FragColor += float4(1.0); } return out; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc index 5c30e05a4b..139c357e20 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc @@ -45,7 +45,7 @@ struct spvUnsafeArray }; constant spvUnsafeArray _49 = spvUnsafeArray({ 0.0, 0.0, 0.0 }); -constant spvUnsafeArray, 4> _27 = spvUnsafeArray, 4>({ spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }) }); +constant spvUnsafeArray, 4> _33 = spvUnsafeArray, 4>({ spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }) }); struct main0_out { @@ -56,7 +56,7 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].foo = _27[gl_InvocationID]; + gl_out[gl_InvocationID].foo = _33[gl_InvocationID]; gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].foo[0] = float(gl_InvocationID); gl_out[gl_InvocationID].foo[1] = float(gl_InvocationID) + 1.0; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc index 71498f5b20..dd5c699637 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc @@ -59,11 +59,11 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _27 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].verts_a = _27[gl_InvocationID].a; - gl_out[gl_InvocationID].verts_b = _27[gl_InvocationID].b; + gl_out[gl_InvocationID].verts_a = _33[gl_InvocationID].a; + gl_out[gl_InvocationID].verts_b = _33[gl_InvocationID].b; gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].verts_a = float(gl_InvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc index d8b74bfa33..65dc4ed56e 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc @@ -66,14 +66,14 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _17 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 } }); - spvUnsafeArray _27 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _18 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 } }); + spvUnsafeArray _33 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].gl_Position = _17[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; - gl_out[gl_InvocationID].gl_PointSize = _17[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - gl_out[gl_InvocationID].verts_a = _27[gl_InvocationID].a; - gl_out[gl_InvocationID].verts_b = _27[gl_InvocationID].b; + gl_out[gl_InvocationID].gl_Position = _18[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _18[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].verts_a = _33[gl_InvocationID].a; + gl_out[gl_InvocationID].verts_b = _33[gl_InvocationID].b; gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].verts_a = float(gl_InvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc index a10731bb28..aa51eb67a5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc @@ -59,10 +59,10 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - spvUnsafeArray _27 = spvUnsafeArray({ Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) } }); device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].foo = _27[gl_InvocationID]; + gl_out[gl_InvocationID].foo = _33[gl_InvocationID]; gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].foo.a = float(gl_InvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc index c606f6a075..fe8ed26656 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -64,37 +64,37 @@ struct main0_in }; static inline __attribute__((always_inline)) -void fork0_epilogue(thread const float4& _87, thread const float4& _88, thread const float4& _89, device half (&gl_TessLevelOuter)[3]) +void fork0_epilogue(thread const float4& _61, thread const float4& _62, thread const float4& _63, device half (&gl_TessLevelOuter)[3]) { - gl_TessLevelOuter[0u] = half(_87.x); - gl_TessLevelOuter[1u] = half(_88.x); - gl_TessLevelOuter[2u] = half(_89.x); + gl_TessLevelOuter[0u] = half(_61.x); + gl_TessLevelOuter[1u] = half(_62.x); + gl_TessLevelOuter[2u] = half(_63.x); } static inline __attribute__((always_inline)) -void fork0(uint vForkInstanceId, device half (&gl_TessLevelOuter)[3], thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, thread float4& _48, thread float4& _49, thread float4& _50) +void fork0(uint vForkInstanceId, thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, device half (&gl_TessLevelOuter)[3], thread float4& _52, thread float4& _55, thread float4& _58) { float4 r0; r0.x = as_type(vForkInstanceId); opc[as_type(r0.x)].x = cb0_0._m0[0u].x; - _48 = opc[0u]; - _49 = opc[1u]; - _50 = opc[2u]; - fork0_epilogue(_48, _49, _50, gl_TessLevelOuter); + _52 = opc[0u]; + _55 = opc[1u]; + _58 = opc[2u]; + fork0_epilogue(_52, _55, _58, gl_TessLevelOuter); } static inline __attribute__((always_inline)) -void fork1_epilogue(thread const float4& _109, device half &gl_TessLevelInner) +void fork1_epilogue(thread const float4& _92, device half &gl_TessLevelInner) { - gl_TessLevelInner = half(_109.x); + gl_TessLevelInner = half(_92.x); } static inline __attribute__((always_inline)) -void fork1(device half &gl_TessLevelInner, thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, thread float4& _56) +void fork1(thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, device half &gl_TessLevelInner, thread float4& _89) { opc[3u].x = cb0_0._m0[0u].x; - _56 = opc[3u]; - fork1_epilogue(_56, gl_TessLevelInner); + _89 = opc[3u]; + fork1_epilogue(_89, gl_TessLevelInner); } kernel void main0(main0_in in [[stage_in]], constant cb1_struct& cb0_0 [[buffer(0)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) @@ -113,13 +113,13 @@ kernel void main0(main0_in in [[stage_in]], constant cb1_struct& cb0_0 [[buffer( gl_out[gl_InvocationID].vocp0 = gl_in[gl_InvocationID].vicp0; gl_out[gl_InvocationID].vocp1 = gl_in[gl_InvocationID].vicp1; spvUnsafeArray opc; - float4 _48; - float4 _49; - float4 _50; - fork0(0u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, _48, _49, _50); - fork0(1u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, _48, _49, _50); - fork0(2u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, _48, _49, _50); - float4 _56; - fork1(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, opc, cb0_0, _56); + float4 _52; + float4 _55; + float4 _58; + fork0(0u, opc, cb0_0, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, _52, _55, _58); + fork0(1u, opc, cb0_0, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, _52, _55, _58); + fork0(2u, opc, cb0_0, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, _52, _55, _58); + float4 _89; + fork1(opc, cb0_0, spvTessLevel[gl_PrimitiveID].insideTessellationFactor, _89); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc index 6585e77204..ba1e0b6d1d 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc @@ -44,8 +44,8 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _19 = spvUnsafeArray({ 1.0, 2.0 }); -constant spvUnsafeArray _25 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); +constant spvUnsafeArray _14 = spvUnsafeArray({ 1.0, 2.0 }); +constant spvUnsafeArray _21 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); struct main0_out { @@ -55,10 +55,10 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_PrimitiveID * 1]; - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_19[0]); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_25[0]); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_25[1]); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_25[2]); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_14[0]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_21[0]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_21[1]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_21[2]); spvUnsafeArray inner = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].insideTessellationFactor), 0.0 }); spvUnsafeArray outer = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2]), 0.0 }); gl_out[gl_InvocationID].gl_Position = float4(1.0); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc index 0c6c1dc813..b1c2c232d9 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc @@ -44,7 +44,7 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _25 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); +constant spvUnsafeArray _31 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); struct main0_out { @@ -55,7 +55,7 @@ struct main0_out kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; - gl_out[gl_InvocationID].v = _25[gl_InvocationID]; + gl_out[gl_InvocationID].v = _31[gl_InvocationID]; gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].v = float(gl_InvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc index c3ace1b9e1..310ed7b256 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc @@ -81,7 +81,7 @@ struct main0_out struct main0_in { VertexOutput_1 p; - ushort2 m_171; + ushort2 m_174; float4 gl_Position; }; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc index d6d0bc0149..53ce5fc68f 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc @@ -44,8 +44,8 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _27 = spvUnsafeArray({ 0.0, 0.0 }); -constant spvUnsafeArray _33 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); +constant spvUnsafeArray _31 = spvUnsafeArray({ 0.0, 0.0 }); +constant spvUnsafeArray _39 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); struct main0_out { diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc index 979f4329f5..41622c5a37 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc @@ -44,8 +44,8 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _27 = spvUnsafeArray({ 0.0, 0.0 }); -constant spvUnsafeArray _33 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); +constant spvUnsafeArray _31 = spvUnsafeArray({ 0.0, 0.0 }); +constant spvUnsafeArray _39 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); struct main0_out { diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-io-use-in-function.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-io-use-in-function.asm.vert index 3e91bb9eb2..e84bb56029 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-io-use-in-function.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-io-use-in-function.asm.vert @@ -92,9 +92,9 @@ struct LightContext struct main0_out { - float4 m_3_v_color [[user(locn1)]]; - float2 m_3_v_texPos [[user(locn2)]]; - float3 m_3_v_worldPosition [[user(locn3)]]; + float4 m_4_v_color [[user(locn1)]]; + float2 m_4_v_texPos [[user(locn2)]]; + float3 m_4_v_worldPosition [[user(locn3)]]; float4 gl_Position [[position]]; }; @@ -106,23 +106,23 @@ struct main0_in }; static inline __attribute__((always_inline)) -void DrawWorldVS(thread PerVertex& _3, thread float4& a_color, thread float2& a_texcoord, thread float3& a_position, thread float4& gl_Position, constant u_objToWorlds& _12, constant SceneSettings& _17) +void DrawWorldVS(thread PerVertex& _4, thread float4& a_color, thread float2& a_texcoord, thread float3& a_position, thread float4& gl_Position, constant u_objToWorlds& _15, constant SceneSettings& _22) { - _3.v_color = a_color; - _3.v_texPos = a_texcoord; - _3.v_worldPosition = a_position; - float4 worldSpacePosition = _12.u_objToWorld * float4(a_position, 1.0); - gl_Position = _17.u_cameras[0].u_projectFromWorld * worldSpacePosition; + _4.v_color = a_color; + _4.v_texPos = a_texcoord; + _4.v_worldPosition = a_position; + float4 worldSpacePosition = _15.u_objToWorld * float4(a_position, 1.0); + gl_Position = _22.u_cameras[0].u_projectFromWorld * worldSpacePosition; } -vertex main0_out main0(main0_in in [[stage_in]], constant u_objToWorlds& _12 [[buffer(0)]], constant SceneSettings& _17 [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant u_objToWorlds& _15 [[buffer(0)]], constant SceneSettings& _22 [[buffer(1)]]) { main0_out out = {}; - PerVertex _3 = {}; - DrawWorldVS(_3, in.a_color, in.a_texcoord, in.a_position, out.gl_Position, _12, _17); - out.m_3_v_color = _3.v_color; - out.m_3_v_texPos = _3.v_texPos; - out.m_3_v_worldPosition = _3.v_worldPosition; + PerVertex _4 = {}; + DrawWorldVS(_4, in.a_color, in.a_texcoord, in.a_position, out.gl_Position, _15, _22); + out.m_4_v_color = _4.v_color; + out.m_4_v_texPos = _4.v_texPos; + out.m_4_v_worldPosition = _4.v_worldPosition; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert index 6c8f938270..5926a20ac1 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -17,8 +17,8 @@ struct Foo struct main0_out { - float m_3_a [[user(locn0)]]; - float m_3_b [[user(locn1)]]; + float m_4_a [[user(locn0)]]; + float m_4_b [[user(locn1)]]; float foo_c [[user(locn2)]]; float foo_d [[user(locn3)]]; float4 gl_Position [[position]]; @@ -27,11 +27,11 @@ struct main0_out vertex main0_out main0() { main0_out out = {}; - Vert _3 = Vert{ 0.0, 0.0 }; + Vert _4 = Vert{ 0.0, 0.0 }; Foo foo = Foo{ 0.0, 0.0 }; out.gl_Position = float4(0.0); - out.m_3_a = _3.a; - out.m_3_b = _3.b; + out.m_4_a = _4.a; + out.m_4_b = _4.b; out.foo_c = foo.c; out.foo_d = foo.d; return out; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/array-copy-threadgroup-memory.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/array-copy-threadgroup-memory.comp index eab1df4fce..a915dfaf30 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/array-copy-threadgroup-memory.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/array-copy-threadgroup-memory.comp @@ -44,129 +44,20 @@ struct spvUnsafeArray } }; -template -inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(8u, 1u, 1u); kernel void main0(uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { - threadgroup float shared_group[8][8]; - threadgroup float shared_group_alt[8][8]; + threadgroup spvUnsafeArray, 8> shared_group; + threadgroup spvUnsafeArray, 8> shared_group_alt; spvUnsafeArray blob; for (int i = 0; i < 8; i++) { blob[i] = float(i); } - spvArrayCopyFromStackToThreadGroup1(shared_group[gl_LocalInvocationIndex], blob.elements); + shared_group[gl_LocalInvocationIndex] = blob; threadgroup_barrier(mem_flags::mem_threadgroup); - spvUnsafeArray copied_blob; - spvArrayCopyFromThreadGroupToStack1(copied_blob.elements, shared_group[gl_LocalInvocationIndex ^ 1u]); - spvArrayCopyFromThreadGroupToThreadGroup1(shared_group_alt[gl_LocalInvocationIndex], shared_group[gl_LocalInvocationIndex]); + spvUnsafeArray copied_blob = shared_group[gl_LocalInvocationIndex ^ 1u]; + shared_group_alt[gl_LocalInvocationIndex] = shared_group[gl_LocalInvocationIndex]; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/extract-atomics-from-function.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/extract-atomics-from-function.comp new file mode 100644 index 0000000000..0d082e2f1e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/extract-atomics-from-function.comp @@ -0,0 +1,82 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +static inline __attribute__((always_inline)) +void testAdd(threadgroup uint& var) +{ + uint _29 = atomic_fetch_add_explicit((threadgroup atomic_uint*)&var, 1u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testMin(threadgroup uint& var) +{ + uint _31 = atomic_fetch_min_explicit((threadgroup atomic_uint*)&var, 2u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testMax(threadgroup uint& var) +{ + uint _33 = atomic_fetch_max_explicit((threadgroup atomic_uint*)&var, 3u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testOr(threadgroup uint& var) +{ + uint _35 = atomic_fetch_or_explicit((threadgroup atomic_uint*)&var, 5u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testXor(threadgroup uint& var) +{ + uint _37 = atomic_fetch_xor_explicit((threadgroup atomic_uint*)&var, 6u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testExchange(threadgroup uint& var) +{ + uint _39 = atomic_exchange_explicit((threadgroup atomic_uint*)&var, 7u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void testCompSwap(threadgroup uint& var) +{ + uint _42; + do + { + _42 = 8u; + } while (!atomic_compare_exchange_weak_explicit((threadgroup atomic_uint*)&var, &_42, 9u, memory_order_relaxed, memory_order_relaxed) && _42 == 8u); +} + +static inline __attribute__((always_inline)) +void testStore(threadgroup uint& var) +{ + atomic_store_explicit((threadgroup atomic_uint*)&var, 10u, memory_order_relaxed); +} + +static inline __attribute__((always_inline)) +void foo(threadgroup uint& var) +{ + testAdd(var); + testMin(var); + testMax(var); + testOr(var); + testXor(var); + testExchange(var); + testCompSwap(var); + testStore(var); +} + +kernel void main0() +{ + threadgroup uint var; + foo(var); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/glsl.std450.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/glsl.std450.comp index b1790b23df..ae1337ff51 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/glsl.std450.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/glsl.std450.comp @@ -224,7 +224,7 @@ kernel void main0(device SSBO& _19 [[buffer(0)]]) _19.res = acosh(((device float*)&_19.f32)[0u]); _19.res = atanh(((device float*)&_19.f32)[0u]); _19.res = precise::atan2(((device float*)&_19.f32)[0u], ((device float*)&_19.f32)[1u]); - _19.res = pow(((device float*)&_19.f32)[0u], ((device float*)&_19.f32)[1u]); + _19.res = powr(((device float*)&_19.f32)[0u], ((device float*)&_19.f32)[1u]); _19.res = exp(((device float*)&_19.f32)[0u]); _19.res = log(((device float*)&_19.f32)[0u]); _19.res = exp2(((device float*)&_19.f32)[0u]); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/illegal-struct-name.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/illegal-struct-name.asm.comp index de1695b068..01751668b5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/illegal-struct-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/illegal-struct-name.asm.comp @@ -19,11 +19,11 @@ struct SSBO Foo_1 foo2; }; -kernel void main0(device SSBO& _7 [[buffer(0)]]) +kernel void main0(device SSBO& _9 [[buffer(0)]]) { Foo f; - f._abs = _7.foo._abs; + f._abs = _9.foo._abs; int _abs = 10; - _7.foo2._abs = f._abs; + _9.foo2._abs = f._abs; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp new file mode 100644 index 0000000000..7d149c3986 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp @@ -0,0 +1,19 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct PushConst +{ + uint texture0; +}; + +kernel void main0(constant PushConst& pc [[buffer(0)]], array, 8> kTextures2D [[texture(0)]]) +{ + uint _30 = kTextures2D[pc.texture0].atomic_fetch_add(uint2(int2(0)), 1u).x; + uint i = _30; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp new file mode 100644 index 0000000000..4f2da06d1b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp @@ -0,0 +1,65 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +T reduce_add(vec v) { return v.x + v.y; } +template +T reduce_add(vec v) { return v.x + v.y + v.z; } +template +T reduce_add(vec v) { return v.x + v.y + v.z + v.w; } + +struct InOut3 +{ + ushort4 x; + ushort4 y; + int acc; + int result; +}; + +struct InOut2 +{ + uint x; + uint y; + uint result; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +struct InOut +{ + uint4 x; + uint4 y; + int result; +}; + +kernel void main0(device void* spvBufferAliasSet0Binding1 [[buffer(0)]]) +{ + device auto& comp3 = *(device InOut3*)spvBufferAliasSet0Binding1; + device auto& comp2 = *(device InOut2*)spvBufferAliasSet0Binding1; + int sdot_int = reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))); + uint sdot_uint = reduce_add(uint4(short4(comp3.x)) * uint4(short4(comp3.y))); + uint udot_uint = reduce_add(uint4(comp3.x) * uint4(comp3.y)); + int sudot_int = reduce_add(int4(short4(comp3.x)) * int4(comp3.y)); + uint sudot_uint = reduce_add(uint4(short4(comp3.x)) * uint4(comp3.y)); + uchar spdot8 = reduce_add(uchar4(as_type(comp2.x)) * uchar4(as_type(comp2.y))); + ushort spdot16 = reduce_add(ushort4(as_type(comp2.x)) * ushort4(as_type(comp2.y))); + uint spdot32 = reduce_add(uint4(as_type(comp2.x)) * uint4(as_type(comp2.y))); + int spdoti32 = reduce_add(int4(as_type(comp2.x)) * int4(as_type(comp2.y))); + uchar updot8 = reduce_add(uchar4(as_type(comp2.x)) * uchar4(as_type(comp2.y))); + ushort updot16 = reduce_add(ushort4(as_type(comp2.x)) * ushort4(as_type(comp2.y))); + uint updot32 = reduce_add(uint4(as_type(comp2.x)) * uint4(as_type(comp2.y))); + uchar supdot8 = reduce_add(uchar4(as_type(comp2.x)) * uchar4(as_type(comp2.y))); + ushort supdot16 = reduce_add(ushort4(as_type(comp2.x)) * ushort4(as_type(comp2.y))); + uint supdot32 = reduce_add(uint4(as_type(comp2.x)) * uint4(as_type(comp2.y))); + int supdoti32 = reduce_add(int4(as_type(comp2.x)) * int4(as_type(comp2.y))); + int sdotaddsat_int = int(addsat(reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))), comp3.acc)); + uint sdotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))), comp3.acc)); + uint udotaddsat_uint = uint(addsat(reduce_add(uint4(comp3.x) * uint4(comp3.y)), uint(comp3.acc))); + int sudotaddsat_int = int(addsat(reduce_add(int4(short4(comp3.x)) * int4(comp3.y)), comp3.acc)); + uint sudotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(comp3.y)), comp3.acc)); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/combined-sampler-parameter-names.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/combined-sampler-parameter-names.asm.frag index 35ba5f7931..4e823ab180 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/combined-sampler-parameter-names.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/combined-sampler-parameter-names.asm.frag @@ -7,24 +7,24 @@ using namespace metal; struct main0_out { - float4 m_4 [[color(0)]]; + float4 m_6 [[color(0)]]; }; struct main0_in { - float2 m_3 [[user(locn0)]]; + float2 m_4 [[user(locn0)]]; }; static inline __attribute__((always_inline)) -float4 _19(thread float2& _3, texture2d _5, sampler _5Smplr) +float4 _22(thread float2& _4, texture2d _7, sampler _7Smplr) { - return _5.sample(_5Smplr, _3); + return _7.sample(_7Smplr, _4); } -fragment main0_out main0(main0_in in [[stage_in]], texture2d _5 [[texture(0)]], sampler _5Smplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d _7 [[texture(0)]], sampler _7Smplr [[sampler(0)]]) { main0_out out = {}; - out.m_4 = _19(in.m_3, _5, _5Smplr); + out.m_6 = _22(in.m_4, _7, _7Smplr); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag index 16182ae2e1..b7eae127f5 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag @@ -102,7 +102,7 @@ void test_builtins(thread half4& v4, thread half3& v3, thread half& v1) res = asinh(v4); res = acosh(v4); res = atanh(v4); - res = pow(v4, v4); + res = powr(v4, v4); res = exp(v4); res = log(v4); res = exp2(v4); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag new file mode 100644 index 0000000000..379f0363bf --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag @@ -0,0 +1,70 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include +#if __METAL_VERSION__ >= 230 +#include +using namespace metal::raytracing; +#endif + +using namespace metal; + +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + +static inline __attribute__((always_inline)) +void initFn(thread raytracing::intersection_query& rayQuery, const raytracing::acceleration_structure topLevelAS) +{ + float3 rayOrigin = float3(0.0, 0.0, 1.0); + float3 rayDirection = float3(0.0, 0.0, -1.0); + float rayDistance = 2.0; + rayQuery.reset(ray(rayOrigin, rayDirection, 0.001000000047497451305389404296875, rayDistance), topLevelAS, 255u, spvMakeIntersectionParams(4u)); +} + +static inline __attribute__((always_inline)) +uint proceeFn(thread raytracing::intersection_query& rayQuery) +{ + for (;;) + { + bool _46 = rayQuery.next(); + if (_46) + { + continue; + } + else + { + break; + } + } + uint _50 = uint(rayQuery.get_committed_intersection_type()); + return _50; +} + +fragment void main0(raytracing::acceleration_structure topLevelAS [[buffer(0)]]) +{ + raytracing::intersection_query rayQuery; + initFn(rayQuery, topLevelAS); + uint _55 = proceeFn(rayQuery); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag new file mode 100644 index 0000000000..4dc98ca4f4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag @@ -0,0 +1,64 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvPaddedStd140 { alignas(16) T data; }; +template +using spvPaddedStd140Matrix = spvPaddedStd140[n]; + +struct Foo +{ + spvPaddedStd140Matrix c23; + spvPaddedStd140Matrix c32; + spvPaddedStd140Matrix r23; + spvPaddedStd140Matrix r32; + spvPaddedStd140 h1[6]; + spvPaddedStd140 h2[6]; + spvPaddedStd140 h3[6]; + spvPaddedStd140 h4[6]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(device Foo& _20 [[buffer(0)]]) +{ + main0_out out = {}; + ((device half*)&_20.c23[1].data)[2u] = half(1.0); + ((device half*)&_20.c32[2].data)[1u] = half(2.0); + ((device half*)&_20.r23[2u])[1] = half(3.0); + ((device half*)&_20.r32[1u])[2] = half(4.0); + _20.c23[1].data = half3(half(0.0), half(1.0), half(2.0)); + _20.c32[1].data = half2(half(0.0), half(1.0)); + ((device half*)&_20.r23[0])[1] = half3(half(0.0), half(1.0), half(2.0)).x; + ((device half*)&_20.r23[1])[1] = half3(half(0.0), half(1.0), half(2.0)).y; + ((device half*)&_20.r23[2])[1] = half3(half(0.0), half(1.0), half(2.0)).z; + ((device half*)&_20.r32[0])[1] = half2(half(0.0), half(1.0)).x; + ((device half*)&_20.r32[1])[1] = half2(half(0.0), half(1.0)).y; + (device half3&)_20.c23[0] = half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[0]; + (device half3&)_20.c23[1] = half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[1]; + (device half2&)_20.c32[0] = half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[0]; + (device half2&)_20.c32[1] = half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[1]; + (device half2&)_20.c32[2] = half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[2]; + (device half2&)_20.r23[0] = half2(half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[0][0], half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[1][0]); + (device half2&)_20.r23[1] = half2(half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[0][1], half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[1][1]); + (device half2&)_20.r23[2] = half2(half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[0][2], half2x3(half3(half(1.0), half(2.0), half(3.0)), half3(half(4.0), half(5.0), half(6.0)))[1][2]); + (device half3&)_20.r32[0] = half3(half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[0][0], half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[1][0], half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[2][0]); + (device half3&)_20.r32[1] = half3(half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[0][1], half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[1][1], half3x2(half2(half(1.0), half(2.0)), half2(half(3.0), half(4.0)), half2(half(5.0), half(6.0)))[2][1]); + _20.h1[5].data = half(1.0); + _20.h2[5].data = half2(half(1.0), half(2.0)); + _20.h3[5].data = half3(half(1.0), half(2.0), half(3.0)); + _20.h4[5].data = half4(half(1.0), half(2.0), half(3.0), half(4.0)); + ((device half*)&_20.h2[5].data)[1u] = half(10.0); + ((device half*)&_20.h3[5].data)[2u] = half(11.0); + ((device half*)&_20.h4[5].data)[3u] = half(12.0); + out.FragColor = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag new file mode 100644 index 0000000000..ea6ca6e40e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag @@ -0,0 +1,98 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvPaddedStd140 { alignas(16) T data; }; +template +using spvPaddedStd140Matrix = spvPaddedStd140[n]; + +struct Foo +{ + spvPaddedStd140Matrix c22; + spvPaddedStd140Matrix c22arr[3]; + spvPaddedStd140Matrix c23; + spvPaddedStd140Matrix c24; + spvPaddedStd140Matrix c32; + spvPaddedStd140Matrix c33; + spvPaddedStd140Matrix c34; + spvPaddedStd140Matrix c42; + spvPaddedStd140Matrix c43; + spvPaddedStd140Matrix c44; + spvPaddedStd140Matrix r22; + spvPaddedStd140Matrix r22arr[3]; + spvPaddedStd140Matrix r23; + spvPaddedStd140Matrix r24; + spvPaddedStd140Matrix r32; + spvPaddedStd140Matrix r33; + spvPaddedStd140Matrix r34; + spvPaddedStd140Matrix r42; + spvPaddedStd140Matrix r43; + spvPaddedStd140Matrix r44; + spvPaddedStd140 h1[6]; + spvPaddedStd140 h2[6]; + spvPaddedStd140 h3[6]; + spvPaddedStd140 h4[6]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant Foo& u [[buffer(0)]]) +{ + main0_out out = {}; + half2 c2 = half2(u.c22[0].data) + half2(u.c22[1].data); + c2 = half2(u.c22arr[2][0].data) + half2(u.c22arr[2][1].data); + half3 c3 = half3(u.c23[0].data) + half3(u.c23[1].data); + half4 c4 = half4(u.c24[0].data) + half4(u.c24[1].data); + c2 = (half2(u.c32[0].data) + half2(u.c32[1].data)) + half2(u.c32[2].data); + c3 = (half3(u.c33[0].data) + half3(u.c33[1].data)) + half3(u.c33[2].data); + c4 = (half4(u.c34[0].data) + half4(u.c34[1].data)) + half4(u.c34[2].data); + c2 = ((half2(u.c42[0].data) + half2(u.c42[1].data)) + half2(u.c42[2].data)) + half2(u.c42[3].data); + c3 = ((half3(u.c43[0].data) + half3(u.c43[1].data)) + half3(u.c43[2].data)) + half3(u.c43[3].data); + c4 = ((half4(u.c44[0].data) + half4(u.c44[1].data)) + half4(u.c44[2].data)) + half4(u.c44[3].data); + half c = ((u.c22[0].data.x + u.c22[0].data.y) + u.c22[1].data.x) + u.c22[1].data.y; + c = ((u.c22arr[2][0].data.x + u.c22arr[2][0].data.y) + u.c22arr[2][1].data.x) + u.c22arr[2][1].data.y; + half2x2 c22 = half2x2(u.c22[0].data.xy, u.c22[1].data.xy); + c22 = half2x2(u.c22arr[2][0].data.xy, u.c22arr[2][1].data.xy); + half2x3 c23 = half2x3(u.c23[0].data.xyz, u.c23[1].data.xyz); + half2x4 c24 = half2x4(u.c24[0].data, u.c24[1].data); + half3x2 c32 = half3x2(u.c32[0].data.xy, u.c32[1].data.xy, u.c32[2].data.xy); + half3x3 c33 = half3x3(u.c33[0].data.xyz, u.c33[1].data.xyz, u.c33[2].data.xyz); + half3x4 c34 = half3x4(u.c34[0].data, u.c34[1].data, u.c34[2].data); + half4x2 c42 = half4x2(u.c42[0].data.xy, u.c42[1].data.xy, u.c42[2].data.xy, u.c42[3].data.xy); + half4x3 c43 = half4x3(u.c43[0].data.xyz, u.c43[1].data.xyz, u.c43[2].data.xyz, u.c43[3].data.xyz); + half4x4 c44 = half4x4(u.c44[0].data, u.c44[1].data, u.c44[2].data, u.c44[3].data); + half2 r2 = half2(u.r22[0].data[0], u.r22[1].data[0]) + half2(u.r22[0].data[1], u.r22[1].data[1]); + r2 = half2(u.r22arr[2][0].data[0], u.r22arr[2][1].data[0]) + half2(u.r22arr[2][0].data[1], u.r22arr[2][1].data[1]); + half3 r3 = half3(u.r23[0].data[0], u.r23[1].data[0], u.r23[2].data[0]) + half3(u.r23[0].data[1], u.r23[1].data[1], u.r23[2].data[1]); + half4 r4 = half4(u.r24[0].data[0], u.r24[1].data[0], u.r24[2].data[0], u.r24[3].data[0]) + half4(u.r24[0].data[1], u.r24[1].data[1], u.r24[2].data[1], u.r24[3].data[1]); + r2 = (half2(u.r32[0].data[0], u.r32[1].data[0]) + half2(u.r32[0].data[1], u.r32[1].data[1])) + half2(u.r32[0].data[2], u.r32[1].data[2]); + r3 = (half3(u.r33[0].data[0], u.r33[1].data[0], u.r33[2].data[0]) + half3(u.r33[0].data[1], u.r33[1].data[1], u.r33[2].data[1])) + half3(u.r33[0].data[2], u.r33[1].data[2], u.r33[2].data[2]); + r4 = (half4(u.r34[0].data[0], u.r34[1].data[0], u.r34[2].data[0], u.r34[3].data[0]) + half4(u.r34[0].data[1], u.r34[1].data[1], u.r34[2].data[1], u.r34[3].data[1])) + half4(u.r34[0].data[2], u.r34[1].data[2], u.r34[2].data[2], u.r34[3].data[2]); + r2 = ((half2(u.r42[0].data[0], u.r42[1].data[0]) + half2(u.r42[0].data[1], u.r42[1].data[1])) + half2(u.r42[0].data[2], u.r42[1].data[2])) + half2(u.r42[0].data[3], u.r42[1].data[3]); + r3 = ((half3(u.r43[0].data[0], u.r43[1].data[0], u.r43[2].data[0]) + half3(u.r43[0].data[1], u.r43[1].data[1], u.r43[2].data[1])) + half3(u.r43[0].data[2], u.r43[1].data[2], u.r43[2].data[2])) + half3(u.r43[0].data[3], u.r43[1].data[3], u.r43[2].data[3]); + r4 = ((half4(u.r44[0].data[0], u.r44[1].data[0], u.r44[2].data[0], u.r44[3].data[0]) + half4(u.r44[0].data[1], u.r44[1].data[1], u.r44[2].data[1], u.r44[3].data[1])) + half4(u.r44[0].data[2], u.r44[1].data[2], u.r44[2].data[2], u.r44[3].data[2])) + half4(u.r44[0].data[3], u.r44[1].data[3], u.r44[2].data[3], u.r44[3].data[3]); + half r = ((u.r22[0u].data[0] + u.r22[1u].data[0]) + u.r22[0u].data[1]) + u.r22[1u].data[1]; + half2x2 r22 = transpose(half2x2(u.r22[0].data.xy, u.r22[1].data.xy)); + half2x3 r23 = transpose(half3x2(u.r23[0].data.xy, u.r23[1].data.xy, u.r23[2].data.xy)); + half2x4 r24 = transpose(half4x2(u.r24[0].data.xy, u.r24[1].data.xy, u.r24[2].data.xy, u.r24[3].data.xy)); + half3x2 r32 = transpose(half2x3(u.r32[0].data.xyz, u.r32[1].data.xyz)); + half3x3 r33 = transpose(half3x3(u.r33[0].data.xyz, u.r33[1].data.xyz, u.r33[2].data.xyz)); + half3x4 r34 = transpose(half4x3(u.r34[0].data.xyz, u.r34[1].data.xyz, u.r34[2].data.xyz, u.r34[3].data.xyz)); + half4x2 r42 = transpose(half2x4(u.r42[0].data, u.r42[1].data)); + half4x3 r43 = transpose(half3x4(u.r43[0].data, u.r43[1].data, u.r43[2].data)); + half4x4 r44 = transpose(half4x4(u.r44[0].data, u.r44[1].data, u.r44[2].data, u.r44[3].data)); + half h1 = half(u.h1[5].data); + half2 h2 = half2(u.h2[5].data); + half3 h3 = half3(u.h3[5].data); + half4 h4 = half4(u.h4[5].data); + out.FragColor = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc index f55e47baf0..5ec3ebada2 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc @@ -52,8 +52,8 @@ struct main0_out struct main0_in { - uint3 m_57; - ushort2 m_61; + uint3 m_58; + ushort2 m_63; spvUnsafeArray gl_ClipDistance; spvUnsafeArray gl_CullDistance; }; diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-decrement.asm.comp index 272337fc12..10ba176312 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-decrement.asm.comp @@ -21,9 +21,9 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - uint _29 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); + uint _24 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); float4 r0; - r0.x = as_type(_29); + r0.x = as_type(_24); u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(((uint(as_type(r0.x)) * 1u) + (uint(0) >> 2u)))); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-increment.asm.comp index 4518248b89..76208ac71d 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/atomic-increment.asm.comp @@ -21,9 +21,9 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - uint _29 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); + uint _24 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); float4 r0; - r0.x = as_type(_29); + r0.x = as_type(_24); u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(((uint(as_type(r0.x)) * 1u) + (uint(0) >> 2u)))); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp index ac78a65196..94f838225a 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp @@ -22,11 +22,11 @@ kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d(int(gl_LocalInvocationID.x) << 4); r0.y = as_type(int(gl_LocalInvocationID.x)); - uint _44 = as_type(r0.x) >> 2u; - uint4 _51 = as_type(cb0_5._m0[uint(as_type(r0.y)) + 1u]); - u0.write(_51.xxxx, spvTexelBufferCoord(_44)); - u0.write(_51.yyyy, spvTexelBufferCoord((_44 + 1u))); - u0.write(_51.zzzz, spvTexelBufferCoord((_44 + 2u))); - u0.write(_51.wwww, spvTexelBufferCoord((_44 + 3u))); + uint _41 = as_type(r0.x) >> 2u; + uint4 _50 = as_type(cb0_5._m0[uint(as_type(r0.y)) + 1u]); + u0.write(_50.xxxx, spvTexelBufferCoord(_41)); + u0.write(_50.yyyy, spvTexelBufferCoord((_41 + 1u))); + u0.write(_50.zzzz, spvTexelBufferCoord((_41 + 2u))); + u0.write(_50.wwww, spvTexelBufferCoord((_41 + 3u))); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp index 89e8d83ea7..f464abf5c1 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp @@ -17,8 +17,8 @@ struct cb float value; }; -kernel void main0(constant cb& _6 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +kernel void main0(constant cb& _8 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { - _buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); + _buffer.write(float4(_8.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp index 536556391e..346f40ee28 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp @@ -8,6 +8,7 @@ using namespace metal; static inline __attribute__((always_inline)) void _main(thread const uint3& id, texture2d TargetTexture) { + TargetTexture.fence(); float2 loaded = TargetTexture.read(uint2(id.xy)).xy; float2 storeTemp = loaded + float2(1.0); TargetTexture.write(storeTemp.xyyy, uint2((id.xy + uint2(1u)))); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/quantize.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/quantize.asm.comp index 672c2b2088..461bf7b8b3 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/quantize.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/quantize.asm.comp @@ -24,11 +24,11 @@ struct SSBO0 float4 vec4_val; }; -kernel void main0(device SSBO0& _4 [[buffer(0)]]) +kernel void main0(device SSBO0& _12 [[buffer(0)]]) { - _4.scalar = spvQuantizeToF16(_4.scalar); - _4.vec2_val = spvQuantizeToF16(_4.vec2_val); - _4.vec3_val = spvQuantizeToF16(_4.vec3_val); - _4.vec4_val = spvQuantizeToF16(_4.vec4_val); + _12.scalar = spvQuantizeToF16(_12.scalar); + _12.vec2_val = spvQuantizeToF16(_12.vec2_val); + _12.vec3_val = spvQuantizeToF16(_12.vec3_val); + _12.vec4_val = spvQuantizeToF16(_12.vec4_val); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/relaxed-block-layout.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/relaxed-block-layout.asm.comp index 6728a4e2d3..1464bd8e88 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/relaxed-block-layout.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/relaxed-block-layout.asm.comp @@ -12,11 +12,11 @@ struct foo packed_half2 wibble; }; -kernel void main0(device foo& _8 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]]) +kernel void main0(device foo& _10 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]]) { - _8.bar = gl_LocalInvocationID.x; - _8.baz = float3(gl_GlobalInvocationID); - _8.blah = uchar4(uint4(uint4(uchar4(_8.blah)).xyz + gl_WorkGroupID, 0u)); - _8.wibble = half2(float2(half2(_8.wibble)) * float2(gl_NumWorkGroups.xy)); + _10.bar = gl_LocalInvocationID.x; + _10.baz = float3(gl_GlobalInvocationID); + _10.blah = uchar4(uint4(uint4(uchar4(_10.blah)).xyz + gl_WorkGroupID, 0u)); + _10.wibble = half2(float2(half2(_10.wibble)) * float2(gl_NumWorkGroups.xy)); } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp index 1e2880f4e8..eb13541c8b 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/specialization-constant-workgroup.asm.comp @@ -8,14 +8,14 @@ struct SSBO float a; }; -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 [[maybe_unused]] = uint3(_5, 20u, _6); +constant uint _19_tmp [[function_constant(10)]]; +constant uint _19 = is_function_constant_defined(_19_tmp) ? _19_tmp : 9u; +constant uint _21_tmp [[function_constant(12)]]; +constant uint _21 = is_function_constant_defined(_21_tmp) ? _21_tmp : 4u; +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_19, 20u, _21); -kernel void main0(device SSBO& _4 [[buffer(0)]]) +kernel void main0(device SSBO& _6 [[buffer(0)]]) { - _4.a += 1.0; + _6.a += 1.0; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp index dafd6d5d4f..4a04262810 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp @@ -31,27 +31,27 @@ thread uint3* select_input(thread uint3& gl_GlobalInvocationID, thread uint3& gl kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - device foo* _46 = select_buffer(buf, cb); - device foo* _45 = _46; - thread uint3* _47 = select_input(gl_GlobalInvocationID, gl_LocalInvocationID, cb); - device foo* _48 = _45; + device foo* _44 = select_buffer(buf, cb); + device foo* _65 = _44; + thread uint3* _45 = select_input(gl_GlobalInvocationID, gl_LocalInvocationID, cb); + device foo* _66 = _65; + device int* _49; device int* _52; - device int* _55; - _52 = &_48->a[0u]; - _55 = &buf.a[0u]; - int _57; - int _58; + _49 = &_66->a[0u]; + _52 = &buf.a[0u]; + int _54; + int _55; for (;;) { - _57 = *_52; - _58 = *_55; - if (_57 != _58) + _54 = *_49; + _55 = *_52; + if (_54 != _55) { - int _66 = (_57 + _58) + int((*_47).x); - *_52 = _66; - *_55 = _66; + int _63 = (_54 + _55) + int((*_45).x); + *_49 = _63; + *_52 = _63; + _49 = &_49[1u]; _52 = &_52[1u]; - _55 = &_55[1u]; continue; } else diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag index 3628c4eaae..2f80be7666 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/default-member-names.asm.frag @@ -3,12 +3,12 @@ using namespace metal; -struct _9 +struct _10 { float _m0; }; -struct _10 +struct _11 { float _m0; float _m1; @@ -22,7 +22,7 @@ struct _10 float _m9; float _m10; float _m11; - _9 _m12; + _10 _m12; }; struct main0_out @@ -33,8 +33,8 @@ struct main0_out fragment main0_out main0() { main0_out out = {}; - _10 _21; - out.m_3 = float4(_21._m0, _21._m1, _21._m2, _21._m3); + _11 _23; + out.m_3 = float4(_23._m0, _23._m1, _23._m2, _23._m3); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag new file mode 100644 index 0000000000..f4b08ef48b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag @@ -0,0 +1,55 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) +{ + // Major axis selection + float3 absP = abs(P); + bool xMajor = absP.x >= max(absP.y, absP.z); + bool yMajor = absP.y >= absP.z; + float3 Q = xMajor ? P.yzx : (yMajor ? P.xzy : P); + float3 dQdx = xMajor ? dPdx.yzx : (yMajor ? dPdx.xzy : dPdx); + float3 dQdy = xMajor ? dPdy.yzx : (yMajor ? dPdy.xzy : dPdy); + + // Skip a couple of operations compared to usual projection + float4 d = float4(dQdx.xy, dQdy.xy) - (Q.xy / Q.z).xyxy * float4(dQdx.zz, dQdy.zz); + + // Final swizzle to put the intermediate values into non-ignored components + // X major: X and Z + // Y major: X and Y + // Z major: Y and Z + return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); +} + +struct buf0 +{ + float4 u_scale; +}; + +struct buf1 +{ + float4 u_bias; +}; + +struct main0_out +{ + float4 o_color [[color(0)]]; +}; + +struct main0_in +{ + float4 v_texCoord [[user(locn0)]]; + float2 v_drefLodBias [[user(locn1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depthcube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag index cf06cddc8a..ba6f0aa5da 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag @@ -21,27 +21,27 @@ struct main0_in }; static inline __attribute__((always_inline)) -void _108(int _109, texture2d _8, device _7& _10) +void _112(int _113, texture2d _8, device _7& _10) { - int2 _113 = int2(_109 - 8 * (_109 / 8), _109 / 8); - _10._m0[_109] = _8.read(uint2(_113), 0); + int2 _117 = int2(_113 - 8 * (_113 / 8), _113 / 8); + _10._m0[_113] = _8.read(uint2(_117), 0); } static inline __attribute__((always_inline)) -float4 _98(float4 _119, texture2d _8, device _7& _10) +float4 _102(float4 _122, texture2d _8, device _7& _10) { - for (int _121 = 0; _121 < 64; _121++) + for (int _124 = 0; _124 < 64; _124++) { - _108(_121, _8, _10); + _112(_124, _8, _10); } - return _119; + return _122; } fragment main0_out main0(main0_in in [[stage_in]], device _7& _10 [[buffer(0)]], texture2d _8 [[texture(0)]]) { main0_out out = {}; - float4 _97 = _98(in.m_2, _8, _10); - out.m_3 = _97; + float4 _101 = _102(in.m_2, _8, _10); + out.m_3 = _101; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag index ee781a9671..6cf446fa90 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag @@ -21,26 +21,26 @@ struct main0_in }; static inline __attribute__((always_inline)) -void _108(int _109, texture2d _8, sampler _9, device _7& _10) +void _112(int _113, texture2d _8, sampler _9, device _7& _10) { - _10._m0[_109] = _8.sample(_9, (float2(int2(_109 - 8 * (_109 / 8), _109 / 8)) / float2(8.0)), level(0.0)); + _10._m0[_113] = _8.sample(_9, (float2(int2(_113 - 8 * (_113 / 8), _113 / 8)) / float2(8.0)), level(0.0)); } static inline __attribute__((always_inline)) -float4 _98(float4 _121, texture2d _8, sampler _9, device _7& _10) +float4 _102(float4 _124, texture2d _8, sampler _9, device _7& _10) { - for (int _123 = 0; _123 < 64; _123++) + for (int _126 = 0; _126 < 64; _126++) { - _108(_123, _8, _9, _10); + _112(_126, _8, _9, _10); } - return _121; + return _124; } fragment main0_out main0(main0_in in [[stage_in]], device _7& _10 [[buffer(0)]], texture2d _8 [[texture(0)]], sampler _9 [[sampler(0)]]) { main0_out out = {}; - float4 _97 = _98(in.m_2, _8, _9, _10); - out.m_3 = _97; + float4 _101 = _102(in.m_2, _8, _9, _10); + out.m_3 = _101; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag index 1870f67194..216e83bc2a 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag @@ -3,46 +3,46 @@ using namespace metal; -struct _4 +struct _6 { float4 _m0; }; -struct _6 +struct _8 { int _m0; }; -struct _7 +struct _9 { float4 _m0; }; struct main0_out { - float4 m_3 [[color(0)]]; + float4 m_4 [[color(0)]]; }; -fragment main0_out main0(const device _4* _5_0 [[buffer(0)]], const device _4* _5_1 [[buffer(1)]], const device _4* _5_2 [[buffer(2)]], const device _4* _5_3 [[buffer(3)]], constant _6& _20 [[buffer(4)]], constant _7* _8_0 [[buffer(5)]], constant _7* _8_1 [[buffer(6)]], constant _7* _8_2 [[buffer(7)]], constant _7* _8_3 [[buffer(8)]]) +fragment main0_out main0(const device _6* _7_0 [[buffer(0)]], const device _6* _7_1 [[buffer(1)]], const device _6* _7_2 [[buffer(2)]], const device _6* _7_3 [[buffer(3)]], constant _8& _21 [[buffer(4)]], constant _9* _10_0 [[buffer(5)]], constant _9* _10_1 [[buffer(6)]], constant _9* _10_2 [[buffer(7)]], constant _9* _10_3 [[buffer(8)]]) { - const device _4* _5[] = + const device _6* _7[] = { - _5_0, - _5_1, - _5_2, - _5_3, + _7_0, + _7_1, + _7_2, + _7_3, }; - constant _7* _8[] = + constant _9* _10[] = { - _8_0, - _8_1, - _8_2, - _8_3, + _10_0, + _10_1, + _10_2, + _10_3, }; main0_out out = {}; - out.m_3 = _5[_20._m0]->_m0 + (_8[_20._m0]->_m0 * float4(0.20000000298023223876953125)); + out.m_4 = _7[_21._m0]->_m0 + (_10[_21._m0]->_m0 * float4(0.20000000298023223876953125)); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag index d946104d8f..e4d32b81ce 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/extract-packed-from-composite.asm.frag @@ -29,21 +29,21 @@ struct main0_out }; static inline __attribute__((always_inline)) -float4 _main(thread const float4& pos, constant buf& _11) +float4 _main(thread const float4& pos, constant buf& _15) { - int _46 = int(pos.x) % 16; + int _32 = int(pos.x) % 16; Foo foo; - foo.a = float3(_11.results[_46].a); - foo.b = _11.results[_46].b; - return float4(dot(foo.a, _11.bar.xyz), foo.b, 0.0, 0.0); + foo.a = float3(_15.results[_32].a); + foo.b = _15.results[_32].b; + return float4(dot(foo.a, _15.bar.xyz), foo.b, 0.0, 0.0); } -fragment main0_out main0(constant buf& _11 [[buffer(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant buf& _15 [[buffer(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; float4 pos = gl_FragCoord; float4 param = pos; - out._entryPointOutput = _main(param, _11); + out._entryPointOutput = _main(param, _15); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag index 830df0c7e9..ffa5af2aba 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag @@ -18,20 +18,20 @@ fragment main0_out main0(main0_in in [[stage_in]], texture2d uImage [[tex main0_out out = {}; int i = 0; float phi; - float4 _36; + float4 _45; phi = 1.0; - _36 = float4(1.0, 2.0, 1.0, 2.0); + _45 = float4(1.0, 2.0, 1.0, 2.0); for (;;) { - out.FragColor = _36; + out.FragColor = _45; if (i < 4) { if (in.v0[i] > 0.0) { - float2 _48 = float2(phi); + float2 _43 = float2(phi); i++; phi += 2.0; - _36 = uImage.sample(uImageSmplr, _48, level(0.0)); + _45 = uImage.sample(uImageSmplr, _43, level(0.0)); continue; } else diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/locations-components.asm.frag index 2cebdec49f..f70015b82e 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/locations-components.asm.frag @@ -10,23 +10,23 @@ struct main0_out struct main0_in { - float2 m_2 [[user(locn1)]]; - float m_3 [[user(locn1_2)]]; - float m_4 [[user(locn2), flat]]; - uint m_5 [[user(locn2_1)]]; - uint m_6 [[user(locn2_2)]]; + float2 m_8 [[user(locn1)]]; + float m_16 [[user(locn1_2)]]; + float m_22 [[user(locn2), flat]]; + uint m_28 [[user(locn2_1)]]; + uint m_33 [[user(locn2_2)]]; }; fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; float4 v1; - v1 = float4(in.m_2.x, in.m_2.y, v1.z, v1.w); - v1.z = in.m_3; + v1 = float4(in.m_8.x, in.m_8.y, v1.z, v1.w); + v1.z = in.m_16; float4 v2; - v2.x = in.m_4; - v2.y = as_type(in.m_5); - v2.z = as_type(in.m_6); + v2.x = in.m_22; + v2.y = as_type(in.m_28); + v2.z = as_type(in.m_33); float4 r0; r0.x = as_type(as_type(v2.y) + as_type(v2.z)); out.o0.y = float(as_type(r0.x)); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag index 41193536e6..002ffae4ca 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/lut-promotion-initializer.asm.frag @@ -44,9 +44,9 @@ struct spvUnsafeArray } }; -constant spvUnsafeArray _46 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 }); -constant spvUnsafeArray _76 = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); -constant spvUnsafeArray _90 = spvUnsafeArray({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) }); +constant spvUnsafeArray _16 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 }); +constant spvUnsafeArray _60 = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); +constant spvUnsafeArray _104 = spvUnsafeArray({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) }); struct main0_out { @@ -63,29 +63,29 @@ fragment main0_out main0(main0_in in [[stage_in]]) spvUnsafeArray foobar = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); spvUnsafeArray baz = spvUnsafeArray({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); main0_out out = {}; - out.FragColor = _46[in.index]; + out.FragColor = _16[in.index]; if (in.index < 10) { - out.FragColor += _46[in.index ^ 1]; + out.FragColor += _16[in.index ^ 1]; } else { - out.FragColor += _46[in.index & 1]; + out.FragColor += _16[in.index & 1]; } if (in.index > 30) { - out.FragColor += _76[in.index & 3].y; + out.FragColor += _60[in.index & 3].y; } else { - out.FragColor += _76[in.index & 1].x; + out.FragColor += _60[in.index & 1].x; } if (in.index > 30) { foobar[1].z = 20.0; } out.FragColor += foobar[in.index & 3].z; - baz = _90; + baz = _104; out.FragColor += baz[in.index & 3].z; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag index f8104f8165..e0037589fc 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/op-constant-null.asm.frag @@ -50,7 +50,7 @@ struct D float b; }; -constant spvUnsafeArray _14 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _41 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); struct main0_out { diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag index 036774d661..18c275fb82 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/phi-loop-variable.asm.frag @@ -5,7 +5,7 @@ using namespace metal; fragment void main0() { - for (int _22 = 35; _22 >= 0; _22--) + for (int _58 = 35; _58 >= 0; _58--) { } } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag index 2cefeb6693..5e240883e9 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/undef-variable-store.asm.frag @@ -3,8 +3,8 @@ using namespace metal; -constant float4 _38 = {}; -constant float4 _47 = {}; +constant float4 _48 = {}; +constant float4 _31 = {}; struct main0_out { @@ -14,24 +14,24 @@ struct main0_out fragment main0_out main0() { main0_out out = {}; - float4 _27; + float4 _37; do { - float2 _26 = float2(0.0); - if (_26.x != 0.0) + float2 _35 = float2(0.0); + if (_35.x != 0.0) { - _27 = float4(1.0, 0.0, 0.0, 1.0); + _37 = float4(1.0, 0.0, 0.0, 1.0); break; } else { - _27 = float4(1.0, 1.0, 0.0, 1.0); + _37 = float4(1.0, 1.0, 0.0, 1.0); break; } - _27 = _38; + _37 = _48; break; } while (false); - out._entryPointOutput = _27; + out._entryPointOutput = _37; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/unreachable.asm.frag index 7ae4aa5e60..93b92a01fc 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/unreachable.asm.frag @@ -3,7 +3,7 @@ using namespace metal; -constant float4 _21 = {}; +constant float4 _44 = {}; struct main0_out { @@ -18,23 +18,23 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]]) { main0_out out = {}; - float4 _24; - _24 = _21; - float4 _33; + float4 _45; + _45 = _44; + float4 _46; for (;;) { if (in.counter == 10) { - _33 = float4(10.0); + _46 = float4(10.0); break; } else { - _33 = float4(30.0); + _46 = float4(30.0); break; } } - out.FragColor = _33; + out.FragColor = _46; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 9e73be477a..b4f4066012 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -3,19 +3,19 @@ using namespace metal; -struct _28 +struct _15 { float4 _m0; }; -struct _6 +struct _3 { float4 _m0; float _m1; float4 _m2; }; -struct _10 +struct _4 { float3 _m0; packed_float3 _m1; @@ -44,7 +44,7 @@ struct _10 float4 _m24; }; -struct _18 +struct _7 { float4x4 _m0; float4x4 _m1; @@ -88,7 +88,7 @@ struct _18 float4 _m38[2]; }; -struct _20 +struct _8 { float4 _m0; float4 _m1; @@ -113,224 +113,224 @@ struct _20 float2 _m20; }; -struct _21 +struct _9 { float4 _m0; }; -constant _28 _74 = {}; +constant _15 _10264 = {}; struct main0_out { - float4 m_5 [[color(0)]]; + float4 m_4317 [[color(0)]]; }; -fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant _3& _22044 [[buffer(0)]], constant _4& _12348 [[buffer(1)]], constant _7& _15259 [[buffer(2)]], texture2d _5785 [[texture(0)]], texture2d _3312 [[texture(1)]], texture2d _4862 [[texture(2)]], sampler _5688 [[sampler(0)]], sampler _4646 [[sampler(1)]], sampler _3594 [[sampler(2)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - _28 _77; - _77._m0 = float4(0.0); - float2 _82 = gl_FragCoord.xy * _19._m23.xy; - float4 _88 = _7._m2 * _7._m0.xyxy; - float2 _97 = fast::clamp(_82 + (float3(0.0, -2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _109 = float3(_11._m5) * fast::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) + _15 _13863; + _13863._m0 = float4(0.0); + float2 _19927 = gl_FragCoord.xy * _15259._m23.xy; + float4 _17581 = _22044._m2 * _22044._m0.xyxy; + float2 _13149 = fast::clamp(_19927 + (float3(0.0, -2.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12103 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13149, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17670 = _3312.sample(_4646, _13149, level(0.0)); + float3 _7719; + if (_17670.y > 0.0) { - _129 = _109 + (_14.sample(_15, _97, level(0.0)).xyz * fast::clamp(_113.y * _113.z, 0.0, 1.0)); + _7719 = _12103 + (_4862.sample(_3594, _13149, level(0.0)).xyz * fast::clamp(_17670.y * _17670.z, 0.0, 1.0)); } else { - _129 = _109; + _7719 = _12103; } - float3 _133 = float4(0.0).xyz + (_129 * 0.5); - float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); - _77._m0 = _134; - float2 _144 = fast::clamp(_82 + (float3(-1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _156 = float3(_11._m5) * fast::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) + float3 _22177 = float4(0.0).xyz + (_7719 * 0.5); + float4 _15527 = float4(_22177.x, _22177.y, _22177.z, float4(0.0).w); + _13863._m0 = _15527; + float2 _13150 = fast::clamp(_19927 + (float3(-1.0, -1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12104 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13150, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17671 = _3312.sample(_4646, _13150, level(0.0)); + float3 _7720; + if (_17671.y > 0.0) { - _176 = _156 + (_14.sample(_15, _144, level(0.0)).xyz * fast::clamp(_160.y * _160.z, 0.0, 1.0)); + _7720 = _12104 + (_4862.sample(_3594, _13150, level(0.0)).xyz * fast::clamp(_17671.y * _17671.z, 0.0, 1.0)); } else { - _176 = _156; + _7720 = _12104; } - float3 _180 = _134.xyz + (_176 * 0.5); - float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); - _77._m0 = _181; - float2 _191 = fast::clamp(_82 + (float3(0.0, -1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _203 = float3(_11._m5) * fast::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) + float3 _22178 = _15527.xyz + (_7720 * 0.5); + float4 _15528 = float4(_22178.x, _22178.y, _22178.z, _15527.w); + _13863._m0 = _15528; + float2 _13151 = fast::clamp(_19927 + (float3(0.0, -1.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12105 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13151, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17672 = _3312.sample(_4646, _13151, level(0.0)); + float3 _7721; + if (_17672.y > 0.0) { - _223 = _203 + (_14.sample(_15, _191, level(0.0)).xyz * fast::clamp(_207.y * _207.z, 0.0, 1.0)); + _7721 = _12105 + (_4862.sample(_3594, _13151, level(0.0)).xyz * fast::clamp(_17672.y * _17672.z, 0.0, 1.0)); } else { - _223 = _203; + _7721 = _12105; } - float3 _227 = _181.xyz + (_223 * 0.75); - float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); - _77._m0 = _228; - float2 _238 = fast::clamp(_82 + (float3(1.0, -1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _250 = float3(_11._m5) * fast::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) + float3 _22179 = _15528.xyz + (_7721 * 0.75); + float4 _15529 = float4(_22179.x, _22179.y, _22179.z, _15528.w); + _13863._m0 = _15529; + float2 _13152 = fast::clamp(_19927 + (float3(1.0, -1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12106 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13152, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17673 = _3312.sample(_4646, _13152, level(0.0)); + float3 _7722; + if (_17673.y > 0.0) { - _270 = _250 + (_14.sample(_15, _238, level(0.0)).xyz * fast::clamp(_254.y * _254.z, 0.0, 1.0)); + _7722 = _12106 + (_4862.sample(_3594, _13152, level(0.0)).xyz * fast::clamp(_17673.y * _17673.z, 0.0, 1.0)); } else { - _270 = _250; + _7722 = _12106; } - float3 _274 = _228.xyz + (_270 * 0.5); - float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); - _77._m0 = _275; - float2 _285 = fast::clamp(_82 + (float3(-2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _297 = float3(_11._m5) * fast::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) + float3 _22180 = _15529.xyz + (_7722 * 0.5); + float4 _15530 = float4(_22180.x, _22180.y, _22180.z, _15529.w); + _13863._m0 = _15530; + float2 _13153 = fast::clamp(_19927 + (float3(-2.0, 0.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12107 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13153, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17674 = _3312.sample(_4646, _13153, level(0.0)); + float3 _7723; + if (_17674.y > 0.0) { - _317 = _297 + (_14.sample(_15, _285, level(0.0)).xyz * fast::clamp(_301.y * _301.z, 0.0, 1.0)); + _7723 = _12107 + (_4862.sample(_3594, _13153, level(0.0)).xyz * fast::clamp(_17674.y * _17674.z, 0.0, 1.0)); } else { - _317 = _297; + _7723 = _12107; } - float3 _321 = _275.xyz + (_317 * 0.5); - float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); - _77._m0 = _322; - float2 _332 = fast::clamp(_82 + (float3(-1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _344 = float3(_11._m5) * fast::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) + float3 _22181 = _15530.xyz + (_7723 * 0.5); + float4 _15531 = float4(_22181.x, _22181.y, _22181.z, _15530.w); + _13863._m0 = _15531; + float2 _13154 = fast::clamp(_19927 + (float3(-1.0, 0.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12108 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13154, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17675 = _3312.sample(_4646, _13154, level(0.0)); + float3 _7724; + if (_17675.y > 0.0) { - _364 = _344 + (_14.sample(_15, _332, level(0.0)).xyz * fast::clamp(_348.y * _348.z, 0.0, 1.0)); + _7724 = _12108 + (_4862.sample(_3594, _13154, level(0.0)).xyz * fast::clamp(_17675.y * _17675.z, 0.0, 1.0)); } else { - _364 = _344; + _7724 = _12108; } - float3 _368 = _322.xyz + (_364 * 0.75); - float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); - _77._m0 = _369; - float2 _379 = fast::clamp(_82 + (float3(0.0, 0.0, 1.0).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _391 = float3(_11._m5) * fast::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) + float3 _22182 = _15531.xyz + (_7724 * 0.75); + float4 _15532 = float4(_22182.x, _22182.y, _22182.z, _15531.w); + _13863._m0 = _15532; + float2 _13155 = fast::clamp(_19927 + (float3(0.0, 0.0, 1.0).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12109 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13155, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17676 = _3312.sample(_4646, _13155, level(0.0)); + float3 _7725; + if (_17676.y > 0.0) { - _411 = _391 + (_14.sample(_15, _379, level(0.0)).xyz * fast::clamp(_395.y * _395.z, 0.0, 1.0)); + _7725 = _12109 + (_4862.sample(_3594, _13155, level(0.0)).xyz * fast::clamp(_17676.y * _17676.z, 0.0, 1.0)); } else { - _411 = _391; + _7725 = _12109; } - float3 _415 = _369.xyz + (_411 * 1.0); - float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); - _77._m0 = _416; - float2 _426 = fast::clamp(_82 + (float3(1.0, 0.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _438 = float3(_11._m5) * fast::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) + float3 _22183 = _15532.xyz + (_7725 * 1.0); + float4 _15533 = float4(_22183.x, _22183.y, _22183.z, _15532.w); + _13863._m0 = _15533; + float2 _13156 = fast::clamp(_19927 + (float3(1.0, 0.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12110 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13156, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17677 = _3312.sample(_4646, _13156, level(0.0)); + float3 _7726; + if (_17677.y > 0.0) { - _458 = _438 + (_14.sample(_15, _426, level(0.0)).xyz * fast::clamp(_442.y * _442.z, 0.0, 1.0)); + _7726 = _12110 + (_4862.sample(_3594, _13156, level(0.0)).xyz * fast::clamp(_17677.y * _17677.z, 0.0, 1.0)); } else { - _458 = _438; + _7726 = _12110; } - float3 _462 = _416.xyz + (_458 * 0.75); - float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); - _77._m0 = _463; - float2 _473 = fast::clamp(_82 + (float3(2.0, 0.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _485 = float3(_11._m5) * fast::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) + float3 _22184 = _15533.xyz + (_7726 * 0.75); + float4 _15534 = float4(_22184.x, _22184.y, _22184.z, _15533.w); + _13863._m0 = _15534; + float2 _13157 = fast::clamp(_19927 + (float3(2.0, 0.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12111 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13157, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17678 = _3312.sample(_4646, _13157, level(0.0)); + float3 _7727; + if (_17678.y > 0.0) { - _505 = _485 + (_14.sample(_15, _473, level(0.0)).xyz * fast::clamp(_489.y * _489.z, 0.0, 1.0)); + _7727 = _12111 + (_4862.sample(_3594, _13157, level(0.0)).xyz * fast::clamp(_17678.y * _17678.z, 0.0, 1.0)); } else { - _505 = _485; + _7727 = _12111; } - float3 _509 = _463.xyz + (_505 * 0.5); - float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); - _77._m0 = _510; - float2 _520 = fast::clamp(_82 + (float3(-1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _532 = float3(_11._m5) * fast::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) + float3 _22185 = _15534.xyz + (_7727 * 0.5); + float4 _15535 = float4(_22185.x, _22185.y, _22185.z, _15534.w); + _13863._m0 = _15535; + float2 _13158 = fast::clamp(_19927 + (float3(-1.0, 1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12112 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13158, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17679 = _3312.sample(_4646, _13158, level(0.0)); + float3 _7728; + if (_17679.y > 0.0) { - _552 = _532 + (_14.sample(_15, _520, level(0.0)).xyz * fast::clamp(_536.y * _536.z, 0.0, 1.0)); + _7728 = _12112 + (_4862.sample(_3594, _13158, level(0.0)).xyz * fast::clamp(_17679.y * _17679.z, 0.0, 1.0)); } else { - _552 = _532; + _7728 = _12112; } - float3 _556 = _510.xyz + (_552 * 0.5); - float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); - _77._m0 = _557; - float2 _567 = fast::clamp(_82 + (float3(0.0, 1.0, 0.75).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _579 = float3(_11._m5) * fast::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) + float3 _22186 = _15535.xyz + (_7728 * 0.5); + float4 _15536 = float4(_22186.x, _22186.y, _22186.z, _15535.w); + _13863._m0 = _15536; + float2 _13159 = fast::clamp(_19927 + (float3(0.0, 1.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12113 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13159, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17680 = _3312.sample(_4646, _13159, level(0.0)); + float3 _7729; + if (_17680.y > 0.0) { - _599 = _579 + (_14.sample(_15, _567, level(0.0)).xyz * fast::clamp(_583.y * _583.z, 0.0, 1.0)); + _7729 = _12113 + (_4862.sample(_3594, _13159, level(0.0)).xyz * fast::clamp(_17680.y * _17680.z, 0.0, 1.0)); } else { - _599 = _579; + _7729 = _12113; } - float3 _603 = _557.xyz + (_599 * 0.75); - float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); - _77._m0 = _604; - float2 _614 = fast::clamp(_82 + (float3(1.0, 1.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _626 = float3(_11._m5) * fast::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) + float3 _22187 = _15536.xyz + (_7729 * 0.75); + float4 _15537 = float4(_22187.x, _22187.y, _22187.z, _15536.w); + _13863._m0 = _15537; + float2 _13160 = fast::clamp(_19927 + (float3(1.0, 1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12114 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13160, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17681 = _3312.sample(_4646, _13160, level(0.0)); + float3 _7730; + if (_17681.y > 0.0) { - _646 = _626 + (_14.sample(_15, _614, level(0.0)).xyz * fast::clamp(_630.y * _630.z, 0.0, 1.0)); + _7730 = _12114 + (_4862.sample(_3594, _13160, level(0.0)).xyz * fast::clamp(_17681.y * _17681.z, 0.0, 1.0)); } else { - _646 = _626; + _7730 = _12114; } - float3 _650 = _604.xyz + (_646 * 0.5); - float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); - _77._m0 = _651; - float2 _661 = fast::clamp(_82 + (float3(0.0, 2.0, 0.5).xy * _7._m0.xy), _88.xy, _88.zw); - float3 _673 = float3(_11._m5) * fast::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) + float3 _22188 = _15537.xyz + (_7730 * 0.5); + float4 _15539 = float4(_22188.x, _22188.y, _22188.z, _15537.w); + _13863._m0 = _15539; + float2 _13161 = fast::clamp(_19927 + (float3(0.0, 2.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + float3 _12115 = float3(_12348._m5) * fast::clamp(_5785.sample(_5688, _13161, level(0.0)).w * _22044._m1, 0.0, 1.0); + float4 _17682 = _3312.sample(_4646, _13161, level(0.0)); + float3 _7731; + if (_17682.y > 0.0) { - _693 = _673 + (_14.sample(_15, _661, level(0.0)).xyz * fast::clamp(_677.y * _677.z, 0.0, 1.0)); + _7731 = _12115 + (_4862.sample(_3594, _13161, level(0.0)).xyz * fast::clamp(_17682.y * _17682.z, 0.0, 1.0)); } else { - _693 = _673; + _7731 = _12115; } - float3 _697 = _651.xyz + (_693 * 0.5); - float4 _698 = float4(_697.x, _697.y, _697.z, _651.w); - _77._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); - _77._m0 = float4(_702.x, _702.y, _702.z, _698.w); - _77._m0.w = 1.0; - out.m_5 = _77._m0; + float3 _22189 = _15539.xyz + (_7731 * 0.5); + float4 _15541 = float4(_22189.x, _22189.y, _22189.z, _15539.w); + _13863._m0 = _15541; + float3 _13750 = _15541.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); + _13863._m0 = float4(_13750.x, _13750.y, _13750.z, _15541.w); + _13863._m0.w = 1.0; + out.m_4317 = _13863._m0; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/vert/invariant.msl21.asm.vert b/third_party/spirv-cross/reference/shaders-msl/asm/vert/invariant.msl21.asm.vert index d74c43b3f0..5272bdc12b 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/vert/invariant.msl21.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl/asm/vert/invariant.msl21.asm.vert @@ -19,8 +19,8 @@ float4 _main() vertex main0_out main0() { main0_out out = {}; - float4 _14 = _main(); - out.gl_Position = _14; + float4 _17 = _main(); + out.gl_Position = _17; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert b/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert index 1926ff9e14..a0f383c9e9 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool-to-uint.asm.vert @@ -25,11 +25,11 @@ struct main0_in float4 a_position [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _9 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) +vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _11 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; - out.gl_Position = _9.umatrix * float4(_9.uquad[int(gl_VertexIndex)].x, _9.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); - if (_9.flags.flags[0] != 0u) + out.gl_Position = _11.umatrix * float4(_11.uquad[int(gl_VertexIndex)].x, _11.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); + if (_11.flags.flags[0] != 0u) { out.gl_Position.z = 0.0; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert b/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert index ee20638574..4d137ebf1f 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl/asm/vert/packed-bool2-to-packed_uint2.asm.vert @@ -25,11 +25,11 @@ struct main0_in float4 a_position [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _9 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) +vertex main0_out main0(main0_in in [[stage_in]], constant defaultUniformsVS& _11 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; - out.gl_Position = _9.umatrix * float4(_9.uquad[int(gl_VertexIndex)].x, _9.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); - if (_9.flags.flags[0].x != 0u) + out.gl_Position = _11.umatrix * float4(_11.uquad[int(gl_VertexIndex)].x, _11.uquad[int(gl_VertexIndex)].y, in.a_position.z, in.a_position.w); + if (_11.flags.flags[0].x != 0u) { out.gl_Position.z = 0.0; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert b/third_party/spirv-cross/reference/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert index 074a47a652..cbfb409ded 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl/asm/vert/spec-constant-op-composite.asm.vert @@ -16,23 +16,23 @@ template::H> return F(hval); } -constant int _7_tmp [[function_constant(201)]]; -constant int _7 = is_function_constant_defined(_7_tmp) ? _7_tmp : -10; -constant int _20 = (_7 + 2); -constant uint _8_tmp [[function_constant(202)]]; -constant uint _8 = is_function_constant_defined(_8_tmp) ? _8_tmp : 100u; -constant uint _25 = (_8 % 5u); -constant int _30 = _7 - (-3) * (_7 / (-3)); -constant int4 _32 = int4(20, 30, _20, _30); -constant int2 _34 = int2(_32.y, _32.x); -constant int _35 = _32.y; -constant float _9_tmp [[function_constant(200)]]; -constant float _9 = is_function_constant_defined(_9_tmp) ? _9_tmp : 3.141590118408203125; -constant float _41 = spvQuantizeToF16(_9); +constant int _13_tmp [[function_constant(201)]]; +constant int _13 = is_function_constant_defined(_13_tmp) ? _13_tmp : -10; +constant int _15 = (_13 + 2); +constant uint _24_tmp [[function_constant(202)]]; +constant uint _24 = is_function_constant_defined(_24_tmp) ? _24_tmp : 100u; +constant uint _26 = (_24 % 5u); +constant int _61 = _13 - (-3) * (_13 / (-3)); +constant int4 _36 = int4(20, 30, _15, _61); +constant int2 _41 = int2(_36.y, _36.x); +constant int _62 = _36.y; +constant float _57_tmp [[function_constant(200)]]; +constant float _57 = is_function_constant_defined(_57_tmp) ? _57_tmp : 3.141590118408203125; +constant float _63 = spvQuantizeToF16(_57); struct main0_out { - int m_4 [[user(locn0)]]; + int m_58 [[user(locn0)]]; float4 gl_Position [[position]]; }; @@ -40,13 +40,13 @@ vertex main0_out main0() { main0_out out = {}; float4 pos = float4(0.0); - pos.y += float(_20); - pos.z += float(_25); - pos += float4(_32); - float2 _59 = pos.xy + float2(_34); - pos = float4(_59.x, _59.y, pos.z, pos.w); + pos.y += float(_15); + pos.z += float(_26); + pos += float4(_36); + float2 _46 = pos.xy + float2(_41); + pos = float4(_46.x, _46.y, pos.z, pos.w); out.gl_Position = pos; - out.m_4 = _35; + out.m_58 = _62; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..fc3df7ffcd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,83 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +struct UBO +{ + float4 v[1024]; +}; + +struct UBOs +{ + float4 v; +}; + +struct SSBOIn +{ + float4 v[1024]; +}; + +struct SSBOIns +{ + float4 v; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* o [[id(0)]]; + constant UBO* v [[id(1)]]; + spvDescriptor vs [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + device SSBOIn* w [[id(0)]]; + spvDescriptor ws [[id(1)]][1] /* unsized array hack */; +}; + +static inline __attribute__((always_inline)) +void in_func(device SSBO& o, thread uint3& gl_GlobalInvocationID, constant UBO& v, thread uint3& gl_WorkGroupID, const spvDescriptorArray vs, device SSBOIn& w, const spvDescriptorArray ws) +{ + o.v[gl_GlobalInvocationID.x] = v.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x]->v; + o.v[gl_GlobalInvocationID.x] = w.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x]->v; +} + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray vs {spvDescriptorSet0.vs}; + spvDescriptorArray ws {spvDescriptorSet1.ws}; + + in_func((*spvDescriptorSet0.o), gl_GlobalInvocationID, (*spvDescriptorSet0.v), gl_WorkGroupID, vs, (*spvDescriptorSet1.w), ws); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..db7c7e921e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,115 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +struct UBO +{ + float4 v[1024]; +}; + +struct UBOs +{ + float4 v; +}; + +struct SSBOIn +{ + float4 v[1024]; +}; + +struct SSBOIns +{ + float4 v; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* o [[id(0)]]; + constant UBO* v [[id(1)]]; + spvDescriptor vs [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + device SSBOIn* w [[id(0)]]; + spvBufferDescriptor ws [[id(1)]][1] /* unsized array hack */; +}; + +static inline __attribute__((always_inline)) +void in_func(device SSBO& o, thread uint3& gl_GlobalInvocationID, constant UBO& v, thread uint3& gl_WorkGroupID, const spvDescriptorArray vs, device SSBOIn& w, const spvDescriptorArray ws) +{ + o.v[gl_GlobalInvocationID.x] = v.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x]->v; + o.v[gl_GlobalInvocationID.x] = w.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x]->v; +} + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray vs {spvDescriptorSet0.vs}; + spvDescriptorArray ws {spvDescriptorSet1.ws}; + + in_func((*spvDescriptorSet0.o), gl_GlobalInvocationID, (*spvDescriptorSet0.v), gl_WorkGroupID, vs, (*spvDescriptorSet1.w), ws); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..7ff6cd77cd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,61 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +struct SSBO +{ + float4 v[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct spvDescriptorSetBuffer0 +{ + device SSBO* m_13 [[id(0)]]; + texture2d T [[id(1)]]; + spvDescriptor> Ts [[id(2)]][1] /* unsized array hack */; +}; + +struct spvDescriptorSetBuffer1 +{ + sampler S [[id(0)]]; + spvDescriptor Ss [[id(1)]][1] /* unsized array hack */; +}; + +static inline __attribute__((always_inline)) +void in_func(device SSBO& _13, thread uint3& gl_GlobalInvocationID, texture2d T, sampler S, const spvDescriptorArray> Ts, thread uint3& gl_WorkGroupID, const spvDescriptorArray Ss) +{ + _13.v[gl_GlobalInvocationID.x] = T.sample(S, float2(0.5), level(0.0)); + _13.v[gl_GlobalInvocationID.x] = Ts[gl_WorkGroupID.x].sample(Ss[gl_WorkGroupID.x], float2(0.5), level(0.0)); +} + +kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], const device spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + spvDescriptorArray> Ts {spvDescriptorSet0.Ts}; + spvDescriptorArray Ss {spvDescriptorSet1.Ss}; + + in_func((*spvDescriptorSet0.m_13), gl_GlobalInvocationID, spvDescriptorSet0.T, spvDescriptorSet1.S, Ts, gl_WorkGroupID, Ss); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.comp b/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.comp new file mode 100644 index 0000000000..466afa3d2c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.comp @@ -0,0 +1,75 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +struct SSBO +{ + uint u32; + int i32; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device SSBO& ssbo [[buffer(2)]], texture2d uImage [[texture(0)]], device atomic_uint* uImage_atomic [[buffer(0)]], texture2d iImage [[texture(1)]], device atomic_int* iImage_atomic [[buffer(1)]]) +{ + uint _19 = atomic_fetch_add_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _27 = atomic_fetch_add_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + iImage.write(int4(int(_27)), uint2(int2(1, 6))); + uint _32 = atomic_fetch_or_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _34 = atomic_fetch_xor_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _36 = atomic_fetch_and_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _38 = atomic_fetch_min_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _40 = atomic_fetch_max_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], 1u, memory_order_relaxed); + uint _44; + do + { + _44 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(1, 5), uImage)], &_44, 2u, memory_order_relaxed, memory_order_relaxed) && _44 == 10u); + int _47 = atomic_fetch_add_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _49 = atomic_fetch_or_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _51 = atomic_fetch_xor_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _53 = atomic_fetch_and_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _55 = atomic_fetch_min_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _57 = atomic_fetch_max_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 6), iImage)], 1, memory_order_relaxed); + int _61; + do + { + _61 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&iImage_atomic[spvImage2DAtomicCoord(int2(1, 5), iImage)], &_61, 2, memory_order_relaxed, memory_order_relaxed) && _61 == 10); + uint _68 = atomic_fetch_add_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _70 = atomic_fetch_or_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _72 = atomic_fetch_xor_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _74 = atomic_fetch_and_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _76 = atomic_fetch_min_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _78 = atomic_fetch_max_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _80 = atomic_exchange_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _82; + do + { + _82 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&ssbo.u32, &_82, 2u, memory_order_relaxed, memory_order_relaxed) && _82 == 10u); + int _85 = atomic_fetch_add_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _87 = atomic_fetch_or_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _89 = atomic_fetch_xor_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _91 = atomic_fetch_and_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _93 = atomic_fetch_min_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _95 = atomic_fetch_max_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _97 = atomic_exchange_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _99; + do + { + _99 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&ssbo.i32, &_99, 2, memory_order_relaxed, memory_order_relaxed) && _99 == 10); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.msl31.comp b/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.msl31.comp new file mode 100644 index 0000000000..1fefb3a7ee --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/atomic-image.msl31.comp @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + uint u32; + int i32; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device SSBO& ssbo [[buffer(0)]], texture2d uImage [[texture(0)]], texture2d iImage [[texture(1)]]) +{ + uint _19 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x; + uint _27 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x; + iImage.write(int4(int(_27)), uint2(int2(1, 6))); + uint _32 = uImage.atomic_fetch_or(uint2(int2(1, 5)), 1u).x; + uint _34 = uImage.atomic_fetch_xor(uint2(int2(1, 5)), 1u).x; + uint _36 = uImage.atomic_fetch_and(uint2(int2(1, 5)), 1u).x; + uint _38 = uImage.atomic_fetch_min(uint2(int2(1, 5)), 1u).x; + uint _40 = uImage.atomic_fetch_max(uint2(int2(1, 5)), 1u).x; + uint _44; + uint4 _102; + do + { + _102.x = 10u; + } while (!uImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_102, 2u) && _102.x == 10u); + _44 = _102.x; + int _47 = iImage.atomic_fetch_add(uint2(int2(1, 6)), 1).x; + int _49 = iImage.atomic_fetch_or(uint2(int2(1, 6)), 1).x; + int _51 = iImage.atomic_fetch_xor(uint2(int2(1, 6)), 1).x; + int _53 = iImage.atomic_fetch_and(uint2(int2(1, 6)), 1).x; + int _55 = iImage.atomic_fetch_min(uint2(int2(1, 6)), 1).x; + int _57 = iImage.atomic_fetch_max(uint2(int2(1, 6)), 1).x; + int _61; + int4 _104; + do + { + _104.x = 10; + } while (!iImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_104, 2) && _104.x == 10); + _61 = _104.x; + uint _68 = atomic_fetch_add_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _70 = atomic_fetch_or_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _72 = atomic_fetch_xor_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _74 = atomic_fetch_and_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _76 = atomic_fetch_min_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _78 = atomic_fetch_max_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _80 = atomic_exchange_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed); + uint _82; + do + { + _82 = 10u; + } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&ssbo.u32, &_82, 2u, memory_order_relaxed, memory_order_relaxed) && _82 == 10u); + int _85 = atomic_fetch_add_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _87 = atomic_fetch_or_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _89 = atomic_fetch_xor_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _91 = atomic_fetch_and_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _93 = atomic_fetch_min_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _95 = atomic_fetch_max_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _97 = atomic_exchange_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed); + int _99; + do + { + _99 = 10; + } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&ssbo.i32, &_99, 2, memory_order_relaxed, memory_order_relaxed) && _99 == 10); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.comp b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.comp new file mode 100644 index 0000000000..cedcec2ea1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.comp @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +static inline __attribute__((always_inline)) +void SPD_IncreaseAtomicCounter(thread uint& spdCounter, texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint _25 = atomic_fetch_add_explicit((volatile device atomic_uint*)&rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), rw_spd_global_atomic)], 1u, memory_order_relaxed); + spdCounter = _25; +} + +static inline __attribute__((always_inline)) +void ComputeAutoExposure(texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint v = 0u; + uint param = v; + SPD_IncreaseAtomicCounter(param, rw_spd_global_atomic, rw_spd_global_atomic_atomic); + v = param; +} + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]], volatile device atomic_uint* rw_spd_global_atomic_atomic [[buffer(0)]]) +{ + ComputeAutoExposure(rw_spd_global_atomic, rw_spd_global_atomic_atomic); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp new file mode 100644 index 0000000000..a43dd40930 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp @@ -0,0 +1,44 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +struct spvDescriptorSetBuffer1 +{ + texture2d rw_spd_global_atomic [[id(0)]]; + volatile device atomic_uint* rw_spd_global_atomic_atomic [[id(1)]]; +}; + +static inline __attribute__((always_inline)) +void SPD_IncreaseAtomicCounter(thread uint& spdCounter, texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint _25 = atomic_fetch_add_explicit((volatile device atomic_uint*)&rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), rw_spd_global_atomic)], 1u, memory_order_relaxed); + spdCounter = _25; +} + +static inline __attribute__((always_inline)) +void ComputeAutoExposure(texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint v = 0u; + uint param = v; + SPD_IncreaseAtomicCounter(param, rw_spd_global_atomic, rw_spd_global_atomic_atomic); + v = param; +} + +kernel void main0(constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]]) +{ + ComputeAutoExposure(spvDescriptorSet1.rw_spd_global_atomic, spvDescriptorSet1.rw_spd_global_atomic_atomic); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.comp b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.comp new file mode 100644 index 0000000000..cedcec2ea1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl2.comp @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +// The required alignment of a linear texture of R32Uint format. +constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]]; +constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4; +// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics +#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x) + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +static inline __attribute__((always_inline)) +void SPD_IncreaseAtomicCounter(thread uint& spdCounter, texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint _25 = atomic_fetch_add_explicit((volatile device atomic_uint*)&rw_spd_global_atomic_atomic[spvImage2DAtomicCoord(int2(0), rw_spd_global_atomic)], 1u, memory_order_relaxed); + spdCounter = _25; +} + +static inline __attribute__((always_inline)) +void ComputeAutoExposure(texture2d rw_spd_global_atomic, volatile device atomic_uint* rw_spd_global_atomic_atomic) +{ + uint v = 0u; + uint param = v; + SPD_IncreaseAtomicCounter(param, rw_spd_global_atomic, rw_spd_global_atomic_atomic); + v = param; +} + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]], volatile device atomic_uint* rw_spd_global_atomic_atomic [[buffer(0)]]) +{ + ComputeAutoExposure(rw_spd_global_atomic, rw_spd_global_atomic_atomic); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp new file mode 100644 index 0000000000..6dbe69cfd3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp @@ -0,0 +1,37 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +struct spvDescriptorSetBuffer1 +{ + texture2d rw_spd_global_atomic [[id(0)]]; +}; + +static inline __attribute__((always_inline)) +void SPD_IncreaseAtomicCounter(thread uint& spdCounter, texture2d rw_spd_global_atomic) +{ + uint _25 = rw_spd_global_atomic.atomic_fetch_add(uint2(int2(0)), 1u).x; + spdCounter = _25; +} + +static inline __attribute__((always_inline)) +void ComputeAutoExposure(texture2d rw_spd_global_atomic) +{ + uint v = 0u; + uint param = v; + SPD_IncreaseAtomicCounter(param, rw_spd_global_atomic); + v = param; +} + +kernel void main0(constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]]) +{ + ComputeAutoExposure(spvDescriptorSet1.rw_spd_global_atomic); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.comp b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.comp new file mode 100644 index 0000000000..81bad9a893 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/coherent-image-atomic.msl31.comp @@ -0,0 +1,32 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(256u, 1u, 1u); + +static inline __attribute__((always_inline)) +void SPD_IncreaseAtomicCounter(thread uint& spdCounter, texture2d rw_spd_global_atomic) +{ + uint _25 = rw_spd_global_atomic.atomic_fetch_add(uint2(int2(0)), 1u).x; + spdCounter = _25; +} + +static inline __attribute__((always_inline)) +void ComputeAutoExposure(texture2d rw_spd_global_atomic) +{ + uint v = 0u; + uint param = v; + SPD_IncreaseAtomicCounter(param, rw_spd_global_atomic); + v = param; +} + +kernel void main0(texture2d rw_spd_global_atomic [[texture(0)]]) +{ + ComputeAutoExposure(rw_spd_global_atomic); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/complex-type-alias.comp b/third_party/spirv-cross/reference/shaders-msl/comp/complex-type-alias.comp index fc0d57500b..982ee87ff6 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/complex-type-alias.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/complex-type-alias.comp @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct Foo0 { float a; @@ -52,7 +91,7 @@ void Zero(thread Foo0& v) kernel void main0(device SSBO& _53 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) { - threadgroup Foo2 coeffs[64]; + threadgroup spvUnsafeArray coeffs; Foo2 data; data.weight = 0.0; Foo0 param; diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/functions.comp b/third_party/spirv-cross/reference/shaders-msl/comp/functions.comp index b107260878..f6d4e23f63 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/functions.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/functions.comp @@ -1,19 +1,58 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + static inline __attribute__((always_inline)) -void myfunc(threadgroup int (&foo)[1337]) +void myfunc(threadgroup spvUnsafeArray& foo) { foo[0] = 13; } kernel void main0() { - threadgroup int foo[1337]; + threadgroup spvUnsafeArray foo; myfunc(foo); } diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp b/third_party/spirv-cross/reference/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp new file mode 100644 index 0000000000..939619c5db --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct recurs; + +struct recurs +{ + int m1; + device recurs* m2; +}; + +struct recurs_1 +{ + int m1; + device recurs_1* m2; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device void* nums_vp [[buffer(0)]], texture2d tex [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + device auto& nums = *(device recurs*)nums_vp; + int rslt = 0; + rslt += nums.m1; + rslt += nums.m2->m1; + rslt += nums.m2->m2->m1; + tex.write(uint4(uint(rslt), 0u, 0u, 1u), uint2(int2(gl_GlobalInvocationID.xy))); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp b/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp index dde7f47b08..09802dd262 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include #if __METAL_VERSION__ >= 230 @@ -7,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct Params { uint ray_flags; @@ -22,9 +48,9 @@ struct Params kernel void main0(constant Params& _18 [[buffer(1)]], raytracing::acceleration_structure AS0 [[buffer(0)]], raytracing::acceleration_structure AS1 [[buffer(2)]]) { raytracing::intersection_query q; - q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, intersection_params()); + q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, _18.cull_mask, spvMakeIntersectionParams(_18.ray_flags)); raytracing::intersection_query q2[2]; - q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, intersection_params()); + q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, _18.cull_mask, spvMakeIntersectionParams(_18.ray_flags)); bool _63 = q.next(); bool res = _63; q2[0].abort(); diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/shader_ballot.msl22.comp b/third_party/spirv-cross/reference/shaders-msl/comp/shader_ballot.msl22.comp new file mode 100644 index 0000000000..bf2df5adf0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/shader_ballot.msl22.comp @@ -0,0 +1,80 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +inline T spvSubgroupBroadcast(T value, ushort lane) +{ + return simd_broadcast(value, lane); +} + +template<> +inline bool spvSubgroupBroadcast(bool value, ushort lane) +{ + return !!simd_broadcast((ushort)value, lane); +} + +template +inline vec spvSubgroupBroadcast(vec value, ushort lane) +{ + return (vec)simd_broadcast((vec)value, lane); +} + +template +inline T spvSubgroupBroadcastFirst(T value) +{ + return simd_broadcast_first(value); +} + +template<> +inline bool spvSubgroupBroadcastFirst(bool value) +{ + return !!simd_broadcast_first((ushort)value); +} + +template +inline vec spvSubgroupBroadcastFirst(vec value) +{ + return (vec)simd_broadcast_first((vec)value); +} + +inline uint4 spvSubgroupBallot(bool value) +{ + simd_vote vote = simd_ballot(value); + // simd_ballot() returns a 64-bit integer-like object, but + // SPIR-V callers expect a uint4. We must convert. + // FIXME: This won't include higher bits if Apple ever supports + // 128 lanes in an SIMD-group. + return uint4(as_type((simd_vote::vote_t)vote), 0, 0); +} + +struct inputData +{ + float inputDataArray[1]; +}; + +struct outputData +{ + float outputDataArray[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(device inputData& _12 [[buffer(0)]], device outputData& _87 [[buffer(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; + bool laneActive = thisLaneData > 0.0; + uint4 activeSlots = uint4(int4(popcount(uint4(as_type(as_type(uint2(gl_SubgroupLtMask.xy))), 0u, 0u) & uint4(as_type(as_type(uint2(spvSubgroupBallot(laneActive).xy))), 0u, 0u)))); + uint thisLaneOutputSlot = activeSlots.x + activeSlots.y; + int firstInvocation = spvSubgroupBroadcastFirst(1); + int invocation = spvSubgroupBroadcast(1, 0u); + if (laneActive) + { + _87.outputDataArray[thisLaneOutputSlot] = thisLaneData; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/shader_group_vote.msl21.comp b/third_party/spirv-cross/reference/shaders-msl/comp/shader_group_vote.msl21.comp new file mode 100644 index 0000000000..62555b109b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/comp/shader_group_vote.msl21.comp @@ -0,0 +1,41 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(all(value == simd_broadcast_first(value))); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +template +inline bool spvSubgroupAllEqual(vec value) +{ + return simd_all(all(value == (vec)simd_broadcast_first((vec)value))); +} + +struct inputData +{ + float inputDataArray[1]; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +kernel void main0(device inputData& _12 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +{ + float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; + bool laneActive = thisLaneData > 0.0; + bool allInvocations = simd_all(laneActive); + bool anyInvocations = simd_any(laneActive); + bool allInvocationsEqual = spvSubgroupAllEqual(laneActive); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/shared-array-of-arrays.comp b/third_party/spirv-cross/reference/shaders-msl/comp/shared-array-of-arrays.comp index 62c4bb0547..d8b7b2f42f 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/shared-array-of-arrays.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/shared-array-of-arrays.comp @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float out_data[1]; @@ -13,7 +52,7 @@ struct SSBO constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 4u, 1u); static inline __attribute__((always_inline)) -void work(threadgroup float (&foo)[4][4], thread uint3& gl_LocalInvocationID, thread uint& gl_LocalInvocationIndex, device SSBO& _67, thread uint3& gl_GlobalInvocationID) +void work(threadgroup spvUnsafeArray, 4>& foo, thread uint3& gl_LocalInvocationID, thread uint& gl_LocalInvocationIndex, device SSBO& _67, thread uint3& gl_GlobalInvocationID) { foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex); threadgroup_barrier(mem_flags::mem_threadgroup); @@ -27,7 +66,7 @@ void work(threadgroup float (&foo)[4][4], thread uint3& gl_LocalInvocationID, th kernel void main0(device SSBO& _67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - threadgroup float foo[4][4]; + threadgroup spvUnsafeArray, 4> foo; work(foo, gl_LocalInvocationID, gl_LocalInvocationIndex, _67, gl_GlobalInvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/shared.comp b/third_party/spirv-cross/reference/shaders-msl/comp/shared.comp index c9ffde15e8..ee8154f078 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/shared.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/shared.comp @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float in_data[1]; @@ -17,7 +58,7 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u); kernel void main0(const device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { - threadgroup float sShared[4]; + threadgroup spvUnsafeArray sShared; uint ident = gl_GlobalInvocationID.x; float idata = _22.in_data[ident]; sShared[gl_LocalInvocationIndex] = idata; diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/threadgroup-boolean-workaround.comp b/third_party/spirv-cross/reference/shaders-msl/comp/threadgroup-boolean-workaround.comp index f0d417bec7..2db794a60a 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/threadgroup-boolean-workaround.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/threadgroup-boolean-workaround.comp @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct SSBO { float4 values[1]; @@ -13,7 +52,7 @@ struct SSBO constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u); static inline __attribute__((always_inline)) -void in_function(threadgroup short4 (&foo)[4], thread uint& gl_LocalInvocationIndex, device SSBO& _23, thread uint3& gl_GlobalInvocationID) +void in_function(threadgroup spvUnsafeArray& foo, thread uint& gl_LocalInvocationIndex, device SSBO& _23, thread uint3& gl_GlobalInvocationID) { foo[gl_LocalInvocationIndex] = short4(_23.values[gl_GlobalInvocationID.x] != float4(10.0)); threadgroup_barrier(mem_flags::mem_threadgroup); @@ -22,7 +61,7 @@ void in_function(threadgroup short4 (&foo)[4], thread uint& gl_LocalInvocationIn kernel void main0(device SSBO& _23 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - threadgroup short4 foo[4]; + threadgroup spvUnsafeArray foo; in_function(foo, gl_LocalInvocationIndex, _23, gl_GlobalInvocationID); } diff --git a/third_party/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/third_party/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag index 7957b209d6..d413563a75 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -6,6 +6,7 @@ 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); + uImageArray.fence(); 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/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc index 6aca015783..ef468c5da5 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc @@ -17,8 +17,8 @@ struct main0_patchOut struct main0_in { - uint3 m_78; - ushort2 m_82; + uint3 m_79; + ushort2 m_84; float4 gl_Position; }; diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag index 648dc9cf89..6fa39c7131 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/frag-demote-checks.discard-checks.msl23.frag @@ -31,18 +31,18 @@ float4 frag_body(device foo_t& foo, thread float4& gl_FragCoord, texture2d +#include +#include + +using namespace metal; + +struct foo_t +{ + float x; + uint y; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +static inline __attribute__((always_inline)) +float4 frag_body(device foo_t& foo, thread float4& gl_FragCoord, texture2d bar, thread bool& gl_HelperInvocation) +{ + if (!gl_HelperInvocation) + { + foo.x = 1.0; + } + uint _25 = (!gl_HelperInvocation ? atomic_exchange_explicit((device atomic_uint*)&foo.y, 0u, memory_order_relaxed) : uint{}); + if (int(gl_FragCoord.x) == 3) + { + gl_HelperInvocation = true, discard_fragment(); + } + (gl_HelperInvocation ? ((void)0) : bar.write(uint4(1u), uint2(int2(gl_FragCoord.xy)))); + uint _50 = (!gl_HelperInvocation ? atomic_fetch_add_explicit((device atomic_uint*)&foo.y, 42u, memory_order_relaxed) : uint{}); + uint _57 = (!gl_HelperInvocation ? bar.atomic_fetch_or(uint2(int2(gl_FragCoord.xy)), 62u).x : uint{}); + uint _60 = (!gl_HelperInvocation ? atomic_fetch_and_explicit((device atomic_uint*)&foo.y, 65535u, memory_order_relaxed) : uint{}); + uint _63 = (!gl_HelperInvocation ? atomic_fetch_xor_explicit((device atomic_uint*)&foo.y, 4294967040u, memory_order_relaxed) : uint{}); + uint _65 = (!gl_HelperInvocation ? atomic_fetch_min_explicit((device atomic_uint*)&foo.y, 1u, memory_order_relaxed) : uint{}); + uint _71 = (!gl_HelperInvocation ? bar.atomic_fetch_max(uint2(int2(gl_FragCoord.xy)), 100u).x : uint{}); + uint _76; + uint4 _96; + if (!gl_HelperInvocation) + { + do + { + _96.x = 100u; + } while (!bar.atomic_compare_exchange_weak(uint2(int2(gl_FragCoord.xy)), &_96, 42u) && _96.x == 100u); + _76 = _96.x; + } + else + { + _76 = {}; + } + bool _77 = gl_HelperInvocation; + return float4(1.0, float(_77), 0.0, 1.0); +} + +fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d bar [[texture(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + float4 _85 = frag_body(foo, gl_FragCoord, bar, gl_HelperInvocation); + out.fragColor = _85; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag b/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag new file mode 100644 index 0000000000..0c11898b08 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag @@ -0,0 +1,49 @@ +#include +#include + +using namespace metal; + +struct foo +{ + int x; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +fragment main0_out main0(device foo& _24 [[buffer(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + if (gl_FragCoord.y == 7.0) + { + gl_HelperInvocation = true, discard_fragment(); + } + if (!gl_HelperInvocation) + { + _24.x = 0; + } + for (;;) + { + if (float(_24.x) < gl_FragCoord.x) + { + int _41 = _24.x; + int _43 = _41 + 1; + if (!gl_HelperInvocation) + { + _24.x = _43; + } + continue; + } + else + { + break; + } + } + out.fragColor = float4(float(_24.x), 0.0, 0.0, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag index c2ae69695f..db0d3d8123 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/frag-discard-checks.discard-checks.msl23.frag @@ -31,18 +31,18 @@ float4 frag_body(device foo_t& foo, thread float4& gl_FragCoord, texture2d +#include +#include + +using namespace metal; + +struct foo_t +{ + float x; + uint y; +}; + +struct main0_out +{ + float4 fragColor [[color(0)]]; +}; + +static inline __attribute__((always_inline)) +float4 frag_body(device foo_t& foo, thread float4& gl_FragCoord, texture2d bar, thread bool& gl_HelperInvocation) +{ + if (!gl_HelperInvocation) + { + foo.x = 1.0; + } + uint _25 = (!gl_HelperInvocation ? atomic_exchange_explicit((device atomic_uint*)&foo.y, 0u, memory_order_relaxed) : uint{}); + if (int(gl_FragCoord.x) == 3) + { + gl_HelperInvocation = true, discard_fragment(); + } + (gl_HelperInvocation ? ((void)0) : bar.write(uint4(1u), uint2(int2(gl_FragCoord.xy)))); + uint _51 = (!gl_HelperInvocation ? atomic_fetch_add_explicit((device atomic_uint*)&foo.y, 42u, memory_order_relaxed) : uint{}); + uint _58 = (!gl_HelperInvocation ? bar.atomic_fetch_or(uint2(int2(gl_FragCoord.xy)), 62u).x : uint{}); + uint _61 = (!gl_HelperInvocation ? atomic_fetch_and_explicit((device atomic_uint*)&foo.y, 65535u, memory_order_relaxed) : uint{}); + uint _64 = (!gl_HelperInvocation ? atomic_fetch_xor_explicit((device atomic_uint*)&foo.y, 4294967040u, memory_order_relaxed) : uint{}); + uint _66 = (!gl_HelperInvocation ? atomic_fetch_min_explicit((device atomic_uint*)&foo.y, 1u, memory_order_relaxed) : uint{}); + uint _72 = (!gl_HelperInvocation ? bar.atomic_fetch_max(uint2(int2(gl_FragCoord.xy)), 100u).x : uint{}); + uint _77; + uint4 _95; + if (!gl_HelperInvocation) + { + do + { + _95.x = 100u; + } while (!bar.atomic_compare_exchange_weak(uint2(int2(gl_FragCoord.xy)), &_95, 42u) && _95.x == 100u); + _77 = _95.x; + } + else + { + _77 = {}; + } + return float4(1.0, 0.0, 0.0, 1.0); +} + +fragment main0_out main0(device foo_t& foo [[buffer(0)]], texture2d bar [[texture(0)]], float4 gl_FragCoord [[position]]) +{ + main0_out out = {}; + bool gl_HelperInvocation = {}; + gl_HelperInvocation = simd_is_helper_thread(); + float4 _84 = frag_body(foo, gl_FragCoord, bar, gl_HelperInvocation); + out.fragColor = _84; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag b/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag new file mode 100644 index 0000000000..e90faef7e9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag @@ -0,0 +1,45 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct Buffer3 +{ + int baz; +}; + +struct Buffer +{ + int foo; + uint bar; +}; + +struct Buffer2 +{ + uint quux; +}; + +struct spvDescriptorSetBuffer0 +{ + device Buffer3* m_9 [[id(0)]]; + texture2d img4 [[id(1)]]; + texture2d img [[id(2), raster_order_group(0)]]; + texture2d img3 [[id(3), raster_order_group(0)]]; + texture2d img2 [[id(4), raster_order_group(0)]]; + volatile device Buffer* m_42 [[id(5), raster_order_group(0)]]; + device Buffer2* m_52 [[id(6), raster_order_group(0)]]; +}; + +fragment void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]]) +{ + (*spvDescriptorSet0.m_9).baz = 0; + spvDescriptorSet0.img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1))); + spvDescriptorSet0.img.write(spvDescriptorSet0.img3.read(uint2(int2(0))), uint2(int2(0))); + uint _39 = spvDescriptorSet0.img2.atomic_fetch_add(uint2(int2(0)), 1u).x; + (*spvDescriptorSet0.m_42).foo += 42; + uint _55 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(*spvDescriptorSet0.m_42).bar, (*spvDescriptorSet0.m_52).quux, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.frag b/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.frag new file mode 100644 index 0000000000..73afda48e2 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/pixel-interlock-ordered.msl31.frag @@ -0,0 +1,34 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct Buffer3 +{ + int baz; +}; + +struct Buffer +{ + int foo; + uint bar; +}; + +struct Buffer2 +{ + uint quux; +}; + +fragment void main0(device Buffer3& _9 [[buffer(0)]], volatile device Buffer& _42 [[buffer(1), raster_order_group(0)]], device Buffer2& _52 [[buffer(2), raster_order_group(0)]], texture2d img4 [[texture(0)]], texture2d img [[texture(1), raster_order_group(0)]], texture2d img3 [[texture(2), raster_order_group(0)]], texture2d img2 [[texture(3), raster_order_group(0)]]) +{ + _9.baz = 0; + img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1))); + img.write(img3.read(uint2(int2(0))), uint2(int2(0))); + uint _39 = img2.atomic_fetch_add(uint2(int2(0)), 1u).x; + _42.foo += 42; + uint _55 = atomic_fetch_and_explicit((volatile device atomic_uint*)&_42.bar, _52.quux, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.ios.msl2.frag b/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.ios.msl2.frag index 3b2885e2e2..d40e2a344c 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.ios.msl2.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.ios.msl2.frag @@ -11,7 +11,7 @@ struct main0_out [[ early_fragment_tests ]] fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask, post_depth_coverage]]) { main0_out out = {}; - out.FragColor = float4(float(gl_SampleMaskIn)); + out.FragColor = float4(float(int(gl_SampleMaskIn))); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.msl23.frag index 3b2885e2e2..d40e2a344c 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/post-depth-coverage.msl23.frag @@ -11,7 +11,7 @@ struct main0_out [[ early_fragment_tests ]] fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask, post_depth_coverage]]) { main0_out out = {}; - out.FragColor = float4(float(gl_SampleMaskIn)); + out.FragColor = float4(float(int(gl_SampleMaskIn))); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag b/third_party/spirv-cross/reference/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag index 3ab6a47161..98ec6106b2 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag @@ -9,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct main0_out { float4 outColor [[color(0)]]; @@ -20,9 +44,9 @@ struct main0_in }; static inline __attribute__((always_inline)) -uint doRay(thread const float3& rayOrigin, thread const float3& rayDirection, thread const float& rayDistance, thread raytracing::intersection_query& rayQuery, thread const raytracing::acceleration_structure& topLevelAS) +uint doRay(thread const float3& rayOrigin, thread const float3& rayDirection, thread const float& rayDistance, thread raytracing::intersection_query& rayQuery, const raytracing::acceleration_structure topLevelAS) { - rayQuery.reset(ray(rayOrigin, rayDirection, 0.001000000047497451305389404296875, rayDistance), topLevelAS, intersection_params()); + rayQuery.reset(ray(rayOrigin, rayDirection, 0.001000000047497451305389404296875, rayDistance), topLevelAS, 255u, spvMakeIntersectionParams(4u)); for (;;) { bool _36 = rayQuery.next(); diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..d6ea317e9f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,233 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include +#if __METAL_VERSION__ >= 230 +#include +using namespace metal::raytracing; +#endif + +using namespace metal; + +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + +template +struct spvDescriptor +{ + T value; +}; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr) + { + } + const device T& operator [] (size_t i) const + { + return ptr[i].value; + } + const device spvDescriptor* ptr; +}; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct Ssbo +{ + uint val; + uint data[1]; +}; + +struct Ubo +{ + uint val; +}; + +struct main0_in +{ + uint inputId [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +void implicit_combined_texture(const spvDescriptorArray> smp_textures, const spvDescriptorArray smp_texturesSmplr, thread uint& inputId) +{ + uint _56 = inputId; + float4 d = smp_textures[_56].sample(smp_texturesSmplr[_56], float2(0.0), level(0.0)); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void implicit_texture(thread uint& inputId, const spvDescriptorArray> textures, const spvDescriptorArray smp) +{ + uint _78 = inputId; + uint _87 = inputId + 8u; + float4 d = textures[_78].sample(smp[_87], float2(0.0), level(0.0)); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void implicit_ssbo(thread uint& inputId, const spvDescriptorArray ssbo) +{ + uint _104 = inputId; + if (ssbo[_104]->val == 2u) + { + discard_fragment(); + } + if (int((ssbo.length(123) - 4) / 4) == 25) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void implicit_ubo(thread uint& inputId, const spvDescriptorArray ubo) +{ + uint _130 = inputId; + if (ubo[_130]->val == 2u) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void implicit_image(thread uint& inputId, const spvDescriptorArray> images) +{ + uint _143 = inputId; + float4 d = images[_143].read(uint2(int2(0))); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void implicit_tlas(thread uint& inputId, thread raytracing::intersection_query& rayQuery, const spvDescriptorArray> tlas) +{ + rayQuery.reset(ray(float3(0.0), float3(1.0), 0.00999999977648258209228515625, 1.0), tlas[inputId], 255u, spvMakeIntersectionParams(0u)); + bool _171 = rayQuery.next(); +} + +static inline __attribute__((always_inline)) +void explicit_comb_texture(texture2d tex, sampler texSmplr) +{ + float4 d = tex.sample(texSmplr, float2(0.0), level(0.0)); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void explicit_texture(texture2d tex, sampler smp) +{ + float4 d = tex.sample(smp, float2(0.0), level(0.0)); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void explicit_image(texture2d tex) +{ + float4 d = tex.read(uint2(int2(0))); + if (d.w > 0.5) + { + discard_fragment(); + } +} + +static inline __attribute__((always_inline)) +void explicit_tlas(const raytracing::acceleration_structure tlas, thread raytracing::intersection_query& rayQuery_1) +{ + rayQuery_1.reset(ray(float3(0.0), float3(1.0), 0.00999999977648258209228515625, 1.0), tlas, 255u, spvMakeIntersectionParams(0u)); + bool _203 = rayQuery_1.next(); +} + +fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor* ssbo_ [[buffer(4)]], const device spvDescriptor* ubo_ [[buffer(5)]], const device spvDescriptor>* smp_textures_ [[buffer(0)]], const device spvDescriptor>* textures_ [[buffer(2)]], const device spvDescriptor>* images_ [[buffer(6)]], const device spvDescriptor* smp_texturesSmplr_ [[buffer(1)]], const device spvDescriptor* smp_ [[buffer(3)]], const device spvDescriptor>* tlas_ [[buffer(7)]]) +{ + spvDescriptorArray> smp_textures {smp_textures_}; + spvDescriptorArray smp_texturesSmplr {smp_texturesSmplr_}; + spvDescriptorArray> textures {textures_}; + spvDescriptorArray smp {smp_}; + spvDescriptorArray ssbo {ssbo_}; + spvDescriptorArray ubo {ubo_}; + spvDescriptorArray> images {images_}; + spvDescriptorArray> tlas {tlas_}; + + implicit_combined_texture(smp_textures, smp_texturesSmplr, in.inputId); + implicit_texture(in.inputId, textures, smp); + implicit_ssbo(in.inputId, ssbo); + implicit_ubo(in.inputId, ubo); + implicit_image(in.inputId, images); + raytracing::intersection_query rayQuery; + implicit_tlas(in.inputId, rayQuery, tlas); + uint _211 = in.inputId; + explicit_comb_texture(smp_textures[_211], smp_texturesSmplr[_211]); + uint _215 = in.inputId; + uint _217 = in.inputId; + explicit_texture(textures[_215], smp[_217]); + uint _222 = in.inputId; + explicit_image(images[_222]); + raytracing::intersection_query rayQuery_1; + explicit_tlas(tlas[in.inputId], rayQuery_1); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..8651782008 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvBufferDescriptor +{ + T value; + int length; + const device T& operator -> () const device + { + return value; + } + const device T& operator * () const device + { + return value; + } +}; + +template +struct spvDescriptorArray; + +template +struct spvDescriptorArray +{ + spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr) + { + } + const device T* operator [] (size_t i) const + { + return ptr[i].value; + } + const int length(int i) const + { + return ptr[i].length; + } + const device spvBufferDescriptor* ptr; +}; + +struct Ssbo +{ + uint val; + uint data[1]; +}; + +struct main0_in +{ + uint inputId [[user(locn0)]]; +}; + +fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor* ssbo_ [[buffer(0)]]) +{ + spvDescriptorArray ssbo {ssbo_}; + + uint _15 = in.inputId; + if (ssbo[_15]->val == 2u) + { + discard_fragment(); + } + if (int((ssbo.length(123) - 4) / 4) == 25) + { + discard_fragment(); + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag index 626fe4c79c..aab186ed02 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.force-sample.frag @@ -13,7 +13,7 @@ fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]], uint gl_SampleID { main0_out out = {}; out.FragColor = float4(1.0); - out.gl_SampleMask = (gl_SampleMaskIn & 0x22 & (1 << gl_SampleID)); + out.gl_SampleMask = int((gl_SampleMaskIn & 0x22 & (1 << gl_SampleID))); out.gl_SampleMask &= 0x22; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag index f478901b6b..0f18da5de7 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-mask-in-and-out.fixed-sample-mask.frag @@ -13,7 +13,7 @@ fragment main0_out main0(uint gl_SampleMaskIn [[sample_mask]]) { main0_out out = {}; out.FragColor = float4(1.0); - out.gl_SampleMask = (gl_SampleMaskIn & 0x22); + out.gl_SampleMask = int((gl_SampleMaskIn & 0x22)); out.gl_SampleMask &= 0x22; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag new file mode 100644 index 0000000000..35597e470b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag @@ -0,0 +1,44 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) +{ + // Major axis selection + float3 absP = abs(P); + bool xMajor = absP.x >= max(absP.y, absP.z); + bool yMajor = absP.y >= absP.z; + float3 Q = xMajor ? P.yzx : (yMajor ? P.xzy : P); + float3 dQdx = xMajor ? dPdx.yzx : (yMajor ? dPdx.xzy : dPdx); + float3 dQdy = xMajor ? dPdy.yzx : (yMajor ? dPdy.xzy : dPdy); + + // Skip a couple of operations compared to usual projection + float4 d = float4(dQdx.xy, dQdy.xy) - (Q.xy / Q.z).xyxy * float4(dQdx.zz, dQdy.zz); + + // Final swizzle to put the intermediate values into non-ignored components + // X major: X and Z + // Y major: X and Y + // Z major: Y and Z + return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); +} + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vTex [[user(locn0), flat]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texturecube uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor += uSampler.sample(uSamplerSmplr, in.vTex, spvGradientCube(in.vTex, float3(5.0), float3(8.0))); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc index 24928da01d..bf84a77ce0 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc @@ -44,114 +44,6 @@ struct spvUnsafeArray } }; -template -inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - struct main0_out { float4 gl_Position; @@ -171,14 +63,14 @@ struct main0_in kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup float4 spvStorageFoo[8][4][2]; - threadgroup float4 (&Foo)[4][2] = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray, 4> spvStorageFoo[8]; + threadgroup auto &Foo = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); gl_out[gl_InvocationID].gl_Position = float4(1.0); - spvArrayCopyFromDeviceToThreadGroup1(Foo[gl_InvocationID], gl_in[gl_InvocationID].iFoo.elements); + Foo[gl_InvocationID] = gl_in[gl_InvocationID].iFoo; if (gl_InvocationID == 0) { spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc index a08364e2b3..ec2316b4f4 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc @@ -44,114 +44,6 @@ struct spvUnsafeArray } }; -template -inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - -template -inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) -{ - for (uint i = 0; i < A; i++) - { - dst[i] = src[i]; - } -} - struct main0_out { float4 gl_Position; @@ -171,7 +63,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup float4 Foo[4][2]; + threadgroup spvUnsafeArray, 4> Foo; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -181,7 +73,7 @@ kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_ return; gl_out[gl_InvocationID].gl_Position = float4(1.0); spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); - spvArrayCopyFromStackToThreadGroup1(Foo[gl_InvocationID], _38.elements); + Foo[gl_InvocationID] = _38; if (gl_InvocationID == 0) { spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc index 7336d094c8..53f1dde70f 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc @@ -44,7 +44,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; threadgroup P spvStorage_11[8]; - threadgroup P (&_11) = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup auto &_11 = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); write_in_function(_11, patchOut, gl_out, gl_InvocationID); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc index c3b54c7dff..5ce2e3f767 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct P { float a; @@ -30,7 +69,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], device main0_out* thread & gl_out, thread uint& gl_InvocationID) +void write_in_function(device main0_patchOut& patchOut, threadgroup spvUnsafeArray& c, device main0_out* thread & gl_out, thread uint& gl_InvocationID) { patchOut.m_11_a = 1.0; patchOut.m_11_b = 2.0; @@ -41,7 +80,7 @@ void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], d kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup C c[4]; + threadgroup spvUnsafeArray c; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_function(patchOut, c, gl_out, gl_InvocationID); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc index a881a682a7..f9947d712f 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct P { float a; @@ -30,7 +69,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], device main0_out* thread & gl_out, thread uint& gl_InvocationID) +void write_in_function(device main0_patchOut& patchOut, threadgroup spvUnsafeArray& c, device main0_out* thread & gl_out, thread uint& gl_InvocationID) { patchOut.m_11_a = 1.0; patchOut.m_11_b = 2.0; @@ -42,8 +81,8 @@ void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], d kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup C spvStoragec[8][4]; - threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragec[8]; + threadgroup auto &c = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc index e4f047d3e3..2fc46855eb 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position; @@ -17,7 +56,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device float4& v1, device main0_out* thread & gl_out) +void write_in_func(threadgroup spvUnsafeArray& v0, thread uint& gl_InvocationID, device float4& v1, device main0_out* thread & gl_out) { v0[gl_InvocationID] = float4(1.0); v0[gl_InvocationID].x = 2.0; @@ -34,7 +73,7 @@ void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, de kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v0[4]; + threadgroup spvUnsafeArray v0; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_func(v0, gl_InvocationID, patchOut.v1, gl_out); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc index 7465cc64db..67aaf0c6ac 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc @@ -57,7 +57,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) +void write_in_func(threadgroup spvUnsafeArray& v0, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) { v0[gl_InvocationID] = float4(1.0); v0[gl_InvocationID].z = 3.0; @@ -77,8 +77,8 @@ void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, de kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup float4 spvStoragev0[8][4]; - threadgroup float4 (&v0)[4] = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragev0[8]; + threadgroup auto &v0 = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc index 0ae265e9e7..e4694b19a7 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc @@ -57,7 +57,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) +void write_in_func(threadgroup spvUnsafeArray& v0, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) { v0[gl_InvocationID] = float4(1.0); v0[gl_InvocationID].z = 3.0; @@ -76,7 +76,7 @@ void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, de kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v0[4]; + threadgroup spvUnsafeArray v0; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_func(v0, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc index df057861ee..18d9170dca 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 v0; @@ -18,7 +57,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup float4 (&v1)[2], device float4& v3) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup spvUnsafeArray& v1, device float4& v3) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -39,8 +78,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; - threadgroup float4 spvStoragev1[8][2]; - threadgroup float4 (&v1)[2] = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragev1[8]; + threadgroup auto &v1 = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); write_in_func(gl_out, gl_InvocationID, v1, patchOut.v3); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc index 0ad2727673..03351f99e8 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 v0; @@ -18,7 +57,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup float4 (&v1)[2], device float4& v3) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup spvUnsafeArray& v1, device float4& v3) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -37,7 +76,7 @@ void write_in_func(device main0_out* thread & gl_out, thread uint& gl_Invocation kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup float4 v1[2]; + threadgroup spvUnsafeArray v1; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_func(gl_out, gl_InvocationID, v1, patchOut.v3); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc index 05d58634ef..c61ceb721a 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc @@ -65,7 +65,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup spvUnsafeArray& gl_out_masked) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -85,8 +85,8 @@ void write_in_func(device main0_out* thread & gl_out, thread uint& gl_Invocation kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc index 8ec2a663b7..0632696e42 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc @@ -65,7 +65,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup spvUnsafeArray& gl_out_masked) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -84,7 +84,7 @@ void write_in_func(device main0_out* thread & gl_out, thread uint& gl_Invocation kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc index 86bc7d37be..ea5a83d697 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc @@ -65,7 +65,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup spvUnsafeArray& gl_out_masked) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -85,8 +85,8 @@ void write_in_func(device main0_out* thread & gl_out, thread uint& gl_Invocation kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; - threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; - threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + threadgroup spvUnsafeArray spvStoragegl_out_masked[8]; + threadgroup auto &gl_out_masked = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc index da0d2a2d10..703cdadd76 100644 --- a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc @@ -65,7 +65,7 @@ struct main0_patchOut }; static inline __attribute__((always_inline)) -void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup spvUnsafeArray& gl_out_masked) { gl_out[gl_InvocationID].v0 = float4(1.0); gl_out[gl_InvocationID].v0.z = 3.0; @@ -84,7 +84,7 @@ void write_in_func(device main0_out* thread & gl_out, thread uint& gl_Invocation kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - threadgroup gl_PerVertex gl_out_masked[4]; + threadgroup spvUnsafeArray gl_out_masked; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc index c11c7410c6..bc0208d2b5 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/arrayed-block-io.multi-patch.tesc @@ -68,7 +68,7 @@ struct main0_patchOut struct main0_in { float3 in_tc_attr; - ushort2 m_179; + ushort2 m_180; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc index b993c9979f..91fbe308e1 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc @@ -52,7 +52,7 @@ struct main0_out struct main0_in { float4 vInputs; - ushort2 m_43; + ushort2 m_44; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc index 98b9dd0524..424885aeae 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc @@ -13,7 +13,7 @@ struct main0_out struct main0_in { float3 in_tc_attr; - ushort2 m_103; + ushort2 m_104; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc index ae33de517a..7e34079598 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc @@ -10,8 +10,8 @@ struct main0_out struct main0_in { - uint3 m_82; - ushort2 m_86; + uint3 m_83; + ushort2 m_88; float4 gl_Position; }; diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc index eaab245c1c..f62614dbd6 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc @@ -20,7 +20,7 @@ struct main0_out struct main0_in { float3 in_tc_attr; - ushort2 m_107; + ushort2 m_108; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc index 0cd540ca15..9e71a50360 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc @@ -24,7 +24,7 @@ struct main0_patchOut struct main0_in { float3 vPatchPosBase; - ushort2 m_430; + ushort2 m_431; }; static inline __attribute__((always_inline)) diff --git a/third_party/spirv-cross/reference/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese b/third_party/spirv-cross/reference/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese new file mode 100644 index 0000000000..129449a4d0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +static inline __attribute__((always_inline)) +float4 read_patch_vertices(thread uint& gl_PatchVerticesIn) +{ + return float4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0); +} + +[[ patch(quad, 0) ]] vertex main0_out main0(uint gl_PrimitiveID [[patch_id]]) +{ + main0_out out = {}; + uint gl_PatchVerticesIn = 0; + out.gl_Position = read_patch_vertices(gl_PatchVerticesIn); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag index 274cea2de1..05d5eb4a82 100644 --- a/third_party/spirv-cross/reference/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.msl23.frag @@ -13,9 +13,9 @@ fragment main0_out main0() main0_out out = {}; bool gl_HelperInvocation = {}; gl_HelperInvocation = simd_is_helper_thread(); - bool _15 = gl_HelperInvocation; + bool _9 = gl_HelperInvocation; gl_HelperInvocation = true, discard_fragment(); - if (!_15) + if (!_9) { out.FragColor = float4(1.0, 0.0, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body-2.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body-2.asm.comp index c27bef6a6d..13a4bfe2d3 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body-2.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body-2.asm.comp @@ -4,21 +4,21 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer SSBO { int values[]; -} _4; +} _6; void main() { - int _17 = 0; + int _51 = 0; for (;;) { - if (_17 < 100) + if (_51 < 100) { - int _24 = _4.values[_17]; - _4.values[_24] = _17; - int _26 = _24 + 1; - int _18 = _4.values[_26]; - _4.values[_17] = _18; - _17 = _18; + int _41 = _6.values[_51]; + _6.values[_41] = _51; + int _47 = _41 + 1; + int _49 = _6.values[_47]; + _6.values[_51] = _49; + _51 = _49; continue; } else diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body.asm.comp index 0517ec4d8b..74803fa863 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/access-chain-dominator-in-loop-body.asm.comp @@ -4,18 +4,18 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer SSBO { int values[]; -} _4; +} _6; void main() { - int _17 = 0; + int _51 = 0; for (;;) { - if (_17 < 100) + if (_51 < 100) { - int _24 = _4.values[_17]; - _4.values[_24] = _17; - _17 = _4.values[_24 + 1]; + int _41 = _6.values[_51]; + _6.values[_41] = _51; + _51 = _6.values[_41 + 1]; continue; } else diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp index d36f543108..eb62c4dfa4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp @@ -9,17 +9,17 @@ struct T layout(binding = 0, std430) buffer SSBO1 { T foo[]; -} _7; +} _9; layout(binding = 1, std140) buffer SSBO2 { T bar[]; -} _10; +} _13; void main() { T v = T(40.0); - _7.foo[10].c = v.c; - _10.bar[30].c = v.c; + _9.foo[10].c = v.c; + _13.bar[30].c = v.c; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/arithmetic-conversion-signs.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/arithmetic-conversion-signs.asm.nocompat.vk.comp.vk index 5f480728e4..b35c14d24e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/arithmetic-conversion-signs.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/arithmetic-conversion-signs.asm.nocompat.vk.comp.vk @@ -10,37 +10,37 @@ layout(set = 0, binding = 0, std430) buffer SSBO int16_t s16; uint16_t u16; float f32; -} _4; +} _6; void main() { - int _29 = _4.s32; - uint _30 = _4.u32; - int16_t _31 = _4.s16; - uint16_t _32 = _4.u16; - float _33 = _4.f32; - _4.s32 = int(_31); - _4.u32 = uint(_31); - _4.s32 = int(int16_t(_32)); - _4.u32 = uint(int16_t(_32)); - _4.u32 = uint(uint16_t(_31)); - _4.u32 = uint(_32); - _4.s16 = int16_t(_29); - _4.u16 = uint16_t(_29); - _4.s16 = int16_t(_30); - _4.u16 = uint16_t(_30); - _4.u16 = uint16_t(_29); - _4.u16 = uint16_t(_30); - _4.f32 = float(_31); - _4.f32 = float(int16_t(_32)); - _4.f32 = float(_29); - _4.f32 = float(int(_30)); - _4.f32 = float(uint16_t(_31)); - _4.f32 = float(_32); - _4.f32 = float(uint(_29)); - _4.f32 = float(_30); - _4.s16 = int16_t(_33); - _4.u16 = uint16_t(int16_t(_33)); - _4.u16 = uint16_t(_33); + int _29 = _6.s32; + uint _30 = _6.u32; + int16_t _31 = _6.s16; + uint16_t _32 = _6.u16; + float _33 = _6.f32; + _6.s32 = int(_31); + _6.u32 = uint(_31); + _6.s32 = int(int16_t(_32)); + _6.u32 = uint(int16_t(_32)); + _6.u32 = uint(uint16_t(_31)); + _6.u32 = uint(_32); + _6.s16 = int16_t(_29); + _6.u16 = uint16_t(_29); + _6.s16 = int16_t(_30); + _6.u16 = uint16_t(_30); + _6.u16 = uint16_t(_29); + _6.u16 = uint16_t(_30); + _6.f32 = float(_31); + _6.f32 = float(int16_t(_32)); + _6.f32 = float(_29); + _6.f32 = float(int(_30)); + _6.f32 = float(uint16_t(_31)); + _6.f32 = float(_32); + _6.f32 = float(uint(_29)); + _6.f32 = float(_30); + _6.s16 = int16_t(_33); + _6.u16 = uint16_t(int16_t(_33)); + _6.u16 = uint16_t(_33); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-load-store.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-load-store.asm.comp index 10a54fc8cf..4c496a58f4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-load-store.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-load-store.asm.comp @@ -5,12 +5,12 @@ layout(binding = 0, std430) buffer SSBO { uint a; uint b; -} _5; +} _7; void main() { - uint _20 = atomicAdd(_5.b, 0u); - uint c = _20; - atomicExchange(_5.a, c); + uint _16 = atomicAdd(_7.b, 0u); + uint c = _16; + atomicExchange(_7.a, c); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-result-temporary.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-result-temporary.asm.comp index b51c6c58de..1ca7304940 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-result-temporary.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/atomic-result-temporary.asm.comp @@ -5,14 +5,14 @@ layout(binding = 0, std430) buffer SSBO { uint count; uint data[]; -} _5; +} _7; void main() { - uint _24 = atomicAdd(_5.count, 1u); - if (_24 < 1024u) + uint _19 = atomicAdd(_7.count, 1u); + if (_19 < 1024u) { - _5.data[_24] = gl_GlobalInvocationID.x; + _7.data[_19] = gl_GlobalInvocationID.x; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/basic.spv16.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/basic.spv16.asm.comp index 7c237d8abd..00929f30d8 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/basic.spv16.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/basic.spv16.asm.comp @@ -4,10 +4,10 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer SSBO { float values[]; -} _3; +} _4; void main() { - _3.values[gl_GlobalInvocationID.x] += 2.0; + _4.values[gl_GlobalInvocationID.x] += 2.0; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-to-array-in-buffer.asm.spv16.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-to-array-in-buffer.asm.spv16.nocompat.vk.comp.vk index dfb8e318e6..c94c2a2225 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-to-array-in-buffer.asm.spv16.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-to-array-in-buffer.asm.spv16.nocompat.vk.comp.vk @@ -6,9 +6,12 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in; +layout(buffer_reference) buffer uintPointer; +layout(buffer_reference) buffer uint8_tPointer; +layout(buffer_reference) buffer uint8_t12_stride_1Pointer; layout(buffer_reference) buffer uint8_tPointer { uint8_t value; @@ -19,7 +22,7 @@ layout(buffer_reference, buffer_reference_align = 4) buffer uintPointer uint value; }; -layout(buffer_reference, buffer_reference_align = 1) buffer uint8_t12_Pointer +layout(std430, buffer_reference, buffer_reference_align = 1) buffer uint8_t12_stride_1Pointer { uint8_t value[12]; }; @@ -27,12 +30,12 @@ layout(buffer_reference, buffer_reference_align = 1) buffer uint8_t12_Pointer layout(set = 0, binding = 0, std430) buffer _7_2 { uint8_tPointer _m0; - uint8_t12_Pointer _m1; + uint8_t12_stride_1Pointer _m1; } _2; uintPointer _23() { - uint8_t12_Pointer _26 = _2._m1; + uint8_t12_stride_1Pointer _26 = _2._m1; uintPointer _29 = uintPointer(uint64_t(_26) + 16ul); _29.value = 1u; return _29; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp index 66a70f1848..ca85cb0c59 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp @@ -14,11 +14,11 @@ layout(binding = 0, std430) buffer SSBO float b; float c; f16vec2 d; -} _4; +} _6; void main() { - _4.b = uintBitsToFloat(packFloat2x16(_4.a)); - _4.d = unpackFloat2x16(floatBitsToUint(_4.c)); + _6.b = uintBitsToFloat(packFloat2x16(_6.a)); + _6.d = unpackFloat2x16(floatBitsToUint(_6.c)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp.vk index 09eccf4b31..d16f507190 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitcast-fp16-fp32.asm.vk.comp.vk @@ -15,11 +15,11 @@ layout(set = 0, binding = 0, std430) buffer SSBO float b; float c; f16vec2 d; -} _4; +} _6; void main() { - _4.b = uintBitsToFloat(packFloat2x16(_4.a)); - _4.d = unpackFloat2x16(floatBitsToUint(_4.c)); + _6.b = uintBitsToFloat(packFloat2x16(_6.a)); + _6.d = unpackFloat2x16(floatBitsToUint(_6.c)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitfield-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitfield-signed-operations.asm.comp index f535ba7f49..570744a383 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitfield-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitfield-signed-operations.asm.comp @@ -5,23 +5,23 @@ layout(binding = 0, std430) buffer SSBO { ivec4 ints; uvec4 uints; -} _3; +} _4; void main() { - ivec4 _19 = _3.ints; - uvec4 _20 = _3.uints; - _3.ints = bitCount(_19); - _3.uints = uvec4(bitCount(_19)); - _3.ints = bitCount(_20); - _3.uints = uvec4(bitCount(_20)); - _3.ints = bitfieldReverse(_19); - _3.uints = bitfieldReverse(_20); - _3.ints = bitfieldExtract(_19, 1, int(11u)); - _3.uints = uvec4(bitfieldExtract(ivec4(_20), int(11u), 1)); - _3.ints = ivec4(bitfieldExtract(uvec4(_19), 1, int(11u))); - _3.uints = bitfieldExtract(_20, int(11u), 1); - _3.ints = bitfieldInsert(_19, _19.wzyx, 1, int(11u)); - _3.uints = bitfieldInsert(_20, _20.wzyx, int(11u), 1); + ivec4 _19 = _4.ints; + uvec4 _20 = _4.uints; + _4.ints = bitCount(_19); + _4.uints = uvec4(bitCount(_19)); + _4.ints = bitCount(_20); + _4.uints = uvec4(bitCount(_20)); + _4.ints = bitfieldReverse(_19); + _4.uints = bitfieldReverse(_20); + _4.ints = bitfieldExtract(_19, 1, int(11u)); + _4.uints = uvec4(bitfieldExtract(ivec4(_20), int(11u), 1)); + _4.ints = ivec4(bitfieldExtract(uvec4(_19), 1, int(11u))); + _4.uints = bitfieldExtract(_20, int(11u), 1); + _4.ints = bitfieldInsert(_19, _19.wzyx, 1, int(11u)); + _4.uints = bitfieldInsert(_20, _20.wzyx, int(11u), 1); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitscan.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitscan.asm.comp index 31a6234abb..eb5010e289 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitscan.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bitscan.asm.comp @@ -5,23 +5,23 @@ layout(binding = 0, std430) buffer SSBO { uvec4 u; ivec4 i; -} _4; +} _6; void main() { - uvec4 _19 = _4.u; - ivec4 _20 = _4.i; - _4.u = uvec4(findLSB(_19)); - _4.i = findLSB(_19); - _4.u = uvec4(findLSB(_20)); - _4.i = findLSB(_20); - _4.u = uvec4(findMSB(_19)); - _4.i = findMSB(_19); - _4.u = uvec4(findMSB(uvec4(_20))); - _4.i = findMSB(uvec4(_20)); - _4.u = uvec4(findMSB(ivec4(_19))); - _4.i = findMSB(ivec4(_19)); - _4.u = uvec4(findMSB(_20)); - _4.i = findMSB(_20); + uvec4 _19 = _6.u; + ivec4 _20 = _6.i; + _6.u = uvec4(findLSB(_19)); + _6.i = findLSB(_19); + _6.u = uvec4(findLSB(_20)); + _6.i = findLSB(_20); + _6.u = uvec4(findMSB(_19)); + _6.i = findMSB(_19); + _6.u = uvec4(findMSB(uvec4(_20))); + _6.i = findMSB(uvec4(_20)); + _6.u = uvec4(findMSB(ivec4(_19))); + _6.i = findMSB(ivec4(_19)); + _6.u = uvec4(findMSB(_20)); + _6.i = findMSB(_20); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp new file mode 100644 index 0000000000..dba99a048a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp @@ -0,0 +1,13 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct FHitGroupRootConstants +{ + uint BaseInstanceIndex; + uint UserData; +}; + +void main() +{ +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-atomic-nonuniform.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-atomic-nonuniform.vk.nocompat.asm.comp.vk index d700d61353..0f9a1c7d54 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-atomic-nonuniform.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-atomic-nonuniform.vk.nocompat.asm.comp.vk @@ -9,7 +9,7 @@ layout(set = 0, binding = 0, std430) buffer SSBO void main() { - uint _24 = gl_GlobalInvocationID.z; - uint _25 = atomicAdd(ssbos[nonuniformEXT(_24)].v, 1u); + uint _18 = gl_GlobalInvocationID.z; + uint _25 = atomicAdd(ssbos[nonuniformEXT(_18)].v, 1u); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-device-address-ptr-casting.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-device-address-ptr-casting.vk.nocompat.asm.comp.vk index f082267f93..cf61180320 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-device-address-ptr-casting.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-device-address-ptr-casting.vk.nocompat.asm.comp.vk @@ -4,7 +4,7 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_buffer_reference_uvec2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk index 12581cc3f8..9fbe0f8e6e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk @@ -1,21 +1,21 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Alias; -layout(buffer_reference) buffer _6; -layout(buffer_reference) buffer _7; +layout(buffer_reference) buffer _8; +layout(buffer_reference) buffer _9; layout(buffer_reference, buffer_reference_align = 16, std430) readonly buffer Alias { vec4 v[]; }; -layout(buffer_reference, buffer_reference_align = 16, std430) restrict buffer _6 +layout(buffer_reference, buffer_reference_align = 16, std430) restrict buffer _8 { vec4 v[]; }; -layout(buffer_reference, buffer_reference_align = 16, std430) coherent writeonly buffer _7 +layout(buffer_reference, buffer_reference_align = 16, std430) coherent writeonly buffer _9 { vec4 v[]; }; @@ -23,8 +23,8 @@ layout(buffer_reference, buffer_reference_align = 16, std430) coherent writeonly layout(push_constant, std430) uniform Registers { Alias ro; - _6 rw; - _7 wo; + _8 rw; + _9 wo; } registers; void main() diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp.vk new file mode 100644 index 0000000000..2020f8aad1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp.vk @@ -0,0 +1,20 @@ +#version 450 +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer S; +layout(buffer_reference, buffer_reference_align = 4, std430) buffer S +{ + vec4 data[]; +}; + +layout(push_constant, std430) uniform Registers +{ + S s; +} registers; + +void main() +{ + registers.s.data[gl_GlobalInvocationID.x][gl_LocalInvocationIndex] = 40.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp.vk new file mode 100644 index 0000000000..7b2560c183 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp.vk @@ -0,0 +1,28 @@ +#version 450 +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + uint a; + uint b; +}; + +layout(buffer_reference) buffer FooPointer; +layout(std430, buffer_reference, buffer_reference_align = 8) buffer FooPointer +{ + Foo value; +}; + +layout(set = 0, binding = 0, std430) buffer SSBO +{ + Foo foos[4]; + FooPointer ptrfoo; +} _7; + +void main() +{ + _7.foos[0].a = 0u; + _7.ptrfoo.value.a = 1u; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-pod-in-buffer.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-pod-in-buffer.asm.nocompat.vk.comp.vk index 06e620d2c9..9dcf0f3a1e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-pod-in-buffer.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-pod-in-buffer.asm.nocompat.vk.comp.vk @@ -1,7 +1,8 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(buffer_reference) buffer uvec4Pointer; layout(buffer_reference, buffer_reference_align = 8) buffer uvec4Pointer { uvec4 value; @@ -10,10 +11,10 @@ layout(buffer_reference, buffer_reference_align = 8) buffer uvec4Pointer layout(push_constant, std430) uniform Push { uvec4Pointer ptr; -} _4; +} _6; void main() { - _4.ptr.value = uvec4(1u, 2u, 3u, 4u); + _6.ptr.value = uvec4(1u, 2u, 3u, 4u); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp.vk new file mode 100644 index 0000000000..a782649e61 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp.vk @@ -0,0 +1,28 @@ +#version 450 +#extension GL_EXT_buffer_reference2 : require +#extension GL_EXT_buffer_reference_uvec2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer vec20_stride_8Pointer; +layout(buffer_reference) buffer vec20_stride_16Pointer; +layout(std430, buffer_reference, buffer_reference_align = 4) buffer vec20_stride_8Pointer +{ + vec2 value[]; +}; + +layout(std140, buffer_reference, buffer_reference_align = 16) buffer vec20_stride_16Pointer +{ + vec2 value[]; +}; + +layout(push_constant, std430) uniform Registers +{ + uvec2 s; +} registers; + +void main() +{ + vec20_stride_8Pointer(registers.s).value[0u].x = 40.0; + vec20_stride_16Pointer(registers.s).value[0u].x = 40.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-unused-pod-in-buffer.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-unused-pod-in-buffer.asm.nocompat.vk.comp.vk index 44427de81e..cf0a3cbf44 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-unused-pod-in-buffer.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-pointer-to-unused-pod-in-buffer.asm.nocompat.vk.comp.vk @@ -1,7 +1,8 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(buffer_reference) buffer uvec4Pointer; layout(buffer_reference) buffer uvec4Pointer { uvec4 value; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-2.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-2.asm.nocompat.vk.comp.vk index f77142a743..c9a4e9d289 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-2.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-2.asm.nocompat.vk.comp.vk @@ -4,22 +4,23 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(buffer_reference) buffer uintPointer; layout(buffer_reference, buffer_reference_align = 4) buffer uintPointer { uint value; }; -layout(push_constant, std430) uniform _4_12 +layout(push_constant, std430) uniform _6_13 { uint64_t _m0; -} _12; +} _13; void main() { - uintPointer _3 = uintPointer(_12._m0); - _3.value = 20u; + uintPointer _4 = uintPointer(_13._m0); + _4.value = 20u; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk new file mode 100644 index 0000000000..a04ceb1320 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk @@ -0,0 +1,32 @@ +#version 450 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer uintPointer; +layout(buffer_reference) buffer uintPointerPointer; +layout(buffer_reference, buffer_reference_align = 4) buffer uintPointer +{ + uint value; +}; + +layout(buffer_reference, buffer_reference_align = 8) buffer uintPointerPointer +{ + uintPointer value; +}; + +layout(push_constant, std430) uniform _6_14 +{ + uint64_t _m0; +} _14; + +void main() +{ + uintPointer _4 = uintPointerPointer(_14._m0).value; + _4.value = 20u; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer.asm.nocompat.vk.comp.vk index 6ba488be6b..237858744f 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer.asm.nocompat.vk.comp.vk @@ -4,22 +4,23 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(buffer_reference, buffer_reference_align = 4) buffer uint0_Pointer +layout(buffer_reference) buffer uint0_stride_4Pointer; +layout(std430, buffer_reference, buffer_reference_align = 4) buffer uint0_stride_4Pointer { uint value[]; }; -layout(push_constant, std430) uniform _6_14 +layout(push_constant, std430) uniform _8_15 { uint64_t _m0; -} _14; +} _15; void main() { - uint0_Pointer _5 = uint0_Pointer(_14._m0); - _5.value[10] = 20u; + uint0_stride_4Pointer _7 = uint0_stride_4Pointer(_15._m0); + _7.value[10] = 20u; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp index 1f43951a15..1b6619260a 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/constant-lut-name-aliasing.asm.comp @@ -7,10 +7,10 @@ const int indexable_1[4] = int[](4, 5, 6, 7); layout(binding = 0, std430) buffer SSBO { int values[]; -} _6; +} _8; void main() { - _6.values[gl_GlobalInvocationID.x] = indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y]; + _8.values[gl_GlobalInvocationID.x] = indexable[gl_LocalInvocationID.x] + indexable_1[gl_LocalInvocationID.y]; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp index 28b2d1d0e9..12ebd3ecd0 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp @@ -25,21 +25,21 @@ struct A B1 b1_array[4]; }; -layout(binding = 0, std430) buffer _8_3 +layout(binding = 0, std430) buffer _10_4 { A a_block; C c_block; -} _3; +} _4; void main() { - A _27; - _27.a = _3.c_block.c; - _27.b1.elem1 = _3.c_block.b2.elem2; - _27.b1_array[0].elem1 = _3.c_block.b2_array[0].elem2; - _27.b1_array[1].elem1 = _3.c_block.b2_array[1].elem2; - _27.b1_array[2].elem1 = _3.c_block.b2_array[2].elem2; - _27.b1_array[3].elem1 = _3.c_block.b2_array[3].elem2; - _3.a_block = _27; + A _24; + _24.a = _4.c_block.c; + _24.b1.elem1 = _4.c_block.b2.elem2; + _24.b1_array[0].elem1 = _4.c_block.b2_array[0].elem2; + _24.b1_array[1].elem1 = _4.c_block.b2_array[1].elem2; + _24.b1_array[2].elem1 = _4.c_block.b2_array[2].elem2; + _24.b1_array[3].elem1 = _4.c_block.b2_array[3].elem2; + _4.a_block = _24; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp new file mode 100644 index 0000000000..98a2b706c1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp @@ -0,0 +1,12 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 15, std140) uniform type_Primitive +{ + int empty_struct_member; +} Primitive; + +void main() +{ +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/expression-nesting-limits.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/expression-nesting-limits.asm.comp index 83a9b83fa1..73634546ee 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/expression-nesting-limits.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/expression-nesting-limits.asm.comp @@ -18,11 +18,11 @@ layout(binding = 2, std430) buffer _4_7 vec4 _88(vec4 _89) { - for (int _91 = 0; _91 < 16; _91++) + for (int _93 = 0; _93 < 16; _93++) { - uint _163 = _6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + _5._m0[_91])))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); - uint _225 = _6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + _163))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); - _7._m0[_91] = _6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + (_6._m0[_91] + _225)))))))))))))); + uint _160 = _6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + _5._m0[_93])))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); + uint _222 = _6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + _160))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); + _7._m0[_93] = _6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + (_6._m0[_93] + _222)))))))))))))); } return _89; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl-signed-operations.asm.comp index 35edd4dd6d..a906c75608 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl-signed-operations.asm.comp @@ -5,43 +5,43 @@ layout(binding = 0, std430) buffer SSBO { ivec4 ints; uvec4 uints; -} _4; +} _6; void main() { - ivec4 _19 = _4.ints; - uvec4 _20 = _4.uints; - _4.ints = abs(_19); - _4.uints = uvec4(abs(_19)); - _4.ints = abs(ivec4(_20)); - _4.uints = uvec4(abs(ivec4(_20))); - _4.ints = sign(_19); - _4.uints = uvec4(sign(_19)); - _4.ints = sign(ivec4(_20)); - _4.uints = uvec4(sign(ivec4(_20))); - _4.ints = findMSB(ivec4(_20)); - _4.uints = uvec4(findMSB(ivec4(_20))); - _4.ints = findMSB(uvec4(_19)); - _4.uints = uvec4(findMSB(uvec4(_19))); - _4.ints = min(_19, _19); - _4.uints = uvec4(min(_19, ivec4(_20))); - _4.ints = min(ivec4(_20), ivec4(_20)); - _4.uints = uvec4(min(ivec4(_20), _19)); - _4.ints = ivec4(min(uvec4(_19), _20)); - _4.uints = min(uvec4(_19), _20); - _4.ints = ivec4(min(_20, uvec4(_19))); - _4.uints = min(_20, uvec4(_19)); - _4.ints = max(_19, _19); - _4.uints = uvec4(max(_19, _19)); - _4.ints = max(ivec4(_20), _19); - _4.uints = uvec4(max(ivec4(_20), _19)); - _4.ints = ivec4(max(uvec4(_19), _20)); - _4.uints = max(uvec4(_19), uvec4(_19)); - _4.ints = ivec4(max(_20, uvec4(_19))); - _4.uints = max(_20, uvec4(_19)); - _4.ints = clamp(ivec4(_20), ivec4(_20), ivec4(_20)); - _4.uints = uvec4(clamp(ivec4(_20), ivec4(_20), ivec4(_20))); - _4.ints = ivec4(clamp(uvec4(_19), uvec4(_19), uvec4(_19))); - _4.uints = clamp(uvec4(_19), uvec4(_19), uvec4(_19)); + ivec4 _19 = _6.ints; + uvec4 _20 = _6.uints; + _6.ints = abs(_19); + _6.uints = uvec4(abs(_19)); + _6.ints = abs(ivec4(_20)); + _6.uints = uvec4(abs(ivec4(_20))); + _6.ints = sign(_19); + _6.uints = uvec4(sign(_19)); + _6.ints = sign(ivec4(_20)); + _6.uints = uvec4(sign(ivec4(_20))); + _6.ints = findMSB(ivec4(_20)); + _6.uints = uvec4(findMSB(ivec4(_20))); + _6.ints = findMSB(uvec4(_19)); + _6.uints = uvec4(findMSB(uvec4(_19))); + _6.ints = min(_19, _19); + _6.uints = uvec4(min(_19, ivec4(_20))); + _6.ints = min(ivec4(_20), ivec4(_20)); + _6.uints = uvec4(min(ivec4(_20), _19)); + _6.ints = ivec4(min(uvec4(_19), _20)); + _6.uints = min(uvec4(_19), _20); + _6.ints = ivec4(min(_20, uvec4(_19))); + _6.uints = min(_20, uvec4(_19)); + _6.ints = max(_19, _19); + _6.uints = uvec4(max(_19, _19)); + _6.ints = max(ivec4(_20), _19); + _6.uints = uvec4(max(ivec4(_20), _19)); + _6.ints = ivec4(max(uvec4(_19), _20)); + _6.uints = max(uvec4(_19), uvec4(_19)); + _6.ints = ivec4(max(_20, uvec4(_19))); + _6.uints = max(_20, uvec4(_19)); + _6.ints = clamp(ivec4(_20), ivec4(_20), ivec4(_20)); + _6.uints = uvec4(clamp(ivec4(_20), ivec4(_20), ivec4(_20))); + _6.ints = ivec4(clamp(uvec4(_19), uvec4(_19), uvec4(_19))); + _6.uints = clamp(uvec4(_19), uvec4(_19), uvec4(_19)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp index dc0956c345..88bfd0decc 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/glsl.std450.frexp-modf-struct.asm.comp @@ -1,33 +1,33 @@ #version 450 layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -struct _8 +struct _9 { float _m0; float _m1; }; -struct _15 +struct _16 { float _m0; int _m1; }; -layout(binding = 0, std430) buffer _3_4 +layout(binding = 0, std430) buffer _4_6 { float _m0; int _m1; -} _4; +} _6; void main() { - _8 _23; + _9 _23; _23._m0 = modf(20.0, _23._m1); - _15 _24; + _16 _24; _24._m0 = frexp(40.0, _24._m1); - _4._m0 = _23._m0; - _4._m0 = _23._m1; - _4._m0 = _24._m0; - _4._m1 = _24._m1; + _6._m0 = _23._m0; + _6._m0 = _23._m1; + _6._m0 = _24._m0; + _6._m1 = _24._m1; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/image-atomic-nonuniform.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/image-atomic-nonuniform.vk.nocompat.asm.comp.vk index c6c1ea3e26..19dd025e0d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/image-atomic-nonuniform.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/image-atomic-nonuniform.vk.nocompat.asm.comp.vk @@ -6,7 +6,7 @@ layout(set = 0, binding = 0, r32ui) uniform uimage2D uImage[]; void main() { - uint _26 = gl_GlobalInvocationID.z; - uint _31 = imageAtomicAdd(uImage[nonuniformEXT(_26)], ivec2(gl_GlobalInvocationID.xy), 1u); + uint _18 = gl_GlobalInvocationID.z; + uint _31 = imageAtomicAdd(uImage[nonuniformEXT(_18)], ivec2(gl_GlobalInvocationID.xy), 1u); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp index 57587ebfa2..3a4f5db121 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp @@ -9,21 +9,21 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_3 #define SPIRV_CROSS_CONSTANT_ID_3 13u #endif -const uint _4 = SPIRV_CROSS_CONSTANT_ID_3; +const uint _6 = SPIRV_CROSS_CONSTANT_ID_3; #ifndef SPIRV_CROSS_CONSTANT_ID_4 #define SPIRV_CROSS_CONSTANT_ID_4 14u #endif -const uint _5 = SPIRV_CROSS_CONSTANT_ID_4; +const uint _7 = SPIRV_CROSS_CONSTANT_ID_4; layout(local_size_x = 3, local_size_y = SPIRV_CROSS_CONSTANT_ID_1, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; layout(binding = 0, std430) buffer SSBO { vec4 values[]; -} _8; +} _10; void main() { - _8.values[gl_GlobalInvocationID.x] += vec4(2.0); + _10.values[gl_GlobalInvocationID.x] += vec4(2.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp.vk index 0073fbee0c..72c491b986 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp.vk @@ -1,16 +1,16 @@ #version 450 layout(local_size_x = 3, local_size_y_id = 1, local_size_z_id = 2) in; -layout(constant_id = 3) const uint _4 = 13u; -layout(constant_id = 4) const uint _5 = 14u; +layout(constant_id = 3) const uint _6 = 13u; +layout(constant_id = 4) const uint _7 = 14u; layout(set = 0, binding = 0, std430) buffer SSBO { vec4 values[]; -} _8; +} _10; void main() { - _8.values[gl_GlobalInvocationID.x] += vec4(2.0); + _10.values[gl_GlobalInvocationID.x] += vec4(2.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp index 5c2a09d3d4..ae6c1f3965 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp @@ -3,29 +3,29 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_1 #define SPIRV_CROSS_CONSTANT_ID_1 11 #endif -const int _10 = SPIRV_CROSS_CONSTANT_ID_1; +const int _12 = SPIRV_CROSS_CONSTANT_ID_1; #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 12 #endif -const int _11 = SPIRV_CROSS_CONSTANT_ID_2; +const int _13 = SPIRV_CROSS_CONSTANT_ID_2; #ifndef SPIRV_CROSS_CONSTANT_ID_3 #define SPIRV_CROSS_CONSTANT_ID_3 13 #endif #ifndef SPIRV_CROSS_CONSTANT_ID_4 #define SPIRV_CROSS_CONSTANT_ID_4 14 #endif -const uint _29 = (uint(int(gl_WorkGroupSize.x)) + 3u); -const uvec3 _30 = uvec3(_29, int(gl_WorkGroupSize.y), 2u); +const uint _37 = (uint(int(gl_WorkGroupSize.x)) + 3u); +const uvec3 _38 = uvec3(_37, int(gl_WorkGroupSize.y), 2u); layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_3, local_size_y = SPIRV_CROSS_CONSTANT_ID_4, local_size_z = 2) in; layout(binding = 0, std430) buffer SSBO { vec4 values[]; -} _8; +} _10; void main() { - _8.values[gl_GlobalInvocationID.x] = ((((_8.values[gl_GlobalInvocationID.x] + vec4(2.0)) + vec3(_30).xyzz) * float(int(gl_WorkGroupSize.x))) * float(int(gl_WorkGroupSize.y))) * float(int(2u)); + _10.values[gl_GlobalInvocationID.x] = ((((_10.values[gl_GlobalInvocationID.x] + vec4(2.0)) + vec3(_38).xyzz) * float(int(gl_WorkGroupSize.x))) * float(int(gl_WorkGroupSize.y))) * float(int(2u)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp.vk deleted file mode 100644 index b6a78bdf1c..0000000000 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp.vk +++ /dev/null @@ -1,22 +0,0 @@ -#version 450 -layout(local_size_x_id = 3, local_size_y_id = 4, local_size_z = 2) in; - -layout(constant_id = 1) const int _10 = 11; -layout(constant_id = 2) const int _11 = 12; -const uint _29 = (uint(int(gl_WorkGroupSize.x)) + 3u); -const uvec3 _30 = uvec3(_29, int(gl_WorkGroupSize.y), 2u); - -layout(set = 0, binding = 0, std430) buffer SSBO -{ - vec4 values[]; -} _8; - -void main() -{ - vec3 _38 = vec3(_30); - float _41 = float(int(gl_WorkGroupSize.x)); - float _42 = float(int(gl_WorkGroupSize.y)); - float _43 = float(int(2u)); - _8.values[gl_GlobalInvocationID.x] = ((((_8.values[gl_GlobalInvocationID.x] + vec4(2.0)) + _38.xyzz) * _41) * _42) * _43; -} - diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp new file mode 100644 index 0000000000..ae6c1f3965 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp @@ -0,0 +1,31 @@ +#version 450 + +#ifndef SPIRV_CROSS_CONSTANT_ID_1 +#define SPIRV_CROSS_CONSTANT_ID_1 11 +#endif +const int _12 = SPIRV_CROSS_CONSTANT_ID_1; +#ifndef SPIRV_CROSS_CONSTANT_ID_2 +#define SPIRV_CROSS_CONSTANT_ID_2 12 +#endif +const int _13 = SPIRV_CROSS_CONSTANT_ID_2; +#ifndef SPIRV_CROSS_CONSTANT_ID_3 +#define SPIRV_CROSS_CONSTANT_ID_3 13 +#endif +#ifndef SPIRV_CROSS_CONSTANT_ID_4 +#define SPIRV_CROSS_CONSTANT_ID_4 14 +#endif +const uint _37 = (uint(int(gl_WorkGroupSize.x)) + 3u); +const uvec3 _38 = uvec3(_37, int(gl_WorkGroupSize.y), 2u); + +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_3, local_size_y = SPIRV_CROSS_CONSTANT_ID_4, local_size_z = 2) in; + +layout(binding = 0, std430) buffer SSBO +{ + vec4 values[]; +} _10; + +void main() +{ + _10.values[gl_GlobalInvocationID.x] = ((((_10.values[gl_GlobalInvocationID.x] + vec4(2.0)) + vec3(_38).xyzz) * float(int(gl_WorkGroupSize.x))) * float(int(gl_WorkGroupSize.y))) * float(int(2u)); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp.vk new file mode 100644 index 0000000000..e4b9b29cba --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp.vk @@ -0,0 +1,22 @@ +#version 450 +layout(local_size_x_id = 3, local_size_y_id = 4, local_size_z = 2) in; + +layout(constant_id = 1) const int _12 = 11; +layout(constant_id = 2) const int _13 = 12; +const uint _37 = (uint(int(gl_WorkGroupSize.x)) + 3u); +const uvec3 _38 = uvec3(_37, int(gl_WorkGroupSize.y), 2u); + +layout(set = 0, binding = 0, std430) buffer SSBO +{ + vec4 values[]; +} _10; + +void main() +{ + vec3 _39 = vec3(_38); + float _42 = float(int(gl_WorkGroupSize.x)); + float _43 = float(int(gl_WorkGroupSize.y)); + float _44 = float(int(2u)); + _10.values[gl_GlobalInvocationID.x] = ((((_10.values[gl_GlobalInvocationID.x] + vec4(2.0)) + _39.xyzz) * _42) * _43) * _44; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp deleted file mode 100644 index c34852f79c..0000000000 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp +++ /dev/null @@ -1,107 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 4, std430) buffer _2_12 -{ - uint _m0[1]; -} _12; - -layout(binding = 1, std430) buffer _2_9 -{ - uint _m0[1]; -} _9; - -layout(binding = 2, std430) buffer _2_10 -{ - uint _m0[1]; -} _10; - -layout(binding = 3, std430) buffer _2_11 -{ - uint _m0[1]; -} _11; - -layout(binding = 0, std430) buffer _4_8 -{ - uint _m0[2]; -} _8; - -layout(binding = 5, std430) buffer _6_13 -{ - uint _m0[11]; -} _13; - -void main() -{ - uint _43 = 0u; - uint _44 = 0u; - uint _45 = 0u; - uint _46 = 0u; - uint _47 = 0u; - _13._m0[0u] = 8u; - uint _50 = 0u + 1u; - uint _42 = _50; - for (;;) - { - _13._m0[_42] = 9u; - _42++; - uint _55 = _43; - _43 = _55 + 1u; - if (_8._m0[_55] == 1u) - { - _13._m0[_42] = 12u; - _42++; - return; - } - else - { - _13._m0[_42] = 13u; - _42++; - uint _70 = _44; - _44 = _70 + 1u; - if (_9._m0[_70] == 1u) - { - _13._m0[_42] = 11u; - _42++; - _13._m0[_42] = 14u; - _42++; - _45++; - do - { - _13._m0[_42] = 16u; - _42++; - break; - } while(false); - _13._m0[_42] = 15u; - _42++; - uint _94 = _46; - _46 = _94 + 1u; - if (_11._m0[_94] == 1u) - { - } - else - { - _13._m0[_42] = 19u; - _42++; - } - _13._m0[_42] = 17u; - _42++; - uint _108 = _47; - _47 = _108 + 1u; - if (_12._m0[_108] == 1u) - { - continue; - } - else - { - break; - } - } - else - { - break; - } - } - } -} - diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp new file mode 100644 index 0000000000..ef1984b4b3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp @@ -0,0 +1,107 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 4, std430) buffer _1_31 +{ + uint _m0[1]; +} _31; + +layout(binding = 1, std430) buffer _1_28 +{ + uint _m0[1]; +} _28; + +layout(binding = 2, std430) buffer _1_29 +{ + uint _m0[1]; +} _29; + +layout(binding = 3, std430) buffer _1_30 +{ + uint _m0[1]; +} _30; + +layout(binding = 0, std430) buffer _4_27 +{ + uint _m0[2]; +} _27; + +layout(binding = 5, std430) buffer _6_32 +{ + uint _m0[11]; +} _32; + +void main() +{ + uint _55 = 0u; + uint _56 = 0u; + uint _57 = 0u; + uint _58 = 0u; + uint _59 = 0u; + _32._m0[0u] = 8u; + uint _62 = 0u + 1u; + uint _54 = _62; + for (;;) + { + _32._m0[_54] = 9u; + _54++; + uint _66 = _55; + _55 = _66 + 1u; + if (_27._m0[_66] == 1u) + { + _32._m0[_54] = 12u; + _54++; + return; + } + else + { + _32._m0[_54] = 13u; + _54++; + uint _77 = _56; + _56 = _77 + 1u; + if (_28._m0[_77] == 1u) + { + _32._m0[_54] = 11u; + _54++; + _32._m0[_54] = 14u; + _54++; + _57++; + do + { + _32._m0[_54] = 16u; + _54++; + break; + } while(false); + _32._m0[_54] = 15u; + _54++; + uint _98 = _58; + _58 = _98 + 1u; + if (_30._m0[_98] == 1u) + { + } + else + { + _32._m0[_54] = 19u; + _54++; + } + _32._m0[_54] = 17u; + _54++; + uint _109 = _59; + _59 = _109 + 1u; + if (_31._m0[_109] == 1u) + { + continue; + } + else + { + break; + } + } + else + { + break; + } + } + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp deleted file mode 100644 index 08f3b44e0b..0000000000 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp +++ /dev/null @@ -1,108 +0,0 @@ -#version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; - -layout(binding = 4, std430) buffer _2_12 -{ - uint _m0[1]; -} _12; - -layout(binding = 1, std430) buffer _2_9 -{ - uint _m0[1]; -} _9; - -layout(binding = 2, std430) buffer _2_10 -{ - uint _m0[1]; -} _10; - -layout(binding = 3, std430) buffer _2_11 -{ - uint _m0[1]; -} _11; - -layout(binding = 0, std430) buffer _4_8 -{ - uint _m0[2]; -} _8; - -layout(binding = 5, std430) buffer _6_13 -{ - uint _m0[11]; -} _13; - -void main() -{ - uint _43 = 0u; - uint _44 = 0u; - uint _45 = 0u; - uint _46 = 0u; - uint _47 = 0u; - uint _115; - _13._m0[_115] = 8u; - uint _50 = _115 + 1u; - uint _42 = _50; - for (;;) - { - _13._m0[_42] = 9u; - _42++; - uint _55 = _43; - _43 = _55 + 1u; - if (_8._m0[_55] == 1u) - { - _13._m0[_42] = 12u; - _42++; - return; - } - else - { - _13._m0[_42] = 13u; - _42++; - uint _70 = _44; - _44 = _70 + 1u; - if (_9._m0[_70] == 1u) - { - _13._m0[_42] = 11u; - _42++; - _13._m0[_42] = 14u; - _42++; - _45++; - do - { - _13._m0[_42] = 16u; - _42++; - break; - } while(false); - _13._m0[_42] = 15u; - _42++; - uint _94 = _46; - _46 = _94 + 1u; - if (_11._m0[_94] == 1u) - { - } - else - { - _13._m0[_42] = 19u; - _42++; - } - _13._m0[_42] = 17u; - _42++; - uint _108 = _47; - _47 = _108 + 1u; - if (_12._m0[_108] == 1u) - { - continue; - } - else - { - break; - } - } - else - { - break; - } - } - } -} - diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp new file mode 100644 index 0000000000..140edd7921 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp @@ -0,0 +1,108 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 4, std430) buffer _1_31 +{ + uint _m0[1]; +} _31; + +layout(binding = 1, std430) buffer _1_28 +{ + uint _m0[1]; +} _28; + +layout(binding = 2, std430) buffer _1_29 +{ + uint _m0[1]; +} _29; + +layout(binding = 3, std430) buffer _1_30 +{ + uint _m0[1]; +} _30; + +layout(binding = 0, std430) buffer _4_27 +{ + uint _m0[2]; +} _27; + +layout(binding = 5, std430) buffer _6_32 +{ + uint _m0[11]; +} _32; + +void main() +{ + uint _55 = 0u; + uint _56 = 0u; + uint _57 = 0u; + uint _58 = 0u; + uint _59 = 0u; + uint _115; + _32._m0[_115] = 8u; + uint _62 = _115 + 1u; + uint _54 = _62; + for (;;) + { + _32._m0[_54] = 9u; + _54++; + uint _66 = _55; + _55 = _66 + 1u; + if (_27._m0[_66] == 1u) + { + _32._m0[_54] = 12u; + _54++; + return; + } + else + { + _32._m0[_54] = 13u; + _54++; + uint _77 = _56; + _56 = _77 + 1u; + if (_28._m0[_77] == 1u) + { + _32._m0[_54] = 11u; + _54++; + _32._m0[_54] = 14u; + _54++; + _57++; + do + { + _32._m0[_54] = 16u; + _54++; + break; + } while(false); + _32._m0[_54] = 15u; + _54++; + uint _98 = _58; + _58 = _98 + 1u; + if (_30._m0[_98] == 1u) + { + } + else + { + _32._m0[_54] = 19u; + _54++; + } + _32._m0[_54] = 17u; + _54++; + uint _109 = _59; + _59 = _109 + 1u; + if (_31._m0[_109] == 1u) + { + continue; + } + else + { + break; + } + } + else + { + break; + } + } + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/multi-break-switch-out-of-loop.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/multi-break-switch-out-of-loop.asm.comp index 7de95ae6b4..58b2b7a59e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/multi-break-switch-out-of-loop.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/multi-break-switch-out-of-loop.asm.comp @@ -4,45 +4,45 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std140) uniform UBO { int v; -} _6; +} _8; void main() { uint count = 0u; for (int i = 0; i < 4; i++) { - bool _31_ladder_break = false; + bool _15_ladder_break = false; do { - bool _33_ladder_break = false; + bool _23_ladder_break = false; do { - bool _35_ladder_break = false; + bool _25_ladder_break = false; do { - if (_6.v == 20) + if (_8.v == 20) { - _35_ladder_break = true; - _33_ladder_break = true; - _31_ladder_break = true; + _25_ladder_break = true; + _23_ladder_break = true; + _15_ladder_break = true; break; } break; } while(false); - if (_35_ladder_break) + if (_25_ladder_break) { break; } break; } while(false); - if (_33_ladder_break) + if (_23_ladder_break) { break; } count++; break; } while(false); - if (_31_ladder_break) + if (_15_ladder_break) { break; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk index 9b7de0622f..fdc65be27f 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_nonuniform_qualifier : require #extension GL_KHR_shader_subgroup_ballot : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -7,7 +7,7 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0, std430) restrict readonly buffer SSBO_Offsets { uvec2 _m0[]; -} _7; +} _13; layout(push_constant, std430) uniform RootConstants { @@ -21,35 +21,35 @@ layout(push_constant, std430) uniform RootConstants uint _m7; } registers; -layout(set = 1, binding = 0) uniform samplerBuffer _8[]; -layout(set = 4, binding = 0, r32f) uniform imageBuffer _9[]; -layout(set = 4, binding = 0, r32ui) uniform uimageBuffer _10[]; +layout(set = 1, binding = 0) uniform samplerBuffer _18[]; +layout(set = 4, binding = 0, r32f) uniform imageBuffer _22[]; +layout(set = 4, binding = 0, r32ui) uniform uimageBuffer _26[]; void main() { - uint _61 = registers._m4 + 2u; - uint _64 = subgroupBroadcastFirst(_61); - uint _71 = subgroupBroadcastFirst(registers._m4); - uint _76 = registers._m1 + 1u; - uint _79 = subgroupBroadcastFirst(_76); - uint _88 = gl_GlobalInvocationID.x + 4u; - uint _99 = gl_GlobalInvocationID.x + 1024u; - imageStore(_9[registers._m4], int((_99 < _7._m0[_71].y) ? (_99 + _7._m0[_71].x) : 4294967295u), vec4(imageLoad(_9[registers._m4], int((_88 < _7._m0[_71].y) ? (_88 + _7._m0[_71].x) : 4294967295u)))); - uint _106 = gl_GlobalInvocationID.x + 2u; - uint _117 = gl_GlobalInvocationID.x + 2048u; - imageStore(_9[registers._m4], int((_117 < _7._m0[_71].y) ? (_117 + _7._m0[_71].x) : 4294967295u), vec4(texelFetch(_8[_76], int((_106 < _7._m0[_79].y) ? (_106 + _7._m0[_79].x) : 4294967295u)))); - uint _130 = imageAtomicAdd(_10[_61], int((gl_GlobalInvocationID.x < _7._m0[_64].y) ? (gl_GlobalInvocationID.x + _7._m0[_64].x) : 4294967295u), 40u); - uint _137 = imageAtomicCompSwap(_10[_61], int((gl_GlobalInvocationID.y < _7._m0[_64].y) ? (gl_GlobalInvocationID.y + _7._m0[_64].x) : 4294967295u), 40u, 50u); - imageStore(_9[registers._m4], int((0u < _7._m0[_71].y) ? (0u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_71].y))); - imageStore(_9[registers._m4], int((1u < _7._m0[_71].y) ? (1u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_79].y))); - uint _11 = registers._m4 + (gl_GlobalInvocationID.z + 0u); - imageStore(_9[nonuniformEXT(_11)], int((_99 < _7._m0[_11].y) ? (_99 + _7._m0[_11].x) : 4294967295u), vec4(imageLoad(_9[nonuniformEXT(_11)], int((_88 < _7._m0[_11].y) ? (_88 + _7._m0[_11].x) : 4294967295u)))); - uint _13 = registers._m1 + (gl_GlobalInvocationID.z + 0u); - imageStore(_9[nonuniformEXT(_11)], int((_117 < _7._m0[_11].y) ? (_117 + _7._m0[_11].x) : 4294967295u), vec4(texelFetch(_8[nonuniformEXT(_13)], int((_88 < _7._m0[_13].y) ? (_88 + _7._m0[_13].x) : 4294967295u)))); - uint _15 = registers._m4 + (gl_GlobalInvocationID.z + 0u); - uint _209 = imageAtomicAdd(_10[nonuniformEXT(_15)], int((gl_GlobalInvocationID.y < _7._m0[_15].y) ? (gl_GlobalInvocationID.y + _7._m0[_15].x) : 4294967295u), 40u); - uint _215 = imageAtomicCompSwap(_10[nonuniformEXT(_15)], int((gl_GlobalInvocationID.y < _7._m0[_15].y) ? (gl_GlobalInvocationID.y + _7._m0[_15].x) : 4294967295u), 40u, 70u); - imageStore(_9[registers._m4], int((2u < _7._m0[_71].y) ? (2u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_11].y))); - imageStore(_9[registers._m4], int((3u < _7._m0[_71].y) ? (3u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_13].y))); + uint _33 = registers._m4 + 2u; + uint _36 = subgroupBroadcastFirst(_33); + uint _47 = subgroupBroadcastFirst(registers._m4); + uint _55 = registers._m1 + 1u; + uint _57 = subgroupBroadcastFirst(_55); + uint _70 = gl_GlobalInvocationID.x + 4u; + uint _84 = gl_GlobalInvocationID.x + 1024u; + imageStore(_22[registers._m4], int((_84 < _13._m0[_47].y) ? (_84 + _13._m0[_47].x) : 4294967295u), vec4(imageLoad(_22[registers._m4], int((_70 < _13._m0[_47].y) ? (_70 + _13._m0[_47].x) : 4294967295u)))); + uint _92 = gl_GlobalInvocationID.x + 2u; + uint _103 = gl_GlobalInvocationID.x + 2048u; + imageStore(_22[registers._m4], int((_103 < _13._m0[_47].y) ? (_103 + _13._m0[_47].x) : 4294967295u), vec4(texelFetch(_18[_55], int((_92 < _13._m0[_57].y) ? (_92 + _13._m0[_57].x) : 4294967295u)))); + uint _118 = imageAtomicAdd(_26[_33], int((gl_GlobalInvocationID.x < _13._m0[_36].y) ? (gl_GlobalInvocationID.x + _13._m0[_36].x) : 4294967295u), 40u); + uint _126 = imageAtomicCompSwap(_26[_33], int((gl_GlobalInvocationID.y < _13._m0[_36].y) ? (gl_GlobalInvocationID.y + _13._m0[_36].x) : 4294967295u), 40u, 50u); + imageStore(_22[registers._m4], int((0u < _13._m0[_47].y) ? (0u + _13._m0[_47].x) : 4294967295u), vec4(float(_13._m0[_47].y))); + imageStore(_22[registers._m4], int((1u < _13._m0[_47].y) ? (1u + _13._m0[_47].x) : 4294967295u), vec4(float(_13._m0[_57].y))); + uint _148 = registers._m4 + (gl_GlobalInvocationID.z + 0u); + imageStore(_22[nonuniformEXT(_148)], int((_84 < _13._m0[_148].y) ? (_84 + _13._m0[_148].x) : 4294967295u), vec4(imageLoad(_22[nonuniformEXT(_148)], int((_70 < _13._m0[_148].y) ? (_70 + _13._m0[_148].x) : 4294967295u)))); + uint _172 = registers._m1 + (gl_GlobalInvocationID.z + 0u); + imageStore(_22[nonuniformEXT(_148)], int((_103 < _13._m0[_148].y) ? (_103 + _13._m0[_148].x) : 4294967295u), vec4(texelFetch(_18[nonuniformEXT(_172)], int((_70 < _13._m0[_172].y) ? (_70 + _13._m0[_172].x) : 4294967295u)))); + uint _196 = registers._m4 + (gl_GlobalInvocationID.z + 0u); + uint _206 = imageAtomicAdd(_26[nonuniformEXT(_196)], int((gl_GlobalInvocationID.y < _13._m0[_196].y) ? (gl_GlobalInvocationID.y + _13._m0[_196].x) : 4294967295u), 40u); + uint _213 = imageAtomicCompSwap(_26[nonuniformEXT(_196)], int((gl_GlobalInvocationID.y < _13._m0[_196].y) ? (gl_GlobalInvocationID.y + _13._m0[_196].x) : 4294967295u), 40u, 70u); + imageStore(_22[registers._m4], int((2u < _13._m0[_47].y) ? (2u + _13._m0[_47].x) : 4294967295u), vec4(float(_13._m0[_148].y))); + imageStore(_22[registers._m4], int((3u < _13._m0[_47].y) ? (3u + _13._m0[_47].x) : 4294967295u), vec4(float(_13._m0[_172].y))); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/ray-query-force-temporary-rtas.spv14.asm.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/ray-query-force-temporary-rtas.spv14.asm.vk.nocompat.comp.vk index fa46c715ba..7fa555342c 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/ray-query-force-temporary-rtas.spv14.asm.vk.nocompat.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/ray-query-force-temporary-rtas.spv14.asm.vk.nocompat.comp.vk @@ -6,23 +6,23 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0, std430) readonly buffer Buf { uvec2 vas[1024]; -} _3; +} _4; layout(push_constant, std430) uniform Registers { uint index; -} _4; +} _10; rayQueryEXT rq; void main() { - uvec2 _41; + uvec2 _37; do { - uvec2 va = _3.vas[_4.index]; - _41 = _3.vas[_4.index]; + uvec2 va = _4.vas[_10.index]; + _37 = _4.vas[_10.index]; } while (false); - rayQueryInitializeEXT(rq, accelerationStructureEXT(_41), 0u, 0u, vec3(0.0), 0.0, vec3(0.0), 0.0); + rayQueryInitializeEXT(rq, accelerationStructureEXT(_37), 0u, 0u, vec3(0.0), 0.0, vec3(0.0), 0.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp index e7b9dbf337..07aa4e5b39 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp @@ -35,10 +35,10 @@ const int A_11 = (A_10 + A_5); layout(binding = 0, std430) buffer SSBO { int values[]; -} _5; +} _7; void main() { - _5.values[gl_GlobalInvocationID.x] = A_11; + _7.values[gl_GlobalInvocationID.x] = A_11; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp.vk index c31d0787d8..9e5fa2fe5c 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-name-aliasing.vk.asm.comp.vk @@ -17,10 +17,10 @@ const int A_11 = (A_10 + A_5); layout(set = 0, binding = 0, std430) buffer SSBO { int values[]; -} _5; +} _7; void main() { - _5.values[gl_GlobalInvocationID.x] = A_11; + _7.values[gl_GlobalInvocationID.x] = A_11; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-op-convert-sign.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-op-convert-sign.asm.comp index 50ca0fbdbc..fd0ff5b34c 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-op-convert-sign.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/spec-constant-op-convert-sign.asm.comp @@ -20,20 +20,20 @@ const int64_t ConstantInt64_1 = int64_t(ConstantInt); const int64_t ConstantInt64_2 = int64_t(int(ConstantUint)); const uint64_t ConstantUint64_1 = uint64_t(ConstantInt); const uint64_t ConstantUint64_2 = uint64_t(int(ConstantUint)); -const int64_t _20 = (ConstantInt64_1 + ConstantInt64_2); -const uint64_t _21 = (ConstantUint64_1 + ConstantUint64_2); -const int _22 = int(_20); -const uint _23 = uint(_21); +const int64_t _21 = (ConstantInt64_1 + ConstantInt64_2); +const uint64_t _23 = (ConstantUint64_1 + ConstantUint64_2); +const int _24 = int(_21); +const uint _25 = uint(_23); layout(binding = 0, std430) buffer SSBO { int s64; uint u64; -} _4; +} _6; void main() { - _4.s64 = _22; - _4.u64 = _23; + _6.s64 = _24; + _6.u64 = _25; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp index 482cfd8a06..fcbd85047e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp @@ -9,20 +9,20 @@ layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 2, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; -layout(binding = 0, std430) buffer _6_8 +layout(binding = 0, std430) buffer _3_20 { float _m0[]; -} _8; +} _20; -layout(binding = 1, std430) buffer _6_9 +layout(binding = 1, std430) buffer _3_21 { float _m0[]; -} _9; +} _21; -uvec3 _22 = gl_WorkGroupSize; +uvec3 _19 = gl_WorkGroupSize; void main() { - _8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x]; + _20._m0[gl_WorkGroupID.x] = _21._m0[gl_WorkGroupID.x] + _20._m0[gl_WorkGroupID.x]; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk index 22834fa8e7..63fa0e65b2 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk @@ -2,17 +2,17 @@ #extension GL_KHR_shader_subgroup_ballot : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; -layout(set = 0, binding = 0) uniform usamplerBuffer _4; -layout(set = 0, binding = 0, r32ui) uniform writeonly uimageBuffer _5; +layout(set = 0, binding = 0) uniform usamplerBuffer _8; +layout(set = 0, binding = 0, r32ui) uniform writeonly uimageBuffer _11; -uvec4 WaveMatch(uint _45) +uvec4 WaveMatch(uint _25) { - uvec4 _52; + uvec4 _35; for (;;) { - bool _51 = _45 == subgroupBroadcastFirst(_45); - _52 = subgroupBallot(_51); - if (_51) + bool _34 = _25 == subgroupBroadcastFirst(_25); + _35 = subgroupBallot(_34); + if (_34) { break; } @@ -21,16 +21,16 @@ uvec4 WaveMatch(uint _45) continue; } } - return _52; + return _35; } void main() { - uvec4 _32 = WaveMatch(texelFetch(_4, int(gl_GlobalInvocationID.x)).x); - uint _37 = gl_GlobalInvocationID.x * 4u; - imageStore(_5, int(_37), uvec4(_32.x)); - imageStore(_5, int(_37 + 1u), uvec4(_32.y)); - imageStore(_5, int(_37 + 2u), uvec4(_32.z)); - imageStore(_5, int(_37 + 3u), uvec4(_32.w)); + uvec4 _37 = WaveMatch(texelFetch(_8, int(gl_GlobalInvocationID.x)).x); + uint _42 = gl_GlobalInvocationID.x * 4u; + imageStore(_11, int(_42), uvec4(_37.x)); + imageStore(_11, int(_42 + 1u), uvec4(_37.y)); + imageStore(_11, int(_42 + 2u), uvec4(_37.z)); + imageStore(_11, int(_42 + 3u), uvec4(_37.w)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/degenerate-selection-constructs.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/degenerate-selection-constructs.asm.frag index eb1cf0ca94..a15a50ba02 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/degenerate-selection-constructs.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/degenerate-selection-constructs.asm.frag @@ -5,44 +5,44 @@ precision highp int; layout(binding = 1, std140) uniform buf1 { highp vec2 resolution; -} _9; +} _12; layout(binding = 0, std140) uniform buf0 { highp vec2 injectionSwitch; -} _13; +} _17; layout(location = 0) out highp vec4 _GLF_color; bool checkSwap(highp float a, highp float b) { - bool _153 = gl_FragCoord.y < (_9.resolution.y / 2.0); - highp float _160; - if (_153) + bool _33 = gl_FragCoord.y < (_12.resolution.y / 2.0); + highp float _38; + if (_33) { - _160 = a; + _38 = a; } else { - highp float _159 = 0.0; - _160 = _159; + highp float _355 = 0.0; + _38 = _355; } - bool _147; + bool _35; do { - highp float _168; - if (_153) + highp float _39; + if (_33) { - _168 = b; + _39 = b; } else { - highp float _167 = 0.0; - _168 = _167; + highp float _360 = 0.0; + _39 = _360; } - if (_153) + if (_33) { - _147 = _160 > _168; + _35 = _38 > _39; } if (true) { @@ -53,31 +53,31 @@ bool checkSwap(highp float a, highp float b) break; } } while(false); - highp float _180; - if (_153) + highp float _42; + if (_33) { - highp float _179 = 0.0; - _180 = _179; + highp float _367 = 0.0; + _42 = _367; } else { - _180 = a; + _42 = a; } - highp float _186; - if (_153) + highp float _43; + if (_33) { - highp float _185 = 0.0; - _186 = _185; + highp float _372 = 0.0; + _43 = _372; } else { - _186 = b; + _43 = b; } - if (!_153) + if (!_33) { - _147 = _180 < _186; + _35 = _42 < _43; } - return _147; + return _35; } void main() @@ -85,7 +85,7 @@ void main() highp float data[10]; for (int i = 0; i < 10; i++) { - data[i] = float(10 - i) * _13.injectionSwitch.y; + data[i] = float(10 - i) * _17.injectionSwitch.y; } for (int i_1 = 0; i_1 < 9; i_1++) { @@ -106,7 +106,7 @@ void main() } } } - if (gl_FragCoord.x < (_9.resolution.x / 2.0)) + if (gl_FragCoord.x < (_12.resolution.x / 2.0)) { _GLF_color = vec4(data[0] / 10.0, data[5] / 10.0, data[9] / 10.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-1.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-1.asm.frag index f01a3282f1..007a8e0451 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-1.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-1.asm.frag @@ -3,25 +3,25 @@ layout(binding = 0, std430) readonly buffer SSBO { float values0[]; -} _5; +} _7; layout(binding = 1, std430) readonly buffer SSBO1 { float values1[]; -} _7; +} _9; layout(location = 0) out vec2 FragColor; void main() { - vec2 _27; - _27 = vec2(0.0); - vec2 _39; - vec2 _40; - vec2 _41; - for (int _30 = 0; _30 < 16; _39 = _27 * _27, _40 = _39, _40.x = _5.values0[_30], _41 = _40, _41.y = _7.values1[_30], _27 += _41, _30++) + vec2 _61; + _61 = vec2(0.0); + vec2 _34; + vec2 _35; + vec2 _36; + for (int _60 = 0; _60 < 16; _34 = _61 * _61, _35 = _34, _35.x = _7.values0[_60], _36 = _35, _36.y = _9.values1[_60], _61 += _36, _60++) { } - FragColor = _27; + FragColor = _61; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-2.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-2.asm.frag index 37b66f8c3d..8a994333f6 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-2.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-hoisted-temporaries-2.asm.frag @@ -3,27 +3,27 @@ layout(binding = 0, std430) readonly buffer SSBO { float values0[]; -} _5; +} _7; layout(binding = 1, std430) readonly buffer SSBO1 { float values1[]; -} _7; +} _9; layout(location = 0) out vec2 FragColor; void main() { - vec2 _27; - _27 = vec2(0.0); - vec2 _42; - for (int _30 = 0; _30 < 16; _27 += _42, _30++) + vec2 _61; + _61 = vec2(0.0); + vec2 _37; + for (int _60 = 0; _60 < 16; _61 += _37, _60++) { - vec2 _40 = _27 * _27; - _40.x = _5.values0[_30]; - _42 = _40; - _42.y = _7.values1[_30]; + vec2 _35 = _61 * _61; + _35.x = _7.values0[_60]; + _37 = _35; + _37.y = _9.values1[_60]; } - FragColor = _27; + FragColor = _61; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-inheritance.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-inheritance.asm.frag index 11c1f4ca3c..c7648b958e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-inheritance.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/composite-insert-inheritance.asm.frag @@ -2,7 +2,7 @@ precision mediump float; precision highp int; -vec4 _32; +vec4 _33; layout(location = 0) in vec4 vInput; layout(location = 0) out vec4 FragColor; @@ -16,21 +16,21 @@ void main() _38.z = 3.0; _38.w = 4.0; FragColor = _38; - vec4 _6 = _37; - _6.x = 1.0; - _6.y = 2.0; - _6.z = 3.0; - _6.w = 4.0; - FragColor = _6; + vec4 _8 = _37; + _8.x = 1.0; + _8.y = 2.0; + _8.z = 3.0; + _8.w = 4.0; + FragColor = _8; highp vec4 _42 = _37; _42.x = 1.0; - vec4 _10 = _42; - _10.y = 2.0; - highp vec4 _43 = _10; + vec4 _12 = _42; + _12.y = 2.0; + highp vec4 _43 = _12; _43.z = 3.0; - vec4 _11 = _43; - _11.w = 4.0; - FragColor = _11; + vec4 _13 = _43; + _13.w = 4.0; + FragColor = _13; highp vec4 _44 = _37; _44.x = 1.0; highp vec4 _45 = _44; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/demote-impure-function-call.vk.nocompat.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/demote-impure-function-call.vk.nocompat.asm.frag.vk index adde5fcbf4..271a739f1d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/demote-impure-function-call.vk.nocompat.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/demote-impure-function-call.vk.nocompat.asm.frag.vk @@ -16,7 +16,7 @@ vec4 foobar(int a) void main() { int param = vA; - vec4 _25 = foobar(param); + vec4 _30 = foobar(param); FragColor = vec4(10.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/discard-impure-function-call.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/discard-impure-function-call.asm.frag index 0fe71f64b4..589e634c77 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/discard-impure-function-call.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/discard-impure-function-call.asm.frag @@ -15,7 +15,7 @@ vec4 foobar(int a) void main() { int param = vA; - vec4 _25 = foobar(param); + vec4 _31 = foobar(param); FragColor = vec4(10.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/do-while-continue-phi.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/do-while-continue-phi.asm.invalid.frag index 2024c302ef..f2b8e1bff9 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/do-while-continue-phi.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/do-while-continue-phi.asm.invalid.frag @@ -8,12 +8,12 @@ void main() { for (;;) { - bool _32; + bool _41; for (;;) { if (gl_FragCoord.x != gl_FragCoord.x) { - _32 = true; + _41 = true; break; } if (false) @@ -22,11 +22,11 @@ void main() } else { - _32 = false; + _41 = false; break; } } - if (_32) + if (_41) { break; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/empty-struct-in-struct.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/empty-struct-in-struct.asm.frag index 0d3958b5b0..d9c3967761 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/empty-struct-in-struct.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/empty-struct-in-struct.asm.frag @@ -22,10 +22,10 @@ float GetValue_1(EmptyStruct2Test self) void main() { - EmptyStructTest _25 = EmptyStructTest(0); + EmptyStructTest _27 = EmptyStructTest(0); EmptyStruct2Test emptyStruct; float value = GetValue(emptyStruct); - value = GetValue_1(EmptyStruct2Test(_25)); + value = GetValue_1(EmptyStruct2Test(_27)); value = GetValue_1(EmptyStruct2Test(EmptyStructTest(0))); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-inverted.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-inverted.asm.invalid.frag index 16c7dc3630..46f71b163e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-inverted.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-inverted.asm.invalid.frag @@ -2,10 +2,10 @@ void main() { - int _13; - for (int _12 = 0; !(_12 == 16); _12 = _13) + int _12; + for (int _10 = 0; !(_10 == 16); _10 = _12) { - _13 = _12 + 1; + _12 = _10 + 1; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag index b4c0631852..8507ba350d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag @@ -2,10 +2,10 @@ void main() { - int _13; - for (int _12 = 0; _12 != 16; _12 = _13) + int _12; + for (int _10 = 0; _10 != 16; _10 = _12) { - _13 = _12 + 1; + _12 = _10 + 1; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-inverted-test.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-inverted-test.asm.frag index 16c7dc3630..46f71b163e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-inverted-test.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/for-loop-inverted-test.asm.frag @@ -2,10 +2,10 @@ void main() { - int _13; - for (int _12 = 0; !(_12 == 16); _12 = _13) + int _12; + for (int _10 = 0; !(_10 == 16); _10 = _12) { - _13 = _12 + 1; + _12 = _10 + 1; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag index 874bc6de13..4eb65b0f6b 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -61,19 +61,19 @@ struct Params vec4 LqmatFarTilingFactor; }; -VertexOutput _121; -SurfaceInput _122; -vec2 _123; -vec4 _124; -Surface _125; -vec4 _192; -vec4 _219; -vec4 _297; +VertexOutput _1509; +SurfaceInput _1510; +vec2 _1511; +vec4 _1512; +Surface _1531; +vec4 _1157; +vec4 _1203; +vec4 _1284; layout(binding = 0, std140) uniform CB0 { Globals CB0; -} _19; +} _24; uniform sampler2D SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler; uniform sampler2D SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler; @@ -97,117 +97,117 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - VertexOutput _128; - _128.HPosition = gl_FragCoord; - _128.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; - _128.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; - _128.Color = IN_Color; - _128.LightPosition_Fog = IN_LightPosition_Fog; - _128.View_Depth = IN_View_Depth; - _128.Normal_SpecPower = IN_Normal_SpecPower; - _128.Tangent = IN_Tangent; - _128.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; - _128.studIndex = IN_studIndex; - SurfaceInput _147; - _147.Color = IN_Color; - _147.Uv = IN_Uv_EdgeDistance1.xy; - _147.UvStuds = IN_UvStuds_EdgeDistance2.xy; - _147.UvStuds.y = (fract(_147.UvStuds.y) + IN_studIndex) * 0.25; - float _160 = clamp(1.0 - (_128.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0); - float _163 = _128.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; + VertexOutput _1378; + _1378.HPosition = gl_FragCoord; + _1378.Uv_EdgeDistance1 = IN_Uv_EdgeDistance1; + _1378.UvStuds_EdgeDistance2 = IN_UvStuds_EdgeDistance2; + _1378.Color = IN_Color; + _1378.LightPosition_Fog = IN_LightPosition_Fog; + _1378.View_Depth = IN_View_Depth; + _1378.Normal_SpecPower = IN_Normal_SpecPower; + _1378.Tangent = IN_Tangent; + _1378.PosLightSpace_Reflectance = IN_PosLightSpace_Reflectance; + _1378.studIndex = IN_studIndex; + SurfaceInput _1400; + _1400.Color = IN_Color; + _1400.Uv = IN_Uv_EdgeDistance1.xy; + _1400.UvStuds = IN_UvStuds_EdgeDistance2.xy; + _1400.UvStuds.y = (fract(_1400.UvStuds.y) + IN_studIndex) * 0.25; + float _987 = clamp(1.0 - (_1378.View_Depth.w * 0.00333332992158830165863037109375), 0.0, 1.0); + float _978 = _1378.View_Depth.w * _24.CB0.RefractionBias_FadeDistance_GlowFactor.y; + float _990 = clamp(1.0 - _978, 0.0, 1.0); + vec2 _1024 = IN_Uv_EdgeDistance1.xy * 1.0; + bool _1124; + vec4 _1517; for (;;) { - _173 = 0.0 == 0.0; - if (_173) + _1124 = 0.0 == 0.0; + if (_1124) { - _193 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _166); + _1517 = texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _1024); 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((_160 * _180) - (0.0 * _180), 0.0, 1.0))); + float _1135 = 1.0 / (1.0 - 0.0); + _1517 = mix(texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _1024 * 0.25), texture(SPIRV_Cross_CombinedDiffuseMapTextureDiffuseMapSampler, _1024), vec4(clamp((_987 * _1135) - (0.0 * _1135), 0.0, 1.0))); break; } - _193 = _192; + _1517 = _1157; break; } - vec4 _220; + vec4 _1523; for (;;) { - if (_173) + if (_1124) { - _220 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _166); + _1523 = texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _1024); 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))); + float _1181 = 1.0 / (1.0 - 0.0); + _1523 = mix(texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _1024 * 0.25), texture(SPIRV_Cross_CombinedNormalMapTextureNormalMapSampler, _1024), vec4(clamp((_990 * _1181) - (0.0 * _1181), 0.0, 1.0))); break; } - _220 = _219; + _1523 = _1203; break; } - 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))); - vec4 _237 = texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0); - vec2 _240 = (_237.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); - vec4 _268 = texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _147.UvStuds); - vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (_268.x * 2.0); - vec4 _298; + vec2 _1212 = vec2(1.0); + vec2 _1213 = (_1523.wy * 2.0) - _1212; + vec3 _1224 = vec3(_1213, sqrt(clamp(1.0 + dot(-_1213, _1213), 0.0, 1.0))); + vec4 _1047 = texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _1024 * 0.0); + vec2 _1231 = (_1047.wy * 2.0) - _1212; + vec2 _1054 = _1224.xy + (vec3(_1231, sqrt(clamp(1.0 + dot(-_1231, _1231), 0.0, 1.0))).xy * 0.0); + vec3 _1056 = vec3(_1054.x, _1054.y, _1224.z); + vec2 _1060 = _1056.xy * _990; + vec3 _1062 = vec3(_1060.x, _1060.y, _1056.z); + vec4 _1080 = texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _1400.UvStuds); + vec3 _1085 = ((IN_Color.xyz * (_1517 * 1.0).xyz) * (1.0 + (_1062.x * 0.300000011920928955078125))) * (_1080.x * 2.0); + vec4 _1530; for (;;) { if (0.75 == 0.0) { - _298 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _166); + _1530 = texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _1024); 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))); + float _1262 = 1.0 / (1.0 - 0.75); + _1530 = mix(texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _1024 * 0.25), texture(SPIRV_Cross_CombinedSpecularMapTextureSpecularMapSampler, _1024), vec4(clamp((_990 * _1262) - (0.75 * _1262), 0.0, 1.0))); break; } - _298 = _297; + _1530 = _1284; break; } - vec2 _303 = mix(vec2(0.800000011920928955078125, 120.0), (_298.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_165)); - Surface _304; - _304.albedo = _271; - _304.normal = _256; - float _306 = _303.x; - _304.specular = _306; - float _308 = _303.y; - _304.gloss = _308; - float _312 = (_298.xy.y * _165) * 0.0; - _304.reflectance = _312; - vec4 _318 = vec4(_271, _128.Color.w); - vec3 _329 = normalize(((IN_Tangent * _304.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _304.normal.y)) + (IN_Normal_SpecPower.xyz * _304.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)); - vec3 _422 = (((_19.CB0.AmbientColor + (((_19.CB0.Lamp0Color * clamp(_333, 0.0, 1.0)) + (_19.CB0.Lamp1Color * max(-_333, 0.0))) * _392)) + _368.xyz) * vec4(_403.x, _403.y, _403.z, _318.w).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 _423 = vec4(_422.x, _422.y, _422.z, _124.w); - _423.w = vec4(_403.x, _403.y, _403.z, _318.w).w; - vec2 _435 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); - float _439 = min(_435.x, _435.y) / _163; - vec3 _445 = _423.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, _423.w); - vec3 _453 = mix(_19.CB0.FogColor, _446.xyz, vec3(clamp(_128.LightPosition_Fog.w, 0.0, 1.0))); - _entryPointOutput = vec4(_453.x, _453.y, _453.z, _446.w); + vec2 _1098 = mix(vec2(0.800000011920928955078125, 120.0), (_1530.xy * vec2(2.0, 256.0)) + vec2(0.0, 0.00999999977648258209228515625), vec2(_990)); + Surface _1438; + _1438.albedo = _1085; + _1438.normal = _1062; + float _1442 = _1098.x; + _1438.specular = _1442; + float _1446 = _1098.y; + _1438.gloss = _1446; + float _1113 = (_1530.xy.y * _990) * 0.0; + _1438.reflectance = _1113; + vec4 _767 = vec4(_1085, _1378.Color.w); + vec3 _791 = normalize(((IN_Tangent * _1438.normal.x) + (cross(IN_Normal_SpecPower.xyz, IN_Tangent) * _1438.normal.y)) + (IN_Normal_SpecPower.xyz * _1438.normal.z)); + vec3 _795 = -_24.CB0.Lamp0Dir; + float _796 = dot(_791, _795); + float _1328 = clamp(dot(step(_24.CB0.LightConfig3.xyz, abs(IN_LightPosition_Fog.xyz - _24.CB0.LightConfig2.xyz)), vec3(1.0)), 0.0, 1.0); + vec4 _1325 = mix(texture(SPIRV_Cross_CombinedLightMapTextureLightMapSampler, IN_LightPosition_Fog.xyz.yzx - (IN_LightPosition_Fog.xyz.yzx * _1328)), _24.CB0.LightBorder, vec4(_1328)); + vec2 _1341 = texture(SPIRV_Cross_CombinedShadowMapTextureShadowMapSampler, IN_PosLightSpace_Reflectance.xyz.xy).xy; + float _1356 = (1.0 - (((step(_1341.x, IN_PosLightSpace_Reflectance.xyz.z) * clamp(9.0 - (20.0 * abs(IN_PosLightSpace_Reflectance.xyz.z - 0.5)), 0.0, 1.0)) * _1341.y) * _24.CB0.OutlineBrightness_ShadowInfo.w)) * _1325.w; + vec3 _846 = mix(_767.xyz, texture(SPIRV_Cross_CombinedEnvironmentMapTextureEnvironmentMapSampler, reflect(-IN_View_Depth.xyz, _791)).xyz, vec3(_1113)); + vec3 _884 = (((_24.CB0.AmbientColor + (((_24.CB0.Lamp0Color * clamp(_796, 0.0, 1.0)) + (_24.CB0.Lamp1Color * max(-_796, 0.0))) * _1356)) + _1325.xyz) * vec4(_846.x, _846.y, _846.z, _767.w).xyz) + (_24.CB0.Lamp0Color * (((step(0.0, _796) * _1442) * _1356) * pow(clamp(dot(_791, normalize(_795 + normalize(IN_View_Depth.xyz))), 0.0, 1.0), _1446))); + vec4 _886 = vec4(_884.x, _884.y, _884.z, _1512.w); + _886.w = vec4(_846.x, _846.y, _846.z, _767.w).w; + vec2 _909 = min(IN_Uv_EdgeDistance1.wz, IN_UvStuds_EdgeDistance2.wz); + float _916 = min(_909.x, _909.y) / _978; + vec3 _926 = _886.xyz * clamp((clamp((_978 * _24.CB0.OutlineBrightness_ShadowInfo.x) + _24.CB0.OutlineBrightness_ShadowInfo.y, 0.0, 1.0) * (1.5 - _916)) + _916, 0.0, 1.0); + vec4 _928 = vec4(_926.x, _926.y, _926.z, _886.w); + vec3 _938 = mix(_24.CB0.FogColor, _928.xyz, vec3(clamp(_1378.LightPosition_Fog.w, 0.0, 1.0))); + _entryPointOutput = vec4(_938.x, _938.y, _938.z, _928.w); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/late-expression-invalidation-2.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/late-expression-invalidation-2.asm.frag index ed853d0125..c2f53d9c3d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/late-expression-invalidation-2.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/late-expression-invalidation-2.asm.frag @@ -17,17 +17,17 @@ precision highp int; layout(binding = 0, std140) uniform buf0 { highp vec2 resolution; -} _7; +} _9; layout(location = 0) out highp vec4 _GLF_color; int map[256]; -highp mat2x4 _60 = mat2x4(vec4(0.0), vec4(0.0)); +highp mat2x4 _558 = mat2x4(vec4(0.0), vec4(0.0)); void main() { - int _65 = 256 - 14; - int _68 = -_65; - highp vec2 pos = gl_FragCoord.xy / _7.resolution; + int _564 = 256 - 14; + int _566 = -_564; + highp vec2 pos = gl_FragCoord.xy / _9.resolution; ivec2 ipos = ivec2(int(pos.x * 16.0), int(pos.y * 16.0)); int i = 0; for (; i < 256; i++) @@ -41,60 +41,60 @@ void main() { v++; int directions = 0; - bool _98 = p.x > 0; - bool _111; - if (_98) + bool _77 = p.x > 0; + bool _92; + if (_77) { - _111 = map[(p.x - 2) + (p.y * 16)] == 0; + _92 = map[(p.x - 2) + (p.y * 16)] == 0; } else { - _111 = _98; + _92 = _77; } - if (_111) + if (_92) { directions++; } - bool _118 = p.y > 0; - bool _131; - if (_118) + bool _99 = p.y > 0; + bool _112; + if (_99) { - _131 = map[p.x + ((p.y - 2) * 16)] == 0; + _112 = map[p.x + ((p.y - 2) * 16)] == 0; } else { - _131 = _118; + _112 = _99; } - if (_131) + if (_112) { directions++; } - bool _138 = p.x < 14; - bool _151; - if (_138) + bool _120 = p.x < 14; + bool _133; + if (_120) { - _151 = map[(p.x + 2) + (p.y * 16)] == 0; + _133 = map[(p.x + 2) + (p.y * 16)] == 0; } else { - _151 = _138; + _133 = _120; } - if (_151) + if (_133) { directions++; } - int _156 = 256 - _68; - bool _159 = p.y < 14; - bool _172; - if (_159) + int _594 = 256 - _566; + bool _140 = p.y < 14; + bool _153; + if (_140) { - _172 = map[p.x + ((p.y + 2) * 16)] == 0; + _153 = map[p.x + ((p.y + 2) * 16)] == 0; } else { - _172 = _159; + _153 = _140; } - if (_172) + if (_153) { directions++; } @@ -104,15 +104,15 @@ void main() i = 0; for (;;) { - int _186 = i; - if (_186 < 8) + int _168 = i; + if (_168 < 8) { int j = 0; - _60 = mat2x4(vec4(0.0), vec4(0.0)); + _558 = mat2x4(vec4(0.0), vec4(0.0)); if (false) { - int _216 = i; - i = _216 + 1; + int _198 = i; + i = _198 + 1; continue; } else @@ -127,8 +127,8 @@ void main() canwalk = true; } } - int _216 = i; - i = _216 + 1; + int _198 = i; + i = _198 + 1; continue; } } @@ -143,26 +143,26 @@ void main() { int d = v % directions; v += directions; - bool _232 = d >= 0; - bool _238; - if (_232) + bool _216 = d >= 0; + bool _222; + if (_216) { - _238 = p.x > 0; + _222 = p.x > 0; } else { - _238 = _232; + _222 = _216; } - bool _251; - if (_238) + bool _235; + if (_222) { - _251 = map[(p.x - 2) + (p.y * 16)] == 0; + _235 = map[(p.x - 2) + (p.y * 16)] == 0; } else { - _251 = _238; + _235 = _222; } - if (_251) + if (_235) { d--; map[p.x + (p.y * 16)] = 1; @@ -170,26 +170,26 @@ void main() map[(p.x - 2) + (p.y * 16)] = 1; p.x -= 2; } - bool _284 = d >= 0; - bool _290; - if (_284) + bool _268 = d >= 0; + bool _274; + if (_268) { - _290 = p.y > 0; + _274 = p.y > 0; } else { - _290 = _284; + _274 = _268; } - bool _303; - if (_290) + bool _287; + if (_274) { - _303 = map[p.x + ((p.y - 2) * 16)] == 0; + _287 = map[p.x + ((p.y - 2) * 16)] == 0; } else { - _303 = _290; + _287 = _274; } - if (_303) + if (_287) { d--; map[p.x + (p.y * 16)] = 1; @@ -197,26 +197,26 @@ void main() map[p.x + ((p.y - 2) * 16)] = 1; p.y -= 2; } - bool _336 = d >= 0; - bool _342; - if (_336) + bool _320 = d >= 0; + bool _326; + if (_320) { - _342 = p.x < 14; + _326 = p.x < 14; } else { - _342 = _336; + _326 = _320; } - bool _355; - if (_342) + bool _339; + if (_326) { - _355 = map[(p.x + 2) + (p.y * 16)] == 0; + _339 = map[(p.x + 2) + (p.y * 16)] == 0; } else { - _355 = _342; + _339 = _326; } - if (_355) + if (_339) { d--; map[p.x + (p.y * 16)] = 1; @@ -224,26 +224,26 @@ void main() map[(p.x + 2) + (p.y * 16)] = 1; p.x += 2; } - bool _388 = d >= 0; - bool _394; - if (_388) + bool _372 = d >= 0; + bool _378; + if (_372) { - _394 = p.y < 14; + _378 = p.y < 14; } else { - _394 = _388; + _378 = _372; } - bool _407; - if (_394) + bool _391; + if (_378) { - _407 = map[p.x + ((p.y + 2) * 16)] == 0; + _391 = map[p.x + ((p.y + 2) * 16)] == 0; } else { - _407 = _394; + _391 = _378; } - if (_407) + if (_391) { d--; map[p.x + (p.y * 16)] = 1; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/ldexp-uint-exponent.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/ldexp-uint-exponent.asm.frag index 4ce9b25357..02955da38c 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/ldexp-uint-exponent.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/ldexp-uint-exponent.asm.frag @@ -6,8 +6,8 @@ layout(location = 0) out highp vec4 _GLF_color; void main() { - mediump uvec4 _4 = uvec4(bitCount(uvec4(1u))); - uvec4 hp_copy_4 = _4; - _GLF_color = ldexp(vec4(1.0), ivec4(hp_copy_4)); + mediump uvec4 _18 = uvec4(bitCount(uvec4(1u))); + uvec4 hp_copy_18 = _18; + _GLF_color = ldexp(vec4(1.0), ivec4(hp_copy_18)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-bracket-handling-2.vk.nocompat.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-bracket-handling-2.vk.nocompat.asm.frag.vk index d2f964674f..83ae576750 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-bracket-handling-2.vk.nocompat.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-bracket-handling-2.vk.nocompat.asm.frag.vk @@ -4,7 +4,7 @@ layout(set = 0, binding = 0, std430) readonly buffer SSBO { uint indices[]; -} _8; +} _12; layout(set = 0, binding = 0) uniform sampler2D uSamplers[]; layout(set = 1, binding = 0) uniform sampler2D uSampler; @@ -14,7 +14,7 @@ layout(location = 0) in vec2 vUV; void main() { - FragColor = textureLod(uSamplers[nonuniformEXT(_8.indices[10])], vUV, 0.0); - FragColor += textureLod(uSampler, vUV, float(_8.indices[int(gl_FragCoord.y)])); + FragColor = textureLod(uSamplers[nonuniformEXT(_12.indices[10])], vUV, 0.0); + FragColor += textureLod(uSampler, vUV, float(_12.indices[int(gl_FragCoord.y)])); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk index 289f576f6d..b71befdc8a 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk @@ -22,16 +22,16 @@ layout(location = 1) in vec2 vUV; void main() { int i = vIndex; - int _59 = i + 10; - int _64 = i + 40; - FragColor = texture(nonuniformEXT(sampler2D(uSamplers[_59], uSamps[_64])), vUV); - int _71 = i + 10; - FragColor = texture(uCombinedSamplers[nonuniformEXT(_71)], vUV); - int _77 = i + 20; - int _80 = i + 40; - FragColor += ubos[nonuniformEXT(_77)].v[_80]; - int _87 = i + 50; - int _90 = i + 60; - FragColor += ssbos[nonuniformEXT(_87)].v[_90]; + int _23 = i + 10; + int _34 = i + 40; + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[_23], uSamps[_34])), vUV); + int _50 = i + 10; + FragColor = texture(uCombinedSamplers[nonuniformEXT(_50)], vUV); + int _66 = i + 20; + int _70 = i + 40; + FragColor += ubos[nonuniformEXT(_66)].v[_70]; + int _84 = i + 50; + int _88 = i + 60; + FragColor += ssbos[nonuniformEXT(_84)].v[_88]; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk index 2d98ec5fdf..946481ea50 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk @@ -13,12 +13,12 @@ layout(location = 0) out vec4 FragColor; void main() { int i = vIndex; - int _42 = i + 60; - int _45 = i + 70; - ssbos[nonuniformEXT(_42)].v[_45] = vec4(20.0); - int _48 = i + 100; - uint _49 = atomicAdd(ssbos[nonuniformEXT(_48)].counter, 100u); - int _51 = i; - FragColor.z += float(int(uint(ssbos[nonuniformEXT(_51)].v.length()))); + int _23 = i + 60; + int _28 = i + 70; + ssbos[nonuniformEXT(_23)].v[_28] = vec4(20.0); + int _36 = i + 100; + uint _43 = atomicAdd(ssbos[nonuniformEXT(_36)].counter, 100u); + int _47 = i; + FragColor.z += float(int(uint(ssbos[nonuniformEXT(_47)].v.length()))); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag index 1041f711f8..73f77e0f88 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -1,8 +1,8 @@ #version 450 -const float _3_init = 0.5; +const float _4_init = 0.5; void main() { - gl_FragDepth = _3_init; + gl_FragDepth = _4_init; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi-alternative-precision.asm..vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi-alternative-precision.asm..vk.nocompat.frag.vk index ae9a8d6905..3e1a5b046f 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi-alternative-precision.asm..vk.nocompat.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi-alternative-precision.asm..vk.nocompat.frag.vk @@ -5,25 +5,25 @@ layout(location = 0) out float FragColor; void main() { - float hp_copy_7; - mediump float _7; - int _22; - _22 = 0; - _7 = 0.0; + float hp_copy_39; + mediump float _39; + int _40; + _40 = 0; + _39 = 0.0; for (;;) { - hp_copy_7 = _7; - int _23 = _22 + 1; - if (_23 < 4) + hp_copy_39 = _39; + int _27 = _40 + 1; + if (_27 < 4) { - _22 = _23; - _7 = fma(_7, b, b); + _40 = _27; + _39 = fma(_39, b, b); } else { break; } } - FragColor = hp_copy_7 * 4.0; + FragColor = hp_copy_39 * 4.0; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi.zero-initialize.asm.frag index 59bac99454..483b8acdb6 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/phi.zero-initialize.asm.frag @@ -16,14 +16,14 @@ layout(location = 0) out vec4 FragColor; void main() { - int _39 = 0; + int _27 = 0; if (vColor.x > 10.0) { - _39 = 10; + _27 = 10; } else { - _39 = 20; + _27 = 20; } FragColor = vColor; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-callstack.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-callstack.asm.frag index 7ba3fd5581..4380e7c74e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-callstack.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-callstack.asm.frag @@ -17,23 +17,23 @@ layout(pixel_interlock_ordered) in; layout(binding = 1, std430) buffer SSBO1 { uint values1[]; -} _7; +} _11; layout(binding = 0, std430) buffer SSBO0 { uint values0[]; -} _9; +} _13; void callee2() { - int _31 = int(gl_FragCoord.x); - _7.values1[_31]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } void callee() { - int _39 = int(gl_FragCoord.x); - _9.values0[_39]++; + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; callee2(); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-control-flow.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-control-flow.asm.frag index 3575e02c8b..23a524e452 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-control-flow.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-control-flow.asm.frag @@ -17,43 +17,43 @@ layout(pixel_interlock_ordered) in; layout(binding = 1, std430) buffer SSBO1 { uint values1[]; -} _7; +} _11; -layout(binding = 2, std430) buffer _12_13 +layout(binding = 2, std430) buffer _16_17 { uint _m0[]; -} _13; +} _17; layout(binding = 0, std430) buffer SSBO0 { uint values0[]; -} _9; +} _13; void callee2() { - int _44 = int(gl_FragCoord.x); - _7.values1[_44]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } void callee() { - int _52 = int(gl_FragCoord.x); - _9.values0[_52]++; + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; callee2(); if (true) { } } -void _35() +void _52() { - _13._m0[int(gl_FragCoord.x)] = 4u; + _17._m0[int(gl_FragCoord.x)] = 4u; } void spvMainInterlockedBody() { callee(); - _35(); + _52(); } void main() diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-split-functions.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-split-functions.asm.frag index 806eedf9fb..868cb1de2e 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-split-functions.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/pixel-interlock-split-functions.asm.frag @@ -17,39 +17,39 @@ layout(pixel_interlock_ordered) in; layout(binding = 1, std430) buffer SSBO1 { uint values1[]; -} _7; +} _11; layout(binding = 0, std430) buffer SSBO0 { uint values0[]; -} _9; +} _13; void callee2() { - int _37 = int(gl_FragCoord.x); - _7.values1[_37]++; + int _25 = int(gl_FragCoord.x); + _11.values1[_25]++; } void callee() { - int _45 = int(gl_FragCoord.x); - _9.values0[_45]++; + int _38 = int(gl_FragCoord.x); + _13.values0[_38]++; callee2(); } -void _29() +void _46() { } -void _31() +void _48() { } void spvMainInterlockedBody() { callee(); - _29(); - _31(); + _46(); + _48(); } void main() diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules-hoisted-temporaries.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules-hoisted-temporaries.asm.frag index 6078efae88..f2dd619f06 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules-hoisted-temporaries.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules-hoisted-temporaries.asm.frag @@ -10,11 +10,11 @@ void main() float a = vColor.x; highp float b = vColor.y; int i = 0; - float _14; - highp float hp_copy_14; - float _15; - highp float hp_copy_15; - for (; i < 4; i++, _14 = a, hp_copy_14 = _14, _15 = a * _14, hp_copy_15 = _15, b += (hp_copy_15 * hp_copy_14)) + float _44; + highp float hp_copy_44; + float _45; + highp float hp_copy_45; + for (; i < 4; i++, _44 = a, hp_copy_44 = _44, _45 = a * _44, hp_copy_45 = _45, b += (hp_copy_45 * hp_copy_44)) { FragColor += vec4(1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules.asm.frag index 5aef013e52..dc3f692752 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/relaxed-precision-inheritance-rules.asm.frag @@ -33,12 +33,12 @@ void main() FragColor0 = V4_value0 + vec4(3.0); FragColor1 = _48; FragColor2 = mp_copy_48 * vec4(3.0); - float _21 = V1_value0 + 3.0; + float _23 = V1_value0 + 3.0; float float_0_weird = 3.0 - mp_copy_ubo_hp0; highp float hp_copy_float_0_weird = float_0_weird; highp float _49 = hp_copy_V1_value0 - hp_copy_float_0_weird; float mp_copy_49 = _49; - FragColor3 = vec4(_21, _49, mp_copy_49 * mp_copy_ubo_hp0, 3.0); + FragColor3 = vec4(_23, _49, mp_copy_49 * mp_copy_ubo_hp0, 3.0); highp float _51 = hp_copy_V1_value2 - hp_copy_ubo_mp0; float mp_copy_51 = _51; FragColor3 = vec4(V4_value0.z + ubo_mp0, _51, mp_copy_51 * mp_copy_ubo_hp0, 3.0); @@ -46,7 +46,7 @@ void main() FragColor1 = sin(V4_value0); float phi_mp; highp float phi_hp; - phi_mp = _21; + phi_mp = _23; phi_hp = _49; hp_copy_phi_mp = phi_mp; mp_copy_phi_hp = phi_hp; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..ebf26eb2d5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,16 @@ +#version 450 + +void main() +{ + uint _16_unrolled[1]; + for (int i = 0; i < int(1); i++) + { + _16_unrolled[i] = int(gl_SampleMaskIn[i]); + } + uint copy_sample_mask[1] = _16_unrolled; + for (int i = 0; i < int(1); i++) + { + gl_SampleMask[i] = int(copy_sample_mask[i]); + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..ccc96adc0e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,16 @@ +#version 450 + +void main() +{ + int _21_unrolled[1]; + for (int i = 0; i < int(1); i++) + { + _21_unrolled[i] = gl_SampleMaskIn[i]; + } + int copy_sample_mask[1] = _21_unrolled; + for (int i = 0; i < int(1); i++) + { + gl_SampleMask[i] = copy_sample_mask[i]; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/scalar-select.spv14.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/scalar-select.spv14.asm.frag index d74286a153..4360e10473 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/scalar-select.spv14.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/scalar-select.spv14.asm.frag @@ -1,6 +1,6 @@ #version 450 -struct _15 +struct _16 { float _m0; }; @@ -13,7 +13,7 @@ void main() FragColor = vec4(false); FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0, 1.0, 0.0, 1.0), bvec4(false, true, false, true)); FragColor = vec4(bvec4(false, true, false, true)); - _15 _32 = false ? _15(0.0) : _15(1.0); - float _33[2] = true ? float[](0.0, 1.0) : float[](1.0, 0.0); + _16 _36 = false ? _16(0.0) : _16(1.0); + float _37[2] = true ? float[](0.0, 1.0) : float[](1.0, 0.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sparse-texture-feedback-uint-code.asm.desktop.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sparse-texture-feedback-uint-code.asm.desktop.frag index 540978c434..5b32eee835 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sparse-texture-feedback-uint-code.asm.desktop.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/sparse-texture-feedback-uint-code.asm.desktop.frag @@ -16,8 +16,8 @@ void main() uint _30; vec4 _31; _30 = sparseTextureARB(uSamp, vUV, _31); - ResType _26 = ResType(_30, _31); - vec4 texel = _26._m1; - bool ret = sparseTexelsResidentARB(int(_26._m0)); + ResType _24 = ResType(_30, _31); + vec4 texel = _24._m1; + bool ret = sparseTexelsResidentARB(int(_24._m0)); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag.vk similarity index 100% rename from third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.frag.vk rename to third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag.vk diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag index 8a918c035c..e9b261c4dd 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag @@ -23,10 +23,10 @@ uvec4 subgroupBallot(bool v) { return uvec4(unpackUint2x32(ballotARB(v)), 0u, 0u void main() { - uvec4 _21 = subgroupBallot(INDEX < 100u); - SV_Target.x = _21.x; - SV_Target.y = _21.y; - SV_Target.z = _21.z; - SV_Target.w = _21.w; + uvec4 _15 = subgroupBallot(INDEX < 100u); + SV_Target.x = _15.x; + SV_Target.y = _15.y; + SV_Target.z = _15.z; + SV_Target.w = _15.w; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk index ed5933f312..b9bb130666 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk @@ -6,10 +6,10 @@ layout(location = 0) out uvec4 SV_Target; void main() { - uvec4 _21 = subgroupBallot(INDEX < 100u); - SV_Target.x = _21.x; - SV_Target.y = _21.y; - SV_Target.z = _21.z; - SV_Target.w = _21.w; + uvec4 _15 = subgroupBallot(INDEX < 100u); + SV_Target.x = _15.x; + SV_Target.y = _15.y; + SV_Target.z = _15.z; + SV_Target.w = _15.w; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag index de8090e317..8281a4a087 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag @@ -7,31 +7,31 @@ void main() { int i; int j; - int _30; - int _31; + int _33; + int _34; if (vIndex != 0 && vIndex != 1 && vIndex != 11 && vIndex != 2 && vIndex != 3 && vIndex != 4 && vIndex != 5) { - _30 = 2; + _33 = 2; } if (vIndex == 1 || vIndex == 11) { - _31 = 1; + _34 = 1; } switch (vIndex) { case 0: { - _30 = 3; + _33 = 3; } default: { - j = _30; - _31 = 0; + j = _33; + _34 = 0; } case 1: case 11: { - j = _31; + j = _34; } case 2: { diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-non-default-fallthrough-no-phi.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-non-default-fallthrough-no-phi.asm.frag index 3315180965..c9273b7b23 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-non-default-fallthrough-no-phi.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-non-default-fallthrough-no-phi.asm.frag @@ -12,56 +12,56 @@ struct _5 int _m1; }; -_4 _16; -int _21; +_4 _26; +int _31; layout(location = 0) flat in int _2; layout(location = 0) out int _3; void main() { - bool _25 = false; + bool _76 = false; do { - _5 _26; - _26._m0 = 0; - _26._m1 = 10; - _4 _35; - _35 = _16; - int _39; - _4 _36; - bool _59; - int _38 = 0; + _5 _33; + _33._m0 = 0; + _33._m1 = 10; + _4 _41; + _41 = _26; + int _45; + _4 _42; + bool _79; + int _44 = 0; for (;;) { - if (_26._m0 < _26._m1) + if (_33._m0 < _33._m1) { - int _27 = _26._m0; - int _28 = _26._m0 + int(1u); - _26._m0 = _28; - _36 = _4(1u, _27); + int _34 = _33._m0; + int _35 = _33._m0 + int(1u); + _33._m0 = _35; + _42 = _4(1u, _34); } else { - _4 _48 = _35; - _48._m0 = 0u; - _36 = _48; + _4 _65 = _41; + _65._m0 = 0u; + _42 = _65; } - bool _45_ladder_break = false; - switch (int(_36._m0)) + bool _55_ladder_break = false; + switch (int(_42._m0)) { case 0: { - _3 = _38; - _25 = true; - _59 = true; - _45_ladder_break = true; + _3 = _44; + _76 = true; + _79 = true; + _55_ladder_break = true; break; } default: { - _59 = false; - _45_ladder_break = true; + _79 = false; + _55_ladder_break = true; break; } case 1: @@ -69,16 +69,16 @@ void main() break; } } - if (_45_ladder_break) + if (_55_ladder_break) { break; } - _39 = _38 + _2; - _35 = _36; - _38 = _39; + _45 = _44 + _2; + _41 = _42; + _44 = _45; continue; } - if (_59) + if (_79) { break; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-single-case-multiple-exit-cfg.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-single-case-multiple-exit-cfg.asm.frag index c9ddbe6899..67ab027da9 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-single-case-multiple-exit-cfg.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/switch-single-case-multiple-exit-cfg.asm.frag @@ -2,25 +2,25 @@ precision mediump float; precision highp int; -vec2 _19; +vec2 _52; layout(location = 0) out highp vec4 _GLF_color; void main() { - highp vec2 _30; + highp vec2 _53; do { if (gl_FragCoord.x != gl_FragCoord.x) { - _30 = _19; + _53 = _52; break; } - highp vec2 _29; - _29.y = _19.y; - _30 = _29; + highp vec2 _51; + _51.y = _52.y; + _53 = _51; break; } while(false); - _GLF_color = vec4(_30, 1.0, 1.0); + _GLF_color = vec4(_53, 1.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag index 0fe71f64b4..589e634c77 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag @@ -15,7 +15,7 @@ vec4 foobar(int a) void main() { int param = vA; - vec4 _25 = foobar(param); + vec4 _31 = foobar(param); FragColor = vec4(10.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/texel-fetch-ms-uint-sample.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/texel-fetch-ms-uint-sample.asm.frag index d62ccb8386..f4ada02a8d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/texel-fetch-ms-uint-sample.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/texel-fetch-ms-uint-sample.asm.frag @@ -6,10 +6,10 @@ layout(location = 0) out vec4 FragColor; void main() { - ivec2 _28 = ivec2(gl_FragCoord.xy); - FragColor.x = texelFetch(uSamp, _28, int(0u)).x; - FragColor.y = texelFetch(uSamp, _28, int(1u)).x; - FragColor.z = texelFetch(uSamp, _28, int(2u)).x; - FragColor.w = texelFetch(uSamp, _28, int(3u)).x; + ivec2 _22 = ivec2(gl_FragCoord.xy); + FragColor.x = texelFetch(uSamp, _22, int(0u)).x; + FragColor.y = texelFetch(uSamp, _22, int(1u)).x; + FragColor.z = texelFetch(uSamp, _22, int(2u)).x; + FragColor.w = texelFetch(uSamp, _22, int(3u)).x; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp index bd2a3c2736..429ed5f707 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp @@ -12,78 +12,78 @@ layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = SPIRV_CROSS_CONSTANT_ID_1, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; -layout(binding = 0, std430) buffer _4_6 +layout(binding = 0, std430) buffer _3_15 { float _m0[]; -} _6; +} _15; -layout(binding = 1, std430) buffer _4_7 +layout(binding = 1, std430) buffer _3_16 { float _m0[]; -} _7; +} _16; -uvec3 _28 = gl_WorkGroupSize; +uvec3 _14 = gl_WorkGroupSize; void main() { - float _44_copy; - float _46; - uint _47; - float _63; - uint _65; - float _36 = _6._m0[0u]; - uint _39 = 0u; - float _44; + float _38_copy; + float _39; + uint _40; + float _70; + uint _71; + float _32 = _15._m0[0u]; + uint _33 = 0u; + float _38; for (;;) { - _44 = _36; - _46 = _6._m0[35u]; - _47 = 0u; + _38 = _32; + _39 = _15._m0[35u]; + _40 = 0u; for (;;) { - uint _48 = _47 + 1u; - float _45 = _6._m0[_48]; - _6._m0[_47] = ((_46 + _44) + _45) / 3.0; - if (!(_47 < 34u)) + uint _44 = _40 + 1u; + float _46 = _15._m0[_44]; + _15._m0[_40] = ((_39 + _38) + _46) / 3.0; + if (!(_40 < 34u)) { break; } else { - _44_copy = _44; - _44 = _45; - _46 = _44_copy; - _47 = _48; + _38_copy = _38; + _38 = _46; + _39 = _38_copy; + _40 = _44; } } - _6._m0[35u] = (_36 + (_44 + _6._m0[35u])) / 3.0; - if (!(_39 < 5u)) + _15._m0[35u] = (_32 + (_38 + _15._m0[35u])) / 3.0; + if (!(_33 < 5u)) { - _63 = _6._m0[0u]; - _65 = 1u; + _70 = _15._m0[0u]; + _71 = 1u; break; } else { - _36 = _6._m0[0u]; - _39++; + _32 = _15._m0[0u]; + _33++; continue; } } - float _64; + float _75; for (;;) { - _64 = (_63 < _6._m0[_65]) ? _6._m0[_65] : _63; - if (!(_65 < 35u)) + _75 = (_70 < _15._m0[_71]) ? _15._m0[_71] : _70; + if (!(_71 < 35u)) { break; } else { - _63 = _64; - _65++; + _70 = _75; + _71++; } } - _7._m0[gl_GlobalInvocationID.x] = _64; + _16._m0[gl_GlobalInvocationID.x] = _75; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh.vk new file mode 100644 index 0000000000..a2e0baaeb9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh.vk @@ -0,0 +1,49 @@ +#version 450 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; +layout(max_vertices = 24, max_primitives = 8, triangles) out; + +out gl_MeshPerVertexEXT +{ + invariant vec4 gl_Position; +} gl_MeshVerticesEXT[]; + +struct _12 +{ + float _m0; +}; + +layout(location = 1) out vec4 B[24]; +layout(location = 3) perprimitiveEXT out vec4 C[8]; +shared float _32[64]; +taskPayloadSharedEXT _12 _38; + +void main() +{ + _32[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); + barrier(); + SetMeshOutputsEXT(24u, 8u); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _32[gl_LocalInvocationIndex]; + float _59 = _38._m0 + _32[gl_LocalInvocationIndex ^ 1u]; + B[gl_LocalInvocationIndex].x = _59; + B[gl_LocalInvocationIndex].y = _59; + B[gl_LocalInvocationIndex].z = _59; + B[gl_LocalInvocationIndex].w = _59; + if (gl_LocalInvocationIndex < 8u) + { + uint _65 = gl_LocalInvocationIndex * 3u; + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(_65, _65 + 1u, _65 + 2u); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_LocalInvocationIndex & 1u) != 0u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = int(gl_LocalInvocationIndex); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = int(gl_LocalInvocationIndex); + uint _78 = gl_LocalInvocationIndex ^ 2u; + C[gl_LocalInvocationIndex].x = _32[_78]; + C[gl_LocalInvocationIndex].y = _32[_78]; + C[gl_LocalInvocationIndex].z = _32[_78]; + C[gl_LocalInvocationIndex].w = _32[_78]; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh.vk new file mode 100644 index 0000000000..7512da83b7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh.vk @@ -0,0 +1,35 @@ +#version 450 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 32, max_primitives = 30, triangles) out; + +out gl_MeshPerVertexEXT +{ + vec4 gl_Position; + float gl_ClipDistance[4]; +} gl_MeshVerticesEXT[]; + +layout(location = 2) out vec4 B[32]; + +void main() +{ + SetMeshOutputsEXT(32u, 30u); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = 1.0; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = 1.0; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = 1.0; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = 1.0; + float _40 = float(int((gl_LocalInvocationIndex << 1u) + 4294967295u)) * 0.5; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0u] = _40; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[1u] = _40; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[2u] = _40; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[3u] = _40; + B[gl_LocalInvocationIndex].x = 2.0; + B[gl_LocalInvocationIndex].y = 2.0; + B[gl_LocalInvocationIndex].z = 2.0; + B[gl_LocalInvocationIndex].w = 2.0; + if (gl_LocalInvocationIndex < 30u) + { + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(gl_LocalInvocationIndex, gl_LocalInvocationIndex + 1u, gl_LocalInvocationIndex + 2u); + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh.vk index 5040aa4696..a2ea566cf4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/mesh/mesh-shader-plain-builtin-outputs.spv14.asm.vk.nocompat.mesh.vk @@ -10,35 +10,35 @@ struct _12 layout(location = 1) out vec4 B[24]; layout(location = 3) perprimitiveEXT out vec4 C[8]; -shared float _9[64]; -taskPayloadSharedEXT _12 _11; +shared float _32[64]; +taskPayloadSharedEXT _12 _38; void main() { - _9[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); + _32[gl_LocalInvocationIndex] = float(gl_LocalInvocationIndex); barrier(); SetMeshOutputsEXT(24u, 8u); - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _9[gl_LocalInvocationIndex]; - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _9[gl_LocalInvocationIndex]; - float _63 = _11._m0 + _9[gl_LocalInvocationIndex ^ 1u]; - B[gl_LocalInvocationIndex].x = _63; - B[gl_LocalInvocationIndex].y = _63; - B[gl_LocalInvocationIndex].z = _63; - B[gl_LocalInvocationIndex].w = _63; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.x = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.z = _32[gl_LocalInvocationIndex]; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.w = _32[gl_LocalInvocationIndex]; + float _59 = _38._m0 + _32[gl_LocalInvocationIndex ^ 1u]; + B[gl_LocalInvocationIndex].x = _59; + B[gl_LocalInvocationIndex].y = _59; + B[gl_LocalInvocationIndex].z = _59; + B[gl_LocalInvocationIndex].w = _59; if (gl_LocalInvocationIndex < 8u) { - uint _71 = gl_LocalInvocationIndex * 3u; - gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(_71, _71 + 1u, _71 + 2u); + uint _65 = gl_LocalInvocationIndex * 3u; + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(_65, _65 + 1u, _65 + 2u); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_LocalInvocationIndex & 1u) != 0u; gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = int(gl_LocalInvocationIndex); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = int(gl_LocalInvocationIndex); - uint _81 = gl_LocalInvocationIndex ^ 2u; - C[gl_LocalInvocationIndex].x = _9[_81]; - C[gl_LocalInvocationIndex].y = _9[_81]; - C[gl_LocalInvocationIndex].z = _9[_81]; - C[gl_LocalInvocationIndex].w = _9[_81]; + uint _78 = gl_LocalInvocationIndex ^ 2u; + C[gl_LocalInvocationIndex].x = _32[_78]; + C[gl_LocalInvocationIndex].y = _32[_78]; + C[gl_LocalInvocationIndex].z = _32[_78]; + C[gl_LocalInvocationIndex].w = _32[_78]; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk index a72a7cf48a..5d07ae4940 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk @@ -11,8 +11,8 @@ void main() vec4 col = vec4(0.0, 0.0, 0.0, 1.0); vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); vec3 direction = vec3(0.0, 0.0, -1.0); - uint _62 = gl_LaunchIDEXT.x; - traceRayEXT(as[nonuniformEXT(_62)], 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + uint _48 = gl_LaunchIDEXT.x; + traceRayEXT(as[nonuniformEXT(_48)], 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); col.y = payload; imageStore(image, ivec2(gl_LaunchIDEXT.xy), col); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/temporary.zero-initialize.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/temporary.zero-initialize.asm.frag index 1b8e8cd329..56a42a2099 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/temporary.zero-initialize.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/temporary.zero-initialize.asm.frag @@ -9,19 +9,19 @@ layout(location = 1) flat in mediump int vB; void main() { FragColor = vec4(0.0); - mediump int _10 = 0; - mediump int _15 = 0; - for (mediump int _16 = 0, _17 = 0; _16 < vA; _17 = _15, _16 += _10) + mediump int _49 = 0; + mediump int _58 = 0; + for (mediump int _57 = 0, _60 = 0; _57 < vA; _60 = _58, _57 += _49) { - if ((vA + _16) == 20) + if ((vA + _57) == 20) { - _15 = 50; + _58 = 50; } else { - _15 = ((vB + _16) == 40) ? 60 : _17; + _58 = ((vB + _57) == 40) ? 60 : _60; } - _10 = _15 + 10; + _49 = _58 + 10; FragColor += vec4(1.0); } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc index 13e1d3294b..446d381c29 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc @@ -13,7 +13,7 @@ layout(location = 0) patch out vert { float v0; float v1; -} _5; +} _7; layout(location = 2) patch out vert_patch { @@ -29,54 +29,54 @@ layout(location = 8) out vert2 float v5; } verts[4]; -const vec4 _3_0_init[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); -const float _3_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); -const float _3_2_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); -const float _3_3_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); -const float _6_0_init[2] = float[](0.0, 0.0); -const float _6_1_init[2] = float[](0.0, 0.0); -const float _7_init = 0.0; -const float _8_init[4] = float[](0.0, 0.0, 0.0, 0.0); -const float _9_0_init[4] = float[](0.0, 0.0, 0.0, 0.0); -const float _9_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const vec4 _4_0_init[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); +const float _4_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _4_2_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); +const float _4_3_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); +const float _8_0_init[2] = float[](0.0, 0.0); +const float _8_1_init[2] = float[](0.0, 0.0); +const float _9_init = 0.0; +const float _10_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _11_0_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _11_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); void main() { - gl_out[gl_InvocationID].gl_Position = _3_0_init[gl_InvocationID]; - gl_out[gl_InvocationID].gl_PointSize = _3_1_init[gl_InvocationID]; - gl_out[gl_InvocationID].gl_ClipDistance = _3_2_init[gl_InvocationID]; - gl_out[gl_InvocationID].gl_CullDistance = _3_3_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _4_0_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_PointSize = _4_1_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_ClipDistance = _4_2_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_CullDistance = _4_3_init[gl_InvocationID]; if (gl_InvocationID == 0) { - _5.v0 = 0.0; + _7.v0 = 0.0; } if (gl_InvocationID == 0) { - _5.v1 = 0.0; + _7.v1 = 0.0; } if (gl_InvocationID == 0) { - patches[0].v2 = _6_0_init[0]; + patches[0].v2 = _8_0_init[0]; } if (gl_InvocationID == 0) { - patches[1].v2 = _6_0_init[1]; + patches[1].v2 = _8_0_init[1]; } if (gl_InvocationID == 0) { - patches[0].v3 = _6_1_init[0]; + patches[0].v3 = _8_1_init[0]; } if (gl_InvocationID == 0) { - patches[1].v3 = _6_1_init[1]; + patches[1].v3 = _8_1_init[1]; } if (gl_InvocationID == 0) { - v2 = _7_init; + v2 = _9_init; } - v3[gl_InvocationID] = _8_init[gl_InvocationID]; - verts[gl_InvocationID].v4 = _9_0_init[gl_InvocationID]; - verts[gl_InvocationID].v5 = _9_1_init[gl_InvocationID]; + v3[gl_InvocationID] = _10_init[gl_InvocationID]; + verts[gl_InvocationID].v4 = _11_0_init[gl_InvocationID]; + verts[gl_InvocationID].v5 = _11_1_init[gl_InvocationID]; gl_out[gl_InvocationID].gl_Position = vec4(1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc index 3412f1cf5c..bb8b3c9182 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -14,16 +14,16 @@ layout(location = 4) in vec4 vicp1[]; layout(location = 5) out vec4 vocp1[3]; vec4 opc[4]; vec4 vicp[2][3]; -vec4 _48; -vec4 _49; -vec4 _50; -vec4 _56; +vec4 _52; +vec4 _55; +vec4 _58; +vec4 _89; -void fork0_epilogue(vec4 _87, vec4 _88, vec4 _89) +void fork0_epilogue(vec4 _61, vec4 _62, vec4 _63) { - gl_TessLevelOuter[0u] = _87.x; - gl_TessLevelOuter[1u] = _88.x; - gl_TessLevelOuter[2u] = _89.x; + gl_TessLevelOuter[0u] = _61.x; + gl_TessLevelOuter[1u] = _62.x; + gl_TessLevelOuter[2u] = _63.x; } void fork0(uint vForkInstanceId) @@ -31,22 +31,22 @@ void fork0(uint vForkInstanceId) vec4 r0; r0.x = uintBitsToFloat(vForkInstanceId); opc[floatBitsToInt(r0.x)].x = cb0_0._m0[0u].x; - _48 = opc[0u]; - _49 = opc[1u]; - _50 = opc[2u]; - fork0_epilogue(_48, _49, _50); + _52 = opc[0u]; + _55 = opc[1u]; + _58 = opc[2u]; + fork0_epilogue(_52, _55, _58); } -void fork1_epilogue(vec4 _109) +void fork1_epilogue(vec4 _92) { - gl_TessLevelInner[0u] = _109.x; + gl_TessLevelInner[0u] = _92.x; } void fork1() { opc[3u].x = cb0_0._m0[0u].x; - _56 = opc[3u]; - fork1_epilogue(_56); + _89 = opc[3u]; + fork1_epilogue(_89); } void main() diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc index ebd2d8aeac..f0493436f4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc @@ -1,17 +1,17 @@ #version 450 layout(vertices = 4) out; -const float _5_init[2] = float[](0.0, 0.0); -const float _6_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _7_init[2] = float[](0.0, 0.0); +const float _8_init[4] = float[](0.0, 0.0, 0.0, 0.0); void main() { if (gl_InvocationID == 0) { - gl_TessLevelInner = _5_init; + gl_TessLevelInner = _7_init; } if (gl_InvocationID == 0) { - gl_TessLevelOuter = _6_init; + gl_TessLevelOuter = _8_init; } gl_out[gl_InvocationID].gl_Position = vec4(1.0); gl_TessLevelInner[0] = 1.0; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert index 6060888d81..074c7f566a 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -10,15 +10,15 @@ layout(location = 0) out Vert { float a; float b; -} _3; +} _4; layout(location = 2) out Foo foo; -const Foo _4_init = Foo(0.0, 0.0); +const Foo _6_init = Foo(0.0, 0.0); void main() { - _3.a = 0.0; - _3.b = 0.0; - foo = _4_init; + _4.a = 0.0; + _4.b = 0.0; + foo = _6_init; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/debug-printf.asm.vk.nocompat.vert.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/debug-printf.asm.vk.nocompat.vert.vk index b90912d1cc..6e1ece4a2d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/debug-printf.asm.vk.nocompat.vert.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/debug-printf.asm.vk.nocompat.vert.vk @@ -4,7 +4,7 @@ void main() { debugPrintfEXT("Foo %f %f", 1.0, 2.0); - vec4 _17 = vec4(0.0, 0.0, 0.0, 1.0); + vec4 _16 = vec4(0.0, 0.0, 0.0, 1.0); gl_Position = vec4(0.0, 0.0, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/empty-struct-composite.asm.vert b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/empty-struct-composite.asm.vert index 8f786d49e1..2234868126 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/empty-struct-composite.asm.vert +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/empty-struct-composite.asm.vert @@ -7,7 +7,7 @@ struct Test void main() { - Test _14 = Test(0); - Test t = _14; + Test _13 = Test(0); + Test t = _13; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/illegal-struct-name.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/illegal-struct-name.asm.comp index 885dcb3baa..991d4dbd2b 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/illegal-struct-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/illegal-struct-name.asm.comp @@ -10,13 +10,13 @@ layout(binding = 0, std430) buffer SSBO { Foo foo; Foo foo2; -} _7; +} _9; void main() { Foo f; - f._abs = _7.foo._abs; + f._abs = _9.foo._abs; int _abs = 10; - _7.foo2._abs = f._abs; + _9.foo2._abs = f._abs; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp index 8b6a032104..83d3d6f0c4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp @@ -4,13 +4,13 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer SSBO { int v[]; -} _64; +} _65; void main() { for (int i = 0; i < 4; i++) { - _64.v[i] += 10; + _65.v[i] += 10; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag.vk new file mode 100644 index 0000000000..7ab0e95066 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag.vk @@ -0,0 +1,11 @@ +#version 450 +#extension GL_EXT_mesh_shader : require + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat perprimitiveEXT in uvec4 v; + +void main() +{ + FragColor = vec4(v); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag index f46bc2fd88..14afed7017 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag @@ -2,23 +2,23 @@ precision mediump float; precision highp int; -vec2 _19; +vec2 _52; void main() { - highp vec2 _30; + highp vec2 _53; for (int spvDummy15 = 0; spvDummy15 < 1; spvDummy15++) { if (gl_FragCoord.x != gl_FragCoord.x) { - _30 = _19; + _53 = _52; break; } - highp vec2 _29; - _29.y = _19.y; - _30 = _29; + highp vec2 _51; + _51.y = _52.y; + _53 = _51; break; } - gl_FragData[0] = vec4(_30, 1.0, 1.0); + gl_FragData[0] = vec4(_53, 1.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh.vk b/third_party/spirv-cross/reference/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh.vk new file mode 100644 index 0000000000..d07a110f0f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh.vk @@ -0,0 +1,19 @@ +#version 450 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 3, max_primitives = 1, triangles) out; + +out gl_MeshPerVertexEXT +{ + invariant vec4 gl_Position; +} gl_MeshVerticesEXT[]; + +void main() +{ + SetMeshOutputsEXT(3u, 1u); + gl_MeshVerticesEXT[0].gl_Position = vec4(1.0); + gl_MeshVerticesEXT[1].gl_Position = vec4(1.0); + gl_MeshVerticesEXT[2].gl_Position = vec4(1.0); + gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0u, 1u, 2u); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp.vk new file mode 100644 index 0000000000..b76556ef29 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp.vk @@ -0,0 +1,22 @@ +#version 450 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_image_int64 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, r64ui) uniform u64image2D uimg; +layout(set = 0, binding = 1, r64i) uniform i64image2D iimg; + +void main() +{ + uint64_t uv = imageLoad(uimg, ivec2(gl_GlobalInvocationID.xy + uvec2(50u))).x; + int64_t iv = imageLoad(iimg, ivec2(gl_GlobalInvocationID.xy + uvec2(50u))).x; + uint64_t _52 = imageAtomicMax(uimg, ivec2(gl_GlobalInvocationID.xy), uv); + uv = _52; + int64_t _59 = imageAtomicMax(iimg, ivec2(gl_GlobalInvocationID.xy), iv); + iv = _59; +} + diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/aliased-entry-point-names.asm.multi.json b/third_party/spirv-cross/reference/shaders-reflection/asm/aliased-entry-point-names.asm.multi.json index 666167af4a..a21659cafd 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/aliased-entry-point-names.asm.multi.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/aliased-entry-point-names.asm.multi.json @@ -18,8 +18,8 @@ } ], "types" : { - "_8" : { - "name" : "_8", + "_13" : { + "name" : "_13", "members" : [ { "name" : "_m0", diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/comp/pointer-to-array-of-physical-pointer.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/comp/pointer-to-array-of-physical-pointer.asm.comp.json index b9224eccdb..53f1435364 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/comp/pointer-to-array-of-physical-pointer.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/comp/pointer-to-array-of-physical-pointer.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_3" : { + "_4" : { "name" : "Params", "members" : [ { @@ -26,13 +26,13 @@ }, { "name" : "y", - "type" : "_6", + "type" : "_8", "offset" : 16, "physical_pointer" : true } ] }, - "_4" : { + "_6" : { "name" : "IntBuf", "members" : [ { @@ -42,12 +42,12 @@ } ] }, - "_11" : { + "_12" : { "name" : "IntBuf", - "type" : "_4", + "type" : "_6", "physical_pointer" : true }, - "_6" : { + "_8" : { "name" : "IntBuf", "array" : [ 3 @@ -55,13 +55,13 @@ "array_size_is_literal" : [ true ], - "type" : "_11", + "type" : "_12", "array_stride" : 16 } }, "ubos" : [ { - "type" : "_3", + "type" : "_4", "name" : "Params", "block_size" : 24, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json index 3b0c9868e5..e7d51221ec 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_5" : { + "_7" : { "name" : "SSBO0", "members" : [ { @@ -36,7 +36,7 @@ }, "ssbos" : [ { - "type" : "_5", + "type" : "_7", "name" : "SSBO0", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json index 80cf862227..62754a3642 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "SSBO0", "members" : [ { @@ -33,7 +33,7 @@ } ] }, - "_6" : { + "_8" : { "name" : "SSBO1", "members" : [ { @@ -53,14 +53,14 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "SSBO0", "block_size" : 0, "set" : 0, "binding" : 0 }, { - "type" : "_6", + "type" : "_8", "name" : "SSBO1", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json index b34f85bb5a..d3af24eed7 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "UAV0", "members" : [ { @@ -36,7 +36,7 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "UAV0", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json index 052e3ba814..27fadb3eb0 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "UAV0", "members" : [ { @@ -36,14 +36,14 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "UAV0", "block_size" : 0, "set" : 0, "binding" : 0 }, { - "type" : "_4", + "type" : "_6", "name" : "UAV1", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json index 3b0c9868e5..e7d51221ec 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_5" : { + "_7" : { "name" : "SSBO0", "members" : [ { @@ -36,7 +36,7 @@ }, "ssbos" : [ { - "type" : "_5", + "type" : "_7", "name" : "SSBO0", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json index 80cf862227..62754a3642 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "SSBO0", "members" : [ { @@ -33,7 +33,7 @@ } ] }, - "_6" : { + "_8" : { "name" : "SSBO1", "members" : [ { @@ -53,14 +53,14 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "SSBO0", "block_size" : 0, "set" : 0, "binding" : 0 }, { - "type" : "_6", + "type" : "_8", "name" : "SSBO1", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json index b34f85bb5a..d3af24eed7 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "UAV0", "members" : [ { @@ -36,7 +36,7 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "UAV0", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json index 052e3ba814..27fadb3eb0 100644 --- a/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json +++ b/third_party/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json @@ -16,7 +16,7 @@ } ], "types" : { - "_4" : { + "_6" : { "name" : "UAV0", "members" : [ { @@ -36,14 +36,14 @@ }, "ssbos" : [ { - "type" : "_4", + "type" : "_6", "name" : "UAV0", "block_size" : 0, "set" : 0, "binding" : 0 }, { - "type" : "_4", + "type" : "_6", "name" : "UAV1", "block_size" : 0, "set" : 0, diff --git a/third_party/spirv-cross/reference/shaders-ue4-no-opt/asm/frag/accesschain-invalid-expression.asm.invalid.frag b/third_party/spirv-cross/reference/shaders-ue4-no-opt/asm/frag/accesschain-invalid-expression.asm.invalid.frag index 429bbf738e..a7df0db9bc 100644 --- a/third_party/spirv-cross/reference/shaders-ue4-no-opt/asm/frag/accesschain-invalid-expression.asm.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-ue4-no-opt/asm/frag/accesschain-invalid-expression.asm.invalid.frag @@ -338,7 +338,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_View& View [[bu else { float3 _521 = _501 * float3(_Globals.LightPositionAndInvRadius[_491].w); - _537 = pow(1.0 - fast::clamp(dot(_521, _521), 0.0, 1.0), _Globals.LightColorAndFalloffExponent[_491].w); + _537 = powr(1.0 - fast::clamp(dot(_521, _521), 0.0, 1.0), _Globals.LightColorAndFalloffExponent[_491].w); } float3 _544 = cross(_206, _507); float _546 = _511 * _442; diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag index 0a6c98418e..ef86380c45 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag @@ -256,7 +256,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G float4 _260 = SSProfilesTexture.read(uint2(int3(1, int(uint((select(float4(0.0), SceneTexturesStruct_GBufferDTexture.sample(SceneTexturesStruct_GBufferDTextureSampler, _114, level(0.0)), bool4(!(((_240 & 4294967280u) & 16u) != 0u))).x * 255.0) + 0.5)), 0).xy), 0); float _263 = _260.y * 0.5; float3 _266 = _148 - (_236 * float3(_263)); - float _274 = pow(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0); + float _274 = powr(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0); float _445; if (_160) { diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/global-constant-arrays.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/global-constant-arrays.asm.frag index 88618a8512..60db7923cb 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/global-constant-arrays.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/global-constant-arrays.asm.frag @@ -163,8 +163,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float3 _599; if (_Globals.OutputDevice >= 3u) { - float3 _591 = pow(_577, float3(0.0126833133399486541748046875)); - _599 = pow(fast::max(float3(0.0), _591 - float3(0.8359375)) / (float3(18.8515625) - (float3(18.6875) * _591)), float3(6.277394771575927734375)) * float3(10000.0); + float3 _591 = powr(_577, float3(0.0126833133399486541748046875)); + _599 = powr(fast::max(float3(0.0), _591 - float3(0.8359375)) / (float3(18.8515625) - (float3(18.6875) * _591)), float3(6.277394771575927734375)) * float3(10000.0); } else { @@ -224,7 +224,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _861 = _Globals.ColorGammaMidtones * _Globals.ColorGamma; float4 _864 = _Globals.ColorGainMidtones * _Globals.ColorGain; float4 _867 = _Globals.ColorOffsetMidtones + _Globals.ColorOffset; - float3 _905 = ((((pow(pow(fast::max(float3(0.0), mix(_772, _745, _751.xyz * float3(_751.w))) * float3(5.5555553436279296875), _756.xyz * float3(_756.w)) * float3(0.180000007152557373046875), float3(1.0) / (_761.xyz * float3(_761.w))) * (_766.xyz * float3(_766.w))) + (_771.xyz + float3(_771.w))) * float3(1.0 - _804)) + (((pow(pow(fast::max(float3(0.0), mix(_772, _745, _855.xyz * float3(_855.w))) * float3(5.5555553436279296875), _858.xyz * float3(_858.w)) * float3(0.180000007152557373046875), float3(1.0) / (_861.xyz * float3(_861.w))) * (_864.xyz * float3(_864.w))) + (_867.xyz + float3(_867.w))) * float3(_804 - _852))) + (((pow(pow(fast::max(float3(0.0), mix(_772, _745, _808.xyz * float3(_808.w))) * float3(5.5555553436279296875), _811.xyz * float3(_811.w)) * float3(0.180000007152557373046875), float3(1.0) / (_814.xyz * float3(_814.w))) * (_817.xyz * float3(_817.w))) + (_820.xyz + float3(_820.w))) * float3(_852)); + float3 _905 = ((((powr(powr(fast::max(float3(0.0), mix(_772, _745, _751.xyz * float3(_751.w))) * float3(5.5555553436279296875), _756.xyz * float3(_756.w)) * float3(0.180000007152557373046875), float3(1.0) / (_761.xyz * float3(_761.w))) * (_766.xyz * float3(_766.w))) + (_771.xyz + float3(_771.w))) * float3(1.0 - _804)) + (((powr(powr(fast::max(float3(0.0), mix(_772, _745, _855.xyz * float3(_855.w))) * float3(5.5555553436279296875), _858.xyz * float3(_858.w)) * float3(0.180000007152557373046875), float3(1.0) / (_861.xyz * float3(_861.w))) * (_864.xyz * float3(_864.w))) + (_867.xyz + float3(_867.w))) * float3(_804 - _852))) + (((powr(powr(fast::max(float3(0.0), mix(_772, _745, _808.xyz * float3(_808.w))) * float3(5.5555553436279296875), _811.xyz * float3(_811.w)) * float3(0.180000007152557373046875), float3(1.0) / (_814.xyz * float3(_814.w))) * (_817.xyz * float3(_817.w))) + (_820.xyz + float3(_820.w))) * float3(_852)); float3 _906 = _905 * _549; float3 _914 = float3(_Globals.BlueCorrection); float3 _916 = mix(_905, _905 * ((_551 * float3x3(float3(0.940437257289886474609375, -0.01830687932670116424560546875, 0.07786960899829864501953125), float3(0.008378696627914905548095703125, 0.82866001129150390625, 0.162961304187774658203125), float3(0.0005471261101774871349334716796875, -0.00088337459601461887359619140625, 1.00033628940582275390625))) * _550), _914) * _551; @@ -332,7 +332,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa { _1189 = fast::max(float3(0.0), mix(_1119, _1119 * ((_551 * float3x3(float3(1.06317996978759765625, 0.02339559979736804962158203125, -0.08657260239124298095703125), float3(-0.010633699595928192138671875, 1.2063200473785400390625, -0.1956900060176849365234375), float3(-0.0005908869788981974124908447265625, 0.00105247995816171169281005859375, 0.999538004398345947265625))) * _550), _914) * _549); } - float3 _1218 = pow(fast::max(float3(0.0), mix((((float3(_Globals.MappingPolynomial.x) * (_1189 * _1189)) + (float3(_Globals.MappingPolynomial.y) * _1189)) + float3(_Globals.MappingPolynomial.z)) * float3(_Globals.ColorScale), _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); + float3 _1218 = powr(fast::max(float3(0.0), mix((((float3(_Globals.MappingPolynomial.x) * (_1189 * _1189)) + (float3(_Globals.MappingPolynomial.y) * _1189)) + float3(_Globals.MappingPolynomial.z)) * float3(_Globals.ColorScale), _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); float3 _3001; if (_Globals.OutputDevice == 0u) { @@ -345,7 +345,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2973 = _2961 * 12.9200000762939453125; break; } - _2973 = (pow(_2961, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _2973 = (powr(_2961, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _2974 = _1218.y; @@ -357,7 +357,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2986 = _2974 * 12.9200000762939453125; break; } - _2986 = (pow(_2974, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _2986 = (powr(_2974, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _2987 = _1218.z; @@ -369,7 +369,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2999 = _2987 * 12.9200000762939453125; break; } - _2999 = (pow(_2987, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _2999 = (powr(_2987, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } _3001 = float3(_2973, _2986, _2999); @@ -380,7 +380,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa if (_Globals.OutputDevice == 1u) { float3 _2953 = fast::max(float3(6.1035199905745685100555419921875e-05), (_1218 * _547) * _576); - _2960 = fast::min(_2953 * float3(4.5), (pow(fast::max(_2953, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)) * float3(1.09899997711181640625)) - float3(0.098999999463558197021484375)); + _2960 = fast::min(_2953 * float3(4.5), (powr(fast::max(_2953, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)) * float3(1.09899997711181640625)) - float3(0.098999999463558197021484375)); } else { @@ -542,7 +542,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2327 = _2324; } float3 _2329; - _2329.x = pow(10.0, _2327); + _2329.x = powr(10.0, _2327); float _2330 = _2248.y; float _2334 = log((_2330 <= 0.0) ? _2255 : _2330) / _1065; float _2401; @@ -580,7 +580,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2401 = _2398; } - _2329.y = pow(10.0, _2401); + _2329.y = powr(10.0, _2401); float _2404 = _2248.z; float _2408 = log((_2404 <= 0.0) ? _2255 : _2404) / _1065; float _2475; @@ -618,9 +618,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2475 = _2472; } - _2329.z = pow(10.0, _2475); + _2329.z = powr(10.0, _2475); float3 _2479 = (_2329 * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); - float _2481 = 0.17999999225139617919921875 * pow(2.0, -12.0); + float _2481 = 0.17999999225139617919921875 * powr(2.0, -12.0); float _2485 = log((_2481 <= 0.0) ? _2255 : _2481) / _1065; float _2552; if (_2485 <= _2260) @@ -689,8 +689,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2611 = _2608; } - float _2612 = pow(10.0, _2611); - float _2614 = 0.17999999225139617919921875 * pow(2.0, 10.0); + float _2612 = powr(10.0, _2611); + float _2614 = 0.17999999225139617919921875 * powr(2.0, 10.0); float _2618 = log((_2614 <= 0.0) ? _2255 : _2614) / _1065; float _2683; if (_2618 <= _2260) @@ -726,10 +726,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2683 = _2680; } - float _2684 = pow(10.0, _2683); + float _2684 = powr(10.0, _2683); float _2685 = _2479.x; float _2689 = log((_2685 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2685) / _1065; - float _2690 = log(pow(10.0, _2552)); + float _2690 = log(powr(10.0, _2552)); float _2691 = _2690 / _1065; float _2768; if (_2689 <= _2691) @@ -768,7 +768,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2768 = _2760; } float3 _2770; - _2770.x = pow(10.0, _2768); + _2770.x = powr(10.0, _2768); float _2771 = _2479.y; float _2775 = log((_2771 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2771) / _1065; float _2852; @@ -807,7 +807,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2852 = _2844; } - _2770.y = pow(10.0, _2852); + _2770.y = powr(10.0, _2852); float _2855 = _2479.z; float _2859 = log((_2855 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2855) / _1065; float _2936; @@ -846,9 +846,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2936 = _2928; } - _2770.z = pow(10.0, _2936); - float3 _2942 = pow(((_2770 - float3(3.5073844628641381859779357910156e-05)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2950 = pow((float3(0.8359375) + (float3(18.8515625) * _2942)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2942))), float3(78.84375)); + _2770.z = powr(10.0, _2936); + float3 _2942 = powr(((_2770 - float3(3.5073844628641381859779357910156e-05)) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2950 = powr((float3(0.8359375) + (float3(18.8515625) * _2942)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2942))), float3(78.84375)); } else { @@ -1010,7 +1010,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1490 = _1487; } float3 _1492; - _1492.x = pow(10.0, _1490); + _1492.x = powr(10.0, _1490); float _1493 = _1411.y; float _1497 = log((_1493 <= 0.0) ? _1418 : _1493) / _1065; float _1564; @@ -1048,7 +1048,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1564 = _1561; } - _1492.y = pow(10.0, _1564); + _1492.y = powr(10.0, _1564); float _1567 = _1411.z; float _1571 = log((_1567 <= 0.0) ? _1418 : _1567) / _1065; float _1638; @@ -1086,9 +1086,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1638 = _1635; } - _1492.z = pow(10.0, _1638); + _1492.z = powr(10.0, _1638); float3 _1642 = (_1492 * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); - float _1644 = 0.17999999225139617919921875 * pow(2.0, -12.0); + float _1644 = 0.17999999225139617919921875 * powr(2.0, -12.0); float _1648 = log((_1644 <= 0.0) ? _1418 : _1644) / _1065; float _1715; if (_1648 <= _1423) @@ -1157,8 +1157,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1774 = _1771; } - float _1775 = pow(10.0, _1774); - float _1777 = 0.17999999225139617919921875 * pow(2.0, 11.0); + float _1775 = powr(10.0, _1774); + float _1777 = 0.17999999225139617919921875 * powr(2.0, 11.0); float _1781 = log((_1777 <= 0.0) ? _1418 : _1777) / _1065; float _1846; if (_1781 <= _1423) @@ -1194,10 +1194,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1846 = _1843; } - float _1847 = pow(10.0, _1846); + float _1847 = powr(10.0, _1846); float _1848 = _1642.x; float _1852 = log((_1848 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _1848) / _1065; - float _1854 = log(pow(10.0, _1715)) / _1065; + float _1854 = log(powr(10.0, _1715)) / _1065; float _1926; if (_1852 <= _1854) { @@ -1235,7 +1235,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1926 = _1923; } float3 _1928; - _1928.x = pow(10.0, _1926); + _1928.x = powr(10.0, _1926); float _1929 = _1642.y; float _1933 = log((_1929 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _1929) / _1065; float _2005; @@ -1274,7 +1274,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2005 = _2002; } - _1928.y = pow(10.0, _2005); + _1928.y = powr(10.0, _2005); float _2008 = _1642.z; float _2012 = log((_2008 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2008) / _1065; float _2084; @@ -1313,21 +1313,21 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2084 = _2081; } - _1928.z = pow(10.0, _2084); - float3 _2089 = pow((_1928 * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2097 = pow((float3(0.8359375) + (float3(18.8515625) * _2089)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2089))), float3(78.84375)); + _1928.z = powr(10.0, _2084); + float3 _2089 = powr((_1928 * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2097 = powr((float3(0.8359375) + (float3(18.8515625) * _2089)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2089))), float3(78.84375)); } else { float3 _1260; if (_Globals.OutputDevice == 7u) { - float3 _1252 = pow(((_906 * _547) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _1260 = pow((float3(0.8359375) + (float3(18.8515625) * _1252)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _1252))), float3(78.84375)); + float3 _1252 = powr(((_906 * _547) * _576) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _1260 = powr((float3(0.8359375) + (float3(18.8515625) * _1252)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _1252))), float3(78.84375)); } else { - _1260 = pow((_1218 * _547) * _576, float3(_Globals.InverseGamma.z)); + _1260 = powr((_1218 * _547) * _576, float3(_Globals.InverseGamma.z)); } _2097 = _1260; } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag index f405fbb68e..88f033dfa5 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/padded-float-array-member-defef.asm.frag @@ -165,8 +165,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float3 _625; if (_Globals.OutputDevice >= 3u) { - float3 _617 = pow(_603, float3(0.0126833133399486541748046875)); - _625 = pow(fast::max(float3(0.0), _617 - float3(0.8359375)) / (float3(18.8515625) - (float3(18.6875) * _617)), float3(6.277394771575927734375)) * float3(10000.0); + float3 _617 = powr(_603, float3(0.0126833133399486541748046875)); + _625 = powr(fast::max(float3(0.0), _617 - float3(0.8359375)) / (float3(18.8515625) - (float3(18.6875) * _617)), float3(6.277394771575927734375)) * float3(10000.0); } else { @@ -226,7 +226,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _887 = _Globals.ColorGammaMidtones * _Globals.ColorGamma; float4 _890 = _Globals.ColorGainMidtones * _Globals.ColorGain; float4 _893 = _Globals.ColorOffsetMidtones + _Globals.ColorOffset; - float3 _931 = ((((pow(pow(fast::max(float3(0.0), mix(_798, _771, _777.xyz * float3(_777.w))) * float3(5.5555553436279296875), _782.xyz * float3(_782.w)) * float3(0.180000007152557373046875), float3(1.0) / (_787.xyz * float3(_787.w))) * (_792.xyz * float3(_792.w))) + (_797.xyz + float3(_797.w))) * float3(1.0 - _830)) + (((pow(pow(fast::max(float3(0.0), mix(_798, _771, _881.xyz * float3(_881.w))) * float3(5.5555553436279296875), _884.xyz * float3(_884.w)) * float3(0.180000007152557373046875), float3(1.0) / (_887.xyz * float3(_887.w))) * (_890.xyz * float3(_890.w))) + (_893.xyz + float3(_893.w))) * float3(_830 - _878))) + (((pow(pow(fast::max(float3(0.0), mix(_798, _771, _834.xyz * float3(_834.w))) * float3(5.5555553436279296875), _837.xyz * float3(_837.w)) * float3(0.180000007152557373046875), float3(1.0) / (_840.xyz * float3(_840.w))) * (_843.xyz * float3(_843.w))) + (_846.xyz + float3(_846.w))) * float3(_878)); + float3 _931 = ((((powr(powr(fast::max(float3(0.0), mix(_798, _771, _777.xyz * float3(_777.w))) * float3(5.5555553436279296875), _782.xyz * float3(_782.w)) * float3(0.180000007152557373046875), float3(1.0) / (_787.xyz * float3(_787.w))) * (_792.xyz * float3(_792.w))) + (_797.xyz + float3(_797.w))) * float3(1.0 - _830)) + (((powr(powr(fast::max(float3(0.0), mix(_798, _771, _881.xyz * float3(_881.w))) * float3(5.5555553436279296875), _884.xyz * float3(_884.w)) * float3(0.180000007152557373046875), float3(1.0) / (_887.xyz * float3(_887.w))) * (_890.xyz * float3(_890.w))) + (_893.xyz + float3(_893.w))) * float3(_830 - _878))) + (((powr(powr(fast::max(float3(0.0), mix(_798, _771, _834.xyz * float3(_834.w))) * float3(5.5555553436279296875), _837.xyz * float3(_837.w)) * float3(0.180000007152557373046875), float3(1.0) / (_840.xyz * float3(_840.w))) * (_843.xyz * float3(_843.w))) + (_846.xyz + float3(_846.w))) * float3(_878)); float3 _932 = _931 * _575; float3 _940 = float3(_Globals.BlueCorrection); float3 _942 = mix(_931, _931 * ((_577 * float3x3(float3(0.940437257289886474609375, -0.01830687932670116424560546875, 0.07786960899829864501953125), float3(0.008378696627914905548095703125, 0.82866001129150390625, 0.162961304187774658203125), float3(0.0005471261101774871349334716796875, -0.00088337459601461887359619140625, 1.00033628940582275390625))) * _576), _940) * _577; @@ -344,7 +344,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1229 = _1217 * 12.9200000762939453125; break; } - _1229 = (pow(_1217, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _1229 = (powr(_1217, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _1230 = _1216.y; @@ -356,7 +356,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1242 = _1230 * 12.9200000762939453125; break; } - _1242 = (pow(_1230, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _1242 = (powr(_1230, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _1243 = _1216.z; @@ -368,7 +368,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1255 = _1243 * 12.9200000762939453125; break; } - _1255 = (pow(_1243, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _1255 = (powr(_1243, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float3 _1256 = float3(_1229, _1242, _1255); @@ -380,8 +380,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa float4 _1279 = Texture1.sample(Texture1Sampler, float2(_1275, _1276)); float4 _1283 = Texture1.sample(Texture1Sampler, float2(_1275 + 0.0625, _1276)); float3 _1289 = fast::max(float3(6.1035199905745685100555419921875e-05), (float3(_Globals.LUTWeights[0].x) * _1256) + (float3(_Globals.LUTWeights[1].x) * mix(_1279, _1283, float4(_1270 - _1271)).xyz)); - float3 _1295 = select(_1289 * float3(0.077399380505084991455078125), pow((_1289 * float3(0.94786727428436279296875)) + float3(0.0521326996386051177978515625), float3(2.400000095367431640625)), _1289 > float3(0.040449999272823333740234375)); - float3 _1324 = pow(fast::max(float3(0.0), mix((((float3(_Globals.MappingPolynomial.x) * (_1295 * _1295)) + (float3(_Globals.MappingPolynomial.y) * _1295)) + float3(_Globals.MappingPolynomial.z)) * _Globals.ColorScale, _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); + float3 _1295 = select(_1289 * float3(0.077399380505084991455078125), powr((_1289 * float3(0.94786727428436279296875)) + float3(0.0521326996386051177978515625), float3(2.400000095367431640625)), _1289 > float3(0.040449999272823333740234375)); + float3 _1324 = powr(fast::max(float3(0.0), mix((((float3(_Globals.MappingPolynomial.x) * (_1295 * _1295)) + (float3(_Globals.MappingPolynomial.y) * _1295)) + float3(_Globals.MappingPolynomial.z)) * _Globals.ColorScale, _Globals.OverlayColor.xyz, float3(_Globals.OverlayColor.w))), float3(_Globals.InverseGamma.y)); float3 _3103; if (_Globals.OutputDevice == 0u) { @@ -393,7 +393,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3075 = _1324.x * 12.9200000762939453125; break; } - _3075 = (pow(_1324.x, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _3075 = (powr(_1324.x, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _3088; @@ -404,7 +404,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3088 = _1324.y * 12.9200000762939453125; break; } - _3088 = (pow(_1324.y, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _3088 = (powr(_1324.y, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } float _3101; @@ -415,7 +415,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _3101 = _1324.z * 12.9200000762939453125; break; } - _3101 = (pow(_1324.z, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; + _3101 = (powr(_1324.z, 0.4166666567325592041015625) * 1.05499994754791259765625) - 0.054999999701976776123046875; break; } _3103 = float3(_3075, _3088, _3101); @@ -426,7 +426,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa if (_Globals.OutputDevice == 1u) { float3 _3055 = fast::max(float3(6.1035199905745685100555419921875e-05), (_1324 * _573) * _602); - _3062 = fast::min(_3055 * float3(4.5), (pow(fast::max(_3055, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)) * float3(1.09899997711181640625)) - float3(0.098999999463558197021484375)); + _3062 = fast::min(_3055 * float3(4.5), (powr(fast::max(_3055, float3(0.017999999225139617919921875)), float3(0.449999988079071044921875)) * float3(1.09899997711181640625)) - float3(0.098999999463558197021484375)); } else { @@ -588,7 +588,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2431 = _2428; } float3 _2433; - _2433.x = pow(10.0, _2431); + _2433.x = powr(10.0, _2431); float _2434 = _2352.y; float _2438 = log((_2434 <= 0.0) ? _2359 : _2434) / _1091; float _2505; @@ -626,7 +626,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2505 = _2502; } - _2433.y = pow(10.0, _2505); + _2433.y = powr(10.0, _2505); float _2508 = _2352.z; float _2512 = log((_2508 <= 0.0) ? _2359 : _2508) / _1091; float _2579; @@ -664,9 +664,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2579 = _2576; } - _2433.z = pow(10.0, _2579); + _2433.z = powr(10.0, _2579); float3 _2583 = (_2433 * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); - float _2585 = 0.17999999225139617919921875 * pow(2.0, -12.0); + float _2585 = 0.17999999225139617919921875 * powr(2.0, -12.0); float _2589 = log((_2585 <= 0.0) ? _2359 : _2585) / _1091; float _2656; if (_2589 <= _2364) @@ -735,8 +735,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2713 = _2710; } - float _2714 = pow(10.0, _2713); - float _2716 = 0.17999999225139617919921875 * pow(2.0, 10.0); + float _2714 = powr(10.0, _2713); + float _2716 = 0.17999999225139617919921875 * powr(2.0, 10.0); float _2720 = log((_2716 <= 0.0) ? _2359 : _2716) / _1091; float _2785; if (_2720 <= _2364) @@ -772,10 +772,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2785 = _2782; } - float _2786 = pow(10.0, _2785); + float _2786 = powr(10.0, _2785); float _2787 = _2583.x; float _2791 = log((_2787 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2787) / _1091; - float _2792 = log(pow(10.0, _2656)); + float _2792 = log(powr(10.0, _2656)); float _2793 = _2792 / _1091; float _2870; if (_2791 <= _2793) @@ -814,7 +814,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2870 = _2862; } float3 _2872; - _2872.x = pow(10.0, _2870); + _2872.x = powr(10.0, _2870); float _2873 = _2583.y; float _2877 = log((_2873 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2873) / _1091; float _2954; @@ -853,7 +853,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2954 = _2946; } - _2872.y = pow(10.0, _2954); + _2872.y = powr(10.0, _2954); float _2957 = _2583.z; float _2961 = log((_2957 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2957) / _1091; float _3038; @@ -892,9 +892,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _3038 = _3030; } - _2872.z = pow(10.0, _3038); - float3 _3044 = pow(((_2872 - float3(3.5073844628641381859779357910156e-05)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _3052 = pow((float3(0.8359375) + (float3(18.8515625) * _3044)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _3044))), float3(78.84375)); + _2872.z = powr(10.0, _3038); + float3 _3044 = powr(((_2872 - float3(3.5073844628641381859779357910156e-05)) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _3052 = powr((float3(0.8359375) + (float3(18.8515625) * _3044)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _3044))), float3(78.84375)); } else { @@ -1056,7 +1056,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _1596 = _1593; } float3 _1598; - _1598.x = pow(10.0, _1596); + _1598.x = powr(10.0, _1596); float _1599 = _1517.y; float _1603 = log((_1599 <= 0.0) ? _1524 : _1599) / _1091; float _1670; @@ -1094,7 +1094,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1670 = _1667; } - _1598.y = pow(10.0, _1670); + _1598.y = powr(10.0, _1670); float _1673 = _1517.z; float _1677 = log((_1673 <= 0.0) ? _1524 : _1673) / _1091; float _1744; @@ -1132,9 +1132,9 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1744 = _1741; } - _1598.z = pow(10.0, _1744); + _1598.z = powr(10.0, _1744); float3 _1748 = (_1598 * float3x3(float3(0.695452213287353515625, 0.140678703784942626953125, 0.16386906802654266357421875), float3(0.0447945632040500640869140625, 0.859671115875244140625, 0.095534317195415496826171875), float3(-0.0055258828215301036834716796875, 0.0040252101607620716094970703125, 1.00150072574615478515625))) * float3x3(float3(1.45143926143646240234375, -0.236510753631591796875, -0.214928567409515380859375), float3(-0.07655377686023712158203125, 1.1762297153472900390625, -0.0996759235858917236328125), float3(0.0083161480724811553955078125, -0.0060324496589601039886474609375, 0.99771630764007568359375)); - float _1750 = 0.17999999225139617919921875 * pow(2.0, -12.0); + float _1750 = 0.17999999225139617919921875 * powr(2.0, -12.0); float _1754 = log((_1750 <= 0.0) ? _1524 : _1750) / _1091; float _1821; if (_1754 <= _1529) @@ -1203,8 +1203,8 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1878 = _1875; } - float _1879 = pow(10.0, _1878); - float _1881 = 0.17999999225139617919921875 * pow(2.0, 11.0); + float _1879 = powr(10.0, _1878); + float _1881 = 0.17999999225139617919921875 * powr(2.0, 11.0); float _1885 = log((_1881 <= 0.0) ? _1524 : _1881) / _1091; float _1950; if (_1885 <= _1529) @@ -1240,10 +1240,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _1950 = _1947; } - float _1951 = pow(10.0, _1950); + float _1951 = powr(10.0, _1950); float _1952 = _1748.x; float _1956 = log((_1952 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _1952) / _1091; - float _1958 = log(pow(10.0, _1821)) / _1091; + float _1958 = log(powr(10.0, _1821)) / _1091; float _2030; if (_1956 <= _1958) { @@ -1281,7 +1281,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa _2030 = _2027; } float3 _2032; - _2032.x = pow(10.0, _2030); + _2032.x = powr(10.0, _2030); float _2033 = _1748.y; float _2037 = log((_2033 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2033) / _1091; float _2109; @@ -1320,7 +1320,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2109 = _2106; } - _2032.y = pow(10.0, _2109); + _2032.y = powr(10.0, _2109); float _2112 = _1748.z; float _2116 = log((_2112 <= 0.0) ? 9.9999997473787516355514526367188e-05 : _2112) / _1091; float _2188; @@ -1359,21 +1359,21 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Globals& _Globa } _2188 = _2185; } - _2032.z = pow(10.0, _2188); - float3 _2193 = pow((_2032 * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _2201 = pow((float3(0.8359375) + (float3(18.8515625) * _2193)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2193))), float3(78.84375)); + _2032.z = powr(10.0, _2188); + float3 _2193 = powr((_2032 * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _2201 = powr((float3(0.8359375) + (float3(18.8515625) * _2193)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _2193))), float3(78.84375)); } else { float3 _1366; if (_Globals.OutputDevice == 7u) { - float3 _1358 = pow(((_932 * _573) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); - _1366 = pow((float3(0.8359375) + (float3(18.8515625) * _1358)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _1358))), float3(78.84375)); + float3 _1358 = powr(((_932 * _573) * _602) * float3(9.9999997473787516355514526367188e-05), float3(0.1593017578125)); + _1366 = powr((float3(0.8359375) + (float3(18.8515625) * _1358)) * (float3(1.0) / (float3(1.0) + (float3(18.6875) * _1358))), float3(78.84375)); } else { - _1366 = pow((_1324 * _573) * _602, float3(_Globals.InverseGamma.z)); + _1366 = powr((_1324 * _573) * _602, float3(_Globals.InverseGamma.z)); } _2201 = _1366; } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag index 72a9c58a63..90c944f34e 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct type_View { float4x4 View_TranslatedWorldToClip; @@ -489,12 +530,12 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_View& View [[bu if (View.View_NumSceneColorMSAASamples > 1) { _268 = _255 * float4(float(View.View_NumSceneColorMSAASamples) * 0.25); - _269 = gl_SampleMaskIn & 15u; + _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0] & 15u; } else { _268 = _255; - _269 = gl_SampleMaskIn; + _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0]; } out.out_var_SV_Target0 = _268; out.gl_SampleMask = _269; diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc index 84540d3592..c2d047a7c5 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-incorrect-base-type.invalid.asm.tesc @@ -263,7 +263,7 @@ struct type_StructuredBuffer_v4float float4 _m0[1]; }; -constant float4 _142 = {}; +constant float4 _140 = {}; struct main0_out { @@ -300,7 +300,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], const device type_StructuredBuffer_v4float& View_PrimitiveSceneData [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -308,26 +308,26 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _144 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _145 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _146 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); - spvUnsafeArray, 12> _147 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0 }) }); - spvUnsafeArray _148 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD4, gl_in[1].in_var_TEXCOORD4, gl_in[2].in_var_TEXCOORD4, gl_in[3].in_var_TEXCOORD4, gl_in[4].in_var_TEXCOORD4, gl_in[5].in_var_TEXCOORD4, gl_in[6].in_var_TEXCOORD4, gl_in[7].in_var_TEXCOORD4, gl_in[8].in_var_TEXCOORD4, gl_in[9].in_var_TEXCOORD4, gl_in[10].in_var_TEXCOORD4, gl_in[11].in_var_TEXCOORD4 }); - spvUnsafeArray _149 = spvUnsafeArray({ gl_in[0].in_var_PRIMITIVE_ID, gl_in[1].in_var_PRIMITIVE_ID, gl_in[2].in_var_PRIMITIVE_ID, gl_in[3].in_var_PRIMITIVE_ID, gl_in[4].in_var_PRIMITIVE_ID, gl_in[5].in_var_PRIMITIVE_ID, gl_in[6].in_var_PRIMITIVE_ID, gl_in[7].in_var_PRIMITIVE_ID, gl_in[8].in_var_PRIMITIVE_ID, gl_in[9].in_var_PRIMITIVE_ID, gl_in[10].in_var_PRIMITIVE_ID, gl_in[11].in_var_PRIMITIVE_ID }); - spvUnsafeArray _150 = spvUnsafeArray({ gl_in[0].in_var_LIGHTMAP_ID, gl_in[1].in_var_LIGHTMAP_ID, gl_in[2].in_var_LIGHTMAP_ID, gl_in[3].in_var_LIGHTMAP_ID, gl_in[4].in_var_LIGHTMAP_ID, gl_in[5].in_var_LIGHTMAP_ID, gl_in[6].in_var_LIGHTMAP_ID, gl_in[7].in_var_LIGHTMAP_ID, gl_in[8].in_var_LIGHTMAP_ID, gl_in[9].in_var_LIGHTMAP_ID, gl_in[10].in_var_LIGHTMAP_ID, gl_in[11].in_var_LIGHTMAP_ID }); - spvUnsafeArray _259 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _284 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[0], _145[0], _146[0], _147[0], _148[0], _149[0], _150[0] } }, FBasePassInterpolantsVSToDS{ { } }, _259[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[1], _145[1], _146[1], _147[1], _148[1], _149[1], _150[1] } }, FBasePassInterpolantsVSToDS{ { } }, _259[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[2], _145[2], _146[2], _147[2], _148[2], _149[2], _150[2] } }, FBasePassInterpolantsVSToDS{ { } }, _259[2] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[3], _145[3], _146[3], _147[3], _148[3], _149[3], _150[3] } }, FBasePassInterpolantsVSToDS{ { } }, _259[3] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[4], _145[4], _146[4], _147[4], _148[4], _149[4], _150[4] } }, FBasePassInterpolantsVSToDS{ { } }, _259[4] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[5], _145[5], _146[5], _147[5], _148[5], _149[5], _150[5] } }, FBasePassInterpolantsVSToDS{ { } }, _259[5] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[6], _145[6], _146[6], _147[6], _148[6], _149[6], _150[6] } }, FBasePassInterpolantsVSToDS{ { } }, _259[6] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[7], _145[7], _146[7], _147[7], _148[7], _149[7], _150[7] } }, FBasePassInterpolantsVSToDS{ { } }, _259[7] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[8], _145[8], _146[8], _147[8], _148[8], _149[8], _150[8] } }, FBasePassInterpolantsVSToDS{ { } }, _259[8] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[9], _145[9], _146[9], _147[9], _148[9], _149[9], _150[9] } }, FBasePassInterpolantsVSToDS{ { } }, _259[9] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[10], _145[10], _146[10], _147[10], _148[10], _149[10], _150[10] } }, FBasePassInterpolantsVSToDS{ { } }, _259[10] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _144[11], _145[11], _146[11], _147[11], _148[11], _149[11], _150[11] } }, FBasePassInterpolantsVSToDS{ { } }, _259[11] } }); - spvUnsafeArray param_var_I = _284; - float4 _301 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _310 = View_PrimitiveSceneData._m0[(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId * 26u) + 22u].xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _313 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _314 = 2u * gl_InvocationID; - uint _315 = 3u + _314; - uint _316 = _314 + 4u; - float4 _328 = float4(param_var_I[_313].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _336 = float4(param_var_I[_315].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _344 = float4(param_var_I[_316].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _392 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_313].Position) - (float4(dot(param_var_I[_313].Position - param_var_I[gl_InvocationID].Position, _301)) * _301)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_315].Position) + param_var_I[_316].Position) - (float4(dot(param_var_I[_316].Position - param_var_I[_315].Position, _336)) * _336)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_313].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_313].Position, _328)) * _328)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_316].Position) + param_var_I[_315].Position) - (float4(dot(param_var_I[_315].Position - param_var_I[_316].Position, _344)) * _344)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + spvUnsafeArray _142 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _143 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _144 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); + spvUnsafeArray, 12> _145 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0 }) }); + spvUnsafeArray _146 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD4, gl_in[1].in_var_TEXCOORD4, gl_in[2].in_var_TEXCOORD4, gl_in[3].in_var_TEXCOORD4, gl_in[4].in_var_TEXCOORD4, gl_in[5].in_var_TEXCOORD4, gl_in[6].in_var_TEXCOORD4, gl_in[7].in_var_TEXCOORD4, gl_in[8].in_var_TEXCOORD4, gl_in[9].in_var_TEXCOORD4, gl_in[10].in_var_TEXCOORD4, gl_in[11].in_var_TEXCOORD4 }); + spvUnsafeArray _147 = spvUnsafeArray({ gl_in[0].in_var_PRIMITIVE_ID, gl_in[1].in_var_PRIMITIVE_ID, gl_in[2].in_var_PRIMITIVE_ID, gl_in[3].in_var_PRIMITIVE_ID, gl_in[4].in_var_PRIMITIVE_ID, gl_in[5].in_var_PRIMITIVE_ID, gl_in[6].in_var_PRIMITIVE_ID, gl_in[7].in_var_PRIMITIVE_ID, gl_in[8].in_var_PRIMITIVE_ID, gl_in[9].in_var_PRIMITIVE_ID, gl_in[10].in_var_PRIMITIVE_ID, gl_in[11].in_var_PRIMITIVE_ID }); + spvUnsafeArray _148 = spvUnsafeArray({ gl_in[0].in_var_LIGHTMAP_ID, gl_in[1].in_var_LIGHTMAP_ID, gl_in[2].in_var_LIGHTMAP_ID, gl_in[3].in_var_LIGHTMAP_ID, gl_in[4].in_var_LIGHTMAP_ID, gl_in[5].in_var_LIGHTMAP_ID, gl_in[6].in_var_LIGHTMAP_ID, gl_in[7].in_var_LIGHTMAP_ID, gl_in[8].in_var_LIGHTMAP_ID, gl_in[9].in_var_LIGHTMAP_ID, gl_in[10].in_var_LIGHTMAP_ID, gl_in[11].in_var_LIGHTMAP_ID }); + spvUnsafeArray _257 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _282 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[0], _143[0], _144[0], _145[0], _146[0], _147[0], _148[0] } }, FBasePassInterpolantsVSToDS{ { } }, _257[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[1], _143[1], _144[1], _145[1], _146[1], _147[1], _148[1] } }, FBasePassInterpolantsVSToDS{ { } }, _257[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[2], _143[2], _144[2], _145[2], _146[2], _147[2], _148[2] } }, FBasePassInterpolantsVSToDS{ { } }, _257[2] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[3], _143[3], _144[3], _145[3], _146[3], _147[3], _148[3] } }, FBasePassInterpolantsVSToDS{ { } }, _257[3] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[4], _143[4], _144[4], _145[4], _146[4], _147[4], _148[4] } }, FBasePassInterpolantsVSToDS{ { } }, _257[4] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[5], _143[5], _144[5], _145[5], _146[5], _147[5], _148[5] } }, FBasePassInterpolantsVSToDS{ { } }, _257[5] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[6], _143[6], _144[6], _145[6], _146[6], _147[6], _148[6] } }, FBasePassInterpolantsVSToDS{ { } }, _257[6] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[7], _143[7], _144[7], _145[7], _146[7], _147[7], _148[7] } }, FBasePassInterpolantsVSToDS{ { } }, _257[7] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[8], _143[8], _144[8], _145[8], _146[8], _147[8], _148[8] } }, FBasePassInterpolantsVSToDS{ { } }, _257[8] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[9], _143[9], _144[9], _145[9], _146[9], _147[9], _148[9] } }, FBasePassInterpolantsVSToDS{ { } }, _257[9] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[10], _143[10], _144[10], _145[10], _146[10], _147[10], _148[10] } }, FBasePassInterpolantsVSToDS{ { } }, _257[10] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[11], _143[11], _144[11], _145[11], _146[11], _147[11], _148[11] } }, FBasePassInterpolantsVSToDS{ { } }, _257[11] } }); + spvUnsafeArray param_var_I = _282; + float4 _299 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _308 = View_PrimitiveSceneData._m0[(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId * 26u) + 22u].xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _311 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _312 = 2u * gl_InvocationID; + uint _313 = 3u + _312; + uint _314 = _312 + 4u; + float4 _326 = float4(param_var_I[_311].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _334 = float4(param_var_I[_313].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _342 = float4(param_var_I[_314].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _390 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_311].Position) - (float4(dot(param_var_I[_311].Position - param_var_I[gl_InvocationID].Position, _299)) * _299)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_313].Position) + param_var_I[_314].Position) - (float4(dot(param_var_I[_314].Position - param_var_I[_313].Position, _334)) * _334)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_311].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_311].Position, _326)) * _326)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_314].Position) + param_var_I[_313].Position) - (float4(dot(param_var_I[_313].Position - param_var_I[_314].Position, _342)) * _342)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_COLOR0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.Color; @@ -336,60 +336,60 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) gl_out[gl_InvocationID].out_var_PRIMITIVE_ID = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.PrimitiveId; gl_out[gl_InvocationID].out_var_LIGHTMAP_ID = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.LightmapDataIndex; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_PN_POSITION = _392; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _310; + gl_out[gl_InvocationID].out_var_PN_POSITION = _390; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _308; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _392, _310, 1.0, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _390, _308, 1.0, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _450 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _463; - _463.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _463.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _463.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _463.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _589; + float4 _448 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _461; + _461.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _461.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _461.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _461.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _587; for (;;) { - float4 _489 = View.View_ViewToClip * float4(0.0); - float4 _494 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _495 = _494.xyz; - float3 _496 = _489.xyz; - float _498 = _494.w; - float _499 = _489.w; - float4 _516 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _517 = _516.xyz; - float _519 = _516.w; - float4 _537 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _538 = _537.xyz; - float _540 = _537.w; - if (any((((int3((_495 - _496) < float3(_498 + _499)) + (int3(2) * int3((_495 + _496) > float3((-_498) - _499)))) | (int3((_517 - _496) < float3(_519 + _499)) + (int3(2) * int3((_517 + _496) > float3((-_519) - _499))))) | (int3((_538 - _496) < float3(_540 + _499)) + (int3(2) * int3((_538 + _496) > float3((-_540) - _499))))) != int3(3))) + float4 _487 = View.View_ViewToClip * float4(0.0); + float4 _492 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _493 = _492.xyz; + float3 _494 = _487.xyz; + float _496 = _492.w; + float _497 = _487.w; + float4 _514 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _515 = _514.xyz; + float _517 = _514.w; + float4 _535 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _536 = _535.xyz; + float _538 = _535.w; + if (any((((int3((_493 - _494) < float3(_496 + _497)) + (int3(2) * int3((_493 + _494) > float3((-_496) - _497)))) | (int3((_515 - _494) < float3(_517 + _497)) + (int3(2) * int3((_515 + _494) > float3((-_517) - _497))))) | (int3((_536 - _494) < float3(_538 + _497)) + (int3(2) * int3((_536 + _494) > float3((-_538) - _497))))) != int3(3))) { - _589 = float4(0.0); + _587 = float4(0.0); break; } - float3 _558 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _559 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _560 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _563 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _566 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _569 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _573 = sqrt(dot(_559, _559) / dot(_566, _566)); - float _577 = sqrt(dot(_560, _560) / dot(_569, _569)); - float _581 = sqrt(dot(_558, _558) / dot(_563, _563)); - float4 _582 = float4(_573, _577, _581, 1.0); - _582.w = 0.333000004291534423828125 * ((_573 + _577) + _581); - _589 = float4(View.View_AdaptiveTessellationFactor) * _582; + float3 _556 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _557 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _558 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _561 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _564 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _567 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _571 = sqrt(dot(_557, _557) / dot(_564, _564)); + float _575 = sqrt(dot(_558, _558) / dot(_567, _567)); + float _579 = sqrt(dot(_556, _556) / dot(_561, _561)); + float4 _580 = float4(_571, _575, _579, 1.0); + _580.w = 0.333000004291534423828125 * ((_571 + _575) + _579); + _587 = float4(View.View_AdaptiveTessellationFactor) * _580; break; } - float4 _591 = fast::clamp(_463 * _589, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_591.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_591.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_591.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_591.w); - patchOut.out_var_PN_POSITION9 = _450 + ((_450 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _589 = fast::clamp(_461 * _587, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_589.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_589.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_589.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_589.w); + patchOut.out_var_PN_POSITION9 = _448 + ((_448 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc index 3bfbb69cde..61fe177287 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-input-array-access.invalid.asm.tesc @@ -304,7 +304,7 @@ struct type_Primitive float4 Primitive_CustomPrimitiveData[4]; }; -constant float4 _140 = {}; +constant float4 _136 = {}; struct main0_out { @@ -342,7 +342,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], constant type_Primitive& Primitive [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -350,114 +350,114 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _142 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _143 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _192 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _193 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_VertexID, gl_in[1].in_var_VS_To_DS_VertexID, gl_in[2].in_var_VS_To_DS_VertexID, gl_in[3].in_var_VS_To_DS_VertexID, gl_in[4].in_var_VS_To_DS_VertexID, gl_in[5].in_var_VS_To_DS_VertexID, gl_in[6].in_var_VS_To_DS_VertexID, gl_in[7].in_var_VS_To_DS_VertexID, gl_in[8].in_var_VS_To_DS_VertexID, gl_in[9].in_var_VS_To_DS_VertexID, gl_in[10].in_var_VS_To_DS_VertexID, gl_in[11].in_var_VS_To_DS_VertexID }); - spvUnsafeArray _230 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[0], _143[0] } }, _192[0], _193[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[1], _143[1] } }, _192[1], _193[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[2], _143[2] } }, _192[2], _193[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[3], _143[3] } }, _192[3], _193[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[4], _143[4] } }, _192[4], _193[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[5], _143[5] } }, _192[5], _193[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[6], _143[6] } }, _192[6], _193[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[7], _143[7] } }, _192[7], _193[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[8], _143[8] } }, _192[8], _193[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[9], _143[9] } }, _192[9], _193[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[10], _143[10] } }, _192[10], _193[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _142[11], _143[11] } }, _192[11], _193[11] } }); - spvUnsafeArray param_var_I = _230; - float4 _247 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _251 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _254 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _255 = 2u * gl_InvocationID; - uint _256 = 3u + _255; - uint _257 = _255 + 4u; - uint _264 = (_254 < 2u) ? (_254 + 1u) : 0u; - uint _265 = 2u * _254; - uint _266 = 3u + _265; - uint _267 = _265 + 4u; - float4 _279 = float4(param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _315; - float4 _316; - float4 _317; - float4 _318; - if ((param_var_I[_266].VertexID < param_var_I[_254].VertexID) || ((param_var_I[_266].VertexID == param_var_I[_254].VertexID) && (param_var_I[_267].VertexID < param_var_I[_264].VertexID))) + spvUnsafeArray _138 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _139 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _188 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _189 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_VertexID, gl_in[1].in_var_VS_To_DS_VertexID, gl_in[2].in_var_VS_To_DS_VertexID, gl_in[3].in_var_VS_To_DS_VertexID, gl_in[4].in_var_VS_To_DS_VertexID, gl_in[5].in_var_VS_To_DS_VertexID, gl_in[6].in_var_VS_To_DS_VertexID, gl_in[7].in_var_VS_To_DS_VertexID, gl_in[8].in_var_VS_To_DS_VertexID, gl_in[9].in_var_VS_To_DS_VertexID, gl_in[10].in_var_VS_To_DS_VertexID, gl_in[11].in_var_VS_To_DS_VertexID }); + spvUnsafeArray _226 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[0], _139[0] } }, _188[0], _189[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[1], _139[1] } }, _188[1], _189[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[2], _139[2] } }, _188[2], _189[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[3], _139[3] } }, _188[3], _189[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[4], _139[4] } }, _188[4], _189[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[5], _139[5] } }, _188[5], _189[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[6], _139[6] } }, _188[6], _189[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[7], _139[7] } }, _188[7], _189[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[8], _139[8] } }, _188[8], _189[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[9], _139[9] } }, _188[9], _189[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[10], _139[10] } }, _188[10], _189[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _138[11], _139[11] } }, _188[11], _189[11] } }); + spvUnsafeArray param_var_I = _226; + float4 _243 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _247 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _250 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _251 = 2u * gl_InvocationID; + uint _252 = 3u + _251; + uint _253 = _251 + 4u; + uint _260 = (_250 < 2u) ? (_250 + 1u) : 0u; + uint _261 = 2u * _250; + uint _262 = 3u + _261; + uint _263 = _261 + 4u; + float4 _275 = float4(param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _311; + float4 _312; + float4 _313; + float4 _314; + if ((param_var_I[_262].VertexID < param_var_I[_250].VertexID) || ((param_var_I[_262].VertexID == param_var_I[_250].VertexID) && (param_var_I[_263].VertexID < param_var_I[_260].VertexID))) { - _315 = param_var_I[_267].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _316 = param_var_I[_267].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; - _317 = param_var_I[_266].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _318 = param_var_I[_266].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _311 = param_var_I[_263].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _312 = param_var_I[_263].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _313 = param_var_I[_262].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _314 = param_var_I[_262].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; } else { - _315 = param_var_I[_264].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _316 = param_var_I[_264].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; - _317 = param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; - _318 = param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _311 = param_var_I[_260].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _312 = param_var_I[_260].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; + _313 = param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; + _314 = param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; } - float4 _324 = float4(_318.xyz, 0.0); - float4 _328 = float4(_316.xyz, 0.0); - float4 _336 = float4(param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _344 = float4(param_var_I[_256].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _352 = float4(param_var_I[_257].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _402 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_254].Position) - (float4(dot(param_var_I[_254].Position - param_var_I[gl_InvocationID].Position, _247)) * _247)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_256].Position) + param_var_I[_257].Position) - (float4(dot(param_var_I[_257].Position - param_var_I[_256].Position, _344)) * _344)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_254].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_254].Position, _336)) * _336)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_257].Position) + param_var_I[_256].Position) - (float4(dot(param_var_I[_256].Position - param_var_I[_257].Position, _352)) * _352)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + float4 _320 = float4(_314.xyz, 0.0); + float4 _324 = float4(_312.xyz, 0.0); + float4 _332 = float4(param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _340 = float4(param_var_I[_252].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _348 = float4(param_var_I[_253].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _398 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_250].Position) - (float4(dot(param_var_I[_250].Position - param_var_I[gl_InvocationID].Position, _243)) * _243)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_252].Position) + param_var_I[_253].Position) - (float4(dot(param_var_I[_253].Position - param_var_I[_252].Position, _340)) * _340)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_250].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_250].Position, _332)) * _332)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_253].Position) + param_var_I[_252].Position) - (float4(dot(param_var_I[_252].Position - param_var_I[_253].Position, _348)) * _348)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; gl_out[gl_InvocationID].out_var_VS_To_DS_VertexID = param_var_I[gl_InvocationID].VertexID; - gl_out[gl_InvocationID].out_var_PN_POSITION = _402; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _251; + gl_out[gl_InvocationID].out_var_PN_POSITION = _398; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _247; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_DominantVertex = float2(0.0); - gl_out[gl_InvocationID].out_var_PN_DominantVertex1 = _279; + gl_out[gl_InvocationID].out_var_PN_DominantVertex1 = _275; gl_out[gl_InvocationID].out_var_PN_DominantVertex2 = param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz; gl_out[gl_InvocationID].out_var_PN_DominantEdge = float2(0.0); gl_out[gl_InvocationID].out_var_PN_DominantEdge1 = float2(0.0); - gl_out[gl_InvocationID].out_var_PN_DominantEdge2 = _324; - gl_out[gl_InvocationID].out_var_PN_DominantEdge3 = _328; - gl_out[gl_InvocationID].out_var_PN_DominantEdge4 = _317.xyz; - gl_out[gl_InvocationID].out_var_PN_DominantEdge5 = _315.xyz; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _402, _251, 1.0, 1.0, FHullShaderConstantDominantVertexData{ float2(0.0), _279, param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz }, FHullShaderConstantDominantEdgeData{ float2(0.0), float2(0.0), _324, _328, _317.xyz, _315.xyz } }; + gl_out[gl_InvocationID].out_var_PN_DominantEdge2 = _320; + gl_out[gl_InvocationID].out_var_PN_DominantEdge3 = _324; + gl_out[gl_InvocationID].out_var_PN_DominantEdge4 = _313.xyz; + gl_out[gl_InvocationID].out_var_PN_DominantEdge5 = _311.xyz; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _398, _247, 1.0, 1.0, FHullShaderConstantDominantVertexData{ float2(0.0), _275, param_var_I[9u + gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz }, FHullShaderConstantDominantEdgeData{ float2(0.0), float2(0.0), _320, _324, _313.xyz, _311.xyz } }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _461 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _474; - _474.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _474.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _474.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _474.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _600; + float4 _457 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _470; + _470.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _470.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _470.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _470.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _596; for (;;) { - float4 _500 = View.View_ViewToClip * float4(0.0); - float4 _505 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _506 = _505.xyz; - float3 _507 = _500.xyz; - float _509 = _505.w; - float _510 = _500.w; - float4 _527 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _528 = _527.xyz; - float _530 = _527.w; - float4 _548 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _549 = _548.xyz; - float _551 = _548.w; - if (any((((int3((_506 - _507) < float3(_509 + _510)) + (int3(2) * int3((_506 + _507) > float3((-_509) - _510)))) | (int3((_528 - _507) < float3(_530 + _510)) + (int3(2) * int3((_528 + _507) > float3((-_530) - _510))))) | (int3((_549 - _507) < float3(_551 + _510)) + (int3(2) * int3((_549 + _507) > float3((-_551) - _510))))) != int3(3))) + float4 _496 = View.View_ViewToClip * float4(0.0); + float4 _501 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _502 = _501.xyz; + float3 _503 = _496.xyz; + float _505 = _501.w; + float _506 = _496.w; + float4 _523 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _524 = _523.xyz; + float _526 = _523.w; + float4 _544 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _545 = _544.xyz; + float _547 = _544.w; + if (any((((int3((_502 - _503) < float3(_505 + _506)) + (int3(2) * int3((_502 + _503) > float3((-_505) - _506)))) | (int3((_524 - _503) < float3(_526 + _506)) + (int3(2) * int3((_524 + _503) > float3((-_526) - _506))))) | (int3((_545 - _503) < float3(_547 + _506)) + (int3(2) * int3((_545 + _503) > float3((-_547) - _506))))) != int3(3))) { - _600 = float4(0.0); + _596 = float4(0.0); break; } - float3 _569 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _570 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _571 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _574 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _577 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _580 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _584 = sqrt(dot(_570, _570) / dot(_577, _577)); - float _588 = sqrt(dot(_571, _571) / dot(_580, _580)); - float _592 = sqrt(dot(_569, _569) / dot(_574, _574)); - float4 _593 = float4(_584, _588, _592, 1.0); - _593.w = 0.333000004291534423828125 * ((_584 + _588) + _592); - _600 = float4(View.View_AdaptiveTessellationFactor) * _593; + float3 _565 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _566 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _567 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _570 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _573 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _576 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _580 = sqrt(dot(_566, _566) / dot(_573, _573)); + float _584 = sqrt(dot(_567, _567) / dot(_576, _576)); + float _588 = sqrt(dot(_565, _565) / dot(_570, _570)); + float4 _589 = float4(_580, _584, _588, 1.0); + _589.w = 0.333000004291534423828125 * ((_580 + _584) + _588); + _596 = float4(View.View_AdaptiveTessellationFactor) * _589; break; } - float4 _602 = fast::clamp(_474 * _600, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_602.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_602.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_602.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_602.w); - patchOut.out_var_PN_POSITION9 = _461 + ((_461 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _598 = fast::clamp(_470 * _596, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_598.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_598.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_598.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_598.w); + patchOut.out_var_PN_POSITION9 = _457 + ((_457 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc index 23859bc5bb..f94e610405 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/hs-texcoord-array.invalid.asm.tesc @@ -286,7 +286,7 @@ struct type_Primitive float4 Primitive_CustomPrimitiveData[4]; }; -constant float4 _127 = {}; +constant float4 _123 = {}; struct main0_out { @@ -318,7 +318,7 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0)]], constant type_Primitive& Primitive [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FPNTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; if (gl_InvocationID < spvIndirectParams[0]) @@ -326,82 +326,82 @@ kernel void main0(main0_in in [[stage_in]], constant type_View& View [[buffer(0) threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _129 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _130 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _131 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); - spvUnsafeArray, 12> _132 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0, gl_in[0].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0, gl_in[1].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0, gl_in[2].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0, gl_in[3].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0, gl_in[4].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0, gl_in[5].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0, gl_in[6].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0, gl_in[7].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0, gl_in[8].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0, gl_in[9].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0, gl_in[10].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0, gl_in[11].in_var_TEXCOORD0_1 }) }); - spvUnsafeArray _205 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); - spvUnsafeArray _230 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[0], _130[0], _131[0], _132[0] } }, _205[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[1], _130[1], _131[1], _132[1] } }, _205[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[2], _130[2], _131[2], _132[2] } }, _205[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[3], _130[3], _131[3], _132[3] } }, _205[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[4], _130[4], _131[4], _132[4] } }, _205[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[5], _130[5], _131[5], _132[5] } }, _205[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[6], _130[6], _131[6], _132[6] } }, _205[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[7], _130[7], _131[7], _132[7] } }, _205[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[8], _130[8], _131[8], _132[8] } }, _205[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[9], _130[9], _131[9], _132[9] } }, _205[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[10], _130[10], _131[10], _132[10] } }, _205[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _129[11], _130[11], _131[11], _132[11] } }, _205[11] } }); - spvUnsafeArray param_var_I = _230; - float4 _247 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float3 _251 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); - uint _254 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; - uint _255 = 2u * gl_InvocationID; - uint _256 = 3u + _255; - uint _257 = _255 + 4u; - float4 _269 = float4(param_var_I[_254].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _277 = float4(param_var_I[_256].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - float4 _285 = float4(param_var_I[_257].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); - spvUnsafeArray _333 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_254].Position) - (float4(dot(param_var_I[_254].Position - param_var_I[gl_InvocationID].Position, _247)) * _247)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_256].Position) + param_var_I[_257].Position) - (float4(dot(param_var_I[_257].Position - param_var_I[_256].Position, _277)) * _277)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_254].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_254].Position, _269)) * _269)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_257].Position) + param_var_I[_256].Position) - (float4(dot(param_var_I[_256].Position - param_var_I[_257].Position, _285)) * _285)) * float4(0.3333333432674407958984375))) * float4(0.5) }); + spvUnsafeArray _125 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid, gl_in[3].in_var_TEXCOORD10_centroid, gl_in[4].in_var_TEXCOORD10_centroid, gl_in[5].in_var_TEXCOORD10_centroid, gl_in[6].in_var_TEXCOORD10_centroid, gl_in[7].in_var_TEXCOORD10_centroid, gl_in[8].in_var_TEXCOORD10_centroid, gl_in[9].in_var_TEXCOORD10_centroid, gl_in[10].in_var_TEXCOORD10_centroid, gl_in[11].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _126 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid, gl_in[3].in_var_TEXCOORD11_centroid, gl_in[4].in_var_TEXCOORD11_centroid, gl_in[5].in_var_TEXCOORD11_centroid, gl_in[6].in_var_TEXCOORD11_centroid, gl_in[7].in_var_TEXCOORD11_centroid, gl_in[8].in_var_TEXCOORD11_centroid, gl_in[9].in_var_TEXCOORD11_centroid, gl_in[10].in_var_TEXCOORD11_centroid, gl_in[11].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _127 = spvUnsafeArray({ gl_in[0].in_var_COLOR0, gl_in[1].in_var_COLOR0, gl_in[2].in_var_COLOR0, gl_in[3].in_var_COLOR0, gl_in[4].in_var_COLOR0, gl_in[5].in_var_COLOR0, gl_in[6].in_var_COLOR0, gl_in[7].in_var_COLOR0, gl_in[8].in_var_COLOR0, gl_in[9].in_var_COLOR0, gl_in[10].in_var_COLOR0, gl_in[11].in_var_COLOR0 }); + spvUnsafeArray, 12> _128 = spvUnsafeArray, 12>({ spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0_0, gl_in[0].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[1].in_var_TEXCOORD0_0, gl_in[1].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[2].in_var_TEXCOORD0_0, gl_in[2].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[3].in_var_TEXCOORD0_0, gl_in[3].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[4].in_var_TEXCOORD0_0, gl_in[4].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[5].in_var_TEXCOORD0_0, gl_in[5].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[6].in_var_TEXCOORD0_0, gl_in[6].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[7].in_var_TEXCOORD0_0, gl_in[7].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[8].in_var_TEXCOORD0_0, gl_in[8].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[9].in_var_TEXCOORD0_0, gl_in[9].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[10].in_var_TEXCOORD0_0, gl_in[10].in_var_TEXCOORD0_1 }), spvUnsafeArray({ gl_in[11].in_var_TEXCOORD0_0, gl_in[11].in_var_TEXCOORD0_1 }) }); + spvUnsafeArray _201 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position, gl_in[3].in_var_VS_To_DS_Position, gl_in[4].in_var_VS_To_DS_Position, gl_in[5].in_var_VS_To_DS_Position, gl_in[6].in_var_VS_To_DS_Position, gl_in[7].in_var_VS_To_DS_Position, gl_in[8].in_var_VS_To_DS_Position, gl_in[9].in_var_VS_To_DS_Position, gl_in[10].in_var_VS_To_DS_Position, gl_in[11].in_var_VS_To_DS_Position }); + spvUnsafeArray _226 = spvUnsafeArray({ FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[0], _126[0], _127[0], _128[0] } }, _201[0] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[1], _126[1], _127[1], _128[1] } }, _201[1] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[2], _126[2], _127[2], _128[2] } }, _201[2] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[3], _126[3], _127[3], _128[3] } }, _201[3] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[4], _126[4], _127[4], _128[4] } }, _201[4] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[5], _126[5], _127[5], _128[5] } }, _201[5] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[6], _126[6], _127[6], _128[6] } }, _201[6] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[7], _126[7], _127[7], _128[7] } }, _201[7] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[8], _126[8], _127[8], _128[8] } }, _201[8] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[9], _126[9], _127[9], _128[9] } }, _201[9] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[10], _126[10], _127[10], _128[10] } }, _201[10] }, FHitProxyVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _125[11], _126[11], _127[11], _128[11] } }, _201[11] } }); + spvUnsafeArray param_var_I = _226; + float4 _243 = float4(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float3 _247 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + uint _250 = (gl_InvocationID < 2u) ? (gl_InvocationID + 1u) : 0u; + uint _251 = 2u * gl_InvocationID; + uint _252 = 3u + _251; + uint _253 = _251 + 4u; + float4 _265 = float4(param_var_I[_250].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _273 = float4(param_var_I[_252].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + float4 _281 = float4(param_var_I[_253].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, 0.0); + spvUnsafeArray _329 = spvUnsafeArray({ param_var_I[gl_InvocationID].Position, (((((float4(2.0) * param_var_I[gl_InvocationID].Position) + param_var_I[_250].Position) - (float4(dot(param_var_I[_250].Position - param_var_I[gl_InvocationID].Position, _243)) * _243)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_252].Position) + param_var_I[_253].Position) - (float4(dot(param_var_I[_253].Position - param_var_I[_252].Position, _273)) * _273)) * float4(0.3333333432674407958984375))) * float4(0.5), (((((float4(2.0) * param_var_I[_250].Position) + param_var_I[gl_InvocationID].Position) - (float4(dot(param_var_I[gl_InvocationID].Position - param_var_I[_250].Position, _265)) * _265)) * float4(0.3333333432674407958984375)) + ((((float4(2.0) * param_var_I[_253].Position) + param_var_I[_252].Position) - (float4(dot(param_var_I[_252].Position - param_var_I[_253].Position, _281)) * _281)) * float4(0.3333333432674407958984375))) * float4(0.5) }); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_COLOR0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.Color; gl_out[gl_InvocationID].out_var_TEXCOORD0 = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TexCoords; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_PN_POSITION = _333; - gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _251; + gl_out[gl_InvocationID].out_var_PN_POSITION = _329; + gl_out[gl_InvocationID].out_var_PN_DisplacementScales = _247; gl_out[gl_InvocationID].out_var_PN_TessellationMultiplier = 1.0; gl_out[gl_InvocationID].out_var_PN_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _333, _251, 1.0, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FPNTessellationHSToDS{ param_var_I[gl_InvocationID], _329, _247, 1.0, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _385 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); - float4 _398; - _398.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _398.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _398.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _398.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _524; + float4 _381 = (((((temp_var_hullMainRetVal[0u].WorldPosition[1] + temp_var_hullMainRetVal[0u].WorldPosition[2]) + temp_var_hullMainRetVal[1u].WorldPosition[1]) + temp_var_hullMainRetVal[1u].WorldPosition[2]) + temp_var_hullMainRetVal[2u].WorldPosition[1]) + temp_var_hullMainRetVal[2u].WorldPosition[2]) * float4(0.16666667163372039794921875); + float4 _394; + _394.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _394.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _394.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _394.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _520; for (;;) { - float4 _424 = View.View_ViewToClip * float4(0.0); - float4 _429 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); - float3 _430 = _429.xyz; - float3 _431 = _424.xyz; - float _433 = _429.w; - float _434 = _424.w; - float4 _451 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); - float3 _452 = _451.xyz; - float _454 = _451.w; - float4 _472 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); - float3 _473 = _472.xyz; - float _475 = _472.w; - if (any((((int3((_430 - _431) < float3(_433 + _434)) + (int3(2) * int3((_430 + _431) > float3((-_433) - _434)))) | (int3((_452 - _431) < float3(_454 + _434)) + (int3(2) * int3((_452 + _431) > float3((-_454) - _434))))) | (int3((_473 - _431) < float3(_475 + _434)) + (int3(2) * int3((_473 + _431) > float3((-_475) - _434))))) != int3(3))) + float4 _420 = View.View_ViewToClip * float4(0.0); + float4 _425 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[0u].WorldPosition[0].xyz, 1.0); + float3 _426 = _425.xyz; + float3 _427 = _420.xyz; + float _429 = _425.w; + float _430 = _420.w; + float4 _447 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[1u].WorldPosition[0].xyz, 1.0); + float3 _448 = _447.xyz; + float _450 = _447.w; + float4 _468 = View.View_TranslatedWorldToClip * float4(temp_var_hullMainRetVal[2u].WorldPosition[0].xyz, 1.0); + float3 _469 = _468.xyz; + float _471 = _468.w; + if (any((((int3((_426 - _427) < float3(_429 + _430)) + (int3(2) * int3((_426 + _427) > float3((-_429) - _430)))) | (int3((_448 - _427) < float3(_450 + _430)) + (int3(2) * int3((_448 + _427) > float3((-_450) - _430))))) | (int3((_469 - _427) < float3(_471 + _430)) + (int3(2) * int3((_469 + _427) > float3((-_471) - _430))))) != int3(3))) { - _524 = float4(0.0); + _520 = float4(0.0); break; } - float3 _493 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; - float3 _494 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; - float3 _495 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; - float3 _498 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _501 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float3 _504 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); - float _508 = sqrt(dot(_494, _494) / dot(_501, _501)); - float _512 = sqrt(dot(_495, _495) / dot(_504, _504)); - float _516 = sqrt(dot(_493, _493) / dot(_498, _498)); - float4 _517 = float4(_508, _512, _516, 1.0); - _517.w = 0.333000004291534423828125 * ((_508 + _512) + _516); - _524 = float4(View.View_AdaptiveTessellationFactor) * _517; + float3 _489 = temp_var_hullMainRetVal[0u].WorldPosition[0].xyz - temp_var_hullMainRetVal[1u].WorldPosition[0].xyz; + float3 _490 = temp_var_hullMainRetVal[1u].WorldPosition[0].xyz - temp_var_hullMainRetVal[2u].WorldPosition[0].xyz; + float3 _491 = temp_var_hullMainRetVal[2u].WorldPosition[0].xyz - temp_var_hullMainRetVal[0u].WorldPosition[0].xyz; + float3 _494 = (float3(0.5) * (temp_var_hullMainRetVal[0u].WorldPosition[0].xyz + temp_var_hullMainRetVal[1u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _497 = (float3(0.5) * (temp_var_hullMainRetVal[1u].WorldPosition[0].xyz + temp_var_hullMainRetVal[2u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float3 _500 = (float3(0.5) * (temp_var_hullMainRetVal[2u].WorldPosition[0].xyz + temp_var_hullMainRetVal[0u].WorldPosition[0].xyz)) - float3(View.View_TranslatedWorldCameraOrigin); + float _504 = sqrt(dot(_490, _490) / dot(_497, _497)); + float _508 = sqrt(dot(_491, _491) / dot(_500, _500)); + float _512 = sqrt(dot(_489, _489) / dot(_494, _494)); + float4 _513 = float4(_504, _508, _512, 1.0); + _513.w = 0.333000004291534423828125 * ((_504 + _508) + _512); + _520 = float4(View.View_AdaptiveTessellationFactor) * _513; break; } - float4 _526 = fast::clamp(_398 * _524, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_526.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_526.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_526.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_526.w); - patchOut.out_var_PN_POSITION9 = _385 + ((_385 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); + float4 _522 = fast::clamp(_394 * _520, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_522.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_522.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_522.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_522.w); + patchOut.out_var_PN_POSITION9 = _381 + ((_381 - (((temp_var_hullMainRetVal[2u].WorldPosition[0] + temp_var_hullMainRetVal[1u].WorldPosition[0]) + temp_var_hullMainRetVal[0u].WorldPosition[0]) * float4(0.3333333432674407958984375))) * float4(0.5)); } } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc index cab75e39bd..fb6559d196 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/tesc/tess-factor-must-be-threadgroup.invalid.asm.tesc @@ -115,7 +115,7 @@ struct type_Material float4 Material_ScalarExpressions[1]; }; -constant float4 _88 = {}; +constant float4 _85 = {}; struct main0_out { @@ -136,39 +136,39 @@ struct main0_in kernel void main0(main0_in in [[stage_in]], constant type_Primitive& Primitive [[buffer(0)]], constant type_Material& Material [[buffer(1)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) { - threadgroup FFlatTessellationHSToDS temp_var_hullMainRetVal[3]; + threadgroup spvUnsafeArray temp_var_hullMainRetVal; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; if (gl_InvocationID < spvIndirectParams[0]) gl_in[gl_InvocationID] = in; threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 3) return; - spvUnsafeArray _90 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _91 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _104 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position }); - spvUnsafeArray _111 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[0], _91[0] } }, FBasePassInterpolantsVSToDS{ { } }, _104[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[1], _91[1] } }, FBasePassInterpolantsVSToDS{ { } }, _104[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _90[2], _91[2] } }, FBasePassInterpolantsVSToDS{ { } }, _104[2] } }); - spvUnsafeArray param_var_I = _111; - float3 _128 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); + spvUnsafeArray _87 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD10_centroid, gl_in[1].in_var_TEXCOORD10_centroid, gl_in[2].in_var_TEXCOORD10_centroid }); + spvUnsafeArray _88 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD11_centroid, gl_in[1].in_var_TEXCOORD11_centroid, gl_in[2].in_var_TEXCOORD11_centroid }); + spvUnsafeArray _101 = spvUnsafeArray({ gl_in[0].in_var_VS_To_DS_Position, gl_in[1].in_var_VS_To_DS_Position, gl_in[2].in_var_VS_To_DS_Position }); + spvUnsafeArray _108 = spvUnsafeArray({ FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[0], _88[0] } }, FBasePassInterpolantsVSToDS{ { } }, _101[0] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[1], _88[1] } }, FBasePassInterpolantsVSToDS{ { } }, _101[1] }, FBasePassVSToDS{ FVertexFactoryInterpolantsVSToDS{ FVertexFactoryInterpolantsVSToPS{ _87[2], _88[2] } }, FBasePassInterpolantsVSToDS{ { } }, _101[2] } }); + spvUnsafeArray param_var_I = _108; + float3 _125 = Primitive.Primitive_NonUniformScale.xyz * float3x3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz, cross(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz, param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0.xyz) * float3(param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.w), param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2.xyz); gl_out[gl_InvocationID].out_var_TEXCOORD10_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld0; gl_out[gl_InvocationID].out_var_TEXCOORD11_centroid = param_var_I[gl_InvocationID].FactoryInterpolants.InterpolantsVSToPS.TangentToWorld2; gl_out[gl_InvocationID].out_var_VS_To_DS_Position = param_var_I[gl_InvocationID].Position; - gl_out[gl_InvocationID].out_var_Flat_DisplacementScales = _128; + gl_out[gl_InvocationID].out_var_Flat_DisplacementScales = _125; gl_out[gl_InvocationID].out_var_Flat_TessellationMultiplier = Material.Material_ScalarExpressions[0].x; gl_out[gl_InvocationID].out_var_Flat_WorldDisplacementMultiplier = 1.0; - temp_var_hullMainRetVal[gl_InvocationID] = FFlatTessellationHSToDS{ param_var_I[gl_InvocationID], _128, Material.Material_ScalarExpressions[0].x, 1.0 }; + temp_var_hullMainRetVal[gl_InvocationID] = FFlatTessellationHSToDS{ param_var_I[gl_InvocationID], _125, Material.Material_ScalarExpressions[0].x, 1.0 }; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); if (gl_InvocationID == 0u) { - float4 _154; - _154.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); - _154.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); - _154.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); - _154.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); - float4 _173 = fast::clamp(_154, float4(1.0), float4(15.0)); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_173.x); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_173.y); - spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_173.z); - spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_173.w); + float4 _151; + _151.x = 0.5 * (temp_var_hullMainRetVal[1u].TessellationMultiplier + temp_var_hullMainRetVal[2u].TessellationMultiplier); + _151.y = 0.5 * (temp_var_hullMainRetVal[2u].TessellationMultiplier + temp_var_hullMainRetVal[0u].TessellationMultiplier); + _151.z = 0.5 * (temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier); + _151.w = 0.333000004291534423828125 * ((temp_var_hullMainRetVal[0u].TessellationMultiplier + temp_var_hullMainRetVal[1u].TessellationMultiplier) + temp_var_hullMainRetVal[2u].TessellationMultiplier); + float4 _170 = fast::clamp(_151, float4(1.0), float4(15.0)); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(_170.x); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(_170.y); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(_170.z); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_170.w); } } diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/vert/array-missing-copies.asm.vert b/third_party/spirv-cross/reference/shaders-ue4/asm/vert/array-missing-copies.asm.vert index 67097c5771..edf911518b 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/vert/array-missing-copies.asm.vert +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/vert/array-missing-copies.asm.vert @@ -444,7 +444,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant type_View& View [[buff float3 _459; if (MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w >= 0.0) { - _459 = (MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.xyz * float3(pow(fast::clamp(dot(_341 * float3(_346), MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.xyz), 0.0, 1.0), MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.w))) * float3(1.0 - fast::clamp(exp2(-(_428 * fast::max(_393 - MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w, 0.0))), 0.0, 1.0)); + _459 = (MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.xyz * float3(powr(fast::clamp(dot(_341 * float3(_346), MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.xyz), 0.0, 1.0), MobileBasePass.MobileBasePass_Fog_DirectionalInscatteringColor.w))) * float3(1.0 - fast::clamp(exp2(-(_428 * fast::max(_393 - MobileBasePass.MobileBasePass_Fog_InscatteringLightDirection.w, 0.0))), 0.0, 1.0)); } else { diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/atomic-decrement.asm.comp index 5ece8257da..bd92891d9d 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/atomic-decrement.asm.comp @@ -10,9 +10,9 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { - uint _29 = atomicAdd(u0_counter.c, uint(-1)); + uint _24 = atomicAdd(u0_counter.c, uint(-1)); vec4 r0; - r0.x = uintBitsToFloat(_29); + r0.x = uintBitsToFloat(_24); imageStore(u0, int((uint(floatBitsToInt(r0.x)) * 1u) + (uint(0) >> 2u)), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/atomic-increment.asm.comp index 2a8f711823..00e195cc57 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/atomic-increment.asm.comp @@ -10,9 +10,9 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { - uint _29 = atomicAdd(u0_counter.c, 1u); + uint _24 = atomicAdd(u0_counter.c, 1u); vec4 r0; - r0.x = uintBitsToFloat(_29); + r0.x = uintBitsToFloat(_24); imageStore(u0, int((uint(floatBitsToInt(r0.x)) * 1u) + (uint(0) >> 2u)), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp index abb8a7976c..0b89fa5c64 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp @@ -4,10 +4,10 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer BUF { int values[]; -} _6; +} _8; void main() { - _6.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z); + _8.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z); } diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/hlsl-functionality.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/hlsl-functionality.asm.comp index e80f52404c..f4926ea29f 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/hlsl-functionality.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/hlsl-functionality.asm.comp @@ -13,8 +13,8 @@ layout(binding = 1, std430) buffer Buf_count void _main() { - int _29 = atomicAdd(Buf_count_1._count, 1); - Buf_1._data[_29] = vec4(1.0); + int _25 = atomicAdd(Buf_count_1._count, 1); + Buf_1._data[_25] = vec4(1.0); } void main() diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/logical.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/logical.asm.comp index 9ae25f78a9..17a8675ed3 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/logical.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/logical.asm.comp @@ -24,8 +24,8 @@ bool and(bool a, bool 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)); + bvec2 _48 = bvec2(a.x && b.x, a.y && b.y); + return not(bvec2(_48.x || b.x, _48.y || b.y)); } bvec3 and(bvec3 a, bvec3 b) diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/quantize.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/quantize.asm.comp index c089213800..6930e5f412 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/quantize.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/quantize.asm.comp @@ -7,13 +7,13 @@ layout(binding = 0, std430) buffer SSBO0 vec2 vec2_val; vec3 vec3_val; vec4 vec4_val; -} _4; +} _12; 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))); + _12.scalar = unpackHalf2x16(packHalf2x16(vec2(_12.scalar))).x; + _12.vec2_val = unpackHalf2x16(packHalf2x16(_12.vec2_val)); + _12.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_12.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_12.vec3_val.zz)).x); + _12.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_12.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_12.vec4_val.zw))); } diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp index 8016ebaf9f..e16bd191fd 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -12,10 +12,10 @@ layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_ layout(binding = 0, std430) buffer SSBO { float a; -} _4; +} _6; void main() { - _4.a += 1.0; + _6.a += 1.0; } diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/switch-break-ladder.asm.invalid.comp b/third_party/spirv-cross/reference/shaders/asm/comp/switch-break-ladder.asm.invalid.comp index f326869cef..a22f3c43e5 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/switch-break-ladder.asm.invalid.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/switch-break-ladder.asm.invalid.comp @@ -14,21 +14,21 @@ void main() int a; for (;;) { - bool _22_ladder_break = false; + bool _17_ladder_break = false; switch (c) { case 5: { for (;;) { - bool _30_ladder_break = false; + bool _25_ladder_break = false; switch (o.d) { case 10: case 20: { c += c; - _30_ladder_break = true; + _25_ladder_break = true; break; } default: @@ -36,7 +36,7 @@ void main() continue; } } - if (_30_ladder_break) + if (_25_ladder_break) { break; } @@ -48,11 +48,11 @@ void main() case 3: { a = c; - _22_ladder_break = true; + _17_ladder_break = true; break; } } - if (_22_ladder_break) + if (_17_ladder_break) { break; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag index c64818d2bf..bbf9a7ddb0 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/composite-construct-struct-no-swizzle.asm.frag @@ -13,7 +13,7 @@ layout(location = 0) out float FooOut; void main() { - SwizzleTest _22 = SwizzleTest(foo.x, foo.y); - FooOut = _22.a + _22.b; + SwizzleTest _19 = SwizzleTest(foo.x, foo.y); + FooOut = _19.a + _19.b; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/default-member-names.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/default-member-names.asm.frag index 57d4536c9b..82406520b0 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/default-member-names.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/default-member-names.asm.frag @@ -1,11 +1,11 @@ #version 450 -struct _9 +struct _10 { float _m0; }; -struct _10 +struct _11 { float _m0; float _m1; @@ -19,14 +19,14 @@ struct _10 float _m9; float _m10; float _m11; - _9 _m12; + _10 _m12; }; layout(location = 0) out vec4 _3; void main() { - _10 _21; - _3 = vec4(_21._m0, _21._m1, _21._m2, _21._m3); + _11 _23; + _3 = vec4(_23._m0, _23._m1, _23._m2, _23._m3); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/empty-struct.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/empty-struct.asm.frag index 7c9d39338e..b3712c0043 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/empty-struct.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/empty-struct.asm.frag @@ -17,9 +17,9 @@ float GetValue_1(EmptyStructTest self) void main() { - EmptyStructTest _23 = EmptyStructTest(0); + EmptyStructTest _24 = EmptyStructTest(0); EmptyStructTest emptyStruct; float value = GetValue(emptyStruct); - value = GetValue_1(_23); + value = GetValue_1(_24); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/for-loop-phi-only-continue.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/for-loop-phi-only-continue.asm.frag index 3101142944..a97b0fb7e0 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/for-loop-phi-only-continue.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/for-loop-phi-only-continue.asm.frag @@ -4,15 +4,15 @@ layout(location = 0) out vec4 FragColor; void main() { - float _19; - _19 = 0.0; - float _20; - int _23; - for (int _22 = 0; _22 < 16; _19 = _20, _22 = _23) + float _50; + _50 = 0.0; + float _25; + int _28; + for (int _47 = 0; _47 < 16; _50 = _25, _47 = _28) { - _20 = _19 + 1.0; - _23 = _22 + 1; + _25 = _50 + 1.0; + _28 = _47 + 1; } - FragColor = vec4(_19); + FragColor = vec4(_50); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag index ec89d44eef..ebaab6b906 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag @@ -6,8 +6,8 @@ layout(location = 0) out float _entryPointOutput; float _main() { - vec4 _33 = vec4(0.100000001490116119384765625, 0.100000001490116119384765625, 0.100000001490116119384765625, 0.5); - return textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(_33.xyz, _33.w), vec3(0.0), vec3(0.0)); + vec4 _29 = vec4(0.100000001490116119384765625, 0.100000001490116119384765625, 0.100000001490116119384765625, 0.5); + return textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(_29.xyz, _29.w), vec3(0.0), vec3(0.0)); } void main() diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag index 63856ddd46..fc1fa20c49 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero.asm.frag @@ -9,8 +9,8 @@ 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)); + vec4 _39 = vec4(vec3(texCoords_1, cascadeIndex_1), fragDepth_1); + float c = textureGrad(SPIRV_Cross_CombinedShadowMapShadowSamplerPCF, vec4(_39.xyz, _39.w), vec2(0.0), vec2(0.0)); return vec4(c, c, c, c); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/implicit-read-dep-phi.asm.frag index 6bc1be0d0f..0596ed6200 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/implicit-read-dep-phi.asm.frag @@ -9,20 +9,20 @@ void main() { int i = 0; float phi; - vec4 _36; + vec4 _45; phi = 1.0; - _36 = vec4(1.0, 2.0, 1.0, 2.0); + _45 = vec4(1.0, 2.0, 1.0, 2.0); for (;;) { - FragColor = _36; + FragColor = _45; if (i < 4) { if (v0[i] > 0.0) { - vec2 _48 = vec2(phi); + vec2 _43 = vec2(phi); i++; phi += 2.0; - _36 = textureLod(uImage, _48, 0.0); + _45 = textureLod(uImage, _43, 0.0); continue; } else diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/invalidation.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/invalidation.asm.frag index db1181804c..1aba1cfa55 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/invalidation.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/invalidation.asm.frag @@ -8,8 +8,8 @@ void main() { float a = v0; float b = v1; - float _17 = a; + float _16 = a; a = v1; - FragColor = (_17 + b) * b; + FragColor = (_16 + b) * b; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/locations-components.asm.frag index 95dcd9ceb7..4b0870e68f 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/locations-components.asm.frag @@ -1,21 +1,21 @@ #version 450 -layout(location = 1) in vec2 _2; -layout(location = 1, component = 2) in float _3; -layout(location = 2) flat in float _4; -layout(location = 2, component = 1) flat in uint _5; -layout(location = 2, component = 2) flat in uint _6; +layout(location = 1) in vec2 _8; +layout(location = 1, component = 2) in float _16; +layout(location = 2) flat in float _22; +layout(location = 2, component = 1) flat in uint _28; +layout(location = 2, component = 2) flat in uint _33; layout(location = 0) out vec4 o0; vec4 v1; vec4 v2; void main() { - v1 = vec4(_2.x, _2.y, v1.z, v1.w); - v1.z = _3; - v2.x = _4; - v2.y = uintBitsToFloat(_5); - v2.z = uintBitsToFloat(_6); + v1 = vec4(_8.x, _8.y, v1.z, v1.w); + v1.z = _16; + v2.x = _22; + v2.y = uintBitsToFloat(_28); + v2.z = uintBitsToFloat(_33); vec4 r0; r0.x = intBitsToFloat(floatBitsToInt(v2.y) + floatBitsToInt(v2.z)); o0.y = float(floatBitsToUint(r0.x)); diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag index 3ee68e321d..6d46bc15f4 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -17,7 +17,7 @@ layout(binding = 0, std140) uniform Foo layout(row_major) mat4 lightVP[64]; uint shadowCascadesNum; int test; -} _11; +} _16; layout(location = 0) in vec3 fragWorld; layout(location = 0) out int _entryPointOutput; @@ -26,7 +26,7 @@ mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } mat4 GetClip2TexMatrix() { - if (_11.test == 0) + if (_16.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)); } @@ -36,9 +36,9 @@ mat4 GetClip2TexMatrix() int GetCascade(vec3 fragWorldPosition) { SPIRV_CROSS_UNROLL - for (uint cascadeIndex = 0u; cascadeIndex < _11.shadowCascadesNum; cascadeIndex++) + for (uint cascadeIndex = 0u; cascadeIndex < _16.shadowCascadesNum; cascadeIndex++) { - mat4 worldToShadowMap = GetClip2TexMatrix() * spvWorkaroundRowMajor(_11.lightVP[cascadeIndex]); + mat4 worldToShadowMap = GetClip2TexMatrix() * spvWorkaroundRowMajor(_16.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)) { diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/loop-header-to-continue.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/loop-header-to-continue.asm.frag index 8a3b664bc4..65676d2a0f 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/loop-header-to-continue.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/loop-header-to-continue.asm.frag @@ -13,7 +13,7 @@ struct Params layout(binding = 1, std140) uniform CB1 { Params CB1; -} _8; +} _12; uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler; @@ -22,24 +22,24 @@ layout(location = 0) out vec4 _entryPointOutput; void main() { - vec2 _45 = vec2(0.0, _8.CB1.TextureSize.w); - vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); - float _50 = _49.y; - float _53 = clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375); - float _55; - float _58; - _55 = 0.0; - _58 = 0.0; - for (int _60 = -3; _60 <= 3; ) + vec2 _180 = vec2(0.0, _12.CB1.TextureSize.w); + vec4 _206 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv); + float _207 = _206.y; + float _211 = clamp((_207 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375); + float _276; + float _277; + _276 = 0.0; + _277 = 0.0; + for (int _278 = -3; _278 <= 3; ) { - float _64 = float(_60); - vec4 _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (_45 * _64)); - float _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < _53); - _55 += (_72.x * _78); - _58 += _78; - _60++; + float _220 = float(_278); + vec4 _236 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (_180 * _220)); + float _246 = exp(((-_220) * _220) * 0.2222220003604888916015625) * float(abs(_236.y - _207) < _211); + _276 += (_236.x * _246); + _277 += _246; + _278++; continue; } - _entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0); + _entryPointOutput = vec4(_276 / _277, _207, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/lut-promotion-initializer.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/lut-promotion-initializer.asm.frag index c08bc2c781..d7bb4c5f31 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/lut-promotion-initializer.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/lut-promotion-initializer.asm.frag @@ -2,32 +2,32 @@ precision mediump float; precision highp int; -const float _46[16] = float[](1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0); -const vec4 _76[4] = vec4[](vec4(0.0), vec4(1.0), vec4(8.0), vec4(5.0)); +const float _16[16] = float[](1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0); +const vec4 _60[4] = vec4[](vec4(0.0), vec4(1.0), vec4(8.0), vec4(5.0)); layout(location = 0) out float FragColor; layout(location = 0) flat in mediump int index; void main() { - vec4 foobar[4] = _76; - vec4 baz[4] = _76; - FragColor = _46[index]; + vec4 foobar[4] = _60; + vec4 baz[4] = _60; + FragColor = _16[index]; if (index < 10) { - FragColor += _46[index ^ 1]; + FragColor += _16[index ^ 1]; } else { - FragColor += _46[index & 1]; + FragColor += _16[index & 1]; } if (index > 30) { - FragColor += _76[index & 3].y; + FragColor += _60[index & 3].y; } else { - FragColor += _76[index & 1].x; + FragColor += _60[index & 1].x; } if (index > 30) { diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/op-constant-null.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/op-constant-null.asm.frag index f293c1802a..b2fb66ecc4 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/op-constant-null.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/op-constant-null.asm.frag @@ -8,7 +8,7 @@ struct D float b; }; -const vec4 _14[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); +const vec4 _41[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); layout(location = 0) out float FragColor; diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/op-phi-swap-continue-block.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/op-phi-swap-continue-block.asm.frag index d62b63a0e0..19702f3c7b 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/op-phi-swap-continue-block.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/op-phi-swap-continue-block.asm.frag @@ -5,20 +5,20 @@ layout(binding = 0, std140) uniform UBO int uCount; int uJ; int uK; -} _5; +} _7; layout(location = 0) out float FragColor; void main() { - int _23; - int _23_copy; - int _24; - _23 = _5.uK; - _24 = _5.uJ; - for (int _26 = 0; _26 < _5.uCount; _23_copy = _23, _23 = _24, _24 = _23_copy, _26++) + int _53; + int _54; + int _54_copy; + _54 = _7.uK; + _53 = _7.uJ; + for (int _52 = 0; _52 < _7.uCount; _54_copy = _54, _54 = _53, _53 = _54_copy, _52++) { } - FragColor = float(_24 - _23) * float(_5.uJ * _5.uK); + FragColor = float(_53 - _54) * float(_7.uJ * _7.uK); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag index eddb3829b7..47e44bdd9a 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag @@ -2,7 +2,7 @@ precision mediump float; precision highp int; -const uint _15 = 3u; +const uint _18 = 3u; void main() { diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag index 786ac74de5..e3f8c67470 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/phi-loop-variable.asm.frag @@ -2,7 +2,7 @@ void main() { - for (int _22 = 35; _22 >= 0; _22--) + for (int _58 = 35; _58 >= 0; _58--) { } } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag index 1ebf8fb96b..264f561066 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/sampler-buffer-without-sampler.asm.frag @@ -14,7 +14,7 @@ vec4 _main() void main() { - vec4 _28 = _main(); - _entryPointOutput = _28; + vec4 _35 = _main(); + _entryPointOutput = _35; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag index a5faaefb30..b839921a51 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag @@ -2,12 +2,12 @@ layout(location = 0) out vec4 FragColors[2]; layout(location = 2) out vec4 FragColor; -const vec4 _3_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); -const vec4 _4_init = vec4(5.0); +const vec4 _4_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); +const vec4 _6_init = vec4(5.0); void main() { - FragColors = _3_init; - FragColor = _4_init; + FragColors = _4_init; + FragColor = _6_init; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag index 7930ca3b4a..396b98138b 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/struct-composite-extract-swizzle.asm.frag @@ -8,7 +8,7 @@ struct Foo float var2; }; -Foo _22; +Foo _33; layout(binding = 0) uniform mediump sampler2D uSampler; @@ -16,6 +16,6 @@ layout(location = 0) out vec4 FragColor; void main() { - FragColor = texture(uSampler, vec2(_22.var1, _22.var2)); + FragColor = texture(uSampler, vec2(_33.var1, _33.var2)); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag index 748f96c8b0..61b45c6dbd 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag @@ -7,26 +7,26 @@ layout(location = 0) out float FragColor; void main() { - highp float _19; + highp float _27; switch (vIndex) { case 0: case 2: { - _19 = 1.0; + _27 = 1.0; break; } default: { - _19 = 3.0; + _27 = 3.0; break; } case 8: { - _19 = 8.0; + _27 = 8.0; break; } } - FragColor = _19; + FragColor = _27; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag index 4cee76cca4..b5d188fef6 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/temporary-phi-hoisting.asm.frag @@ -8,19 +8,19 @@ struct MyStruct layout(binding = 0, std140) uniform MyStruct_CB { MyStruct g_MyStruct[4]; -} _6; +} _8; 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++) + vec3 _85; + _85 = vec3(0.0); + vec3 _77; + for (int _86 = 0; _86 < 4; _85 = _77, _86++) { - _29 = _28 + _6.g_MyStruct[_31].color.xyz; + _77 = _85 + _8.g_MyStruct[_86].color.xyz; } - _entryPointOutput = vec4(_28, 1.0); + _entryPointOutput = vec4(_85, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/undef-variable-store.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/undef-variable-store.asm.frag index a3b1290de6..990fde79ba 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/undef-variable-store.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/undef-variable-store.asm.frag @@ -1,29 +1,29 @@ #version 450 -vec4 _38; -vec4 _47; +vec4 _48; +vec4 _31; layout(location = 0) out vec4 _entryPointOutput; void main() { - vec4 _27; + vec4 _37; do { - vec2 _26 = vec2(0.0); - if (_26.x != 0.0) + vec2 _35 = vec2(0.0); + if (_35.x != 0.0) { - _27 = vec4(1.0, 0.0, 0.0, 1.0); + _37 = vec4(1.0, 0.0, 0.0, 1.0); break; } else { - _27 = vec4(1.0, 1.0, 0.0, 1.0); + _37 = vec4(1.0, 1.0, 0.0, 1.0); break; } - _27 = _38; + _37 = _48; break; } while (false); - _entryPointOutput = _27; + _entryPointOutput = _37; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/unreachable.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/unreachable.asm.frag index beb8708e16..dd71ba4014 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/unreachable.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/unreachable.asm.frag @@ -1,28 +1,28 @@ #version 450 -vec4 _21; +vec4 _44; layout(location = 0) flat in int counter; layout(location = 0) out vec4 FragColor; void main() { - vec4 _24; - _24 = _21; - vec4 _33; + vec4 _45; + _45 = _44; + vec4 _46; for (;;) { if (counter == 10) { - _33 = vec4(10.0); + _46 = vec4(10.0); break; } else { - _33 = vec4(30.0); + _46 = vec4(30.0); break; } } - FragColor = _33; + FragColor = _46; } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag index 97c9a2eb9c..e68d972f96 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -12,21 +12,21 @@ #define SPIRV_CROSS_LOOP #endif -struct _28 +struct _15 { vec4 _m0; }; -_28 _74; +_15 _10264; -layout(binding = 0, std140) uniform _6_7 +layout(binding = 0, std140) uniform _3_22044 { vec4 _m0; float _m1; vec4 _m2; -} _7; +} _22044; -layout(binding = 2, std140) uniform _10_11 +layout(binding = 2, std140) uniform _4_12348 { vec3 _m0; vec3 _m1; @@ -53,9 +53,9 @@ layout(binding = 2, std140) uniform _10_11 vec4 _m22; layout(row_major) mat4 _m23; vec4 _m24; -} _11; +} _12348; -layout(binding = 1, std140) uniform _18_19 +layout(binding = 1, std140) uniform _7_15259 { layout(row_major) mat4 _m0; layout(row_major) mat4 _m1; @@ -96,231 +96,231 @@ layout(binding = 1, std140) uniform _18_19 vec3 _m36; layout(row_major) mat4 _m37[2]; vec4 _m38[2]; -} _19; +} _15259; uniform sampler2D SPIRV_Cross_Combined; uniform sampler2D SPIRV_Cross_Combined_1; uniform sampler2D SPIRV_Cross_Combined_2; -layout(location = 0) out vec4 _5; +layout(location = 0) out vec4 _4317; void main() { - _28 _77; - _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; + _15 _13863; + _13863._m0 = vec4(0.0); + vec2 _19927 = gl_FragCoord.xy * _15259._m23.xy; + vec4 _17581 = _22044._m2 * _22044._m0.xyxy; + vec2 _13149 = clamp(_19927 + (vec3(0.0, -2.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12103 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13149, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17670 = textureLod(SPIRV_Cross_Combined_1, _13149, 0.0); + vec3 _7719; SPIRV_CROSS_BRANCH - if (_113.y > 0.0) + if (_17670.y > 0.0) { - _129 = _109 + (textureLod(SPIRV_Cross_Combined_2, _97, 0.0).xyz * clamp(_113.y * _113.z, 0.0, 1.0)); + _7719 = _12103 + (textureLod(SPIRV_Cross_Combined_2, _13149, 0.0).xyz * clamp(_17670.y * _17670.z, 0.0, 1.0)); } else { - _129 = _109; + _7719 = _12103; } - vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); - vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); - _77._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; + vec3 _22177 = vec4(0.0).xyz + (_7719 * 0.5); + vec4 _15527 = vec4(_22177.x, _22177.y, _22177.z, vec4(0.0).w); + _13863._m0 = _15527; + vec2 _13150 = clamp(_19927 + (vec3(-1.0, -1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12104 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13150, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17671 = textureLod(SPIRV_Cross_Combined_1, _13150, 0.0); + vec3 _7720; SPIRV_CROSS_BRANCH - if (_160.y > 0.0) + if (_17671.y > 0.0) { - _176 = _156 + (textureLod(SPIRV_Cross_Combined_2, _144, 0.0).xyz * clamp(_160.y * _160.z, 0.0, 1.0)); + _7720 = _12104 + (textureLod(SPIRV_Cross_Combined_2, _13150, 0.0).xyz * clamp(_17671.y * _17671.z, 0.0, 1.0)); } else { - _176 = _156; + _7720 = _12104; } - vec3 _180 = _134.xyz + (_176 * 0.5); - vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); - _77._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; + vec3 _22178 = _15527.xyz + (_7720 * 0.5); + vec4 _15528 = vec4(_22178.x, _22178.y, _22178.z, _15527.w); + _13863._m0 = _15528; + vec2 _13151 = clamp(_19927 + (vec3(0.0, -1.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12105 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13151, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17672 = textureLod(SPIRV_Cross_Combined_1, _13151, 0.0); + vec3 _7721; SPIRV_CROSS_BRANCH - if (_207.y > 0.0) + if (_17672.y > 0.0) { - _223 = _203 + (textureLod(SPIRV_Cross_Combined_2, _191, 0.0).xyz * clamp(_207.y * _207.z, 0.0, 1.0)); + _7721 = _12105 + (textureLod(SPIRV_Cross_Combined_2, _13151, 0.0).xyz * clamp(_17672.y * _17672.z, 0.0, 1.0)); } else { - _223 = _203; + _7721 = _12105; } - vec3 _227 = _181.xyz + (_223 * 0.75); - vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); - _77._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; + vec3 _22179 = _15528.xyz + (_7721 * 0.75); + vec4 _15529 = vec4(_22179.x, _22179.y, _22179.z, _15528.w); + _13863._m0 = _15529; + vec2 _13152 = clamp(_19927 + (vec3(1.0, -1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12106 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13152, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17673 = textureLod(SPIRV_Cross_Combined_1, _13152, 0.0); + vec3 _7722; SPIRV_CROSS_BRANCH - if (_254.y > 0.0) + if (_17673.y > 0.0) { - _270 = _250 + (textureLod(SPIRV_Cross_Combined_2, _238, 0.0).xyz * clamp(_254.y * _254.z, 0.0, 1.0)); + _7722 = _12106 + (textureLod(SPIRV_Cross_Combined_2, _13152, 0.0).xyz * clamp(_17673.y * _17673.z, 0.0, 1.0)); } else { - _270 = _250; + _7722 = _12106; } - vec3 _274 = _228.xyz + (_270 * 0.5); - vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); - _77._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; + vec3 _22180 = _15529.xyz + (_7722 * 0.5); + vec4 _15530 = vec4(_22180.x, _22180.y, _22180.z, _15529.w); + _13863._m0 = _15530; + vec2 _13153 = clamp(_19927 + (vec3(-2.0, 0.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12107 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13153, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17674 = textureLod(SPIRV_Cross_Combined_1, _13153, 0.0); + vec3 _7723; SPIRV_CROSS_BRANCH - if (_301.y > 0.0) + if (_17674.y > 0.0) { - _317 = _297 + (textureLod(SPIRV_Cross_Combined_2, _285, 0.0).xyz * clamp(_301.y * _301.z, 0.0, 1.0)); + _7723 = _12107 + (textureLod(SPIRV_Cross_Combined_2, _13153, 0.0).xyz * clamp(_17674.y * _17674.z, 0.0, 1.0)); } else { - _317 = _297; + _7723 = _12107; } - vec3 _321 = _275.xyz + (_317 * 0.5); - vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); - _77._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; + vec3 _22181 = _15530.xyz + (_7723 * 0.5); + vec4 _15531 = vec4(_22181.x, _22181.y, _22181.z, _15530.w); + _13863._m0 = _15531; + vec2 _13154 = clamp(_19927 + (vec3(-1.0, 0.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12108 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13154, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17675 = textureLod(SPIRV_Cross_Combined_1, _13154, 0.0); + vec3 _7724; SPIRV_CROSS_BRANCH - if (_348.y > 0.0) + if (_17675.y > 0.0) { - _364 = _344 + (textureLod(SPIRV_Cross_Combined_2, _332, 0.0).xyz * clamp(_348.y * _348.z, 0.0, 1.0)); + _7724 = _12108 + (textureLod(SPIRV_Cross_Combined_2, _13154, 0.0).xyz * clamp(_17675.y * _17675.z, 0.0, 1.0)); } else { - _364 = _344; + _7724 = _12108; } - vec3 _368 = _322.xyz + (_364 * 0.75); - vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); - _77._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; + vec3 _22182 = _15531.xyz + (_7724 * 0.75); + vec4 _15532 = vec4(_22182.x, _22182.y, _22182.z, _15531.w); + _13863._m0 = _15532; + vec2 _13155 = clamp(_19927 + (vec3(0.0, 0.0, 1.0).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12109 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13155, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17676 = textureLod(SPIRV_Cross_Combined_1, _13155, 0.0); + vec3 _7725; SPIRV_CROSS_BRANCH - if (_395.y > 0.0) + if (_17676.y > 0.0) { - _411 = _391 + (textureLod(SPIRV_Cross_Combined_2, _379, 0.0).xyz * clamp(_395.y * _395.z, 0.0, 1.0)); + _7725 = _12109 + (textureLod(SPIRV_Cross_Combined_2, _13155, 0.0).xyz * clamp(_17676.y * _17676.z, 0.0, 1.0)); } else { - _411 = _391; + _7725 = _12109; } - vec3 _415 = _369.xyz + (_411 * 1.0); - vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); - _77._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; + vec3 _22183 = _15532.xyz + (_7725 * 1.0); + vec4 _15533 = vec4(_22183.x, _22183.y, _22183.z, _15532.w); + _13863._m0 = _15533; + vec2 _13156 = clamp(_19927 + (vec3(1.0, 0.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12110 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13156, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17677 = textureLod(SPIRV_Cross_Combined_1, _13156, 0.0); + vec3 _7726; SPIRV_CROSS_BRANCH - if (_442.y > 0.0) + if (_17677.y > 0.0) { - _458 = _438 + (textureLod(SPIRV_Cross_Combined_2, _426, 0.0).xyz * clamp(_442.y * _442.z, 0.0, 1.0)); + _7726 = _12110 + (textureLod(SPIRV_Cross_Combined_2, _13156, 0.0).xyz * clamp(_17677.y * _17677.z, 0.0, 1.0)); } else { - _458 = _438; + _7726 = _12110; } - vec3 _462 = _416.xyz + (_458 * 0.75); - vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); - _77._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; + vec3 _22184 = _15533.xyz + (_7726 * 0.75); + vec4 _15534 = vec4(_22184.x, _22184.y, _22184.z, _15533.w); + _13863._m0 = _15534; + vec2 _13157 = clamp(_19927 + (vec3(2.0, 0.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12111 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13157, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17678 = textureLod(SPIRV_Cross_Combined_1, _13157, 0.0); + vec3 _7727; SPIRV_CROSS_BRANCH - if (_489.y > 0.0) + if (_17678.y > 0.0) { - _505 = _485 + (textureLod(SPIRV_Cross_Combined_2, _473, 0.0).xyz * clamp(_489.y * _489.z, 0.0, 1.0)); + _7727 = _12111 + (textureLod(SPIRV_Cross_Combined_2, _13157, 0.0).xyz * clamp(_17678.y * _17678.z, 0.0, 1.0)); } else { - _505 = _485; + _7727 = _12111; } - vec3 _509 = _463.xyz + (_505 * 0.5); - vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); - _77._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; + vec3 _22185 = _15534.xyz + (_7727 * 0.5); + vec4 _15535 = vec4(_22185.x, _22185.y, _22185.z, _15534.w); + _13863._m0 = _15535; + vec2 _13158 = clamp(_19927 + (vec3(-1.0, 1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12112 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13158, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17679 = textureLod(SPIRV_Cross_Combined_1, _13158, 0.0); + vec3 _7728; SPIRV_CROSS_BRANCH - if (_536.y > 0.0) + if (_17679.y > 0.0) { - _552 = _532 + (textureLod(SPIRV_Cross_Combined_2, _520, 0.0).xyz * clamp(_536.y * _536.z, 0.0, 1.0)); + _7728 = _12112 + (textureLod(SPIRV_Cross_Combined_2, _13158, 0.0).xyz * clamp(_17679.y * _17679.z, 0.0, 1.0)); } else { - _552 = _532; + _7728 = _12112; } - vec3 _556 = _510.xyz + (_552 * 0.5); - vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); - _77._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; + vec3 _22186 = _15535.xyz + (_7728 * 0.5); + vec4 _15536 = vec4(_22186.x, _22186.y, _22186.z, _15535.w); + _13863._m0 = _15536; + vec2 _13159 = clamp(_19927 + (vec3(0.0, 1.0, 0.75).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12113 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13159, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17680 = textureLod(SPIRV_Cross_Combined_1, _13159, 0.0); + vec3 _7729; SPIRV_CROSS_BRANCH - if (_583.y > 0.0) + if (_17680.y > 0.0) { - _599 = _579 + (textureLod(SPIRV_Cross_Combined_2, _567, 0.0).xyz * clamp(_583.y * _583.z, 0.0, 1.0)); + _7729 = _12113 + (textureLod(SPIRV_Cross_Combined_2, _13159, 0.0).xyz * clamp(_17680.y * _17680.z, 0.0, 1.0)); } else { - _599 = _579; + _7729 = _12113; } - vec3 _603 = _557.xyz + (_599 * 0.75); - vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); - _77._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; + vec3 _22187 = _15536.xyz + (_7729 * 0.75); + vec4 _15537 = vec4(_22187.x, _22187.y, _22187.z, _15536.w); + _13863._m0 = _15537; + vec2 _13160 = clamp(_19927 + (vec3(1.0, 1.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12114 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13160, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17681 = textureLod(SPIRV_Cross_Combined_1, _13160, 0.0); + vec3 _7730; SPIRV_CROSS_BRANCH - if (_630.y > 0.0) + if (_17681.y > 0.0) { - _646 = _626 + (textureLod(SPIRV_Cross_Combined_2, _614, 0.0).xyz * clamp(_630.y * _630.z, 0.0, 1.0)); + _7730 = _12114 + (textureLod(SPIRV_Cross_Combined_2, _13160, 0.0).xyz * clamp(_17681.y * _17681.z, 0.0, 1.0)); } else { - _646 = _626; + _7730 = _12114; } - vec3 _650 = _604.xyz + (_646 * 0.5); - vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); - _77._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; + vec3 _22188 = _15537.xyz + (_7730 * 0.5); + vec4 _15539 = vec4(_22188.x, _22188.y, _22188.z, _15537.w); + _13863._m0 = _15539; + vec2 _13161 = clamp(_19927 + (vec3(0.0, 2.0, 0.5).xy * _22044._m0.xy), _17581.xy, _17581.zw); + vec3 _12115 = _12348._m5 * clamp(textureLod(SPIRV_Cross_Combined, _13161, 0.0).w * _22044._m1, 0.0, 1.0); + vec4 _17682 = textureLod(SPIRV_Cross_Combined_1, _13161, 0.0); + vec3 _7731; SPIRV_CROSS_BRANCH - if (_677.y > 0.0) + if (_17682.y > 0.0) { - _693 = _673 + (textureLod(SPIRV_Cross_Combined_2, _661, 0.0).xyz * clamp(_677.y * _677.z, 0.0, 1.0)); + _7731 = _12115 + (textureLod(SPIRV_Cross_Combined_2, _13161, 0.0).xyz * clamp(_17682.y * _17682.z, 0.0, 1.0)); } else { - _693 = _673; + _7731 = _12115; } - vec3 _697 = _651.xyz + (_693 * 0.5); - vec4 _698 = vec4(_697.x, _697.y, _697.z, _651.w); - _77._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); - _77._m0 = vec4(_702.x, _702.y, _702.z, _698.w); - _77._m0.w = 1.0; - _5 = _77._m0; + vec3 _22189 = _15539.xyz + (_7731 * 0.5); + vec4 _15541 = vec4(_22189.x, _22189.y, _22189.z, _15539.w); + _13863._m0 = _15541; + vec3 _13750 = _15541.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); + _13863._m0 = vec4(_13750.x, _13750.y, _13750.z, _15541.w); + _13863._m0.w = 1.0; + _4317 = _13863._m0; } diff --git a/third_party/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom b/third_party/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom index 39bc097d89..99d4d2fde6 100644 --- a/third_party/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom +++ b/third_party/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom @@ -21,12 +21,12 @@ void _main(vec4 positions[3], SceneOut OUT) void main() { - vec4 _35_unrolled[3]; + vec4 _48_unrolled[3]; for (int i = 0; i < int(3); i++) { - _35_unrolled[i] = gl_in[i].gl_Position; + _48_unrolled[i] = gl_in[i].gl_Position; } - vec4 positions[3] = _35_unrolled; + vec4 positions[3] = _48_unrolled; vec4 param[3] = positions; SceneOut param_1; _main(param, param_1); diff --git a/third_party/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese b/third_party/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese index 34970b82eb..e2d3b2e63b 100644 --- a/third_party/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese +++ b/third_party/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese @@ -34,12 +34,12 @@ void main() _input.foo = input_foo; _input.bar = input_bar; vec2 uv = vec2(gl_TessCoord.xy); - ControlPoint _54_unrolled[4]; + ControlPoint _68_unrolled[4]; for (int i = 0; i < int(4); i++) { - _54_unrolled[i] = CPData[i]; + _68_unrolled[i] = CPData[i]; } - ControlPoint CPData_1[4] = _54_unrolled; + ControlPoint CPData_1[4] = _68_unrolled; HS_INPUT param = _input; vec2 param_1 = uv; ControlPoint param_2[4] = CPData_1; diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/invariant-block.sso.asm.vert b/third_party/spirv-cross/reference/shaders/asm/vert/invariant-block.sso.asm.vert index eb88694196..a89e336283 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/invariant-block.sso.asm.vert +++ b/third_party/spirv-cross/reference/shaders/asm/vert/invariant-block.sso.asm.vert @@ -2,14 +2,12 @@ out gl_PerVertex { - vec4 gl_Position; + invariant vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[1]; float gl_CullDistance[1]; }; -invariant gl_Position; - void main() { gl_Position = vec4(1.0); diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/invariant.asm.vert b/third_party/spirv-cross/reference/shaders/asm/vert/invariant.asm.vert index c4c6ad6ba2..9bcfe0b3d7 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/invariant.asm.vert +++ b/third_party/spirv-cross/reference/shaders/asm/vert/invariant.asm.vert @@ -9,7 +9,7 @@ vec4 _main() void main() { - vec4 _14 = _main(); - gl_Position = _14; + vec4 _17 = _main(); + gl_Position = _17; } diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/invariant.sso.asm.vert b/third_party/spirv-cross/reference/shaders/asm/vert/invariant.sso.asm.vert index c486be1840..3cb264a30c 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/invariant.sso.asm.vert +++ b/third_party/spirv-cross/reference/shaders/asm/vert/invariant.sso.asm.vert @@ -2,11 +2,9 @@ out gl_PerVertex { - vec4 gl_Position; + invariant vec4 gl_Position; }; -invariant gl_Position; - vec4 _main() { return vec4(1.0); @@ -14,7 +12,7 @@ vec4 _main() void main() { - vec4 _14 = _main(); - gl_Position = _14; + vec4 _17 = _main(); + gl_Position = _17; } diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert b/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert index daf0071ae7..bc405c3a97 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert +++ b/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert @@ -3,33 +3,33 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_201 #define SPIRV_CROSS_CONSTANT_ID_201 -10 #endif -const int _7 = SPIRV_CROSS_CONSTANT_ID_201; -const int _20 = (_7 + 2); +const int _13 = SPIRV_CROSS_CONSTANT_ID_201; +const int _15 = (_13 + 2); #ifndef SPIRV_CROSS_CONSTANT_ID_202 #define SPIRV_CROSS_CONSTANT_ID_202 100u #endif -const uint _8 = SPIRV_CROSS_CONSTANT_ID_202; -const uint _25 = (_8 % 5u); -const int _30 = _7 - (-3) * (_7 / (-3)); -const ivec4 _32 = ivec4(20, 30, _20, _30); -const ivec2 _34 = ivec2(_32.y, _32.x); -const int _35 = _32.y; +const uint _24 = SPIRV_CROSS_CONSTANT_ID_202; +const uint _26 = (_24 % 5u); +const int _61 = _13 - (-3) * (_13 / (-3)); +const ivec4 _36 = ivec4(20, 30, _15, _61); +const ivec2 _41 = ivec2(_36.y, _36.x); +const int _62 = _36.y; #ifndef SPIRV_CROSS_CONSTANT_ID_200 #define SPIRV_CROSS_CONSTANT_ID_200 3.141590118408203125 #endif -const float _9 = SPIRV_CROSS_CONSTANT_ID_200; +const float _57 = SPIRV_CROSS_CONSTANT_ID_200; -layout(location = 0) flat out int _4; +layout(location = 0) flat out int _58; void main() { vec4 pos = vec4(0.0); - pos.y += float(_20); - pos.z += float(_25); - pos += vec4(_32); - vec2 _58 = pos.xy + vec2(_34); - pos = vec4(_58.x, _58.y, pos.z, pos.w); + pos.y += float(_15); + pos.z += float(_26); + pos += vec4(_36); + vec2 _46 = pos.xy + vec2(_41); + pos = vec4(_46.x, _46.y, pos.z, pos.w); gl_Position = pos; - _4 = _35; + _58 = _62; } diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk b/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk index 4cddf82138..79fac9f88c 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk +++ b/third_party/spirv-cross/reference/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk @@ -1,30 +1,30 @@ #version 450 -layout(constant_id = 201) const int _7 = -10; -const int _20 = (_7 + 2); -layout(constant_id = 202) const uint _8 = 100u; -const uint _25 = (_8 % 5u); -const int _30 = _7 - (-3) * (_7 / (-3)); -const ivec4 _32 = ivec4(20, 30, _20, _30); -const ivec2 _34 = ivec2(_32.y, _32.x); -const int _35 = _32.y; -layout(constant_id = 200) const float _9 = 3.141590118408203125; +layout(constant_id = 201) const int _13 = -10; +const int _15 = (_13 + 2); +layout(constant_id = 202) const uint _24 = 100u; +const uint _26 = (_24 % 5u); +const int _61 = _13 - (-3) * (_13 / (-3)); +const ivec4 _36 = ivec4(20, 30, _15, _61); +const ivec2 _41 = ivec2(_36.y, _36.x); +const int _62 = _36.y; +layout(constant_id = 200) const float _57 = 3.141590118408203125; -layout(location = 0) flat out int _4; +layout(location = 0) flat out int _58; void main() { vec4 pos = vec4(0.0); - float _42 = float(_20); - pos.y += _42; - float _47 = float(_25); - pos.z += _47; - vec4 _52 = vec4(_32); - pos += _52; - vec2 _55 = vec2(_34); - vec2 _58 = pos.xy + _55; - pos = vec4(_58.x, _58.y, pos.z, pos.w); + float _16 = float(_15); + pos.y += _16; + float _27 = float(_26); + pos.z += _27; + vec4 _37 = vec4(_36); + pos += _37; + vec2 _43 = vec2(_41); + vec2 _46 = pos.xy + _43; + pos = vec4(_46.x, _46.y, pos.z, pos.w); gl_Position = pos; - _4 = _35; + _58 = _62; } diff --git a/third_party/spirv-cross/reference/shaders/frag/block-match-sad.frag b/third_party/spirv-cross/reference/shaders/frag/block-match-sad.frag new file mode 100644 index 0000000000..9a344d400f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/block-match-sad.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSADQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, blockSize); + fragColor = _59; + vec4 _68 = textureBlockMatchSADQCOM(target_samp, tgt_coords, ref_samp, ref_coords, blockSize); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/shaders/frag/block-match-ssd.frag b/third_party/spirv-cross/reference/shaders/frag/block-match-ssd.frag new file mode 100644 index 0000000000..861610cc2b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/block-match-ssd.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSSDQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, blockSize); + fragColor = _59; + vec4 _68 = textureBlockMatchSSDQCOM(target_samp, tgt_coords, ref_samp, ref_coords, blockSize); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/shaders/frag/box-filter.frag b/third_party/spirv-cross/reference/shaders/frag/box-filter.frag new file mode 100644 index 0000000000..58b6cd5554 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/box-filter.frag @@ -0,0 +1,18 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec2 boxSize = vec2(2.5, 4.5); + vec4 _31 = textureBoxFilterQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, boxSize); + fragColor = _31; + vec4 _38 = textureBoxFilterQCOM(tex_samp, v_texcoord.xy, boxSize); + fragColor = _38; +} + diff --git a/third_party/spirv-cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag b/third_party/spirv-cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag index 414dd956af..0406ede143 100644 --- a/third_party/spirv-cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag +++ b/third_party/spirv-cross/reference/shaders/frag/image-load-store-uint-coord.asm.frag @@ -20,7 +20,7 @@ vec4 _main() void main() { - vec4 _45 = _main(); - _entryPointOutput = _45; + vec4 _62 = _main(); + _entryPointOutput = _62; } diff --git a/third_party/spirv-cross/reference/shaders/frag/sample-weighted.frag b/third_party/spirv-cross/reference/shaders/frag/sample-weighted.frag new file mode 100644 index 0000000000..7d1c35e241 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/sample-weighted.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +layout(binding = 5) uniform sampler2DArray tex_samp_array; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2DArray SPIRV_Cross_Combinedtex2DArray_weightssamp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec4 _32 = textureWeightedQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, SPIRV_Cross_Combinedtex2DArray_weightssamp); + fragColor = _32; + vec4 _41 = textureWeightedQCOM(tex_samp, v_texcoord.xy, tex_samp_array); + fragColor = _41; +} + diff --git a/third_party/spirv-cross/reference/shaders/tese/read-patch-vertices-in-func.tese b/third_party/spirv-cross/reference/shaders/tese/read-patch-vertices-in-func.tese new file mode 100644 index 0000000000..2627fcef0b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/tese/read-patch-vertices-in-func.tese @@ -0,0 +1,13 @@ +#version 450 +layout(quads, ccw, equal_spacing) in; + +vec4 read_patch_vertices() +{ + return vec4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0); +} + +void main() +{ + gl_Position = read_patch_vertices(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk index 771d049644..a76f8ccb80 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/array-of-buffer-reference.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Block; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk index f5907d3e2c..c9b2bbcfad 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-atomic.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Bar; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk index 9cd3d3e5bb..c63618fc13 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-base-alignment-promote.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Bar; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk index 20a4f1b423..835eae4104 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2-2.nocompat.invalid.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_buffer_reference_uvec2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk index 5cf6e2df36..b99ace3f17 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast-uvec2.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require #extension GL_EXT_buffer_reference_uvec2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk index 8923d21d78..4b59857a3e 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-bitcast.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer PtrUint; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk index b7e88062a0..92a8bcb1b1 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk @@ -1,5 +1,5 @@ #version 450 -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer RO; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk index 241483ede4..48071fcc22 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp.vk @@ -4,7 +4,7 @@ #else #error No extension available for 64-bit integers. #endif -#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference2 : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(buffer_reference) buffer Node; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-sad.frag b/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-sad.frag new file mode 100644 index 0000000000..9a344d400f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-sad.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSADQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, blockSize); + fragColor = _59; + vec4 _68 = textureBlockMatchSADQCOM(target_samp, tgt_coords, ref_samp, ref_coords, blockSize); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-ssd.frag b/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-ssd.frag new file mode 100644 index 0000000000..861610cc2b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/block-match-ssd.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D target_samp; +layout(binding = 5) uniform sampler2D ref_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src2samp; + +layout(location = 0) in vec4 v_texcoord; +layout(location = 0) out vec4 fragColor; + +void main() +{ + uvec2 tgt_coords; + tgt_coords.x = uint(v_texcoord.x); + tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; + ref_coords.x = uint(v_texcoord.z); + ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4u); + vec4 _59 = textureBlockMatchSSDQCOM(SPIRV_Cross_Combinedtex2D_src1samp, tgt_coords, SPIRV_Cross_Combinedtex2D_src2samp, ref_coords, blockSize); + fragColor = _59; + vec4 _68 = textureBlockMatchSSDQCOM(target_samp, tgt_coords, ref_samp, ref_coords, blockSize); + fragColor = _68; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/box-filter.frag b/third_party/spirv-cross/reference/shaders/vulkan/frag/box-filter.frag new file mode 100644 index 0000000000..58b6cd5554 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/box-filter.frag @@ -0,0 +1,18 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec2 boxSize = vec2(2.5, 4.5); + vec4 _31 = textureBoxFilterQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, boxSize); + fragColor = _31; + vec4 _38 = textureBoxFilterQCOM(tex_samp, v_texcoord.xy, boxSize); + fragColor = _38; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk index 153164920f..92209f2a5c 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/demote-to-helper-forwarding.asm.vk.nocompat.frag.vk @@ -5,9 +5,9 @@ layout(location = 0) out vec4 FragColor; void main() { - bool _15 = helperInvocationEXT(); + bool _9 = helperInvocationEXT(); demote; - if (!_15) + if (!_9) { FragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/sample-weighted.frag b/third_party/spirv-cross/reference/shaders/vulkan/frag/sample-weighted.frag new file mode 100644 index 0000000000..7d1c35e241 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/sample-weighted.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +layout(binding = 4) uniform sampler2D tex_samp; +layout(binding = 5) uniform sampler2DArray tex_samp_array; +uniform sampler2D SPIRV_Cross_Combinedtex2D_src1samp; +uniform sampler2DArray SPIRV_Cross_Combinedtex2DArray_weightssamp; + +layout(location = 0) out vec4 fragColor; +layout(location = 0) in vec4 v_texcoord; + +void main() +{ + vec4 _32 = textureWeightedQCOM(SPIRV_Cross_Combinedtex2D_src1samp, v_texcoord.xy, SPIRV_Cross_Combinedtex2DArray_weightssamp); + fragColor = _32; + vec4 _41 = textureWeightedQCOM(tex_samp, v_texcoord.xy, tex_samp_array); + fragColor = _41; +} + diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.comp rename to third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/local-size-id.asm.invalid.comp diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..700987b709 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %uint %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..7d29180259 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %int %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 + %int_0 = OpConstant %int 0 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Input_int = OpTypePointer Input %int +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output +%_ptr_Output_int = OpTypePointer Output %int + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh new file mode 100644 index 0000000000..7b38001d8d --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/mesh/mesh-shader-dxil-spirv.flip-vert-y.asm.spv14.nofxc.nocompat.vk.mesh @@ -0,0 +1,150 @@ +; SPIR-V +; Version: 1.4 +; Generator: Unknown(30017); 21022 +; Bound: 89 +; Schema: 0 + OpCapability Shader + OpCapability Geometry + OpCapability ShaderViewportIndexLayerEXT + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpExtension "SPV_EXT_shader_viewport_index_layer" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %SV_Position %B %SV_CullPrimitive %SV_RenderTargetArrayIndex %SV_PrimitiveID %C %indices %32 %gl_LocalInvocationIndex %38 + OpExecutionMode %main OutputVertices 24 + OpExecutionMode %main OutputPrimitivesNV 8 + OpExecutionMode %main OutputTrianglesNV + OpExecutionMode %main LocalSize 2 3 4 + OpName %main "main" + OpName %SV_Position "SV_Position" + OpName %B "B" + OpName %SV_CullPrimitive "SV_CullPrimitive" + OpName %SV_RenderTargetArrayIndex "SV_RenderTargetArrayIndex" + OpName %SV_PrimitiveID "SV_PrimitiveID" + OpName %C "C" + OpName %indices "indices" + OpName %_ "" + OpDecorate %SV_Position BuiltIn Position + OpDecorate %B Location 1 + OpDecorate %SV_CullPrimitive BuiltIn CullPrimitiveEXT + OpDecorate %SV_CullPrimitive PerPrimitiveNV + OpDecorate %SV_RenderTargetArrayIndex BuiltIn Layer + OpDecorate %SV_RenderTargetArrayIndex PerPrimitiveNV + OpDecorate %SV_PrimitiveID BuiltIn PrimitiveId + OpDecorate %SV_PrimitiveID PerPrimitiveNV + OpDecorate %C Location 3 + OpDecorate %C PerPrimitiveNV + OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + %void = OpTypeVoid + %2 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_24 = OpConstant %uint 24 +%_arr_v4float_uint_24 = OpTypeArray %v4float %uint_24 +%_ptr_Output__arr_v4float_uint_24 = OpTypePointer Output %_arr_v4float_uint_24 +%SV_Position = OpVariable %_ptr_Output__arr_v4float_uint_24 Output + %B = OpVariable %_ptr_Output__arr_v4float_uint_24 Output + %bool = OpTypeBool + %uint_8 = OpConstant %uint 8 +%_arr_bool_uint_8 = OpTypeArray %bool %uint_8 +%_ptr_Output__arr_bool_uint_8 = OpTypePointer Output %_arr_bool_uint_8 +%SV_CullPrimitive = OpVariable %_ptr_Output__arr_bool_uint_8 Output +%_arr_uint_uint_8 = OpTypeArray %uint %uint_8 +%_ptr_Output__arr_uint_uint_8 = OpTypePointer Output %_arr_uint_uint_8 +%SV_RenderTargetArrayIndex = OpVariable %_ptr_Output__arr_uint_uint_8 Output +%SV_PrimitiveID = OpVariable %_ptr_Output__arr_uint_uint_8 Output +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Output__arr_v4float_uint_8 = OpTypePointer Output %_arr_v4float_uint_8 + %C = OpVariable %_ptr_Output__arr_v4float_uint_8 Output + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_8 = OpTypeArray %v3uint %uint_8 +%_ptr_Output__arr_v3uint_uint_8 = OpTypePointer Output %_arr_v3uint_uint_8 + %indices = OpVariable %_ptr_Output__arr_v3uint_uint_8 Output + %uint_64 = OpConstant %uint 64 +%_arr_float_uint_64 = OpTypeArray %float %uint_64 +%_ptr_Workgroup__arr_float_uint_64 = OpTypePointer Workgroup %_arr_float_uint_64 + %32 = OpVariable %_ptr_Workgroup__arr_float_uint_64 Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %_ = OpTypeStruct %float +%_ptr_TaskPayloadWorkgroupEXT__ = OpTypePointer TaskPayloadWorkgroupEXT %_ + %38 = OpVariable %_ptr_TaskPayloadWorkgroupEXT__ TaskPayloadWorkgroupEXT +%_ptr_Workgroup_float = OpTypePointer Workgroup %float + %uint_2 = OpConstant %uint 2 + %uint_264 = OpConstant %uint 264 +%_ptr_Output_float = OpTypePointer Output %float + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 +%_ptr_TaskPayloadWorkgroupEXT_float = OpTypePointer TaskPayloadWorkgroupEXT %float +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_bool = OpTypePointer Output %bool +%_ptr_Output_uint = OpTypePointer Output %uint + %main = OpFunction %void None %2 + %4 = OpLabel + OpBranch %85 + %85 = OpLabel + %35 = OpLoad %uint %gl_LocalInvocationIndex + %39 = OpConvertUToF %float %35 + %41 = OpAccessChain %_ptr_Workgroup_float %32 %35 + OpStore %41 %39 + OpControlBarrier %uint_2 %uint_2 %uint_264 + OpSetMeshOutputsEXT %uint_24 %uint_8 + %44 = OpLoad %float %41 + %46 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_0 + OpStore %46 %44 + %48 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_1 + OpStore %48 %44 + %50 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_2 + OpStore %50 %44 + %51 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_3 + OpStore %51 %44 + %53 = OpBitwiseXor %uint %35 %uint_1 + %54 = OpAccessChain %_ptr_Workgroup_float %32 %53 + %55 = OpLoad %float %54 + %57 = OpInBoundsAccessChain %_ptr_TaskPayloadWorkgroupEXT_float %38 %uint_0 + %58 = OpLoad %float %57 + %59 = OpFAdd %float %58 %55 + %60 = OpAccessChain %_ptr_Output_float %B %35 %uint_0 + OpStore %60 %59 + %61 = OpAccessChain %_ptr_Output_float %B %35 %uint_1 + OpStore %61 %59 + %62 = OpAccessChain %_ptr_Output_float %B %35 %uint_2 + OpStore %62 %59 + %63 = OpAccessChain %_ptr_Output_float %B %35 %uint_3 + OpStore %63 %59 + %64 = OpULessThan %bool %35 %uint_8 + OpSelectionMerge %87 None + OpBranchConditional %64 %86 %87 + %86 = OpLabel + %65 = OpIMul %uint %35 %uint_3 + %66 = OpIAdd %uint %65 %uint_1 + %67 = OpIAdd %uint %65 %uint_2 + %68 = OpCompositeConstruct %v3uint %65 %66 %67 + %70 = OpAccessChain %_ptr_Output_v3uint %indices %35 + OpStore %70 %68 + %71 = OpBitwiseAnd %uint %35 %uint_1 + %72 = OpINotEqual %bool %71 %uint_0 + %74 = OpAccessChain %_ptr_Output_bool %SV_CullPrimitive %35 + OpStore %74 %72 + %76 = OpAccessChain %_ptr_Output_uint %SV_PrimitiveID %35 + OpStore %76 %35 + %77 = OpAccessChain %_ptr_Output_uint %SV_RenderTargetArrayIndex %35 + OpStore %77 %35 + %78 = OpBitwiseXor %uint %35 %uint_2 + %79 = OpAccessChain %_ptr_Workgroup_float %32 %78 + %80 = OpLoad %float %79 + %81 = OpAccessChain %_ptr_Output_float %C %35 %uint_0 + OpStore %81 %80 + %82 = OpAccessChain %_ptr_Output_float %C %35 %uint_1 + OpStore %82 %80 + %83 = OpAccessChain %_ptr_Output_float %C %35 %uint_2 + OpStore %83 %80 + %84 = OpAccessChain %_ptr_Output_float %C %35 %uint_3 + OpStore %84 %80 + OpBranch %87 + %87 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp new file mode 100644 index 0000000000..ffd871f04d --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle-top-level.comp @@ -0,0 +1,12 @@ +#version 450 + +layout(set = 0, binding = 0, std140) uniform UboData +{ + vec3 data0; + // uint padding0; // 4 bytes of padding here + ivec2 data1; +}; + +void main() +{ +} diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp new file mode 100644 index 0000000000..da69948a97 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/substruct-cbuffer-packing-straddle.comp @@ -0,0 +1,17 @@ +#version 450 + +struct Data +{ + vec3 data0; + // uint padding0; // 4 bytes of padding here + ivec2 data1; +}; + +layout(set = 0, binding = 0, std140) uniform UboData +{ + Data scene; +}; + +void main() +{ +} diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh new file mode 100644 index 0000000000..06b43ecb26 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.nofxc.flip-vert-y.mesh @@ -0,0 +1,54 @@ +#version 450 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; +layout(triangles, max_vertices = 24, max_primitives = 22) out; + +out gl_MeshPerVertexEXT +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[1]; + float gl_CullDistance[2]; +} gl_MeshVerticesEXT[]; + +layout(location = 0) out vec4 vOut[]; + +layout(location = 2) out BlockOut +{ + vec4 a; + vec4 b; +} outputs[]; + +shared float shared_float[16]; + +struct TaskPayload +{ + float a; + float b; + int c; +}; + +layout(constant_id = 0) const int spec_const_index = 1; + +taskPayloadSharedEXT TaskPayload payload; + +void main() +{ + SetMeshOutputsEXT(24, 22); + + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(gl_GlobalInvocationID, 1.0); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.y = float(gl_WorkGroupID); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.xzw = vec3(gl_GlobalInvocationID); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position[gl_LocalInvocationIndex % 4] = float(gl_GlobalInvocationID.z); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position[spec_const_index] = float(gl_GlobalInvocationID.z); + + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0] = 4.0; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[0] = 3.0; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[1] = 5.0; + + barrier(); + if (gl_LocalInvocationIndex < 22) + { + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0, 1, 2) + gl_LocalInvocationIndex; + } +} diff --git a/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp new file mode 100644 index 0000000000..dc2a508d8a --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp @@ -0,0 +1,19 @@ +#version 460 + +struct Data +{ + uint arr[3]; +}; + +layout(set = 0, binding = 0, std430) buffer B0 +{ + Data d[]; +}; + +void main() +{ + Data d1; + d[0].arr = d1.arr; +} + + diff --git a/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh b/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh index 4f9500fe17..79b3178488 100644 --- a/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh @@ -1,5 +1,6 @@ #version 450 #extension GL_EXT_mesh_shader : require +#extension GL_EXT_fragment_shading_rate : require layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; layout(lines, max_vertices = 24, max_primitives = 22) out; diff --git a/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh b/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh index 4d8e3f6494..11b1afbff5 100644 --- a/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh @@ -1,5 +1,6 @@ #version 450 #extension GL_EXT_mesh_shader : require +#extension GL_EXT_fragment_shading_rate : require layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; layout(triangles, max_vertices = 24, max_primitives = 22) out; diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp new file mode 100644 index 0000000000..b9876122ae --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/groupshared-inner-array-of-struct-copy.asm.comp @@ -0,0 +1,137 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google spiregg; 0 +; Bound: 91 +; Schema: 0 + OpCapability Shader + OpCapability StorageImageReadWithoutFormat + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpExtension "SPV_GOOGLE_user_type" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %csMain "main" %gl_GlobalInvocationID + OpExecutionMode %csMain LocalSize 8 8 1 + OpSource HLSL 500 + OpName %Data "Data" + OpMemberName %Data 0 "sourceData" + OpName %g_data "g_data" + OpName %type_2d_image "type.2d.image" + OpName %g_inputTexture "g_inputTexture" + OpName %type_2d_image_0 "type.2d.image" + OpName %g_output "g_output" + OpName %csMain "csMain" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorateString %gl_GlobalInvocationID UserSemantic "SV_DispatchThreadID" + OpDecorate %g_inputTexture DescriptorSet 0 + OpDecorate %g_inputTexture Binding 0 + OpDecorate %g_output DescriptorSet 0 + OpDecorate %g_output Binding 0 + OpDecorateString %g_inputTexture UserTypeGOOGLE "texture2d:" + OpDecorateString %g_output UserTypeGOOGLE "rwtexture2d:" + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_4 = OpConstant %uint 4 + %uint_1 = OpConstant %uint 1 + %int_16 = OpConstant %int 16 + %float = OpTypeFloat 32 + %float_n1 = OpConstant %float -1 + %v3float = OpTypeVector %float 3 + %20 = OpConstantComposite %v3float %float_n1 %float_n1 %float_n1 + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %int_1 = OpConstant %int 1 + %uint_64 = OpConstant %uint 64 + %uint_16 = OpConstant %uint 16 +%_arr_v3float_uint_16 = OpTypeArray %v3float %uint_16 + %Data = OpTypeStruct %_arr_v3float_uint_16 +%_arr_Data_uint_64 = OpTypeArray %Data %uint_64 +%_ptr_Workgroup__arr_Data_uint_64 = OpTypePointer Workgroup %_arr_Data_uint_64 +%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image +%type_2d_image_0 = OpTypeImage %uint 2D 2 0 0 2 R32ui +%_ptr_UniformConstant_type_2d_image_0 = OpTypePointer UniformConstant %type_2d_image_0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %34 = OpTypeFunction %void + %v2uint = OpTypeVector %uint 2 +%_ptr_Function__arr_v3float_uint_16 = OpTypePointer Function %_arr_v3float_uint_16 +%_ptr_Workgroup__arr_v3float_uint_16 = OpTypePointer Workgroup %_arr_v3float_uint_16 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %bool = OpTypeBool + %v3int = OpTypeVector %int 3 + %v2int = OpTypeVector %int 2 + %v4float = OpTypeVector %float 4 +%_ptr_Workgroup_v3float = OpTypePointer Workgroup %v3float + %g_data = OpVariable %_ptr_Workgroup__arr_Data_uint_64 Workgroup +%g_inputTexture = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant + %g_output = OpVariable %_ptr_UniformConstant_type_2d_image_0 UniformConstant +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %csMain = OpFunction %void None %34 + %44 = OpLabel + %45 = OpVariable %_ptr_Function__arr_v3float_uint_16 Function + %46 = OpLoad %v3uint %gl_GlobalInvocationID + %47 = OpCompositeExtract %uint %46 0 + OpBranch %48 + %48 = OpLabel + %49 = OpPhi %uint %uint_0 %44 %50 %51 + %52 = OpULessThan %bool %49 %uint_4 + OpLoopMerge %53 %51 None + OpBranchConditional %52 %54 %53 + %54 = OpLabel + OpBranch %55 + %55 = OpLabel + %56 = OpPhi %uint %uint_0 %54 %57 %58 + %59 = OpULessThan %bool %56 %uint_4 + OpLoopMerge %60 %58 None + OpBranchConditional %59 %58 %60 + %58 = OpLabel + %61 = OpBitcast %v3int %46 + %62 = OpBitcast %int %56 + %63 = OpBitcast %int %49 + %64 = OpCompositeConstruct %v3int %62 %63 %int_0 + %65 = OpIAdd %v3int %61 %64 + %66 = OpVectorShuffle %v2int %65 %65 0 1 + %67 = OpCompositeExtract %int %65 2 + %68 = OpLoad %type_2d_image %g_inputTexture + %69 = OpImageFetch %v4float %68 %66 Lod %67 + %70 = OpVectorShuffle %v3float %69 %69 0 1 2 + %71 = OpIMul %uint %49 %uint_4 + %72 = OpIAdd %uint %71 %56 + %73 = OpAccessChain %_ptr_Workgroup_v3float %g_data %47 %int_0 %72 + OpStore %73 %70 + %57 = OpIAdd %uint %56 %uint_1 + OpBranch %55 + %60 = OpLabel + OpBranch %51 + %51 = OpLabel + %50 = OpIAdd %uint %49 %uint_1 + OpBranch %48 + %53 = OpLabel + %74 = OpAccessChain %_ptr_Workgroup__arr_v3float_uint_16 %g_data %47 %int_0 + %75 = OpLoad %_arr_v3float_uint_16 %74 + OpStore %45 %75 + OpBranch %76 + %76 = OpLabel + %77 = OpPhi %uint %uint_0 %53 %78 %79 + %80 = OpPhi %int %int_0 %53 %81 %79 + %82 = OpSLessThan %bool %80 %int_16 + OpLoopMerge %83 %79 None + OpBranchConditional %82 %79 %83 + %79 = OpLabel + %84 = OpAccessChain %_ptr_Function_v3float %45 %80 + %85 = OpLoad %v3float %84 + %86 = OpDot %float %85 %20 + %87 = OpExtInst %float %1 FClamp %86 %float_0 %float_1 + %88 = OpConvertFToU %uint %87 + %78 = OpBitwiseOr %uint %77 %88 + %81 = OpIAdd %int %80 %int_1 + OpBranch %76 + %83 = OpLabel + %89 = OpVectorShuffle %v2uint %46 %46 0 1 + %90 = OpLoad %type_2d_image_0 %g_output + OpImageWrite %90 %89 %77 None + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/shaders-msl-no-opt/asm/comp/local-size-id.asm.comp rename to third_party/spirv-cross/shaders-msl-no-opt/asm/comp/local-size-id.asm.invalid.comp diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp new file mode 100644 index 0000000000..9c2afe3936 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-2.asm.comp @@ -0,0 +1,71 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_variable_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex %gl_GlobalInvocationID + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %test "test" + OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex" + OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_v2float_uint_64 = OpTypeArray %v2float %uint_64 +%_ptr_Workgroup__arr_v2float_uint_64 = OpTypePointer Workgroup %_arr_v2float_uint_64 + %test = OpVariable %_ptr_Workgroup__arr_v2float_uint_64 Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 +%_ptr_Workgroup_float = OpTypePointer Workgroup %float +%_ptr_Workgroup_v2float = OpTypePointer Workgroup %v2float +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %uint %gl_LocalInvocationIndex + %19 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %20 = OpLoad %uint %19 + %21 = OpConvertUToF %float %20 + %22 = OpCompositeConstruct %v2float %21 %21 + + ; Dummy expression. *(&test + 0) + %ptr0 = OpPtrAccessChain %_ptr_Workgroup__arr_v2float_uint_64 %test %uint_0 + %ptr1 = OpPtrAccessChain %_ptr_Workgroup_v2float %ptr0 %uint_0 %uint_1 + %ptr2 = OpPtrAccessChain %_ptr_Workgroup_v2float %ptr1 %uint_2 + OpStore %ptr2 %22 + + ; Chain PtrAccessChain while keeping pointer type. + %ptr3 = OpPtrAccessChain %_ptr_Workgroup_v2float %test %uint_0 %uint_1 + %ptr4 = OpPtrAccessChain %_ptr_Workgroup_v2float %ptr3 %uint_2 + OpStore %ptr4 %22 + + ; Same semantics. + %ptr5 = OpPtrAccessChain %_ptr_Workgroup_v2float %test %uint_0 %uint_3 + OpStore %ptr5 %22 + + ; Scalar shenanigans. + %ptr6 = OpPtrAccessChain %_ptr_Workgroup_float %test %uint_0 %uint_2 %uint_0 + %ptr7 = OpPtrAccessChain %_ptr_Workgroup_float %ptr6 %uint_1 + OpStore %ptr7 %21 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp new file mode 100644 index 0000000000..79ff08edc4 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-3.asm.comp @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_variable_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex %gl_GlobalInvocationID + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %test "test" + OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex" + OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %bool = OpTypeBool + %true = OpConstantTrue %bool + %v2float = OpTypeVector %float 2 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_v2float_uint_64 = OpTypeArray %v2float %uint_64 +%_ptr_Workgroup__arr_v2float_uint_64 = OpTypePointer Workgroup %_arr_v2float_uint_64 + %test = OpVariable %_ptr_Workgroup__arr_v2float_uint_64 Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 +%_ptr_Workgroup_float = OpTypePointer Workgroup %float +%_ptr_Workgroup_v2float = OpTypePointer Workgroup %v2float +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %uint %gl_LocalInvocationIndex + %19 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %20 = OpLoad %uint %19 + %21 = OpConvertUToF %float %20 + %22 = OpCompositeConstruct %v2float %21 %21 + + ; Scalar shenanigans. + %ptr6 = OpPtrAccessChain %_ptr_Workgroup_float %test %uint_0 %uint_2 %uint_0 + %ptr6_alt = OpPtrAccessChain %_ptr_Workgroup_float %test %uint_0 %uint_2 %uint_0 + %ptr6_sel = OpSelect %_ptr_Workgroup_float %true %ptr6 %ptr6_alt + %ptr7 = OpPtrAccessChain %_ptr_Workgroup_float %ptr6_sel %uint_1 + OpStore %ptr7 %21 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp new file mode 100644 index 0000000000..c4512858a9 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/variable-pointers-vector-to-scalar.asm.comp @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpExtension "SPV_KHR_variable_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex %gl_GlobalInvocationID + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %test "test" + OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex" + OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %bool = OpTypeBool + %true = OpConstantTrue %bool + %v2float = OpTypeVector %float 2 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_v2float_uint_64 = OpTypeArray %v2float %uint_64 +%_ptr_Workgroup__arr_v2float_uint_64 = OpTypePointer Workgroup %_arr_v2float_uint_64 + %test = OpVariable %_ptr_Workgroup__arr_v2float_uint_64 Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 +%_ptr_Workgroup_float = OpTypePointer Workgroup %float +%_ptr_Workgroup_v2float = OpTypePointer Workgroup %v2float +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %uint %gl_LocalInvocationIndex + %19 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %20 = OpLoad %uint %19 + %21 = OpConvertUToF %float %20 + %22 = OpCompositeConstruct %v2float %21 %21 + + %a = OpAccessChain %_ptr_Workgroup_v2float %test %uint_1 + %b = OpAccessChain %_ptr_Workgroup_v2float %test %uint_2 + %c = OpSelect %_ptr_Workgroup_v2float %true %a %b + + %d = OpAccessChain %_ptr_Workgroup_float %c %uint_1 + OpStore %d %21 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp new file mode 100644 index 0000000000..ed4e104466 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/workgroup-uint-to-uchar-alias-ptr-access-chain.asm.comp @@ -0,0 +1,214 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google Clspv; 0 +; Bound: 175 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_KHR_variable_pointers" + OpExtension "SPV_KHR_non_semantic_info" + %163 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %32 "main" %gl_LocalInvocationID %gl_WorkGroupID + OpSource OpenCL_C 120 + %164 = OpString "main" + %165 = OpString " __kernel" + %167 = OpString "out_data" + %170 = OpString "pix_in_block" + OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId + OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_v4uint ArrayStride 16 + OpMemberDecorate %_struct_23 0 Offset 0 + OpDecorate %_struct_23 Block + OpMemberDecorate %_struct_26 0 Offset 0 + OpMemberDecorate %_struct_27 0 Offset 0 + OpDecorate %_struct_27 Block + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 0 + OpDecorate %_arr_uint_uint_256 ArrayStride 4 + OpDecorate %_arr_uchar_uint_1024 ArrayStride 1 + OpDecorate %15 SpecId 0 + OpDecorate %16 SpecId 1 + OpDecorate %17 SpecId 2 + %uint = OpTypeInt 32 0 + %uint_256 = OpConstant %uint 256 +%_arr_uint_uint_256 = OpTypeArray %uint %uint_256 +%_ptr_Workgroup__arr_uint_uint_256 = OpTypePointer Workgroup %_arr_uint_uint_256 + %uchar = OpTypeInt 8 0 + %uint_1024 = OpConstant %uint 1024 +%_arr_uchar_uint_1024 = OpTypeArray %uchar %uint_1024 +%_ptr_Workgroup__arr_uchar_uint_1024 = OpTypePointer Workgroup %_arr_uchar_uint_1024 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %15 = OpSpecConstant %uint 1 + %16 = OpSpecConstant %uint 1 + %17 = OpSpecConstant %uint 1 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %v4uint = OpTypeVector %uint 4 +%_runtimearr_v4uint = OpTypeRuntimeArray %v4uint + %_struct_23 = OpTypeStruct %_runtimearr_v4uint +%_ptr_StorageBuffer__struct_23 = OpTypePointer StorageBuffer %_struct_23 + %_struct_26 = OpTypeStruct %uint + %_struct_27 = OpTypeStruct %_struct_26 +%_ptr_PushConstant__struct_27 = OpTypePointer PushConstant %_struct_27 + %void = OpTypeVoid + %31 = OpTypeFunction %void +%_ptr_PushConstant__struct_26 = OpTypePointer PushConstant %_struct_26 + %uint_0 = OpConstant %uint 0 + %bool = OpTypeBool +%_ptr_Input_uint = OpTypePointer Input %uint + %uint_1 = OpConstant %uint 1 + %uint_255 = OpConstant %uint 255 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_2 = OpConstant %uint 2 + %uint_10 = OpConstant %uint 10 + %uint_1020 = OpConstant %uint 1020 + %v4uchar = OpTypeVector %uchar 4 +%_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar + %uint_3 = OpConstant %uint 3 + %uint_264 = OpConstant %uint 264 +%_ptr_StorageBuffer_v4uint = OpTypePointer StorageBuffer %v4uint + %137 = OpUndef %v4uchar + %uint_4 = OpConstant %uint 4 + %5 = OpVariable %_ptr_Workgroup__arr_uint_uint_256 Workgroup + %10 = OpVariable %_ptr_Workgroup__arr_uchar_uint_1024 Workgroup +%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input +%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input + %20 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %25 = OpVariable %_ptr_StorageBuffer__struct_23 StorageBuffer + %29 = OpVariable %_ptr_PushConstant__struct_27 PushConstant + %32 = OpFunction %void None %31 + %33 = OpLabel + %36 = OpAccessChain %_ptr_PushConstant__struct_26 %29 %uint_0 + %37 = OpLoad %_struct_26 %36 + %38 = OpCompositeExtract %uint %37 0 + %40 = OpINotEqual %bool %38 %uint_0 + OpSelectionMerge %105 None + OpBranchConditional %40 %43 %105 + %43 = OpLabel + %45 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 + %46 = OpLoad %uint %45 + %48 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_1 + %49 = OpLoad %uint %48 + %50 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0 + %51 = OpLoad %uint %50 + %52 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_1 + %53 = OpLoad %uint %52 + %54 = OpIMul %uint %53 %51 + %55 = OpUDiv %uint %54 %49 + %57 = OpUMod %uint %55 %uint_255 + %58 = OpUConvert %uchar %57 + OpBranch %60 + %60 = OpLabel + %61 = OpPhi %uint %100 %99 %uint_0 %43 + %62 = OpIMul %uint %61 %38 + OpLoopMerge %103 %99 None + OpBranch %65 + %65 = OpLabel + %66 = OpPhi %uint %93 %65 %uint_0 %60 + %67 = OpIAdd %uint %66 %62 + %68 = OpIMul %uint %66 %61 + %69 = OpIAdd %uint %46 %68 + %71 = OpAccessChain %_ptr_Workgroup_uint %5 %67 + OpStore %71 %69 + %72 = OpIAdd %uint %49 %68 + %74 = OpShiftLeftLogical %uint %67 %uint_2 + %76 = OpShiftRightLogical %uint %74 %uint_10 + %78 = OpBitwiseAnd %uint %74 %uint_1020 + %80 = OpBitcast %v4uchar %72 + %81 = OpCompositeExtract %uchar %80 1 + %82 = OpCompositeExtract %uchar %80 2 + %83 = OpCompositeExtract %uchar %80 3 + %85 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %76 %78 + %86 = OpBitwiseOr %uint %78 %uint_1 + %87 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %76 %86 + OpStore %87 %81 + %88 = OpBitwiseOr %uint %78 %uint_2 + %89 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %76 %88 + OpStore %89 %82 + %91 = OpBitwiseOr %uint %78 %uint_3 + %92 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %76 %91 + OpStore %92 %83 + OpStore %85 %58 + %93 = OpIAdd %uint %66 %uint_1 + %94 = OpUGreaterThanEqual %bool %93 %38 + OpLoopMerge %97 %65 None + OpBranchConditional %94 %97 %65 + %97 = OpLabel + OpBranch %99 + %99 = OpLabel + %100 = OpIAdd %uint %61 %uint_1 + %101 = OpUGreaterThanEqual %bool %100 %38 + OpBranchConditional %101 %103 %60 + %103 = OpLabel + OpBranch %105 + %105 = OpLabel + OpBranch %107 + %107 = OpLabel + OpControlBarrier %uint_2 %uint_2 %uint_264 + OpSelectionMerge %162 None + OpBranchConditional %40 %111 %162 + %111 = OpLabel + %112 = OpPhi %uint %157 %156 %uint_0 %107 + %113 = OpIMul %uint %112 %38 + OpLoopMerge %160 %156 None + OpBranch %116 + %116 = OpLabel + %117 = OpPhi %uint %150 %116 %uint_0 %111 + %118 = OpIAdd %uint %117 %113 + %120 = OpAccessChain %_ptr_StorageBuffer_v4uint %25 %uint_0 %118 + %121 = OpAccessChain %_ptr_Workgroup_uint %5 %118 + %122 = OpLoad %uint %121 + %123 = OpShiftLeftLogical %uint %118 %uint_2 + %124 = OpShiftRightLogical %uint %123 %uint_10 + %125 = OpBitwiseAnd %uint %123 %uint_1020 + %126 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %124 %125 + %127 = OpLoad %uchar %126 + %128 = OpBitwiseOr %uint %125 %uint_1 + %129 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %124 %128 + %130 = OpLoad %uchar %129 + %131 = OpBitwiseOr %uint %125 %uint_2 + %132 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %124 %131 + %133 = OpLoad %uchar %132 + %134 = OpBitwiseOr %uint %125 %uint_3 + %135 = OpPtrAccessChain %_ptr_Workgroup_uchar %10 %124 %134 + %136 = OpLoad %uchar %135 + %138 = OpCompositeInsert %v4uchar %127 %137 0 + %139 = OpCompositeInsert %v4uchar %130 %138 1 + %140 = OpCompositeInsert %v4uchar %133 %139 2 + %141 = OpCompositeInsert %v4uchar %136 %140 3 + %142 = OpBitcast %uint %141 + %143 = OpIAdd %uint %122 %142 + %144 = OpLoad %v4uint %120 + %145 = OpCompositeInsert %v4uint %143 %144 0 + %146 = OpShiftRightLogical %uint %143 %uint_2 + %147 = OpCompositeInsert %v4uint %146 %145 1 + %148 = OpShiftRightLogical %uint %143 %uint_3 + %149 = OpCompositeInsert %v4uint %148 %147 3 + OpStore %120 %149 + %150 = OpIAdd %uint %117 %uint_1 + %151 = OpUGreaterThanEqual %bool %150 %38 + OpLoopMerge %154 %116 None + OpBranchConditional %151 %154 %116 + %154 = OpLabel + OpBranch %156 + %156 = OpLabel + %157 = OpIAdd %uint %112 %uint_1 + %158 = OpUGreaterThanEqual %bool %157 %38 + OpBranchConditional %158 %160 %111 + %160 = OpLabel + OpBranch %162 + %162 = OpLabel + OpControlBarrier %uint_2 %uint_2 %uint_264 + OpReturn + OpFunctionEnd + %166 = OpExtInst %void %163 Kernel %32 %164 %uint_2 %uint_0 %165 + %168 = OpExtInst %void %163 ArgumentInfo %167 + %169 = OpExtInst %void %163 ArgumentStorageBuffer %166 %uint_0 %uint_0 %uint_0 %168 + %171 = OpExtInst %void %163 ArgumentInfo %170 + %173 = OpExtInst %void %163 ArgumentPodPushConstant %166 %uint_1 %uint_0 %uint_4 %171 + %174 = OpExtInst %void %163 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..700987b709 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %uint %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..7d29180259 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %int %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 + %int_0 = OpConstant %int 0 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Input_int = OpTypePointer Input %int +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output +%_ptr_Output_int = OpTypePointer Output %int + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.frag rename to third_party/spirv-cross/shaders-msl-no-opt/asm/frag/subgroup-arithmetic-cast.msl21.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/extract-atomics-from-function.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/extract-atomics-from-function.comp new file mode 100644 index 0000000000..c1b7632f85 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/extract-atomics-from-function.comp @@ -0,0 +1,69 @@ +#version 460 + +#extension GL_KHR_memory_scope_semantics : enable + +layout(local_size_x = 64) in; + +shared uint var; + +void testAdd() +{ + atomicAdd(var, 1); +} + +void testMin() +{ + atomicMin(var, 2); +} + +void testMax() +{ + atomicMax(var, 3); +} + +void testAnd() +{ + atomicAnd(var, 4); +} + +void testOr() +{ + atomicOr(var, 5); +} + +void testXor() +{ + atomicXor(var, 6); +} + +void testExchange() +{ + atomicExchange(var, 7); +} + +void testCompSwap() +{ + atomicCompSwap(var, 8, 9); +} + +void testStore() +{ + atomicStore(var, 10u, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); +} + +void foo() +{ + testAdd(); + testMin(); + testMax(); + testOr(); + testXor(); + testExchange(); + testCompSwap(); + testStore(); +} + +void main() +{ + foo(); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp new file mode 100644 index 0000000000..6d7d6f3f1f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/image-array-atomic.msl31.comp @@ -0,0 +1,14 @@ +#version 460 +#extension GL_EXT_buffer_reference : require +#extension GL_EXT_nonuniform_qualifier : require + +layout (set = 0, binding = 0, r32ui) uniform uimage2D kTextures2D[8]; + +layout(push_constant) uniform PushConst { + uint texture0; +} pc; + +void main() { + uint i = imageAtomicAdd(kTextures2D[pc.texture0], ivec2(0, 0), 1); +} + diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp new file mode 100644 index 0000000000..8b6630922b --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp @@ -0,0 +1,114 @@ +#version 450 +#extension GL_EXT_shader_8bit_storage : require +#extension GL_EXT_shader_16bit_storage : require +#extension GL_EXT_shader_explicit_arithmetic_types : require +#extension GL_EXT_spirv_intrinsics : require + +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer InOut { + uvec4 x; + uvec4 y; + int result; +} comp; + +layout(std430, binding = 1) buffer InOut2 { + uint x; + uint y; + uint result; +} comp2; + +layout(std430, binding = 1) buffer InOut3 { + u16vec4 x; + u16vec4 y; + int acc; + int result; +} comp3; + +// Signed integer dot with unsigned integer +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +int sdot_int_result(u16vec4 x, u16vec4 y); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +uint sdot_uint_result(u16vec4 x, u16vec4 y); + +// Unsigned integer dot with signed integer. Only unsigned result is allowed in SPIR-V. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +uint udot_uint_result(u16vec4 x, u16vec4 y); + +// Mixed integer dot with unsigned integer +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +int sudot_int_result(u16vec4 x, u16vec4 y); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +uint sudot_uint_result(u16vec4 x, u16vec4 y); + +// Signed packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +uint8_t spdot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +uint16_t spdot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +uint spdot_to_32(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +int spdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); + +// Unsigned packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +uint8_t updot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +uint16_t updot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +uint updot_to_32(uint x, uint y, spirv_literal uint packedFormat); + +// Mixed packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +uint8_t supdot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +uint16_t supdot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +uint supdot_to_32(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +int supdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); + +// SDotAccSat with unsigned input and result type +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4453) +int sdotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4453) +uint sdotaddsat_uint_result(u16vec4 x, u16vec4 y, int acc); + +// UDotAccSat. Result type must be unsigned in SPIR-V. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4454) +uint udotaddsat(u16vec4 x, u16vec4 y, int acc); + +// SUDotAccSat +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4455) +int sudotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4455) +uint sudotaddsat_uint_result(u16vec4 x, u16vec4 y, int acc); + +void main() { + int sdot_int = sdot_int_result(comp3.x, comp3.y); + uint sdot_uint = sdot_uint_result(comp3.x, comp3.y); + uint udot_uint = udot_uint_result(comp3.x, comp3.y); + int sudot_int = sudot_int_result(comp3.x, comp3.y); + uint sudot_uint = sudot_uint_result(comp3.x, comp3.y); + + uint8_t spdot8 = spdot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t spdot16 = spdot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint spdot32 = spdot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + int spdoti32 = spdot_to_i32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + uint8_t updot8 = updot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t updot16 = updot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint updot32 = updot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + uint8_t supdot8 = supdot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t supdot16 = supdot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint supdot32 = supdot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + int supdoti32 = supdot_to_i32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + int sdotaddsat_int = sdotaddsat_int_result(comp3.x, comp3.y, comp3.acc); + uint sdotaddsat_uint = sdotaddsat_uint_result(comp3.x, comp3.y, comp3.acc); + uint udotaddsat_uint = udotaddsat(comp3.x, comp3.y, comp3.acc); + int sudotaddsat_int = sudotaddsat_int_result(comp3.x, comp3.y, comp3.acc); + uint sudotaddsat_uint = sudotaddsat_uint_result(comp3.x, comp3.y, comp3.acc); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag new file mode 100644 index 0000000000..d359422581 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag @@ -0,0 +1,26 @@ +#version 460 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_EXT_ray_query : enable + +layout(binding = 0) uniform accelerationStructureEXT topLevelAS; + +void initFn(rayQueryEXT rayQuery) { + vec3 rayOrigin = vec3(0, 0, 1); + vec3 rayDirection = vec3(0, 0,-1); + float rayDistance = 2.0; + rayQueryInitializeEXT(rayQuery, topLevelAS, gl_RayFlagsTerminateOnFirstHitEXT, 0xFF, rayOrigin, 0.001, rayDirection, rayDistance); +} + +uint proceeFn(rayQueryEXT rayQuery) { + while(rayQueryProceedEXT(rayQuery)) + ; + return rayQueryGetIntersectionTypeEXT(rayQuery, true); +} + +void main() { + rayQueryEXT rayQuery; + + initFn(rayQuery); + proceeFn(rayQuery); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag b/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag new file mode 100644 index 0000000000..9377a8affe --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array-write.frag @@ -0,0 +1,51 @@ +#version 450 +#extension GL_EXT_shader_explicit_arithmetic_types : require + +layout(set = 0, binding = 0, std140) buffer Foo +{ + f16mat2x3 c23; + f16mat3x2 c32; + layout(row_major) f16mat2x3 r23; + layout(row_major) f16mat3x2 r32; + + float16_t h1[6]; + f16vec2 h2[6]; + f16vec3 h3[6]; + f16vec4 h4[6]; +}; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + // Store scalar + c23[1][2] = 1.0hf; + c32[2][1] = 2.0hf; + r23[1][2] = 3.0hf; + r32[2][1] = 4.0hf; + + // Store vector + c23[1] = f16vec3(0, 1, 2); + c32[1] = f16vec2(0, 1); + r23[1] = f16vec3(0, 1, 2); + r32[1] = f16vec2(0, 1); + + // Store matrix + c23 = f16mat2x3(1, 2, 3, 4, 5, 6); + c32 = f16mat3x2(1, 2, 3, 4, 5, 6); + r23 = f16mat2x3(1, 2, 3, 4, 5, 6); + r32 = f16mat3x2(1, 2, 3, 4, 5, 6); + + // Store array + h1[5] = 1.0hf; + h2[5] = f16vec2(1, 2); + h3[5] = f16vec3(1, 2, 3); + h4[5] = f16vec4(1, 2, 3, 4); + + // Store scalar in array + h2[5][1] = 10.0hf; + h3[5][2] = 11.0hf; + h4[5][3] = 12.0hf; + + FragColor = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag b/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag new file mode 100644 index 0000000000..78d54cfa06 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/packing/std140-half-matrix-and-array.frag @@ -0,0 +1,110 @@ +#version 450 +#extension GL_EXT_shader_explicit_arithmetic_types : require + +layout(set = 0, binding = 0, std140) uniform Foo +{ + f16mat2x2 c22; + f16mat2x2 c22arr[3]; + f16mat2x3 c23; + f16mat2x4 c24; + + f16mat3x2 c32; + f16mat3x3 c33; + f16mat3x4 c34; + + f16mat4x2 c42; + f16mat4x3 c43; + f16mat4x4 c44; + + layout(row_major) f16mat2x2 r22; + layout(row_major) f16mat2x2 r22arr[3]; + layout(row_major) f16mat2x3 r23; + layout(row_major) f16mat2x4 r24; + + layout(row_major) f16mat3x2 r32; + layout(row_major) f16mat3x3 r33; + layout(row_major) f16mat3x4 r34; + + layout(row_major) f16mat4x2 r42; + layout(row_major) f16mat4x3 r43; + layout(row_major) f16mat4x4 r44; + + float16_t h1[6]; + f16vec2 h2[6]; + f16vec3 h3[6]; + f16vec4 h4[6]; +} u; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + // Load vectors. + f16vec2 c2 = u.c22[0] + u.c22[1]; + c2 = u.c22arr[2][0] + u.c22arr[2][1]; + f16vec3 c3 = u.c23[0] + u.c23[1]; + f16vec4 c4 = u.c24[0] + u.c24[1]; + + c2 = u.c32[0] + u.c32[1] + u.c32[2]; + c3 = u.c33[0] + u.c33[1] + u.c33[2]; + c4 = u.c34[0] + u.c34[1] + u.c34[2]; + + c2 = u.c42[0] + u.c42[1] + u.c42[2] + u.c42[3]; + c3 = u.c43[0] + u.c43[1] + u.c43[2] + u.c43[3]; + c4 = u.c44[0] + u.c44[1] + u.c44[2] + u.c44[3]; + + // Load scalars. + float16_t c = u.c22[0].x + u.c22[0].y + u.c22[1].x + u.c22[1].y; + c = u.c22arr[2][0].x + u.c22arr[2][0].y + u.c22arr[2][1].x + u.c22arr[2][1].y; + + // Load full matrix. + f16mat2x2 c22 = u.c22; + c22 = u.c22arr[2]; + f16mat2x3 c23 = u.c23; + f16mat2x4 c24 = u.c24; + + f16mat3x2 c32 = u.c32; + f16mat3x3 c33 = u.c33; + f16mat3x4 c34 = u.c34; + + f16mat4x2 c42 = u.c42; + f16mat4x3 c43 = u.c43; + f16mat4x4 c44 = u.c44; + + // Same, but row-major. + f16vec2 r2 = u.r22[0] + u.r22[1]; + r2 = u.r22arr[2][0] + u.r22arr[2][1]; + f16vec3 r3 = u.r23[0] + u.r23[1]; + f16vec4 r4 = u.r24[0] + u.r24[1]; + + r2 = u.r32[0] + u.r32[1] + u.r32[2]; + r3 = u.r33[0] + u.r33[1] + u.r33[2]; + r4 = u.r34[0] + u.r34[1] + u.r34[2]; + + r2 = u.r42[0] + u.r42[1] + u.r42[2] + u.r42[3]; + r3 = u.r43[0] + u.r43[1] + u.r43[2] + u.r43[3]; + r4 = u.r44[0] + u.r44[1] + u.r44[2] + u.r44[3]; + + // Load scalars. + float16_t r = u.r22[0].x + u.r22[0].y + u.r22[1].x + u.r22[1].y; + + // Load full matrix. + f16mat2x2 r22 = u.r22; + f16mat2x3 r23 = u.r23; + f16mat2x4 r24 = u.r24; + + f16mat3x2 r32 = u.r32; + f16mat3x3 r33 = u.r33; + f16mat3x4 r34 = u.r34; + + f16mat4x2 r42 = u.r42; + f16mat4x3 r43 = u.r43; + f16mat4x4 r44 = u.r44; + + float16_t h1 = u.h1[5]; + f16vec2 h2 = u.h2[5]; + f16vec3 h3 = u.h3[5]; + f16vec4 h4 = u.h4[5]; + + FragColor = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag b/third_party/spirv-cross/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag new file mode 100644 index 0000000000..600c522c3d --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag @@ -0,0 +1,86 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 45 +; Schema: 0 + OpCapability Shader + OpCapability SampledCubeArray + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %o_color %v_texCoord %v_drefLodBias + OpExecutionMode %main OriginUpperLeft + + ; Debug Information + OpSource GLSL 450 + OpName %main "main" ; id %4 + OpName %o_color "o_color" ; id %9 + OpName %u_sampler "u_sampler" ; id %13 + OpName %v_texCoord "v_texCoord" ; id %16 + OpName %v_drefLodBias "v_drefLodBias" ; id %21 + OpName %buf0 "buf0" ; id %39 + OpMemberName %buf0 0 "u_scale" + OpName %_ "" ; id %41 + OpName %buf1 "buf1" ; id %42 + OpMemberName %buf1 0 "u_bias" + OpName %__0 "" ; id %44 + + ; Annotations + OpDecorate %o_color RelaxedPrecision + OpDecorate %o_color Location 0 + OpDecorate %u_sampler DescriptorSet 0 + OpDecorate %u_sampler Binding 0 + OpDecorate %v_texCoord Location 0 + OpDecorate %v_drefLodBias Location 1 + OpMemberDecorate %buf0 0 Offset 0 + OpDecorate %buf0 Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 1 + OpMemberDecorate %buf1 0 Offset 0 + OpDecorate %buf1 Block + OpDecorate %__0 DescriptorSet 0 + OpDecorate %__0 Binding 2 + + ; Types, variables and constants + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %o_color = OpVariable %_ptr_Output_v4float Output + %10 = OpTypeImage %float Cube 1 1 0 1 Unknown + %11 = OpTypeSampledImage %10 +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 + %u_sampler = OpVariable %_ptr_UniformConstant_11 UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float + %v_texCoord = OpVariable %_ptr_Input_v4float Input + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float +%v_drefLodBias = OpVariable %_ptr_Input_v2float Input + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float + %v3float = OpTypeVector %float 3 + %uint_1 = OpConstant %uint 1 + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %buf0 = OpTypeStruct %v4float +%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0 + %_ = OpVariable %_ptr_Uniform_buf0 Uniform + %buf1 = OpTypeStruct %v4float +%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1 + %__0 = OpVariable %_ptr_Uniform_buf1 Uniform + + ; Function main + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %11 %u_sampler + %18 = OpLoad %v4float %v_texCoord + %25 = OpAccessChain %_ptr_Input_float %v_drefLodBias %uint_0 + %26 = OpLoad %float %25 + %32 = OpAccessChain %_ptr_Input_float %v_drefLodBias %uint_1 + %33 = OpLoad %float %32 + %35 = OpImageSampleDrefExplicitLod %float %14 %18 %26 Lod %33 + %38 = OpCompositeConstruct %v4float %35 %float_0 %float_0 %float_1 + OpStore %o_color %38 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..6f0d06a869 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,28 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0) buffer SSBO +{ + vec4 v[]; +} o; + +layout(set = 0, binding = 1) uniform UBO { vec4 v[1024]; } v; +layout(set = 0, binding = 2) uniform UBOs { vec4 v; } vs[]; + +layout(set = 1, binding = 0) buffer SSBOIn { vec4 v[1024]; } w; +layout(set = 1, binding = 1) buffer SSBOIns { vec4 v; } ws[]; + +void in_func() +{ + o.v[gl_GlobalInvocationID.x] = v.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x].v; + + o.v[gl_GlobalInvocationID.x] = w.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x].v; +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..6f0d06a869 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array-buffer.rich-descriptor.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,28 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0) buffer SSBO +{ + vec4 v[]; +} o; + +layout(set = 0, binding = 1) uniform UBO { vec4 v[1024]; } v; +layout(set = 0, binding = 2) uniform UBOs { vec4 v; } vs[]; + +layout(set = 1, binding = 0) buffer SSBOIn { vec4 v[1024]; } w; +layout(set = 1, binding = 1) buffer SSBOIns { vec4 v; } ws[]; + +void in_func() +{ + o.v[gl_GlobalInvocationID.x] = v.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = vs[gl_WorkGroupID.x].v; + + o.v[gl_GlobalInvocationID.x] = w.v[gl_WorkGroupID.x]; + o.v[gl_GlobalInvocationID.x] = ws[gl_WorkGroupID.x].v; +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp new file mode 100644 index 0000000000..58144ffac6 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/argument-buffers-runtime-array.argument.device-argument-buffer.argument-tier-1.msl2.comp @@ -0,0 +1,25 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require +layout(local_size_x = 64) in; + +layout(set = 0, binding = 0) buffer SSBO +{ + vec4 v[]; +}; + +layout(set = 0, binding = 1) uniform texture2D T; +layout(set = 0, binding = 2) uniform texture2D Ts[]; + +layout(set = 1, binding = 0) uniform sampler S; +layout(set = 1, binding = 1) uniform sampler Ss[]; + +void in_func() +{ + v[gl_GlobalInvocationID.x] = textureLod(sampler2D(T, S), vec2(0.5), 0.0); + v[gl_GlobalInvocationID.x] = textureLod(sampler2D(Ts[gl_WorkGroupID.x], Ss[gl_WorkGroupID.x]), vec2(0.5), 0.0); +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/atomic-image.comp b/third_party/spirv-cross/shaders-msl/comp/atomic-image.comp new file mode 100644 index 0000000000..703256d879 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/atomic-image.comp @@ -0,0 +1,56 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1) in; + +layout(r32ui, binding = 0) uniform highp uimage2D uImage; +layout(r32i, binding = 1) uniform highp iimage2D iImage; +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +void main() +{ + imageAtomicAdd(uImage, ivec2(1, 5), 1u); + + // Test that we do not invalidate OpImage variables which are loaded from UniformConstant + // address space. + imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); + + imageAtomicOr(uImage, ivec2(1, 5), 1u); + imageAtomicXor(uImage, ivec2(1, 5), 1u); + imageAtomicAnd(uImage, ivec2(1, 5), 1u); + imageAtomicMin(uImage, ivec2(1, 5), 1u); + imageAtomicMax(uImage, ivec2(1, 5), 1u); + //imageAtomicExchange(uImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + + imageAtomicAdd(iImage, ivec2(1, 6), 1); + imageAtomicOr(iImage, ivec2(1, 6), 1); + imageAtomicXor(iImage, ivec2(1, 6), 1); + imageAtomicAnd(iImage, ivec2(1, 6), 1); + imageAtomicMin(iImage, ivec2(1, 6), 1); + imageAtomicMax(iImage, ivec2(1, 6), 1); + //imageAtomicExchange(iImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + + atomicAdd(ssbo.u32, 1u); + atomicOr(ssbo.u32, 1u); + atomicXor(ssbo.u32, 1u); + atomicAnd(ssbo.u32, 1u); + atomicMin(ssbo.u32, 1u); + atomicMax(ssbo.u32, 1u); + atomicExchange(ssbo.u32, 1u); + atomicCompSwap(ssbo.u32, 10u, 2u); + + atomicAdd(ssbo.i32, 1); + atomicOr(ssbo.i32, 1); + atomicXor(ssbo.i32, 1); + atomicAnd(ssbo.i32, 1); + atomicMin(ssbo.i32, 1); + atomicMax(ssbo.i32, 1); + atomicExchange(ssbo.i32, 1); + atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/third_party/spirv-cross/shaders-msl/comp/atomic-image.msl31.comp b/third_party/spirv-cross/shaders-msl/comp/atomic-image.msl31.comp new file mode 100644 index 0000000000..703256d879 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/atomic-image.msl31.comp @@ -0,0 +1,56 @@ +#version 310 es +#extension GL_OES_shader_image_atomic : require +layout(local_size_x = 1) in; + +layout(r32ui, binding = 0) uniform highp uimage2D uImage; +layout(r32i, binding = 1) uniform highp iimage2D iImage; +layout(binding = 2, std430) buffer SSBO +{ + uint u32; + int i32; +} ssbo; + +void main() +{ + imageAtomicAdd(uImage, ivec2(1, 5), 1u); + + // Test that we do not invalidate OpImage variables which are loaded from UniformConstant + // address space. + imageStore(iImage, ivec2(1, 6), ivec4(imageAtomicAdd(uImage, ivec2(1, 5), 1u))); + + imageAtomicOr(uImage, ivec2(1, 5), 1u); + imageAtomicXor(uImage, ivec2(1, 5), 1u); + imageAtomicAnd(uImage, ivec2(1, 5), 1u); + imageAtomicMin(uImage, ivec2(1, 5), 1u); + imageAtomicMax(uImage, ivec2(1, 5), 1u); + //imageAtomicExchange(uImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u); + + imageAtomicAdd(iImage, ivec2(1, 6), 1); + imageAtomicOr(iImage, ivec2(1, 6), 1); + imageAtomicXor(iImage, ivec2(1, 6), 1); + imageAtomicAnd(iImage, ivec2(1, 6), 1); + imageAtomicMin(iImage, ivec2(1, 6), 1); + imageAtomicMax(iImage, ivec2(1, 6), 1); + //imageAtomicExchange(iImage, ivec2(1, 5), 1u); + imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2); + + atomicAdd(ssbo.u32, 1u); + atomicOr(ssbo.u32, 1u); + atomicXor(ssbo.u32, 1u); + atomicAnd(ssbo.u32, 1u); + atomicMin(ssbo.u32, 1u); + atomicMax(ssbo.u32, 1u); + atomicExchange(ssbo.u32, 1u); + atomicCompSwap(ssbo.u32, 10u, 2u); + + atomicAdd(ssbo.i32, 1); + atomicOr(ssbo.i32, 1); + atomicXor(ssbo.i32, 1); + atomicAnd(ssbo.i32, 1); + atomicMin(ssbo.i32, 1); + atomicMax(ssbo.i32, 1); + atomicExchange(ssbo.i32, 1); + atomicCompSwap(ssbo.i32, 10, 2); +} + diff --git a/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.comp b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.comp new file mode 100644 index 0000000000..ed754f0eb0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.comp @@ -0,0 +1,20 @@ +#version 450 + +layout (set = 1, binding = 0, r32ui) coherent uniform uimage2D rw_spd_global_atomic; + +void SPD_IncreaseAtomicCounter(inout uint spdCounter) +{ + spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); +} + +void ComputeAutoExposure() { + uint v = 0; + SPD_IncreaseAtomicCounter(v); +} + +layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ComputeAutoExposure(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp new file mode 100644 index 0000000000..ed754f0eb0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.argument.comp @@ -0,0 +1,20 @@ +#version 450 + +layout (set = 1, binding = 0, r32ui) coherent uniform uimage2D rw_spd_global_atomic; + +void SPD_IncreaseAtomicCounter(inout uint spdCounter) +{ + spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); +} + +void ComputeAutoExposure() { + uint v = 0; + SPD_IncreaseAtomicCounter(v); +} + +layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ComputeAutoExposure(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.comp b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.comp new file mode 100644 index 0000000000..ed754f0eb0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl2.comp @@ -0,0 +1,20 @@ +#version 450 + +layout (set = 1, binding = 0, r32ui) coherent uniform uimage2D rw_spd_global_atomic; + +void SPD_IncreaseAtomicCounter(inout uint spdCounter) +{ + spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); +} + +void ComputeAutoExposure() { + uint v = 0; + SPD_IncreaseAtomicCounter(v); +} + +layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ComputeAutoExposure(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp new file mode 100644 index 0000000000..ed754f0eb0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.argument.comp @@ -0,0 +1,20 @@ +#version 450 + +layout (set = 1, binding = 0, r32ui) coherent uniform uimage2D rw_spd_global_atomic; + +void SPD_IncreaseAtomicCounter(inout uint spdCounter) +{ + spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); +} + +void ComputeAutoExposure() { + uint v = 0; + SPD_IncreaseAtomicCounter(v); +} + +layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ComputeAutoExposure(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.comp b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.comp new file mode 100644 index 0000000000..ed754f0eb0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/coherent-image-atomic.msl31.comp @@ -0,0 +1,20 @@ +#version 450 + +layout (set = 1, binding = 0, r32ui) coherent uniform uimage2D rw_spd_global_atomic; + +void SPD_IncreaseAtomicCounter(inout uint spdCounter) +{ + spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); +} + +void ComputeAutoExposure() { + uint v = 0; + SPD_IncreaseAtomicCounter(v); +} + +layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ComputeAutoExposure(); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp b/third_party/spirv-cross/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp new file mode 100644 index 0000000000..ce7765259e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/metal3_1_regression_patch.replace-recursive-inputs.msl3.comp @@ -0,0 +1,21 @@ +#version 450 +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer recurs; +layout(buffer_reference, buffer_reference_align = 16, set = 0, binding = 1, std140) buffer recurs +{ + int m1; + recurs m2; +} nums; + +layout(set = 0, binding = 0, r32ui) uniform writeonly uimage2D tex; + +void main() +{ + int rslt = 0; + rslt += nums.m1; + rslt += nums.m2.m1; + rslt += nums.m2.m2.m1; + imageStore(tex, ivec2(gl_GlobalInvocationID.xy), uvec4(rslt, 0u, 0u, 1u)); +} diff --git a/third_party/spirv-cross/shaders-msl/comp/shader_ballot.msl22.comp b/third_party/spirv-cross/shaders-msl/comp/shader_ballot.msl22.comp new file mode 100644 index 0000000000..7ef76a6634 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/shader_ballot.msl22.comp @@ -0,0 +1,29 @@ +#version 450 +#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); + + uvec4 activeSlots = bitCount(uvec4(unpackUint2x32(gl_SubGroupLtMaskARB), uvec2(0)) & uvec4(unpackUint2x32(ballotARB (laneActive)), uvec2(0))); + uint thisLaneOutputSlot = activeSlots.x + activeSlots.y; + + int firstInvocation = readFirstInvocationARB(1); + int invocation = readInvocationARB(1, 0); + + if (laneActive) { + outputDataArray[thisLaneOutputSlot] = thisLaneData; + } +} diff --git a/third_party/spirv-cross/shaders-msl/comp/shader_group_vote.msl21.comp b/third_party/spirv-cross/shaders-msl/comp/shader_group_vote.msl21.comp new file mode 100644 index 0000000000..d24aa92f84 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/comp/shader_group_vote.msl21.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/third_party/spirv-cross/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag b/third_party/spirv-cross/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag new file mode 100644 index 0000000000..9799a1392f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/frag-demote-checks.discard-checks.msl31.frag @@ -0,0 +1,33 @@ +#version 450 +#extension GL_EXT_demote_to_helper_invocation : enable + +layout(set=0, binding=0, std430) buffer foo_t +{ + float x; + uint y; +} foo; + +layout(r32ui, set=0, binding=1) uniform uimage2D bar; + +layout(location=0) out vec4 fragColor; + +vec4 frag_body() { + foo.x = 1.0f; + atomicExchange(foo.y, 0); + if (int(gl_FragCoord.x) == 3) + demote; + imageStore(bar, ivec2(gl_FragCoord.xy), uvec4(1)); + atomicAdd(foo.y, 42); + imageAtomicOr(bar, ivec2(gl_FragCoord.xy), 0x3e); + atomicAnd(foo.y, 0xffff); + atomicXor(foo.y, 0xffffff00); + atomicMin(foo.y, 1); + imageAtomicMax(bar, ivec2(gl_FragCoord.xy), 100); + imageAtomicCompSwap(bar, ivec2(gl_FragCoord.xy), 100, 42); + return vec4(1.0f, float(helperInvocationEXT()), 0.0f, 1.0f); +} + +void main() { + fragColor = frag_body(); +} + diff --git a/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag b/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag new file mode 100644 index 0000000000..a7f37a5a70 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks-continue-block.discard-checks.msl31.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(binding=0, set=0, std430) buffer foo +{ + int x; +}; + +layout(location=0) out vec4 fragColor; + +void main(void) +{ + if (gl_FragCoord.y == 7) + discard; + for (x = 0; x < gl_FragCoord.x; ++x) + ; + fragColor = vec4(x, 0, 0, 1); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag b/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag new file mode 100644 index 0000000000..8b40e60c19 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/frag-discard-checks.discard-checks.msl31.frag @@ -0,0 +1,32 @@ +#version 450 + +layout(set=0, binding=0, std430) buffer foo_t +{ + float x; + uint y; +} foo; + +layout(r32ui, set=0, binding=1) uniform uimage2D bar; + +layout(location=0) out vec4 fragColor; + +vec4 frag_body() { + foo.x = 1.0f; + atomicExchange(foo.y, 0); + if (int(gl_FragCoord.x) == 3) + discard; + imageStore(bar, ivec2(gl_FragCoord.xy), uvec4(1)); + atomicAdd(foo.y, 42); + imageAtomicOr(bar, ivec2(gl_FragCoord.xy), 0x3e); + atomicAnd(foo.y, 0xffff); + atomicXor(foo.y, 0xffffff00); + atomicMin(foo.y, 1); + imageAtomicMax(bar, ivec2(gl_FragCoord.xy), 100); + imageAtomicCompSwap(bar, ivec2(gl_FragCoord.xy), 100, 42); + return vec4(1.0f, 0.0f, 0.0f, 1.0f); +} + +void main() { + fragColor = frag_body(); +} + diff --git a/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag b/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag new file mode 100644 index 0000000000..ceac8cc50e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.argument.frag @@ -0,0 +1,36 @@ +#version 450 +#extension GL_ARB_fragment_shader_interlock : require + +layout(pixel_interlock_ordered) in; + +layout(binding = 0, rgba8) uniform writeonly image2D img; +layout(binding = 1, r32ui) uniform uimage2D img2; +layout(binding = 2, rgba8) uniform readonly image2D img3; +layout(binding = 3) coherent buffer Buffer +{ + int foo; + uint bar; +}; +layout(binding = 4) buffer Buffer2 +{ + uint quux; +}; + +layout(binding = 5, rgba8) uniform writeonly image2D img4; +layout(binding = 6) buffer Buffer3 +{ + int baz; +}; + +void main() +{ + // Deliberately outside the critical section to test usage tracking. + baz = 0; + imageStore(img4, ivec2(1, 1), vec4(1.0, 0.0, 0.0, 1.0)); + beginInvocationInterlockARB(); + imageStore(img, ivec2(0, 0), imageLoad(img3, ivec2(0, 0))); + imageAtomicAdd(img2, ivec2(0, 0), 1u); + foo += 42; + atomicAnd(bar, quux); + endInvocationInterlockARB(); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.frag b/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.frag new file mode 100644 index 0000000000..ceac8cc50e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/pixel-interlock-ordered.msl31.frag @@ -0,0 +1,36 @@ +#version 450 +#extension GL_ARB_fragment_shader_interlock : require + +layout(pixel_interlock_ordered) in; + +layout(binding = 0, rgba8) uniform writeonly image2D img; +layout(binding = 1, r32ui) uniform uimage2D img2; +layout(binding = 2, rgba8) uniform readonly image2D img3; +layout(binding = 3) coherent buffer Buffer +{ + int foo; + uint bar; +}; +layout(binding = 4) buffer Buffer2 +{ + uint quux; +}; + +layout(binding = 5, rgba8) uniform writeonly image2D img4; +layout(binding = 6) buffer Buffer3 +{ + int baz; +}; + +void main() +{ + // Deliberately outside the critical section to test usage tracking. + baz = 0; + imageStore(img4, ivec2(1, 1), vec4(1.0, 0.0, 0.0, 1.0)); + beginInvocationInterlockARB(); + imageStore(img, ivec2(0, 0), imageLoad(img3, ivec2(0, 0))); + imageAtomicAdd(img2, ivec2(0, 0), 1u); + foo += 42; + atomicAnd(bar, quux); + endInvocationInterlockARB(); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..006c9c0b8f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,90 @@ +#version 460 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_EXT_nonuniform_qualifier : enable +#extension GL_EXT_shader_image_load_formatted : enable +#extension GL_EXT_ray_query : enable + +layout(location = 0) in flat uint inputId; + +layout(binding = 0) uniform sampler2D smp_textures[]; +layout(binding = 1) uniform sampler smp[]; +layout(binding = 2) uniform texture2D textures[]; +layout(binding = 3, std430) readonly buffer Ssbo { uint val; uint data[]; } ssbo[]; +layout(binding = 4, std140) uniform Ubo { uint val; } ubo[]; +layout(binding = 5) uniform image2D images[]; +layout(binding = 6) uniform accelerationStructureEXT tlas[]; + +void implicit_combined_texture() { + vec4 d = textureLod(smp_textures[nonuniformEXT(inputId)],vec2(0,0),0); + if(d.a>0.5) + discard; + } + +void implicit_texture() { + vec4 d = textureLod(sampler2D(textures[nonuniformEXT(inputId)], smp[nonuniformEXT(inputId+8)]),vec2(0,0),0); + if(d.a>0.5) + discard; + } + +void implicit_ssbo() { + if(ssbo[nonuniformEXT(inputId)].val==2) + discard; + if(ssbo[123].data.length()==25) + discard; + } + +void implicit_ubo() { + if(ubo[nonuniformEXT(inputId)].val==2) + discard; + } + +void implicit_image() { + vec4 d = imageLoad(images[nonuniformEXT(inputId)],ivec2(0,0)); + if(d.a>0.5) + discard; + } + +void implicit_tlas() { + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, tlas[inputId], 0, 0xFF, vec3(0), 0.01, vec3(1), 1); + rayQueryProceedEXT(rayQuery); + } + +void explicit_comb_texture(in sampler2D tex) { + vec4 d = textureLod(tex,vec2(0,0),0); + if(d.a>0.5) + discard; + } + +void explicit_texture(in texture2D tex, in sampler smp) { + vec4 d = textureLod(sampler2D(tex,smp),vec2(0,0),0); + if(d.a>0.5) + discard; + } + +void explicit_image(in image2D tex) { + vec4 d = imageLoad(tex,ivec2(0,0)); + if(d.a>0.5) + discard; + } + +void explicit_tlas(in accelerationStructureEXT tlas) { + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, tlas, 0, 0xFF, vec3(0), 0.01, vec3(1), 1); + rayQueryProceedEXT(rayQuery); + } + +void main() { + implicit_combined_texture(); + implicit_texture(); + implicit_ssbo(); + implicit_ubo(); + implicit_image(); + implicit_tlas(); + + explicit_comb_texture(smp_textures[nonuniformEXT(inputId)]); + explicit_texture(textures[nonuniformEXT(inputId)], smp[nonuniformEXT(inputId)]); + explicit_image(images[nonuniformEXT(inputId)]); + explicit_tlas(tlas[inputId]); + } diff --git a/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag b/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag new file mode 100644 index 0000000000..00849d0d47 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag @@ -0,0 +1,15 @@ +#version 460 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_EXT_nonuniform_qualifier : enable + +layout(location = 0) in flat uint inputId; + +layout(binding = 0, std430) readonly buffer Ssbo { uint val; uint data[]; } ssbo[]; + +void main() { + if(ssbo[nonuniformEXT(inputId)].val==2) + discard; + if(ssbo[123].data.length()==25) + discard; + } diff --git a/third_party/spirv-cross/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag b/third_party/spirv-cross/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag new file mode 100644 index 0000000000..fe6ff897cd --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/sampler-cube-grad.agx-cube-grad.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in vec3 vTex; +layout(binding = 0) uniform samplerCube uSampler; + +void main() +{ + FragColor += textureGrad(uSampler, vTex, vec3(5.0), vec3(8.0)); +} diff --git a/third_party/spirv-cross/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese b/third_party/spirv-cross/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese new file mode 100644 index 0000000000..613f8f039d --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tese/read-patch-vertices-in-func.raw-tess-in.tese @@ -0,0 +1,12 @@ +#version 450 +layout(quads) in; + +vec4 read_patch_vertices() +{ + return vec4(gl_PatchVerticesIn, 0, 0, 1); +} + +void main() +{ + gl_Position = read_patch_vertices(); +} diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp new file mode 100644 index 0000000000..9abef684e1 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/block-undef.noeliminate.invalid.asm.comp @@ -0,0 +1,34 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 460 + OpName %main "main" + OpName %FHitGroupRootConstants "FHitGroupRootConstants" + OpMemberName %FHitGroupRootConstants 0 "BaseInstanceIndex" + OpMemberName %FHitGroupRootConstants 1 "UserData" + OpName %type_StructuredBuffer_FHitGroupRootConstants "type_StructuredBuffer_FHitGroupRootConstants" + OpMemberName %type_StructuredBuffer_FHitGroupRootConstants 0 "_m0" + OpName %HitGroupData "HitGroupData" + OpMemberDecorate %FHitGroupRootConstants 0 Offset 0 + OpMemberDecorate %FHitGroupRootConstants 1 Offset 4 + OpDecorate %_runtimearr_FHitGroupRootConstants ArrayStride 8 + OpMemberDecorate %type_StructuredBuffer_FHitGroupRootConstants 0 NonWritable + OpMemberDecorate %type_StructuredBuffer_FHitGroupRootConstants 0 Offset 0 + OpDecorate %type_StructuredBuffer_FHitGroupRootConstants BufferBlock + OpDecorate %HitGroupData DescriptorSet 0 + OpDecorate %HitGroupData Binding 20 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%FHitGroupRootConstants = OpTypeStruct %uint %uint +%_runtimearr_FHitGroupRootConstants = OpTypeRuntimeArray %FHitGroupRootConstants +%type_StructuredBuffer_FHitGroupRootConstants = OpTypeStruct %_runtimearr_FHitGroupRootConstants +%_ptr_StorageBuffer_type_StructuredBuffer_FHitGroupRootConstants = OpTypePointer StorageBuffer %type_StructuredBuffer_FHitGroupRootConstants +%HitGroupData = OpVariable %_ptr_StorageBuffer_type_StructuredBuffer_FHitGroupRootConstants StorageBuffer +%728 = OpUndef %_ptr_StorageBuffer_type_StructuredBuffer_FHitGroupRootConstants + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp new file mode 100644 index 0000000000..e6d95206e2 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-chained-access.spv16.asm.nocompat.vk.comp @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 35 +; Schema: 0 + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" %registers %gl_GlobalInvocationID %gl_LocalInvocationIndex + OpExecutionMode %main LocalSize 4 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_buffer_reference" + OpName %main "main" + OpName %Registers "Registers" + OpMemberName %Registers 0 "s" + OpName %S "S" + OpMemberName %S 0 "data" + OpName %registers "registers" + OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" + OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex" + OpMemberDecorate %Registers 0 Offset 0 + OpDecorate %Registers Block + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %S 0 Offset 0 + OpDecorate %S Block + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + %void = OpTypeVoid + %3 = OpTypeFunction %void + OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_S PhysicalStorageBuffer + %Registers = OpTypeStruct %_ptr_PhysicalStorageBuffer_S + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %S = OpTypeStruct %_runtimearr_v4float +%_ptr_PhysicalStorageBuffer_S = OpTypePointer PhysicalStorageBuffer %S +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_PushConstant__ptr_PhysicalStorageBuffer_S = OpTypePointer PushConstant %_ptr_PhysicalStorageBuffer_S + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %float_40 = OpConstant %float 40 +%_ptr_PhysicalStorageBuffer_v4float = OpTypePointer PhysicalStorageBuffer %v4float +%_ptr_PhysicalStorageBuffer_float = OpTypePointer PhysicalStorageBuffer %float + %uint_4 = OpConstant %uint 4 + %uint_1 = OpConstant %uint 1 + %34 = OpConstantComposite %v3uint %uint_4 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_S %registers %int_0 + %18 = OpLoad %_ptr_PhysicalStorageBuffer_S %17 + %25 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %26 = OpLoad %uint %25 + %28 = OpLoad %uint %gl_LocalInvocationIndex + %31 = OpAccessChain %_ptr_PhysicalStorageBuffer_v4float %18 %int_0 %26 + %32 = OpAccessChain %_ptr_PhysicalStorageBuffer_float %31 %28 + OpStore %32 %float_40 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp new file mode 100644 index 0000000000..a2981f3f15 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-plain-struct.asm.nocompat.vk.comp @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 27 +; Schema: 0 + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + OpExtension "SPV_KHR_physical_storage_buffer" + OpExtension "SPV_KHR_storage_buffer_storage_class" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_buffer_reference" + OpName %main "main" + OpName %Foo "Foo" + OpMemberName %Foo 0 "a" + OpMemberName %Foo 1 "b" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "foos" + OpMemberName %SSBO 1 "ptrfoo" + OpName %_ "" + OpMemberDecorate %Foo 0 Offset 0 + OpMemberDecorate %Foo 1 Offset 4 + OpDecorate %_arr_Foo_uint_4 ArrayStride 8 + OpMemberDecorate %SSBO 0 Offset 0 + OpMemberDecorate %SSBO 1 Offset 32 + OpDecorate %SSBO Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %Foo = OpTypeStruct %uint %uint + %uint_4 = OpConstant %uint 4 +%_arr_Foo_uint_4 = OpTypeArray %Foo %uint_4 +%_ptr_PhysicalStorageBuffer_Foo = OpTypePointer PhysicalStorageBuffer %Foo + %SSBO = OpTypeStruct %_arr_Foo_uint_4 %_ptr_PhysicalStorageBuffer_Foo +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO + %_ = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer__ptr_PhysicalStorageBuffer_Foo = OpTypePointer StorageBuffer %_ptr_PhysicalStorageBuffer_Foo + %uint_1 = OpConstant %uint 1 +%_ptr_PhysicalStorageBuffer_uint = OpTypePointer PhysicalStorageBuffer %uint + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %_ptr_StorageBuffer_uint %_ %int_0 %int_0 %int_0 + OpStore %19 %uint_0 + %22 = OpAccessChain %_ptr_StorageBuffer__ptr_PhysicalStorageBuffer_Foo %_ %int_1 + %23 = OpLoad %_ptr_PhysicalStorageBuffer_Foo %22 + %26 = OpAccessChain %_ptr_PhysicalStorageBuffer_uint %23 %int_0 + OpStore %26 %uint_1 Aligned 8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp new file mode 100644 index 0000000000..55bfea83e7 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-pointer-to-std140-std430-array.asm.spv16.nocompat.vk.comp @@ -0,0 +1,54 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 35 +; Schema: 0 + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" %registers + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_buffer_reference" + OpName %main "main" + OpName %Registers "Registers" + OpMemberName %Registers 0 "s" + OpName %registers "registers" + OpMemberDecorate %Registers 0 Offset 0 + OpDecorate %Registers Block + OpDecorate %std430array_v2float ArrayStride 8 + OpDecorate %std140array_v2float ArrayStride 16 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 + %Registers = OpTypeStruct %v2uint +%std430array_v2float = OpTypeRuntimeArray %v2float +%std140array_v2float = OpTypeRuntimeArray %v2float +%_ptr_PhysicalStorageBuffer_std430array_v2float = OpTypePointer PhysicalStorageBuffer %std430array_v2float +%_ptr_PhysicalStorageBuffer_std140array_v2float = OpTypePointer PhysicalStorageBuffer %std140array_v2float +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers +%_ptr_PushConstant_v2uint = OpTypePointer PushConstant %v2uint + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %v3uint = OpTypeVector %uint 3 + %uint_0 = OpConstant %uint 0 + %float_40 = OpConstant %float 40 +%_ptr_PhysicalStorageBuffer_v2float = OpTypePointer PhysicalStorageBuffer %v2float +%_ptr_PhysicalStorageBuffer_float = OpTypePointer PhysicalStorageBuffer %float + %main = OpFunction %void None %3 + %5 = OpLabel + %ptr_bda = OpAccessChain %_ptr_PushConstant_v2uint %registers %int_0 + %bda = OpLoad %v2uint %ptr_bda + %std430_ptr = OpBitcast %_ptr_PhysicalStorageBuffer_std430array_v2float %bda + %std140_ptr = OpBitcast %_ptr_PhysicalStorageBuffer_std140array_v2float %bda + %ptr0 = OpAccessChain %_ptr_PhysicalStorageBuffer_float %std430_ptr %uint_0 %uint_0 + %ptr1 = OpAccessChain %_ptr_PhysicalStorageBuffer_float %std140_ptr %uint_0 %uint_0 + OpStore %ptr0 %float_40 Aligned 4 + OpStore %ptr1 %float_40 Aligned 16 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp new file mode 100644 index 0000000000..d8147f47fb --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 27 +; Schema: 0 + OpCapability Shader + OpCapability Int64 + OpCapability PhysicalStorageBufferAddressesEXT + OpExtension "SPV_EXT_physical_storage_buffer" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64EXT GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_ARB_gpu_shader_int64" + OpSourceExtension "GL_EXT_buffer_reference" + OpDecorate %ptr AliasedPointerEXT + OpMemberDecorate %Registers 0 Offset 0 + OpDecorate %Registers Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_PhysicalStorageBufferEXT_uint = OpTypePointer PhysicalStorageBufferEXT %uint +%_ptr_ptr_PhysicalStorageBufferEXT_uint = OpTypePointer PhysicalStorageBufferEXT %_ptr_PhysicalStorageBufferEXT_uint +%_ptr_Function__ptr_PhysicalStorageBufferEXT_uint = OpTypePointer Function %_ptr_PhysicalStorageBufferEXT_uint + %ulong = OpTypeInt 64 0 + %Registers = OpTypeStruct %ulong +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_PushConstant_ulong = OpTypePointer PushConstant %ulong + %int_10 = OpConstant %int 10 + %uint_20 = OpConstant %uint 20 + %main = OpFunction %void None %3 + %5 = OpLabel + %ptr = OpVariable %_ptr_Function__ptr_PhysicalStorageBufferEXT_uint Function + %19 = OpAccessChain %_ptr_PushConstant_ulong %registers %int_0 + %20 = OpLoad %ulong %19 + %21 = OpConvertUToPtr %_ptr_ptr_PhysicalStorageBufferEXT_uint %20 + %loaded_ptr = OpLoad %_ptr_PhysicalStorageBufferEXT_uint %21 Aligned 8 + OpStore %ptr %loaded_ptr + %22 = OpLoad %_ptr_PhysicalStorageBufferEXT_uint %ptr + OpStore %22 %uint_20 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp new file mode 100644 index 0000000000..d791c7c423 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp @@ -0,0 +1,21 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 460 + OpName %main "main" + OpName %type_Primitive "type_Primitive" + OpName %Primitive "Primitive" + OpDecorate %type_Primitive Block + OpDecorate %Primitive DescriptorSet 0 + OpDecorate %Primitive Binding 15 + %void = OpTypeVoid + %3 = OpTypeFunction %void +%type_Primitive = OpTypeStruct +%_ptr_Uniform_type_Primitive = OpTypePointer Uniform %type_Primitive + %Primitive = OpVariable %_ptr_Uniform_type_Primitive Uniform + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp similarity index 100% rename from third_party/spirv-cross/shaders-no-opt/asm/comp/local-size-id.vk.asm.comp rename to third_party/spirv-cross/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.comp rename to third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-initializer.asm.invalid.comp diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.comp rename to third_party/spirv-cross/shaders-no-opt/asm/comp/loop-variable-early-read-with-undef.asm.invalid.comp diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag new file mode 100644 index 0000000000..700987b709 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array-uint.asm.frag @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %uint %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag new file mode 100644 index 0000000000..7d29180259 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/sample-mask-load-store-array.asm.frag @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_SampleMaskIn %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %copy_sample_mask "copy_sample_mask" + OpName %gl_SampleMaskIn "gl_SampleMaskIn" + OpName %out_sample_mask "out_sample_mask" + OpName %gl_SampleMask "gl_SampleMask" + OpDecorate %gl_SampleMaskIn Flat + OpDecorate %gl_SampleMaskIn BuiltIn SampleMask + OpDecorate %gl_SampleMask BuiltIn SampleMask + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_int_uint_1 = OpTypeArray %int %uint_1 +%_ptr_Function__arr_int_uint_1 = OpTypePointer Function %_arr_int_uint_1 + %int_0 = OpConstant %int 0 +%_ptr_Input__arr_int_uint_1 = OpTypePointer Input %_arr_int_uint_1 +%gl_SampleMaskIn = OpVariable %_ptr_Input__arr_int_uint_1 Input +%_ptr_Input_int = OpTypePointer Input %int +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Output__arr_int_uint_1 = OpTypePointer Output %_arr_int_uint_1 +%gl_SampleMask = OpVariable %_ptr_Output__arr_int_uint_1 Output +%_ptr_Output_int = OpTypePointer Output %int + %main = OpFunction %void None %3 + %5 = OpLabel +%copy_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function +%out_sample_mask = OpVariable %_ptr_Function__arr_int_uint_1 Function + + %loaded_sample_mask_in = OpLoad %_arr_int_uint_1 %gl_SampleMaskIn + OpStore %copy_sample_mask %loaded_sample_mask_in + %loaded_copy = OpLoad %_arr_int_uint_1 %copy_sample_mask + OpStore %gl_SampleMask %loaded_copy + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.frag rename to third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-arithmetic-cast.nocompat.vk.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh b/third_party/spirv-cross/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh new file mode 100644 index 0000000000..bfd3928507 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/mesh/invariant-position-dx-style.vk.nocompat.spv14.asm.mesh @@ -0,0 +1,151 @@ +; SPIR-V +; Version: 1.4 +; Generator: Unknown(30017); 21022 +; Bound: 89 +; Schema: 0 + OpCapability Shader + OpCapability Geometry + OpCapability ShaderViewportIndexLayerEXT + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpExtension "SPV_EXT_shader_viewport_index_layer" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %SV_Position %B %SV_CullPrimitive %SV_RenderTargetArrayIndex %SV_PrimitiveID %C %indices %32 %gl_LocalInvocationIndex %38 + OpExecutionMode %main OutputVertices 24 + OpExecutionMode %main OutputPrimitivesNV 8 + OpExecutionMode %main OutputTrianglesNV + OpExecutionMode %main LocalSize 2 3 4 + OpName %main "main" + OpName %SV_Position "SV_Position" + OpName %B "B" + OpName %SV_CullPrimitive "SV_CullPrimitive" + OpName %SV_RenderTargetArrayIndex "SV_RenderTargetArrayIndex" + OpName %SV_PrimitiveID "SV_PrimitiveID" + OpName %C "C" + OpName %indices "indices" + OpName %_ "" + OpDecorate %SV_Position BuiltIn Position + OpDecorate %SV_Position Invariant + OpDecorate %B Location 1 + OpDecorate %SV_CullPrimitive BuiltIn CullPrimitiveEXT + OpDecorate %SV_CullPrimitive PerPrimitiveNV + OpDecorate %SV_RenderTargetArrayIndex BuiltIn Layer + OpDecorate %SV_RenderTargetArrayIndex PerPrimitiveNV + OpDecorate %SV_PrimitiveID BuiltIn PrimitiveId + OpDecorate %SV_PrimitiveID PerPrimitiveNV + OpDecorate %C Location 3 + OpDecorate %C PerPrimitiveNV + OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + %void = OpTypeVoid + %2 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_24 = OpConstant %uint 24 +%_arr_v4float_uint_24 = OpTypeArray %v4float %uint_24 +%_ptr_Output__arr_v4float_uint_24 = OpTypePointer Output %_arr_v4float_uint_24 +%SV_Position = OpVariable %_ptr_Output__arr_v4float_uint_24 Output + %B = OpVariable %_ptr_Output__arr_v4float_uint_24 Output + %bool = OpTypeBool + %uint_8 = OpConstant %uint 8 +%_arr_bool_uint_8 = OpTypeArray %bool %uint_8 +%_ptr_Output__arr_bool_uint_8 = OpTypePointer Output %_arr_bool_uint_8 +%SV_CullPrimitive = OpVariable %_ptr_Output__arr_bool_uint_8 Output +%_arr_uint_uint_8 = OpTypeArray %uint %uint_8 +%_ptr_Output__arr_uint_uint_8 = OpTypePointer Output %_arr_uint_uint_8 +%SV_RenderTargetArrayIndex = OpVariable %_ptr_Output__arr_uint_uint_8 Output +%SV_PrimitiveID = OpVariable %_ptr_Output__arr_uint_uint_8 Output +%_arr_v4float_uint_8 = OpTypeArray %v4float %uint_8 +%_ptr_Output__arr_v4float_uint_8 = OpTypePointer Output %_arr_v4float_uint_8 + %C = OpVariable %_ptr_Output__arr_v4float_uint_8 Output + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_8 = OpTypeArray %v3uint %uint_8 +%_ptr_Output__arr_v3uint_uint_8 = OpTypePointer Output %_arr_v3uint_uint_8 + %indices = OpVariable %_ptr_Output__arr_v3uint_uint_8 Output + %uint_64 = OpConstant %uint 64 +%_arr_float_uint_64 = OpTypeArray %float %uint_64 +%_ptr_Workgroup__arr_float_uint_64 = OpTypePointer Workgroup %_arr_float_uint_64 + %32 = OpVariable %_ptr_Workgroup__arr_float_uint_64 Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %_ = OpTypeStruct %float +%_ptr_TaskPayloadWorkgroupEXT__ = OpTypePointer TaskPayloadWorkgroupEXT %_ + %38 = OpVariable %_ptr_TaskPayloadWorkgroupEXT__ TaskPayloadWorkgroupEXT +%_ptr_Workgroup_float = OpTypePointer Workgroup %float + %uint_2 = OpConstant %uint 2 + %uint_264 = OpConstant %uint 264 +%_ptr_Output_float = OpTypePointer Output %float + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 +%_ptr_TaskPayloadWorkgroupEXT_float = OpTypePointer TaskPayloadWorkgroupEXT %float +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_bool = OpTypePointer Output %bool +%_ptr_Output_uint = OpTypePointer Output %uint + %main = OpFunction %void None %2 + %4 = OpLabel + OpBranch %85 + %85 = OpLabel + %35 = OpLoad %uint %gl_LocalInvocationIndex + %39 = OpConvertUToF %float %35 + %41 = OpAccessChain %_ptr_Workgroup_float %32 %35 + OpStore %41 %39 + OpControlBarrier %uint_2 %uint_2 %uint_264 + OpSetMeshOutputsEXT %uint_24 %uint_8 + %44 = OpLoad %float %41 + %46 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_0 + OpStore %46 %44 + %48 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_1 + OpStore %48 %44 + %50 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_2 + OpStore %50 %44 + %51 = OpAccessChain %_ptr_Output_float %SV_Position %35 %uint_3 + OpStore %51 %44 + %53 = OpBitwiseXor %uint %35 %uint_1 + %54 = OpAccessChain %_ptr_Workgroup_float %32 %53 + %55 = OpLoad %float %54 + %57 = OpInBoundsAccessChain %_ptr_TaskPayloadWorkgroupEXT_float %38 %uint_0 + %58 = OpLoad %float %57 + %59 = OpFAdd %float %58 %55 + %60 = OpAccessChain %_ptr_Output_float %B %35 %uint_0 + OpStore %60 %59 + %61 = OpAccessChain %_ptr_Output_float %B %35 %uint_1 + OpStore %61 %59 + %62 = OpAccessChain %_ptr_Output_float %B %35 %uint_2 + OpStore %62 %59 + %63 = OpAccessChain %_ptr_Output_float %B %35 %uint_3 + OpStore %63 %59 + %64 = OpULessThan %bool %35 %uint_8 + OpSelectionMerge %87 None + OpBranchConditional %64 %86 %87 + %86 = OpLabel + %65 = OpIMul %uint %35 %uint_3 + %66 = OpIAdd %uint %65 %uint_1 + %67 = OpIAdd %uint %65 %uint_2 + %68 = OpCompositeConstruct %v3uint %65 %66 %67 + %70 = OpAccessChain %_ptr_Output_v3uint %indices %35 + OpStore %70 %68 + %71 = OpBitwiseAnd %uint %35 %uint_1 + %72 = OpINotEqual %bool %71 %uint_0 + %74 = OpAccessChain %_ptr_Output_bool %SV_CullPrimitive %35 + OpStore %74 %72 + %76 = OpAccessChain %_ptr_Output_uint %SV_PrimitiveID %35 + OpStore %76 %35 + %77 = OpAccessChain %_ptr_Output_uint %SV_RenderTargetArrayIndex %35 + OpStore %77 %35 + %78 = OpBitwiseXor %uint %35 %uint_2 + %79 = OpAccessChain %_ptr_Workgroup_float %32 %78 + %80 = OpLoad %float %79 + %81 = OpAccessChain %_ptr_Output_float %C %35 %uint_0 + OpStore %81 %80 + %82 = OpAccessChain %_ptr_Output_float %C %35 %uint_1 + OpStore %82 %80 + %83 = OpAccessChain %_ptr_Output_float %C %35 %uint_2 + OpStore %83 %80 + %84 = OpAccessChain %_ptr_Output_float %C %35 %uint_3 + OpStore %84 %80 + OpBranch %87 + %87 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh b/third_party/spirv-cross/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh new file mode 100644 index 0000000000..14a4f2fd3b --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/mesh/mesh-shader-clip-cull.vk.nocompat.spv14.asm.mesh @@ -0,0 +1,104 @@ +; SPIR-V +; Version: 1.4 +; Generator: Unknown(30017); 21022 +; Bound: 62 +; Schema: 0 + OpCapability Shader + OpCapability ClipDistance + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %SV_Position %B %gl_ClipDistance %indices %gl_LocalInvocationIndex + OpExecutionMode %main OutputVertices 32 + OpExecutionMode %main OutputPrimitivesNV 30 + OpExecutionMode %main OutputTrianglesNV + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + OpName %SV_Position "SV_Position" + OpName %B "B" + OpName %indices "indices" + OpDecorate %SV_Position BuiltIn Position + OpDecorate %B Location 2 + OpDecorate %gl_ClipDistance BuiltIn ClipDistance + OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + %void = OpTypeVoid + %2 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_32 = OpConstant %uint 32 +%_arr_v4float_uint_32 = OpTypeArray %v4float %uint_32 +%_ptr_Output__arr_v4float_uint_32 = OpTypePointer Output %_arr_v4float_uint_32 +%SV_Position = OpVariable %_ptr_Output__arr_v4float_uint_32 Output + %B = OpVariable %_ptr_Output__arr_v4float_uint_32 Output + %uint_4 = OpConstant %uint 4 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_arr__arr_float_uint_4_uint_32 = OpTypeArray %_arr_float_uint_4 %uint_32 +%_ptr_Output__arr__arr_float_uint_4_uint_32 = OpTypePointer Output %_arr__arr_float_uint_4_uint_32 +%gl_ClipDistance = OpVariable %_ptr_Output__arr__arr_float_uint_4_uint_32 Output + %uint_30 = OpConstant %uint 30 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_30 = OpTypeArray %v3uint %uint_30 +%_ptr_Output__arr_v3uint_uint_30 = OpTypePointer Output %_arr_v3uint_uint_30 + %indices = OpVariable %_ptr_Output__arr_v3uint_uint_30 Output +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input +%_ptr_Output_float = OpTypePointer Output %float + %uint_0 = OpConstant %uint 0 + %float_1 = OpConstant %float 1 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 +%uint_4294967295 = OpConstant %uint 4294967295 + %float_0_5 = OpConstant %float 0.5 + %float_2 = OpConstant %float 2 + %bool = OpTypeBool +%_ptr_Output_v3uint = OpTypePointer Output %v3uint + %main = OpFunction %void None %2 + %4 = OpLabel + OpBranch %58 + %58 = OpLabel + %25 = OpLoad %uint %gl_LocalInvocationIndex + OpSetMeshOutputsEXT %uint_32 %uint_30 + %27 = OpAccessChain %_ptr_Output_float %SV_Position %25 %uint_0 + OpStore %27 %float_1 + %30 = OpAccessChain %_ptr_Output_float %SV_Position %25 %uint_1 + OpStore %30 %float_1 + %32 = OpAccessChain %_ptr_Output_float %SV_Position %25 %uint_2 + OpStore %32 %float_1 + %34 = OpAccessChain %_ptr_Output_float %SV_Position %25 %uint_3 + OpStore %34 %float_1 + %36 = OpShiftLeftLogical %uint %25 %uint_1 + %37 = OpIAdd %uint %36 %uint_4294967295 + %39 = OpConvertSToF %float %37 + %40 = OpFMul %float %39 %float_0_5 + %42 = OpAccessChain %_ptr_Output_float %gl_ClipDistance %25 %uint_0 + OpStore %42 %40 + %43 = OpAccessChain %_ptr_Output_float %gl_ClipDistance %25 %uint_1 + OpStore %43 %40 + %44 = OpAccessChain %_ptr_Output_float %gl_ClipDistance %25 %uint_2 + OpStore %44 %40 + %45 = OpAccessChain %_ptr_Output_float %gl_ClipDistance %25 %uint_3 + OpStore %45 %40 + %46 = OpAccessChain %_ptr_Output_float %B %25 %uint_0 + OpStore %46 %float_2 + %48 = OpAccessChain %_ptr_Output_float %B %25 %uint_1 + OpStore %48 %float_2 + %49 = OpAccessChain %_ptr_Output_float %B %25 %uint_2 + OpStore %49 %float_2 + %50 = OpAccessChain %_ptr_Output_float %B %25 %uint_3 + OpStore %50 %float_2 + %52 = OpULessThan %bool %25 %uint_30 + OpSelectionMerge %60 None + OpBranchConditional %52 %59 %60 + %59 = OpLabel + %53 = OpIAdd %uint %25 %uint_1 + %54 = OpIAdd %uint %25 %uint_2 + %55 = OpCompositeConstruct %v3uint %25 %53 %54 + %57 = OpAccessChain %_ptr_Output_v3uint %indices %25 + OpStore %57 %55 + OpBranch %60 + %60 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag b/third_party/spirv-cross/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag new file mode 100644 index 0000000000..8dffccc283 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/mesh-shader-perprimitive.spv14.nocompat.vk.frag @@ -0,0 +1,10 @@ +#version 450 +#extension GL_EXT_mesh_shader : require + +layout(location = 0) perprimitiveEXT flat in uvec4 v; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(v); +} diff --git a/third_party/spirv-cross/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh b/third_party/spirv-cross/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh new file mode 100644 index 0000000000..9ce59eb995 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/mesh/invariant-position-mesh.spv14.nocompat.vk.mesh @@ -0,0 +1,18 @@ +#version 450 +#extension GL_EXT_mesh_shader : require +layout(max_vertices = 3, max_primitives = 1, triangles) out; +layout(local_size_x = 1) in; + +out gl_MeshPerVertexEXT +{ + invariant vec4 gl_Position; +} gl_MeshVerticesEXT[3]; + +void main() +{ + SetMeshOutputsEXT(3, 1); + gl_MeshVerticesEXT[0].gl_Position = vec4(1.0); + gl_MeshVerticesEXT[1].gl_Position = vec4(1.0); + gl_MeshVerticesEXT[2].gl_Position = vec4(1.0); + gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0, 1, 2); +} diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp new file mode 100644 index 0000000000..1ef6d45e6d --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/image-64bit.vk.nocompat.comp @@ -0,0 +1,16 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +#extension GL_EXT_shader_image_int64 : require +layout(local_size_x = 1) in; + +layout(set = 0, binding = 0, r64ui) uniform u64image2D uimg; +layout(set = 0, binding = 1, r64i) uniform i64image2D iimg; + +void main() +{ + uint64_t uv = imageLoad(uimg, ivec2(gl_GlobalInvocationID.xy + 50)).x; + int64_t iv = imageLoad(iimg, ivec2(gl_GlobalInvocationID.xy + 50)).x; + + uv = imageAtomicMax(uimg, ivec2(gl_GlobalInvocationID.xy), uv); + iv = imageAtomicMax(iimg, ivec2(gl_GlobalInvocationID.xy), iv); +} diff --git a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh index 0f1beef75b..70a612b009 100644 --- a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh @@ -1,5 +1,6 @@ #version 450 #extension GL_EXT_mesh_shader : require +#extension GL_EXT_fragment_shading_rate : require layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; layout(lines, max_vertices = 24, max_primitives = 22) out; diff --git a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh index 3d037bcd5e..247ce4493d 100644 --- a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh @@ -1,5 +1,6 @@ #version 450 #extension GL_EXT_mesh_shader : require +#extension GL_EXT_fragment_shading_rate : require layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; layout(points, max_vertices = 24, max_primitives = 22) out; diff --git a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh index 944525aa50..80ffdb3ada 100644 --- a/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh @@ -1,5 +1,6 @@ #version 450 #extension GL_EXT_mesh_shader : require +#extension GL_EXT_fragment_shading_rate : require layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in; layout(triangles, max_vertices = 24, max_primitives = 22) out; diff --git a/third_party/spirv-cross/shaders/tese/read-patch-vertices-in-func.tese b/third_party/spirv-cross/shaders/tese/read-patch-vertices-in-func.tese new file mode 100644 index 0000000000..613f8f039d --- /dev/null +++ b/third_party/spirv-cross/shaders/tese/read-patch-vertices-in-func.tese @@ -0,0 +1,12 @@ +#version 450 +layout(quads) in; + +vec4 read_patch_vertices() +{ + return vec4(gl_PatchVerticesIn, 0, 0, 1); +} + +void main() +{ + gl_Position = read_patch_vertices(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/frag/block-match-sad.frag b/third_party/spirv-cross/shaders/vulkan/frag/block-match-sad.frag new file mode 100644 index 0000000000..832f59d491 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/frag/block-match-sad.frag @@ -0,0 +1,38 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D target_samp; +layout(set = 0, binding = 5) uniform sampler2D ref_samp; + +void main() +{ + + uvec2 tgt_coords; tgt_coords.x = uint(v_texcoord.x); tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; ref_coords.x = uint(v_texcoord.z); ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4, 4); + fragColor = textureBlockMatchSADQCOM( + sampler2D(tex2D_src1, samp), // target texture + tgt_coords, // target coords + sampler2D(tex2D_src2, samp), // reference texture + ref_coords, // reference coords + blockSize); // block size + fragColor = textureBlockMatchSADQCOM( + target_samp, // target texture + tgt_coords, // target coords + ref_samp, // reference texture + ref_coords, // reference coords + blockSize); // block size +} + diff --git a/third_party/spirv-cross/shaders/vulkan/frag/block-match-ssd.frag b/third_party/spirv-cross/shaders/vulkan/frag/block-match-ssd.frag new file mode 100644 index 0000000000..aa3ff2a951 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/frag/block-match-ssd.frag @@ -0,0 +1,38 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D target_samp; +layout(set = 0, binding = 5) uniform sampler2D ref_samp; + +void main() +{ + + uvec2 tgt_coords; tgt_coords.x = uint(v_texcoord.x); tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; ref_coords.x = uint(v_texcoord.z); ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4, 4); + fragColor = textureBlockMatchSSDQCOM( + sampler2D(tex2D_src1, samp), // target texture + tgt_coords, // target coords + sampler2D(tex2D_src2, samp), // reference texture + ref_coords, // reference coords + blockSize); // block size + fragColor = textureBlockMatchSSDQCOM( + target_samp, // target texture + tgt_coords, // target coords + ref_samp, // reference texture + ref_coords, // reference coords + blockSize); // block size +} + diff --git a/third_party/spirv-cross/shaders/vulkan/frag/box-filter.frag b/third_party/spirv-cross/shaders/vulkan/frag/box-filter.frag new file mode 100644 index 0000000000..d86d531e25 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/frag/box-filter.frag @@ -0,0 +1,32 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D tex_samp; + +void main() +{ + + vec2 boxSize = vec2(2.5, 4.5); + fragColor = textureBoxFilterQCOM( + sampler2D(tex2D_src1, samp), // source texture + v_texcoord.xy, // tex coords + boxSize); // box size + fragColor = textureBoxFilterQCOM( + tex_samp, // combined source texture + v_texcoord.xy, // tex coords + boxSize); // box size + +} + diff --git a/third_party/spirv-cross/shaders/vulkan/frag/sample-weighted.frag b/third_party/spirv-cross/shaders/vulkan/frag/sample-weighted.frag new file mode 100644 index 0000000000..0d10028936 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/frag/sample-weighted.frag @@ -0,0 +1,32 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D tex_samp; +layout(set = 0, binding = 5) uniform sampler2DArray tex_samp_array; + +void main() +{ + + fragColor = textureWeightedQCOM( + sampler2D(tex2D_src1, samp), // source texture + v_texcoord.xy, // tex coords + sampler2DArray(tex2DArray_weights, samp)); // weight texture + fragColor = textureWeightedQCOM( + tex_samp, // combined source texture + v_texcoord.xy, // tex coords + tex_samp_array); // combined weight texture + +} + diff --git a/third_party/spirv-cross/spirv.h b/third_party/spirv-cross/spirv.h index 5b6e8aaf47..2d6e215de9 100644 --- a/third_party/spirv-cross/spirv.h +++ b/third_party/spirv-cross/spirv.h @@ -509,6 +509,8 @@ typedef enum SpvDecoration_ { SpvDecorationMaxByteOffsetId = 47, SpvDecorationNoSignedWrap = 4469, SpvDecorationNoUnsignedWrap = 4470, + SpvDecorationWeightTextureQCOM = 4487, + SpvDecorationBlockMatchTextureQCOM = 4488, SpvDecorationExplicitInterpAMD = 4999, SpvDecorationOverrideCoverageNV = 5248, SpvDecorationPassthroughNV = 5250, @@ -991,6 +993,9 @@ typedef enum SpvCapability_ { SpvCapabilityRayQueryKHR = 4472, SpvCapabilityRayTraversalPrimitiveCullingKHR = 4478, SpvCapabilityRayTracingKHR = 4479, + SpvCapabilityTextureSampleWeightedQCOM = 4484, + SpvCapabilityTextureBoxFilterQCOM = 4485, + SpvCapabilityTextureBlockMatchQCOM = 4486, SpvCapabilityFloat16ImageAMD = 5008, SpvCapabilityImageGatherBiasLodAMD = 5009, SpvCapabilityFragmentMaskAMD = 5010, @@ -1596,6 +1601,10 @@ typedef enum SpvOp_ { SpvOpRayQueryConfirmIntersectionKHR = 4476, SpvOpRayQueryProceedKHR = 4477, SpvOpRayQueryGetIntersectionTypeKHR = 4479, + SpvOpImageSampleWeightedQCOM = 4480, + SpvOpImageBoxFilterQCOM = 4481, + SpvOpImageBlockMatchSSDQCOM = 4482, + SpvOpImageBlockMatchSADQCOM = 4483, SpvOpGroupIAddNonUniformAMD = 5000, SpvOpGroupFAddNonUniformAMD = 5001, SpvOpGroupFMinNonUniformAMD = 5002, @@ -2271,6 +2280,10 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; case SpvOpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case SpvOpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case SpvOpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; diff --git a/third_party/spirv-cross/spirv.hpp b/third_party/spirv-cross/spirv.hpp index e25264af28..f2ee9096bd 100644 --- a/third_party/spirv-cross/spirv.hpp +++ b/third_party/spirv-cross/spirv.hpp @@ -505,6 +505,8 @@ enum Decoration { DecorationMaxByteOffsetId = 47, DecorationNoSignedWrap = 4469, DecorationNoUnsignedWrap = 4470, + DecorationWeightTextureQCOM = 4487, + DecorationBlockMatchTextureQCOM = 4488, DecorationExplicitInterpAMD = 4999, DecorationOverrideCoverageNV = 5248, DecorationPassthroughNV = 5250, @@ -987,6 +989,9 @@ enum Capability { CapabilityRayQueryKHR = 4472, CapabilityRayTraversalPrimitiveCullingKHR = 4478, CapabilityRayTracingKHR = 4479, + CapabilityTextureSampleWeightedQCOM = 4484, + CapabilityTextureBoxFilterQCOM = 4485, + CapabilityTextureBlockMatchQCOM = 4486, CapabilityFloat16ImageAMD = 5008, CapabilityImageGatherBiasLodAMD = 5009, CapabilityFragmentMaskAMD = 5010, @@ -1592,6 +1597,10 @@ enum Op { OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -2267,6 +2276,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case OpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; case OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; diff --git a/third_party/spirv-cross/spirv_common.hpp b/third_party/spirv-cross/spirv_common.hpp index 7fb23fa360..c1b22a768b 100644 --- a/third_party/spirv-cross/spirv_common.hpp +++ b/third_party/spirv-cross/spirv_common.hpp @@ -220,7 +220,7 @@ static inline std::string convert_to_string(int32_t value) // INT_MIN is ... special on some backends. If we use a decimal literal, and negate it, we // could accidentally promote the literal to long first, then negate. // To workaround it, emit int(0x80000000) instead. - if (value == std::numeric_limits::min()) + if (value == (std::numeric_limits::min)()) return "int(0x80000000)"; else return std::to_string(value); @@ -231,7 +231,7 @@ static inline std::string convert_to_string(int64_t value, const std::string &in // INT64_MIN is ... special on some backends. // If we use a decimal literal, and negate it, we might overflow the representable numbers. // To workaround it, emit int(0x80000000) instead. - if (value == std::numeric_limits::min()) + if (value == (std::numeric_limits::min)()) return join(int64_type, "(0x8000000000000000u", (long_long_literal_suffix ? "ll" : "l"), ")"); else return std::to_string(value) + (long_long_literal_suffix ? "ll" : "l"); @@ -316,6 +316,20 @@ inline std::string convert_to_string(double t, char locale_radix_point) return buf; } +#if defined(__clang__) || defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif + +class FloatFormatter +{ +public: + virtual ~FloatFormatter() = default; + virtual std::string format_float(float value) = 0; + virtual std::string format_double(double value) = 0; +}; + template struct ValueSaver { @@ -339,12 +353,6 @@ struct ValueSaver T saved; }; -#if defined(__clang__) || defined(__GNUC__) -#pragma GCC diagnostic pop -#elif defined(_MSC_VER) -#pragma warning(pop) -#endif - struct Instruction { uint16_t op = 0; @@ -561,6 +569,9 @@ struct SPIRType : IVariant type = TypeType }; + spv::Op op = spv::Op::OpNop; + explicit SPIRType(spv::Op op_) : op(op_) {} + enum BaseType { Unknown, @@ -631,7 +642,7 @@ struct SPIRType : IVariant uint32_t sampled; spv::ImageFormat format; spv::AccessQualifier access; - } image; + } image = {}; // Structs can be declared multiple times if they are used as part of interface blocks. // We want to detect this so that we only emit the struct definition once. @@ -750,6 +761,9 @@ struct SPIRExpression : IVariant // Whether or not this is an access chain expression. bool access_chain = false; + // Whether or not gl_MeshVerticesEXT[].gl_Position (as a whole or .y) is referenced + bool access_meshlet_position_y = false; + // A list of expressions which this expression depends on. SmallVector expression_dependencies; @@ -1601,6 +1615,7 @@ struct AccessChainMeta bool storage_is_invariant = false; bool flattened_struct = false; bool relaxed_precision = false; + bool access_meshlet_position_y = false; }; enum ExtendedDecorations @@ -1702,6 +1717,7 @@ struct Meta uint32_t index = 0; spv::FPRoundingMode fp_rounding_mode = spv::FPRoundingModeMax; bool builtin = false; + bool qualified_alias_explicit_override = false; struct Extended { diff --git a/third_party/spirv-cross/spirv_common.hpp.orig b/third_party/spirv-cross/spirv_common.hpp.orig index 0264e8185e..51fffe7a13 100644 --- a/third_party/spirv-cross/spirv_common.hpp.orig +++ b/third_party/spirv-cross/spirv_common.hpp.orig @@ -220,7 +220,7 @@ static inline std::string convert_to_string(int32_t value) // INT_MIN is ... special on some backends. If we use a decimal literal, and negate it, we // could accidentally promote the literal to long first, then negate. // To workaround it, emit int(0x80000000) instead. - if (value == std::numeric_limits::min()) + if (value == (std::numeric_limits::min)()) return "int(0x80000000)"; else return std::to_string(value); @@ -231,7 +231,7 @@ static inline std::string convert_to_string(int64_t value, const std::string &in // INT64_MIN is ... special on some backends. // If we use a decimal literal, and negate it, we might overflow the representable numbers. // To workaround it, emit int(0x80000000) instead. - if (value == std::numeric_limits::min()) + if (value == (std::numeric_limits::min)()) return join(int64_type, "(0x8000000000000000u", (long_long_literal_suffix ? "ll" : "l"), ")"); else return std::to_string(value) + (long_long_literal_suffix ? "ll" : "l"); @@ -295,6 +295,20 @@ inline std::string convert_to_string(double t, char locale_radix_point) return buf; } +#if defined(__clang__) || defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif + +class FloatFormatter +{ +public: + virtual ~FloatFormatter() = default; + virtual std::string format_float(float value) = 0; + virtual std::string format_double(double value) = 0; +}; + template struct ValueSaver { @@ -318,12 +332,6 @@ struct ValueSaver T saved; }; -#if defined(__clang__) || defined(__GNUC__) -#pragma GCC diagnostic pop -#elif defined(_MSC_VER) -#pragma warning(pop) -#endif - struct Instruction { uint16_t op = 0; @@ -540,6 +548,9 @@ struct SPIRType : IVariant type = TypeType }; + spv::Op op = spv::Op::OpNop; + explicit SPIRType(spv::Op op_) : op(op_) {} + enum BaseType { Unknown, @@ -610,7 +621,7 @@ struct SPIRType : IVariant uint32_t sampled; spv::ImageFormat format; spv::AccessQualifier access; - } image; + } image = {}; // Structs can be declared multiple times if they are used as part of interface blocks. // We want to detect this so that we only emit the struct definition once. @@ -729,6 +740,9 @@ struct SPIRExpression : IVariant // Whether or not this is an access chain expression. bool access_chain = false; + // Whether or not gl_MeshVerticesEXT[].gl_Position (as a whole or .y) is referenced + bool access_meshlet_position_y = false; + // A list of expressions which this expression depends on. SmallVector expression_dependencies; @@ -1580,6 +1594,7 @@ struct AccessChainMeta bool storage_is_invariant = false; bool flattened_struct = false; bool relaxed_precision = false; + bool access_meshlet_position_y = false; }; enum ExtendedDecorations @@ -1681,6 +1696,7 @@ struct Meta uint32_t index = 0; spv::FPRoundingMode fp_rounding_mode = spv::FPRoundingModeMax; bool builtin = false; + bool qualified_alias_explicit_override = false; struct Extended { diff --git a/third_party/spirv-cross/spirv_cross.cpp b/third_party/spirv-cross/spirv_cross.cpp index 49cc838682..3f0fec334a 100644 --- a/third_party/spirv-cross/spirv_cross.cpp +++ b/third_party/spirv-cross/spirv_cross.cpp @@ -627,7 +627,29 @@ bool Compiler::is_matrix(const SPIRType &type) const bool Compiler::is_array(const SPIRType &type) const { - return !type.array.empty(); + return type.op == OpTypeArray || type.op == OpTypeRuntimeArray; +} + +bool Compiler::is_pointer(const SPIRType &type) const +{ + return type.op == OpTypePointer && type.basetype != SPIRType::Unknown; // Ignore function pointers. +} + +bool Compiler::is_physical_pointer(const SPIRType &type) const +{ + return type.op == OpTypePointer && type.storage == StorageClassPhysicalStorageBuffer; +} + +bool Compiler::is_physical_pointer_to_buffer_block(const SPIRType &type) const +{ + return is_physical_pointer(type) && get_pointee_type(type).self == type.parent_type && + (has_decoration(type.self, DecorationBlock) || + has_decoration(type.self, DecorationBufferBlock)); +} + +bool Compiler::is_runtime_size_array(const SPIRType &type) +{ + return type.op == OpTypeRuntimeArray; } ShaderResources Compiler::get_shader_resources() const @@ -995,57 +1017,70 @@ ShaderResources Compiler::get_shader_resources(const unordered_set * { res.shader_record_buffers.push_back({ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, ssbo_instance_name) }); } - // Images - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && - type.image.sampled == 2) - { - res.storage_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); - } - // Separate images - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && - type.image.sampled == 1) - { - res.separate_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); - } - // Separate samplers - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Sampler) - { - res.separate_samplers.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); - } - // Textures - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage) - { - res.sampled_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); - } // Atomic counters else if (type.storage == StorageClassAtomicCounter) { res.atomic_counters.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); } - // Acceleration structures - else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::AccelerationStructure) + else if (type.storage == StorageClassUniformConstant) { - res.acceleration_structures.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + if (type.basetype == SPIRType::Image) + { + // Images + if (type.image.sampled == 2) + { + res.storage_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } + // Separate images + else if (type.image.sampled == 1) + { + res.separate_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } + } + // Separate samplers + else if (type.basetype == SPIRType::Sampler) + { + res.separate_samplers.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } + // Textures + else if (type.basetype == SPIRType::SampledImage) + { + res.sampled_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } + // Acceleration structures + else if (type.basetype == SPIRType::AccelerationStructure) + { + res.acceleration_structures.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } + else + { + res.gl_plain_uniforms.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); + } } }); return res; } -bool Compiler::type_is_block_like(const SPIRType &type) const +bool Compiler::type_is_top_level_block(const SPIRType &type) const { if (type.basetype != SPIRType::Struct) return false; + return has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); +} - if (has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock)) - { +bool Compiler::type_is_block_like(const SPIRType &type) const +{ + if (type_is_top_level_block(type)) return true; - } - // Block-like types may have Offset decorations. - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) - if (has_member_decoration(type.self, i, DecorationOffset)) - return true; + if (type.basetype == SPIRType::Struct) + { + // Block-like types may have Offset decorations. + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + if (has_member_decoration(type.self, i, DecorationOffset)) + return true; + } return false; } @@ -2717,8 +2752,8 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR auto ptr_type_id = id + 1; auto combined_id = id + 2; auto &base = compiler.expression_type(image_id); - auto &type = compiler.set(type_id); - auto &ptr_type = compiler.set(ptr_type_id); + auto &type = compiler.set(type_id, OpTypeSampledImage); + auto &ptr_type = compiler.set(ptr_type_id, OpTypePointer); type = base; type.self = type_id; @@ -2977,7 +3012,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar { // Have to invent the sampled image type. sampled_type = compiler.ir.increase_bound_by(1); - auto &type = compiler.set(sampled_type); + auto &type = compiler.set(sampled_type, OpTypeSampledImage); type = compiler.expression_type(args[2]); type.self = sampled_type; type.basetype = SPIRType::SampledImage; @@ -2996,7 +3031,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar // Make a new type, pointer to OpTypeSampledImage, so we can make a variable of this type. // We will probably have this type lying around, but it doesn't hurt to make duplicates for internal purposes. - auto &type = compiler.set(type_id); + auto &type = compiler.set(type_id, OpTypePointer); auto &base = compiler.get(sampled_type); type = base; type.pointer = true; @@ -3042,11 +3077,10 @@ VariableID Compiler::build_dummy_sampler_for_combined_images() auto ptr_type_id = offset + 1; auto var_id = offset + 2; - SPIRType sampler_type; - auto &sampler = set(type_id); + auto &sampler = set(type_id, OpTypeSampler); sampler.basetype = SPIRType::Sampler; - auto &ptr_sampler = set(ptr_type_id); + auto &ptr_sampler = set(ptr_type_id, OpTypePointer); ptr_sampler = sampler; ptr_sampler.self = type_id; ptr_sampler.storage = StorageClassUniformConstant; @@ -4997,8 +5031,7 @@ void Compiler::PhysicalStorageBufferPointerHandler::mark_aligned_access(uint32_t bool Compiler::PhysicalStorageBufferPointerHandler::type_is_bda_block_entry(uint32_t type_id) const { auto &type = compiler.get(type_id); - return type.storage == StorageClassPhysicalStorageBufferEXT && type.pointer && - type.pointer_depth == 1 && !compiler.type_is_array_of_pointers(type); + return compiler.is_physical_pointer(type); } uint32_t Compiler::PhysicalStorageBufferPointerHandler::get_minimum_scalar_alignment(const SPIRType &type) const @@ -5028,7 +5061,8 @@ void Compiler::PhysicalStorageBufferPointerHandler::setup_meta_chain(uint32_t ty access_chain_to_physical_block[var_id] = &meta; auto &type = compiler.get(type_id); - if (type.basetype != SPIRType::Struct) + + if (!compiler.is_physical_pointer_to_buffer_block(type)) non_block_types.insert(type_id); if (meta.alignment == 0) @@ -5087,9 +5121,7 @@ bool Compiler::PhysicalStorageBufferPointerHandler::handle(Op op, const uint32_t uint32_t Compiler::PhysicalStorageBufferPointerHandler::get_base_non_block_type_id(uint32_t type_id) const { auto *type = &compiler.get(type_id); - while (type->pointer && - type->storage == StorageClassPhysicalStorageBufferEXT && - !type_is_bda_block_entry(type_id)) + while (compiler.is_physical_pointer(*type) && !type_is_bda_block_entry(type_id)) { type_id = type->parent_type; type = &compiler.get(type_id); @@ -5104,12 +5136,10 @@ void Compiler::PhysicalStorageBufferPointerHandler::analyze_non_block_types_from for (auto &member : type.member_types) { auto &subtype = compiler.get(member); - if (subtype.basetype != SPIRType::Struct && subtype.pointer && - subtype.storage == spv::StorageClassPhysicalStorageBufferEXT) - { + + if (compiler.is_physical_pointer(subtype) && !compiler.is_physical_pointer_to_buffer_block(subtype)) non_block_types.insert(get_base_non_block_type_id(member)); - } - else if (subtype.basetype == SPIRType::Struct && !subtype.pointer) + else if (subtype.basetype == SPIRType::Struct && !compiler.is_pointer(subtype)) analyze_non_block_types_from_block(subtype); } } @@ -5122,9 +5152,14 @@ void Compiler::analyze_non_block_pointer_types() // Analyze any block declaration we have to make. It might contain // physical pointers to POD types which we never used, and thus never added to the list. // We'll need to add those pointer types to the set of types we declare. - ir.for_each_typed_id([&](uint32_t, SPIRType &type) { - if (has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock)) + ir.for_each_typed_id([&](uint32_t id, SPIRType &type) { + // Only analyze the raw block struct, not any pointer-to-struct, since that's just redundant. + if (type.self == id && + (has_decoration(type.self, DecorationBlock) || + has_decoration(type.self, DecorationBufferBlock))) + { handler.analyze_non_block_types_from_block(type); + } }); physical_storage_non_block_pointer_types.reserve(handler.non_block_types.size()); @@ -5444,9 +5479,39 @@ void Compiler::analyze_interlocked_resource_usage() } } +// Helper function +bool Compiler::check_internal_recursion(const SPIRType &type, std::unordered_set &checked_ids) +{ + if (type.basetype != SPIRType::Struct) + return false; + + if (checked_ids.count(type.self)) + return true; + + // Recurse into struct members + bool is_recursive = false; + checked_ids.insert(type.self); + uint32_t mbr_cnt = uint32_t(type.member_types.size()); + for (uint32_t mbr_idx = 0; !is_recursive && mbr_idx < mbr_cnt; mbr_idx++) + { + uint32_t mbr_type_id = type.member_types[mbr_idx]; + auto &mbr_type = get(mbr_type_id); + is_recursive |= check_internal_recursion(mbr_type, checked_ids); + } + checked_ids.erase(type.self); + return is_recursive; +} + +// Return whether the struct type contains a structural recursion nested somewhere within its content. +bool Compiler::type_contains_recursion(const SPIRType &type) +{ + std::unordered_set checked_ids; + return check_internal_recursion(type, checked_ids); +} + bool Compiler::type_is_array_of_pointers(const SPIRType &type) const { - if (!type_is_top_level_array(type)) + if (!is_array(type)) return false; // BDA types must have parent type hierarchy. @@ -5455,45 +5520,10 @@ bool Compiler::type_is_array_of_pointers(const SPIRType &type) const // Punch through all array layers. auto *parent = &get(type.parent_type); - while (type_is_top_level_array(*parent)) + while (is_array(*parent)) parent = &get(parent->parent_type); - return type_is_top_level_pointer(*parent); -} - -bool Compiler::type_is_top_level_pointer(const SPIRType &type) const -{ - if (!type.pointer) - return false; - - // Function pointers, should not be hit by valid SPIR-V. - // Parent type will be SPIRFunction instead. - if (type.basetype == SPIRType::Unknown) - return false; - - // Some types are synthesized in-place without complete type hierarchy and might not have parent types, - // but these types are never array-of-pointer or any complicated BDA type, infer reasonable defaults. - if (type.parent_type) - return type.pointer_depth > get(type.parent_type).pointer_depth; - else - return true; -} - -bool Compiler::type_is_top_level_physical_pointer(const SPIRType &type) const -{ - return type_is_top_level_pointer(type) && type.storage == StorageClassPhysicalStorageBuffer; -} - -bool Compiler::type_is_top_level_array(const SPIRType &type) const -{ - if (type.array.empty()) - return false; - - // If we have pointer and array, we infer pointer-to-array as it's the only meaningful thing outside BDA. - if (type.parent_type) - return type.array.size() > get(type.parent_type).array.size(); - else - return !type.pointer; + return is_pointer(*parent); } bool Compiler::flush_phi_required(BlockID from, BlockID to) const diff --git a/third_party/spirv-cross/spirv_cross.hpp b/third_party/spirv-cross/spirv_cross.hpp index b99b7ae7a2..2ba6025021 100644 --- a/third_party/spirv-cross/spirv_cross.hpp +++ b/third_party/spirv-cross/spirv_cross.hpp @@ -94,6 +94,7 @@ struct ShaderResources SmallVector sampled_images; SmallVector atomic_counters; SmallVector acceleration_structures; + SmallVector gl_plain_uniforms; // There can only be one push constant block, // but keep the vector in case this restriction is lifted in the future. @@ -682,6 +683,10 @@ protected: bool is_vector(const SPIRType &type) const; bool is_matrix(const SPIRType &type) const; bool is_array(const SPIRType &type) const; + bool is_pointer(const SPIRType &type) const; + bool is_physical_pointer(const SPIRType &type) const; + bool is_physical_pointer_to_buffer_block(const SPIRType &type) const; + static bool is_runtime_size_array(const SPIRType &type); 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; @@ -1143,11 +1148,11 @@ protected: bool has_extended_member_decoration(uint32_t type, uint32_t index, ExtendedDecorations decoration) const; void unset_extended_member_decoration(uint32_t type, uint32_t index, ExtendedDecorations decoration); + bool check_internal_recursion(const SPIRType &type, std::unordered_set &checked_ids); + bool type_contains_recursion(const SPIRType &type); bool type_is_array_of_pointers(const SPIRType &type) const; - bool type_is_top_level_physical_pointer(const SPIRType &type) const; - bool type_is_top_level_pointer(const SPIRType &type) const; - bool type_is_top_level_array(const SPIRType &type) const; bool type_is_block_like(const SPIRType &type) const; + bool type_is_top_level_block(const SPIRType &type) const; bool type_is_opaque_value(const SPIRType &type) const; bool reflection_ssbo_instance_name_is_significant() const; diff --git a/third_party/spirv-cross/spirv_cross.natvis b/third_party/spirv-cross/spirv_cross.natvis new file mode 100644 index 0000000000..eea0930ad5 --- /dev/null +++ b/third_party/spirv-cross/spirv_cross.natvis @@ -0,0 +1,39 @@ + + + + + {{size = {buffer_size}}} + + buffer_size + + buffer_size + ptr + + + + + {{size = {buffer_size}}} + + buffer_size + + buffer_size + ptr + + + + \ No newline at end of file diff --git a/third_party/spirv-cross/spirv_cross_c.cpp b/third_party/spirv-cross/spirv_cross_c.cpp index c21fdeb6ed..679333dac9 100644 --- a/third_party/spirv-cross/spirv_cross_c.cpp +++ b/third_party/spirv-cross/spirv_cross_c.cpp @@ -742,6 +742,18 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c case SPVC_COMPILER_OPTION_MSL_SAMPLE_DREF_LOD_ARRAY_AS_GRAD: options->msl.sample_dref_lod_array_as_grad = value != 0; break; + + case SPVC_COMPILER_OPTION_MSL_READWRITE_TEXTURE_FENCES: + options->msl.readwrite_texture_fences = value != 0; + break; + + case SPVC_COMPILER_OPTION_MSL_REPLACE_RECURSIVE_INPUTS: + options->msl.replace_recursive_inputs = value != 0; + break; + + case SPVC_COMPILER_OPTION_MSL_AGX_MANUAL_CUBE_GRAD_FIXUP: + options->msl.agx_manual_cube_grad_fixup = value != 0; + break; #endif default: @@ -2540,6 +2552,16 @@ int spvc_constant_get_scalar_i32(spvc_constant constant, unsigned column, unsign return constant->scalar_i32(column, row); } +unsigned long long spvc_constant_get_scalar_u64(spvc_constant constant, unsigned column, unsigned row) +{ + return constant->scalar_u64(column, row); +} + +long long spvc_constant_get_scalar_i64(spvc_constant constant, unsigned column, unsigned row) +{ + return constant->scalar_i64(column, row); +} + unsigned spvc_constant_get_scalar_u16(spvc_constant constant, unsigned column, unsigned row) { return constant->scalar_u16(column, row); @@ -2597,6 +2619,16 @@ void spvc_constant_set_scalar_i32(spvc_constant constant, unsigned column, unsig constant->m.c[column].r[row].i32 = value; } +void spvc_constant_set_scalar_u64(spvc_constant constant, unsigned column, unsigned row, unsigned long long value) +{ + constant->m.c[column].r[row].u64 = value; +} + +void spvc_constant_set_scalar_i64(spvc_constant constant, unsigned column, unsigned row, long long value) +{ + constant->m.c[column].r[row].i64 = value; +} + void spvc_constant_set_scalar_u16(spvc_constant constant, unsigned column, unsigned row, unsigned short value) { constant->m.c[column].r[row].u32 = uint32_t(value); diff --git a/third_party/spirv-cross/spirv_cross_c.h b/third_party/spirv-cross/spirv_cross_c.h index 0d8e6e10a6..47369964ab 100644 --- a/third_party/spirv-cross/spirv_cross_c.h +++ b/third_party/spirv-cross/spirv_cross_c.h @@ -40,7 +40,7 @@ extern "C" { /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ -#define SPVC_C_API_VERSION_MINOR 57 +#define SPVC_C_API_VERSION_MINOR 59 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 @@ -725,6 +725,9 @@ typedef enum spvc_compiler_option SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS_TIER = 84 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SAMPLE_DREF_LOD_ARRAY_AS_GRAD = 85 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_READWRITE_TEXTURE_FENCES = 86 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_REPLACE_RECURSIVE_INPUTS = 87 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_AGX_MANUAL_CUBE_GRAD_FIXUP = 88 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff } spvc_compiler_option; @@ -1049,6 +1052,8 @@ SPVC_PUBLIC_API int spvc_constant_get_scalar_i16(spvc_constant constant, unsigne SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u8(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API int spvc_constant_get_scalar_i8(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API void spvc_constant_get_subconstants(spvc_constant constant, const spvc_constant_id **constituents, size_t *count); +SPVC_PUBLIC_API unsigned long long spvc_constant_get_scalar_u64(spvc_constant constant, unsigned column, unsigned row); +SPVC_PUBLIC_API long long spvc_constant_get_scalar_i64(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API spvc_type_id spvc_constant_get_type(spvc_constant constant); /* @@ -1059,6 +1064,8 @@ SPVC_PUBLIC_API void spvc_constant_set_scalar_fp32(spvc_constant constant, unsig SPVC_PUBLIC_API void spvc_constant_set_scalar_fp64(spvc_constant constant, unsigned column, unsigned row, double value); SPVC_PUBLIC_API void spvc_constant_set_scalar_u32(spvc_constant constant, unsigned column, unsigned row, unsigned value); SPVC_PUBLIC_API void spvc_constant_set_scalar_i32(spvc_constant constant, unsigned column, unsigned row, int value); +SPVC_PUBLIC_API void spvc_constant_set_scalar_u64(spvc_constant constant, unsigned column, unsigned row, unsigned long long value); +SPVC_PUBLIC_API void spvc_constant_set_scalar_i64(spvc_constant constant, unsigned column, unsigned row, long long value); SPVC_PUBLIC_API void spvc_constant_set_scalar_u16(spvc_constant constant, unsigned column, unsigned row, unsigned short value); SPVC_PUBLIC_API void spvc_constant_set_scalar_i16(spvc_constant constant, unsigned column, unsigned row, signed short value); SPVC_PUBLIC_API void spvc_constant_set_scalar_u8(spvc_constant constant, unsigned column, unsigned row, unsigned char value); diff --git a/third_party/spirv-cross/spirv_cross_containers.hpp b/third_party/spirv-cross/spirv_cross_containers.hpp index e79b32093c..c496cb75be 100644 --- a/third_party/spirv-cross/spirv_cross_containers.hpp +++ b/third_party/spirv-cross/spirv_cross_containers.hpp @@ -576,6 +576,7 @@ public: if (!ptr) return nullptr; + vacants.reserve(num_objects); for (unsigned i = 0; i < num_objects; i++) vacants.push_back(&ptr[i]); diff --git a/third_party/spirv-cross/spirv_cross_error_handling.hpp b/third_party/spirv-cross/spirv_cross_error_handling.hpp index e96ebb9a79..91e6cf4f86 100644 --- a/third_party/spirv-cross/spirv_cross_error_handling.hpp +++ b/third_party/spirv-cross/spirv_cross_error_handling.hpp @@ -66,6 +66,11 @@ public: : std::runtime_error(str) { } + + explicit CompilerError(const char *str) + : std::runtime_error(str) + { + } }; #define SPIRV_CROSS_THROW(x) throw CompilerError(x) diff --git a/third_party/spirv-cross/spirv_glsl.cpp b/third_party/spirv-cross/spirv_glsl.cpp index e0b39f95bb..2ca13334ab 100644 --- a/third_party/spirv-cross/spirv_glsl.cpp +++ b/third_party/spirv-cross/spirv_glsl.cpp @@ -235,7 +235,7 @@ static const char *to_pls_layout(PlsFormat format) } } -static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) +static std::pair pls_format_to_basetype(PlsFormat format) { switch (format) { @@ -246,17 +246,17 @@ static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) case PlsRGB10A2: case PlsRGBA8: case PlsRG16: - return SPIRType::Float; + return std::make_pair(spv::OpTypeFloat, SPIRType::Float); case PlsRGBA8I: case PlsRG16I: - return SPIRType::Int; + return std::make_pair(spv::OpTypeInt, SPIRType::Int); case PlsRGB10A2UI: case PlsRGBA8UI: case PlsRG16UI: case PlsR32UI: - return SPIRType::UInt; + return std::make_pair(spv::OpTypeInt, SPIRType::UInt); } } @@ -565,7 +565,7 @@ void CompilerGLSL::find_static_extensions() SPIRV_CROSS_THROW("GL_EXT_buffer_reference requires ESSL 320."); else if (!options.es && options.version < 450) SPIRV_CROSS_THROW("GL_EXT_buffer_reference requires GLSL 450."); - require_extension_internal("GL_EXT_buffer_reference"); + require_extension_internal("GL_EXT_buffer_reference2"); } else if (ir.addressing_model != AddressingModelLogical) { @@ -1307,7 +1307,10 @@ string CompilerGLSL::to_interpolation_qualifiers(const Bitset &flags) if (flags.get(DecorationInvariant) && (options.es || options.version >= 120)) res += "invariant "; if (flags.get(DecorationPerPrimitiveEXT)) - res += "perprimitiveEXT "; + { + res += "perprimitiveEXT "; + require_extension_internal("GL_EXT_mesh_shader"); + } if (flags.get(DecorationExplicitInterpAMD)) { @@ -1498,6 +1501,10 @@ const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format) return "rg8i"; case ImageFormatR16i: return "r16i"; + case ImageFormatR64i: + return "r64i"; + case ImageFormatR64ui: + return "r64ui"; default: case ImageFormatUnknown: return nullptr; @@ -1534,7 +1541,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits { // If using PhysicalStorageBufferEXT storage class, this is a pointer, // and is 64-bit. - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) { if (!type.pointer) SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers."); @@ -1549,7 +1556,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits else SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT."); } - else if (type_is_top_level_array(type)) + else if (is_array(type)) { uint32_t minimum_alignment = 1; if (packing_is_vec4_padded(packing)) @@ -1657,7 +1664,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f { // If using PhysicalStorageBufferEXT storage class, this is a pointer, // and is 64-bit. - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) { if (!type.pointer) SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers."); @@ -1667,7 +1674,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f else SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT."); } - else if (type_is_top_level_array(type)) + else if (is_array(type)) { uint32_t packed_size = to_array_size_literal(type) * type_to_packed_array_stride(type, flags, packing); @@ -1773,7 +1780,9 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin for (uint32_t i = 0; i < type.member_types.size(); i++) { auto &memb_type = get(type.member_types[i]); - auto member_flags = ir.meta[type.self].members[i].decoration_flags; + + auto *type_meta = ir.find_meta(type.self); + auto member_flags = type_meta ? type_meta->members[i].decoration_flags : Bitset{}; // Verify alignment rules. uint32_t packed_alignment = type_to_packed_alignment(memb_type, member_flags, packing); @@ -1802,8 +1811,20 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin if (packing_is_hlsl(packing)) { // If a member straddles across a vec4 boundary, alignment is actually vec4. - uint32_t begin_word = actual_offset / 16; - uint32_t end_word = (actual_offset + packed_size - 1) / 16; + uint32_t target_offset; + + // If we intend to use explicit packing, we must check for improper straddle with that offset. + // In implicit packing, we must check with implicit offset, since the explicit offset + // might have already accounted for the straddle, and we'd miss the alignment promotion to vec4. + // This is important when packing sub-structs that don't support packoffset(). + if (packing_has_flexible_offset(packing)) + target_offset = actual_offset; + else + target_offset = offset; + + uint32_t begin_word = target_offset / 16; + uint32_t end_word = (target_offset + packed_size - 1) / 16; + if (begin_word != end_word) packed_alignment = max(packed_alignment, 16u); } @@ -1845,7 +1866,7 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin } // Verify array stride rules. - if (type_is_top_level_array(memb_type) && + if (is_array(memb_type) && type_to_packed_array_stride(memb_type, member_flags, packing) != type_struct_member_array_stride(type, i)) { @@ -2138,11 +2159,11 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) // If SPIR-V does not comply with either layout, we cannot really work around it. if (can_use_buffer_blocks && (ubo_block || emulated_ubo)) { - attr.push_back(buffer_to_packing_standard(type, false)); + attr.push_back(buffer_to_packing_standard(type, false, true)); } else if (can_use_buffer_blocks && (push_constant_block || ssbo_block)) { - attr.push_back(buffer_to_packing_standard(type, true)); + attr.push_back(buffer_to_packing_standard(type, true, true)); } // For images, the type itself adds a layout qualifer. @@ -2163,7 +2184,9 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) return res; } -string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool support_std430_without_scalar_layout) +string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, + bool support_std430_without_scalar_layout, + bool support_enhanced_layouts) { if (support_std430_without_scalar_layout && buffer_is_packing_standard(type, BufferPackingStd430)) return "std430"; @@ -2175,6 +2198,7 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo return "scalar"; } else if (support_std430_without_scalar_layout && + support_enhanced_layouts && buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) { if (options.es && !options.vulkan_semantics) @@ -2186,7 +2210,8 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); return "std430"; } - else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) + else if (support_enhanced_layouts && + buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) { // 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. @@ -2200,7 +2225,9 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); return "std140"; } - else if (options.vulkan_semantics && buffer_is_packing_standard(type, BufferPackingScalarEnhancedLayout)) + else if (options.vulkan_semantics && + support_enhanced_layouts && + buffer_is_packing_standard(type, BufferPackingScalarEnhancedLayout)) { set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); require_extension_internal("GL_EXT_scalar_block_layout"); @@ -2214,6 +2241,7 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo return "std430"; } else if (!support_std430_without_scalar_layout && options.vulkan_semantics && + support_enhanced_layouts && buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) { // UBOs can support std430 with GL_EXT_scalar_block_layout. @@ -2312,7 +2340,7 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de auto &type = get(type_id); string buffer_name; - if (forward_declaration) + if (forward_declaration && is_physical_pointer_to_buffer_block(type)) { // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... // Allow aliased name since we might be declaring the block twice. Once with buffer reference (forward declared) and one proper declaration. @@ -2345,10 +2373,10 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de // Ensure we emit the correct name when emitting non-forward pointer type. ir.meta[type.self].decoration.alias = buffer_name; } - else if (type.basetype != SPIRType::Struct) - buffer_name = type_to_glsl(type); else - buffer_name = to_name(type.self, false); + { + buffer_name = type_to_glsl(type); + } if (!forward_declaration) { @@ -2357,13 +2385,13 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de if (itr != physical_storage_type_to_alignment.end()) alignment = itr->second.alignment; - if (type.basetype == SPIRType::Struct) + if (is_physical_pointer_to_buffer_block(type)) { SmallVector attributes; attributes.push_back("buffer_reference"); if (alignment) attributes.push_back(join("buffer_reference_align = ", alignment)); - attributes.push_back(buffer_to_packing_standard(type, true)); + attributes.push_back(buffer_to_packing_standard(type, true, true)); auto flags = ir.get_buffer_block_type_flags(type); string decorations; @@ -2378,14 +2406,32 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de statement("layout(", merge(attributes), ")", decorations, " buffer ", buffer_name); } - else if (alignment) - statement("layout(buffer_reference, buffer_reference_align = ", alignment, ") buffer ", buffer_name); else - statement("layout(buffer_reference) buffer ", buffer_name); + { + string packing_standard; + if (type.basetype == SPIRType::Struct) + { + // The non-block type is embedded in a block, so we cannot use enhanced layouts :( + packing_standard = buffer_to_packing_standard(type, true, false) + ", "; + } + else if (is_array(get_pointee_type(type))) + { + SPIRType wrap_type{OpTypeStruct}; + wrap_type.self = ir.increase_bound_by(1); + wrap_type.member_types.push_back(get_pointee_type_id(type_id)); + ir.set_member_decoration(wrap_type.self, 0, DecorationOffset, 0); + packing_standard = buffer_to_packing_standard(wrap_type, true, false) + ", "; + } + + if (alignment) + statement("layout(", packing_standard, "buffer_reference, buffer_reference_align = ", alignment, ") buffer ", buffer_name); + else + statement("layout(", packing_standard, "buffer_reference) buffer ", buffer_name); + } begin_scope(); - if (type.basetype == SPIRType::Struct) + if (is_physical_pointer_to_buffer_block(type)) { type.member_name_cache.clear(); @@ -2470,6 +2516,10 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) i++; } + // Don't declare empty blocks in GLSL, this is not allowed. + if (type_is_empty(type) && !backend.supports_empty_struct) + statement("int empty_struct_member;"); + // var.self can be used as a backup name for the block name, // so we need to make sure we don't disturb the name here on a recompile. // It will need to be reset if we have to recompile. @@ -2490,7 +2540,7 @@ void CompilerGLSL::emit_buffer_block_flattened(const SPIRVariable &var) SPIRType::BaseType basic_type; if (get_common_basic_type(type, basic_type)) { - SPIRType tmp; + SPIRType tmp { OpTypeVector }; tmp.basetype = basic_type; tmp.vecsize = 4; if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt) @@ -2808,6 +2858,9 @@ string CompilerGLSL::constant_value_macro_name(uint32_t id) void CompilerGLSL::emit_specialization_constant_op(const SPIRConstantOp &constant) { auto &type = get(constant.basetype); + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; add_resource_name(constant.self); auto name = to_name(constant.self); statement("const ", variable_decl(type, name), " = ", constant_op_expression(constant), ";"); @@ -2837,6 +2890,10 @@ void CompilerGLSL::emit_constant(const SPIRConstant &constant) { auto &type = get(constant.constant_type); + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; + SpecializationConstant wg_x, wg_y, wg_z; ID workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); @@ -3167,6 +3224,10 @@ bool CompilerGLSL::should_force_emit_builtin_block(StorageClass storage) should_force = true; } + // Either glslang bug or oversight, but global invariant position does not work in mesh shaders. + if (get_execution_model() == ExecutionModelMeshEXT && position_invariant) + should_force = true; + return should_force; } @@ -3307,11 +3368,13 @@ void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionMo auto &m = ir.meta[var.self].decoration; if (m.builtin && builtin_is_per_vertex_set(m.builtin_type)) { + // For mesh/tesc output, Clip/Cull is an array-of-array. Look at innermost array type + // for correct result. global_builtins.set(m.builtin_type); if (m.builtin_type == BuiltInCullDistance) - cull_distance_size = to_array_size_literal(type); + cull_distance_size = to_array_size_literal(type, 0); else if (m.builtin_type == BuiltInClipDistance) - clip_distance_size = to_array_size_literal(type); + clip_distance_size = to_array_size_literal(type, 0); if (is_block_builtin(m.builtin_type) && m.decoration_flags.get(DecorationXfbStride) && m.decoration_flags.get(DecorationXfbBuffer) && m.decoration_flags.get(DecorationOffset)) @@ -3415,6 +3478,8 @@ void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionMo auto itr = builtin_xfb_offsets.find(BuiltInPosition); if (itr != end(builtin_xfb_offsets)) statement("layout(xfb_offset = ", itr->second, ") vec4 gl_Position;"); + else if (position_invariant) + statement("invariant vec4 gl_Position;"); else statement("vec4 gl_Position;"); } @@ -3511,6 +3576,8 @@ void CompilerGLSL::emit_resources() break; } + bool global_invariant_position = position_invariant && (options.es || options.version >= 120); + // Emit custom gl_PerVertex for SSO compatibility. if (options.separate_shader_objects && !options.es && execution.model != ExecutionModelFragment) { @@ -3521,11 +3588,13 @@ void CompilerGLSL::emit_resources() case ExecutionModelTessellationEvaluation: emit_declared_builtin_block(StorageClassInput, execution.model); emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; break; case ExecutionModelVertex: case ExecutionModelMeshEXT: emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; break; default: @@ -3535,6 +3604,7 @@ void CompilerGLSL::emit_resources() else if (should_force_emit_builtin_block(StorageClassOutput)) { emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; } else if (execution.geometry_passthrough) { @@ -3555,7 +3625,7 @@ void CompilerGLSL::emit_resources() statement(""); } - if (position_invariant && (options.es || options.version >= 120)) + if (global_invariant_position) { statement("invariant gl_Position;"); statement(""); @@ -3573,6 +3643,10 @@ void CompilerGLSL::emit_resources() { auto &id = ir.ids[id_]; + // Skip declaring any bogus constants or undefs which use block types. + // We don't declare block types directly, so this will never work. + // Should not be legal SPIR-V, so this is considered a workaround. + if (id.get_type() == TypeConstant) { auto &c = id.get(); @@ -3630,6 +3704,10 @@ void CompilerGLSL::emit_resources() if (type.basetype == SPIRType::Void) return; + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; + string initializer; if (options.force_zero_initialized_variables && type_can_zero_initialize(type)) initializer = join(" = ", to_zero_initialized_expression(undef.basetype)); @@ -3666,31 +3744,34 @@ void CompilerGLSL::emit_resources() if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64EXT) { - for (auto type : physical_storage_non_block_pointer_types) - { - emit_buffer_reference_block(type, false); - } - // Output buffer reference blocks. // Do this in two stages, one with forward declaration, // and one without. Buffer reference blocks can reference themselves // to support things like linked lists. - ir.for_each_typed_id([&](uint32_t self, SPIRType &type) { - if (type.basetype == SPIRType::Struct && type.pointer && - type.pointer_depth == 1 && !type_is_array_of_pointers(type) && - type.storage == StorageClassPhysicalStorageBufferEXT) + ir.for_each_typed_id([&](uint32_t id, SPIRType &type) { + if (is_physical_pointer(type)) { - emit_buffer_reference_block(self, true); + bool emit_type = true; + if (!is_physical_pointer_to_buffer_block(type)) + { + // Only forward-declare if we intend to emit it in the non_block_pointer types. + // Otherwise, these are just "benign" pointer types that exist as a result of access chains. + emit_type = std::find(physical_storage_non_block_pointer_types.begin(), + physical_storage_non_block_pointer_types.end(), + id) != physical_storage_non_block_pointer_types.end(); + } + + if (emit_type) + emit_buffer_reference_block(id, true); } }); - ir.for_each_typed_id([&](uint32_t self, SPIRType &type) { - if (type.basetype == SPIRType::Struct && - type.pointer && type.pointer_depth == 1 && !type_is_array_of_pointers(type) && - type.storage == StorageClassPhysicalStorageBufferEXT) - { - emit_buffer_reference_block(self, false); - } + for (auto type : physical_storage_non_block_pointer_types) + emit_buffer_reference_block(type, false); + + ir.for_each_typed_id([&](uint32_t id, SPIRType &type) { + if (is_physical_pointer_to_buffer_block(type)) + emit_buffer_reference_block(id, false); }); } @@ -3899,6 +3980,7 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) auto &member_type = get(member_type_id); auto array_type = member_type; array_type.parent_type = member_type_id; + array_type.op = OpTypeArray; array_type.array.push_back(array_size); array_type.array_size_literal.push_back(true); @@ -3922,10 +4004,9 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) if (is_control_point) { uint32_t ids = ir.increase_bound_by(3); - SPIRType uint_type; + auto &uint_type = set(ids, OpTypeInt); uint_type.basetype = SPIRType::UInt; uint_type.width = 32; - set(ids, uint_type); set(ids + 1, builtin_to_glsl(BuiltInInvocationId, StorageClassInput), ids, true); set(ids + 2, ids, i, false); invocation_id = ids + 1; @@ -4972,11 +5053,8 @@ string CompilerGLSL::dereference_expression(const SPIRType &expr_type, const std return expr.substr(1); else if (backend.native_pointers) return join('*', expr); - else if (expr_type.storage == StorageClassPhysicalStorageBufferEXT && expr_type.basetype != SPIRType::Struct && - expr_type.pointer_depth == 1) - { + else if (is_physical_pointer(expr_type) && !is_physical_pointer_to_buffer_block(expr_type)) return join(enclose_expression(expr), ".value"); - } else return expr; } @@ -5121,7 +5199,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type, type.basetype == SPIRType::Boolean && backend.boolean_in_struct_remapped_type != SPIRType::Boolean; - SPIRType tmp_type; + SPIRType tmp_type { OpNop }; if (remapped_boolean) { tmp_type = get(type.parent_type); @@ -5142,7 +5220,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type, for (uint32_t i = 0; i < size; i++) { auto subexpr = join(base_expr, "[", convert_to_string(i), "]"); - if (!type_is_top_level_array(parent)) + if (!is_array(parent)) { if (remapped_boolean) subexpr = join(type_to_glsl(tmp_type), "(", subexpr, ")"); @@ -5168,7 +5246,7 @@ string CompilerGLSL::to_composite_constructor_expression(const SPIRType &parent_ type.basetype == SPIRType::Boolean && backend.boolean_in_struct_remapped_type != SPIRType::Boolean; - if (type_is_top_level_array(type)) + if (is_array(type)) { reroll_array = !backend.array_is_value_type || (block_like_type && !backend.array_is_value_type_in_buffer_blocks); @@ -5721,7 +5799,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, { auto &type = get(c.constant_type); - if (type_is_top_level_pointer(type)) + if (is_pointer(type)) { return backend.null_pointer_literal; } @@ -5736,21 +5814,21 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, // with Offset = 0, using no ArrayStride on the enclosed array type. // A particular CTS test hits this scenario. bool array_type_decays = inside_block_like_struct_scope && - type_is_top_level_array(type) && + is_array(type) && !backend.array_is_value_type_in_buffer_blocks; // Allow Metal to use the array template to make arrays a value type bool needs_trailing_tracket = false; if (backend.use_initializer_list && backend.use_typed_initializer_list && type.basetype == SPIRType::Struct && - !type_is_top_level_array(type)) + !is_array(type)) { res = type_to_glsl_constructor(type) + "{ "; } else if (backend.use_initializer_list && backend.use_typed_initializer_list && backend.array_is_value_type && - type_is_top_level_array(type) && !array_type_decays) + is_array(type) && !array_type_decays) { const auto *p_type = &type; - SPIRType tmp_type; + SPIRType tmp_type { OpNop }; if (inside_struct_scope && backend.boolean_in_struct_remapped_type != SPIRType::Boolean && @@ -5791,7 +5869,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, res += to_name(elem); else { - if (!type_is_top_level_array(type) && type.basetype == SPIRType::Struct) + if (!is_array(type) && type.basetype == SPIRType::Struct) { // When we get down to emitting struct members, override the block-like information. // For constants, we can freely mix and match block-like state. @@ -5889,7 +5967,7 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col, // of complicated workarounds, just value-cast to the half type always. if (std::isnan(float_value) || std::isinf(float_value)) { - SPIRType type; + SPIRType type { OpTypeFloat }; type.basetype = SPIRType::Half; type.vecsize = 1; type.columns = 1; @@ -5905,11 +5983,11 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col, } else { - SPIRType type; + SPIRType type { OpTypeFloat }; type.basetype = SPIRType::Half; type.vecsize = 1; type.columns = 1; - res = join(type_to_glsl(type), "(", convert_to_string(float_value, current_locale_radix_character), ")"); + res = join(type_to_glsl(type), "(", format_float(float_value), ")"); } return res; @@ -5925,8 +6003,8 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col // Use special representation. if (!is_legacy()) { - SPIRType out_type; - SPIRType in_type; + SPIRType out_type { OpTypeFloat }; + SPIRType in_type { OpTypeInt }; out_type.basetype = SPIRType::Float; in_type.basetype = SPIRType::UInt; out_type.vecsize = 1; @@ -5977,7 +6055,7 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col } else { - res = convert_to_string(float_value, current_locale_radix_character); + res = format_float(float_value); if (backend.float_literal_suffix) res += "f"; } @@ -5995,8 +6073,8 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 // Use special representation. if (!is_legacy()) { - SPIRType out_type; - SPIRType in_type; + SPIRType out_type { OpTypeFloat }; + SPIRType in_type { OpTypeInt }; out_type.basetype = SPIRType::Double; in_type.basetype = SPIRType::UInt64; out_type.vecsize = 1; @@ -6060,7 +6138,7 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 } else { - res = convert_to_string(double_value, current_locale_radix_character); + res = format_double(double_value); if (backend.double_literal_suffix) res += "lf"; } @@ -6704,7 +6782,7 @@ SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_o // Create a fake type so we can bitcast to it. // We only deal with regular arithmetic types here like int, uints and so on. - SPIRType expected_type; + SPIRType expected_type{type0.op}; expected_type.basetype = input_type; expected_type.vecsize = type0.vecsize; expected_type.columns = type0.columns; @@ -7058,7 +7136,9 @@ void CompilerGLSL::emit_bitfield_insert_op(uint32_t result_type, uint32_t result auto op2_expr = to_unpacked_expression(op2); auto op3_expr = to_unpacked_expression(op3); - SPIRType target_type; + assert(offset_count_type == SPIRType::UInt || offset_count_type == SPIRType::Int); + SPIRType target_type { OpTypeInt }; + target_type.width = 32; target_type.vecsize = 1; target_type.basetype = offset_count_type; @@ -7849,7 +7929,7 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const bool CompilerGLSL::expression_is_non_value_type_array(uint32_t ptr) { auto &type = expression_type(ptr); - if (!type_is_top_level_array(get_pointee_type(type))) + if (!is_array(get_pointee_type(type))) return false; if (!backend.array_is_value_type) @@ -9583,6 +9663,8 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) return "gl_TessLevelInner"; case BuiltInTessCoord: return "gl_TessCoord"; + case BuiltInPatchVertices: + return "gl_PatchVerticesIn"; case BuiltInFragCoord: return "gl_FragCoord"; case BuiltInPointCoord: @@ -9885,16 +9967,21 @@ void CompilerGLSL::access_chain_internal_append_index(std::string &expr, uint32_ if (ptr_chain && access_chain_is_arrayed) { size_t split_pos = expr.find_last_of(']'); - string expr_front = expr.substr(0, split_pos); - string expr_back = expr.substr(split_pos); - expr = expr_front + " + " + enclose_expression(idx_expr) + expr_back; - } - else - { - expr += "["; - expr += idx_expr; - expr += "]"; + size_t enclose_split = expr.find_last_of(')'); + + // If we have already enclosed the expression, don't try to be clever, it will break. + if (split_pos > enclose_split || enclose_split == string::npos) + { + string expr_front = expr.substr(0, split_pos); + string expr_back = expr.substr(split_pos); + expr = expr_front + " + " + enclose_expression(idx_expr) + expr_back; + return; + } } + + expr += "["; + expr += idx_expr; + expr += "]"; } bool CompilerGLSL::access_chain_needs_stage_io_builtin_translation(uint32_t) @@ -9929,6 +10016,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Start traversing type hierarchy at the proper non-pointer types, // but keep type_id referencing the original pointer for use below. uint32_t type_id = expression_type_id(base); + const auto *type = &get_pointee_type(type_id); if (!backend.native_pointers) { @@ -9938,13 +10026,10 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Wrapped buffer reference pointer types will need to poke into the internal "value" member before // continuing the access chain. if (should_dereference(base)) - { - auto &type = get(type_id); - expr = dereference_expression(type, expr); - } + expr = dereference_expression(get(type_id), expr); } - - const auto *type = &get_pointee_type(type_id); + else if (should_dereference(base) && type->basetype != SPIRType::Struct && !ptr_chain) + expr = join("(", dereference_expression(*type, expr), ")"); bool access_chain_is_arrayed = expr.find_first_of('[') != string::npos; bool row_major_matrix_needs_conversion = is_non_native_row_major_matrix(base); @@ -9954,6 +10039,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice bool relaxed_precision = has_decoration(base, DecorationRelaxedPrecision); bool pending_array_enclose = false; bool dimension_flatten = false; + bool access_meshlet_position_y = false; + + if (auto *base_expr = maybe_get(base)) + { + access_meshlet_position_y = base_expr->access_meshlet_position_y; + } // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden bool hide_first_subscript = count > 1 && is_user_type_structured(base); @@ -9979,9 +10070,21 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice index &= 0x7fffffffu; } - // Pointer chains + bool ptr_chain_array_entry = ptr_chain && i == 0 && is_array(*type); + + if (ptr_chain_array_entry) + { + // This is highly unusual code, since normally we'd use plain AccessChain, but it's still allowed. + // We are considered to have a pointer to array and one element shifts by one array at a time. + // If we use normal array indexing, we'll first decay to pointer, and lose the array-ness, + // so we have to take pointer to array explicitly. + if (!should_dereference(base)) + expr = enclose_expression(address_of_expression(expr)); + } + if (ptr_chain && i == 0) { + // Pointer chains // If we are flattening multidimensional arrays, only create opening bracket on first // array index. if (options.flatten_multidimensional_arrays) @@ -10026,6 +10129,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice } access_chain_is_arrayed = true; + + // Explicitly enclose the expression if this is one of the weird pointer-to-array cases. + // We don't want any future indexing to add to this array dereference. + // Enclosing the expression blocks that and avoids any shenanigans with operand priority. + if (ptr_chain_array_entry) + expr = join("(", expr, ")"); } // Arrays else if (!type->array.empty()) @@ -10057,8 +10166,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice switch (builtin) { - // case BuiltInCullDistance: // These are already arrays, need to figure out rules for these in tess/geom. - // case BuiltInClipDistance: + case BuiltInCullDistance: + case BuiltInClipDistance: + if (type->array.size() == 1) // Red herring. Only consider block IO for two-dimensional arrays here. + { + append_index(index, is_literal); + break; + } + // fallthrough case BuiltInPosition: case BuiltInPointSize: if (mesh_shader) @@ -10119,16 +10234,34 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (!pending_array_enclose) expr += "]"; } - // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. - // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. - else if (!builtin_translates_to_nonarray(BuiltIn(get_decoration(base, DecorationBuiltIn)))) + else if (index_is_literal || !builtin_translates_to_nonarray(BuiltIn(get_decoration(base, DecorationBuiltIn)))) { + // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. + // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. + // For literal indices we are working on composites, so we ignore this since we have already converted to proper array. append_index(index, is_literal); } + if (var && has_decoration(var->self, DecorationBuiltIn) && + get_decoration(var->self, DecorationBuiltIn) == BuiltInPosition && + get_execution_model() == ExecutionModelMeshEXT) + { + access_meshlet_position_y = true; + } + type_id = type->parent_type; type = &get(type_id); + // If the physical type has an unnatural vecsize, + // we must assume it's a faked struct where the .data member + // is used for the real payload. + if (physical_type && (is_vector(*type) || is_scalar(*type))) + { + auto &phys = get(physical_type); + if (phys.vecsize > 4) + expr += ".data"; + } + access_chain_is_arrayed = true; } // For structs, the index refers to a constant, which indexes into the members, possibly through a redirection mapping. @@ -10161,6 +10294,11 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice } else expr = builtin_to_glsl(builtin, type->storage); + + if (builtin == BuiltInPosition && get_execution_model() == ExecutionModelMeshEXT) + { + access_meshlet_position_y = true; + } } else { @@ -10209,6 +10347,16 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice expr += to_unpacked_expression(index, register_expression_read); expr += "]"; + // If the physical type has an unnatural vecsize, + // we must assume it's a faked struct where the .data member + // is used for the real payload. + if (physical_type) + { + auto &phys = get(physical_type); + if (phys.vecsize > 4 || phys.columns > 4) + expr += ".data"; + } + type_id = type->parent_type; type = &get(type_id); } @@ -10223,6 +10371,18 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (column_index != string::npos) { deferred_index = expr.substr(column_index); + + auto end_deferred_index = deferred_index.find_last_of(']'); + if (end_deferred_index != string::npos && end_deferred_index + 1 != deferred_index.size()) + { + // If we have any data member fixups, it must be transposed so that it refers to this index. + // E.g. [0].data followed by [1] would be shuffled to [1][0].data which is wrong, + // and needs to be [1].data[0] instead. + end_deferred_index++; + deferred_index = deferred_index.substr(end_deferred_index) + + deferred_index.substr(0, end_deferred_index); + } + expr.resize(column_index); } } @@ -10301,8 +10461,34 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (row_major_matrix_needs_conversion && !ignore_potential_sliced_writes) { - prepare_access_chain_for_scalar_access(expr, get(type->parent_type), effective_storage, - is_packed); + if (prepare_access_chain_for_scalar_access(expr, get(type->parent_type), effective_storage, + is_packed)) + { + // We're in a pointer context now, so just remove any member dereference. + auto first_index = deferred_index.find_first_of('['); + if (first_index != string::npos && first_index != 0) + deferred_index = deferred_index.substr(first_index); + } + } + + if (access_meshlet_position_y) + { + if (is_literal) + { + access_meshlet_position_y = index == 1; + } + else + { + const auto *c = maybe_get(index); + if (c) + access_meshlet_position_y = c->scalar() == 1; + else + { + // We don't know, but we have to assume no. + // Flip Y in mesh shaders is an opt-in horrible hack, so we'll have to assume shaders try to behave. + access_meshlet_position_y = false; + } + } } expr += deferred_index; @@ -10331,6 +10517,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice meta->storage_is_invariant = is_invariant; meta->storage_physical_type = physical_type; meta->relaxed_precision = relaxed_precision; + meta->access_meshlet_position_y = access_meshlet_position_y; } return expr; @@ -10340,8 +10527,9 @@ void CompilerGLSL::check_physical_type_cast(std::string &, const SPIRType *, uin { } -void CompilerGLSL::prepare_access_chain_for_scalar_access(std::string &, const SPIRType &, spv::StorageClass, bool &) +bool CompilerGLSL::prepare_access_chain_for_scalar_access(std::string &, const SPIRType &, spv::StorageClass, bool &) { + return false; } string CompilerGLSL::to_flattened_struct_member(const string &basename, const SPIRType &type, uint32_t index) @@ -11903,6 +12091,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) expr.loaded_from = backing_variable ? backing_variable->self : ID(ops[2]); expr.need_transpose = meta.need_transpose; expr.access_chain = true; + expr.access_meshlet_position_y = meta.access_meshlet_position_y; // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. if (meta.storage_is_packed) @@ -13998,6 +14187,66 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpImageSampleWeightedQCOM: + case OpImageBoxFilterQCOM: + case OpImageBlockMatchSSDQCOM: + case OpImageBlockMatchSADQCOM: + { + require_extension_internal("GL_QCOM_image_processing"); + uint32_t result_type_id = ops[0]; + uint32_t id = ops[1]; + string expr; + switch (opcode) + { + case OpImageSampleWeightedQCOM: + expr = "textureWeightedQCOM"; + break; + case OpImageBoxFilterQCOM: + expr = "textureBoxFilterQCOM"; + break; + case OpImageBlockMatchSSDQCOM: + expr = "textureBlockMatchSSDQCOM"; + break; + case OpImageBlockMatchSADQCOM: + expr = "textureBlockMatchSADQCOM"; + break; + default: + SPIRV_CROSS_THROW("Invalid opcode for QCOM_image_processing."); + } + expr += "("; + + bool forward = false; + expr += to_expression(ops[2]); + expr += ", " + to_expression(ops[3]); + + switch (opcode) + { + case OpImageSampleWeightedQCOM: + expr += ", " + to_non_uniform_aware_expression(ops[4]); + break; + case OpImageBoxFilterQCOM: + expr += ", " + to_expression(ops[4]); + break; + case OpImageBlockMatchSSDQCOM: + case OpImageBlockMatchSADQCOM: + expr += ", " + to_non_uniform_aware_expression(ops[4]); + expr += ", " + to_expression(ops[5]); + expr += ", " + to_expression(ops[6]); + break; + default: + SPIRV_CROSS_THROW("Invalid opcode for QCOM_image_processing."); + } + + expr += ")"; + emit_op(result_type_id, id, expr, forward); + + inherit_expression_dependencies(id, ops[3]); + if (opcode == OpImageBlockMatchSSDQCOM || opcode == OpImageBlockMatchSADQCOM) + inherit_expression_dependencies(id, ops[5]); + + break; + } + // Compute case OpControlBarrier: case OpMemoryBarrier: @@ -14883,6 +15132,17 @@ string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &ex auto column_expr = exp_str.substr(column_index); exp_str.resize(column_index); + auto end_deferred_index = column_expr.find_last_of(']'); + if (end_deferred_index != string::npos && end_deferred_index + 1 != column_expr.size()) + { + // If we have any data member fixups, it must be transposed so that it refers to this index. + // E.g. [0].data followed by [1] would be shuffled to [1][0].data which is wrong, + // and needs to be [1].data[0] instead. + end_deferred_index++; + column_expr = column_expr.substr(end_deferred_index) + + column_expr.substr(0, end_deferred_index); + } + auto transposed_expr = type_to_glsl_constructor(exp_type) + "("; // Loading a column from a row-major matrix. Unroll the load. @@ -15216,9 +15476,16 @@ string CompilerGLSL::pls_decl(const PlsRemap &var) { auto &variable = get(var.id); - SPIRType type; - type.vecsize = pls_format_to_components(var.format); - type.basetype = pls_format_to_basetype(var.format); + auto op_and_basetype = pls_format_to_basetype(var.format); + + SPIRType type { op_and_basetype.first }; + type.basetype = op_and_basetype.second; + auto vecsize = pls_format_to_components(var.format); + if (vecsize > 1) + { + type.op = OpTypeVector; + type.vecsize = vecsize; + } return join(to_pls_layout(var.format), to_pls_qualifiers_glsl(variable), type_to_glsl(type), " ", to_name(variable.self)); @@ -15315,13 +15582,21 @@ string CompilerGLSL::type_to_array_glsl(const SPIRType &type) } } -string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id) +string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id, bool /*member*/) { auto &imagetype = get(type.image.type); string res; switch (imagetype.basetype) { + case SPIRType::Int64: + res = "i64"; + require_extension_internal("GL_EXT_shader_image_int64"); + break; + case SPIRType::UInt64: + res = "u64"; + require_extension_internal("GL_EXT_shader_image_int64"); + break; case SPIRType::Int: case SPIRType::Short: case SPIRType::SByte: @@ -15459,17 +15734,29 @@ string CompilerGLSL::type_to_glsl_constructor(const SPIRType &type) // depend on a specific object's use of that type. string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) { - if (type.pointer && type.storage == StorageClassPhysicalStorageBufferEXT && type.basetype != SPIRType::Struct) + if (is_physical_pointer(type) && !is_physical_pointer_to_buffer_block(type)) { // Need to create a magic type name which compacts the entire type information. - string name = type_to_glsl(get_pointee_type(type)); - for (size_t i = 0; i < type.array.size(); i++) + auto *parent = &get_pointee_type(type); + string name = type_to_glsl(*parent); + + uint32_t array_stride = get_decoration(type.parent_type, DecorationArrayStride); + + // Resolve all array dimensions in one go since once we lose the pointer type, + // array information is left to to_array_type_glsl. The base type loses array information. + while (is_array(*parent)) { - if (type.array_size_literal[i]) - name += join(type.array[i], "_"); + if (parent->array_size_literal.back()) + name += join(type.array.back(), "_"); else - name += join("id", type.array[i], "_"); + name += join("id", type.array.back(), "_"); + + name += "stride_" + std::to_string(array_stride); + + array_stride = get_decoration(parent->parent_type, DecorationArrayStride); + parent = &get(parent->parent_type); } + name += "Pointer"; return name; } @@ -16447,6 +16734,17 @@ bool CompilerGLSL::for_loop_initializers_are_same_type(const SPIRBlock &block) return true; } +void CompilerGLSL::emit_block_instructions_with_masked_debug(SPIRBlock &block) +{ + // Have to block debug instructions such as OpLine here, since it will be treated as a statement otherwise, + // which breaks loop optimizations. + // Any line directive would be declared outside the loop body, which would just be confusing either way. + bool old_block_debug_directives = block_debug_directives; + block_debug_directives = true; + emit_block_instructions(block); + block_debug_directives = old_block_debug_directives; +} + bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method) { SPIRBlock::ContinueBlockType continue_type = continue_block_type(get(block.continue_block)); @@ -16457,7 +16755,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. - emit_block_instructions(block); + emit_block_instructions_with_masked_debug(block); bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries); @@ -16537,7 +16835,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. - emit_block_instructions(child); + emit_block_instructions_with_masked_debug(child); bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries); @@ -17510,7 +17808,7 @@ bool CompilerGLSL::unroll_array_to_complex_store(uint32_t target_id, uint32_t so else array_expr = to_expression(type.array.back()); - SPIRType target_type; + SPIRType target_type { OpTypeInt }; target_type.basetype = SPIRType::Int; statement("for (int i = 0; i < int(", array_expr, "); i++)"); @@ -17575,7 +17873,7 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s statement(new_expr, "[i] = gl_in[i].", expr, ";"); else if (is_sample_mask) { - SPIRType target_type; + SPIRType target_type { OpTypeInt }; target_type.basetype = SPIRType::Int; statement(new_expr, "[i] = ", bitcast_expression(target_type, type.basetype, join(expr, "[i]")), ";"); } @@ -17654,6 +17952,25 @@ void CompilerGLSL::cast_from_variable_load(uint32_t source_id, std::string &expr expr = bitcast_expression(expr_type, expected_type, expr); } +SPIRType::BaseType CompilerGLSL::get_builtin_basetype(BuiltIn builtin, SPIRType::BaseType default_type) +{ + // TODO: Fill in for more builtins. + switch (builtin) + { + case BuiltInLayer: + case BuiltInPrimitiveId: + case BuiltInViewportIndex: + case BuiltInFragStencilRefEXT: + case BuiltInSampleMask: + case BuiltInPrimitiveShadingRateKHR: + case BuiltInShadingRateKHR: + return SPIRType::Int; + + default: + return default_type; + } +} + void CompilerGLSL::cast_to_variable_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) { auto *var = maybe_get_backing_variable(target_id); @@ -17665,24 +17982,7 @@ void CompilerGLSL::cast_to_variable_store(uint32_t target_id, std::string &expr, return; auto builtin = static_cast(get_decoration(target_id, DecorationBuiltIn)); - auto expected_type = expr_type.basetype; - - // TODO: Fill in for more builtins. - switch (builtin) - { - case BuiltInLayer: - case BuiltInPrimitiveId: - case BuiltInViewportIndex: - case BuiltInFragStencilRefEXT: - case BuiltInSampleMask: - case BuiltInPrimitiveShadingRateKHR: - case BuiltInShadingRateKHR: - expected_type = SPIRType::Int; - break; - - default: - break; - } + auto expected_type = get_builtin_basetype(builtin, expr_type.basetype); if (expected_type != expr_type.basetype) { @@ -17916,6 +18216,11 @@ void CompilerGLSL::emit_line_directive(uint32_t file_id, uint32_t line_literal) if (redirect_statement) return; + // If we're emitting code in a sensitive context such as condition blocks in for loops, don't emit + // any line directives, because it's not possible. + if (block_debug_directives) + return; + if (options.emit_line_directives) { require_extension_internal("GL_GOOGLE_cpp_style_line_directive"); @@ -18543,3 +18848,22 @@ uint32_t CompilerGLSL::type_to_location_count(const SPIRType &type) const return count; } + +std::string CompilerGLSL::format_float(float value) const +{ + if (float_formatter) + return float_formatter->format_float(value); + + // default behavior + return convert_to_string(value, current_locale_radix_character); +} + +std::string CompilerGLSL::format_double(double value) const +{ + if (float_formatter) + return float_formatter->format_double(value); + + // default behavior + return convert_to_string(value, current_locale_radix_character); +} + diff --git a/third_party/spirv-cross/spirv_glsl.cpp.orig b/third_party/spirv-cross/spirv_glsl.cpp.orig index f2104ff856..0d37ba2e8d 100644 --- a/third_party/spirv-cross/spirv_glsl.cpp.orig +++ b/third_party/spirv-cross/spirv_glsl.cpp.orig @@ -223,7 +223,7 @@ static const char *to_pls_layout(PlsFormat format) } } -static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) +static std::pair pls_format_to_basetype(PlsFormat format) { switch (format) { @@ -234,17 +234,17 @@ static SPIRType::BaseType pls_format_to_basetype(PlsFormat format) case PlsRGB10A2: case PlsRGBA8: case PlsRG16: - return SPIRType::Float; + return std::make_pair(spv::OpTypeFloat, SPIRType::Float); case PlsRGBA8I: case PlsRG16I: - return SPIRType::Int; + return std::make_pair(spv::OpTypeInt, SPIRType::Int); case PlsRGB10A2UI: case PlsRGBA8UI: case PlsRG16UI: case PlsR32UI: - return SPIRType::UInt; + return std::make_pair(spv::OpTypeInt, SPIRType::UInt); } } @@ -553,7 +553,7 @@ void CompilerGLSL::find_static_extensions() SPIRV_CROSS_THROW("GL_EXT_buffer_reference requires ESSL 320."); else if (!options.es && options.version < 450) SPIRV_CROSS_THROW("GL_EXT_buffer_reference requires GLSL 450."); - require_extension_internal("GL_EXT_buffer_reference"); + require_extension_internal("GL_EXT_buffer_reference2"); } else if (ir.addressing_model != AddressingModelLogical) { @@ -1295,7 +1295,10 @@ string CompilerGLSL::to_interpolation_qualifiers(const Bitset &flags) if (flags.get(DecorationInvariant) && (options.es || options.version >= 120)) res += "invariant "; if (flags.get(DecorationPerPrimitiveEXT)) - res += "perprimitiveEXT "; + { + res += "perprimitiveEXT "; + require_extension_internal("GL_EXT_mesh_shader"); + } if (flags.get(DecorationExplicitInterpAMD)) { @@ -1486,6 +1489,10 @@ const char *CompilerGLSL::format_to_glsl(spv::ImageFormat format) return "rg8i"; case ImageFormatR16i: return "r16i"; + case ImageFormatR64i: + return "r64i"; + case ImageFormatR64ui: + return "r64ui"; default: case ImageFormatUnknown: return nullptr; @@ -1522,7 +1529,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits { // If using PhysicalStorageBufferEXT storage class, this is a pointer, // and is 64-bit. - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) { if (!type.pointer) SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers."); @@ -1537,7 +1544,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits else SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT."); } - else if (type_is_top_level_array(type)) + else if (is_array(type)) { uint32_t minimum_alignment = 1; if (packing_is_vec4_padded(packing)) @@ -1645,7 +1652,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f { // If using PhysicalStorageBufferEXT storage class, this is a pointer, // and is 64-bit. - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) { if (!type.pointer) SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers."); @@ -1655,7 +1662,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f else SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT."); } - else if (type_is_top_level_array(type)) + else if (is_array(type)) { uint32_t packed_size = to_array_size_literal(type) * type_to_packed_array_stride(type, flags, packing); @@ -1761,7 +1768,9 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin for (uint32_t i = 0; i < type.member_types.size(); i++) { auto &memb_type = get(type.member_types[i]); - auto member_flags = ir.meta[type.self].members[i].decoration_flags; + + auto *type_meta = ir.find_meta(type.self); + auto member_flags = type_meta ? type_meta->members[i].decoration_flags : Bitset{}; // Verify alignment rules. uint32_t packed_alignment = type_to_packed_alignment(memb_type, member_flags, packing); @@ -1790,8 +1799,20 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin if (packing_is_hlsl(packing)) { // If a member straddles across a vec4 boundary, alignment is actually vec4. - uint32_t begin_word = actual_offset / 16; - uint32_t end_word = (actual_offset + packed_size - 1) / 16; + uint32_t target_offset; + + // If we intend to use explicit packing, we must check for improper straddle with that offset. + // In implicit packing, we must check with implicit offset, since the explicit offset + // might have already accounted for the straddle, and we'd miss the alignment promotion to vec4. + // This is important when packing sub-structs that don't support packoffset(). + if (packing_has_flexible_offset(packing)) + target_offset = actual_offset; + else + target_offset = offset; + + uint32_t begin_word = target_offset / 16; + uint32_t end_word = (target_offset + packed_size - 1) / 16; + if (begin_word != end_word) packed_alignment = max(packed_alignment, 16u); } @@ -1833,7 +1854,7 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin } // Verify array stride rules. - if (type_is_top_level_array(memb_type) && + if (is_array(memb_type) && type_to_packed_array_stride(memb_type, member_flags, packing) != type_struct_member_array_stride(type, i)) { @@ -2126,11 +2147,11 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) // If SPIR-V does not comply with either layout, we cannot really work around it. if (can_use_buffer_blocks && (ubo_block || emulated_ubo)) { - attr.push_back(buffer_to_packing_standard(type, false)); + attr.push_back(buffer_to_packing_standard(type, false, true)); } else if (can_use_buffer_blocks && (push_constant_block || ssbo_block)) { - attr.push_back(buffer_to_packing_standard(type, true)); + attr.push_back(buffer_to_packing_standard(type, true, true)); } // For images, the type itself adds a layout qualifer. @@ -2151,7 +2172,9 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) return res; } -string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool support_std430_without_scalar_layout) +string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, + bool support_std430_without_scalar_layout, + bool support_enhanced_layouts) { if (support_std430_without_scalar_layout && buffer_is_packing_standard(type, BufferPackingStd430)) return "std430"; @@ -2163,6 +2186,7 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo return "scalar"; } else if (support_std430_without_scalar_layout && + support_enhanced_layouts && buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) { if (options.es && !options.vulkan_semantics) @@ -2174,7 +2198,8 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); return "std430"; } - else if (buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) + else if (support_enhanced_layouts && + buffer_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) { // 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. @@ -2188,7 +2213,9 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); return "std140"; } - else if (options.vulkan_semantics && buffer_is_packing_standard(type, BufferPackingScalarEnhancedLayout)) + else if (options.vulkan_semantics && + support_enhanced_layouts && + buffer_is_packing_standard(type, BufferPackingScalarEnhancedLayout)) { set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset); require_extension_internal("GL_EXT_scalar_block_layout"); @@ -2202,6 +2229,7 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool suppo return "std430"; } else if (!support_std430_without_scalar_layout && options.vulkan_semantics && + support_enhanced_layouts && buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout)) { // UBOs can support std430 with GL_EXT_scalar_block_layout. @@ -2300,7 +2328,7 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de auto &type = get(type_id); string buffer_name; - if (forward_declaration) + if (forward_declaration && is_physical_pointer_to_buffer_block(type)) { // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... // Allow aliased name since we might be declaring the block twice. Once with buffer reference (forward declared) and one proper declaration. @@ -2333,10 +2361,10 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de // Ensure we emit the correct name when emitting non-forward pointer type. ir.meta[type.self].decoration.alias = buffer_name; } - else if (type.basetype != SPIRType::Struct) - buffer_name = type_to_glsl(type); else - buffer_name = to_name(type.self, false); + { + buffer_name = type_to_glsl(type); + } if (!forward_declaration) { @@ -2345,13 +2373,13 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de if (itr != physical_storage_type_to_alignment.end()) alignment = itr->second.alignment; - if (type.basetype == SPIRType::Struct) + if (is_physical_pointer_to_buffer_block(type)) { SmallVector attributes; attributes.push_back("buffer_reference"); if (alignment) attributes.push_back(join("buffer_reference_align = ", alignment)); - attributes.push_back(buffer_to_packing_standard(type, true)); + attributes.push_back(buffer_to_packing_standard(type, true, true)); auto flags = ir.get_buffer_block_type_flags(type); string decorations; @@ -2366,14 +2394,32 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de statement("layout(", merge(attributes), ")", decorations, " buffer ", buffer_name); } - else if (alignment) - statement("layout(buffer_reference, buffer_reference_align = ", alignment, ") buffer ", buffer_name); else - statement("layout(buffer_reference) buffer ", buffer_name); + { + string packing_standard; + if (type.basetype == SPIRType::Struct) + { + // The non-block type is embedded in a block, so we cannot use enhanced layouts :( + packing_standard = buffer_to_packing_standard(type, true, false) + ", "; + } + else if (is_array(get_pointee_type(type))) + { + SPIRType wrap_type{OpTypeStruct}; + wrap_type.self = ir.increase_bound_by(1); + wrap_type.member_types.push_back(get_pointee_type_id(type_id)); + ir.set_member_decoration(wrap_type.self, 0, DecorationOffset, 0); + packing_standard = buffer_to_packing_standard(wrap_type, true, false) + ", "; + } + + if (alignment) + statement("layout(", packing_standard, "buffer_reference, buffer_reference_align = ", alignment, ") buffer ", buffer_name); + else + statement("layout(", packing_standard, "buffer_reference) buffer ", buffer_name); + } begin_scope(); - if (type.basetype == SPIRType::Struct) + if (is_physical_pointer_to_buffer_block(type)) { type.member_name_cache.clear(); @@ -2458,6 +2504,10 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) i++; } + // Don't declare empty blocks in GLSL, this is not allowed. + if (type_is_empty(type) && !backend.supports_empty_struct) + statement("int empty_struct_member;"); + // var.self can be used as a backup name for the block name, // so we need to make sure we don't disturb the name here on a recompile. // It will need to be reset if we have to recompile. @@ -2478,7 +2528,7 @@ void CompilerGLSL::emit_buffer_block_flattened(const SPIRVariable &var) SPIRType::BaseType basic_type; if (get_common_basic_type(type, basic_type)) { - SPIRType tmp; + SPIRType tmp { OpTypeVector }; tmp.basetype = basic_type; tmp.vecsize = 4; if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt) @@ -2796,6 +2846,9 @@ string CompilerGLSL::constant_value_macro_name(uint32_t id) void CompilerGLSL::emit_specialization_constant_op(const SPIRConstantOp &constant) { auto &type = get(constant.basetype); + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; add_resource_name(constant.self); auto name = to_name(constant.self); statement("const ", variable_decl(type, name), " = ", constant_op_expression(constant), ";"); @@ -2825,6 +2878,10 @@ void CompilerGLSL::emit_constant(const SPIRConstant &constant) { auto &type = get(constant.constant_type); + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; + SpecializationConstant wg_x, wg_y, wg_z; ID workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); @@ -3155,6 +3212,10 @@ bool CompilerGLSL::should_force_emit_builtin_block(StorageClass storage) should_force = true; } + // Either glslang bug or oversight, but global invariant position does not work in mesh shaders. + if (get_execution_model() == ExecutionModelMeshEXT && position_invariant) + should_force = true; + return should_force; } @@ -3295,11 +3356,13 @@ void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionMo auto &m = ir.meta[var.self].decoration; if (m.builtin && builtin_is_per_vertex_set(m.builtin_type)) { + // For mesh/tesc output, Clip/Cull is an array-of-array. Look at innermost array type + // for correct result. global_builtins.set(m.builtin_type); if (m.builtin_type == BuiltInCullDistance) - cull_distance_size = to_array_size_literal(type); + cull_distance_size = to_array_size_literal(type, 0); else if (m.builtin_type == BuiltInClipDistance) - clip_distance_size = to_array_size_literal(type); + clip_distance_size = to_array_size_literal(type, 0); if (is_block_builtin(m.builtin_type) && m.decoration_flags.get(DecorationXfbStride) && m.decoration_flags.get(DecorationXfbBuffer) && m.decoration_flags.get(DecorationOffset)) @@ -3403,6 +3466,8 @@ void CompilerGLSL::emit_declared_builtin_block(StorageClass storage, ExecutionMo auto itr = builtin_xfb_offsets.find(BuiltInPosition); if (itr != end(builtin_xfb_offsets)) statement("layout(xfb_offset = ", itr->second, ") vec4 gl_Position;"); + else if (position_invariant) + statement("invariant vec4 gl_Position;"); else statement("vec4 gl_Position;"); } @@ -3499,6 +3564,8 @@ void CompilerGLSL::emit_resources() break; } + bool global_invariant_position = position_invariant && (options.es || options.version >= 120); + // Emit custom gl_PerVertex for SSO compatibility. if (options.separate_shader_objects && !options.es && execution.model != ExecutionModelFragment) { @@ -3509,11 +3576,13 @@ void CompilerGLSL::emit_resources() case ExecutionModelTessellationEvaluation: emit_declared_builtin_block(StorageClassInput, execution.model); emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; break; case ExecutionModelVertex: case ExecutionModelMeshEXT: emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; break; default: @@ -3523,6 +3592,7 @@ void CompilerGLSL::emit_resources() else if (should_force_emit_builtin_block(StorageClassOutput)) { emit_declared_builtin_block(StorageClassOutput, execution.model); + global_invariant_position = false; } else if (execution.geometry_passthrough) { @@ -3543,7 +3613,7 @@ void CompilerGLSL::emit_resources() statement(""); } - if (position_invariant && (options.es || options.version >= 120)) + if (global_invariant_position) { statement("invariant gl_Position;"); statement(""); @@ -3561,6 +3631,10 @@ void CompilerGLSL::emit_resources() { auto &id = ir.ids[id_]; + // Skip declaring any bogus constants or undefs which use block types. + // We don't declare block types directly, so this will never work. + // Should not be legal SPIR-V, so this is considered a workaround. + if (id.get_type() == TypeConstant) { auto &c = id.get(); @@ -3618,6 +3692,10 @@ void CompilerGLSL::emit_resources() if (type.basetype == SPIRType::Void) return; + // This will break. It is bogus and should not be legal. + if (type_is_top_level_block(type)) + return; + string initializer; if (options.force_zero_initialized_variables && type_can_zero_initialize(type)) initializer = join(" = ", to_zero_initialized_expression(undef.basetype)); @@ -3654,31 +3732,34 @@ void CompilerGLSL::emit_resources() if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64EXT) { - for (auto type : physical_storage_non_block_pointer_types) - { - emit_buffer_reference_block(type, false); - } - // Output buffer reference blocks. // Do this in two stages, one with forward declaration, // and one without. Buffer reference blocks can reference themselves // to support things like linked lists. - ir.for_each_typed_id([&](uint32_t self, SPIRType &type) { - if (type.basetype == SPIRType::Struct && type.pointer && - type.pointer_depth == 1 && !type_is_array_of_pointers(type) && - type.storage == StorageClassPhysicalStorageBufferEXT) + ir.for_each_typed_id([&](uint32_t id, SPIRType &type) { + if (is_physical_pointer(type)) { - emit_buffer_reference_block(self, true); + bool emit_type = true; + if (!is_physical_pointer_to_buffer_block(type)) + { + // Only forward-declare if we intend to emit it in the non_block_pointer types. + // Otherwise, these are just "benign" pointer types that exist as a result of access chains. + emit_type = std::find(physical_storage_non_block_pointer_types.begin(), + physical_storage_non_block_pointer_types.end(), + id) != physical_storage_non_block_pointer_types.end(); + } + + if (emit_type) + emit_buffer_reference_block(id, true); } }); - ir.for_each_typed_id([&](uint32_t self, SPIRType &type) { - if (type.basetype == SPIRType::Struct && - type.pointer && type.pointer_depth == 1 && !type_is_array_of_pointers(type) && - type.storage == StorageClassPhysicalStorageBufferEXT) - { - emit_buffer_reference_block(self, false); - } + for (auto type : physical_storage_non_block_pointer_types) + emit_buffer_reference_block(type, false); + + ir.for_each_typed_id([&](uint32_t id, SPIRType &type) { + if (is_physical_pointer_to_buffer_block(type)) + emit_buffer_reference_block(id, false); }); } @@ -3887,6 +3968,7 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) auto &member_type = get(member_type_id); auto array_type = member_type; array_type.parent_type = member_type_id; + array_type.op = OpTypeArray; array_type.array.push_back(array_size); array_type.array_size_literal.push_back(true); @@ -3910,10 +3992,9 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) if (is_control_point) { uint32_t ids = ir.increase_bound_by(3); - SPIRType uint_type; + auto &uint_type = set(ids, OpTypeInt); uint_type.basetype = SPIRType::UInt; uint_type.width = 32; - set(ids, uint_type); set(ids + 1, builtin_to_glsl(BuiltInInvocationId, StorageClassInput), ids, true); set(ids + 2, ids, i, false); invocation_id = ids + 1; @@ -4960,11 +5041,8 @@ string CompilerGLSL::dereference_expression(const SPIRType &expr_type, const std return expr.substr(1); else if (backend.native_pointers) return join('*', expr); - else if (expr_type.storage == StorageClassPhysicalStorageBufferEXT && expr_type.basetype != SPIRType::Struct && - expr_type.pointer_depth == 1) - { + else if (is_physical_pointer(expr_type) && !is_physical_pointer_to_buffer_block(expr_type)) return join(enclose_expression(expr), ".value"); - } else return expr; } @@ -5109,7 +5187,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type, type.basetype == SPIRType::Boolean && backend.boolean_in_struct_remapped_type != SPIRType::Boolean; - SPIRType tmp_type; + SPIRType tmp_type { OpNop }; if (remapped_boolean) { tmp_type = get(type.parent_type); @@ -5130,7 +5208,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type, for (uint32_t i = 0; i < size; i++) { auto subexpr = join(base_expr, "[", convert_to_string(i), "]"); - if (!type_is_top_level_array(parent)) + if (!is_array(parent)) { if (remapped_boolean) subexpr = join(type_to_glsl(tmp_type), "(", subexpr, ")"); @@ -5156,7 +5234,7 @@ string CompilerGLSL::to_composite_constructor_expression(const SPIRType &parent_ type.basetype == SPIRType::Boolean && backend.boolean_in_struct_remapped_type != SPIRType::Boolean; - if (type_is_top_level_array(type)) + if (is_array(type)) { reroll_array = !backend.array_is_value_type || (block_like_type && !backend.array_is_value_type_in_buffer_blocks); @@ -5709,7 +5787,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, { auto &type = get(c.constant_type); - if (type_is_top_level_pointer(type)) + if (is_pointer(type)) { return backend.null_pointer_literal; } @@ -5724,21 +5802,21 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, // with Offset = 0, using no ArrayStride on the enclosed array type. // A particular CTS test hits this scenario. bool array_type_decays = inside_block_like_struct_scope && - type_is_top_level_array(type) && + is_array(type) && !backend.array_is_value_type_in_buffer_blocks; // Allow Metal to use the array template to make arrays a value type bool needs_trailing_tracket = false; if (backend.use_initializer_list && backend.use_typed_initializer_list && type.basetype == SPIRType::Struct && - !type_is_top_level_array(type)) + !is_array(type)) { res = type_to_glsl_constructor(type) + "{ "; } else if (backend.use_initializer_list && backend.use_typed_initializer_list && backend.array_is_value_type && - type_is_top_level_array(type) && !array_type_decays) + is_array(type) && !array_type_decays) { const auto *p_type = &type; - SPIRType tmp_type; + SPIRType tmp_type { OpNop }; if (inside_struct_scope && backend.boolean_in_struct_remapped_type != SPIRType::Boolean && @@ -5779,7 +5857,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, res += to_name(elem); else { - if (!type_is_top_level_array(type) && type.basetype == SPIRType::Struct) + if (!is_array(type) && type.basetype == SPIRType::Struct) { // When we get down to emitting struct members, override the block-like information. // For constants, we can freely mix and match block-like state. @@ -5877,7 +5955,7 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col, // of complicated workarounds, just value-cast to the half type always. if (std::isnan(float_value) || std::isinf(float_value)) { - SPIRType type; + SPIRType type { OpTypeFloat }; type.basetype = SPIRType::Half; type.vecsize = 1; type.columns = 1; @@ -5893,11 +5971,11 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col, } else { - SPIRType type; + SPIRType type { OpTypeFloat }; type.basetype = SPIRType::Half; type.vecsize = 1; type.columns = 1; - res = join(type_to_glsl(type), "(", convert_to_string(float_value, current_locale_radix_character), ")"); + res = join(type_to_glsl(type), "(", format_float(float_value), ")"); } return res; @@ -5913,8 +5991,8 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col // Use special representation. if (!is_legacy()) { - SPIRType out_type; - SPIRType in_type; + SPIRType out_type { OpTypeFloat }; + SPIRType in_type { OpTypeInt }; out_type.basetype = SPIRType::Float; in_type.basetype = SPIRType::UInt; out_type.vecsize = 1; @@ -5965,7 +6043,7 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col } else { - res = convert_to_string(float_value, current_locale_radix_character); + res = format_float(float_value); if (backend.float_literal_suffix) res += "f"; } @@ -5983,8 +6061,8 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 // Use special representation. if (!is_legacy()) { - SPIRType out_type; - SPIRType in_type; + SPIRType out_type { OpTypeFloat }; + SPIRType in_type { OpTypeInt }; out_type.basetype = SPIRType::Double; in_type.basetype = SPIRType::UInt64; out_type.vecsize = 1; @@ -6048,7 +6126,7 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 } else { - res = convert_to_string(double_value, current_locale_radix_character); + res = format_double(double_value); if (backend.double_literal_suffix) res += "lf"; } @@ -6692,7 +6770,7 @@ SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_o // Create a fake type so we can bitcast to it. // We only deal with regular arithmetic types here like int, uints and so on. - SPIRType expected_type; + SPIRType expected_type{type0.op}; expected_type.basetype = input_type; expected_type.vecsize = type0.vecsize; expected_type.columns = type0.columns; @@ -7046,7 +7124,9 @@ void CompilerGLSL::emit_bitfield_insert_op(uint32_t result_type, uint32_t result auto op2_expr = to_unpacked_expression(op2); auto op3_expr = to_unpacked_expression(op3); - SPIRType target_type; + assert(offset_count_type == SPIRType::UInt || offset_count_type == SPIRType::Int); + SPIRType target_type { OpTypeInt }; + target_type.width = 32; target_type.vecsize = 1; target_type.basetype = offset_count_type; @@ -7837,7 +7917,7 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const bool CompilerGLSL::expression_is_non_value_type_array(uint32_t ptr) { auto &type = expression_type(ptr); - if (!type_is_top_level_array(get_pointee_type(type))) + if (!is_array(get_pointee_type(type))) return false; if (!backend.array_is_value_type) @@ -9571,6 +9651,8 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) return "gl_TessLevelInner"; case BuiltInTessCoord: return "gl_TessCoord"; + case BuiltInPatchVertices: + return "gl_PatchVerticesIn"; case BuiltInFragCoord: return "gl_FragCoord"; case BuiltInPointCoord: @@ -9873,16 +9955,21 @@ void CompilerGLSL::access_chain_internal_append_index(std::string &expr, uint32_ if (ptr_chain && access_chain_is_arrayed) { size_t split_pos = expr.find_last_of(']'); - string expr_front = expr.substr(0, split_pos); - string expr_back = expr.substr(split_pos); - expr = expr_front + " + " + enclose_expression(idx_expr) + expr_back; - } - else - { - expr += "["; - expr += idx_expr; - expr += "]"; + size_t enclose_split = expr.find_last_of(')'); + + // If we have already enclosed the expression, don't try to be clever, it will break. + if (split_pos > enclose_split || enclose_split == string::npos) + { + string expr_front = expr.substr(0, split_pos); + string expr_back = expr.substr(split_pos); + expr = expr_front + " + " + enclose_expression(idx_expr) + expr_back; + return; + } } + + expr += "["; + expr += idx_expr; + expr += "]"; } bool CompilerGLSL::access_chain_needs_stage_io_builtin_translation(uint32_t) @@ -9917,6 +10004,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Start traversing type hierarchy at the proper non-pointer types, // but keep type_id referencing the original pointer for use below. uint32_t type_id = expression_type_id(base); + const auto *type = &get_pointee_type(type_id); if (!backend.native_pointers) { @@ -9926,13 +10014,10 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Wrapped buffer reference pointer types will need to poke into the internal "value" member before // continuing the access chain. if (should_dereference(base)) - { - auto &type = get(type_id); - expr = dereference_expression(type, expr); - } + expr = dereference_expression(get(type_id), expr); } - - const auto *type = &get_pointee_type(type_id); + else if (should_dereference(base) && type->basetype != SPIRType::Struct && !ptr_chain) + expr = join("(", dereference_expression(*type, expr), ")"); bool access_chain_is_arrayed = expr.find_first_of('[') != string::npos; bool row_major_matrix_needs_conversion = is_non_native_row_major_matrix(base); @@ -9942,6 +10027,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice bool relaxed_precision = has_decoration(base, DecorationRelaxedPrecision); bool pending_array_enclose = false; bool dimension_flatten = false; + bool access_meshlet_position_y = false; + + if (auto *base_expr = maybe_get(base)) + { + access_meshlet_position_y = base_expr->access_meshlet_position_y; + } // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden bool hide_first_subscript = count > 1 && is_user_type_structured(base); @@ -9967,9 +10058,21 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice index &= 0x7fffffffu; } - // Pointer chains + bool ptr_chain_array_entry = ptr_chain && i == 0 && is_array(*type); + + if (ptr_chain_array_entry) + { + // This is highly unusual code, since normally we'd use plain AccessChain, but it's still allowed. + // We are considered to have a pointer to array and one element shifts by one array at a time. + // If we use normal array indexing, we'll first decay to pointer, and lose the array-ness, + // so we have to take pointer to array explicitly. + if (!should_dereference(base)) + expr = enclose_expression(address_of_expression(expr)); + } + if (ptr_chain && i == 0) { + // Pointer chains // If we are flattening multidimensional arrays, only create opening bracket on first // array index. if (options.flatten_multidimensional_arrays) @@ -10014,6 +10117,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice } access_chain_is_arrayed = true; + + // Explicitly enclose the expression if this is one of the weird pointer-to-array cases. + // We don't want any future indexing to add to this array dereference. + // Enclosing the expression blocks that and avoids any shenanigans with operand priority. + if (ptr_chain_array_entry) + expr = join("(", expr, ")"); } // Arrays else if (!type->array.empty()) @@ -10045,8 +10154,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice switch (builtin) { - // case BuiltInCullDistance: // These are already arrays, need to figure out rules for these in tess/geom. - // case BuiltInClipDistance: + case BuiltInCullDistance: + case BuiltInClipDistance: + if (type->array.size() == 1) // Red herring. Only consider block IO for two-dimensional arrays here. + { + append_index(index, is_literal); + break; + } + // fallthrough case BuiltInPosition: case BuiltInPointSize: if (mesh_shader) @@ -10107,16 +10222,34 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (!pending_array_enclose) expr += "]"; } - // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. - // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. - else if (!builtin_translates_to_nonarray(BuiltIn(get_decoration(base, DecorationBuiltIn)))) + else if (index_is_literal || !builtin_translates_to_nonarray(BuiltIn(get_decoration(base, DecorationBuiltIn)))) { + // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. + // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. + // For literal indices we are working on composites, so we ignore this since we have already converted to proper array. append_index(index, is_literal); } + if (var && has_decoration(var->self, DecorationBuiltIn) && + get_decoration(var->self, DecorationBuiltIn) == BuiltInPosition && + get_execution_model() == ExecutionModelMeshEXT) + { + access_meshlet_position_y = true; + } + type_id = type->parent_type; type = &get(type_id); + // If the physical type has an unnatural vecsize, + // we must assume it's a faked struct where the .data member + // is used for the real payload. + if (physical_type && (is_vector(*type) || is_scalar(*type))) + { + auto &phys = get(physical_type); + if (phys.vecsize > 4) + expr += ".data"; + } + access_chain_is_arrayed = true; } // For structs, the index refers to a constant, which indexes into the members, possibly through a redirection mapping. @@ -10149,6 +10282,11 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice } else expr = builtin_to_glsl(builtin, type->storage); + + if (builtin == BuiltInPosition && get_execution_model() == ExecutionModelMeshEXT) + { + access_meshlet_position_y = true; + } } else { @@ -10197,6 +10335,16 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice expr += to_unpacked_expression(index, register_expression_read); expr += "]"; + // If the physical type has an unnatural vecsize, + // we must assume it's a faked struct where the .data member + // is used for the real payload. + if (physical_type) + { + auto &phys = get(physical_type); + if (phys.vecsize > 4 || phys.columns > 4) + expr += ".data"; + } + type_id = type->parent_type; type = &get(type_id); } @@ -10211,6 +10359,18 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (column_index != string::npos) { deferred_index = expr.substr(column_index); + + auto end_deferred_index = deferred_index.find_last_of(']'); + if (end_deferred_index != string::npos && end_deferred_index + 1 != deferred_index.size()) + { + // If we have any data member fixups, it must be transposed so that it refers to this index. + // E.g. [0].data followed by [1] would be shuffled to [1][0].data which is wrong, + // and needs to be [1].data[0] instead. + end_deferred_index++; + deferred_index = deferred_index.substr(end_deferred_index) + + deferred_index.substr(0, end_deferred_index); + } + expr.resize(column_index); } } @@ -10289,8 +10449,34 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (row_major_matrix_needs_conversion && !ignore_potential_sliced_writes) { - prepare_access_chain_for_scalar_access(expr, get(type->parent_type), effective_storage, - is_packed); + if (prepare_access_chain_for_scalar_access(expr, get(type->parent_type), effective_storage, + is_packed)) + { + // We're in a pointer context now, so just remove any member dereference. + auto first_index = deferred_index.find_first_of('['); + if (first_index != string::npos && first_index != 0) + deferred_index = deferred_index.substr(first_index); + } + } + + if (access_meshlet_position_y) + { + if (is_literal) + { + access_meshlet_position_y = index == 1; + } + else + { + const auto *c = maybe_get(index); + if (c) + access_meshlet_position_y = c->scalar() == 1; + else + { + // We don't know, but we have to assume no. + // Flip Y in mesh shaders is an opt-in horrible hack, so we'll have to assume shaders try to behave. + access_meshlet_position_y = false; + } + } } expr += deferred_index; @@ -10319,6 +10505,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice meta->storage_is_invariant = is_invariant; meta->storage_physical_type = physical_type; meta->relaxed_precision = relaxed_precision; + meta->access_meshlet_position_y = access_meshlet_position_y; } return expr; @@ -10328,8 +10515,9 @@ void CompilerGLSL::check_physical_type_cast(std::string &, const SPIRType *, uin { } -void CompilerGLSL::prepare_access_chain_for_scalar_access(std::string &, const SPIRType &, spv::StorageClass, bool &) +bool CompilerGLSL::prepare_access_chain_for_scalar_access(std::string &, const SPIRType &, spv::StorageClass, bool &) { + return false; } string CompilerGLSL::to_flattened_struct_member(const string &basename, const SPIRType &type, uint32_t index) @@ -11891,6 +12079,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) expr.loaded_from = backing_variable ? backing_variable->self : ID(ops[2]); expr.need_transpose = meta.need_transpose; expr.access_chain = true; + expr.access_meshlet_position_y = meta.access_meshlet_position_y; // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. if (meta.storage_is_packed) @@ -13986,6 +14175,66 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpImageSampleWeightedQCOM: + case OpImageBoxFilterQCOM: + case OpImageBlockMatchSSDQCOM: + case OpImageBlockMatchSADQCOM: + { + require_extension_internal("GL_QCOM_image_processing"); + uint32_t result_type_id = ops[0]; + uint32_t id = ops[1]; + string expr; + switch (opcode) + { + case OpImageSampleWeightedQCOM: + expr = "textureWeightedQCOM"; + break; + case OpImageBoxFilterQCOM: + expr = "textureBoxFilterQCOM"; + break; + case OpImageBlockMatchSSDQCOM: + expr = "textureBlockMatchSSDQCOM"; + break; + case OpImageBlockMatchSADQCOM: + expr = "textureBlockMatchSADQCOM"; + break; + default: + SPIRV_CROSS_THROW("Invalid opcode for QCOM_image_processing."); + } + expr += "("; + + bool forward = false; + expr += to_expression(ops[2]); + expr += ", " + to_expression(ops[3]); + + switch (opcode) + { + case OpImageSampleWeightedQCOM: + expr += ", " + to_non_uniform_aware_expression(ops[4]); + break; + case OpImageBoxFilterQCOM: + expr += ", " + to_expression(ops[4]); + break; + case OpImageBlockMatchSSDQCOM: + case OpImageBlockMatchSADQCOM: + expr += ", " + to_non_uniform_aware_expression(ops[4]); + expr += ", " + to_expression(ops[5]); + expr += ", " + to_expression(ops[6]); + break; + default: + SPIRV_CROSS_THROW("Invalid opcode for QCOM_image_processing."); + } + + expr += ")"; + emit_op(result_type_id, id, expr, forward); + + inherit_expression_dependencies(id, ops[3]); + if (opcode == OpImageBlockMatchSSDQCOM || opcode == OpImageBlockMatchSADQCOM) + inherit_expression_dependencies(id, ops[5]); + + break; + } + // Compute case OpControlBarrier: case OpMemoryBarrier: @@ -14871,6 +15120,17 @@ string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &ex auto column_expr = exp_str.substr(column_index); exp_str.resize(column_index); + auto end_deferred_index = column_expr.find_last_of(']'); + if (end_deferred_index != string::npos && end_deferred_index + 1 != column_expr.size()) + { + // If we have any data member fixups, it must be transposed so that it refers to this index. + // E.g. [0].data followed by [1] would be shuffled to [1][0].data which is wrong, + // and needs to be [1].data[0] instead. + end_deferred_index++; + column_expr = column_expr.substr(end_deferred_index) + + column_expr.substr(0, end_deferred_index); + } + auto transposed_expr = type_to_glsl_constructor(exp_type) + "("; // Loading a column from a row-major matrix. Unroll the load. @@ -14965,7 +15225,12 @@ string CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const Bitset { auto &execution = get_entry_point(); - if (flags.get(DecorationRelaxedPrecision)) + if (type.basetype == SPIRType::UInt && is_legacy_es()) + { + // HACK: This is a bool. See comment in type_to_glsl(). + qual += "lowp "; + } + else if (flags.get(DecorationRelaxedPrecision)) { bool implied_fmediump = type.basetype == SPIRType::Float && options.fragment.default_float_precision == Options::Mediump && @@ -15199,9 +15464,16 @@ string CompilerGLSL::pls_decl(const PlsRemap &var) { auto &variable = get(var.id); - SPIRType type; - type.vecsize = pls_format_to_components(var.format); - type.basetype = pls_format_to_basetype(var.format); + auto op_and_basetype = pls_format_to_basetype(var.format); + + SPIRType type { op_and_basetype.first }; + type.basetype = op_and_basetype.second; + auto vecsize = pls_format_to_components(var.format); + if (vecsize > 1) + { + type.op = OpTypeVector; + type.vecsize = vecsize; + } return join(to_pls_layout(var.format), to_pls_qualifiers_glsl(variable), type_to_glsl(type), " ", to_name(variable.self)); @@ -15298,13 +15570,21 @@ string CompilerGLSL::type_to_array_glsl(const SPIRType &type) } } -string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id) +string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id, bool /*member*/) { auto &imagetype = get(type.image.type); string res; switch (imagetype.basetype) { + case SPIRType::Int64: + res = "i64"; + require_extension_internal("GL_EXT_shader_image_int64"); + break; + case SPIRType::UInt64: + res = "u64"; + require_extension_internal("GL_EXT_shader_image_int64"); + break; case SPIRType::Int: case SPIRType::Short: case SPIRType::SByte: @@ -15442,17 +15722,29 @@ string CompilerGLSL::type_to_glsl_constructor(const SPIRType &type) // depend on a specific object's use of that type. string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) { - if (type.pointer && type.storage == StorageClassPhysicalStorageBufferEXT && type.basetype != SPIRType::Struct) + if (is_physical_pointer(type) && !is_physical_pointer_to_buffer_block(type)) { // Need to create a magic type name which compacts the entire type information. - string name = type_to_glsl(get_pointee_type(type)); - for (size_t i = 0; i < type.array.size(); i++) + auto *parent = &get_pointee_type(type); + string name = type_to_glsl(*parent); + + uint32_t array_stride = get_decoration(type.parent_type, DecorationArrayStride); + + // Resolve all array dimensions in one go since once we lose the pointer type, + // array information is left to to_array_type_glsl. The base type loses array information. + while (is_array(*parent)) { - if (type.array_size_literal[i]) - name += join(type.array[i], "_"); + if (parent->array_size_literal.back()) + name += join(type.array.back(), "_"); else - name += join("id", type.array[i], "_"); + name += join("id", type.array.back(), "_"); + + name += "stride_" + std::to_string(array_stride); + + array_stride = get_decoration(parent->parent_type, DecorationArrayStride); + parent = &get(parent->parent_type); } + name += "Pointer"; return name; } @@ -15491,7 +15783,11 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) if (type.basetype == SPIRType::UInt && is_legacy()) { if (options.es) - SPIRV_CROSS_THROW("Unsigned integers are not supported on legacy ESSL."); + // HACK: spirv-cross changes bools into uints and generates code which compares them to + // zero. Input code will have already been validated as not to have contained any uints, + // so any remaining uints must in fact be bools. However, simply returning "bool" here + // will result in invalid code. Instead, return an int. + return backend.basic_int_type; else require_extension_internal("GL_EXT_gpu_shader4"); } @@ -16426,6 +16722,17 @@ bool CompilerGLSL::for_loop_initializers_are_same_type(const SPIRBlock &block) return true; } +void CompilerGLSL::emit_block_instructions_with_masked_debug(SPIRBlock &block) +{ + // Have to block debug instructions such as OpLine here, since it will be treated as a statement otherwise, + // which breaks loop optimizations. + // Any line directive would be declared outside the loop body, which would just be confusing either way. + bool old_block_debug_directives = block_debug_directives; + block_debug_directives = true; + emit_block_instructions(block); + block_debug_directives = old_block_debug_directives; +} + bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method method) { SPIRBlock::ContinueBlockType continue_type = continue_block_type(get(block.continue_block)); @@ -16436,7 +16743,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. - emit_block_instructions(block); + emit_block_instructions_with_masked_debug(block); bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries); @@ -16516,7 +16823,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. - emit_block_instructions(child); + emit_block_instructions_with_masked_debug(child); bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries); @@ -17489,7 +17796,7 @@ bool CompilerGLSL::unroll_array_to_complex_store(uint32_t target_id, uint32_t so else array_expr = to_expression(type.array.back()); - SPIRType target_type; + SPIRType target_type { OpTypeInt }; target_type.basetype = SPIRType::Int; statement("for (int i = 0; i < int(", array_expr, "); i++)"); @@ -17554,7 +17861,7 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s statement(new_expr, "[i] = gl_in[i].", expr, ";"); else if (is_sample_mask) { - SPIRType target_type; + SPIRType target_type { OpTypeInt }; target_type.basetype = SPIRType::Int; statement(new_expr, "[i] = ", bitcast_expression(target_type, type.basetype, join(expr, "[i]")), ";"); } @@ -17633,6 +17940,25 @@ void CompilerGLSL::cast_from_variable_load(uint32_t source_id, std::string &expr expr = bitcast_expression(expr_type, expected_type, expr); } +SPIRType::BaseType CompilerGLSL::get_builtin_basetype(BuiltIn builtin, SPIRType::BaseType default_type) +{ + // TODO: Fill in for more builtins. + switch (builtin) + { + case BuiltInLayer: + case BuiltInPrimitiveId: + case BuiltInViewportIndex: + case BuiltInFragStencilRefEXT: + case BuiltInSampleMask: + case BuiltInPrimitiveShadingRateKHR: + case BuiltInShadingRateKHR: + return SPIRType::Int; + + default: + return default_type; + } +} + void CompilerGLSL::cast_to_variable_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) { auto *var = maybe_get_backing_variable(target_id); @@ -17644,24 +17970,7 @@ void CompilerGLSL::cast_to_variable_store(uint32_t target_id, std::string &expr, return; auto builtin = static_cast(get_decoration(target_id, DecorationBuiltIn)); - auto expected_type = expr_type.basetype; - - // TODO: Fill in for more builtins. - switch (builtin) - { - case BuiltInLayer: - case BuiltInPrimitiveId: - case BuiltInViewportIndex: - case BuiltInFragStencilRefEXT: - case BuiltInSampleMask: - case BuiltInPrimitiveShadingRateKHR: - case BuiltInShadingRateKHR: - expected_type = SPIRType::Int; - break; - - default: - break; - } + auto expected_type = get_builtin_basetype(builtin, expr_type.basetype); if (expected_type != expr_type.basetype) { @@ -17895,6 +18204,11 @@ void CompilerGLSL::emit_line_directive(uint32_t file_id, uint32_t line_literal) if (redirect_statement) return; + // If we're emitting code in a sensitive context such as condition blocks in for loops, don't emit + // any line directives, because it's not possible. + if (block_debug_directives) + return; + if (options.emit_line_directives) { require_extension_internal("GL_GOOGLE_cpp_style_line_directive"); @@ -18522,3 +18836,22 @@ uint32_t CompilerGLSL::type_to_location_count(const SPIRType &type) const return count; } + +std::string CompilerGLSL::format_float(float value) const +{ + if (float_formatter) + return float_formatter->format_float(value); + + // default behavior + return convert_to_string(value, current_locale_radix_character); +} + +std::string CompilerGLSL::format_double(double value) const +{ + if (float_formatter) + return float_formatter->format_double(value); + + // default behavior + return convert_to_string(value, current_locale_radix_character); +} + diff --git a/third_party/spirv-cross/spirv_glsl.hpp b/third_party/spirv-cross/spirv_glsl.hpp index 66b23cbeab..3ce044e39f 100644 --- a/third_party/spirv-cross/spirv_glsl.hpp +++ b/third_party/spirv-cross/spirv_glsl.hpp @@ -287,6 +287,14 @@ public: void mask_stage_output_by_location(uint32_t location, uint32_t component); void mask_stage_output_by_builtin(spv::BuiltIn builtin); + // Allow to control how to format float literals in the output. + // Set to "nullptr" to use the default "convert_to_string" function. + // This handle is not owned by SPIRV-Cross and must remain valid until compile() has been called. + void set_float_formatter(FloatFormatter *formatter) + { + float_formatter = formatter; + } + protected: struct ShaderSubgroupSupportHelper { @@ -397,6 +405,7 @@ protected: }; TemporaryCopy handle_instruction_precision(const Instruction &instr); void emit_block_instructions(SPIRBlock &block); + void emit_block_instructions_with_masked_debug(SPIRBlock &block); // For relax_nan_checks. GLSLstd450 get_remapped_glsl_op(GLSLstd450 std450_op) const; @@ -429,7 +438,7 @@ protected: virtual void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const std::string &qualifier = "", uint32_t base_offset = 0); virtual void emit_struct_padding_target(const SPIRType &type); - virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0); + virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0, bool member = false); std::string constant_expression(const SPIRConstant &c, bool inside_block_like_struct_scope = false, bool inside_struct_scope = false); @@ -545,6 +554,7 @@ protected: SmallVector *redirect_statement = nullptr; const SPIRBlock *current_continue_block = nullptr; bool block_temporary_hoisting = false; + bool block_debug_directives = false; void begin_scope(); void end_scope(); @@ -747,7 +757,7 @@ protected: virtual bool access_chain_needs_stage_io_builtin_translation(uint32_t base); virtual void check_physical_type_cast(std::string &expr, const SPIRType *type, uint32_t physical_type); - virtual void prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, + virtual bool prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, bool &is_packed); std::string access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, @@ -823,7 +833,9 @@ protected: bool buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing, uint32_t *failed_index = nullptr, uint32_t start_offset = 0, uint32_t end_offset = ~(0u)); - std::string buffer_to_packing_standard(const SPIRType &type, bool support_std430_without_scalar_layout); + std::string buffer_to_packing_standard(const SPIRType &type, + bool support_std430_without_scalar_layout, + bool support_enhanced_layouts); uint32_t type_to_packed_base_size(const SPIRType &type, BufferPackingStandard packing); uint32_t type_to_packed_alignment(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing); @@ -991,6 +1003,7 @@ protected: // Builtins in GLSL are always specific signedness, but the SPIR-V can declare them // as either unsigned or signed. // Sometimes we will need to automatically perform casts on load and store to make this work. + virtual SPIRType::BaseType get_builtin_basetype(spv::BuiltIn builtin, SPIRType::BaseType default_type); virtual void cast_to_variable_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type); virtual void cast_from_variable_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type); void unroll_array_from_complex_load(uint32_t target_id, uint32_t source_id, std::string &expr); @@ -1028,6 +1041,10 @@ protected: std::unordered_set masked_output_locations; std::unordered_set masked_output_builtins; + FloatFormatter *float_formatter = nullptr; + std::string format_float(float value) const; + std::string format_double(double value) const; + private: void init(); diff --git a/third_party/spirv-cross/spirv_hlsl.cpp b/third_party/spirv-cross/spirv_hlsl.cpp index d702197813..9b8349365e 100644 --- a/third_party/spirv-cross/spirv_hlsl.cpp +++ b/third_party/spirv-cross/spirv_hlsl.cpp @@ -1149,29 +1149,48 @@ void CompilerHLSL::emit_builtin_variables() builtins.merge_or(active_output_builtins); std::unordered_map builtin_to_initializer; - ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { - if (!is_builtin_variable(var) || var.storage != StorageClassOutput || !var.initializer) - return; - auto *c = this->maybe_get(var.initializer); - if (!c) + // We need to declare sample mask with the same type that module declares it. + // Sample mask is somewhat special in that SPIR-V has an array, and we can copy that array, so we need to + // match sign. + SPIRType::BaseType sample_mask_in_basetype = SPIRType::Void; + SPIRType::BaseType sample_mask_out_basetype = SPIRType::Void; + + ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { + if (!is_builtin_variable(var)) return; auto &type = this->get(var.basetype); - if (type.basetype == SPIRType::Struct) + auto builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn)); + + if (var.storage == StorageClassInput && builtin == BuiltInSampleMask) + sample_mask_in_basetype = type.basetype; + else if (var.storage == StorageClassOutput && builtin == BuiltInSampleMask) + sample_mask_out_basetype = type.basetype; + + if (var.initializer && var.storage == StorageClassOutput) { - uint32_t member_count = uint32_t(type.member_types.size()); - for (uint32_t i = 0; i < member_count; i++) + auto *c = this->maybe_get(var.initializer); + if (!c) + return; + + if (type.basetype == SPIRType::Struct) { - if (has_member_decoration(type.self, i, DecorationBuiltIn)) + uint32_t member_count = uint32_t(type.member_types.size()); + for (uint32_t i = 0; i < member_count; i++) { - builtin_to_initializer[get_member_decoration(type.self, i, DecorationBuiltIn)] = - c->subconstants[i]; + if (has_member_decoration(type.self, i, DecorationBuiltIn)) + { + builtin_to_initializer[get_member_decoration(type.self, i, DecorationBuiltIn)] = + c->subconstants[i]; + } } } + else if (has_decoration(var.self, DecorationBuiltIn)) + { + builtin_to_initializer[builtin] = var.initializer; + } } - else if (has_decoration(var.self, DecorationBuiltIn)) - builtin_to_initializer[get_decoration(var.self, DecorationBuiltIn)] = var.initializer; }); // Emit global variables for the interface variables which are statically used by the shader. @@ -1288,7 +1307,11 @@ void CompilerHLSL::emit_builtin_variables() break; case BuiltInSampleMask: - type = "int"; + if (active_input_builtins.get(BuiltInSampleMask)) + type = sample_mask_in_basetype == SPIRType::UInt ? "uint" : "int"; + else + type = sample_mask_out_basetype == SPIRType::UInt ? "uint" : "int"; + array_size = 1; break; case BuiltInPrimitiveId: @@ -1322,7 +1345,11 @@ void CompilerHLSL::emit_builtin_variables() // declared the input variable and we need to add the output one now. if (builtin == BuiltInSampleMask && storage == StorageClassInput && this->active_output_builtins.get(i)) { - statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), init_expr, ";"); + type = sample_mask_out_basetype == SPIRType::UInt ? "uint" : "int"; + if (array_size) + statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), "[", array_size, "]", init_expr, ";"); + else + statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), init_expr, ";"); } }); @@ -1536,6 +1563,18 @@ void CompilerHLSL::replace_illegal_names() CompilerGLSL::replace_illegal_names(); } +SPIRType::BaseType CompilerHLSL::get_builtin_basetype(BuiltIn builtin, SPIRType::BaseType default_type) +{ + switch (builtin) + { + case BuiltInSampleMask: + // We declare sample mask array with module type, so always use default_type here. + return default_type; + default: + return CompilerGLSL::get_builtin_basetype(builtin, default_type); + } +} + void CompilerHLSL::emit_resources() { auto &execution = get_entry_point(); @@ -2254,6 +2293,20 @@ void CompilerHLSL::emit_resources() end_scope(); statement(""); } + + if (is_mesh_shader && options.vertex.flip_vert_y) + { + statement("float4 spvFlipVertY(float4 v)"); + begin_scope(); + statement("return float4(v.x, -v.y, v.z, v.w);"); + end_scope(); + statement(""); + statement("float spvFlipVertY(float v)"); + begin_scope(); + statement("return -v;"); + end_scope(); + statement(""); + } } void CompilerHLSL::emit_texture_size_variants(uint64_t variant_mask, const char *vecsize_qualifier, bool uav, @@ -2379,7 +2432,7 @@ void CompilerHLSL::analyze_meshlet_writes() uint32_t op_ptr = op_type + 2; uint32_t op_var = op_type + 3; - auto &type = set(op_type); + auto &type = set(op_type, OpTypeStruct); type.basetype = SPIRType::Struct; set_name(op_type, block_name); set_decoration(op_type, DecorationBlock); @@ -3107,6 +3160,10 @@ void CompilerHLSL::emit_hlsl_entry_point() statement(builtin, " = int(stage_input.", builtin, ");"); break; + case BuiltInSampleMask: + statement(builtin, "[0] = stage_input.", builtin, ";"); + break; + case BuiltInNumWorkgroups: case BuiltInPointCoord: case BuiltInSubgroupSize: @@ -3281,6 +3338,10 @@ void CompilerHLSL::emit_hlsl_entry_point() cull, "];"); break; + case BuiltInSampleMask: + statement("stage_output.gl_SampleMask = gl_SampleMask[0];"); + break; + default: { auto builtin_expr = builtin_to_glsl(static_cast(i), StorageClassOutput); @@ -4447,7 +4508,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR { auto &type = get(chain.basetype); - SPIRType target_type; + SPIRType target_type { is_scalar(type) ? OpTypeInt : type.op }; target_type.basetype = SPIRType::UInt; target_type.vecsize = type.vecsize; target_type.columns = type.columns; @@ -4682,14 +4743,19 @@ void CompilerHLSL::emit_load(const Instruction &instruction) void CompilerHLSL::write_access_chain_array(const SPIRAccessChain &chain, uint32_t value, const SmallVector &composite_chain) { - auto &type = get(chain.basetype); + auto *ptype = &get(chain.basetype); + while (ptype->pointer) + { + ptype = &get(ptype->basetype); + } + auto &type = *ptype; // Need to use a reserved identifier here since it might shadow an identifier in the access chain input or other loops. auto ident = get_unique_identifier(); uint32_t id = ir.increase_bound_by(2); uint32_t int_type_id = id + 1; - SPIRType int_type; + SPIRType int_type { OpTypeInt }; int_type.basetype = SPIRType::Int; int_type.width = 32; set(int_type_id, int_type); @@ -4777,7 +4843,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val // Make sure we trigger a read of the constituents in the access chain. track_expression_read(chain.self); - SPIRType target_type; + SPIRType target_type { is_scalar(type) ? OpTypeInt : type.op }; target_type.basetype = SPIRType::UInt; target_type.vecsize = type.vecsize; target_type.columns = type.columns; @@ -4950,6 +5016,19 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val void CompilerHLSL::emit_store(const Instruction &instruction) { auto ops = stream(instruction); + if (options.vertex.flip_vert_y) + { + auto *expr = maybe_get(ops[0]); + if (expr != nullptr && expr->access_meshlet_position_y) + { + auto lhs = to_dereferenced_expression(ops[0]); + auto rhs = to_unpacked_expression(ops[1]); + statement(lhs, " = spvFlipVertY(", rhs, ");"); + register_write(ops[0]); + return; + } + } + auto *chain = maybe_get(ops[0]); if (chain) write_access_chain(*chain, ops[1], {}); @@ -6056,6 +6135,11 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) break; } + case OpAtomicFAddEXT: + case OpAtomicFMinEXT: + case OpAtomicFMaxEXT: + SPIRV_CROSS_THROW("Floating-point atomics are not supported in HLSL."); + case OpAtomicCompareExchange: case OpAtomicExchange: case OpAtomicISub: @@ -6499,14 +6583,14 @@ VariableID CompilerHLSL::remap_num_workgroups_builtin() uint32_t block_pointer_type_id = offset + 2; uint32_t variable_id = offset + 3; - SPIRType uint_type; + SPIRType uint_type { OpTypeVector }; uint_type.basetype = SPIRType::UInt; uint_type.width = 32; uint_type.vecsize = 3; uint_type.columns = 1; set(uint_type_id, uint_type); - SPIRType block_type; + SPIRType block_type { OpTypeStruct }; block_type.basetype = SPIRType::Struct; block_type.member_types.push_back(uint_type_id); set(block_type_id, block_type); @@ -6714,11 +6798,6 @@ void CompilerHLSL::set_hlsl_force_storage_buffer_as_uav(uint32_t desc_set, uint3 force_uav_buffer_bindings.insert(pair); } -bool CompilerHLSL::builtin_translates_to_nonarray(spv::BuiltIn builtin) const -{ - return (builtin == BuiltInSampleMask); -} - bool CompilerHLSL::is_user_type_structured(uint32_t id) const { if (hlsl_options.preserve_structured_buffers) diff --git a/third_party/spirv-cross/spirv_hlsl.hpp b/third_party/spirv-cross/spirv_hlsl.hpp index a5d30b1b2a..bec458c612 100644 --- a/third_party/spirv-cross/spirv_hlsl.hpp +++ b/third_party/spirv-cross/spirv_hlsl.hpp @@ -126,7 +126,7 @@ public: // By default, a readonly storage buffer will be declared as ByteAddressBuffer (SRV) instead. // Alternatively, use set_hlsl_force_storage_buffer_as_uav to specify individually. bool force_storage_buffer_as_uav = false; - + // Forces any storage image type marked as NonWritable to be considered an SRV instead. // For this to work with function call parameters, NonWritable must be considered to be part of the type system // so that NonWritable image arguments are also translated to Texture rather than RWTexture. @@ -290,6 +290,8 @@ private: const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override; void replace_illegal_names() override; + SPIRType::BaseType get_builtin_basetype(spv::BuiltIn builtin, SPIRType::BaseType default_type) override; + bool is_hlsl_force_storage_buffer_as_uav(ID id) const; Options hlsl_options; @@ -400,9 +402,6 @@ private: bool used = false; } base_vertex_info; - // Returns true for BuiltInSampleMask because gl_SampleMask[] is an array in SPIR-V, but SV_Coverage is a scalar in HLSL. - bool builtin_translates_to_nonarray(spv::BuiltIn builtin) const override; - // Returns true if the specified ID has a UserTypeGOOGLE decoration for StructuredBuffer or RWStructuredBuffer resources. bool is_user_type_structured(uint32_t id) const override; diff --git a/third_party/spirv-cross/spirv_msl.cpp b/third_party/spirv-cross/spirv_msl.cpp index 8d83d7e031..a6dd8da9af 100644 --- a/third_party/spirv-cross/spirv_msl.cpp +++ b/third_party/spirv-cross/spirv_msl.cpp @@ -189,10 +189,21 @@ bool CompilerMSL::is_msl_resource_binding_used(ExecutionModel model, uint32_t de return itr != end(resource_bindings) && itr->second.second; } -// Returns the size of the array of resources used by the variable with the specified id. -// The returned value is retrieved from the resource binding added using add_msl_resource_binding(). -uint32_t CompilerMSL::get_resource_array_size(uint32_t id) const +bool CompilerMSL::is_var_runtime_size_array(const SPIRVariable &var) const { + auto& type = get_variable_data_type(var); + return is_runtime_size_array(type) && get_resource_array_size(type, var.self) == 0; +} + +// Returns the size of the array of resources used by the variable with the specified type and id. +// The size is first retrieved from the type, but in the case of runtime array sizing, +// the size is retrieved from the resource binding added using add_msl_resource_binding(). +uint32_t CompilerMSL::get_resource_array_size(const SPIRType &type, uint32_t id) const +{ + uint32_t array_size = to_array_size_literal(type); + if (array_size) + return array_size; + StageSetBinding tuple = { get_entry_point().model, get_decoration(id, DecorationDescriptorSet), get_decoration(id, DecorationBinding) }; auto itr = resource_bindings.find(tuple); @@ -473,14 +484,14 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 2; // Create gl_FragCoord. - SPIRType vec4_type; + SPIRType vec4_type { OpTypeVector }; vec4_type.basetype = SPIRType::Float; vec4_type.width = 32; vec4_type.vecsize = 4; set(type_id, vec4_type); - SPIRType vec4_type_ptr; - vec4_type_ptr = vec4_type; + SPIRType vec4_type_ptr = vec4_type; + vec4_type_ptr.op = OpTypePointer; vec4_type_ptr.pointer = true; vec4_type_ptr.pointer_depth++; vec4_type_ptr.parent_type = type_id; @@ -501,8 +512,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_Layer. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -523,8 +534,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_ViewIndex. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -546,8 +557,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_SampleID. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -566,8 +577,8 @@ void CompilerMSL::build_implicit_builtins() { uint32_t type_ptr_id = ir.increase_bound_by(1); - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -626,8 +637,8 @@ void CompilerMSL::build_implicit_builtins() // Note that we can't just abuse gl_ViewIndex for this purpose: it's an input, but // gl_Layer is an output in vertex-pipeline shaders. uint32_t type_ptr_out_id = ir.increase_bound_by(2); - SPIRType uint_type_ptr_out; - uint_type_ptr_out = get_uint_type(); + SPIRType uint_type_ptr_out = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr_out.pointer = true; uint_type_ptr_out.pointer_depth++; uint_type_ptr_out.parent_type = get_uint_type_id(); @@ -658,8 +669,8 @@ void CompilerMSL::build_implicit_builtins() { uint32_t type_ptr_id = ir.increase_bound_by(1); - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -718,8 +729,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_SubgroupInvocationID. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -740,8 +751,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_SubgroupSize. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -799,8 +810,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_SampleMask. - SPIRType uint_type_ptr_out; - uint_type_ptr_out = get_uint_type(); + SPIRType uint_type_ptr_out = get_uint_type(); + uint_type_ptr_out.op = OpTypePointer; uint_type_ptr_out.pointer = true; uint_type_ptr_out.pointer_depth++; uint_type_ptr_out.parent_type = get_uint_type_id(); @@ -822,14 +833,14 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 2; // Create gl_HelperInvocation. - SPIRType bool_type; + SPIRType bool_type { OpTypeBool }; bool_type.basetype = SPIRType::Boolean; bool_type.width = 8; bool_type.vecsize = 1; set(type_id, bool_type); - SPIRType bool_type_ptr_in; - bool_type_ptr_in = bool_type; + SPIRType bool_type_ptr_in = bool_type; + bool_type_ptr_in.op = spv::OpTypePointer; bool_type_ptr_in.pointer = true; bool_type_ptr_in.pointer_depth++; bool_type_ptr_in.parent_type = type_id; @@ -850,8 +861,8 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 1; // Create gl_LocalInvocationIndex. - SPIRType uint_type_ptr; - uint_type_ptr = get_uint_type(); + SPIRType uint_type_ptr = get_uint_type(); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); @@ -874,6 +885,7 @@ void CompilerMSL::build_implicit_builtins() // Create gl_WorkgroupSize. uint32_t type_id = build_extended_vector_type(get_uint_type_id(), 3); SPIRType uint_type_ptr = get(type_id); + uint_type_ptr.op = OpTypePointer; uint_type_ptr.pointer = true; uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = type_id; @@ -981,14 +993,14 @@ void CompilerMSL::build_implicit_builtins() uint32_t var_id = offset + 2; // Create gl_Position. - SPIRType vec4_type; + SPIRType vec4_type { OpTypeVector }; vec4_type.basetype = SPIRType::Float; vec4_type.width = 32; vec4_type.vecsize = 4; set(type_id, vec4_type); - SPIRType vec4_type_ptr; - vec4_type_ptr = vec4_type; + SPIRType vec4_type_ptr = vec4_type; + vec4_type_ptr.op = OpTypePointer; vec4_type_ptr.pointer = true; vec4_type_ptr.pointer_depth++; vec4_type_ptr.parent_type = type_id; @@ -1065,6 +1077,7 @@ uint32_t CompilerMSL::build_constant_uint_array_pointer() // Create a buffer to hold extra data, including the swizzle constants. SPIRType uint_type_pointer = get_uint_type(); + uint_type_pointer.op = OpTypePointer; uint_type_pointer.pointer = true; uint_type_pointer.pointer_depth++; uint_type_pointer.parent_type = get_uint_type_id(); @@ -1143,7 +1156,7 @@ uint32_t CompilerMSL::get_uint_type_id() uint_type_id = ir.increase_bound_by(1); - SPIRType type; + SPIRType type { OpTypeInt }; type.basetype = SPIRType::UInt; type.width = 32; set(uint_type_id, type); @@ -1269,8 +1282,7 @@ void CompilerMSL::emit_entry_point_declarations() args.push_back(join("max_anisotropy(", s.max_anisotropy, ")")); if (s.lod_clamp_enable) { - args.push_back(join("lod_clamp(", convert_to_string(s.lod_clamp_min, current_locale_radix_character), ", ", - convert_to_string(s.lod_clamp_max, current_locale_radix_character), ")")); + args.push_back(join("lod_clamp(", format_float(s.lod_clamp_min), ", ", format_float(s.lod_clamp_max), ")")); } // If we would emit no arguments, then omit the parentheses entirely. Otherwise, @@ -1354,23 +1366,63 @@ void CompilerMSL::emit_entry_point_declarations() } } - // Emit buffer arrays here. - for (uint32_t array_id : buffer_arrays_discrete) + bool has_runtime_array_declaration = false; + for (SPIRVariable *arg : entry_point_bindings) { - const auto &var = get(array_id); + const auto &var = *arg; const auto &type = get_variable_data_type(var); const auto &buffer_type = get_variable_element_type(var); - string name = to_name(array_id); - statement(get_argument_address_space(var), " ", type_to_glsl(buffer_type), "* ", to_restrict(array_id, true), name, - "[] ="); - begin_scope(); - for (uint32_t i = 0; i < to_array_size_literal(type); ++i) - statement(name, "_", i, ","); - end_scope_decl(); - statement_no_indent(""); + const string name = to_name(var.self); + if (is_var_runtime_size_array(var)) + { + if (msl_options.argument_buffers_tier < Options::ArgumentBuffersTier::Tier2) + { + SPIRV_CROSS_THROW("Unsized array of descriptors requires argument buffer tier 2"); + } + + string resource_name; + if (descriptor_set_is_argument_buffer(get_decoration(var.self, DecorationDescriptorSet))) + resource_name = ir.meta[var.self].decoration.qualified_alias; + else + resource_name = name + "_"; + + switch (type.basetype) + { + case SPIRType::Image: + case SPIRType::Sampler: + case SPIRType::AccelerationStructure: + statement("spvDescriptorArray<", type_to_glsl(buffer_type), "> ", name, " {", resource_name, "};"); + break; + case SPIRType::SampledImage: + statement("spvDescriptorArray<", type_to_glsl(buffer_type), "> ", name, " {", resource_name, "};"); + // Unsupported with argument buffer for now. + statement("spvDescriptorArray ", name, "Smplr {", name, "Smplr_};"); + break; + case SPIRType::Struct: + statement("spvDescriptorArray<", get_argument_address_space(var), " ", type_to_glsl(buffer_type), "*> ", + name, " {", resource_name, "};"); + break; + default: + break; + } + has_runtime_array_declaration = true; + } + else if (!type.array.empty() && type.basetype == SPIRType::Struct) + { + // Emit only buffer arrays here. + statement(get_argument_address_space(var), " ", type_to_glsl(buffer_type), "* ", + to_restrict(var.self, true), name, "[] ="); + begin_scope(); + uint32_t array_size = get_resource_array_size(type, var.self); + for (uint32_t i = 0; i < array_size; ++i) + statement(name, "_", i, ","); + end_scope_decl(); + statement_no_indent(""); + } } - // Discrete descriptors are processed in entry point emission every compiler iteration. - buffer_arrays_discrete.clear(); + + if (has_runtime_array_declaration) + statement_no_indent(""); // Emit buffer aliases here. for (auto &var_id : buffer_aliases_discrete) @@ -1427,7 +1479,7 @@ void CompilerMSL::emit_entry_point_declarations() { auto &var = get(var_id); add_local_variable_name(var_id); - statement(variable_decl(var), ";"); + statement(CompilerGLSL::variable_decl(var), ";"); var.deferred_declaration = false; } } @@ -1867,9 +1919,18 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: case OpAtomicOr: case OpAtomicXor: case OpImageWrite: + { if (needs_frag_discard_checks()) added_arg_ids.insert(builtin_helper_invocation_id); + uint32_t ptr = 0; + if (op == OpAtomicStore || op == OpImageWrite) + ptr = ops[0]; + else + ptr = ops[2]; + if (global_var_ids.find(ptr) != global_var_ids.end()) + added_arg_ids.insert(ptr); break; + } // Emulate texture2D atomic operations case OpImageTexelPointer: @@ -1877,8 +1938,15 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: // When using the pointer, we need to know which variable it is actually loaded from. uint32_t base_id = ops[2]; auto *var = maybe_get_backing_variable(base_id); - if (var && atomic_image_vars.count(var->self)) + if (var) { + if (atomic_image_vars_emulated.count(var->self) && + !get(var->basetype).array.empty()) + { + SPIRV_CROSS_THROW( + "Cannot emulate array of storage images with atomics. Use MSL 3.1 for native support."); + } + if (global_var_ids.find(base_id) != global_var_ids.end()) added_arg_ids.insert(base_id); } @@ -2284,9 +2352,27 @@ uint32_t CompilerMSL::get_target_components_for_fragment_location(uint32_t locat uint32_t CompilerMSL::build_extended_vector_type(uint32_t type_id, uint32_t components, SPIRType::BaseType basetype) { + assert(components > 1); uint32_t new_type_id = ir.increase_bound_by(1); - auto &old_type = get(type_id); - auto *type = &set(new_type_id, old_type); + const auto *p_old_type = &get(type_id); + const SPIRType *old_ptr_t = nullptr; + const SPIRType *old_array_t = nullptr; + + if (is_pointer(*p_old_type)) + { + old_ptr_t = p_old_type; + p_old_type = &get_pointee_type(*old_ptr_t); + } + + if (is_array(*p_old_type)) + { + old_array_t = p_old_type; + p_old_type = &get_type(old_array_t->parent_type); + } + + auto *type = &set(new_type_id, *p_old_type); + assert(is_scalar(*type) || is_vector(*type)); + type->op = OpTypeVector; type->vecsize = components; if (basetype != SPIRType::Unknown) type->basetype = basetype; @@ -2296,23 +2382,24 @@ uint32_t CompilerMSL::build_extended_vector_type(uint32_t type_id, uint32_t comp type->array_size_literal.clear(); type->pointer = false; - if (is_array(old_type)) + if (old_array_t) { uint32_t array_type_id = ir.increase_bound_by(1); type = &set(array_type_id, *type); + type->op = OpTypeArray; type->parent_type = new_type_id; - type->array = old_type.array; - type->array_size_literal = old_type.array_size_literal; + type->array = old_array_t->array; + type->array_size_literal = old_array_t->array_size_literal; new_type_id = array_type_id; } - if (old_type.pointer) + if (old_ptr_t) { uint32_t ptr_type_id = ir.increase_bound_by(1); type = &set(ptr_type_id, *type); - type->self = new_type_id; + type->op = OpTypePointer; type->parent_type = new_type_id; - type->storage = old_type.storage; + type->storage = old_ptr_t->storage; type->pointer = true; type->pointer_depth++; new_type_id = ptr_type_id; @@ -3389,9 +3476,6 @@ void CompilerMSL::emit_local_masked_variable(const SPIRVariable &masked_var, boo auto &type = get_variable_data_type(masked_var); add_local_variable_name(masked_var.self); - bool old_is_builtin = is_using_builtin_array; - is_using_builtin_array = true; - const uint32_t max_control_points_per_patch = 32u; uint32_t max_num_instances = (max_control_points_per_patch + get_entry_point().output_vertices - 1u) / @@ -3407,14 +3491,12 @@ void CompilerMSL::emit_local_masked_variable(const SPIRVariable &masked_var, boo // since Metal does not allow that. :( // FIXME: We will likely need an option to support passing down target workgroup size, // so we can emit appropriate size here. - statement("threadgroup ", type_to_glsl(type), " ", - "(&", to_name(masked_var.self), ")", - type_to_array_glsl(type), " = spvStorage", to_name(masked_var.self), "[", + statement("threadgroup auto ", + "&", to_name(masked_var.self), + " = spvStorage", to_name(masked_var.self), "[", "(", to_expression(builtin_invocation_id_id), ".x / ", get_entry_point().output_vertices, ") % ", max_num_instances, "];"); - - is_using_builtin_array = old_is_builtin; }); } else @@ -3890,7 +3972,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) // declaraion is emitted, because it is cleared after each compilation pass. uint32_t next_id = ir.increase_bound_by(3); uint32_t ib_type_id = next_id++; - auto &ib_type = set(ib_type_id); + auto &ib_type = set(ib_type_id, OpTypeStruct); ib_type.basetype = SPIRType::Struct; ib_type.storage = storage; set_decoration(ib_type_id, DecorationBlock); @@ -4113,13 +4195,14 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) continue; // Create a fake variable to put at the location. - uint32_t offset = ir.increase_bound_by(4); + uint32_t offset = ir.increase_bound_by(5); uint32_t type_id = offset; - uint32_t array_type_id = offset + 1; - uint32_t ptr_type_id = offset + 2; - uint32_t var_id = offset + 3; + uint32_t vec_type_id = offset + 1; + uint32_t array_type_id = offset + 2; + uint32_t ptr_type_id = offset + 3; + uint32_t var_id = offset + 4; - SPIRType type; + SPIRType type { OpTypeInt }; switch (input.second.format) { case MSL_SHADER_VARIABLE_FORMAT_UINT16: @@ -4133,14 +4216,23 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) type.width = 32; break; } - type.vecsize = input.second.vecsize; set(type_id, type); + if (input.second.vecsize > 1) + { + type.op = OpTypeVector; + type.vecsize = input.second.vecsize; + set(vec_type_id, type); + type_id = vec_type_id; + } + type.op = OpTypeArray; type.array.push_back(0); type.array_size_literal.push_back(true); type.parent_type = type_id; set(array_type_id, type); + type.self = type_id; + type.op = OpTypePointer; type.pointer = true; type.pointer_depth++; type.parent_type = array_type_id; @@ -4171,13 +4263,14 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) continue; // Create a fake variable to put at the location. - uint32_t offset = ir.increase_bound_by(4); + uint32_t offset = ir.increase_bound_by(5); uint32_t type_id = offset; - uint32_t array_type_id = offset + 1; - uint32_t ptr_type_id = offset + 2; - uint32_t var_id = offset + 3; + uint32_t vec_type_id = offset + 1; + uint32_t array_type_id = offset + 2; + uint32_t ptr_type_id = offset + 3; + uint32_t var_id = offset + 4; - SPIRType type; + SPIRType type { OpTypeInt }; switch (output.second.format) { case MSL_SHADER_VARIABLE_FORMAT_UINT16: @@ -4191,17 +4284,25 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) type.width = 32; break; } - type.vecsize = output.second.vecsize; set(type_id, type); + if (output.second.vecsize > 1) + { + type.op = OpTypeVector; + type.vecsize = output.second.vecsize; + set(vec_type_id, type); + type_id = vec_type_id; + } if (is_tesc_shader()) { + type.op = OpTypeArray; type.array.push_back(0); type.array_size_literal.push_back(true); type.parent_type = type_id; set(array_type_id, type); } + type.op = OpTypePointer; type.pointer = true; type.pointer_depth++; type.parent_type = is_tesc_shader() ? array_type_id : type_id; @@ -4288,6 +4389,7 @@ uint32_t CompilerMSL::add_interface_block_pointer(uint32_t ib_var_id, StorageCla // do the same with our struct here. uint32_t ib_ptr_type_id = next_id++; auto &ib_ptr_type = set(ib_ptr_type_id, ib_type); + ib_ptr_type.op = OpTypePointer; ib_ptr_type.parent_type = ib_ptr_type.type_alias = ib_type.self; ib_ptr_type.pointer = true; ib_ptr_type.pointer_depth++; @@ -4342,23 +4444,24 @@ uint32_t CompilerMSL::add_interface_block_pointer(uint32_t ib_var_id, StorageCla uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn builtin) { auto &type = get(type_id); + auto &pointee_type = get_pointee_type(type); - if ((builtin == BuiltInSampleMask && is_array(type)) || + if ((builtin == BuiltInSampleMask && is_array(pointee_type)) || ((builtin == BuiltInLayer || builtin == BuiltInViewportIndex || builtin == BuiltInFragStencilRefEXT) && - type.basetype != SPIRType::UInt)) + pointee_type.basetype != SPIRType::UInt)) { - uint32_t next_id = ir.increase_bound_by(type.pointer ? 2 : 1); + uint32_t next_id = ir.increase_bound_by(type_is_pointer(type) ? 2 : 1); uint32_t base_type_id = next_id++; - auto &base_type = set(base_type_id); + auto &base_type = set(base_type_id, OpTypeInt); base_type.basetype = SPIRType::UInt; base_type.width = 32; - if (!type.pointer) + if (!type_is_pointer(type)) return base_type_id; uint32_t ptr_type_id = next_id++; - auto &ptr_type = set(ptr_type_id); - ptr_type = base_type; + auto &ptr_type = set(ptr_type_id, base_type); + ptr_type.op = spv::OpTypePointer; ptr_type.pointer = true; ptr_type.pointer_depth++; ptr_type.storage = type.storage; @@ -4731,9 +4834,17 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in if (elems_per_stride == 3) SPIRV_CROSS_THROW("Cannot use ArrayStride of 3 elements in remapping scenarios."); - else if (elems_per_stride > 4) + else if (elems_per_stride > 4 && elems_per_stride != 8) SPIRV_CROSS_THROW("Cannot represent vectors with more than 4 elements in MSL."); + if (elems_per_stride == 8) + { + if (mbr_type.width == 16) + add_spv_func_and_recompile(SPVFuncImplPaddedStd140); + else + SPIRV_CROSS_THROW("Unexpected type in std140 wide array resolve."); + } + auto physical_type = mbr_type; physical_type.vecsize = elems_per_stride; physical_type.parent_type = 0; @@ -4765,13 +4876,20 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in if (elems_per_stride == 3) SPIRV_CROSS_THROW("Cannot use ArrayStride of 3 elements in remapping scenarios."); - else if (elems_per_stride > 4) + else if (elems_per_stride > 4 && elems_per_stride != 8) SPIRV_CROSS_THROW("Cannot represent vectors with more than 4 elements in MSL."); - bool row_major = has_member_decoration(ib_type.self, index, DecorationRowMajor); + if (elems_per_stride == 8) + { + if (mbr_type.basetype != SPIRType::Half) + SPIRV_CROSS_THROW("Unexpected type in std140 wide matrix stride resolve."); + add_spv_func_and_recompile(SPVFuncImplPaddedStd140); + } + bool row_major = has_member_decoration(ib_type.self, index, DecorationRowMajor); auto physical_type = mbr_type; physical_type.parent_type = 0; + if (row_major) physical_type.columns = elems_per_stride; else @@ -4833,6 +4951,7 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in { type.columns = 1; assert(type.array.empty()); + type.op = OpTypeArray; type.array.push_back(1); type.array_size_literal.push_back(true); } @@ -4849,6 +4968,7 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in type.vecsize = type.columns; type.columns = 1; assert(type.array.empty()); + type.op = OpTypeArray; type.array.push_back(1); type.array_size_literal.push_back(true); } @@ -4871,9 +4991,18 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp bool transpose = lhs_e && lhs_e->need_transpose; - // No physical type remapping, and no packed type, so can just emit a store directly. - if (!lhs_remapped_type && !lhs_packed_type) + if (has_decoration(lhs_expression, DecorationBuiltIn) && + BuiltIn(get_decoration(lhs_expression, DecorationBuiltIn)) == BuiltInSampleMask && + is_array(type)) { + // Storing an array to SampleMask, have to remove the array-ness before storing. + statement(to_expression(lhs_expression), " = ", to_enclosed_unpacked_expression(rhs_expression), "[0];"); + register_write(lhs_expression); + } + else if (!lhs_remapped_type && !lhs_packed_type) + { + // No physical type remapping, and no packed type, so can just emit a store directly. + // We might not be dealing with remapped physical types or packed types, // but we might be doing a clean store to a row-major matrix. // In this case, we just flip transpose states, and emit the store, a transpose must be in the RHS expression, if any. @@ -5061,6 +5190,13 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp { auto lhs_expr = to_enclosed_expression(lhs_expression); auto column_index = lhs_expr.find_last_of('['); + + // Get rid of any ".data" half8 handling here, we're casting to scalar anyway. + auto end_column_index = lhs_expr.find_last_of(']'); + auto end_dot_index = lhs_expr.find_last_of('.'); + if (end_dot_index != string::npos && end_dot_index > end_column_index) + lhs_expr.resize(end_dot_index); + if (column_index != string::npos) { statement("((", cast_addr_space, " ", type_to_glsl(write_type), "*)&", @@ -5071,7 +5207,9 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp lhs_e->need_transpose = true; } - else if ((is_matrix(physical_type) || is_array(physical_type)) && physical_type.vecsize > type.vecsize) + else if ((is_matrix(physical_type) || is_array(physical_type)) && + physical_type.vecsize <= 4 && + physical_type.vecsize > type.vecsize) { assert(type.vecsize >= 1 && type.vecsize <= 3); @@ -5128,19 +5266,26 @@ string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type ".x", ".xy", ".xyz", + "", }; + // TODO: Move everything to the template wrapper? + bool uses_std140_wrapper = physical_type && physical_type->vecsize > 4; + if (physical_type && is_vector(*physical_type) && is_array(*physical_type) && + !uses_std140_wrapper && physical_type->vecsize > type.vecsize && !expression_ends_with(expr_str, swizzle_lut[type.vecsize - 1])) { // std140 array cases for vectors. assert(type.vecsize >= 1 && type.vecsize <= 3); return enclose_expression(expr_str) + swizzle_lut[type.vecsize - 1]; } - else if (physical_type && is_matrix(*physical_type) && is_vector(type) && physical_type->vecsize > type.vecsize) + else if (physical_type && is_matrix(*physical_type) && is_vector(type) && + !uses_std140_wrapper && + physical_type->vecsize > type.vecsize) { // Extract column from padded matrix. - assert(type.vecsize >= 1 && type.vecsize <= 3); + assert(type.vecsize >= 1 && type.vecsize <= 4); return enclose_expression(expr_str) + swizzle_lut[type.vecsize - 1]; } else if (is_matrix(type)) @@ -5162,6 +5307,7 @@ string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type string unpack_expr = join(base_type, columns, "x", vecsize, "("); const char *load_swiz = ""; + const char *data_swiz = physical_vecsize > 4 ? ".data" : ""; if (physical_vecsize != vecsize) load_swiz = swizzle_lut[vecsize - 1]; @@ -5174,7 +5320,7 @@ string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type if (packed) unpack_expr += join(base_type, physical_vecsize, "(", expr_str, "[", i, "]", ")", load_swiz); else - unpack_expr += join(expr_str, "[", i, "]", load_swiz); + unpack_expr += join(expr_str, "[", i, "]", data_swiz, load_swiz); } unpack_expr += ")"; @@ -5640,6 +5786,31 @@ void CompilerMSL::emit_custom_functions() break; } + // Fix up gradient vectors when sampling a cube texture for Apple Silicon. + // h/t Alexey Knyazev (https://github.com/KhronosGroup/MoltenVK/issues/2068#issuecomment-1817799067) for the code. + case SPVFuncImplGradientCube: + statement("static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy)"); + begin_scope(); + statement("// Major axis selection"); + statement("float3 absP = abs(P);"); + statement("bool xMajor = absP.x >= max(absP.y, absP.z);"); + statement("bool yMajor = absP.y >= absP.z;"); + statement("float3 Q = xMajor ? P.yzx : (yMajor ? P.xzy : P);"); + statement("float3 dQdx = xMajor ? dPdx.yzx : (yMajor ? dPdx.xzy : dPdx);"); + statement("float3 dQdy = xMajor ? dPdy.yzx : (yMajor ? dPdy.xzy : dPdy);"); + statement_no_indent(""); + statement("// Skip a couple of operations compared to usual projection"); + statement("float4 d = float4(dQdx.xy, dQdy.xy) - (Q.xy / Q.z).xyxy * float4(dQdx.zz, dQdy.zz);"); + statement_no_indent(""); + statement("// Final swizzle to put the intermediate values into non-ignored components"); + statement("// X major: X and Z"); + statement("// Y major: X and Y"); + statement("// Z major: Y and Z"); + statement("return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz);"); + end_scope(); + statement(""); + break; + // "fadd" intrinsic support case SPVFuncImplFAdd: statement("template"); @@ -7187,6 +7358,134 @@ void CompilerMSL::emit_custom_functions() end_scope(); end_scope_decl(); statement(""); + break; + + case SPVFuncImplRayQueryIntersectionParams: + statement("intersection_params spvMakeIntersectionParams(uint flags)"); + begin_scope(); + statement("intersection_params ip;"); + statement("if ((flags & ", RayFlagsOpaqueKHRMask, ") != 0)"); + statement(" ip.force_opacity(forced_opacity::opaque);"); + statement("if ((flags & ", RayFlagsNoOpaqueKHRMask, ") != 0)"); + statement(" ip.force_opacity(forced_opacity::non_opaque);"); + statement("if ((flags & ", RayFlagsTerminateOnFirstHitKHRMask, ") != 0)"); + statement(" ip.accept_any_intersection(true);"); + // RayFlagsSkipClosestHitShaderKHRMask is not available in MSL + statement("if ((flags & ", RayFlagsCullBackFacingTrianglesKHRMask, ") != 0)"); + statement(" ip.set_triangle_cull_mode(triangle_cull_mode::back);"); + statement("if ((flags & ", RayFlagsCullFrontFacingTrianglesKHRMask, ") != 0)"); + statement(" ip.set_triangle_cull_mode(triangle_cull_mode::front);"); + statement("if ((flags & ", RayFlagsCullOpaqueKHRMask, ") != 0)"); + statement(" ip.set_opacity_cull_mode(opacity_cull_mode::opaque);"); + statement("if ((flags & ", RayFlagsCullNoOpaqueKHRMask, ") != 0)"); + statement(" ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque);"); + statement("if ((flags & ", RayFlagsSkipTrianglesKHRMask, ") != 0)"); + statement(" ip.set_geometry_cull_mode(geometry_cull_mode::triangle);"); + statement("if ((flags & ", RayFlagsSkipAABBsKHRMask, ") != 0)"); + statement(" ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box);"); + statement("return ip;"); + end_scope(); + statement(""); + break; + + case SPVFuncImplVariableDescriptor: + statement("template"); + statement("struct spvDescriptor"); + begin_scope(); + statement("T value;"); + end_scope_decl(); + statement(""); + break; + + case SPVFuncImplVariableSizedDescriptor: + statement("template"); + statement("struct spvBufferDescriptor"); + begin_scope(); + statement("T value;"); + statement("int length;"); + statement("const device T& operator -> () const device"); + begin_scope(); + statement("return value;"); + end_scope(); + statement("const device T& operator * () const device"); + begin_scope(); + statement("return value;"); + end_scope(); + end_scope_decl(); + statement(""); + break; + + case SPVFuncImplVariableDescriptorArray: + if (spv_function_implementations.count(SPVFuncImplVariableDescriptor) != 0) + { + statement("template"); + statement("struct spvDescriptorArray"); + begin_scope(); + statement("spvDescriptorArray(const device spvDescriptor* ptr) : ptr(ptr)"); + begin_scope(); + end_scope(); + statement("const device T& operator [] (size_t i) const"); + begin_scope(); + statement("return ptr[i].value;"); + end_scope(); + statement("const device spvDescriptor* ptr;"); + end_scope_decl(); + statement(""); + } + else + { + statement("template"); + statement("struct spvDescriptorArray;"); + statement(""); + } + + if (msl_options.runtime_array_rich_descriptor && + spv_function_implementations.count(SPVFuncImplVariableSizedDescriptor) != 0) + { + statement("template"); + statement("struct spvDescriptorArray"); + begin_scope(); + statement("spvDescriptorArray(const device spvBufferDescriptor* ptr) : ptr(ptr)"); + begin_scope(); + end_scope(); + statement("const device T* operator [] (size_t i) const"); + begin_scope(); + statement("return ptr[i].value;"); + end_scope(); + statement("const int length(int i) const"); + begin_scope(); + statement("return ptr[i].length;"); + end_scope(); + statement("const device spvBufferDescriptor* ptr;"); + end_scope_decl(); + statement(""); + } + break; + + case SPVFuncImplPaddedStd140: + // .data is used in access chain. + statement("template "); + statement("struct spvPaddedStd140 { alignas(16) T data; };"); + statement("template "); + statement("using spvPaddedStd140Matrix = spvPaddedStd140[n];"); + statement(""); + break; + + case SPVFuncImplReduceAdd: + // Metal doesn't support __builtin_reduce_add or simd_reduce_add, so we need this. + // Metal also doesn't support the other vector builtins, which would have been useful to make this a single template. + + statement("template "); + statement("T reduce_add(vec v) { return v.x + v.y; }"); + + statement("template "); + statement("T reduce_add(vec v) { return v.x + v.y + v.z; }"); + + statement("template "); + statement("T reduce_add(vec v) { return v.x + v.y + v.z + v.w; }"); + + statement(""); + break; default: break; @@ -7235,7 +7534,7 @@ void CompilerMSL::declare_constant_arrays() // FIXME: However, hoisting constants to main() means we need to pass down constant arrays to leaf functions if they are used there. // If there are multiple functions in the module, drop this case to avoid breaking use cases which do not need to // link into Metal libraries. This is hacky. - if (type_is_top_level_array(type) && (!fully_inlined || is_scalar(type) || is_vector(type))) + if (is_array(type) && (!fully_inlined || is_scalar(type) || is_vector(type))) { add_resource_name(c.self); auto name = to_name(c.self); @@ -7267,7 +7566,7 @@ void CompilerMSL::declare_complex_constant_arrays() return; auto &type = this->get(c.constant_type); - if (type_is_top_level_array(type) && !(is_scalar(type) || is_vector(type))) + if (is_array(type) && !(is_scalar(type) || is_vector(type))) { add_resource_name(c.self); auto name = to_name(c.self); @@ -8006,8 +8305,9 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l // We're not going to emit the actual member name, we let any further OpLoad take care of that. // Tag the access chain with the member index we're referencing. - bool defer_access_chain = flatten_composites && (is_matrix(result_ptr_type) || is_array(result_ptr_type) || - result_ptr_type.basetype == SPIRType::Struct); + auto &result_pointee_type = get_pointee_type(result_ptr_type); + bool defer_access_chain = flatten_composites && (is_matrix(result_pointee_type) || is_array(result_pointee_type) || + result_pointee_type.basetype == SPIRType::Struct); if (!defer_access_chain) { @@ -8191,7 +8491,7 @@ bool CompilerMSL::is_out_of_bounds_tessellation_level(uint32_t id_lhs) (builtin == BuiltInTessLevelOuter && c->scalar() == 3); } -void CompilerMSL::prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, +bool CompilerMSL::prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, bool &is_packed) { // If there is any risk of writes happening with the access chain in question, @@ -8205,7 +8505,10 @@ void CompilerMSL::prepare_access_chain_for_scalar_access(std::string &expr, cons // Further indexing should happen with packed rules (array index, not swizzle). is_packed = true; + return true; } + else + return false; } bool CompilerMSL::access_chain_needs_stage_io_builtin_translation(uint32_t base) @@ -8540,7 +8843,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) 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", opcode, mem_sem, mem_sem, false, ptr, val); + emit_atomic_func_op(result_type, id, "atomic_exchange", opcode, mem_sem, mem_sem, false, ptr, val); break; } @@ -8553,7 +8856,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) 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", opcode, + emit_atomic_func_op(result_type, id, "atomic_compare_exchange_weak", opcode, mem_sem_pass, mem_sem_fail, true, ptr, comp, true, false, val); break; @@ -8568,7 +8871,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) 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", opcode, mem_sem, mem_sem, false, ptr, 0); + check_atomic_image(ptr); + emit_atomic_func_op(result_type, id, "atomic_load", opcode, mem_sem, mem_sem, false, ptr, 0); break; } @@ -8579,7 +8883,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) 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", opcode, mem_sem, mem_sem, false, ptr, val); + check_atomic_image(ptr); + emit_atomic_func_op(result_type, id, "atomic_store", opcode, mem_sem, mem_sem, false, ptr, val); break; } @@ -8591,7 +8896,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) 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", opcode, \ + emit_atomic_func_op(result_type, id, "atomic_fetch_" #op, opcode, \ mem_sem, mem_sem, false, ptr, val, \ false, valconst); \ } while (false) @@ -8646,9 +8951,9 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) // Mark that this shader reads from this image uint32_t img_id = ops[2]; auto &type = expression_type(img_id); + auto *p_var = maybe_get_backing_variable(img_id); if (type.image.dim != DimSubpassData) { - auto *p_var = maybe_get_backing_variable(img_id); if (p_var && has_decoration(p_var->self, DecorationNonReadable)) { unset_decoration(p_var->self, DecorationNonReadable); @@ -8656,6 +8961,10 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) } } + // Metal requires explicit fences to break up RAW hazards, even within the same shader invocation + if (msl_options.readwrite_texture_fences && p_var && !has_decoration(p_var->self, DecorationNonWritable)) + statement(to_expression(img_id), ".fence();"); + emit_texture_op(instruction, false); break; } @@ -8665,7 +8974,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) { // When using the pointer, we need to know which variable it is actually loaded from. auto *var = maybe_get_backing_variable(ops[2]); - if (var && atomic_image_vars.count(var->self)) + if (var && atomic_image_vars_emulated.count(var->self)) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; @@ -8685,8 +8994,14 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; + + // Virtual expression. Split this up in the actual image atomic. + // In GLSL and HLSL we are able to resolve the dereference inline, but MSL has + // image.op(coord, ...) syntax. auto &e = - set(id, join(to_expression(ops[2]), ", ", to_expression(ops[3])), result_type, true); + set(id, join(to_expression(ops[2]), "@", + bitcast_expression(SPIRType::UInt, ops[3])), + result_type, true); // When using the pointer, we need to know which variable it is actually loaded from. e.loaded_from = var ? var->self : ID(0); @@ -9137,6 +9452,16 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; } + // Legacy sub-group stuff ... + case OpSubgroupBallotKHR: + case OpSubgroupFirstInvocationKHR: + case OpSubgroupReadInvocationKHR: + case OpSubgroupAllKHR: + case OpSubgroupAnyKHR: + case OpSubgroupAllEqualKHR: + emit_subgroup_op(instruction); + break; + // SPV_INTEL_shader_integer_functions2 case OpUCountLeadingZerosINTEL: MSL_UFOP(clz); @@ -9227,15 +9552,18 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case OpRayQueryInitializeKHR: { flush_variable_declaration(ops[0]); + register_write(ops[0]); + add_spv_func_and_recompile(SPVFuncImplRayQueryIntersectionParams); statement(to_expression(ops[0]), ".reset(", "ray(", to_expression(ops[4]), ", ", to_expression(ops[6]), ", ", - to_expression(ops[5]), ", ", to_expression(ops[7]), "), ", to_expression(ops[1]), - ", intersection_params());"); + to_expression(ops[5]), ", ", to_expression(ops[7]), "), ", to_expression(ops[1]), ", ", to_expression(ops[3]), + ", spvMakeIntersectionParams(", to_expression(ops[2]), "));"); break; } case OpRayQueryProceedKHR: { flush_variable_declaration(ops[0]); + register_write(ops[2]); emit_op(ops[0], ops[1], join(to_expression(ops[2]), ".next()"), false); break; } @@ -9296,14 +9624,17 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) } case OpRayQueryConfirmIntersectionKHR: flush_variable_declaration(ops[0]); + register_write(ops[0]); statement(to_expression(ops[0]), ".commit_triangle_intersection();"); break; case OpRayQueryGenerateIntersectionKHR: flush_variable_declaration(ops[0]); + register_write(ops[0]); statement(to_expression(ops[0]), ".commit_bounding_box_intersection(", to_expression(ops[1]), ");"); break; case OpRayQueryTerminateKHR: flush_variable_declaration(ops[0]); + register_write(ops[0]); statement(to_expression(ops[0]), ".abort();"); break; #undef MSL_RAY_QUERY_GET_OP @@ -9339,6 +9670,132 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; } + case OpSDot: + case OpUDot: + case OpSUDot: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t vec1 = ops[2]; + uint32_t vec2 = ops[3]; + + auto &input_type1 = expression_type(vec1); + auto &input_type2 = expression_type(vec2); + + string vec1input, vec2input; + auto input_size = input_type1.vecsize; + if (instruction.length == 5) + { + if (ops[4] == PackedVectorFormatPackedVectorFormat4x8Bit) + { + string type = opcode == OpSDot || opcode == OpSUDot ? "char4" : "uchar4"; + vec1input = join("as_type<", type, ">(", to_expression(vec1), ")"); + type = opcode == OpSDot ? "char4" : "uchar4"; + vec2input = join("as_type<", type, ">(", to_expression(vec2), ")"); + input_size = 4; + } + else + SPIRV_CROSS_THROW("Packed vector formats other than 4x8Bit for integer dot product is not supported."); + } + else + { + // Inputs are sign or zero-extended to their target width. + SPIRType::BaseType vec1_expected_type = + opcode != OpUDot ? + to_signed_basetype(input_type1.width) : + to_unsigned_basetype(input_type1.width); + + SPIRType::BaseType vec2_expected_type = + opcode != OpSDot ? + to_unsigned_basetype(input_type2.width) : + to_signed_basetype(input_type2.width); + + vec1input = bitcast_expression(vec1_expected_type, vec1); + vec2input = bitcast_expression(vec2_expected_type, vec2); + } + + auto &type = get(result_type); + + // We'll get the appropriate sign-extend or zero-extend, no matter which type we cast to here. + // The addition in reduce_add is sign-invariant. + auto result_type_cast = join(type_to_glsl(type), input_size); + + string exp = join("reduce_add(", + result_type_cast, "(", vec1input, ") * ", + result_type_cast, "(", vec2input, "))"); + + emit_op(result_type, id, exp, should_forward(vec1) && should_forward(vec2)); + inherit_expression_dependencies(id, vec1); + inherit_expression_dependencies(id, vec2); + break; + } + + case OpSDotAccSat: + case OpUDotAccSat: + case OpSUDotAccSat: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t vec1 = ops[2]; + uint32_t vec2 = ops[3]; + uint32_t acc = ops[4]; + + auto input_type1 = expression_type(vec1); + auto input_type2 = expression_type(vec2); + + string vec1input, vec2input; + if (instruction.length == 6) + { + if (ops[5] == PackedVectorFormatPackedVectorFormat4x8Bit) + { + string type = opcode == OpSDotAccSat || opcode == OpSUDotAccSat ? "char4" : "uchar4"; + vec1input = join("as_type<", type, ">(", to_expression(vec1), ")"); + type = opcode == OpSDotAccSat ? "char4" : "uchar4"; + vec2input = join("as_type<", type, ">(", to_expression(vec2), ")"); + input_type1.vecsize = 4; + input_type2.vecsize = 4; + } + else + SPIRV_CROSS_THROW("Packed vector formats other than 4x8Bit for integer dot product is not supported."); + } + else + { + // Inputs are sign or zero-extended to their target width. + SPIRType::BaseType vec1_expected_type = + opcode != OpUDotAccSat ? + to_signed_basetype(input_type1.width) : + to_unsigned_basetype(input_type1.width); + + SPIRType::BaseType vec2_expected_type = + opcode != OpSDotAccSat ? + to_unsigned_basetype(input_type2.width) : + to_signed_basetype(input_type2.width); + + vec1input = bitcast_expression(vec1_expected_type, vec1); + vec2input = bitcast_expression(vec2_expected_type, vec2); + } + + auto &type = get(result_type); + + SPIRType::BaseType pre_saturate_type = + opcode != OpUDotAccSat ? + to_signed_basetype(type.width) : + to_unsigned_basetype(type.width); + + input_type1.basetype = pre_saturate_type; + input_type2.basetype = pre_saturate_type; + + string exp = join(type_to_glsl(type), "(addsat(reduce_add(", + type_to_glsl(input_type1), "(", vec1input, ") * ", + type_to_glsl(input_type2), "(", vec2input, ")), ", + bitcast_expression(pre_saturate_type, acc), "))"); + + emit_op(result_type, id, exp, should_forward(vec1) && should_forward(vec2)); + inherit_expression_dependencies(id, vec1); + inherit_expression_dependencies(id, vec2); + break; + } + default: CompilerGLSL::emit_instruction(instruction); break; @@ -9478,8 +9935,8 @@ bool CompilerMSL::emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rh bool lhs_is_thread_storage = storage_class_array_is_thread(lhs_storage); bool rhs_is_thread_storage = storage_class_array_is_thread(rhs_storage); - bool lhs_is_array_template = lhs_is_thread_storage; - bool rhs_is_array_template = rhs_is_thread_storage; + bool lhs_is_array_template = lhs_is_thread_storage || lhs_storage == StorageClassWorkgroup; + bool rhs_is_array_template = rhs_is_thread_storage || rhs_storage == StorageClassWorkgroup; // Special considerations for stage IO variables. // If the variable is actually backed by non-user visible device storage, we use array templates for those. @@ -9494,15 +9951,13 @@ bool CompilerMSL::emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rh auto *lhs_var = maybe_get_backing_variable(lhs_id); if (lhs_var && lhs_storage == StorageClassStorageBuffer && storage_class_array_is_thread(lhs_var->storage)) lhs_is_array_template = true; - else if (lhs_var && (lhs_storage == StorageClassFunction || lhs_storage == StorageClassPrivate) && - type_is_block_like(get(lhs_var->basetype))) + else if (lhs_var && lhs_storage != StorageClassGeneric && type_is_block_like(get(lhs_var->basetype))) lhs_is_array_template = false; auto *rhs_var = maybe_get_backing_variable(rhs_id); if (rhs_var && rhs_storage == StorageClassStorageBuffer && storage_class_array_is_thread(rhs_var->storage)) rhs_is_array_template = true; - else if (rhs_var && (rhs_storage == StorageClassFunction || rhs_storage == StorageClassPrivate) && - type_is_block_like(get(rhs_var->basetype))) + else if (rhs_var && rhs_storage != StorageClassGeneric && type_is_block_like(get(rhs_var->basetype))) rhs_is_array_template = false; // If threadgroup storage qualifiers are *not* used: @@ -9616,8 +10071,8 @@ uint32_t CompilerMSL::get_physical_tess_level_array_size(spv::BuiltIn builtin) c bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs) { // We only care about assignments of an entire array - auto &type = expression_type(id_rhs); - if (!type_is_top_level_array(get_pointee_type(type))) + auto &type = expression_type(id_lhs); + if (!is_array(get_pointee_type(type))) return false; auto *var = maybe_get(id_lhs); @@ -9679,6 +10134,12 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, else if (opcode == OpAtomicSMax || opcode == OpAtomicSMin) expected_type = to_signed_basetype(type.width); + bool use_native_image_atomic; + if (msl_options.supports_msl_version(3, 1)) + use_native_image_atomic = check_atomic_image(obj); + else + use_native_image_atomic = false; + if (type.width == 64) SPIRV_CROSS_THROW("MSL currently does not support 64-bit atomics."); @@ -9696,12 +10157,31 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, ((res_type.storage == StorageClassUniformConstant && res_type.basetype == SPIRType::Image) || var->storage == StorageClassStorageBuffer || var->storage == StorageClassUniform); + // Even compare exchange atomics are vec4 on metal for ... reasons :v + uint32_t vec4_temporary_id = 0; + if (use_native_image_atomic && is_atomic_compare_exchange_strong) + { + uint32_t &tmp_id = extra_sub_expressions[result_id]; + if (!tmp_id) + { + tmp_id = ir.increase_bound_by(2); + + auto vec4_type = get(result_type); + vec4_type.vecsize = 4; + set(tmp_id + 1, vec4_type); + } + + vec4_temporary_id = tmp_id; + } + if (check_discard) { if (is_atomic_compare_exchange_strong) { // We're already emitting a CAS loop here; a conditional won't hurt. emit_uninitialized_temporary_expression(result_type, result_id); + if (vec4_temporary_id) + emit_uninitialized_temporary_expression(vec4_temporary_id + 1, vec4_temporary_id); statement("if (!", builtin_to_glsl(BuiltInHelperInvocation, StorageClassInput), ")"); begin_scope(); } @@ -9709,131 +10189,135 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, exp = join("(!", builtin_to_glsl(BuiltInHelperInvocation, StorageClassInput), " ? "); } - exp += string(op) + "("; - exp += "("; - // Emulate texture2D atomic operations - if (res_type.storage == StorageClassUniformConstant && res_type.basetype == SPIRType::Image) + if (use_native_image_atomic) { - exp += "device"; + auto obj_expression = to_expression(obj); + auto split_index = obj_expression.find_first_of('@'); + + // Will only be false if we're in "force recompile later" mode. + if (split_index != string::npos) + exp += join(obj_expression.substr(0, split_index), ".", op, "(", obj_expression.substr(split_index + 1)); + else + exp += obj_expression; } else { - exp += get_argument_address_space(*var); + exp += string(op) + "_explicit("; + exp += "("; + // Emulate texture2D atomic operations + if (res_type.storage == StorageClassUniformConstant && res_type.basetype == SPIRType::Image) + { + auto &flags = ir.get_decoration_bitset(var->self); + if (decoration_flags_signal_volatile(flags)) + exp += "volatile "; + exp += "device"; + } + else + { + exp += get_argument_address_space(*var); + } + + exp += " atomic_"; + // For signed and unsigned min/max, we can signal this through the pointer type. + // There is no other way, since C++ does not have explicit signage for atomics. + exp += type_to_glsl(remapped_type); + exp += "*)"; + + exp += "&"; + exp += to_enclosed_expression(obj); } - exp += " atomic_"; - // For signed and unsigned min/max, we can signal this through the pointer type. - // There is no other way, since C++ does not have explicit signage for atomics. - exp += type_to_glsl(remapped_type); - exp += "*)"; - - exp += "&"; - exp += to_enclosed_expression(obj); - if (is_atomic_compare_exchange_strong) { - assert(strcmp(op, "atomic_compare_exchange_weak_explicit") == 0); + assert(strcmp(op, "atomic_compare_exchange_weak") == 0); assert(op2); assert(has_mem_order_2); exp += ", &"; - exp += to_name(result_id); + exp += to_name(vec4_temporary_id ? vec4_temporary_id : result_id); exp += ", "; exp += to_expression(op2); - exp += ", "; - exp += get_memory_order(mem_order_1); - exp += ", "; - exp += get_memory_order(mem_order_2); + + if (!use_native_image_atomic) + { + exp += ", "; + exp += get_memory_order(mem_order_1); + exp += ", "; + exp += get_memory_order(mem_order_2); + } exp += ")"; // MSL only supports the weak atomic compare exchange, so emit a CAS loop here. // The MSL function returns false if the atomic write fails OR the comparison test fails, // so we must validate that it wasn't the comparison test that failed before continuing // the CAS loop, otherwise it will loop infinitely, with the comparison test always failing. - // The function updates the comparitor value from the memory value, so the additional + // The function updates the comparator value from the memory value, so the additional // comparison test evaluates the memory value against the expected value. if (!check_discard) + { emit_uninitialized_temporary_expression(result_type, result_id); + if (vec4_temporary_id) + emit_uninitialized_temporary_expression(vec4_temporary_id + 1, vec4_temporary_id); + } + statement("do"); begin_scope(); - statement(to_name(result_id), " = ", to_expression(op1), ";"); - end_scope_decl(join("while (!", exp, " && ", to_name(result_id), " == ", to_enclosed_expression(op1), ")")); + + string scalar_expression; + if (vec4_temporary_id) + scalar_expression = join(to_expression(vec4_temporary_id), ".x"); + else + scalar_expression = to_expression(result_id); + + statement(scalar_expression, " = ", to_expression(op1), ";"); + end_scope_decl(join("while (!", exp, " && ", scalar_expression, " == ", to_enclosed_expression(op1), ")")); + if (vec4_temporary_id) + statement(to_expression(result_id), " = ", scalar_expression, ";"); + + // Vulkan: (section 9.29: ... and values returned by atomic instructions in helper invocations are undefined) if (check_discard) { end_scope(); statement("else"); begin_scope(); - exp = "atomic_load_explicit("; - exp += "("; - // Emulate texture2D atomic operations - if (res_type.storage == StorageClassUniformConstant && res_type.basetype == SPIRType::Image) - exp += "device"; - else - exp += get_argument_address_space(*var); - - exp += " atomic_"; - exp += type_to_glsl(remapped_type); - exp += "*)"; - - exp += "&"; - exp += to_enclosed_expression(obj); - - if (has_mem_order_2) - exp += string(", ") + get_memory_order(mem_order_2); - else - exp += string(", ") + get_memory_order(mem_order_1); - - exp += ")"; - - statement(to_name(result_id), " = ", exp, ";"); + statement(to_expression(result_id), " = {};"); end_scope(); } } else { - assert(strcmp(op, "atomic_compare_exchange_weak_explicit") != 0); + assert(strcmp(op, "atomic_compare_exchange_weak") != 0); + if (op1) { + exp += ", "; if (op1_is_literal) - exp += join(", ", op1); + exp += to_string(op1); else - exp += ", " + bitcast_expression(expected_type, op1); + exp += bitcast_expression(expected_type, 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); + if (!use_native_image_atomic) + { + exp += string(", ") + get_memory_order(mem_order_1); + if (has_mem_order_2) + exp += string(", ") + get_memory_order(mem_order_2); + } exp += ")"; + // For some particular reason, atomics return vec4 in Metal ... + if (use_native_image_atomic) + exp += ".x"; + + // Vulkan: (section 9.29: ... and values returned by atomic instructions in helper invocations are undefined) if (check_discard) { exp += " : "; - if (strcmp(op, "atomic_store_explicit") != 0) - { - exp += "atomic_load_explicit("; - exp += "("; - // Emulate texture2D atomic operations - if (res_type.storage == StorageClassUniformConstant && res_type.basetype == SPIRType::Image) - exp += "device"; - else - exp += get_argument_address_space(*var); - - exp += " atomic_"; - exp += type_to_glsl(remapped_type); - exp += "*)"; - - exp += "&"; - exp += to_enclosed_expression(obj); - - if (has_mem_order_2) - exp += string(", ") + get_memory_order(mem_order_2); - else - exp += string(", ") + get_memory_order(mem_order_1); - - exp += ")"; - } + if (strcmp(op, "atomic_store") != 0) + exp += join(type_to_glsl(get(result_type)), "{}"); else exp += "((void)0)"; exp += ")"; @@ -9842,7 +10326,7 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, if (expected_type != type.basetype) exp = bitcast_expression(type, expected_type, exp); - if (strcmp(op, "atomic_store_explicit") != 0) + if (strcmp(op, "atomic_store") != 0) emit_op(result_type, result_id, exp, false); else statement(exp, ";"); @@ -10182,6 +10666,11 @@ void CompilerMSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, break; } + case GLSLstd450Pow: + // powr makes x < 0.0 undefined, just like SPIR-V. + emit_binary_func_op(result_type, id, args[0], args[1], "powr"); + break; + default: CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); break; @@ -10340,9 +10829,9 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, const Bitset &) // Manufacture automatic sampler arg for SampledImage texture if (arg_type.image.dim != DimBuffer) { - if (arg_type.array.empty()) + if (arg_type.array.empty() || (var ? is_var_runtime_size_array(*var) : is_runtime_size_array(arg_type))) { - decl += join(", ", sampler_type(arg_type, arg.id), " ", to_sampler_expression(name_id)); + decl += join(", ", sampler_type(arg_type, arg.id, false), " ", to_sampler_expression(name_id)); } else { @@ -10350,7 +10839,7 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, const Bitset &) descriptor_address_space(name_id, StorageClassUniformConstant, "thread const"); - decl += join(", ", sampler_address_space, " ", sampler_type(arg_type, name_id), "& ", + decl += join(", ", sampler_address_space, " ", sampler_type(arg_type, name_id, false), "& ", to_sampler_expression(name_id)); } } @@ -10536,7 +11025,7 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args) string CompilerMSL::convert_to_f32(const string &expr, uint32_t components) { - SPIRType t; + SPIRType t { components > 1 ? OpTypeVector : OpTypeFloat }; t.basetype = SPIRType::Float; t.vecsize = components; t.columns = 1; @@ -10912,29 +11401,38 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool // rhoX = dP/dx * extent; rhoY = dP/dy * extent // Therefore, dP/dx = dP/dy = exp2(lod)/extent. // (Subtracting 0.5 before exponentiation gives better results.) - string grad_opt, extent; + string grad_opt, extent, grad_coord; VariableID base_img = img; if (auto *combined = maybe_get(img)) base_img = combined->image; switch (imgtype.image.dim) { case Dim1D: - grad_opt = "2d"; + grad_opt = "gradient2d"; extent = join("float2(", to_expression(base_img), ".get_width(), 1.0)"); break; case Dim2D: - grad_opt = "2d"; + grad_opt = "gradient2d"; extent = join("float2(", to_expression(base_img), ".get_width(), ", to_expression(base_img), ".get_height())"); break; case DimCube: if (imgtype.image.arrayed && msl_options.emulate_cube_array) { - grad_opt = "2d"; + grad_opt = "gradient2d"; extent = join("float2(", to_expression(base_img), ".get_width())"); } else { - grad_opt = "cube"; + if (msl_options.agx_manual_cube_grad_fixup) + { + add_spv_func_and_recompile(SPVFuncImplGradientCube); + grad_opt = "spvGradientCube"; + grad_coord = tex_coords + ", "; + } + else + { + grad_opt = "gradientcube"; + } extent = join("float3(", to_expression(base_img), ".get_width())"); } break; @@ -10943,8 +11441,8 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool extent = "float3(1.0)"; break; } - farg_str += join(", gradient", grad_opt, "(exp2(", to_expression(lod), " - 0.5) / ", extent, ", exp2(", - to_expression(lod), " - 0.5) / ", extent, ")"); + farg_str += join(", ", grad_opt, "(", grad_coord, "exp2(", to_expression(lod), " - 0.5) / ", extent, + ", exp2(", to_expression(lod), " - 0.5) / ", extent, ")"); } else { @@ -10964,27 +11462,37 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool { forward = forward && should_forward(grad_x); forward = forward && should_forward(grad_y); - string grad_opt; + string grad_opt, grad_coord; switch (imgtype.image.dim) { case Dim1D: case Dim2D: - grad_opt = "2d"; + grad_opt = "gradient2d"; break; case Dim3D: - grad_opt = "3d"; + grad_opt = "gradient3d"; break; case DimCube: if (imgtype.image.arrayed && msl_options.emulate_cube_array) - grad_opt = "2d"; + { + grad_opt = "gradient2d"; + } + else if (msl_options.agx_manual_cube_grad_fixup) + { + add_spv_func_and_recompile(SPVFuncImplGradientCube); + grad_opt = "spvGradientCube"; + grad_coord = tex_coords + ", "; + } else - grad_opt = "cube"; + { + grad_opt = "gradientcube"; + } break; default: grad_opt = "unsupported_gradient_dimension"; break; } - farg_str += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; + farg_str += join(", ", grad_opt, "(", grad_coord, to_expression(grad_x), ", ", to_expression(grad_y), ")"); } if (args.min_lod) @@ -11453,7 +11961,7 @@ string CompilerMSL::to_func_call_arg(const SPIRFunction::Parameter &arg, uint32_ // Emulate texture2D atomic operations auto *backing_var = maybe_get_backing_variable(var_id); - if (backing_var && atomic_image_vars.count(backing_var->self)) + if (backing_var && atomic_image_vars_emulated.count(backing_var->self)) { arg_str += ", " + to_expression(var_id) + "_atomic"; } @@ -11528,6 +12036,18 @@ string CompilerMSL::to_buffer_size_expression(uint32_t id) { auto buffer_expr = expr.substr(0, index); auto array_expr = expr.substr(index); + if (auto var = maybe_get_backing_variable(id)) + { + if (is_var_runtime_size_array(*var)) + { + if (!msl_options.runtime_array_rich_descriptor) + SPIRV_CROSS_THROW("OpArrayLength requires rich descriptor format"); + + auto last_pos = array_expr.find_last_of(']'); + if (last_pos != std::string::npos) + return buffer_expr + ".length(" + array_expr.substr(1, last_pos - 1) + ")"; + } + } return buffer_expr + buffer_size_name_suffix + array_expr; } } @@ -11597,6 +12117,7 @@ void CompilerMSL::emit_fixup() string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const string &qualifier) { + uint32_t orig_member_type_id = member_type_id; if (member_is_remapped_physical_type(type, index)) member_type_id = get_extended_member_decoration(type.self, index, SPIRVCrossDecorationPhysicalTypeID); auto &physical_type = get(member_type_id); @@ -11613,7 +12134,7 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ if (is_matrix(physical_type)) row_major = has_member_decoration(type.self, index, DecorationRowMajor); - SPIRType row_major_physical_type; + SPIRType row_major_physical_type { OpTypeMatrix }; const SPIRType *declared_type = &physical_type; // If a struct is being declared with physical layout, @@ -11708,7 +12229,38 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ array_type = type_to_array_glsl(physical_type); } - auto result = join(pack_pfx, type_to_glsl(*declared_type, orig_id, true), " ", qualifier, + if (orig_id) + { + auto *data_type = declared_type; + if (is_pointer(*data_type)) + data_type = &get_pointee_type(*data_type); + + if (is_array(*data_type) && get_resource_array_size(*data_type, orig_id) == 0) + { + // Hack for declaring unsized array of resources. Need to declare dummy sized array by value inline. + // This can then be wrapped in spvDescriptorArray as usual. + array_type = "[1] /* unsized array hack */"; + } + } + + string decl_type; + if (declared_type->vecsize > 4) + { + auto orig_type = get(orig_member_type_id); + if (is_matrix(orig_type) && row_major) + swap(orig_type.vecsize, orig_type.columns); + orig_type.columns = 1; + decl_type = type_to_glsl(orig_type, orig_id, true); + + if (declared_type->columns > 1) + decl_type = join("spvPaddedStd140Matrix<", decl_type, ", ", declared_type->columns, ">"); + else + decl_type = join("spvPaddedStd140<", decl_type, ">"); + } + else + decl_type = type_to_glsl(*declared_type, orig_id, true); + + auto result = join(pack_pfx, decl_type, " ", qualifier, to_member_name(type, index), member_attribute_qualifier(type, index), array_type, ";"); is_using_builtin_array = false; @@ -12314,6 +12866,11 @@ string CompilerMSL::get_argument_address_space(const SPIRVariable &argument) return get_type_address_space(type, argument.self, true); } +bool CompilerMSL::decoration_flags_signal_volatile(const Bitset &flags) +{ + return flags.get(DecorationVolatile) || flags.get(DecorationCoherent); +} + string CompilerMSL::get_type_address_space(const SPIRType &type, uint32_t id, bool argument) { // This can be called for variable pointer contexts as well, so be very careful about which method we choose. @@ -12423,7 +12980,7 @@ string CompilerMSL::get_type_address_space(const SPIRType &type, uint32_t id, bo addr_space = type.pointer || (argument && type.basetype == SPIRType::ControlPointArray) ? "thread" : ""; } - return join(flags.get(DecorationVolatile) || flags.get(DecorationCoherent) ? "volatile " : "", addr_space); + return join(decoration_flags_signal_volatile(flags) ? "volatile " : "", addr_space); } const char *CompilerMSL::to_restrict(uint32_t id, bool space) @@ -12588,7 +13145,7 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) else ep_args += builtin_type_decl(bi_type, var_id) + " " + to_expression(var_id); - ep_args += " [[" + builtin_qualifier(bi_type); + ep_args += string(" [[") + builtin_qualifier(bi_type); if (bi_type == BuiltInSampleMask && get_entry_point().flags.get(ExecutionModePostDepthCoverage)) { if (!msl_options.supports_msl_version(2)) @@ -12904,18 +13461,29 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) SmallVector resources; + entry_point_bindings.clear(); ir.for_each_typed_id([&](uint32_t var_id, SPIRVariable &var) { if ((var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant || var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer) && !is_hidden_variable(var)) { auto &type = get_variable_data_type(var); + uint32_t desc_set = get_decoration(var_id, DecorationDescriptorSet); if (is_supported_argument_buffer_type(type) && var.storage != StorageClassPushConstant) { - uint32_t desc_set = get_decoration(var_id, DecorationDescriptorSet); if (descriptor_set_is_argument_buffer(desc_set)) + { + if (is_var_runtime_size_array(var)) + { + // Runtime arrays need to be wrapped in spvDescriptorArray from argument buffer payload. + entry_point_bindings.push_back(&var); + // We'll wrap this, so to_name() will always use non-qualified name. + // We'll need the qualified name to create temporary variable instead. + ir.meta[var_id].decoration.qualified_alias_explicit_override = true; + } return; + } } // Handle descriptor aliasing. We can handle aliasing of buffers by casting pointers, @@ -12933,10 +13501,6 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) (resource.var->storage == StorageClassUniform || resource.var->storage == StorageClassStorageBuffer)) { - // Possible, but horrible to implement, ignore for now. - if (!type.array.empty()) - SPIRV_CROSS_THROW("Aliasing arrayed discrete descriptors is currently not supported."); - descriptor_alias = resource.var; // Self-reference marks that we should declare the resource, // and it's being used as an alias (so we can emit void* instead). @@ -12962,7 +13526,7 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) // Emulate texture2D atomic operations uint32_t secondary_index = 0; - if (atomic_image_vars.count(var.self)) + if (atomic_image_vars_emulated.count(var.self)) { secondary_index = get_metal_resource_index(var, SPIRType::AtomicCounter, 0); } @@ -12975,6 +13539,7 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) if (constexpr_sampler && constexpr_sampler->ycbcr_conversion_enable) plane_count = constexpr_sampler->planes; + entry_point_bindings.push_back(&var); for (uint32_t i = 0; i < plane_count; i++) resources.push_back({ &var, descriptor_alias, to_name(var_id), SPIRType::Image, get_metal_resource_index(var, SPIRType::Image, i), i, secondary_index }); @@ -12995,15 +13560,16 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) if (!descriptor_alias) resource_index = get_metal_resource_index(var, type.basetype); + entry_point_bindings.push_back(&var); resources.push_back({ &var, descriptor_alias, to_name(var_id), type.basetype, resource_index, 0, secondary_index }); } } }); - stable_sort(resources.begin(), resources.end(), [](const Resource &lhs, const Resource &rhs) { - return tie(lhs.basetype, lhs.index) < tie(rhs.basetype, rhs.index); - }); + stable_sort(resources.begin(), resources.end(), + [](const Resource &lhs, const Resource &rhs) + { return tie(lhs.basetype, lhs.index) < tie(rhs.basetype, rhs.index); }); for (auto &r : resources) { @@ -13046,36 +13612,59 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) if (type.array.size() > 1) SPIRV_CROSS_THROW("Arrays of arrays of buffers are not supported."); - // Metal doesn't directly support this, so we must expand the - // array. We'll declare a local array to hold these elements - // later. - uint32_t array_size = to_array_size_literal(type); - - if (array_size == 0) - SPIRV_CROSS_THROW("Unsized arrays of buffers are not supported in MSL."); - - // Allow Metal to use the array template to make arrays a value type is_using_builtin_array = true; - buffer_arrays_discrete.push_back(var_id); - for (uint32_t i = 0; i < array_size; ++i) + if (is_var_runtime_size_array(var)) { + add_spv_func_and_recompile(SPVFuncImplVariableDescriptorArray); if (!ep_args.empty()) ep_args += ", "; - ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "* " + to_restrict(var_id, true) + - r.name + "_" + convert_to_string(i); - ep_args += " [[buffer(" + convert_to_string(r.index + i) + ")"; + const bool ssbo = has_decoration(type.self, DecorationBufferBlock); + if ((var.storage == spv::StorageClassStorageBuffer || ssbo) && + msl_options.runtime_array_rich_descriptor) + { + add_spv_func_and_recompile(SPVFuncImplVariableSizedDescriptor); + ep_args += "const device spvBufferDescriptor<" + get_argument_address_space(var) + " " + + type_to_glsl(type) + "*>* "; + } + else + { + ep_args += "const device spvDescriptor<" + get_argument_address_space(var) + " " + + type_to_glsl(type) + "*>* "; + } + ep_args += to_restrict(var_id, true) + r.name + "_"; + ep_args += " [[buffer(" + convert_to_string(r.index) + ")"; if (interlocked_resources.count(var_id)) ep_args += ", raster_order_group(0)"; ep_args += "]]"; } + else + { + uint32_t array_size = get_resource_array_size(type, var_id); + for (uint32_t i = 0; i < array_size; ++i) + { + if (!ep_args.empty()) + ep_args += ", "; + ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "* " + + to_restrict(var_id, true) + r.name + "_" + convert_to_string(i); + ep_args += " [[buffer(" + convert_to_string(r.index + i) + ")"; + if (interlocked_resources.count(var_id)) + ep_args += ", raster_order_group(0)"; + ep_args += "]]"; + } + } is_using_builtin_array = false; } else { if (!ep_args.empty()) ep_args += ", "; - ep_args += - get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + to_restrict(var_id, true) + r.name; + ep_args += get_argument_address_space(var) + " "; + + if (recursive_inputs.count(type.self)) + ep_args += string("void* ") + to_restrict(var_id, true) + r.name + "_vp"; + else + ep_args += type_to_glsl(type) + "& " + to_restrict(var_id, true) + r.name; + ep_args += " [[buffer(" + convert_to_string(r.index) + ")"; if (interlocked_resources.count(var_id)) ep_args += ", raster_order_group(0)"; @@ -13086,8 +13675,11 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) case SPIRType::Sampler: if (!ep_args.empty()) ep_args += ", "; - ep_args += sampler_type(type, var_id) + " " + r.name; - ep_args += " [[sampler(" + convert_to_string(r.index) + ")]]"; + ep_args += sampler_type(type, var_id, false) + " " + r.name; + if (is_var_runtime_size_array(var)) + ep_args += "_ [[buffer(" + convert_to_string(r.index) + ")]]"; + else + ep_args += " [[sampler(" + convert_to_string(r.index) + ")]]"; break; case SPIRType::Image: { @@ -13098,10 +13690,15 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) const auto &basetype = get(var.basetype); if (!type_is_msl_framebuffer_fetch(basetype)) { - ep_args += image_type_glsl(type, var_id) + " " + r.name; + ep_args += image_type_glsl(type, var_id, false) + " " + r.name; if (r.plane > 0) ep_args += join(plane_name_suffix, r.plane); - ep_args += " [[texture(" + convert_to_string(r.index) + ")"; + + if (is_var_runtime_size_array(var)) + ep_args += "_ [[buffer(" + convert_to_string(r.index) + ")"; + else + ep_args += " [[texture(" + convert_to_string(r.index) + ")"; + if (interlocked_resources.count(var_id)) ep_args += ", raster_order_group(0)"; ep_args += "]]"; @@ -13110,14 +13707,16 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) { if (msl_options.is_macos() && !msl_options.supports_msl_version(2, 3)) SPIRV_CROSS_THROW("Framebuffer fetch on Mac is not supported before MSL 2.3."); - ep_args += image_type_glsl(type, var_id) + " " + r.name; + ep_args += image_type_glsl(type, var_id, false) + " " + r.name; ep_args += " [[color(" + convert_to_string(r.index) + ")]]"; } // Emulate texture2D atomic operations - if (atomic_image_vars.count(var.self)) + if (atomic_image_vars_emulated.count(var.self)) { - ep_args += ", device atomic_" + type_to_glsl(get(basetype.image.type), 0); + auto &flags = ir.get_decoration_bitset(var.self); + const char *cv_flags = decoration_flags_signal_volatile(flags) ? "volatile " : ""; + ep_args += join(", ", cv_flags, "device atomic_", type_to_glsl(get(basetype.image.type), 0)); ep_args += "* " + r.name + "_atomic"; ep_args += " [[buffer(" + convert_to_string(r.secondary_index) + ")"; if (interlocked_resources.count(var_id)) @@ -13127,9 +13726,26 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) break; } case SPIRType::AccelerationStructure: - ep_args += ", " + type_to_glsl(type, var_id) + " " + r.name; - ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]"; + { + if (is_var_runtime_size_array(var)) + { + add_spv_func_and_recompile(SPVFuncImplVariableDescriptor); + const auto &parent_type = get(type.parent_type); + if (!ep_args.empty()) + ep_args += ", "; + ep_args += "const device spvDescriptor<" + type_to_glsl(parent_type) + ">* " + + to_restrict(var_id, true) + r.name + "_"; + ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]"; + } + else + { + if (!ep_args.empty()) + ep_args += ", "; + ep_args += type_to_glsl(type, var_id) + " " + r.name; + ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]"; + } break; + } default: if (!ep_args.empty()) ep_args += ", "; @@ -13214,27 +13830,42 @@ void CompilerMSL::fix_up_shader_inputs_outputs() { if (buffer_requires_array_length(var.self)) { - entry_func.fixup_hooks_in.push_back([this, &type, &var, var_id]() { - bool is_array_type = !type.array.empty(); + entry_func.fixup_hooks_in.push_back( + [this, &type, &var, var_id]() + { + bool is_array_type = !type.array.empty() && !is_var_runtime_size_array(var); - uint32_t desc_set = get_decoration(var_id, DecorationDescriptorSet); - if (descriptor_set_is_argument_buffer(desc_set)) - { - statement("constant uint", is_array_type ? "* " : "& ", to_buffer_size_expression(var_id), - is_array_type ? " = &" : " = ", to_name(argument_buffer_ids[desc_set]), - ".spvBufferSizeConstants", "[", - convert_to_string(get_metal_resource_index(var, SPIRType::Image)), "];"); - } - else - { - // If we have an array of images, we need to be able to index into it, so take a pointer instead. - statement("constant uint", is_array_type ? "* " : "& ", to_buffer_size_expression(var_id), - is_array_type ? " = &" : " = ", to_name(buffer_size_buffer_id), "[", - convert_to_string(get_metal_resource_index(var, type.basetype)), "];"); - } - }); + uint32_t desc_set = get_decoration(var_id, DecorationDescriptorSet); + if (descriptor_set_is_argument_buffer(desc_set)) + { + statement("constant uint", is_array_type ? "* " : "& ", to_buffer_size_expression(var_id), + is_array_type ? " = &" : " = ", to_name(argument_buffer_ids[desc_set]), + ".spvBufferSizeConstants", "[", + convert_to_string(get_metal_resource_index(var, SPIRType::Image)), "];"); + } + else + { + // If we have an array of images, we need to be able to index into it, so take a pointer instead. + statement("constant uint", is_array_type ? "* " : "& ", to_buffer_size_expression(var_id), + is_array_type ? " = &" : " = ", to_name(buffer_size_buffer_id), "[", + convert_to_string(get_metal_resource_index(var, type.basetype)), "];"); + } + }); } } + + if (msl_options.replace_recursive_inputs && type_contains_recursion(type) && + (var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant || + var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer)) + { + recursive_inputs.insert(type.self); + entry_func.fixup_hooks_in.push_back([this, &type, &var, var_id]() { + auto addr_space = get_argument_address_space(var); + auto var_name = to_name(var_id); + statement(addr_space, " auto& ", to_restrict(var_id, true), var_name, + " = *(", addr_space, " ", type_to_glsl(type), "*)", var_name, "_vp;"); + }); + } }); // Builtin variables @@ -13291,14 +13922,31 @@ void CompilerMSL::fix_up_shader_inputs_outputs() break; case BuiltInPatchVertices: if (is_tese_shader()) - entry_func.fixup_hooks_in.push_back([=]() { - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", - to_expression(patch_stage_in_var_id), ".gl_in.size();"); - }); + { + if (msl_options.raw_buffer_tese_input) + { + entry_func.fixup_hooks_in.push_back( + [=]() { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", + get_entry_point().output_vertices, ";"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back( + [=]() + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", + to_expression(patch_stage_in_var_id), ".gl_in.size();"); + }); + } + } else + { entry_func.fixup_hooks_in.push_back([=]() { statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = spvIndirectParams[0];"); }); + } break; case BuiltInTessCoord: if (get_entry_point().flags.get(ExecutionModeQuads)) @@ -13807,8 +14455,6 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) binding_stride *= to_array_size_literal(type, i); - assert(binding_stride != 0); - // If a binding has not been specified, revert to incrementing resource indices. uint32_t resource_index; @@ -13820,6 +14466,11 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base } else { + if (is_var_runtime_size_array(var)) + { + basetype = SPIRType::Struct; + binding_stride = 1; + } // Allocate from plain bindings which are allocated per resource type. switch (basetype) { @@ -13905,7 +14556,6 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) auto &type = get_variable_data_type(var); auto &var_type = get(arg.type); StorageClass type_storage = var_type.storage; - bool is_pointer = var_type.pointer; // If we need to modify the name of the variable, make sure we use the original variable. // Our alias is just a shadow variable. @@ -13913,7 +14563,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (arg.alias_global_variable && var.basevariable) name_id = var.basevariable; - bool constref = !arg.alias_global_variable && is_pointer && arg.write_count == 0; + bool constref = !arg.alias_global_variable && is_pointer(var_type) && arg.write_count == 0; // Framebuffer fetch is plain value, const looks out of place, but it is not wrong. if (type_is_msl_framebuffer_fetch(type)) constref = false; @@ -13922,6 +14572,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) bool type_is_image = type.basetype == SPIRType::Image || type.basetype == SPIRType::SampledImage || type.basetype == SPIRType::Sampler; + bool type_is_tlas = type.basetype == SPIRType::AccelerationStructure; // For opaque types we handle const later due to descriptor address spaces. const char *cv_qualifier = (constref && !type_is_image) ? "const " : ""; @@ -13941,9 +14592,6 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) bool builtin = has_decoration(var.self, DecorationBuiltIn); auto builtin_type = BuiltIn(get_decoration(arg.id, DecorationBuiltIn)); - if (address_space == "threadgroup") - is_using_builtin_array = true; - if (var.basevariable && (var.basevariable == stage_in_ptr_var_id || var.basevariable == stage_out_ptr_var_id)) decl = join(cv_qualifier, type_to_glsl(type, arg.id)); else if (builtin) @@ -13972,6 +14620,18 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) else decl = join(cv_qualifier, type_to_glsl(type, arg.id)); } + else if (is_var_runtime_size_array(var)) + { + const auto *parent_type = &get(type.parent_type); + auto type_name = type_to_glsl(*parent_type, arg.id); + if (type.basetype == SPIRType::AccelerationStructure) + decl = join("spvDescriptorArray<", type_name, ">"); + else if (type_is_image) + decl = join("spvDescriptorArray<", cv_qualifier, type_name, ">"); + else + decl = join("spvDescriptorArray<", address_space, " ", type_name, "*>"); + address_space = "const"; + } else if ((type_storage == StorageClassUniform || type_storage == StorageClassStorageBuffer) && is_array(type)) { is_using_builtin_array = true; @@ -13993,10 +14653,12 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) decl += join(" ", cv_qualifier); } else + { decl = join(cv_qualifier, type_to_glsl(type, arg.id)); + } } - if (!builtin && !is_pointer && + if (!builtin && !is_pointer(var_type) && (type_storage == StorageClassFunction || type_storage == StorageClassGeneric)) { // If the argument is a pure value and not an opaque type, we will pass by value. @@ -14035,11 +14697,15 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (!address_space.empty()) decl = join(address_space, " ", decl); - const char *argument_buffer_space = descriptor_address_space(name_id, type_storage, nullptr); - if (argument_buffer_space) + // spvDescriptorArray absorbs the address space inside the template. + if (!is_var_runtime_size_array(var)) { - decl += " "; - decl += argument_buffer_space; + const char *argument_buffer_space = descriptor_address_space(name_id, type_storage, nullptr); + if (argument_buffer_space) + { + decl += " "; + decl += argument_buffer_space; + } } // Special case, need to override the array size here if we're using tess level as an argument. @@ -14060,6 +14726,10 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) decl += join("[", array_size, "]"); } } + else if (is_var_runtime_size_array(var)) + { + decl += " " + to_expression(name_id); + } else { auto array_size_decl = type_to_array_glsl(type); @@ -14083,7 +14753,8 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) } } } - else if (!type_is_image && (!pull_model_inputs.count(var.basevariable) || type.basetype == SPIRType::Struct)) + else if (!type_is_image && !type_is_tlas && + (!pull_model_inputs.count(var.basevariable) || type.basetype == SPIRType::Struct)) { // If this is going to be a reference to a variable pointer, the address space // for the reference has to go before the '&', but after the '*'. @@ -14103,9 +14774,13 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) decl += to_restrict(name_id, true); decl += to_expression(name_id); } - else if (type_is_image) + else if (type_is_image || type_is_tlas) { - if (type.array.empty()) + if (is_var_runtime_size_array(var)) + { + decl = address_space + " " + decl + " " + to_expression(name_id); + } + else if (type.array.empty()) { // For non-arrayed types we can just pass opaque descriptors by value. // This fixes problems if descriptors are passed by value from argument buffers and plain descriptors @@ -14134,9 +14809,11 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) // Emulate texture2D atomic operations auto *backing_var = maybe_get_backing_variable(name_id); - if (backing_var && atomic_image_vars.count(backing_var->self)) + if (backing_var && atomic_image_vars_emulated.count(backing_var->self)) { - decl += ", device atomic_" + type_to_glsl(get(var_type.image.type), 0); + auto &flags = ir.get_decoration_bitset(backing_var->self); + const char *cv_flags = decoration_flags_signal_volatile(flags) ? "volatile " : ""; + decl += join(", ", cv_flags, "device atomic_", type_to_glsl(get(var_type.image.type), 0)); decl += "* " + to_expression(name_id) + "_atomic"; } @@ -14152,7 +14829,7 @@ string CompilerMSL::to_name(uint32_t id, bool allow_alias) const if (current_function && (current_function->self == ir.default_entry_point)) { auto *m = ir.find_meta(id); - if (m && !m->decoration.qualified_alias.empty()) + if (m && !m->decoration.qualified_alias_explicit_override && !m->decoration.qualified_alias.empty()) return m->decoration.qualified_alias; } return Compiler::to_name(id, allow_alias); @@ -14330,6 +15007,7 @@ const std::unordered_set &CompilerMSL::get_illegal_func_names() "assert", "fmin3", "fmax3", + "divide", "VARIABLE_TRACEPOINT", "STATIC_DATA_TRACEPOINT", "STATIC_DATA_TRACEPOINT_V", @@ -14530,11 +15208,12 @@ string CompilerMSL::to_member_reference(uint32_t base, const SPIRType &type, uin { // Only allow -> dereference for block types. This is so we get expressions like // buffer[i]->first_member.second_member, rather than buffer[i]->first->second. - bool is_block = has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); + const bool is_block = + has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); bool is_buffer_variable = is_block && (var->storage == StorageClassUniform || var->storage == StorageClassStorageBuffer); - declared_as_pointer = is_buffer_variable && is_array(get(var->basetype)); + declared_as_pointer = is_buffer_variable && is_array(get_pointee_type(var->basetype)); } if (declared_as_pointer || (!ptr_chain_is_resolved && should_dereference(base))) @@ -14564,7 +15243,7 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) string type_name; // Pointer? - if (type_is_top_level_pointer(type) || type_is_array_of_pointers(type)) + if (is_pointer(type) || type_is_array_of_pointers(type)) { assert(type.pointer_depth > 0); @@ -14573,6 +15252,26 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) auto type_address_space = get_type_address_space(type, id); const auto *p_parent_type = &get(type.parent_type); + // If we're wrapping buffer descriptors in a spvDescriptorArray, we'll have to handle it as a special case. + if (member && id) + { + auto &var = get(id); + if (is_var_runtime_size_array(var) && is_runtime_size_array(*p_parent_type)) + { + const bool ssbo = has_decoration(p_parent_type->self, DecorationBufferBlock); + bool buffer_desc = + (var.storage == StorageClassStorageBuffer || ssbo) && + msl_options.runtime_array_rich_descriptor; + + const char *wrapper_type = buffer_desc ? "spvBufferDescriptor" : "spvDescriptor"; + add_spv_func_and_recompile(SPVFuncImplVariableDescriptorArray); + add_spv_func_and_recompile(buffer_desc ? SPVFuncImplVariableSizedDescriptor : SPVFuncImplVariableDescriptor); + + type_name = join(wrapper_type, "<", type_address_space, " ", type_to_glsl(*p_parent_type, id), " *>"); + return type_name; + } + } + // Work around C pointer qualifier rules. If glsl_type is a pointer type as well // we'll need to emit the address space to the right. // We could always go this route, but it makes the code unnatural. @@ -14592,7 +15291,7 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) // the C-style nesting works right. // FIXME: This is somewhat of a hack. bool old_is_using_builtin_array = is_using_builtin_array; - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) is_using_builtin_array = false; type_name = join(type_address_space, " ", type_to_glsl(*p_parent_type, id)); @@ -14631,10 +15330,10 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) case SPIRType::Image: case SPIRType::SampledImage: - return image_type_glsl(type, id); + return image_type_glsl(type, id, member); case SPIRType::Sampler: - return sampler_type(type, id); + return sampler_type(type, id, member); case SPIRType::Void: return "void"; @@ -14844,26 +15543,13 @@ bool CompilerMSL::variable_decl_is_remapped_storage(const SPIRVariable &variable } } -std::string CompilerMSL::variable_decl(const SPIRVariable &variable) -{ - bool old_is_using_builtin_array = is_using_builtin_array; - - // Threadgroup arrays can't have a wrapper type. - if (variable_decl_is_remapped_storage(variable, StorageClassWorkgroup)) - is_using_builtin_array = true; - - auto expr = CompilerGLSL::variable_decl(variable); - is_using_builtin_array = old_is_using_builtin_array; - return expr; -} - // GCC workaround of lambdas calling protected funcs std::string CompilerMSL::variable_decl(const SPIRType &type, const std::string &name, uint32_t id) { return CompilerGLSL::variable_decl(type, name, id); } -std::string CompilerMSL::sampler_type(const SPIRType &type, uint32_t id) +std::string CompilerMSL::sampler_type(const SPIRType &type, uint32_t id, bool member) { auto *var = maybe_get(id); if (var && var->basevariable) @@ -14882,22 +15568,31 @@ std::string CompilerMSL::sampler_type(const SPIRType &type, uint32_t id) // Arrays of samplers in MSL must be declared with a special array syntax ala C++11 std::array. // If we have a runtime array, it could be a variable-count descriptor set binding. - uint32_t array_size = to_array_size_literal(type); - if (array_size == 0) - array_size = get_resource_array_size(id); - - if (array_size == 0) - SPIRV_CROSS_THROW("Unsized array of samplers is not supported in MSL."); - auto &parent = get(get_pointee_type(type).parent_type); - return join("array<", sampler_type(parent, id), ", ", array_size, ">"); + uint32_t array_size = get_resource_array_size(type, id); + + if (array_size == 0) + { + add_spv_func_and_recompile(SPVFuncImplVariableDescriptor); + add_spv_func_and_recompile(SPVFuncImplVariableDescriptorArray); + + const char *descriptor_wrapper = processing_entry_point ? "const device spvDescriptor" : "const spvDescriptorArray"; + if (member) + descriptor_wrapper = "spvDescriptor"; + return join(descriptor_wrapper, "<", sampler_type(parent, id, false), ">", + processing_entry_point ? "*" : ""); + } + else + { + return join("array<", sampler_type(parent, id, false), ", ", array_size, ">"); + } } else return "sampler"; } // Returns an MSL string describing the SPIR-V image type -string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id) +string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id, bool member) { auto *var = maybe_get(id); if (var && var->basevariable) @@ -14928,15 +15623,29 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id) // Arrays of images in MSL must be declared with a special array syntax ala C++11 std::array. // If we have a runtime array, it could be a variable-count descriptor set binding. - uint32_t array_size = to_array_size_literal(type); - if (array_size == 0) - array_size = get_resource_array_size(id); - - if (array_size == 0) - SPIRV_CROSS_THROW("Unsized array of images is not supported in MSL."); - auto &parent = get(get_pointee_type(type).parent_type); - return join("array<", image_type_glsl(parent, id), ", ", array_size, ">"); + uint32_t array_size = get_resource_array_size(type, id); + + if (array_size == 0) + { + add_spv_func_and_recompile(SPVFuncImplVariableDescriptor); + add_spv_func_and_recompile(SPVFuncImplVariableDescriptorArray); + const char *descriptor_wrapper = processing_entry_point ? "const device spvDescriptor" : "const spvDescriptorArray"; + if (member) + { + descriptor_wrapper = "spvDescriptor"; + // This requires a specialized wrapper type that packs image and sampler side by side. + // It is possible in theory. + if (type.basetype == SPIRType::SampledImage) + SPIRV_CROSS_THROW("Argument buffer runtime array currently not supported for combined image sampler."); + } + return join(descriptor_wrapper, "<", image_type_glsl(parent, id, false), ">", + processing_entry_point ? "*" : ""); + } + else + { + return join("array<", image_type_glsl(parent, id, false), ", ", array_size, ">"); + } } string img_type_name; @@ -15149,6 +15858,10 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformBallotFindLSB: case OpGroupNonUniformBallotFindMSB: case OpGroupNonUniformBallotBitCount: + case OpSubgroupBallotKHR: + case OpSubgroupAllKHR: + case OpSubgroupAnyKHR: + case OpSubgroupAllEqualKHR: if (!msl_options.supports_msl_version(2, 2)) SPIRV_CROSS_THROW("Ballot ops on iOS requires Metal 2.2 and up."); break; @@ -15159,6 +15872,7 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformShuffleDown: case OpGroupNonUniformQuadSwap: case OpGroupNonUniformQuadBroadcast: + case OpSubgroupReadInvocationKHR: break; } } @@ -15174,14 +15888,31 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformShuffleXor: case OpGroupNonUniformShuffleUp: case OpGroupNonUniformShuffleDown: + case OpSubgroupReadInvocationKHR: break; } } - uint32_t result_type = ops[0]; - uint32_t id = ops[1]; + uint32_t op_idx = 0; + uint32_t result_type = ops[op_idx++]; + uint32_t id = ops[op_idx++]; - auto scope = static_cast(evaluate_constant_u32(ops[2])); + Scope scope; + switch (op) + { + case OpSubgroupBallotKHR: + case OpSubgroupFirstInvocationKHR: + case OpSubgroupReadInvocationKHR: + case OpSubgroupAllKHR: + case OpSubgroupAnyKHR: + case OpSubgroupAllEqualKHR: + // These earlier instructions don't have the scope operand. + scope = ScopeSubgroup; + break; + default: + scope = static_cast(evaluate_constant_u32(ops[op_idx++])); + break; + } if (scope != ScopeSubgroup) SPIRV_CROSS_THROW("Only subgroup scope is supported."); @@ -15195,47 +15926,50 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) break; case OpGroupNonUniformBroadcast: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupBroadcast"); + case OpSubgroupReadInvocationKHR: + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupBroadcast"); break; case OpGroupNonUniformBroadcastFirst: - emit_unary_func_op(result_type, id, ops[3], "spvSubgroupBroadcastFirst"); + case OpSubgroupFirstInvocationKHR: + emit_unary_func_op(result_type, id, ops[op_idx], "spvSubgroupBroadcastFirst"); break; case OpGroupNonUniformBallot: - emit_unary_func_op(result_type, id, ops[3], "spvSubgroupBallot"); + case OpSubgroupBallotKHR: + emit_unary_func_op(result_type, id, ops[op_idx], "spvSubgroupBallot"); break; case OpGroupNonUniformInverseBallot: - emit_binary_func_op(result_type, id, ops[3], builtin_subgroup_invocation_id_id, "spvSubgroupBallotBitExtract"); + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_invocation_id_id, "spvSubgroupBallotBitExtract"); break; case OpGroupNonUniformBallotBitExtract: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupBallotBitExtract"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupBallotBitExtract"); break; case OpGroupNonUniformBallotFindLSB: - emit_binary_func_op(result_type, id, ops[3], builtin_subgroup_size_id, "spvSubgroupBallotFindLSB"); + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_size_id, "spvSubgroupBallotFindLSB"); break; case OpGroupNonUniformBallotFindMSB: - emit_binary_func_op(result_type, id, ops[3], builtin_subgroup_size_id, "spvSubgroupBallotFindMSB"); + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_size_id, "spvSubgroupBallotFindMSB"); break; case OpGroupNonUniformBallotBitCount: { - auto operation = static_cast(ops[3]); + auto operation = static_cast(ops[op_idx++]); switch (operation) { case GroupOperationReduce: - emit_binary_func_op(result_type, id, ops[4], builtin_subgroup_size_id, "spvSubgroupBallotBitCount"); + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_size_id, "spvSubgroupBallotBitCount"); break; case GroupOperationInclusiveScan: - emit_binary_func_op(result_type, id, ops[4], builtin_subgroup_invocation_id_id, + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_invocation_id_id, "spvSubgroupBallotInclusiveBitCount"); break; case GroupOperationExclusiveScan: - emit_binary_func_op(result_type, id, ops[4], builtin_subgroup_invocation_id_id, + emit_binary_func_op(result_type, id, ops[op_idx], builtin_subgroup_invocation_id_id, "spvSubgroupBallotExclusiveBitCount"); break; default: @@ -15245,57 +15979,60 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) } case OpGroupNonUniformShuffle: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupShuffle"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupShuffle"); break; case OpGroupNonUniformShuffleXor: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupShuffleXor"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupShuffleXor"); break; case OpGroupNonUniformShuffleUp: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupShuffleUp"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupShuffleUp"); break; case OpGroupNonUniformShuffleDown: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvSubgroupShuffleDown"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvSubgroupShuffleDown"); break; case OpGroupNonUniformAll: + case OpSubgroupAllKHR: if (msl_options.use_quadgroup_operation()) - emit_unary_func_op(result_type, id, ops[3], "quad_all"); + emit_unary_func_op(result_type, id, ops[op_idx], "quad_all"); else - emit_unary_func_op(result_type, id, ops[3], "simd_all"); + emit_unary_func_op(result_type, id, ops[op_idx], "simd_all"); break; case OpGroupNonUniformAny: + case OpSubgroupAnyKHR: if (msl_options.use_quadgroup_operation()) - emit_unary_func_op(result_type, id, ops[3], "quad_any"); + emit_unary_func_op(result_type, id, ops[op_idx], "quad_any"); else - emit_unary_func_op(result_type, id, ops[3], "simd_any"); + emit_unary_func_op(result_type, id, ops[op_idx], "simd_any"); break; case OpGroupNonUniformAllEqual: - emit_unary_func_op(result_type, id, ops[3], "spvSubgroupAllEqual"); + case OpSubgroupAllEqualKHR: + emit_unary_func_op(result_type, id, ops[op_idx], "spvSubgroupAllEqual"); break; // clang-format off #define MSL_GROUP_OP(op, msl_op) \ case OpGroupNonUniform##op: \ { \ - auto operation = static_cast(ops[3]); \ + auto operation = static_cast(ops[op_idx++]); \ if (operation == GroupOperationReduce) \ - emit_unary_func_op(result_type, id, ops[4], "simd_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "simd_" #msl_op); \ else if (operation == GroupOperationInclusiveScan) \ - emit_unary_func_op(result_type, id, ops[4], "simd_prefix_inclusive_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "simd_prefix_inclusive_" #msl_op); \ else if (operation == GroupOperationExclusiveScan) \ - emit_unary_func_op(result_type, id, ops[4], "simd_prefix_exclusive_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "simd_prefix_exclusive_" #msl_op); \ else if (operation == GroupOperationClusteredReduce) \ { \ /* Only cluster sizes of 4 are supported. */ \ - uint32_t cluster_size = evaluate_constant_u32(ops[5]); \ + uint32_t cluster_size = evaluate_constant_u32(ops[op_idx + 1]); \ if (cluster_size != 4) \ SPIRV_CROSS_THROW("Metal only supports quad ClusteredReduce."); \ - emit_unary_func_op(result_type, id, ops[4], "quad_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "quad_" #msl_op); \ } \ else \ SPIRV_CROSS_THROW("Invalid group operation."); \ @@ -15311,9 +16048,9 @@ case OpGroupNonUniform##op: \ #define MSL_GROUP_OP(op, msl_op) \ case OpGroupNonUniform##op: \ { \ - auto operation = static_cast(ops[3]); \ + auto operation = static_cast(ops[op_idx++]); \ if (operation == GroupOperationReduce) \ - emit_unary_func_op(result_type, id, ops[4], "simd_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "simd_" #msl_op); \ else if (operation == GroupOperationInclusiveScan) \ SPIRV_CROSS_THROW("Metal doesn't support InclusiveScan for OpGroupNonUniform" #op "."); \ else if (operation == GroupOperationExclusiveScan) \ @@ -15321,10 +16058,10 @@ case OpGroupNonUniform##op: \ else if (operation == GroupOperationClusteredReduce) \ { \ /* Only cluster sizes of 4 are supported. */ \ - uint32_t cluster_size = evaluate_constant_u32(ops[5]); \ + uint32_t cluster_size = evaluate_constant_u32(ops[op_idx + 1]); \ if (cluster_size != 4) \ SPIRV_CROSS_THROW("Metal only supports quad ClusteredReduce."); \ - emit_unary_func_op(result_type, id, ops[4], "quad_" #msl_op); \ + emit_unary_func_op(result_type, id, ops[op_idx], "quad_" #msl_op); \ } \ else \ SPIRV_CROSS_THROW("Invalid group operation."); \ @@ -15334,9 +16071,9 @@ case OpGroupNonUniform##op: \ #define MSL_GROUP_OP_CAST(op, msl_op, type) \ case OpGroupNonUniform##op: \ { \ - auto operation = static_cast(ops[3]); \ + auto operation = static_cast(ops[op_idx++]); \ if (operation == GroupOperationReduce) \ - emit_unary_func_op_cast(result_type, id, ops[4], "simd_" #msl_op, type, type); \ + emit_unary_func_op_cast(result_type, id, ops[op_idx], "simd_" #msl_op, type, type); \ else if (operation == GroupOperationInclusiveScan) \ SPIRV_CROSS_THROW("Metal doesn't support InclusiveScan for OpGroupNonUniform" #op "."); \ else if (operation == GroupOperationExclusiveScan) \ @@ -15344,10 +16081,10 @@ case OpGroupNonUniform##op: \ else if (operation == GroupOperationClusteredReduce) \ { \ /* Only cluster sizes of 4 are supported. */ \ - uint32_t cluster_size = evaluate_constant_u32(ops[5]); \ + uint32_t cluster_size = evaluate_constant_u32(ops[op_idx + 1]); \ if (cluster_size != 4) \ SPIRV_CROSS_THROW("Metal only supports quad ClusteredReduce."); \ - emit_unary_func_op_cast(result_type, id, ops[4], "quad_" #msl_op, type, type); \ + emit_unary_func_op_cast(result_type, id, ops[op_idx], "quad_" #msl_op, type, type); \ } \ else \ SPIRV_CROSS_THROW("Invalid group operation."); \ @@ -15371,11 +16108,11 @@ case OpGroupNonUniform##op: \ #undef MSL_GROUP_OP_CAST case OpGroupNonUniformQuadSwap: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvQuadSwap"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvQuadSwap"); break; case OpGroupNonUniformQuadBroadcast: - emit_binary_func_op(result_type, id, ops[3], ops[4], "spvQuadBroadcast"); + emit_binary_func_op(result_type, id, ops[op_idx], ops[op_idx + 1], "spvQuadBroadcast"); break; default: @@ -15958,8 +16695,8 @@ string CompilerMSL::built_in_func_arg(BuiltIn builtin, bool prefix_comma) // Handle HLSL-style 0-based vertex/instance index. builtin_declaration = true; bi_arg += builtin_type_decl(builtin); - bi_arg += " " + builtin_to_glsl(builtin, StorageClassInput); - bi_arg += " [[" + builtin_qualifier(builtin) + "]]"; + bi_arg += string(" ") + builtin_to_glsl(builtin, StorageClassInput); + bi_arg += string(" [[") + builtin_qualifier(builtin) + string("]]"); builtin_declaration = false; return bi_arg; @@ -16320,8 +17057,11 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui // Emulate texture2D atomic operations case OpImageTexelPointer: { - auto *var = compiler.maybe_get_backing_variable(args[2]); - image_pointers[args[1]] = var ? var->self : ID(0); + if (!compiler.msl_options.supports_msl_version(3, 1)) + { + auto *var = compiler.maybe_get_backing_variable(args[2]); + image_pointers_emulated[args[1]] = var ? var->self : ID(0); + } break; } @@ -16351,11 +17091,11 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui case OpAtomicXor: { uses_atomics = true; - auto it = image_pointers.find(args[2]); - if (it != image_pointers.end()) + auto it = image_pointers_emulated.find(args[2]); + if (it != image_pointers_emulated.end()) { uses_image_write = true; - compiler.atomic_image_vars.insert(it->second); + compiler.atomic_image_vars_emulated.insert(it->second); } else check_resource_write(args[2]); @@ -16365,10 +17105,10 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui case OpAtomicStore: { uses_atomics = true; - auto it = image_pointers.find(args[0]); - if (it != image_pointers.end()) + auto it = image_pointers_emulated.find(args[0]); + if (it != image_pointers_emulated.end()) { - compiler.atomic_image_vars.insert(it->second); + compiler.atomic_image_vars_emulated.insert(it->second); uses_image_write = true; } else @@ -16379,10 +17119,10 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui case OpAtomicLoad: { uses_atomics = true; - auto it = image_pointers.find(args[2]); - if (it != image_pointers.end()) + auto it = image_pointers_emulated.find(args[2]); + if (it != image_pointers_emulated.end()) { - compiler.atomic_image_vars.insert(it->second); + compiler.atomic_image_vars_emulated.insert(it->second); } break; } @@ -16406,8 +17146,11 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui case OpArrayLength: { auto *var = compiler.maybe_get_backing_variable(args[2]); - if (var) - compiler.buffers_requiring_array_length.insert(var->self); + if (var != nullptr) + { + if (!compiler.is_var_runtime_size_array(*var)) + compiler.buffers_requiring_array_length.insert(var->self); + } break; } @@ -16558,8 +17301,8 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o case OpAtomicLoad: case OpAtomicStore: { - auto it = image_pointers.find(args[opcode == OpAtomicStore ? 0 : 2]); - if (it != image_pointers.end()) + auto it = image_pointers_emulated.find(args[opcode == OpAtomicStore ? 0 : 2]); + if (it != image_pointers_emulated.end()) { uint32_t tid = compiler.get(it->second).basetype; if (tid && compiler.get(tid).image.dim == Dim2D) @@ -16644,12 +17387,15 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o } case OpGroupNonUniformBroadcast: + case OpSubgroupReadInvocationKHR: return SPVFuncImplSubgroupBroadcast; case OpGroupNonUniformBroadcastFirst: + case OpSubgroupFirstInvocationKHR: return SPVFuncImplSubgroupBroadcastFirst; case OpGroupNonUniformBallot: + case OpSubgroupBallotKHR: return SPVFuncImplSubgroupBallot; case OpGroupNonUniformInverseBallot: @@ -16666,6 +17412,7 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o return SPVFuncImplSubgroupBallotBitCount; case OpGroupNonUniformAllEqual: + case OpSubgroupAllEqualKHR: return SPVFuncImplSubgroupAllEqual; case OpGroupNonUniformShuffle: @@ -16686,6 +17433,14 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o case OpGroupNonUniformQuadSwap: return SPVFuncImplQuadSwap; + case OpSDot: + case OpUDot: + case OpSUDot: + case OpSDotAccSat: + case OpUDotAccSat: + case OpSUDotAccSat: + return SPVFuncImplReduceAdd; + default: break; } @@ -16814,7 +17569,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr, // Type fixups for workgroup variables if they are booleans. if (rewrite_boolean_load) { - if (type_is_top_level_array(expr_type)) + if (is_array(expr_type)) expr = to_rerolled_array_expression(expr_type, expr, expr_type); else expr = join(type_to_glsl(expr_type), "(", expr, ")"); @@ -16873,6 +17628,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr, case BuiltInInstanceIndex: case BuiltInBaseInstance: case BuiltInBaseVertex: + case BuiltInSampleMask: expected_type = SPIRType::UInt; expected_width = 32; break; @@ -16890,9 +17646,17 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr, break; } - if (expected_type != expr_type.basetype) + if (is_array(expr_type) && builtin == BuiltInSampleMask) { - if (!expr_type.array.empty() && (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter)) + // Needs special handling. + auto wrap_expr = join(type_to_glsl(expr_type), "({ "); + wrap_expr += join(type_to_glsl(get(expr_type.parent_type)), "(", expr, ")"); + wrap_expr += " })"; + expr = std::move(wrap_expr); + } + else if (expected_type != expr_type.basetype) + { + if (is_array(expr_type) && (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter)) { // Triggers when loading TessLevel directly as an array. // Need explicit padding + cast. @@ -16951,7 +17715,7 @@ void CompilerMSL::cast_to_variable_store(uint32_t target_id, std::string &expr, // Type fixups for workgroup variables or struct members if they are booleans. if (rewrite_boolean_store) { - if (type_is_top_level_array(expr_type)) + if (is_array(expr_type)) { expr = to_rerolled_array_expression(*var_type, expr, expr_type); } @@ -17195,7 +17959,7 @@ void CompilerMSL::analyze_argument_buffers() { &var, descriptor_alias, to_name(var_id), type.basetype, resource_index, 0 }); // Emulate texture2D atomic operations - if (atomic_image_vars.count(var.self)) + if (atomic_image_vars_emulated.count(var.self)) { uint32_t buffer_resource_index = get_metal_resource_index(var, SPIRType::AtomicCounter, 0); resources_in_set[desc_set].push_back( @@ -17230,6 +17994,7 @@ void CompilerMSL::analyze_argument_buffers() // Create a buffer to hold extra data, including the swizzle constants. SPIRType uint_type_pointer = get_uint_type(); + uint_type_pointer.op = OpTypePointer; uint_type_pointer.pointer = true; uint_type_pointer.pointer_depth++; uint_type_pointer.parent_type = get_uint_type_id(); @@ -17285,7 +18050,7 @@ void CompilerMSL::analyze_argument_buffers() uint32_t ptr_type_id = next_id + 2; argument_buffer_ids[desc_set] = next_id; - auto &buffer_type = set(type_id); + auto &buffer_type = set(type_id, OpTypeStruct); buffer_type.basetype = SPIRType::Struct; @@ -17302,8 +18067,9 @@ void CompilerMSL::analyze_argument_buffers() set_name(type_id, join("spvDescriptorSetBuffer", desc_set)); - auto &ptr_type = set(ptr_type_id); + auto &ptr_type = set(ptr_type_id, OpTypePointer); ptr_type = buffer_type; + ptr_type.op = spv::OpTypePointer; ptr_type.pointer = true; ptr_type.pointer_depth++; ptr_type.parent_type = type_id; @@ -17324,15 +18090,18 @@ void CompilerMSL::analyze_argument_buffers() auto &var = *resource.var; auto &type = get_variable_data_type(var); + if (is_var_runtime_size_array(var) && (argument_buffer_device_storage_mask & (1u << desc_set)) == 0) + SPIRV_CROSS_THROW("Runtime sized variables must be in device storage argument buffers."); + // If needed, synthesize and add padding members. // member_index and next_arg_buff_index are incremented when padding members are added. if (msl_options.pad_argument_buffer_resources) { + auto &rez_bind = get_argument_buffer_resource(desc_set, next_arg_buff_index); if (!resource.descriptor_alias) { while (resource.index > next_arg_buff_index) { - auto &rez_bind = get_argument_buffer_resource(desc_set, next_arg_buff_index); switch (rez_bind.basetype) { case SPIRType::Void: @@ -17370,12 +18139,9 @@ void CompilerMSL::analyze_argument_buffers() } // Adjust the number of slots consumed by current member itself. - // If actual member is an array, allow runtime array resolution as well. - uint32_t elem_cnt = type.array.empty() ? 1 : to_array_size_literal(type); - if (elem_cnt == 0) - elem_cnt = get_resource_array_size(var.self); - - next_arg_buff_index += elem_cnt; + // Use the count value from the app, instead of the shader, in case the + // shader is only accesing part, or even one element, of the array. + next_arg_buff_index += rez_bind.count; } string mbr_name = ensure_valid_name(resource.name, "m"); @@ -17389,14 +18155,14 @@ void CompilerMSL::analyze_argument_buffers() bool type_is_array = !type.array.empty(); uint32_t sampler_type_id = ir.increase_bound_by(type_is_array ? 2 : 1); - auto &new_sampler_type = set(sampler_type_id); + auto &new_sampler_type = set(sampler_type_id, OpTypeSampler); new_sampler_type.basetype = SPIRType::Sampler; new_sampler_type.storage = StorageClassUniformConstant; if (type_is_array) { uint32_t sampler_type_array_id = sampler_type_id + 1; - auto &sampler_type_array = set(sampler_type_array_id); + auto &sampler_type_array = set(sampler_type_array_id, OpTypeArray); sampler_type_array = new_sampler_type; sampler_type_array.array = type.array; sampler_type_array.array_size_literal = type.array_size_literal; @@ -17437,7 +18203,7 @@ void CompilerMSL::analyze_argument_buffers() buffer_type.member_types.push_back(get_variable_data_type_id(var)); set_qualified_name(var.self, join(to_name(buffer_variable_id), ".", mbr_name)); } - else if (atomic_image_vars.count(var.self)) + else if (atomic_image_vars_emulated.count(var.self)) { // Emulate texture2D atomic operations. // Don't set the qualified name: it's already set for this variable, @@ -17447,12 +18213,13 @@ void CompilerMSL::analyze_argument_buffers() uint32_t atomic_type_id = offset; uint32_t type_ptr_id = offset + 1; - SPIRType atomic_type; + SPIRType atomic_type { OpTypeInt }; atomic_type.basetype = SPIRType::AtomicCounter; atomic_type.width = 32; atomic_type.vecsize = 1; set(atomic_type_id, atomic_type); + atomic_type.op = OpTypePointer; atomic_type.pointer = true; atomic_type.pointer_depth++; atomic_type.parent_type = atomic_type_id; @@ -17513,13 +18280,14 @@ void CompilerMSL::add_argument_buffer_padding_buffer_type(SPIRType &struct_type, if (!argument_buffer_padding_buffer_type_id) { uint32_t buff_type_id = ir.increase_bound_by(2); - auto &buff_type = set(buff_type_id); + auto &buff_type = set(buff_type_id, OpNop); buff_type.basetype = rez_bind.basetype; buff_type.storage = StorageClassUniformConstant; uint32_t ptr_type_id = buff_type_id + 1; - auto &ptr_type = set(ptr_type_id); + auto &ptr_type = set(ptr_type_id, OpTypePointer); ptr_type = buff_type; + ptr_type.op = spv::OpTypePointer; ptr_type.pointer = true; ptr_type.pointer_depth++; ptr_type.parent_type = buff_type_id; @@ -17527,8 +18295,7 @@ void CompilerMSL::add_argument_buffer_padding_buffer_type(SPIRType &struct_type, argument_buffer_padding_buffer_type_id = ptr_type_id; } - for (uint32_t rez_idx = 0; rez_idx < rez_bind.count; rez_idx++) - add_argument_buffer_padding_type(argument_buffer_padding_buffer_type_id, struct_type, mbr_idx, arg_buff_index, 1); + add_argument_buffer_padding_type(argument_buffer_padding_buffer_type_id, struct_type, mbr_idx, arg_buff_index, rez_bind.count); } // Adds an argument buffer padding argument image type as a member of the struct type at the member index. @@ -17538,12 +18305,12 @@ void CompilerMSL::add_argument_buffer_padding_image_type(SPIRType &struct_type, if (!argument_buffer_padding_image_type_id) { uint32_t base_type_id = ir.increase_bound_by(2); - auto &base_type = set(base_type_id); + auto &base_type = set(base_type_id, OpTypeFloat); base_type.basetype = SPIRType::Float; base_type.width = 32; uint32_t img_type_id = base_type_id + 1; - auto &img_type = set(img_type_id); + auto &img_type = set(img_type_id, OpTypeImage); img_type.basetype = SPIRType::Image; img_type.storage = StorageClassUniformConstant; @@ -17569,7 +18336,7 @@ void CompilerMSL::add_argument_buffer_padding_sampler_type(SPIRType &struct_type if (!argument_buffer_padding_sampler_type_id) { uint32_t samp_type_id = ir.increase_bound_by(1); - auto &samp_type = set(samp_type_id); + auto &samp_type = set(samp_type_id, OpTypeSampler); samp_type.basetype = SPIRType::Sampler; samp_type.storage = StorageClassUniformConstant; @@ -17588,8 +18355,8 @@ void CompilerMSL::add_argument_buffer_padding_type(uint32_t mbr_type_id, SPIRTyp if (count > 1) { uint32_t ary_type_id = ir.increase_bound_by(1); - auto &ary_type = set(ary_type_id); - ary_type = get(type_id); + auto &ary_type = set(ary_type_id, get(type_id)); + ary_type.op = OpTypeArray; ary_type.array.push_back(count); ary_type.array_size_literal.push_back(true); ary_type.parent_type = type_id; diff --git a/third_party/spirv-cross/spirv_msl.hpp b/third_party/spirv-cross/spirv_msl.hpp index 4c5c753db7..ed9180972f 100644 --- a/third_party/spirv-cross/spirv_msl.hpp +++ b/third_party/spirv-cross/spirv_msl.hpp @@ -358,6 +358,9 @@ public: // Tier capabilities based on recommendations from Apple engineering. ArgumentBuffersTier argument_buffers_tier = ArgumentBuffersTier::Tier1; + // Enables specifick argument buffer format with extra information to track SSBO-length + bool runtime_array_rich_descriptor = false; + // Ensures vertex and instance indices start at zero. This reflects the behavior of HLSL with SV_VertexID and SV_InstanceID. bool enable_base_index_zero = false; @@ -496,6 +499,26 @@ public: // so it can be enabled only when the bug is present. bool sample_dref_lod_array_as_grad = false; + // MSL doesn't guarantee coherence between writes and subsequent reads of read_write textures. + // This inserts fences before each read of a read_write texture to ensure coherency. + // If you're sure you never rely on this, you can set this to false for a possible performance improvement. + // Note: Only Apple's GPU compiler takes advantage of the lack of coherency, so make sure to test on Apple GPUs if you disable this. + bool readwrite_texture_fences = true; + + // Metal 3.1 introduced a Metal regression bug which causes infinite recursion during + // Metal's analysis of an entry point input structure that is itself recursive. Enabling + // this option will replace the recursive input declaration with a alternate variable of + // type void*, and then cast to the correct type at the top of the entry point function. + // The bug has been reported to Apple, and will hopefully be fixed in future releases. + bool replace_recursive_inputs = false; + + // If set, manual fixups of gradient vectors for cube texture lookups will be performed. + // All released Apple Silicon GPUs to date behave incorrectly when sampling a cube texture + // with explicit gradients. They will ignore one of the three partial derivatives based + // on the selected major axis, and expect the remaining derivatives to be partially + // transformed. + bool agx_manual_cube_grad_fixup = false; + bool is_ios() const { return platform == iOS; @@ -740,6 +763,7 @@ protected: SPVFuncImplArrayOfArrayCopy6Dim = SPVFuncImplArrayCopyMultidimBase + 6, SPVFuncImplTexelBufferCoords, SPVFuncImplImage2DAtomicCoords, // Emulate texture2D atomic operations + SPVFuncImplGradientCube, SPVFuncImplFMul, SPVFuncImplFAdd, SPVFuncImplFSub, @@ -795,6 +819,12 @@ protected: SPVFuncImplConvertYCbCrBT601, SPVFuncImplConvertYCbCrBT2020, SPVFuncImplDynamicImageSampler, + SPVFuncImplRayQueryIntersectionParams, + SPVFuncImplVariableDescriptor, + SPVFuncImplVariableSizedDescriptor, + SPVFuncImplVariableDescriptorArray, + SPVFuncImplPaddedStd140, + SPVFuncImplReduceAdd }; // If the underlying resource has been used for comparison then duplicate loads of that resource must be too @@ -828,16 +858,13 @@ protected: std::string type_to_array_glsl(const SPIRType &type) override; std::string constant_op_expression(const SPIRConstantOp &cop) override; - // Threadgroup arrays can't have a wrapper type - std::string variable_decl(const SPIRVariable &variable) override; - bool variable_decl_is_remapped_storage(const SPIRVariable &variable, spv::StorageClass storage) const override; // GCC workaround of lambdas calling protected functions (for older GCC versions) std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0) override; - std::string image_type_glsl(const SPIRType &type, uint32_t id = 0) override; - std::string sampler_type(const SPIRType &type, uint32_t id); + std::string image_type_glsl(const SPIRType &type, uint32_t id, bool member) override; + std::string sampler_type(const SPIRType &type, uint32_t id, bool member); std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override; std::string to_func_call_arg(const SPIRFunction::Parameter &arg, uint32_t id) override; std::string to_name(uint32_t id, bool allow_alias = true) const override; @@ -950,7 +977,8 @@ protected: void emit_specialization_constants_and_structs(); void emit_interface_block(uint32_t ib_var_id); bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs); - uint32_t get_resource_array_size(uint32_t id) const; + bool is_var_runtime_size_array(const SPIRVariable &var) const; + uint32_t get_resource_array_size(const SPIRType &type, uint32_t id) const; void fix_up_shader_inputs_outputs(); @@ -1017,6 +1045,7 @@ protected: bool validate_member_packing_rules_msl(const SPIRType &type, uint32_t index) const; std::string get_argument_address_space(const SPIRVariable &argument); std::string get_type_address_space(const SPIRType &type, uint32_t id, bool argument = false); + static bool decoration_flags_signal_volatile(const Bitset &flags); const char *to_restrict(uint32_t id, bool space); SPIRType &get_stage_in_struct_type(); SPIRType &get_stage_out_struct_type(); @@ -1076,7 +1105,7 @@ protected: void analyze_sampled_image_usage(); bool access_chain_needs_stage_io_builtin_translation(uint32_t base) override; - void prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, + bool prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, bool &is_packed) override; void fix_up_interpolant_access_chain(const uint32_t *ops, uint32_t length); void check_physical_type_cast(std::string &expr, const SPIRType *type, uint32_t physical_type) override; @@ -1177,11 +1206,13 @@ protected: const MSLConstexprSampler *find_constexpr_sampler(uint32_t id) const; std::unordered_set buffers_requiring_array_length; - SmallVector buffer_arrays_discrete; SmallVector> buffer_aliases_argument; SmallVector buffer_aliases_discrete; - std::unordered_set atomic_image_vars; // Emulate texture2D atomic operations + std::unordered_set atomic_image_vars_emulated; // Emulate texture2D atomic operations std::unordered_set pull_model_inputs; + std::unordered_set recursive_inputs; + + SmallVector entry_point_bindings; // Must be ordered since array is in a specific order. std::map> buffers_requiring_dynamic_offset; @@ -1247,7 +1278,7 @@ protected: CompilerMSL &compiler; std::unordered_map result_types; - std::unordered_map image_pointers; // Emulate texture2D atomic operations + std::unordered_map image_pointers_emulated; // Emulate texture2D atomic operations bool suppress_missing_prototypes = false; bool uses_atomics = false; bool uses_image_write = false; diff --git a/third_party/spirv-cross/spirv_parser.cpp b/third_party/spirv-cross/spirv_parser.cpp index 01c2e38124..6108dbb653 100644 --- a/third_party/spirv-cross/spirv_parser.cpp +++ b/third_party/spirv-cross/spirv_parser.cpp @@ -517,7 +517,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeVoid: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::Void; break; } @@ -525,7 +525,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeBool: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::Boolean; type.width = 1; break; @@ -535,7 +535,7 @@ void Parser::parse(const Instruction &instruction) { uint32_t id = ops[0]; uint32_t width = ops[1]; - auto &type = set(id); + auto &type = set(id, op); if (width == 64) type.basetype = SPIRType::Double; else if (width == 32) @@ -553,7 +553,7 @@ void Parser::parse(const Instruction &instruction) uint32_t id = ops[0]; uint32_t width = ops[1]; bool signedness = ops[2] != 0; - auto &type = set(id); + auto &type = set(id, op); type.basetype = signedness ? to_signed_basetype(width) : to_unsigned_basetype(width); type.width = width; break; @@ -568,9 +568,9 @@ void Parser::parse(const Instruction &instruction) uint32_t vecsize = ops[2]; auto &base = get(ops[1]); - auto &vecbase = set(id); + auto &vecbase = set(id, base); - vecbase = base; + vecbase.op = op; vecbase.vecsize = vecsize; vecbase.self = id; vecbase.parent_type = ops[1]; @@ -583,9 +583,9 @@ void Parser::parse(const Instruction &instruction) uint32_t colcount = ops[2]; auto &base = get(ops[1]); - auto &matrixbase = set(id); + auto &matrixbase = set(id, base); - matrixbase = base; + matrixbase.op = op; matrixbase.columns = colcount; matrixbase.self = id; matrixbase.parent_type = ops[1]; @@ -595,12 +595,11 @@ void Parser::parse(const Instruction &instruction) case OpTypeArray: { uint32_t id = ops[0]; - auto &arraybase = set(id); - uint32_t tid = ops[1]; auto &base = get(tid); + auto &arraybase = set(id, base); - arraybase = base; + arraybase.op = op; arraybase.parent_type = tid; uint32_t cid = ops[2]; @@ -615,7 +614,9 @@ void Parser::parse(const Instruction &instruction) arraybase.array_size_literal.push_back(literal); arraybase.array.push_back(literal ? c->scalar() : cid); - // Do NOT set arraybase.self! + + // .self resolves down to non-array/non-pointer type. + arraybase.self = base.self; break; } @@ -624,25 +625,27 @@ void Parser::parse(const Instruction &instruction) uint32_t id = ops[0]; auto &base = get(ops[1]); - auto &arraybase = set(id); + auto &arraybase = set(id, base); // We're copying type information into Array types, so we'll need a fixup for any physical pointer // references. if (base.forward_pointer) forward_pointer_fixups.push_back({ id, ops[1] }); - arraybase = base; + arraybase.op = op; arraybase.array.push_back(0); arraybase.array_size_literal.push_back(true); arraybase.parent_type = ops[1]; - // Do NOT set arraybase.self! + + // .self resolves down to non-array/non-pointer type. + arraybase.self = base.self; break; } case OpTypeImage: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::Image; type.image.type = ops[1]; type.image.dim = static_cast(ops[2]); @@ -659,7 +662,7 @@ void Parser::parse(const Instruction &instruction) { uint32_t id = ops[0]; uint32_t imagetype = ops[1]; - auto &type = set(id); + auto &type = set(id, op); type = get(imagetype); type.basetype = SPIRType::SampledImage; type.self = id; @@ -669,7 +672,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeSampler: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::Sampler; break; } @@ -682,10 +685,13 @@ void Parser::parse(const Instruction &instruction) // We won't be able to compile it, but we shouldn't crash when parsing. // We should be able to reflect. auto *base = maybe_get(ops[2]); - auto &ptrbase = set(id); + auto &ptrbase = set(id, op); if (base) + { ptrbase = *base; + ptrbase.op = op; + } ptrbase.pointer = true; ptrbase.pointer_depth++; @@ -706,7 +712,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeForwardPointer: { uint32_t id = ops[0]; - auto &ptrbase = set(id); + auto &ptrbase = set(id, op); ptrbase.pointer = true; ptrbase.pointer_depth++; ptrbase.storage = static_cast(ops[1]); @@ -721,7 +727,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeStruct: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::Struct; for (uint32_t i = 1; i < length; i++) type.member_types.push_back(ops[i]); @@ -770,7 +776,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeAccelerationStructureKHR: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::AccelerationStructure; break; } @@ -778,7 +784,7 @@ void Parser::parse(const Instruction &instruction) case OpTypeRayQueryKHR: { uint32_t id = ops[0]; - auto &type = set(id); + auto &type = set(id, op); type.basetype = SPIRType::RayQuery; break; } @@ -1025,10 +1031,9 @@ void Parser::parse(const Instruction &instruction) { uint32_t ids = ir.increase_bound_by(2); - SPIRType type; + auto &type = set(ids, OpTypeInt); type.basetype = SPIRType::Int; type.width = 32; - set(ids, type); auto &c = set(ids + 1, ids); current_block->condition = c.self; diff --git a/third_party/spirv-cross/spirv_reflect.cpp b/third_party/spirv-cross/spirv_reflect.cpp index 9fcd3bc09b..633983bd30 100644 --- a/third_party/spirv-cross/spirv_reflect.cpp +++ b/third_party/spirv-cross/spirv_reflect.cpp @@ -291,7 +291,7 @@ static bool naturally_emit_type(const SPIRType &type) bool CompilerReflection::type_is_reference(const SPIRType &type) const { // Physical pointers and arrays of physical pointers need to refer to the pointee's type. - return type_is_top_level_physical_pointer(type) || + return is_physical_pointer(type) || (type_is_array_of_pointers(type) && type.storage == StorageClassPhysicalStorageBuffer); } @@ -341,7 +341,7 @@ void CompilerReflection::emit_type(uint32_t type_id, bool &emitted_open_tag) json_stream->emit_json_key_object("_" + std::to_string(type_id)); json_stream->emit_json_key_value("name", name); - if (type_is_top_level_physical_pointer(type)) + if (is_physical_pointer(type)) { json_stream->emit_json_key_value("type", "_" + std::to_string(type.parent_type)); json_stream->emit_json_key_value("physical_pointer", true); @@ -404,7 +404,7 @@ void CompilerReflection::emit_type_member(const SPIRType &type, uint32_t index) void CompilerReflection::emit_type_array(const SPIRType &type) { - if (!type_is_top_level_physical_pointer(type) && !type.array.empty()) + if (!is_physical_pointer(type) && !type.array.empty()) { json_stream->emit_json_key_array("array"); // Note that we emit the zeros here as a means of identifying @@ -444,7 +444,7 @@ void CompilerReflection::emit_type_member_qualifiers(const SPIRType &type, uint3 if (dec.decoration_flags.get(DecorationRowMajor)) json_stream->emit_json_key_value("row_major", true); - if (type_is_top_level_physical_pointer(membertype)) + if (is_physical_pointer(membertype)) json_stream->emit_json_key_value("physical_pointer", true); } } @@ -633,6 +633,10 @@ void CompilerReflection::emit_resources(const char *tag, const SmallVectoremit_json_key_value("offset", get_decoration(res.id, DecorationOffset)); + if (mask.get(DecorationWeightTextureQCOM)) + json_stream->emit_json_key_value("WeightTextureQCOM", get_decoration(res.id, DecorationWeightTextureQCOM)); + if (mask.get(DecorationBlockMatchTextureQCOM)) + json_stream->emit_json_key_value("BlockMatchTextureQCOM", get_decoration(res.id, DecorationBlockMatchTextureQCOM)); // For images, the type itself adds a layout qualifer. // Only emit the format for storage images. diff --git a/third_party/spirv-cross/test_shaders.py b/third_party/spirv-cross/test_shaders.py index 6ae9c94afd..452e5e384a 100755 --- a/third_party/spirv-cross/test_shaders.py +++ b/third_party/spirv-cross/test_shaders.py @@ -29,6 +29,7 @@ import codecs import json import multiprocessing import errno +import platform from functools import partial class Paths(): @@ -100,8 +101,14 @@ def get_shader_stats(shader): 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 + if platform.system() == 'Darwin': + subprocess.check_call(['xcrun', '--sdk', 'iphoneos', 'metal', '--version']) + print('... are the Metal compiler characteristics.\n') # display after so xcrun FNF is silent + else: + # Use Metal Windows toolkit to test on Linux (Wine) and Windows. + print('Running on non-macOS system.') + subprocess.check_call(['metal', '-x', 'metal', '--version']) + except OSError as e: if (e.errno != errno.ENOENT): # Ignore xcrun not found error raise @@ -111,9 +118,13 @@ def print_msl_compiler_version(): def msl_compiler_supports_version(version): try: - subprocess.check_call(['xcrun', '--sdk', 'macosx', 'metal', '-x', 'metal', version, '-'], - stdin = subprocess.DEVNULL, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) - print('Current SDK supports MSL {0}. Enabling validation for MSL {0} shaders.'.format(version)) + if platform.system() == 'Darwin': + subprocess.check_call(['xcrun', '--sdk', 'macosx', 'metal', '-x', 'metal', version, '-'], + stdin = subprocess.DEVNULL, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) + print('Current SDK supports MSL {0}. Enabling validation for MSL {0} shaders.'.format(version)) + else: + print('Running on {}, assuming {} is supported.'.format(platform.system(), version)) + # If we're running on non-macOS system, assume it's supported. return True except OSError as e: print('Failed to check if MSL {} is not supported. It probably is not.'.format(version)) @@ -123,10 +134,12 @@ def msl_compiler_supports_version(version): return False def path_to_msl_standard(shader): - if '.ios.' in shader: - if '.msl3.' in shader: - return '-std=metal3.0' - elif '.msl2.' in shader: + if '.msl31.' in shader: + return '-std=metal3.1' + elif '.msl3.' in shader: + return '-std=metal3.0' + elif '.ios.' in shader: + if '.msl2.' in shader: return '-std=ios-metal2.0' elif '.msl21.' in shader: return '-std=ios-metal2.1' @@ -143,9 +156,7 @@ def path_to_msl_standard(shader): else: return '-std=ios-metal1.2' else: - if '.msl3.' in shader: - return '-std=metal3.0' - elif '.msl2.' in shader: + if '.msl2.' in shader: return '-std=macos-metal2.0' elif '.msl21.' in shader: return '-std=macos-metal2.1' @@ -161,7 +172,9 @@ def path_to_msl_standard(shader): return '-std=macos-metal1.2' def path_to_msl_standard_cli(shader): - if '.msl3.' in shader: + if '.msl31.' in shader: + return '30100' + elif '.msl3.' in shader: return '30000' elif '.msl2.' in shader: return '20000' @@ -178,18 +191,30 @@ def path_to_msl_standard_cli(shader): else: return '10200' +ignore_win_metal_tool = False def validate_shader_msl(shader, opt): msl_path = reference_path(shader[0], shader[1], opt) + global ignore_win_metal_tool try: if '.ios.' in msl_path: msl_os = 'iphoneos' else: msl_os = 'macosx' - subprocess.check_call(['xcrun', '--sdk', msl_os, 'metal', '-x', 'metal', path_to_msl_standard(msl_path), '-Werror', '-Wno-unused-variable', msl_path]) - print('Compiled Metal shader: ' + msl_path) # display after so xcrun FNF is silent + + if platform.system() == 'Darwin': + subprocess.check_call(['xcrun', '--sdk', msl_os, 'metal', '-x', 'metal', path_to_msl_standard(msl_path), '-Werror', '-Wno-unused-variable', msl_path]) + print('Compiled Metal shader: ' + msl_path) # display after so xcrun FNF is silent + elif not ignore_win_metal_tool: + # Use Metal Windows toolkit to test on Linux (Wine) and Windows. Running offline tool on Linux gets weird. + # Normal winepath doesn't work, it must be Z:/abspath *exactly* for some bizarre reason. + target_path = msl_path if platform.system == 'Windows' else ('Z:' + os.path.abspath(msl_path)) + subprocess.check_call(['metal', '-x', 'metal', path_to_msl_standard(msl_path), '-Werror', '-Wno-unused-variable', target_path]) + except OSError as oe: - if (oe.errno != errno.ENOENT): # Ignore xcrun not found error + if (oe.errno != errno.ENOENT): # Ignore xcrun or metal not found error raise + print('metal toolkit does not exist, ignoring further attempts to use it.') + ignore_win_metal_tool = True except subprocess.CalledProcessError: print('Error compiling Metal shader: ' + msl_path) raise RuntimeError('Failed to compile Metal shader') @@ -211,9 +236,7 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): spirv_env = 'vulkan1.1' glslang_env = 'vulkan1.1' - spirv_cmd = [paths.spirv_as, '--target-env', spirv_env, '-o', spirv_path, shader] - if '.preserve.' in shader: - spirv_cmd.append('--preserve-numeric-ids') + spirv_cmd = [paths.spirv_as, '--preserve-numeric-ids', '--target-env', spirv_env, '-o', spirv_path, shader] if spirv: subprocess.check_call(spirv_cmd) @@ -246,6 +269,9 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): msl_args.append('--msl-domain-lower-left') if '.argument.' in shader: msl_args.append('--msl-argument-buffers') + if '.argument-tier-1.' in shader: + msl_args.append('--msl-argument-buffer-tier') + msl_args.append('1') if '.texture-buffer-native.' in shader: msl_args.append('--msl-texture-buffer-native') if '.framebuffer-fetch.' in shader: @@ -352,8 +378,14 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): msl_args.append('--msl-check-discarded-frag-stores') if '.lod-as-grad.' in shader: msl_args.append('--msl-sample-dref-lod-array-as-grad') + if '.agx-cube-grad.' in shader: + msl_args.append('--msl-agx-manual-cube-grad-fixup') if '.decoration-binding.' in shader: msl_args.append('--msl-decoration-binding') + if '.rich-descriptor.' in shader: + msl_args.append('--msl-runtime-array-rich-descriptor') + if '.replace-recursive-inputs.' in shader: + msl_args.append('--msl-replace-recursive-inputs') if '.mask-location-0.' in shader: msl_args.append('--mask-stage-output-location') msl_args.append('0') @@ -482,9 +514,7 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati spirv_env = 'vulkan1.1' glslang_env = 'vulkan1.1' - spirv_cmd = [paths.spirv_as, '--target-env', spirv_env, '-o', spirv_path, shader] - if '.preserve.' in shader: - spirv_cmd.append('--preserve-numeric-ids') + spirv_cmd = [paths.spirv_as, '--preserve-numeric-ids', '--target-env', spirv_env, '-o', spirv_path, shader] if spirv: subprocess.check_call(spirv_cmd) @@ -517,6 +547,8 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati hlsl_args.append('--relax-nan-checks') if '.structured.' in shader: hlsl_args.append('--hlsl-preserve-structured-buffers') + if '.flip-vert-y.' in shader: + hlsl_args.append('--flip-vert-y') subprocess.check_call(hlsl_args) @@ -531,9 +563,7 @@ def cross_compile_reflect(shader, spirv, opt, iterations, paths): spirv_path = create_temporary() reflect_path = create_temporary(os.path.basename(shader)) - spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader] - if '.preserve.' in shader: - spirv_cmd.append('--preserve-numeric-ids') + spirv_cmd = [paths.spirv_as, '--preserve-numeric-ids', '--target-env', 'vulkan1.1', '-o', spirv_path, shader] if spirv: subprocess.check_call(spirv_cmd) @@ -576,9 +606,7 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fo if vulkan or spirv: vulkan_glsl_path = create_temporary('vk' + os.path.basename(shader)) - spirv_cmd = [paths.spirv_as, '--target-env', spirv_env, '-o', spirv_path, shader] - if '.preserve.' in shader: - spirv_cmd.append('--preserve-numeric-ids') + spirv_cmd = [paths.spirv_as, '--preserve-numeric-ids', '--target-env', spirv_env, '-o', spirv_path, shader] if spirv: subprocess.check_call(spirv_cmd) @@ -869,10 +897,20 @@ def test_shader_msl(stats, shader, args, paths): # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. # print('SPRIV shader: ' + spirv) - shader_is_msl22 = 'msl22' in joined_path - shader_is_msl23 = 'msl23' in joined_path - shader_is_msl24 = 'msl24' in joined_path - skip_validation = (shader_is_msl22 and (not args.msl22)) or (shader_is_msl23 and (not args.msl23)) or (shader_is_msl24 and (not args.msl24)) + shader_is_msl22 = '.msl22.' in joined_path + shader_is_msl23 = '.msl23.' in joined_path + shader_is_msl24 = '.msl24.' in joined_path + shader_is_msl30 = '.msl3.' in joined_path + shader_is_msl31 = '.msl31.' in joined_path + skip_validation = (shader_is_msl22 and (not args.msl22)) or \ + (shader_is_msl23 and (not args.msl23)) or \ + (shader_is_msl24 and (not args.msl24)) or \ + (shader_is_msl30 and (not args.msl30)) or \ + (shader_is_msl31 and (not args.msl31)) + + if skip_validation: + print('Skipping validation for {} due to lack of toolchain support.'.format(joined_path)) + if '.invalid.' in joined_path: skip_validation = True @@ -1026,12 +1064,14 @@ def main(): args.msl23 = False args.msl24 = False args.msl30 = False + args.msl31 = False if args.msl: print_msl_compiler_version() args.msl22 = msl_compiler_supports_version('-std=macos-metal2.2') args.msl23 = msl_compiler_supports_version('-std=macos-metal2.3') args.msl24 = msl_compiler_supports_version('-std=macos-metal2.4') args.msl30 = msl_compiler_supports_version('-std=metal3.0') + args.msl31 = msl_compiler_supports_version('-std=metal3.1') backend = 'glsl' if (args.msl or args.metal): diff --git a/third_party/spirv-cross/tnt/README.md b/third_party/spirv-cross/tnt/README.md index 954fa0ba3d..e752d33290 100644 --- a/third_party/spirv-cross/tnt/README.md +++ b/third_party/spirv-cross/tnt/README.md @@ -1,4 +1,18 @@ ## Updating +To update to the spire-cross of a specific chromium commit, do the following. +``` +cd third_party +curl -L https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross/+archive/b8fcf307.tar.gz > spirv-cross-src.tar.gz +mkdir spirv-cross-new +tar -xzf spirv-cross-src.tar.gz -C spirv-cross-new +rsync -r spirv-cross-new/ spirv-cross/ --delete +git restore spirv-cross/tnt +patch -p2 < spirv-cross/tnt/0001-convert-floats-to-their-smallest-string-representati.patch +patch -p2 < spirv-cross/tnt/0002-localeconv-api-level-check.patch +rm -rf spirv-cross-new spirv-cross-src.tar.gz +git add spirv-cross +``` + To update to the spirv-cross that's currently on GitHub master, do the following. diff --git a/third_party/spirv-headers/BUILD.bazel b/third_party/spirv-headers/BUILD.bazel index c898ade80a..36e83fa981 100644 --- a/third_party/spirv-headers/BUILD.bazel +++ b/third_party/spirv-headers/BUILD.bazel @@ -81,6 +81,11 @@ filegroup( srcs = ["include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json"], ) +filegroup( + name = "spirv_ext_inst_nonsemantic_vkspreflection_grammar_unified1", + srcs = ["include/spirv/unified1/extinst.nonsemantic.vkspreflection.grammar.json"], +) + filegroup( name = "spirv_ext_inst_nonsemantic_debugprintf_grammar_unified1", srcs = ["include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json"], @@ -128,6 +133,8 @@ cc_library( "include/spirv/unified1/GLSL.std.450.h", "include/spirv/unified1/NonSemanticClspvReflection.h", "include/spirv/unified1/NonSemanticDebugPrintf.h", + "include/spirv/unified1/NonSemanticShaderDebugInfo100.h", + "include/spirv/unified1/NonSemanticVkspReflection.h", "include/spirv/unified1/OpenCL.std.h", ], includes = ["include"], diff --git a/third_party/spirv-headers/BUILD.gn b/third_party/spirv-headers/BUILD.gn index be3f43b3f1..34294e023b 100644 --- a/third_party/spirv-headers/BUILD.gn +++ b/third_party/spirv-headers/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Google LLC +# Copyright (c) 2020-2024 Google LLC # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and/or associated documentation files (the "Materials"), @@ -35,6 +35,7 @@ source_set("spv_headers") { "include/spirv/unified1/GLSL.std.450.h", "include/spirv/unified1/NonSemanticClspvReflection.h", "include/spirv/unified1/NonSemanticDebugPrintf.h", + "include/spirv/unified1/NonSemanticVkspReflection.h", "include/spirv/unified1/OpenCL.std.h", "include/spirv/unified1/spirv.h", "include/spirv/unified1/spirv.hpp", diff --git a/third_party/spirv-headers/CMakeLists.txt b/third_party/spirv-headers/CMakeLists.txt index 2b8bb5e595..957b92243c 100644 --- a/third_party/spirv-headers/CMakeLists.txt +++ b/third_party/spirv-headers/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016 The Khronos Group Inc. +# Copyright (c) 2015-2024 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 @@ -23,113 +23,45 @@ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +cmake_minimum_required(VERSION 3.14) +project(SPIRV-Headers LANGUAGES C CXX VERSION 1.5.5) -# -# The SPIR-V headers from the SPIR-V Registry -# https://www.khronos.org/registry/spir-v/ -# -cmake_minimum_required(VERSION 3.19) -project(SPIRV-Headers VERSION 1.5.5) - -# There are two ways to use this project. -# -# Using this source tree directly from a CMake-based project: -# 1. Add an add_subdirectory directive to include this sub directory. -# 2. Use ${SPIRV-Headers_SOURCE_DIR}/include} in a target_include_directories -# command. -# -# Installing the headers first, then using them with an implicit include -# directory. To install the headers: -# 1. mkdir build ; cd build -# 2. cmake .. -# 3. cmake --build . --target install - -option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) - -option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) - -if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) - set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) +if (CMAKE_VERSION VERSION_LESS "3.21") + # https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html + string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL) endif() -if(NOT ${SPIRV_HEADERS_SKIP_INSTALL}) - set(SPIRV_HEADERS_ENABLE_INSTALL ON) - # legacy - add_custom_target(install-headers - COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv - $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) +add_library(SPIRV-Headers INTERFACE) +add_library(SPIRV-Headers::SPIRV-Headers ALIAS SPIRV-Headers) +target_include_directories(SPIRV-Headers INTERFACE $) + +option(SPIRV_HEADERS_ENABLE_TESTS "Test SPIRV-Headers" ${PROJECT_IS_TOP_LEVEL}) +option(SPIRV_HEADERS_ENABLE_INSTALL "Install SPIRV-Headers" ${PROJECT_IS_TOP_LEVEL}) + +if(SPIRV_HEADERS_ENABLE_TESTS) + add_subdirectory(tests) endif() -if (SPIRV_HEADERS_ENABLE_EXAMPLES) - message(STATUS "Building SPIRV-Header examples") - add_subdirectory(example) -endif() - -include(GNUInstallDirs) -add_library(${PROJECT_NAME} INTERFACE) -target_include_directories(${PROJECT_NAME} INTERFACE - $ -) - -# Installation - -if (SPIRV_HEADERS_ENABLE_INSTALL) - message(STATUS "Installing SPIRV-Header") - - set(config_install_dir "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}") - - set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") - - set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") - set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") - set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") - set(namespace "${PROJECT_NAME}::") - +if(SPIRV_HEADERS_ENABLE_INSTALL) + include(GNUInstallDirs) include(CMakePackageConfigHelpers) - if (NOT CMAKE_VERSION VERSION_LESS 3.14) - set(arch_independent_str ARCH_INDEPENDENT) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + set(cmake_install_dir "${CMAKE_INSTALL_DATADIR}/cmake/SPIRV-Headers") + set(version_config "${CMAKE_CURRENT_BINARY_DIR}/generated/SPIRV-HeadersConfigVersion.cmake") + + write_basic_package_version_file("${version_config}" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) + install(FILES "${version_config}" DESTINATION "${cmake_install_dir}") + + install(TARGETS SPIRV-Headers EXPORT "SPIRV-HeadersConfig" INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(EXPORT "SPIRV-HeadersConfig" NAMESPACE "SPIRV-Headers::" DESTINATION "${cmake_install_dir}") + + if (IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) + set(SPIRV_HEADERS_PKGCONFIG_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) + else() + set(SPIRV_HEADERS_PKGCONFIG_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) endif() - write_basic_package_version_file( - "${version_config}" - COMPATIBILITY SameMajorVersion - ${arch_independent_str} - ) - - configure_package_config_file( - "cmake/Config.cmake.in" - "${project_config}" - INSTALL_DESTINATION "${config_install_dir}" - ) - - install( - TARGETS ${PROJECT_NAME} - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) - - install( - DIRECTORY include/spirv - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) - - install( - FILES "${project_config}" "${version_config}" - DESTINATION "${config_install_dir}" - ) - - install( - EXPORT "${TARGETS_EXPORT_NAME}" - NAMESPACE "${namespace}" - DESTINATION "${config_install_dir}" - ) - - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers.pc.in ${CMAKE_BINARY_DIR}/SPIRV-Headers.pc @ONLY) - install( - FILES "${CMAKE_BINARY_DIR}/SPIRV-Headers.pc" - DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig - ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Headers.pc.in ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Headers.pc @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Headers.pc" DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig) endif() diff --git a/third_party/spirv-headers/FILAMENT_README.md b/third_party/spirv-headers/FILAMENT_README.md deleted file mode 100644 index c3eed55a2e..0000000000 --- a/third_party/spirv-headers/FILAMENT_README.md +++ /dev/null @@ -1,5 +0,0 @@ -This project is pulled in as a dependency for spirv-tools. The Vulkan -backend also has a dependency on this project. This project should not -be updated directly, instead, please see -/third_party/spirv-tools/FILAMENT_README.md for instructions for -update. diff --git a/third_party/spirv-headers/LICENSE b/third_party/spirv-headers/LICENSE index 47974f8ce3..a02ace17bf 100644 --- a/third_party/spirv-headers/LICENSE +++ b/third_party/spirv-headers/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2015-2018 The Khronos Group Inc. +Files: All files except for those called out below. +Copyright (c) 2015-2024 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 @@ -23,3 +24,80 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +--- + +Files: include/spirv/spir-v.xml +Copyright (c) 2015-2024 The Khronos Group Inc. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and/or associated documentation files (the +"Materials"), to deal in the Materials without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Materials, and to +permit persons to whom the Materials are furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Materials. + +THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +--- + +Files: tools/buildHeaders/jsoncpp/* +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== + +--- diff --git a/third_party/spirv-headers/README.md b/third_party/spirv-headers/README.md index 8c7039f7d1..ed38828564 100644 --- a/third_party/spirv-headers/README.md +++ b/third_party/spirv-headers/README.md @@ -198,7 +198,7 @@ python3 bin/makeExtinstHeaders.py ## License ``` -Copyright (c) 2015-2018 The Khronos Group Inc. +Copyright (c) 2015-2024 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 diff --git a/third_party/spirv-headers/SECURITY.md b/third_party/spirv-headers/SECURITY.md new file mode 100644 index 0000000000..9b51f0cf0c --- /dev/null +++ b/third_party/spirv-headers/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/KhronosGroup/SPIRV-Headers/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/third_party/spirv-headers/cmake/Config.cmake.in b/third_party/spirv-headers/cmake/Config.cmake.in deleted file mode 100644 index 38bbde7b37..0000000000 --- a/third_party/spirv-headers/cmake/Config.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") -check_required_components("@PROJECT_NAME@") diff --git a/third_party/spirv-headers/SPIRV-Headers.pc.in b/third_party/spirv-headers/cmake/SPIRV-Headers.pc.in similarity index 65% rename from third_party/spirv-headers/SPIRV-Headers.pc.in rename to third_party/spirv-headers/cmake/SPIRV-Headers.pc.in index 345f5f8040..843b0a7e7a 100644 --- a/third_party/spirv-headers/SPIRV-Headers.pc.in +++ b/third_party/spirv-headers/cmake/SPIRV-Headers.pc.in @@ -1,5 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +includedir=@SPIRV_HEADERS_PKGCONFIG_INCLUDE_DIR@ Name: SPIRV-Headers Description: Header files from the SPIR-V registry diff --git a/third_party/spirv-headers/example/CMakeLists.txt b/third_party/spirv-headers/example/CMakeLists.txt deleted file mode 100644 index 8b22f600a2..0000000000 --- a/third_party/spirv-headers/example/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_library(SPIRV-Headers-example - ${CMAKE_CURRENT_SOURCE_DIR}/example.cpp) -target_include_directories(SPIRV-Headers-example - PRIVATE ${SPIRV-Headers_SOURCE_DIR}/include) diff --git a/third_party/spirv-headers/filament-specific-changes.patch b/third_party/spirv-headers/filament-specific-changes.patch deleted file mode 100644 index b9ddb551ae..0000000000 --- a/third_party/spirv-headers/filament-specific-changes.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/third_party/spirv-headers/CMakeLists.txt b/third_party/spirv-headers/CMakeLists.txt -index 9cfba73af..2b8bb5e59 100644 ---- a/third_party/spirv-headers/CMakeLists.txt -+++ b/third_party/spirv-headers/CMakeLists.txt -@@ -28,7 +28,7 @@ - # The SPIR-V headers from the SPIR-V Registry - # https://www.khronos.org/registry/spir-v/ - # --cmake_minimum_required(VERSION 3.0) -+cmake_minimum_required(VERSION 3.19) - project(SPIRV-Headers VERSION 1.5.5) - - # There are two ways to use this project. -@@ -44,11 +44,9 @@ project(SPIRV-Headers VERSION 1.5.5) - # 2. cmake .. - # 3. cmake --build . --target install - --option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" -- ${SPIRV_HEADERS_SKIP_EXAMPLES}) -+option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) - --option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" -- ${SPIRV_HEADERS_SKIP_INSTALL}) -+option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) - - if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) - set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-headers/include/spirv/spir-v.xml b/third_party/spirv-headers/include/spirv/spir-v.xml index 642fdf3b67..01d1512e82 100644 --- a/third_party/spirv-headers/include/spirv/spir-v.xml +++ b/third_party/spirv-headers/include/spirv/spir-v.xml @@ -1,7 +1,7 @@ @@ -140,13 +150,18 @@ + + + + + - + @@ -170,13 +185,17 @@ + + + + - + @@ -196,8 +215,8 @@ - - + + @@ -237,7 +256,8 @@ - + + @@ -256,8 +276,9 @@ - - + + + diff --git a/third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h b/third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h index 80165ae5c0..e626a7a956 100644 --- a/third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h +++ b/third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h index 8a8bb6eced..563c0b622d 100644 --- a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h +++ b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h index 12b6480f13..e663330c19 100644 --- a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h +++ b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h index 1b14997d27..dd51c5fc81 100644 --- a/third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h +++ b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/include/spirv/unified1/DebugInfo.h b/third_party/spirv-headers/include/spirv/unified1/DebugInfo.h index 4657556bf0..a3c0af4562 100644 --- a/third_party/spirv-headers/include/spirv/unified1/DebugInfo.h +++ b/third_party/spirv-headers/include/spirv/unified1/DebugInfo.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017 The Khronos Group Inc. +// Copyright (c) 2017-2024 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"), diff --git a/third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h b/third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h index 54cc00e9a8..0594f907a1 100644 --- a/third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h +++ b/third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2014-2016 The Khronos Group Inc. +** Copyright (c) 2014-2024 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"), diff --git a/third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h index 0cdf29d129..b6c27fa9b9 100644 --- a/third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h +++ b/third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 @@ -33,7 +33,7 @@ extern "C" { #endif enum { - NonSemanticClspvReflectionRevision = 4, + NonSemanticClspvReflectionRevision = 6, NonSemanticClspvReflectionRevision_BitWidthPadding = 0x7fffffff }; @@ -73,10 +73,23 @@ enum NonSemanticClspvReflectionInstructions { NonSemanticClspvReflectionImageArgumentInfoChannelDataTypeUniform = 33, NonSemanticClspvReflectionArgumentStorageTexelBuffer = 34, NonSemanticClspvReflectionArgumentUniformTexelBuffer = 35, + NonSemanticClspvReflectionConstantDataPointerPushConstant = 36, + NonSemanticClspvReflectionProgramScopeVariablePointerPushConstant = 37, + NonSemanticClspvReflectionPrintfInfo = 38, + NonSemanticClspvReflectionPrintfBufferStorageBuffer = 39, + NonSemanticClspvReflectionPrintfBufferPointerPushConstant = 40, + NonSemanticClspvReflectionNormalizedSamplerMaskPushConstant = 41, NonSemanticClspvReflectionInstructionsMax = 0x7fffffff }; +enum NonSemanticClspvReflectionKernelPropertyFlags { + NonSemanticClspvReflectionNone = 0x0, + NonSemanticClspvReflectionMayUsePrintf = 0x1, + NonSemanticClspvReflectionKernelPropertyFlagsMax = 0x7fffffff +}; + + #ifdef __cplusplus } #endif diff --git a/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugBreak.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugBreak.h new file mode 100644 index 0000000000..8604fe7842 --- /dev/null +++ b/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugBreak.h @@ -0,0 +1,50 @@ +// Copyright (c) 2020-2024 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +// https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +// + +#ifndef SPIRV_UNIFIED1_NonSemanticDebugBreak_H_ +#define SPIRV_UNIFIED1_NonSemanticDebugBreak_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + NonSemanticDebugBreakRevision = 1, + NonSemanticDebugBreakRevision_BitWidthPadding = 0x7fffffff +}; + +enum NonSemanticDebugBreakInstructions { + NonSemanticDebugBreakDebugBreak = 1, + NonSemanticDebugBreakInstructionsMax = 0x7fffffff +}; + + +#ifdef __cplusplus +} +#endif + +#endif // SPIRV_UNIFIED1_NonSemanticDebugBreak_H_ diff --git a/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h index 83796d75e5..bc24683ec0 100644 --- a/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h +++ b/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h index c52f32f809..b276b560cb 100644 --- a/third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h +++ b/third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018 The Khronos Group Inc. +// Copyright (c) 2018-2024 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"), diff --git a/third_party/spirv-headers/include/spirv/unified1/NonSemanticVkspReflection.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticVkspReflection.h new file mode 100644 index 0000000000..af4a556e54 --- /dev/null +++ b/third_party/spirv-headers/include/spirv/unified1/NonSemanticVkspReflection.h @@ -0,0 +1,57 @@ +// Copyright (c) 2020-2024 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +// https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +// + +#ifndef SPIRV_UNIFIED1_NonSemanticVkspReflection_H_ +#define SPIRV_UNIFIED1_NonSemanticVkspReflection_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + NonSemanticVkspReflectionRevision = 4, + NonSemanticVkspReflectionRevision_BitWidthPadding = 0x7fffffff +}; + +enum NonSemanticVkspReflectionInstructions { + NonSemanticVkspReflectionConfiguration = 1, + NonSemanticVkspReflectionStartCounter = 2, + NonSemanticVkspReflectionStopCounter = 3, + NonSemanticVkspReflectionPushConstants = 4, + NonSemanticVkspReflectionSpecializationMapEntry = 5, + NonSemanticVkspReflectionDescriptorSetBuffer = 6, + NonSemanticVkspReflectionDescriptorSetImage = 7, + NonSemanticVkspReflectionDescriptorSetSampler = 8, + NonSemanticVkspReflectionInstructionsMax = 0x7fffffff +}; + + +#ifdef __cplusplus +} +#endif + +#endif // SPIRV_UNIFIED1_NonSemanticVkspReflection_H_ diff --git a/third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h b/third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h index 2745e30df3..ed74f203e1 100644 --- a/third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h +++ b/third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2015-2019 The Khronos Group Inc. +** Copyright (c) 2015-2024 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"), diff --git a/third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h b/third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h index e3847c902b..ffbd16f1d7 100644 --- a/third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h +++ b/third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018 The Khronos Group Inc. +// Copyright (c) 2018-2024 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"), diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json index 7d6e8e5b31..918a9e547b 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2017 The Khronos Group Inc.", + "Copyright (c) 2017-2024 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\"),", diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json index 3d9f39e76c..ac8fc6dda6 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2014-2016 The Khronos Group Inc.", + "Copyright (c) 2014-2024 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\"),", diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json index b5a6637218..cfccc80b6d 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json @@ -1,12 +1,15 @@ { - "revision" : 4, + "revision" : 6, "instructions" : [ { "opname" : "Kernel", "opcode" : 1, "operands" : [ { "kind" : "IdRef", "name" : "Kernel" }, - { "kind" : "IdRef", "name" : "Name" } + { "kind" : "IdRef", "name" : "Name" }, + { "kind" : "IdRef", "name" : "NumArguments", "quantifier" : "?" }, + { "kind" : "IdRef", "name" : "Flags", "quantifier" : "?" }, + { "kind" : "IdRef", "name" : "Attributes", "quantifier" : "?" } ] }, { @@ -347,6 +350,77 @@ { "kind" : "IdRef", "name" : "Binding" }, { "kind" : "IdRef", "name" : "ArgInfo", "quantifier" : "?" } ] + }, + { + "opname" : "ConstantDataPointerPushConstant", + "opcode" : 36, + "operands" : [ + { "kind" : "IdRef", "name" : "Offset"}, + { "kind" : "IdRef", "name" : "Size"}, + { "kind" : "IdRef", "name" : "Data" } + ] + }, + { + "opname" : "ProgramScopeVariablePointerPushConstant", + "opcode" : 37, + "operands" : [ + { "kind" : "IdRef", "name" : "Offset"}, + { "kind" : "IdRef", "name" : "Size"}, + { "kind" : "IdRef", "name" : "Data" } + ] + }, + { + "opname" : "PrintfInfo", + "opcode" : 38, + "operands" : [ + { "kind" : "IdRef", "name" : "PrintfID" }, + { "kind" : "IdRef", "name" : "FormatString" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "ArgumentSizes"} + ] + }, + { + "opname" : "PrintfBufferStorageBuffer", + "opcode" : 39, + "operands" : [ + { "kind" : "IdRef", "name" : "DescriptorSet" }, + { "kind" : "IdRef", "name" : "Binding" }, + { "kind" : "IdRef", "name" : "BufferSize"} + ] + }, + { + "opname" : "PrintfBufferPointerPushConstant", + "opcode" : 40, + "operands" : [ + { "kind" : "IdRef", "name" : "Offset" }, + { "kind" : "IdRef", "name" : "Size"}, + { "kind" : "IdRef", "name" : "BufferSize"} + ] + }, + { + "opname" : "NormalizedSamplerMaskPushConstant", + "opcode" : 41, + "operands" : [ + { "kind" : "IdRef", "name" : "Kernel" }, + { "kind" : "IdRef", "name" : "Ordinal" }, + { "kind" : "IdRef", "name" : "Offset" }, + { "kind" : "IdRef", "name" : "Size" } + ] + } + ], + "operand_kinds" : [ + { + "category" : "BitEnum", + "kind" : "KernelPropertyFlags", + "enumerants" : [ + { + "enumerant" : "None", + "value" : "0x0" + }, + { + "enumerant" : "MayUsePrintf", + "value" : "0x1" + } + ] } ] } diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugbreak.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugbreak.grammar.json new file mode 100644 index 0000000000..ae28883381 --- /dev/null +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugbreak.grammar.json @@ -0,0 +1,9 @@ +{ + "revision" : 1, + "instructions" : [ + { + "opname" : "DebugBreak", + "opcode" : 1 + } + ] +} diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json index f3621b0b4f..1eb2859a10 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2018 The Khronos Group Inc.", + "Copyright (c) 2018-2024 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\"),", diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.vkspreflection.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.vkspreflection.grammar.json new file mode 100644 index 0000000000..0bc12d60df --- /dev/null +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.vkspreflection.grammar.json @@ -0,0 +1,138 @@ +{ + "revision" : 4, + "instructions" : [ + { + "opname" : "Configuration", + "opcode" : 1, + "operands" : [ + {"kind" : "IdRef", "name" : "enabledExtensionNames" }, + {"kind" : "IdRef", "name" : "specializationInfoDataSize" }, + {"kind" : "IdRef", "name" : "specializationInfoData" }, + {"kind" : "IdRef", "name" : "shaderName" }, + {"kind" : "IdRef", "name" : "EntryPoint" }, + {"kind" : "IdRef", "name" : "groupCountX" }, + {"kind" : "IdRef", "name" : "groupCountY" }, + {"kind" : "IdRef", "name" : "groupCountZ" }, + {"kind" : "IdRef", "name" : "dispatchId" } + ] + }, + { + "opname" : "StartCounter", + "opcode" : 2, + "operands" : [ + {"kind" : "IdRef", "name" : "name" } + ] + }, + { + "opname" : "StopCounter", + "opcode" : 3, + "operands" : [ + {"kind" : "IdRef", "name" : "counter" } + ] + }, + { + "opname" : "PushConstants", + "opcode" : 4, + "operands" : [ + { "kind" : "IdRef", "name" : "offset" }, + { "kind" : "IdRef", "name" : "size" }, + { "kind" : "IdRef", "name" : "pValues" }, + { "kind" : "IdRef", "name" : "stageFlags" } + ] + }, + { + "opname" : "SpecializationMapEntry", + "opcode" : 5, + "operands" : [ + {"kind" : "IdRef", "name" : "constantID" }, + {"kind" : "IdRef", "name" : "offset" }, + {"kind" : "IdRef", "name" : "size" } + ] + }, + { + "opname" : "DescriptorSetBuffer", + "opcode" : 6, + "operands" : [ + { "kind" : "IdRef", "name" : "ds" }, + { "kind" : "IdRef", "name" : "binding" }, + { "kind" : "IdRef", "name" : "type" }, + { "kind" : "IdRef", "name" : "flags" }, + { "kind" : "IdRef", "name" : "queueFamilyIndexCount" }, + { "kind" : "IdRef", "name" : "sharingMode" }, + { "kind" : "IdRef", "name" : "size" }, + { "kind" : "IdRef", "name" : "usage" }, + { "kind" : "IdRef", "name" : "range" }, + { "kind" : "IdRef", "name" : "offset" }, + { "kind" : "IdRef", "name" : "memorySize" }, + { "kind" : "IdRef", "name" : "memoryType" }, + { "kind" : "IdRef", "name" : "bindOffset" }, + { "kind" : "IdRef", "name" : "viewFlags" }, + { "kind" : "IdRef", "name" : "viewFormat" } + ] + }, + { + "opname" : "DescriptorSetImage", + "opcode" : 7, + "operands" : [ + { "kind" : "IdRef", "name" : "ds" }, + { "kind" : "IdRef", "name" : "binding" }, + { "kind" : "IdRef", "name" : "type" }, + { "kind" : "IdRef", "name" : "imageLayout"}, + { "kind" : "IdRef", "name" : "imageFlags"}, + { "kind" : "IdRef", "name" : "imageType"}, + { "kind" : "IdRef", "name" : "imageformat"}, + { "kind" : "IdRef", "name" : "width"}, + { "kind" : "IdRef", "name" : "height"}, + { "kind" : "IdRef", "name" : "depth"}, + { "kind" : "IdRef", "name" : "mipLevels"}, + { "kind" : "IdRef", "name" : "arrayLayers"}, + { "kind" : "IdRef", "name" : "samples"}, + { "kind" : "IdRef", "name" : "tiling"}, + { "kind" : "IdRef", "name" : "usage"}, + { "kind" : "IdRef", "name" : "sharingMode"}, + { "kind" : "IdRef", "name" : "queueFamilyIndexCount"}, + { "kind" : "IdRef", "name" : "initialLayout"}, + { "kind" : "IdRef", "name" : "aspectMask"}, + { "kind" : "IdRef", "name" : "baseMipLevel"}, + { "kind" : "IdRef", "name" : "levelCount"}, + { "kind" : "IdRef", "name" : "baseArrayLayer"}, + { "kind" : "IdRef", "name" : "layerCount"}, + { "kind" : "IdRef", "name" : "viewFlags"}, + { "kind" : "IdRef", "name" : "viewType"}, + { "kind" : "IdRef", "name" : "viewFormat"}, + { "kind" : "IdRef", "name" : "component_a"}, + { "kind" : "IdRef", "name" : "component_b"}, + { "kind" : "IdRef", "name" : "component_g"}, + { "kind" : "IdRef", "name" : "component_r"}, + { "kind" : "IdRef", "name" : "memorySize" }, + { "kind" : "IdRef", "name" : "memoryType" }, + { "kind" : "IdRef", "name" : "bindOffset"} + ] + }, + { + "opname" : "DescriptorSetSampler", + "opcode" : 8, + "operands" : [ + { "kind" : "IdRef", "name" : "ds" }, + { "kind" : "IdRef", "name" : "binding" }, + { "kind" : "IdRef", "name" : "type" }, + { "kind" : "IdRef", "name" : "flags"}, + { "kind" : "IdRef", "name" : "magFilter"}, + { "kind" : "IdRef", "name" : "minFilter"}, + { "kind" : "IdRef", "name" : "mipmapMode"}, + { "kind" : "IdRef", "name" : "addressModeU"}, + { "kind" : "IdRef", "name" : "addressModeV"}, + { "kind" : "IdRef", "name" : "addressModeW"}, + { "kind" : "IdRef", "name" : "mipLodBias"}, + { "kind" : "IdRef", "name" : "anisotropyEnable"}, + { "kind" : "IdRef", "name" : "maxAnisotropy"}, + { "kind" : "IdRef", "name" : "compareEnable"}, + { "kind" : "IdRef", "name" : "compareOp"}, + { "kind" : "IdRef", "name" : "minLod"}, + { "kind" : "IdRef", "name" : "maxLod"}, + { "kind" : "IdRef", "name" : "borderColor"}, + { "kind" : "IdRef", "name" : "unnormalizedCoordinates"} + ] + } + ] +} diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json index 699fe40369..53b001c530 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2018 The Khronos Group Inc.", + "Copyright (c) 2018-2024 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\"),", diff --git a/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json index 4fe45060bb..21b7876b0e 100644 --- a/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2014-2016 The Khronos Group Inc.", + "Copyright (c) 2014-2024 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\"),", diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.bf b/third_party/spirv-headers/include/spirv/unified1/spirv.bf index 15eafabe63..d8a433e124 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.bf +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.bf @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -66,6 +66,13 @@ namespace Spv HLSL = 5, CPP_for_OpenCL = 6, SYCL = 7, + HERO_C = 8, + NZSL = 9, + WGSL = 10, + Slang = 11, + Zig = 12, + Rust = 13, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ExecutionModel @@ -93,6 +100,7 @@ namespace Spv CallableNV = 5318, TaskEXT = 5364, MeshEXT = 5365, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum AddressingModel @@ -102,6 +110,7 @@ namespace Spv Physical64 = 2, PhysicalStorageBuffer64 = 5348, PhysicalStorageBuffer64EXT = 5348, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum MemoryModel @@ -111,6 +120,7 @@ namespace Spv OpenCL = 2, Vulkan = 3, VulkanKHR = 3, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ExecutionMode @@ -153,6 +163,9 @@ namespace Spv SubgroupsPerWorkgroupId = 37, LocalSizeId = 38, LocalSizeHintId = 39, + NonCoherentColorAttachmentReadEXT = 4169, + NonCoherentDepthAttachmentReadEXT = 4170, + NonCoherentStencilAttachmentReadEXT = 4171, SubgroupUniformControlFlowKHR = 4421, PostDepthCoverage = 4446, DenormPreserve = 4459, @@ -162,17 +175,28 @@ namespace Spv RoundingModeRTZ = 4463, EarlyAndLateFragmentTestsAMD = 5017, StencilRefReplacingEXT = 5027, + CoalescingAMDX = 5069, + IsApiEntryAMDX = 5070, + MaxNodeRecursionAMDX = 5071, + StaticNumWorkgroupsAMDX = 5072, + ShaderIndexAMDX = 5073, + MaxNumWorkgroupsAMDX = 5077, StencilRefUnchangedFrontAMD = 5079, StencilRefGreaterFrontAMD = 5080, StencilRefLessFrontAMD = 5081, StencilRefUnchangedBackAMD = 5082, StencilRefGreaterBackAMD = 5083, StencilRefLessBackAMD = 5084, + QuadDerivativesKHR = 5088, + RequireFullQuadsKHR = 5089, + SharesInputWithAMDX = 5102, OutputLinesEXT = 5269, OutputLinesNV = 5269, OutputPrimitivesEXT = 5270, OutputPrimitivesNV = 5270, + DerivativeGroupQuadsKHR = 5289, DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearKHR = 5290, DerivativeGroupLinearNV = 5290, OutputTrianglesEXT = 5298, OutputTrianglesNV = 5298, @@ -192,8 +216,15 @@ namespace Spv NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + MaximallyReconvergesKHR = 6023, + FPFastMathDefault = 6028, StreamingInterfaceINTEL = 6154, + RegisterMapInterfaceINTEL = 6160, NamedBarrierCountINTEL = 6417, + MaximumRegistersINTEL = 6461, + MaximumRegistersIdINTEL = 6462, + NamedMaximumRegistersINTEL = 6463, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum StorageClass @@ -211,6 +242,8 @@ namespace Spv AtomicCounter = 10, Image = 11, StorageBuffer = 12, + TileImageEXT = 4172, + NodePayloadAMDX = 5068, CallableDataKHR = 5328, CallableDataNV = 5328, IncomingCallableDataKHR = 5329, @@ -230,6 +263,7 @@ namespace Spv CodeSectionINTEL = 5605, DeviceOnlyINTEL = 5936, HostOnlyINTEL = 5937, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum Dim @@ -241,6 +275,8 @@ namespace Spv Rect = 4, Buffer = 5, SubpassData = 6, + TileImageDataEXT = 4173, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum SamplerAddressingMode @@ -250,12 +286,14 @@ namespace Spv Clamp = 2, Repeat = 3, RepeatMirrored = 4, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum SamplerFilterMode { Nearest = 0, Linear = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ImageFormat @@ -302,6 +340,7 @@ namespace Spv R8ui = 39, R64ui = 40, R64i = 41, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ImageChannelOrder @@ -326,6 +365,7 @@ namespace Spv sRGBA = 17, sBGRA = 18, ABGR = 19, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ImageChannelDataType @@ -347,6 +387,10 @@ namespace Spv Float = 14, UnormInt24 = 15, UnormInt101010_2 = 16, + UnsignedIntRaw10EXT = 19, + UnsignedIntRaw12EXT = 20, + UnormInt2_101010EXT = 21, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ImageOperandsShift @@ -371,6 +415,7 @@ namespace Spv ZeroExtend = 13, Nontemporal = 14, Offsets = 16, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum ImageOperandsMask @@ -405,8 +450,12 @@ namespace Spv NSZ = 2, AllowRecip = 3, Fast = 4, + AllowContract = 16, AllowContractFastINTEL = 16, + AllowReassoc = 17, AllowReassocINTEL = 17, + AllowTransform = 18, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FPFastMathModeMask @@ -417,8 +466,11 @@ namespace Spv NSZ = 0x00000004, AllowRecip = 0x00000008, Fast = 0x00000010, + AllowContract = 0x00010000, AllowContractFastINTEL = 0x00010000, + AllowReassoc = 0x00020000, AllowReassocINTEL = 0x00020000, + AllowTransform = 0x00040000, } [AllowDuplicates, CRepr] public enum FPRoundingMode @@ -427,6 +479,7 @@ namespace Spv RTZ = 1, RTP = 2, RTN = 3, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum LinkageType @@ -434,6 +487,7 @@ namespace Spv Export = 0, Import = 1, LinkOnceODR = 2, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum AccessQualifier @@ -441,6 +495,7 @@ namespace Spv ReadOnly = 0, WriteOnly = 1, ReadWrite = 2, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FunctionParameterAttribute @@ -454,6 +509,7 @@ namespace Spv NoWrite = 6, NoReadWrite = 7, RuntimeAlignedINTEL = 5940, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum Decoration @@ -507,7 +563,18 @@ namespace Spv MaxByteOffsetId = 47, NoSignedWrap = 4469, NoUnsignedWrap = 4470, + WeightTextureQCOM = 4487, + BlockMatchTextureQCOM = 4488, + BlockMatchSamplerQCOM = 4499, ExplicitInterpAMD = 4999, + NodeSharesPayloadLimitsWithAMDX = 5019, + NodeMaxPayloadsAMDX = 5020, + TrackFinishWritingAMDX = 5078, + PayloadNodeNameAMDX = 5091, + PayloadNodeBaseIndexAMDX = 5098, + PayloadNodeSparseArrayAMDX = 5099, + PayloadNodeArraySizeAMDX = 5100, + PayloadDispatchIndirectAMDX = 5105, OverrideCoverageNV = 5248, PassthroughNV = 5250, ViewportRelativeNV = 5252, @@ -557,6 +624,9 @@ namespace Spv MergeINTEL = 5834, BankBitsINTEL = 5835, ForcePow2DepthINTEL = 5836, + StridesizeINTEL = 5883, + WordsizeINTEL = 5884, + TrueDualPortINTEL = 5885, BurstCoalesceINTEL = 5899, CacheSizeINTEL = 5900, DontStaticallyCoalesceINTEL = 5901, @@ -575,6 +645,25 @@ namespace Spv SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, MediaBlockIOINTEL = 6140, + StallFreeINTEL = 6151, + FPMaxErrorDecorationINTEL = 6170, + LatencyControlLabelINTEL = 6172, + LatencyControlConstraintINTEL = 6173, + ConduitKernelArgumentINTEL = 6175, + RegisterMapKernelArgumentINTEL = 6176, + MMHostInterfaceAddressWidthINTEL = 6177, + MMHostInterfaceDataWidthINTEL = 6178, + MMHostInterfaceLatencyINTEL = 6179, + MMHostInterfaceReadWriteModeINTEL = 6180, + MMHostInterfaceMaxBurstINTEL = 6181, + MMHostInterfaceWaitRequestINTEL = 6182, + StableKernelArgumentINTEL = 6183, + HostAccessINTEL = 6188, + InitModeINTEL = 6190, + ImplementInRegisterMapINTEL = 6191, + CacheControlLoadINTEL = 6442, + CacheControlStoreINTEL = 6443, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum BuiltIn @@ -650,6 +739,8 @@ namespace Spv BaryCoordSmoothSampleAMD = 4997, BaryCoordPullModelAMD = 4998, FragStencilRefEXT = 5014, + RemainingRecursionLevelsAMDX = 5021, + ShaderIndexAMDX = 5073, ViewportMaskNV = 5253, SecondaryPositionNV = 5257, SecondaryViewportMaskNV = 5258, @@ -702,20 +793,34 @@ namespace Spv HitKindKHR = 5333, HitKindNV = 5333, CurrentRayTimeNV = 5334, + HitTriangleVertexPositionsKHR = 5335, + HitMicroTriangleVertexPositionsNV = 5337, + HitMicroTriangleVertexBarycentricsNV = 5344, IncomingRayFlagsKHR = 5351, IncomingRayFlagsNV = 5351, RayGeometryIndexKHR = 5352, + HitIsSphereNV = 5359, + HitIsLSSNV = 5360, + HitSpherePositionNV = 5361, WarpsPerSMNV = 5374, SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + HitLSSPositionsNV = 5396, + HitKindFrontFacingMicroTriangleNV = 5405, + HitKindBackFacingMicroTriangleNV = 5406, + HitSphereRadiusNV = 5420, + HitLSSRadiiNV = 5421, + ClusterIDNV = 5436, CullMaskKHR = 6021, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum SelectionControlShift { Flatten = 0, DontFlatten = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum SelectionControlMask @@ -746,6 +851,7 @@ namespace Spv NoFusionINTEL = 23, LoopCountINTEL = 24, MaxReinvocationDelayINTEL = 25, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum LoopControlMask @@ -778,7 +884,9 @@ namespace Spv DontInline = 1, Pure = 2, Const = 3, + OptNoneEXT = 16, OptNoneINTEL = 16, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FunctionControlMask @@ -788,6 +896,7 @@ namespace Spv DontInline = 0x00000002, Pure = 0x00000004, Const = 0x00000008, + OptNoneEXT = 0x00010000, OptNoneINTEL = 0x00010000, } @@ -810,6 +919,7 @@ namespace Spv MakeVisible = 14, MakeVisibleKHR = 14, Volatile = 15, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum MemorySemanticsMask @@ -847,6 +957,7 @@ namespace Spv NonPrivatePointerKHR = 5, AliasScopeINTELMask = 16, NoAliasINTELMask = 17, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum MemoryAccessMask @@ -875,6 +986,7 @@ namespace Spv QueueFamily = 5, QueueFamilyKHR = 5, ShaderCallKHR = 6, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum GroupOperation @@ -886,6 +998,7 @@ namespace Spv PartitionedReduceNV = 6, PartitionedInclusiveScanNV = 7, PartitionedExclusiveScanNV = 8, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum KernelEnqueueFlags @@ -893,11 +1006,13 @@ namespace Spv NoWait = 0, WaitKernel = 1, WaitWorkGroup = 2, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum KernelProfilingInfoShift { CmdExecTime = 0, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum KernelProfilingInfoMask @@ -979,6 +1094,10 @@ namespace Spv ShaderViewportIndex = 70, UniformDecoration = 71, CoreBuiltinsARM = 4165, + TileImageColorReadAccessEXT = 4166, + TileImageDepthReadAccessEXT = 4167, + TileImageStencilReadAccessEXT = 4168, + CooperativeMatrixLayoutsARM = 4201, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -1008,8 +1127,13 @@ namespace Spv RoundingModeRTZ = 4468, RayQueryProvisionalKHR = 4471, RayQueryKHR = 4472, + UntypedPointersKHR = 4473, RayTraversalPrimitiveCullingKHR = 4478, RayTracingKHR = 4479, + TextureSampleWeightedQCOM = 4484, + TextureBoxFilterQCOM = 4485, + TextureBlockMatchQCOM = 4486, + TextureBlockMatch2QCOM = 4498, Float16ImageAMD = 5008, ImageGatherBiasLodAMD = 5009, FragmentMaskAMD = 5010, @@ -1017,6 +1141,8 @@ namespace Spv ImageReadWriteLodAMD = 5015, Int64ImageEXT = 5016, ShaderClockKHR = 5055, + ShaderEnqueueAMDX = 5067, + QuadControlKHR = 5087, SampleMaskOverrideCoverageNV = 5249, GeometryShaderPassthroughNV = 5251, ShaderViewportIndexLayerEXT = 5254, @@ -1030,6 +1156,7 @@ namespace Spv MeshShadingEXT = 5283, FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsKHR = 5288, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, ShadingRateNV = 5291, @@ -1058,6 +1185,7 @@ namespace Spv UniformTexelBufferArrayNonUniformIndexingEXT = 5311, StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingPositionFetchKHR = 5336, RayTracingNV = 5340, RayTracingMotionBlurNV = 5341, VulkanMemoryModel = 5345, @@ -1066,6 +1194,7 @@ namespace Spv VulkanMemoryModelDeviceScopeKHR = 5346, PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearKHR = 5350, ComputeDerivativeGroupLinearNV = 5350, RayTracingProvisionalKHR = 5353, CooperativeMatrixNV = 5357, @@ -1075,9 +1204,25 @@ namespace Spv FragmentShaderPixelInterlockEXT = 5378, DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, + DisplacementMicromapNV = 5380, RayTracingOpacityMicromapEXT = 5381, ShaderInvocationReorderNV = 5383, BindlessTextureNV = 5390, + RayQueryPositionFetchKHR = 5391, + CooperativeVectorNV = 5394, + AtomicFloat16VectorNV = 5404, + RayTracingDisplacementMicromapNV = 5409, + RawAccessChainsNV = 5414, + RayTracingSpheresGeometryNV = 5418, + RayTracingLinearSweptSpheresGeometryNV = 5419, + CooperativeMatrixReductionsNV = 5430, + CooperativeMatrixConversionsNV = 5431, + CooperativeMatrixPerElementOperationsNV = 5432, + CooperativeMatrixTensorAddressingNV = 5433, + CooperativeMatrixBlockLoadsNV = 5434, + CooperativeVectorTrainingNV = 5435, + RayTracingClusterAccelerationStructureNV = 5437, + TensorAddressingNV = 5439, SubgroupShuffleINTEL = 5568, SubgroupBufferBlockIOINTEL = 5569, SubgroupImageBlockIOINTEL = 5570, @@ -1129,16 +1274,38 @@ namespace Spv DotProduct = 6019, DotProductKHR = 6019, RayCullMaskKHR = 6020, + CooperativeMatrixKHR = 6022, + ReplicatedCompositesEXT = 6024, BitInstructions = 6025, GroupNonUniformRotateKHR = 6026, + FloatControls2 = 6029, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, - LongConstantCompositeINTEL = 6089, + LongCompositesINTEL = 6089, + OptNoneEXT = 6094, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + BFloat16ConversionINTEL = 6115, SplitBarrierINTEL = 6141, + ArithmeticFenceEXT = 6144, + FPGAClusterAttributesV2INTEL = 6150, + FPGAKernelAttributesv2INTEL = 6161, + FPMaxErrorINTEL = 6169, + FPGALatencyControlINTEL = 6171, + FPGAArgumentInterfacesINTEL = 6174, + GlobalVariableHostAccessINTEL = 6187, + GlobalVariableFPGADecorationsINTEL = 6189, + SubgroupBufferPrefetchINTEL = 6220, + Subgroup2DBlockIOINTEL = 6228, + Subgroup2DBlockTransformINTEL = 6229, + Subgroup2DBlockTransposeINTEL = 6230, + SubgroupMatrixMultiplyAccumulateINTEL = 6236, GroupUniformArithmeticKHR = 6400, + MaskedGatherScatterINTEL = 6427, + CacheControlsINTEL = 6441, + RegisterLimitsINTEL = 6460, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum RayFlagsShift @@ -1151,9 +1318,11 @@ namespace Spv CullFrontFacingTrianglesKHR = 5, CullOpaqueKHR = 6, CullNoOpaqueKHR = 7, + SkipBuiltinPrimitivesNV = 8, SkipTrianglesKHR = 8, SkipAABBsKHR = 9, ForceOpacityMicromap2StateEXT = 10, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum RayFlagsMask @@ -1167,6 +1336,7 @@ namespace Spv CullFrontFacingTrianglesKHR = 0x00000020, CullOpaqueKHR = 0x00000040, CullNoOpaqueKHR = 0x00000080, + SkipBuiltinPrimitivesNV = 0x00000100, SkipTrianglesKHR = 0x00000100, SkipAABBsKHR = 0x00000200, ForceOpacityMicromap2StateEXT = 0x00000400, @@ -1176,6 +1346,7 @@ namespace Spv { RayQueryCandidateIntersectionKHR = 0, RayQueryCommittedIntersectionKHR = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum RayQueryCommittedIntersectionType @@ -1183,12 +1354,14 @@ namespace Spv RayQueryCommittedIntersectionNoneKHR = 0, RayQueryCommittedIntersectionTriangleKHR = 1, RayQueryCommittedIntersectionGeneratedKHR = 2, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum RayQueryCandidateIntersectionType { RayQueryCandidateIntersectionTriangleKHR = 0, RayQueryCandidateIntersectionAABBKHR = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FragmentShadingRateShift @@ -1197,6 +1370,7 @@ namespace Spv Vertical4Pixels = 1, Horizontal2Pixels = 2, Horizontal4Pixels = 3, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FragmentShadingRateMask @@ -1212,12 +1386,14 @@ namespace Spv { Preserve = 0, FlushToZero = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum FPOperationMode { IEEE = 0, ALT = 1, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum QuantizationModes @@ -1230,6 +1406,7 @@ namespace Spv RND_MIN_INF = 5, RND_CONV = 6, RND_CONV_ODD = 7, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum OverflowModes @@ -1238,12 +1415,218 @@ namespace Spv SAT = 1, SAT_ZERO = 2, SAT_SYM = 3, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum PackedVectorFormat { PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixOperandsShift + { + MatrixASignedComponentsKHR = 0, + MatrixBSignedComponentsKHR = 1, + MatrixCSignedComponentsKHR = 2, + MatrixResultSignedComponentsKHR = 3, + SaturatingAccumulationKHR = 4, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixOperandsMask + { + MaskNone = 0, + MatrixASignedComponentsKHR = 0x00000001, + MatrixBSignedComponentsKHR = 0x00000002, + MatrixCSignedComponentsKHR = 0x00000004, + MatrixResultSignedComponentsKHR = 0x00000008, + SaturatingAccumulationKHR = 0x00000010, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixLayout + { + RowMajorKHR = 0, + ColumnMajorKHR = 1, + RowBlockedInterleavedARM = 4202, + ColumnBlockedInterleavedARM = 4203, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixUse + { + MatrixAKHR = 0, + MatrixBKHR = 1, + MatrixAccumulatorKHR = 2, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixReduceShift + { + Row = 0, + Column = 1, + CooperativeMatrixReduce2x2 = 2, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeMatrixReduceMask + { + MaskNone = 0, + Row = 0x00000001, + Column = 0x00000002, + CooperativeMatrixReduce2x2 = 0x00000004, + } + + [AllowDuplicates, CRepr] public enum TensorClampMode + { + Undefined = 0, + Constant = 1, + ClampToEdge = 2, + Repeat = 3, + RepeatMirrored = 4, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum TensorAddressingOperandsShift + { + TensorView = 0, + DecodeFunc = 1, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum TensorAddressingOperandsMask + { + MaskNone = 0, + TensorView = 0x00000001, + DecodeFunc = 0x00000002, + } + + [AllowDuplicates, CRepr] public enum InitializationModeQualifier + { + InitOnDeviceReprogramINTEL = 0, + InitOnDeviceResetINTEL = 1, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum HostAccessQualifier + { + NoneINTEL = 0, + ReadINTEL = 1, + WriteINTEL = 2, + ReadWriteINTEL = 3, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum LoadCacheControl + { + UncachedINTEL = 0, + CachedINTEL = 1, + StreamingINTEL = 2, + InvalidateAfterReadINTEL = 3, + ConstCachedINTEL = 4, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum StoreCacheControl + { + UncachedINTEL = 0, + WriteThroughINTEL = 1, + WriteBackINTEL = 2, + StreamingINTEL = 3, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum NamedMaximumNumberOfRegisters + { + AutoINTEL = 0, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum MatrixMultiplyAccumulateOperandsShift + { + MatrixASignedComponentsINTEL = 0, + MatrixBSignedComponentsINTEL = 1, + MatrixCBFloat16INTEL = 2, + MatrixResultBFloat16INTEL = 3, + MatrixAPackedInt8INTEL = 4, + MatrixBPackedInt8INTEL = 5, + MatrixAPackedInt4INTEL = 6, + MatrixBPackedInt4INTEL = 7, + MatrixATF32INTEL = 8, + MatrixBTF32INTEL = 9, + MatrixAPackedFloat16INTEL = 10, + MatrixBPackedFloat16INTEL = 11, + MatrixAPackedBFloat16INTEL = 12, + MatrixBPackedBFloat16INTEL = 13, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum MatrixMultiplyAccumulateOperandsMask + { + MaskNone = 0, + MatrixASignedComponentsINTEL = 0x00000001, + MatrixBSignedComponentsINTEL = 0x00000002, + MatrixCBFloat16INTEL = 0x00000004, + MatrixResultBFloat16INTEL = 0x00000008, + MatrixAPackedInt8INTEL = 0x00000010, + MatrixBPackedInt8INTEL = 0x00000020, + MatrixAPackedInt4INTEL = 0x00000040, + MatrixBPackedInt4INTEL = 0x00000080, + MatrixATF32INTEL = 0x00000100, + MatrixBTF32INTEL = 0x00000200, + MatrixAPackedFloat16INTEL = 0x00000400, + MatrixBPackedFloat16INTEL = 0x00000800, + MatrixAPackedBFloat16INTEL = 0x00001000, + MatrixBPackedBFloat16INTEL = 0x00002000, + } + + [AllowDuplicates, CRepr] public enum RawAccessChainOperandsShift + { + RobustnessPerComponentNV = 0, + RobustnessPerElementNV = 1, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum RawAccessChainOperandsMask + { + MaskNone = 0, + RobustnessPerComponentNV = 0x00000001, + RobustnessPerElementNV = 0x00000002, + } + + [AllowDuplicates, CRepr] public enum FPEncoding + { + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum CooperativeVectorMatrixLayout + { + RowMajorNV = 0, + ColumnMajorNV = 1, + InferencingOptimalNV = 2, + TrainingOptimalNV = 3, + Max = 0x7fffffff, + } + + [AllowDuplicates, CRepr] public enum ComponentType + { + Float16NV = 0, + Float32NV = 1, + Float64NV = 2, + SignedInt8NV = 3, + SignedInt16NV = 4, + SignedInt32NV = 5, + SignedInt64NV = 6, + UnsignedInt8NV = 7, + UnsignedInt16NV = 8, + UnsignedInt32NV = 9, + UnsignedInt64NV = 10, + SignedInt8PackedNV = 1000491000, + UnsignedInt8PackedNV = 1000491001, + FloatE4M3NV = 1000491002, + FloatE5M2NV = 1000491003, + Max = 0x7fffffff, } [AllowDuplicates, CRepr] public enum Op @@ -1592,14 +1975,26 @@ namespace Spv OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1617,6 +2012,14 @@ namespace Spv OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1624,6 +2027,14 @@ namespace Spv OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1635,6 +2046,16 @@ namespace Spv OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1669,10 +2090,20 @@ namespace Spv OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1680,9 +2111,12 @@ namespace Spv OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1690,9 +2124,26 @@ namespace Spv OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1700,6 +2151,20 @@ namespace Spv OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1941,8 +2406,19 @@ namespace Spv OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1951,6 +2427,9 @@ namespace Spv OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, + Max = 0x7fffffff, } } } diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json b/third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json index b23d8a86c3..f839eaf821 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json @@ -1,6 +1,6 @@ { "copyright" : [ - "Copyright (c) 2014-2020 The Khronos Group Inc.", + "Copyright (c) 2014-2024 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\"),", @@ -27,7 +27,7 @@ "magic_number" : "0x07230203", "major_version" : 1, "minor_version" : 6, - "revision" : 1, + "revision" : 4, "instruction_printing_class" : [ { "tag" : "@exclude" @@ -137,7 +137,8 @@ { "opname" : "OpNop", "class" : "Miscellaneous", - "opcode" : 0 + "opcode" : 0, + "version" : "1.0" }, { "opname" : "OpUndef", @@ -146,7 +147,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version" : "1.0" }, { "opname" : "OpSourceContinued", @@ -154,7 +156,8 @@ "opcode" : 2, "operands" : [ { "kind" : "LiteralString", "name" : "'Continued Source'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSource", @@ -165,7 +168,8 @@ { "kind" : "LiteralInteger", "name" : "'Version'" }, { "kind" : "IdRef", "quantifier" : "?", "name" : "'File'" }, { "kind" : "LiteralString", "quantifier" : "?", "name" : "'Source'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSourceExtension", @@ -173,7 +177,8 @@ "opcode" : 4, "operands" : [ { "kind" : "LiteralString", "name" : "'Extension'" } - ] + ], + "version": "1.0" }, { "opname" : "OpName", @@ -182,7 +187,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Target'" }, { "kind" : "LiteralString", "name" : "'Name'" } - ] + ], + "version": "1.0" }, { "opname" : "OpMemberName", @@ -192,7 +198,8 @@ { "kind" : "IdRef", "name" : "'Type'" }, { "kind" : "LiteralInteger", "name" : "'Member'" }, { "kind" : "LiteralString", "name" : "'Name'" } - ] + ], + "version": "1.0" }, { "opname" : "OpString", @@ -201,7 +208,8 @@ "operands" : [ { "kind" : "IdResult" }, { "kind" : "LiteralString", "name" : "'String'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLine", @@ -211,7 +219,8 @@ { "kind" : "IdRef", "name" : "'File'" }, { "kind" : "LiteralInteger", "name" : "'Line'" }, { "kind" : "LiteralInteger", "name" : "'Column'" } - ] + ], + "version": "1.0" }, { "opname" : "OpExtension", @@ -219,7 +228,8 @@ "opcode" : 10, "operands" : [ { "kind" : "LiteralString", "name" : "'Name'" } - ] + ], + "version": "1.0" }, { "opname" : "OpExtInstImport", @@ -228,7 +238,8 @@ "operands" : [ { "kind" : "IdResult" }, { "kind" : "LiteralString", "name" : "'Name'" } - ] + ], + "version": "1.0" }, { "opname" : "OpExtInst", @@ -240,7 +251,8 @@ { "kind" : "IdRef", "name" : "'Set'" }, { "kind" : "LiteralExtInstInteger", "name" : "'Instruction'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Operand 1', +\n'Operand 2', +\n..." } - ] + ], + "version": "1.0" }, { "opname" : "OpMemoryModel", @@ -249,7 +261,8 @@ "operands" : [ { "kind" : "AddressingModel" }, { "kind" : "MemoryModel" } - ] + ], + "version": "1.0" }, { "opname" : "OpEntryPoint", @@ -260,7 +273,8 @@ { "kind" : "IdRef", "name" : "'Entry Point'" }, { "kind" : "LiteralString", "name" : "'Name'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Interface'" } - ] + ], + "version": "1.0" }, { "opname" : "OpExecutionMode", @@ -269,7 +283,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Entry Point'" }, { "kind" : "ExecutionMode", "name" : "'Mode'" } - ] + ], + "version": "1.0" }, { "opname" : "OpCapability", @@ -277,7 +292,8 @@ "opcode" : 17, "operands" : [ { "kind" : "Capability", "name" : "'Capability'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeVoid", @@ -285,7 +301,8 @@ "opcode" : 19, "operands" : [ { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeBool", @@ -293,7 +310,8 @@ "opcode" : 20, "operands" : [ { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeInt", @@ -303,7 +321,8 @@ { "kind" : "IdResult" }, { "kind" : "LiteralInteger", "name" : "'Width'" }, { "kind" : "LiteralInteger", "name" : "'Signedness'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeFloat", @@ -311,8 +330,10 @@ "opcode" : 22, "operands" : [ { "kind" : "IdResult" }, - { "kind" : "LiteralInteger", "name" : "'Width'" } - ] + { "kind" : "LiteralInteger", "name" : "'Width'" }, + { "kind" : "FPEncoding", "quantifier" : "?", "name" : "'Floating Point Encoding'" } + ], + "version": "1.0" }, { "opname" : "OpTypeVector", @@ -322,7 +343,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Component Type'" }, { "kind" : "LiteralInteger", "name" : "'Component Count'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeMatrix", @@ -333,7 +355,8 @@ { "kind" : "IdRef", "name" : "'Column Type'" }, { "kind" : "LiteralInteger", "name" : "'Column Count'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpTypeImage", @@ -349,7 +372,8 @@ { "kind" : "LiteralInteger", "name" : "'Sampled'" }, { "kind" : "ImageFormat" }, { "kind" : "AccessQualifier", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeSampler", @@ -357,7 +381,8 @@ "opcode" : 26, "operands" : [ { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeSampledImage", @@ -366,7 +391,8 @@ "operands" : [ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image Type'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeArray", @@ -376,7 +402,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Element Type'" }, { "kind" : "IdRef", "name" : "'Length'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeRuntimeArray", @@ -386,7 +413,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Element Type'" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpTypeStruct", @@ -395,7 +423,8 @@ "operands" : [ { "kind" : "IdResult" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Member 0 type', +\n'member 1 type', +\n..." } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeOpaque", @@ -405,7 +434,8 @@ { "kind" : "IdResult" }, { "kind" : "LiteralString", "name" : "The name of the opaque type." } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpTypePointer", @@ -415,7 +445,8 @@ { "kind" : "IdResult" }, { "kind" : "StorageClass" }, { "kind" : "IdRef", "name" : "'Type'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeFunction", @@ -425,7 +456,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Return Type'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Parameter 0 Type', +\n'Parameter 1 Type', +\n..." } - ] + ], + "version": "1.0" }, { "opname" : "OpTypeEvent", @@ -434,7 +466,8 @@ "operands" : [ { "kind" : "IdResult" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpTypeDeviceEvent", @@ -443,7 +476,8 @@ "operands" : [ { "kind" : "IdResult" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpTypeReserveId", @@ -452,7 +486,8 @@ "operands" : [ { "kind" : "IdResult" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpTypeQueue", @@ -461,7 +496,8 @@ "operands" : [ { "kind" : "IdResult" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpTypePipe", @@ -471,7 +507,8 @@ { "kind" : "IdResult" }, { "kind" : "AccessQualifier", "name" : "'Qualifier'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpTypeForwardPointer", @@ -484,7 +521,8 @@ "capabilities" : [ "Addresses", "PhysicalStorageBufferAddresses" - ] + ], + "version": "1.0" }, { "opname" : "OpConstantTrue", @@ -493,7 +531,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpConstantFalse", @@ -502,7 +541,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpConstant", @@ -512,7 +552,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "LiteralContextDependentNumber", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConstantComposite", @@ -522,7 +563,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConstantSampler", @@ -535,7 +577,8 @@ { "kind" : "LiteralInteger", "name" : "'Param'" }, { "kind" : "SamplerFilterMode" } ], - "capabilities" : [ "LiteralSampler" ] + "capabilities" : [ "LiteralSampler" ], + "version": "1.0" }, { "opname" : "OpConstantNull", @@ -544,7 +587,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpSpecConstantTrue", @@ -553,7 +597,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpSpecConstantFalse", @@ -562,7 +607,8 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpSpecConstant", @@ -572,7 +618,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "LiteralContextDependentNumber", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSpecConstantComposite", @@ -582,7 +629,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSpecConstantOp", @@ -592,7 +640,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "LiteralSpecConstantOpInteger", "name" : "'Opcode'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFunction", @@ -603,7 +652,8 @@ { "kind" : "IdResult" }, { "kind" : "FunctionControl" }, { "kind" : "IdRef", "name" : "'Function Type'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFunctionParameter", @@ -612,12 +662,14 @@ "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpFunctionEnd", "class" : "Function", - "opcode" : 56 + "opcode" : 56, + "version" : "1.0" }, { "opname" : "OpFunctionCall", @@ -628,7 +680,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Function'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Argument 0', +\n'Argument 1', +\n..." } - ] + ], + "version": "1.0" }, { "opname" : "OpVariable", @@ -639,7 +692,8 @@ { "kind" : "IdResult" }, { "kind" : "StorageClass" }, { "kind" : "IdRef", "quantifier" : "?", "name" : "'Initializer'" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageTexelPointer", @@ -651,7 +705,8 @@ { "kind" : "IdRef", "name" : "'Image'" }, { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "IdRef", "name" : "'Sample'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLoad", @@ -662,7 +717,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "MemoryAccess", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpStore", @@ -672,7 +728,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "IdRef", "name" : "'Object'" }, { "kind" : "MemoryAccess", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpCopyMemory", @@ -683,7 +740,8 @@ { "kind" : "IdRef", "name" : "'Source'" }, { "kind" : "MemoryAccess", "quantifier" : "?" }, { "kind" : "MemoryAccess", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpCopyMemorySized", @@ -696,7 +754,11 @@ { "kind" : "MemoryAccess", "quantifier" : "?" }, { "kind" : "MemoryAccess", "quantifier" : "?" } ], - "capabilities" : [ "Addresses" ] + "capabilities" : [ + "Addresses", + "UntypedPointersKHR" + ], + "version": "1.0" }, { "opname" : "OpAccessChain", @@ -707,7 +769,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } - ] + ], + "version": "1.0" }, { "opname" : "OpInBoundsAccessChain", @@ -718,7 +781,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } - ] + ], + "version": "1.0" }, { "opname" : "OpPtrAccessChain", @@ -736,7 +800,8 @@ "VariablePointers", "VariablePointersStorageBuffer", "PhysicalStorageBufferAddresses" - ] + ], + "version": "1.0" }, { "opname" : "OpArrayLength", @@ -748,7 +813,8 @@ { "kind" : "IdRef", "name" : "'Structure'" }, { "kind" : "LiteralInteger", "name" : "'Array member'" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpGenericPtrMemSemantics", @@ -759,7 +825,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Pointer'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpInBoundsPtrAccessChain", @@ -772,7 +839,8 @@ { "kind" : "IdRef", "name" : "'Element'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } ], - "capabilities" : [ "Addresses" ] + "capabilities" : [ "Addresses" ], + "version": "1.0" }, { "opname" : "OpDecorate", @@ -781,7 +849,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Target'" }, { "kind" : "Decoration" } - ] + ], + "version": "1.0" }, { "opname" : "OpMemberDecorate", @@ -791,7 +860,8 @@ { "kind" : "IdRef", "name" : "'Structure Type'" }, { "kind" : "LiteralInteger", "name" : "'Member'" }, { "kind" : "Decoration" } - ] + ], + "version": "1.0" }, { "opname" : "OpDecorationGroup", @@ -799,7 +869,8 @@ "opcode" : 73, "operands" : [ { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpGroupDecorate", @@ -808,7 +879,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Decoration Group'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Targets'" } - ] + ], + "version": "1.0" }, { "opname" : "OpGroupMemberDecorate", @@ -817,7 +889,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Decoration Group'" }, { "kind" : "PairIdRefLiteralInteger", "quantifier" : "*", "name" : "'Targets'" } - ] + ], + "version": "1.0" }, { "opname" : "OpVectorExtractDynamic", @@ -828,7 +901,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Vector'" }, { "kind" : "IdRef", "name" : "'Index'" } - ] + ], + "version": "1.0" }, { "opname" : "OpVectorInsertDynamic", @@ -840,7 +914,8 @@ { "kind" : "IdRef", "name" : "'Vector'" }, { "kind" : "IdRef", "name" : "'Component'" }, { "kind" : "IdRef", "name" : "'Index'" } - ] + ], + "version": "1.0" }, { "opname" : "OpVectorShuffle", @@ -852,7 +927,8 @@ { "kind" : "IdRef", "name" : "'Vector 1'" }, { "kind" : "IdRef", "name" : "'Vector 2'" }, { "kind" : "LiteralInteger", "quantifier" : "*", "name" : "'Components'" } - ] + ], + "version": "1.0" }, { "opname" : "OpCompositeConstruct", @@ -862,7 +938,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } - ] + ], + "version": "1.0" }, { "opname" : "OpCompositeExtract", @@ -873,7 +950,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Composite'" }, { "kind" : "LiteralInteger", "quantifier" : "*", "name" : "'Indexes'" } - ] + ], + "version": "1.0" }, { "opname" : "OpCompositeInsert", @@ -885,7 +963,8 @@ { "kind" : "IdRef", "name" : "'Object'" }, { "kind" : "IdRef", "name" : "'Composite'" }, { "kind" : "LiteralInteger", "quantifier" : "*", "name" : "'Indexes'" } - ] + ], + "version": "1.0" }, { "opname" : "OpCopyObject", @@ -895,7 +974,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpTranspose", @@ -906,7 +986,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Matrix'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpSampledImage", @@ -917,7 +998,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" }, { "kind" : "IdRef", "name" : "'Sampler'" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageSampleImplicitLod", @@ -930,7 +1012,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleExplicitLod", @@ -942,7 +1025,8 @@ { "kind" : "IdRef", "name" : "'Sampled Image'" }, { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageSampleDrefImplicitLod", @@ -956,7 +1040,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleDrefExplicitLod", @@ -970,7 +1055,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleProjImplicitLod", @@ -983,7 +1069,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleProjExplicitLod", @@ -996,7 +1083,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleProjDrefImplicitLod", @@ -1010,7 +1098,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageSampleProjDrefExplicitLod", @@ -1024,7 +1113,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageFetch", @@ -1036,7 +1126,8 @@ { "kind" : "IdRef", "name" : "'Image'" }, { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageGather", @@ -1050,7 +1141,8 @@ { "kind" : "IdRef", "name" : "'Component'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageDrefGather", @@ -1064,7 +1156,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpImageRead", @@ -1076,7 +1169,8 @@ { "kind" : "IdRef", "name" : "'Image'" }, { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageWrite", @@ -1087,7 +1181,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "IdRef", "name" : "'Texel'" }, { "kind" : "ImageOperands", "quantifier" : "?" } - ] + ], + "version": "1.0" }, { "opname" : "OpImage", @@ -1097,7 +1192,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Sampled Image'" } - ] + ], + "version": "1.0" }, { "opname" : "OpImageQueryFormat", @@ -1108,7 +1204,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpImageQueryOrder", @@ -1119,7 +1216,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpImageQuerySizeLod", @@ -1131,7 +1229,8 @@ { "kind" : "IdRef", "name" : "'Image'" }, { "kind" : "IdRef", "name" : "'Level of Detail'" } ], - "capabilities" : [ "Kernel", "ImageQuery" ] + "capabilities" : [ "Kernel", "ImageQuery" ], + "version": "1.0" }, { "opname" : "OpImageQuerySize", @@ -1142,7 +1241,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" } ], - "capabilities" : [ "Kernel", "ImageQuery" ] + "capabilities" : [ "Kernel", "ImageQuery" ], + "version": "1.0" }, { "opname" : "OpImageQueryLod", @@ -1154,7 +1254,8 @@ { "kind" : "IdRef", "name" : "'Sampled Image'" }, { "kind" : "IdRef", "name" : "'Coordinate'" } ], - "capabilities" : [ "ImageQuery" ] + "capabilities" : [ "ImageQuery" ], + "version": "1.0" }, { "opname" : "OpImageQueryLevels", @@ -1165,7 +1266,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" } ], - "capabilities" : [ "Kernel", "ImageQuery" ] + "capabilities" : [ "Kernel", "ImageQuery" ], + "version": "1.0" }, { "opname" : "OpImageQuerySamples", @@ -1176,7 +1278,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Image'" } ], - "capabilities" : [ "Kernel", "ImageQuery" ] + "capabilities" : [ "Kernel", "ImageQuery" ], + "version": "1.0" }, { "opname" : "OpConvertFToU", @@ -1186,7 +1289,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Float Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConvertFToS", @@ -1196,7 +1300,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Float Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConvertSToF", @@ -1206,7 +1311,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Signed Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConvertUToF", @@ -1216,7 +1322,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Unsigned Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUConvert", @@ -1226,7 +1333,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Unsigned Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSConvert", @@ -1236,7 +1344,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Signed Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFConvert", @@ -1246,7 +1355,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Float Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpQuantizeToF16", @@ -1256,7 +1366,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpConvertPtrToU", @@ -1270,7 +1381,8 @@ "capabilities" : [ "Addresses", "PhysicalStorageBufferAddresses" - ] + ], + "version": "1.0" }, { "opname" : "OpSatConvertSToU", @@ -1281,7 +1393,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Signed Value'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpSatConvertUToS", @@ -1292,7 +1405,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Unsigned Value'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpConvertUToPtr", @@ -1306,7 +1420,8 @@ "capabilities" : [ "Addresses", "PhysicalStorageBufferAddresses" - ] + ], + "version": "1.0" }, { "opname" : "OpPtrCastToGeneric", @@ -1317,7 +1432,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Pointer'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpGenericCastToPtr", @@ -1328,7 +1444,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Pointer'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpGenericCastToPtrExplicit", @@ -1340,7 +1457,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "StorageClass", "name" : "'Storage'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpBitcast", @@ -1350,7 +1468,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSNegate", @@ -1360,7 +1479,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFNegate", @@ -1370,7 +1490,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIAdd", @@ -1381,7 +1502,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFAdd", @@ -1392,7 +1514,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpISub", @@ -1403,7 +1526,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFSub", @@ -1414,7 +1538,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIMul", @@ -1425,7 +1550,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFMul", @@ -1436,7 +1562,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUDiv", @@ -1447,7 +1574,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSDiv", @@ -1458,7 +1586,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFDiv", @@ -1469,7 +1598,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUMod", @@ -1480,7 +1610,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSRem", @@ -1491,7 +1622,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSMod", @@ -1502,7 +1634,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFRem", @@ -1513,7 +1646,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFMod", @@ -1524,7 +1658,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpVectorTimesScalar", @@ -1535,7 +1670,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Vector'" }, { "kind" : "IdRef", "name" : "'Scalar'" } - ] + ], + "version": "1.0" }, { "opname" : "OpMatrixTimesScalar", @@ -1547,7 +1683,8 @@ { "kind" : "IdRef", "name" : "'Matrix'" }, { "kind" : "IdRef", "name" : "'Scalar'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpVectorTimesMatrix", @@ -1559,7 +1696,8 @@ { "kind" : "IdRef", "name" : "'Vector'" }, { "kind" : "IdRef", "name" : "'Matrix'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpMatrixTimesVector", @@ -1571,7 +1709,8 @@ { "kind" : "IdRef", "name" : "'Matrix'" }, { "kind" : "IdRef", "name" : "'Vector'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpMatrixTimesMatrix", @@ -1583,7 +1722,8 @@ { "kind" : "IdRef", "name" : "'LeftMatrix'" }, { "kind" : "IdRef", "name" : "'RightMatrix'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpOuterProduct", @@ -1595,7 +1735,8 @@ { "kind" : "IdRef", "name" : "'Vector 1'" }, { "kind" : "IdRef", "name" : "'Vector 2'" } ], - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "opname" : "OpDot", @@ -1606,7 +1747,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Vector 1'" }, { "kind" : "IdRef", "name" : "'Vector 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIAddCarry", @@ -1617,7 +1759,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpISubBorrow", @@ -1628,7 +1771,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUMulExtended", @@ -1639,7 +1783,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSMulExtended", @@ -1650,7 +1795,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAny", @@ -1660,7 +1806,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Vector'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAll", @@ -1670,7 +1817,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Vector'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIsNan", @@ -1680,7 +1828,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'x'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIsInf", @@ -1690,7 +1839,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'x'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIsFinite", @@ -1701,7 +1851,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'x'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpIsNormal", @@ -1712,7 +1863,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'x'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpSignBitSet", @@ -1723,7 +1875,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'x'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpLessOrGreater", @@ -1736,6 +1889,7 @@ { "kind" : "IdRef", "name" : "'y'" } ], "capabilities" : [ "Kernel" ], + "version" : "1.0", "lastVersion" : "1.5" }, { @@ -1748,7 +1902,8 @@ { "kind" : "IdRef", "name" : "'x'" }, { "kind" : "IdRef", "name" : "'y'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpUnordered", @@ -1760,7 +1915,8 @@ { "kind" : "IdRef", "name" : "'x'" }, { "kind" : "IdRef", "name" : "'y'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpLogicalEqual", @@ -1771,7 +1927,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLogicalNotEqual", @@ -1782,7 +1939,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLogicalOr", @@ -1793,7 +1951,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLogicalAnd", @@ -1804,7 +1963,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version" : "1.0" }, { "opname" : "OpLogicalNot", @@ -1814,7 +1974,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSelect", @@ -1826,7 +1987,8 @@ { "kind" : "IdRef", "name" : "'Condition'" }, { "kind" : "IdRef", "name" : "'Object 1'" }, { "kind" : "IdRef", "name" : "'Object 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpIEqual", @@ -1837,7 +1999,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpINotEqual", @@ -1848,7 +2011,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUGreaterThan", @@ -1859,7 +2023,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSGreaterThan", @@ -1870,7 +2035,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUGreaterThanEqual", @@ -1881,7 +2047,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSGreaterThanEqual", @@ -1892,7 +2059,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpULessThan", @@ -1903,7 +2071,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSLessThan", @@ -1914,7 +2083,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpULessThanEqual", @@ -1925,7 +2095,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSLessThanEqual", @@ -1936,7 +2107,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdEqual", @@ -1947,7 +2119,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordEqual", @@ -1958,7 +2131,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdNotEqual", @@ -1969,7 +2143,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordNotEqual", @@ -1980,7 +2155,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdLessThan", @@ -1991,7 +2167,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordLessThan", @@ -2002,7 +2179,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdGreaterThan", @@ -2013,7 +2191,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordGreaterThan", @@ -2024,7 +2203,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdLessThanEqual", @@ -2035,7 +2215,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordLessThanEqual", @@ -2046,7 +2227,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFOrdGreaterThanEqual", @@ -2057,7 +2239,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpFUnordGreaterThanEqual", @@ -2068,7 +2251,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpShiftRightLogical", @@ -2079,7 +2263,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" }, { "kind" : "IdRef", "name" : "'Shift'" } - ] + ], + "version": "1.0" }, { "opname" : "OpShiftRightArithmetic", @@ -2090,7 +2275,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" }, { "kind" : "IdRef", "name" : "'Shift'" } - ] + ], + "version": "1.0" }, { "opname" : "OpShiftLeftLogical", @@ -2101,7 +2287,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" }, { "kind" : "IdRef", "name" : "'Shift'" } - ] + ], + "version": "1.0" }, { "opname" : "OpBitwiseOr", @@ -2112,7 +2299,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpBitwiseXor", @@ -2123,7 +2311,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpBitwiseAnd", @@ -2134,7 +2323,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand 1'" }, { "kind" : "IdRef", "name" : "'Operand 2'" } - ] + ], + "version": "1.0" }, { "opname" : "OpNot", @@ -2144,7 +2334,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Operand'" } - ] + ], + "version": "1.0" }, { "opname" : "OpBitFieldInsert", @@ -2158,7 +2349,8 @@ { "kind" : "IdRef", "name" : "'Offset'" }, { "kind" : "IdRef", "name" : "'Count'" } ], - "capabilities" : [ "Shader", "BitInstructions" ] + "capabilities" : [ "Shader", "BitInstructions" ], + "version": "1.0" }, { "opname" : "OpBitFieldSExtract", @@ -2171,7 +2363,8 @@ { "kind" : "IdRef", "name" : "'Offset'" }, { "kind" : "IdRef", "name" : "'Count'" } ], - "capabilities" : [ "Shader", "BitInstructions" ] + "capabilities" : [ "Shader", "BitInstructions" ], + "version": "1.0" }, { "opname" : "OpBitFieldUExtract", @@ -2184,7 +2377,8 @@ { "kind" : "IdRef", "name" : "'Offset'" }, { "kind" : "IdRef", "name" : "'Count'" } ], - "capabilities" : [ "Shader", "BitInstructions" ] + "capabilities" : [ "Shader", "BitInstructions" ], + "version": "1.0" }, { "opname" : "OpBitReverse", @@ -2195,7 +2389,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" } ], - "capabilities" : [ "Shader", "BitInstructions" ] + "capabilities" : [ "Shader", "BitInstructions" ], + "version": "1.0" }, { "opname" : "OpBitCount", @@ -2205,7 +2400,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Base'" } - ] + ], + "version": "1.0" }, { "opname" : "OpDPdx", @@ -2216,7 +2412,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpDPdy", @@ -2227,7 +2424,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpFwidth", @@ -2238,7 +2436,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpDPdxFine", @@ -2249,7 +2448,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpDPdyFine", @@ -2260,7 +2460,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpFwidthFine", @@ -2271,7 +2472,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpDPdxCoarse", @@ -2282,7 +2484,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpDPdyCoarse", @@ -2293,7 +2496,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpFwidthCoarse", @@ -2304,19 +2508,22 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'P'" } ], - "capabilities" : [ "DerivativeControl" ] + "capabilities" : [ "DerivativeControl" ], + "version": "1.0" }, { "opname" : "OpEmitVertex", "class" : "Primitive", "opcode" : 218, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "opname" : "OpEndPrimitive", "class" : "Primitive", "opcode" : 219, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "opname" : "OpEmitStreamVertex", @@ -2325,7 +2532,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Stream'" } ], - "capabilities" : [ "GeometryStreams" ] + "capabilities" : [ "GeometryStreams" ], + "version": "1.0" }, { "opname" : "OpEndStreamPrimitive", @@ -2334,7 +2542,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Stream'" } ], - "capabilities" : [ "GeometryStreams" ] + "capabilities" : [ "GeometryStreams" ], + "version": "1.0" }, { "opname" : "OpControlBarrier", @@ -2344,7 +2553,8 @@ { "kind" : "IdScope", "name" : "'Execution'" }, { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } - ] + ], + "version": "1.0" }, { "opname" : "OpMemoryBarrier", @@ -2353,7 +2563,8 @@ "operands" : [ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicLoad", @@ -2365,7 +2576,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicStore", @@ -2376,7 +2588,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicExchange", @@ -2389,7 +2602,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicCompareExchange", @@ -2404,7 +2618,8 @@ { "kind" : "IdMemorySemantics", "name" : "'Unequal'" }, { "kind" : "IdRef", "name" : "'Value'" }, { "kind" : "IdRef", "name" : "'Comparator'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicCompareExchangeWeak", @@ -2421,6 +2636,7 @@ { "kind" : "IdRef", "name" : "'Comparator'" } ], "capabilities" : [ "Kernel" ], + "version" : "1.0", "lastVersion" : "1.3" }, { @@ -2433,7 +2649,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicIDecrement", @@ -2445,7 +2662,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicIAdd", @@ -2458,7 +2676,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicISub", @@ -2471,7 +2690,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicSMin", @@ -2484,7 +2704,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicUMin", @@ -2497,7 +2718,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicSMax", @@ -2510,7 +2732,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicUMax", @@ -2523,7 +2746,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicAnd", @@ -2536,7 +2760,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicOr", @@ -2549,7 +2774,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpAtomicXor", @@ -2562,7 +2788,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpPhi", @@ -2572,7 +2799,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "PairIdRefIdRef", "quantifier" : "*", "name" : "'Variable, Parent, ...'" } - ] + ], + "version": "1.0" }, { "opname" : "OpLoopMerge", @@ -2582,7 +2810,8 @@ { "kind" : "IdRef", "name" : "'Merge Block'" }, { "kind" : "IdRef", "name" : "'Continue Target'" }, { "kind" : "LoopControl" } - ] + ], + "version": "1.0" }, { "opname" : "OpSelectionMerge", @@ -2591,7 +2820,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Merge Block'" }, { "kind" : "SelectionControl" } - ] + ], + "version": "1.0" }, { "opname" : "OpLabel", @@ -2599,7 +2829,8 @@ "opcode" : 248, "operands" : [ { "kind" : "IdResult" } - ] + ], + "version": "1.0" }, { "opname" : "OpBranch", @@ -2607,7 +2838,8 @@ "opcode" : 249, "operands" : [ { "kind" : "IdRef", "name" : "'Target Label'" } - ] + ], + "version": "1.0" }, { "opname" : "OpBranchConditional", @@ -2618,7 +2850,8 @@ { "kind" : "IdRef", "name" : "'True Label'" }, { "kind" : "IdRef", "name" : "'False Label'" }, { "kind" : "LiteralInteger", "quantifier" : "*", "name" : "'Branch weights'" } - ] + ], + "version": "1.0" }, { "opname" : "OpSwitch", @@ -2628,18 +2861,21 @@ { "kind" : "IdRef", "name" : "'Selector'" }, { "kind" : "IdRef", "name" : "'Default'" }, { "kind" : "PairLiteralIntegerIdRef", "quantifier" : "*", "name" : "'Target'" } - ] + ], + "version": "1.0" }, { "opname" : "OpKill", "class" : "Control-Flow", "opcode" : 252, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "opname" : "OpReturn", "class" : "Control-Flow", - "opcode" : 253 + "opcode" : 253, + "version" : "1.0" }, { "opname" : "OpReturnValue", @@ -2647,12 +2883,14 @@ "opcode" : 254, "operands" : [ { "kind" : "IdRef", "name" : "'Value'" } - ] + ], + "version": "1.0" }, { "opname" : "OpUnreachable", "class" : "Control-Flow", - "opcode" : 255 + "opcode" : 255, + "version" : "1.0" }, { "opname" : "OpLifetimeStart", @@ -2662,7 +2900,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "LiteralInteger", "name" : "'Size'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpLifetimeStop", @@ -2672,7 +2911,8 @@ { "kind" : "IdRef", "name" : "'Pointer'" }, { "kind" : "LiteralInteger", "name" : "'Size'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpGroupAsyncCopy", @@ -2688,7 +2928,8 @@ { "kind" : "IdRef", "name" : "'Stride'" }, { "kind" : "IdRef", "name" : "'Event'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpGroupWaitEvents", @@ -2699,7 +2940,8 @@ { "kind" : "IdRef", "name" : "'Num Events'" }, { "kind" : "IdRef", "name" : "'Events List'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpGroupAll", @@ -2711,7 +2953,8 @@ { "kind" : "IdScope", "name" : "'Execution'" }, { "kind" : "IdRef", "name" : "'Predicate'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupAny", @@ -2723,7 +2966,8 @@ { "kind" : "IdScope", "name" : "'Execution'" }, { "kind" : "IdRef", "name" : "'Predicate'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupBroadcast", @@ -2736,7 +2980,8 @@ { "kind" : "IdRef", "name" : "'Value'" }, { "kind" : "IdRef", "name" : "'LocalId'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupIAdd", @@ -2749,7 +2994,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupFAdd", @@ -2762,7 +3008,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupFMin", @@ -2775,7 +3022,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupUMin", @@ -2788,7 +3036,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupSMin", @@ -2801,7 +3050,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupFMax", @@ -2814,7 +3064,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupUMax", @@ -2827,7 +3078,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpGroupSMax", @@ -2840,7 +3092,8 @@ { "kind" : "GroupOperation", "name" : "'Operation'" }, { "kind" : "IdRef", "name" : "'X'" } ], - "capabilities" : [ "Groups" ] + "capabilities" : [ "Groups" ], + "version": "1.0" }, { "opname" : "OpReadPipe", @@ -2854,7 +3107,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpWritePipe", @@ -2868,7 +3122,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpReservedReadPipe", @@ -2884,7 +3139,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpReservedWritePipe", @@ -2900,7 +3156,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpReserveReadPipePackets", @@ -2914,7 +3171,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpReserveWritePipePackets", @@ -2928,7 +3186,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpCommitReadPipe", @@ -2940,7 +3199,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpCommitWritePipe", @@ -2952,7 +3212,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpIsValidReserveId", @@ -2963,7 +3224,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Reserve Id'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGetNumPipePackets", @@ -2976,7 +3238,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGetMaxPipePackets", @@ -2989,7 +3252,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGroupReserveReadPipePackets", @@ -3004,7 +3268,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGroupReserveWritePipePackets", @@ -3019,7 +3284,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGroupCommitReadPipe", @@ -3032,7 +3298,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpGroupCommitWritePipe", @@ -3045,7 +3312,8 @@ { "kind" : "IdRef", "name" : "'Packet Size'" }, { "kind" : "IdRef", "name" : "'Packet Alignment'" } ], - "capabilities" : [ "Pipes" ] + "capabilities" : [ "Pipes" ], + "version": "1.0" }, { "opname" : "OpEnqueueMarker", @@ -3059,7 +3327,8 @@ { "kind" : "IdRef", "name" : "'Wait Events'" }, { "kind" : "IdRef", "name" : "'Ret Event'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpEnqueueKernel", @@ -3080,7 +3349,8 @@ { "kind" : "IdRef", "name" : "'Param Align'" }, { "kind" : "IdRef", "quantifier" : "*", "name" : "'Local Size'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpGetKernelNDrangeSubGroupCount", @@ -3095,7 +3365,8 @@ { "kind" : "IdRef", "name" : "'Param Size'" }, { "kind" : "IdRef", "name" : "'Param Align'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpGetKernelNDrangeMaxSubGroupSize", @@ -3110,7 +3381,8 @@ { "kind" : "IdRef", "name" : "'Param Size'" }, { "kind" : "IdRef", "name" : "'Param Align'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpGetKernelWorkGroupSize", @@ -3124,7 +3396,8 @@ { "kind" : "IdRef", "name" : "'Param Size'" }, { "kind" : "IdRef", "name" : "'Param Align'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpGetKernelPreferredWorkGroupSizeMultiple", @@ -3138,7 +3411,8 @@ { "kind" : "IdRef", "name" : "'Param Size'" }, { "kind" : "IdRef", "name" : "'Param Align'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpRetainEvent", @@ -3147,7 +3421,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Event'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpReleaseEvent", @@ -3156,7 +3431,8 @@ "operands" : [ { "kind" : "IdRef", "name" : "'Event'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpCreateUserEvent", @@ -3166,7 +3442,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpIsValidEvent", @@ -3177,7 +3454,8 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Event'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpSetUserEventStatus", @@ -3187,7 +3465,8 @@ { "kind" : "IdRef", "name" : "'Event'" }, { "kind" : "IdRef", "name" : "'Status'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpCaptureEventProfilingInfo", @@ -3198,7 +3477,8 @@ { "kind" : "IdRef", "name" : "'Profiling Info'" }, { "kind" : "IdRef", "name" : "'Value'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpGetDefaultQueue", @@ -3208,7 +3488,8 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpBuildNDRange", @@ -3221,7 +3502,8 @@ { "kind" : "IdRef", "name" : "'LocalWorkSize'" }, { "kind" : "IdRef", "name" : "'GlobalWorkOffset'" } ], - "capabilities" : [ "DeviceEnqueue" ] + "capabilities" : [ "DeviceEnqueue" ], + "version": "1.0" }, { "opname" : "OpImageSparseSampleImplicitLod", @@ -3234,7 +3516,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseSampleExplicitLod", @@ -3247,7 +3530,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseSampleDrefImplicitLod", @@ -3261,7 +3545,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseSampleDrefExplicitLod", @@ -3275,7 +3560,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseSampleProjImplicitLod", @@ -3346,7 +3632,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseGather", @@ -3360,7 +3647,8 @@ { "kind" : "IdRef", "name" : "'Component'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseDrefGather", @@ -3374,7 +3662,8 @@ { "kind" : "IdRef", "name" : "'D~ref~'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpImageSparseTexelsResident", @@ -3385,12 +3674,14 @@ { "kind" : "IdResult" }, { "kind" : "IdRef", "name" : "'Resident Code'" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpNoLine", "class" : "Debug", - "opcode" : 317 + "opcode" : 317, + "version" : "1.0" }, { "opname" : "OpAtomicFlagTestAndSet", @@ -3403,7 +3694,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpAtomicFlagClear", @@ -3414,7 +3706,8 @@ { "kind" : "IdScope", "name" : "'Memory'" }, { "kind" : "IdMemorySemantics", "name" : "'Semantics'" } ], - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "opname" : "OpImageSparseRead", @@ -3427,7 +3720,8 @@ { "kind" : "IdRef", "name" : "'Coordinate'" }, { "kind" : "ImageOperands", "quantifier" : "?" } ], - "capabilities" : [ "SparseResidency" ] + "capabilities" : [ "SparseResidency" ], + "version": "1.0" }, { "opname" : "OpSizeOf", @@ -4102,6 +4396,43 @@ "capabilities" : [ "Addresses", "VariablePointers", "VariablePointersStorageBuffer" ], "version" : "1.4" }, + { + "opname" : "OpColorAttachmentReadEXT", + "class" : "Image", + "opcode" : 4160, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Attachment'" }, + { "kind" : "IdRef", "name" : "'Sample'", "quantifier" : "?" } + ], + "capabilities": [ "TileImageColorReadAccessEXT" ], + "version" : "None" + }, + { + "opname" : "OpDepthAttachmentReadEXT", + "class" : "Image", + "opcode" : 4161, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Sample'", "quantifier" : "?" } + ], + "capabilities" : [ "TileImageDepthReadAccessEXT" ], + "version" : "None" + }, + { + "opname" : "OpStencilAttachmentReadEXT", + "class" : "Image", + "opcode" : 4162, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Sample'", "quantifier" : "?" } + ], + "capabilities" : [ "TileImageStencilReadAccessEXT" ], + "version" : "None" + }, { "opname" : "OpTerminateInvocation", "class" : "Control-Flow", @@ -4112,6 +4443,65 @@ "capabilities" : [ "Shader" ], "version" : "1.6" }, + { + "opname" : "OpTypeUntypedPointerKHR", + "class" : "Type-Declaration", + "opcode" : 4417, + "capabilities" : [ + "UntypedPointersKHR" + ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "StorageClass" } + ] + }, + { + "opname" : "OpUntypedVariableKHR", + "class" : "Memory", + "opcode" : 4418, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "StorageClass" }, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Data Type'" }, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Initializer'" } + ] + }, + { + "opname" : "OpUntypedAccessChainKHR", + "class" : "Memory", + "opcode" : 4419, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Base Type'" }, + { "kind" : "IdRef", "name" : "'Base'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } + ] + }, + { + "opname" : "OpUntypedInBoundsAccessChainKHR", + "class" : "Memory", + "opcode" : 4420, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Base Type'" }, + { "kind" : "IdRef", "name" : "'Base'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } + ] + }, { "opname" : "OpSubgroupBallotKHR", "class" : "Group", @@ -4138,6 +4528,68 @@ "extensions" : [ "SPV_KHR_shader_ballot" ], "version" : "None" }, + { + "opname" : "OpUntypedPtrAccessChainKHR", + "class" : "Memory", + "opcode" : 4423, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Base Type'" }, + { "kind" : "IdRef", "name" : "'Base'" }, + { "kind" : "IdRef", "name" : "'Element'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } + ] + }, + { + "opname" : "OpUntypedInBoundsPtrAccessChainKHR", + "class" : "Memory", + "opcode" : 4424, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Base Type'" }, + { "kind" : "IdRef", "name" : "'Base'" }, + { "kind" : "IdRef", "name" : "'Element'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Indexes'" } + ] + }, + { + "opname" : "OpUntypedArrayLengthKHR", + "class" : "Memory", + "opcode" : 4425, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Structure'" }, + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "LiteralInteger", "name" : "'Array member'" } + ] + }, + { + "opname" : "OpUntypedPrefetchKHR", + "class" : "Memory", + "opcode" : 4426, + "capabilities" : [ "UntypedPointersKHR" ], + "provisional" : true, + "version" : "None", + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer Type'" }, + { "kind" : "IdRef", "name" : "'Num Bytes'" }, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'RW'" }, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Locality'" }, + { "kind" : "IdRef", "quantifier" : "?", "name" : "'Cache Type'" } + ] + }, { "opname" : "OpSubgroupAllKHR", "class" : "Group", @@ -4212,6 +4664,20 @@ "extensions" : [ "SPV_KHR_shader_ballot" ], "version" : "None" }, + { + "opname" : "OpExtInstWithForwardRefsKHR", + "class" : "Extension", + "opcode" : 4433, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Set'" }, + { "kind" : "LiteralExtInstInteger", "name" : "'Instruction'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Operand 1', +\n'Operand 2', +\n..." } + ], + "extensions" : [ "SPV_KHR_relaxed_extended_instruction" ], + "version": "None" + }, { "opname" : "OpTraceRayKHR", "class" : "Reserved", @@ -4279,6 +4745,7 @@ { "opname" : "OpSDot", "class" : "Arithmetic", + "aliases" : ["OpSDotKHR"], "opcode" : 4450, "operands" : [ { "kind" : "IdResultType" }, @@ -4288,26 +4755,13 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpSDotKHR", - "class" : "Arithmetic", - "opcode" : 4450, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "opname" : "OpUDot", "class" : "Arithmetic", + "aliases" : ["OpUDotKHR"], "opcode" : 4451, "operands" : [ { "kind" : "IdResultType" }, @@ -4317,26 +4771,13 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpUDotKHR", - "class" : "Arithmetic", - "opcode" : 4451, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "opname" : "OpSUDot", "class" : "Arithmetic", + "aliases" : ["OpSUDotKHR"], "opcode" : 4452, "operands" : [ { "kind" : "IdResultType" }, @@ -4346,26 +4787,13 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpSUDotKHR", - "class" : "Arithmetic", - "opcode" : 4452, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "opname" : "OpSDotAccSat", "class" : "Arithmetic", + "aliases" : ["OpSDotAccSatKHR"], "opcode" : 4453, "operands" : [ { "kind" : "IdResultType" }, @@ -4376,27 +4804,13 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpSDotAccSatKHR", - "class" : "Arithmetic", - "opcode" : 4453, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "IdRef", "name" : "'Accumulator'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "opname" : "OpUDotAccSat", "class" : "Arithmetic", + "aliases" : ["OpUDotAccSatKHR"], "opcode" : 4454, "operands" : [ { "kind" : "IdResultType" }, @@ -4407,27 +4821,13 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpUDotAccSatKHR", - "class" : "Arithmetic", - "opcode" : 4454, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "IdRef", "name" : "'Accumulator'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "opname" : "OpSUDotAccSat", "class" : "Arithmetic", + "aliases" : ["OpSUDotAccSatKHR"], "opcode" : 4455, "operands" : [ { "kind" : "IdResultType" }, @@ -4438,27 +4838,119 @@ { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } ], "capabilities" : [ "DotProduct" ], - "version" : "1.6" - }, - { - "opname" : "OpSUDotAccSatKHR", - "class" : "Arithmetic", - "opcode" : 4455, - "operands" : [ - { "kind" : "IdResultType" }, - { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Vector 1'" }, - { "kind" : "IdRef", "name" : "'Vector 2'" }, - { "kind" : "IdRef", "name" : "'Accumulator'" }, - { "kind" : "PackedVectorFormat", "name" : "'Packed Vector Format'", "quantifier" : "?" } - ], - "capabilities" : [ "DotProductKHR" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, + { + "opname" : "OpTypeCooperativeMatrixKHR", + "class" : "Type-Declaration", + "opcode" : 4456, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Component Type'" }, + { "kind" : "IdScope", "name" : "'Scope'" }, + { "kind" : "IdRef", "name" : "'Rows'" }, + { "kind" : "IdRef", "name" : "'Columns'" }, + { "kind" : "IdRef", "name" : "'Use'" } + ], + "capabilities" : [ "CooperativeMatrixKHR" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixLoadKHR", + "class" : "Memory", + "opcode" : 4457, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'MemoryLayout'" }, + { "kind" : "IdRef", "name" : "'Stride'", "quantifier": "?" }, + { "kind" : "MemoryAccess", "name" : "'Memory Operand'", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeMatrixKHR" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixStoreKHR", + "class" : "Memory", + "opcode" : 4458, + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Object'" }, + { "kind" : "IdRef", "name" : "'MemoryLayout'" }, + { "kind" : "IdRef", "name" : "'Stride'", "quantifier": "?" }, + { "kind" : "MemoryAccess", "name" : "'Memory Operand'", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeMatrixKHR" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixMulAddKHR", + "class" : "Arithmetic", + "opcode" : 4459, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'A'" }, + { "kind" : "IdRef", "name" : "'B'" }, + { "kind" : "IdRef", "name" : "'C'" }, + { "kind" : "CooperativeMatrixOperands", "name" : "'Cooperative Matrix Operands'", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeMatrixKHR" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixLengthKHR", + "class" : "Miscellaneous", + "opcode" : 4460, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Type'" } + ], + "capabilities" : [ "CooperativeMatrixKHR" ], + "version" : "None" + }, + { + "opname" : "OpConstantCompositeReplicateEXT", + "class" : "Constant-Creation", + "opcode" : 4461, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Value'" } + ], + "capabilities" : [ "ReplicatedCompositesEXT" ], + "version" : "None" + }, + { + "opname" : "OpSpecConstantCompositeReplicateEXT", + "class" : "Constant-Creation", + "opcode" : 4462, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Value'" } + ], + "capabilities" : [ "ReplicatedCompositesEXT" ], + "version" : "None" + }, + { + "opname" : "OpCompositeConstructReplicateEXT", + "class" : "Composite", + "opcode" : 4463, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Value'" } + ], + "capabilities" : [ "ReplicatedCompositesEXT" ], + "version" : "None" + }, { "opname" : "OpTypeRayQueryKHR", - "class" : "Reserved", + "class" : "Type-Declaration", "opcode" : 4472, "operands" : [ { "kind" : "IdResult" } @@ -4592,6 +5084,130 @@ "extensions" : [ "SPV_KHR_ray_query" ], "version" : "None" }, + { + "opname" : "OpImageSampleWeightedQCOM", + "class" : "Image", + "opcode" : 4480, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Texture'" }, + { "kind" : "IdRef", "name" : "'Coordinates'" }, + { "kind" : "IdRef", "name" : "'Weights'" } + ], + "capabilities" : [ "TextureSampleWeightedQCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBoxFilterQCOM", + "class" : "Image", + "opcode" : 4481, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Texture'" }, + { "kind" : "IdRef", "name" : "'Coordinates'" }, + { "kind" : "IdRef", "name" : "'Box Size'" } + ], + "capabilities" : [ "TextureBoxFilterQCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchSSDQCOM", + "class" : "Image", + "opcode" : 4482, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatchQCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchSADQCOM", + "class" : "Image", + "opcode" : 4483, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatchQCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchWindowSSDQCOM", + "class" : "Image", + "opcode" : 4500, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatch2QCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchWindowSADQCOM", + "class" : "Image", + "opcode" : 4501, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatch2QCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchGatherSSDQCOM", + "class" : "Image", + "opcode" : 4502, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatch2QCOM" ], + "version" : "None" + }, + { + "opname" : "OpImageBlockMatchGatherSADQCOM", + "class" : "Image", + "opcode" : 4503, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Target Coordinates'" }, + { "kind" : "IdRef", "name" : "'Reference Sampled Image'" }, + { "kind" : "IdRef", "name" : "'Reference Coordinates'" }, + { "kind" : "IdRef", "name" : "'Block Size'" } + ], + "capabilities" : [ "TextureBlockMatch2QCOM" ], + "version" : "None" + }, { "opname" : "OpGroupIAddNonUniformAMD", "class" : "Group", @@ -4751,7 +5367,132 @@ { "kind" : "IdScope", "name" : "'Scope'" } ], "capabilities" : [ "ShaderClockKHR" ], - "extensions" : [ "SPV_KHR_shader_clock" ], + "version" : "None" + }, + { + "opname" : "OpAllocateNodePayloadsAMDX", + "class" : "Reserved", + "opcode" : 5074, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdScope", "name" : "'Visibility'" }, + { "kind" : "IdRef", "name": "'Payload Count'" }, + { "kind" : "IdRef", "name": "'Node Index'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "opname" : "OpEnqueueNodePayloadsAMDX", + "class" : "Reserved", + "opcode" : 5075, + "operands" : [ + { "kind" : "IdRef", "name": "'Payload Array'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "opname" : "OpTypeNodePayloadArrayAMDX", + "class" : "Reserved", + "opcode" : 5076, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name": "'Payload Type'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "opname" : "OpFinishWritingNodePayloadAMDX", + "class" : "Reserved", + "opcode" : 5078, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name": "'Payload'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "opname" : "OpNodePayloadArrayLengthAMDX", + "class" : "Reserved", + "opcode" : 5090, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name": "'Payload Array'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "opname" : "OpIsNodePayloadValidAMDX", + "class" : "Reserved", + "opcode" : 5101, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name": "'Payload Type'" }, + { "kind" : "IdRef", "name": "'Node Index'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version": "None" + }, + { + "opname" : "OpConstantStringAMDX", + "class" : "Reserved", + "opcode" : 5103, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "LiteralString", "name": "'Literal String'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version": "None" + }, + { + "opname" : "OpSpecConstantStringAMDX", + "class" : "Reserved", + "opcode" : 5104, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "LiteralString", "name": "'Literal String'" } + ], + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version": "None" + }, + { + "opname" : "OpGroupNonUniformQuadAllKHR", + "class" : "Non-Uniform", + "opcode" : 5110, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Predicate'" } + ], + "capabilities" : [ "QuadControlKHR" ], + "version" : "None" + }, + { + "opname" : "OpGroupNonUniformQuadAnyKHR", + "class" : "Non-Uniform", + "opcode" : 5111, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Predicate'" } + ], + "capabilities" : [ "QuadControlKHR" ], "version" : "None" }, { @@ -5201,7 +5942,7 @@ }, { "opname" : "OpTypeHitObjectNV", - "class" : "Reserved", + "class" : "Type-Declaration", "opcode" : 5281, "operands" : [ { "kind" : "IdResult" } @@ -5226,6 +5967,105 @@ "extensions" : [ "SPV_NV_shader_image_footprint" ], "version" : "None" }, + { + "opname" : "OpTypeCooperativeVectorNV", + "class" : "Type-Declaration", + "opcode" : 5288, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Component Type'" }, + { "kind" : "IdRef", "name" : "'Component Count'" } + ], + "capabilities" : [ "CooperativeVectorNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorMatrixMulNV", + "class" : "Reserved", + "opcode" : 5289, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Input'" }, + { "kind" : "IdRef", "name" : "'InputInterpretation'" }, + { "kind" : "IdRef", "name" : "'Matrix'" }, + { "kind" : "IdRef", "name" : "'MatrixOffset'" }, + { "kind" : "IdRef", "name" : "'MatrixInterpretation'" }, + { "kind" : "IdRef", "name" : "'M'" }, + { "kind" : "IdRef", "name" : "'K'" }, + { "kind" : "IdRef", "name" : "'MemoryLayout'" }, + { "kind" : "IdRef", "name" : "'Transpose'" }, + { "kind" : "IdRef", "name" : "'MatrixStride'", "quantifier": "?" }, + { "kind" : "CooperativeMatrixOperands", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeVectorNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorOuterProductAccumulateNV", + "class" : "Reserved", + "opcode" : 5290, + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Offset'" }, + { "kind" : "IdRef", "name" : "'A'" }, + { "kind" : "IdRef", "name" : "'B'" }, + { "kind" : "IdRef", "name" : "'MemoryLayout'" }, + { "kind" : "IdRef", "name" : "'MatrixInterpretation'" }, + { "kind" : "IdRef", "name" : "'MatrixStride'", "quantifier": "?" } + ], + "capabilities" : [ "CooperativeVectorTrainingNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorReduceSumAccumulateNV", + "class" : "Reserved", + "opcode" : 5291, + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Offset'" }, + { "kind" : "IdRef", "name" : "'V'" } + ], + "capabilities" : [ "CooperativeVectorTrainingNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorMatrixMulAddNV", + "class" : "Reserved", + "opcode" : 5292, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Input'" }, + { "kind" : "IdRef", "name" : "'InputInterpretation'" }, + { "kind" : "IdRef", "name" : "'Matrix'" }, + { "kind" : "IdRef", "name" : "'MatrixOffset'" }, + { "kind" : "IdRef", "name" : "'MatrixInterpretation'" }, + { "kind" : "IdRef", "name" : "'Bias'" }, + { "kind" : "IdRef", "name" : "'BiasOffset'" }, + { "kind" : "IdRef", "name" : "'BiasInterpretation'" }, + { "kind" : "IdRef", "name" : "'M'" }, + { "kind" : "IdRef", "name" : "'K'" }, + { "kind" : "IdRef", "name" : "'MemoryLayout'" }, + { "kind" : "IdRef", "name" : "'Transpose'" }, + { "kind" : "IdRef", "name" : "'MatrixStride'", "quantifier": "?" }, + { "kind" : "CooperativeMatrixOperands", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeVectorNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixConvertNV", + "class" : "Conversion", + "opcode" : 5293, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Matrix'" } + ], + "capabilities" : [ "CooperativeMatrixConversionsNV" ], + "version" : "None" + }, { "opname" : "OpEmitMeshTasksEXT", "class" : "Reserved", @@ -5276,22 +6116,68 @@ "version" : "None" }, { - "opname" : "OpReportIntersectionNV", + "opname" : "OpFetchMicroTriangleVertexPositionNV", "class" : "Reserved", - "opcode" : 5334, + "opcode" : 5300, "operands" : [ { "kind" : "IdResultType" }, { "kind" : "IdResult" }, - { "kind" : "IdRef", "name" : "'Hit'" }, - { "kind" : "IdRef", "name" : "'HitKind'" } + { "kind" : "IdRef", "name" : "'Accel'" }, + { "kind" : "IdRef", "name" : "'Instance Id'" }, + { "kind" : "IdRef", "name" : "'Geometry Index'" }, + { "kind" : "IdRef", "name" : "'Primitive Index'" }, + { "kind" : "IdRef", "name" : "'Barycentric'" } ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], + "capabilities" : [ "DisplacementMicromapNV" ], + "version" : "None" + }, + { + "opname" : "OpFetchMicroTriangleVertexBarycentricNV", + "class" : "Reserved", + "opcode" : 5301, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Accel'" }, + { "kind" : "IdRef", "name" : "'Instance Id'" }, + { "kind" : "IdRef", "name" : "'Geometry Index'" }, + { "kind" : "IdRef", "name" : "'Primitive Index'" }, + { "kind" : "IdRef", "name" : "'Barycentric'" } + ], + "capabilities" : [ "DisplacementMicromapNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorLoadNV", + "class" : "Memory", + "opcode" : 5302, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Offset'" }, + { "kind" : "MemoryAccess", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeVectorNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeVectorStoreNV", + "class" : "Memory", + "opcode" : 5303, + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Offset'" }, + { "kind" : "IdRef", "name" : "'Object'" }, + { "kind" : "MemoryAccess", "quantifier" : "?" } + ], + "capabilities" : [ "CooperativeVectorNV" ], "version" : "None" }, { "opname" : "OpReportIntersectionKHR", "class" : "Reserved", + "aliases" : ["OpReportIntersectionNV"], "opcode" : 5334, "operands" : [ { "kind" : "IdResultType" }, @@ -5388,19 +6274,28 @@ "version" : "None" }, { - "opname" : "OpTypeAccelerationStructureNV", + "opname" : "OpRayQueryGetIntersectionTriangleVertexPositionsKHR", "class" : "Reserved", - "opcode" : 5341, - "operands" : [ - { "kind" : "IdResult" } - ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR", "RayQueryKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing", "SPV_KHR_ray_query" ], + "opcode" : 5340, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayQueryPositionFetchKHR" ], "version" : "None" }, { "opname" : "OpTypeAccelerationStructureKHR", - "class" : "Reserved", + "class" : "Type-Declaration", + "aliases" : ["OpTypeAccelerationStructureNV"], "opcode" : 5341, "operands" : [ { "kind" : "IdResult" } @@ -5422,9 +6317,40 @@ "extensions" : [ "SPV_NV_ray_tracing" ], "version" : "None" }, + { + "opname" : "OpRayQueryGetClusterIdNV", + "class" : "Reserved", + "opcode" : 5345, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingClusterAccelerationStructureNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectGetClusterIdNV", + "class" : "Reserved", + "opcode" : 5346, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingClusterAccelerationStructureNV" ], + "version" : "None" + }, { "opname" : "OpTypeCooperativeMatrixNV", - "class" : "Reserved", + "class" : "Type-Declaration", "opcode" : 5358, "operands" : [ { "kind" : "IdResult" }, @@ -5513,17 +6439,200 @@ "version" : "None" }, { - "opname" : "OpDemoteToHelperInvocation", - "class" : "Control-Flow", - "opcode" : 5380, - "capabilities" : [ "DemoteToHelperInvocation" ], - "version" : "1.6" + "opname" : "OpCooperativeMatrixReduceNV", + "class" : "Arithmetic", + "opcode" : 5366, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Matrix'" }, + { "kind" : "CooperativeMatrixReduce", "name" : "'Reduce'" }, + { "kind" : "IdRef", "name" : "'CombineFunc'" } + ], + "capabilities" : [ "CooperativeMatrixReductionsNV" ], + "version" : "None" }, { - "opname" : "OpDemoteToHelperInvocationEXT", + "opname" : "OpCooperativeMatrixLoadTensorNV", + "class" : "Memory", + "opcode" : 5367, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Object'" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "MemoryAccess", "name" : "'Memory Operand'"}, + { "kind" : "TensorAddressingOperands", "name" : "'Tensor Addressing Operands'"} + ], + "capabilities" : [ "CooperativeMatrixTensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixStoreTensorNV", + "class" : "Memory", + "opcode" : 5368, + "operands" : [ + { "kind" : "IdRef", "name" : "'Pointer'" }, + { "kind" : "IdRef", "name" : "'Object'" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "MemoryAccess", "name" : "'Memory Operand'"}, + { "kind" : "TensorAddressingOperands", "name" : "'Tensor Addressing Operands'"} + ], + "capabilities" : [ "CooperativeMatrixTensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixPerElementOpNV", + "class" : "Function", + "opcode" : 5369, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Matrix'" }, + { "kind" : "IdRef", "name" : "'Func'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Operands'" } + ], + "capabilities" : [ "CooperativeMatrixPerElementOperationsNV" ], + "version" : "None" + }, + { + "opname" : "OpTypeTensorLayoutNV", + "class" : "Type-Declaration", + "opcode" : 5370, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Dim'" }, + { "kind" : "IdRef", "name" : "'ClampMode'" } + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTypeTensorViewNV", + "class" : "Type-Declaration", + "opcode" : 5371, + "operands" : [ + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Dim'" }, + { "kind" : "IdRef", "name" : "'HasDimensions'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'p'" } + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpCreateTensorLayoutNV", + "class" : "Reserved", + "opcode" : 5372, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" } + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorLayoutSetDimensionNV", + "class" : "Reserved", + "opcode" : 5373, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Dim'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorLayoutSetStrideNV", + "class" : "Reserved", + "opcode" : 5374, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Stride'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorLayoutSliceNV", + "class" : "Reserved", + "opcode" : 5375, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Operands'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorLayoutSetClampValueNV", + "class" : "Reserved", + "opcode" : 5376, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "IdRef", "name" : "'Value'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpCreateTensorViewNV", + "class" : "Reserved", + "opcode" : 5377, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" } + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorViewSetDimensionNV", + "class" : "Reserved", + "opcode" : 5378, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorView'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Dim'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorViewSetStrideNV", + "class" : "Reserved", + "opcode" : 5379, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorView'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Stride'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpDemoteToHelperInvocation", "class" : "Control-Flow", + "aliases" : ["OpDemoteToHelperInvocationEXT"], "opcode" : 5380, - "capabilities" : [ "DemoteToHelperInvocationEXT" ], + "capabilities" : [ "DemoteToHelperInvocation" ], "version" : "1.6" }, { @@ -5534,10 +6643,52 @@ { "kind" : "IdResultType" }, { "kind" : "IdResult" } ], - "capabilities" : [ "DemoteToHelperInvocationEXT" ], + "capabilities" : [ "DemoteToHelperInvocation" ], "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ], "version" : "None" }, + { + "opname" : "OpTensorViewSetClipNV", + "class" : "Reserved", + "opcode" : 5382, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorView'" }, + { "kind" : "IdRef", "name" : "'ClipRowOffset'" }, + { "kind" : "IdRef", "name" : "'ClipRowSpan'" }, + { "kind" : "IdRef", "name" : "'ClipColOffset'" }, + { "kind" : "IdRef", "name" : "'ClipColSpan'" } + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpTensorLayoutSetBlockSizeNV", + "class" : "Reserved", + "opcode" : 5384, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'TensorLayout'" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'BlockSize'" } + + ], + "capabilities" : [ "TensorAddressingNV" ], + "version" : "None" + }, + { + "opname" : "OpCooperativeMatrixTransposeNV", + "class" : "Conversion", + "opcode" : 5390, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Matrix'" } + ], + "capabilities" : [ "CooperativeMatrixConversionsNV" ], + "version" : "None" + }, { "opname" : "OpConvertUToImageNV", "class" : "Reserved", @@ -5620,6 +6771,229 @@ "capabilities" : [ "BindlessTextureNV" ], "version" : "None" }, + { + "opname" : "OpRawAccessChainNV", + "class" : "Memory", + "opcode" : 5398, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Base'" }, + { "kind" : "IdRef", "name" : "'Byte stride'" }, + { "kind" : "IdRef", "name" : "'Element index'" }, + { "kind" : "IdRef", "name" : "'Byte offset'" }, + { "kind" : "RawAccessChainOperands", "quantifier" : "?" } + ], + "capabilities" : [ + "RawAccessChainsNV" + ], + "version" : "None" + }, + { + "opname" : "OpRayQueryGetIntersectionSpherePositionNV", + "class" : "Reserved", + "opcode" : 5427, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpRayQueryGetIntersectionSphereRadiusNV", + "class" : "Reserved", + "opcode" : 5428, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpRayQueryGetIntersectionLSSPositionsNV", + "class" : "Reserved", + "opcode" : 5429, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpRayQueryGetIntersectionLSSRadiiNV", + "class" : "Reserved", + "opcode" : 5430, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV"], + "version" : "None" + }, + { + "opname" : "OpRayQueryGetIntersectionLSSHitValueNV", + "class" : "Reserved", + "opcode" : 5431, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectGetSpherePositionNV", + "class" : "Reserved", + "opcode" : 5432, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectGetSphereRadiusNV", + "class" : "Reserved", + "opcode" : 5433, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectGetLSSPositionsNV", + "class" : "Reserved", + "opcode" : 5434, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectGetLSSRadiiNV", + "class" : "Reserved", + "opcode" : 5435, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectIsSphereHitNV", + "class" : "Reserved", + "opcode" : 5436, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpHitObjectIsLSSHitNV", + "class" : "Reserved", + "opcode" : 5437, + "operands" : [ + { "kind" : "IdResultType"}, + { "kind" : "IdResult"}, + { "kind" : "IdRef", "name" : "'Hit Object'" } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpRayQueryIsSphereHitNV", + "class" : "Reserved", + "opcode" : 5438, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "version" : "None" + }, + { + "opname" : "OpRayQueryIsLSSHitNV", + "class" : "Reserved", + "opcode" : 5439, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { + "kind" : "IdRef", + "name" : "'RayQuery'" + }, + { + "kind" : "IdRef", + "name" : "'Intersection'" + } + ], + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "version" : "None" + }, { "opname" : "OpSubgroupShuffleINTEL", "class" : "Group", @@ -5962,7 +7336,6 @@ "class" : "@exclude", "opcode" : 5609, "operands" : [ - { "kind" : "IdResultType" }, { "kind" : "IdResult" }, { "kind" : "LiteralString", "name" : "'Asm target'" } ], @@ -6009,7 +7382,7 @@ { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } ], - "capabilities" : [ "AtomicFloat16MinMaxEXT", "AtomicFloat32MinMaxEXT", "AtomicFloat64MinMaxEXT" ], + "capabilities" : [ "AtomicFloat16MinMaxEXT", "AtomicFloat32MinMaxEXT", "AtomicFloat64MinMaxEXT", "AtomicFloat16VectorNV" ], "version" : "None" }, { @@ -6024,7 +7397,7 @@ { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } ], - "capabilities" : [ "AtomicFloat16MinMaxEXT", "AtomicFloat32MinMaxEXT", "AtomicFloat64MinMaxEXT" ], + "capabilities" : [ "AtomicFloat16MinMaxEXT", "AtomicFloat32MinMaxEXT", "AtomicFloat64MinMaxEXT", "AtomicFloat16VectorNV" ], "version" : "None" }, { @@ -6055,17 +7428,7 @@ { "opname" : "OpDecorateString", "class" : "Annotation", - "opcode" : 5632, - "operands" : [ - { "kind" : "IdRef", "name" : "'Target'" }, - { "kind" : "Decoration" } - ], - "extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ], - "version" : "1.4" - }, - { - "opname" : "OpDecorateStringGOOGLE", - "class" : "Annotation", + "aliases" : ["OpDecorateStringGOOGLE"], "opcode" : 5632, "operands" : [ { "kind" : "IdRef", "name" : "'Target'" }, @@ -6077,18 +7440,7 @@ { "opname" : "OpMemberDecorateString", "class" : "Annotation", - "opcode" : 5633, - "operands" : [ - { "kind" : "IdRef", "name" : "'Struct Type'" }, - { "kind" : "LiteralInteger", "name" : "'Member'" }, - { "kind" : "Decoration" } - ], - "extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ], - "version" : "1.4" - }, - { - "opname" : "OpMemberDecorateStringGOOGLE", - "class" : "Annotation", + "aliases" : ["OpMemberDecorateStringGOOGLE"], "opcode" : 5633, "operands" : [ { "kind" : "IdRef", "name" : "'Struct Type'" }, @@ -8996,7 +10348,7 @@ { "kind" : "IdMemorySemantics", "name" : "'Semantics'" }, { "kind" : "IdRef", "name" : "'Value'" } ], - "capabilities" : [ "AtomicFloat16AddEXT", "AtomicFloat32AddEXT", "AtomicFloat64AddEXT" ], + "capabilities" : [ "AtomicFloat16AddEXT", "AtomicFloat32AddEXT", "AtomicFloat64AddEXT", "AtomicFloat16VectorNV" ], "extensions" : [ "SPV_EXT_shader_atomic_float_add" ], "version" : "None" }, @@ -9021,7 +10373,7 @@ "operands" : [ { "kind" : "IdRef", "quantifier" : "*", "name" : "'Member 0 type', +\n'member 1 type', +\n..." } ], - "capabilities" : [ "LongConstantCompositeINTEL" ], + "capabilities" : [ "LongCompositesINTEL" ], "version" : "None" }, { @@ -9031,7 +10383,7 @@ "operands" : [ { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } ], - "capabilities" : [ "LongConstantCompositeINTEL" ], + "capabilities" : [ "LongCompositesINTEL" ], "version" : "None" }, { @@ -9041,7 +10393,43 @@ "operands" : [ { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } ], - "capabilities" : [ "LongConstantCompositeINTEL" ], + "capabilities" : [ "LongCompositesINTEL" ], + "version" : "None" + }, + { + "opname" : "OpCompositeConstructContinuedINTEL", + "class" : "Composite", + "opcode" : 6096, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "quantifier" : "*", "name" : "'Constituents'" } + ], + "capabilities" : [ "LongCompositesINTEL" ], + "version": "None" + }, + { + "opname" : "OpConvertFToBF16INTEL", + "class" : "Conversion", + "opcode" : 6116, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Float Value'" } + ], + "capabilities" : [ "BFloat16ConversionINTEL" ], + "version" : "None" + }, + { + "opname" : "OpConvertBF16ToFINTEL", + "class" : "Conversion", + "opcode" : 6117, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'BFloat16 Value'" } + ], + "capabilities" : [ "BFloat16ConversionINTEL" ], "version" : "None" }, { @@ -9068,6 +10456,140 @@ "capabilities" : [ "SplitBarrierINTEL" ], "version" : "None" }, + { + "opname" : "OpArithmeticFenceEXT", + "class" : "Miscellaneous", + "opcode" : 6145, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'Target'" } + ], + "capabilities" : [ "ArithmeticFenceEXT" ], + "version" : "None" + }, + { + "opname" : "OpSubgroupBlockPrefetchINTEL", + "class" : "Group", + "opcode" : 6221, + "operands" : [ + { "kind" : "IdRef", "name" : "'Ptr'" }, + { "kind" : "IdRef", "name" : "'NumBytes'" }, + { "kind" : "MemoryAccess", "quantifier" : "?" } + ], + "capabilities" : [ "SubgroupBufferPrefetchINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroup2DBlockLoadINTEL", + "class" : "Group", + "opcode" : 6231, + "operands" : [ + { "kind" : "IdRef", "name" : "'Element Size'" }, + { "kind" : "IdRef", "name" : "'Block Width'" }, + { "kind" : "IdRef", "name" : "'Block Height'" }, + { "kind" : "IdRef", "name" : "'Block Count'" }, + { "kind" : "IdRef", "name" : "'Src Base Pointer'" }, + { "kind" : "IdRef", "name" : "'Memory Width'" }, + { "kind" : "IdRef", "name" : "'Memory Height'" }, + { "kind" : "IdRef", "name" : "'Memory Pitch'" }, + { "kind" : "IdRef", "name" : "'Coordinate'" }, + { "kind" : "IdRef", "name" : "'Dst Pointer'" } + ], + "capabilities" : [ "Subgroup2DBlockIOINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroup2DBlockLoadTransformINTEL", + "class" : "Group", + "opcode" : 6232, + "operands" : [ + { "kind" : "IdRef", "name" : "'Element Size'" }, + { "kind" : "IdRef", "name" : "'Block Width'" }, + { "kind" : "IdRef", "name" : "'Block Height'" }, + { "kind" : "IdRef", "name" : "'Block Count'" }, + { "kind" : "IdRef", "name" : "'Src Base Pointer'" }, + { "kind" : "IdRef", "name" : "'Memory Width'" }, + { "kind" : "IdRef", "name" : "'Memory Height'" }, + { "kind" : "IdRef", "name" : "'Memory Pitch'" }, + { "kind" : "IdRef", "name" : "'Coordinate'" }, + { "kind" : "IdRef", "name" : "'Dst Pointer'" } + ], + "capabilities" : [ "Subgroup2DBlockTransformINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroup2DBlockLoadTransposeINTEL", + "class" : "Group", + "opcode" : 6233, + "operands" : [ + { "kind" : "IdRef", "name" : "'Element Size'" }, + { "kind" : "IdRef", "name" : "'Block Width'" }, + { "kind" : "IdRef", "name" : "'Block Height'" }, + { "kind" : "IdRef", "name" : "'Block Count'" }, + { "kind" : "IdRef", "name" : "'Src Base Pointer'" }, + { "kind" : "IdRef", "name" : "'Memory Width'" }, + { "kind" : "IdRef", "name" : "'Memory Height'" }, + { "kind" : "IdRef", "name" : "'Memory Pitch'" }, + { "kind" : "IdRef", "name" : "'Coordinate'" }, + { "kind" : "IdRef", "name" : "'Dst Pointer'" } + ], + "capabilities" : [ "Subgroup2DBlockTransposeINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroup2DBlockPrefetchINTEL", + "class" : "Group", + "opcode" : 6234, + "operands" : [ + { "kind" : "IdRef", "name" : "'Element Size'" }, + { "kind" : "IdRef", "name" : "'Block Width'" }, + { "kind" : "IdRef", "name" : "'Block Height'" }, + { "kind" : "IdRef", "name" : "'Block Count'" }, + { "kind" : "IdRef", "name" : "'Src Base Pointer'" }, + { "kind" : "IdRef", "name" : "'Memory Width'" }, + { "kind" : "IdRef", "name" : "'Memory Height'" }, + { "kind" : "IdRef", "name" : "'Memory Pitch'" }, + { "kind" : "IdRef", "name" : "'Coordinate'" } + ], + "capabilities" : [ "Subgroup2DBlockIOINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroup2DBlockStoreINTEL", + "class" : "Group", + "opcode" : 6235, + "operands" : [ + { "kind" : "IdRef", "name" : "'Element Size'" }, + { "kind" : "IdRef", "name" : "'Block Width'" }, + { "kind" : "IdRef", "name" : "'Block Height'" }, + { "kind" : "IdRef", "name" : "'Block Count'" }, + { "kind" : "IdRef", "name" : "'Src Pointer'" }, + { "kind" : "IdRef", "name" : "'Dst Base Pointer'" }, + { "kind" : "IdRef", "name" : "'Memory Width'" }, + { "kind" : "IdRef", "name" : "'Memory Height'" }, + { "kind" : "IdRef", "name" : "'Memory Pitch'" }, + { "kind" : "IdRef", "name" : "'Coordinate'" } + ], + "capabilities" : [ "Subgroup2DBlockIOINTEL" ], + "version" : "None" + }, + { + "opname" : "OpSubgroupMatrixMultiplyAccumulateINTEL", + "class" : "Group", + "opcode" : 6237, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'K Dim'" }, + { "kind" : "IdRef", "name" : "'Matrix A'" }, + { "kind" : "IdRef", "name" : "'Matrix B'" }, + { "kind" : "IdRef", "name" : "'Matrix C'" }, + { "kind" : "MatrixMultiplyAccumulateOperands", "quantifier" : "?" } + ], + "capabilities" : [ "SubgroupMatrixMultiplyAccumulateINTEL" ], + "version" : "None" + }, { "opname" : "OpGroupIMulKHR", "class" : "Group", @@ -9179,6 +10701,34 @@ ], "capabilities" : [ "GroupUniformArithmeticKHR" ], "version" : "None" + }, + { + "opname" : "OpMaskedGatherINTEL", + "class" : "Memory", + "opcode" : 6428, + "operands" : [ + { "kind" : "IdResultType" }, + { "kind" : "IdResult" }, + { "kind" : "IdRef", "name" : "'PtrVector'" }, + { "kind" : "LiteralInteger", "name" : "'Alignment'" }, + { "kind" : "IdRef", "name" : "'Mask'" }, + { "kind" : "IdRef", "name" : "'FillEmpty'" } + ], + "capabilities" : [ "MaskedGatherScatterINTEL" ], + "version" : "None" + }, + { + "opname" : "OpMaskedScatterINTEL", + "class" : "Memory", + "opcode" : 6429, + "operands" : [ + { "kind" : "IdRef", "name" : "'InputVector'" }, + { "kind" : "IdRef", "name" : "'PtrVector'" }, + { "kind" : "LiteralInteger", "name" : "'Alignment'" }, + { "kind" : "IdRef", "name" : "'Mask'" } + ], + "capabilities" : [ "MaskedGatherScatterINTEL" ], + "version" : "None" } ], "operand_kinds" : [ @@ -9196,14 +10746,16 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "Lod", "value" : "0x0002", "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "Grad", @@ -9211,14 +10763,16 @@ "parameters" : [ { "kind" : "IdRef" }, { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "ConstOffset", "value" : "0x0008", "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "Offset", @@ -9226,7 +10780,8 @@ "capabilities" : [ "ImageGatherExtended" ], "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "ConstOffsets", @@ -9234,14 +10789,16 @@ "capabilities" : [ "ImageGatherExtended" ], "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "Sample", "value" : "0x0040", "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "MinLod", @@ -9249,19 +10806,12 @@ "capabilities" : [ "MinLod" ], "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" }, { "enumerant" : "MakeTexelAvailable", - "value" : "0x0100", - "capabilities" : [ "VulkanMemoryModel" ], - "parameters" : [ - { "kind" : "IdScope" } - ], - "version" : "1.5" - }, - { - "enumerant" : "MakeTexelAvailableKHR", + "aliases" : [ "MakeTexelAvailableKHR" ], "value" : "0x0100", "capabilities" : [ "VulkanMemoryModel" ], "parameters" : [ @@ -9272,15 +10822,7 @@ }, { "enumerant" : "MakeTexelVisible", - "value" : "0x0200", - "capabilities" : [ "VulkanMemoryModel" ], - "parameters" : [ - { "kind" : "IdScope" } - ], - "version" : "1.5" - }, - { - "enumerant" : "MakeTexelVisibleKHR", + "aliases" : [ "MakeTexelVisibleKHR" ], "value" : "0x0200", "capabilities" : [ "VulkanMemoryModel" ], "parameters" : [ @@ -9291,12 +10833,7 @@ }, { "enumerant" : "NonPrivateTexel", - "value" : "0x0400", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "NonPrivateTexelKHR", + "aliases" : [ "NonPrivateTexelKHR" ], "value" : "0x0400", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9304,12 +10841,7 @@ }, { "enumerant" : "VolatileTexel", - "value" : "0x0800", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "VolatileTexelKHR", + "aliases" : [ "VolatileTexelKHR" ], "value" : "0x0800", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9335,7 +10867,8 @@ "value" : "0x10000", "parameters" : [ { "kind" : "IdRef" } - ] + ], + "version": "1.0" } ] }, @@ -9345,38 +10878,52 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "NotNaN", - "value" : "0x0001" + "value" : "0x0001", + "version" : "1.0" }, { "enumerant" : "NotInf", - "value" : "0x0002" + "value" : "0x0002", + "version" : "1.0" }, { "enumerant" : "NSZ", - "value" : "0x0004" + "value" : "0x0004", + "version" : "1.0" }, { "enumerant" : "AllowRecip", - "value" : "0x0008" + "value" : "0x0008", + "version" : "1.0" }, { "enumerant" : "Fast", - "value" : "0x0010" + "value" : "0x0010", + "version" : "1.0" }, { - "enumerant" : "AllowContractFastINTEL", + "enumerant" : "AllowContract", + "aliases" : ["AllowContractFastINTEL"], "value" : "0x10000", - "capabilities" : [ "FPFastMathModeINTEL" ], + "capabilities" : [ "FloatControls2", "FPFastMathModeINTEL" ], "version" : "None" }, { - "enumerant" : "AllowReassocINTEL", + "enumerant" : "AllowReassoc", + "aliases" : ["AllowReassocINTEL"], "value" : "0x20000", - "capabilities" : [ "FPFastMathModeINTEL" ], + "capabilities" : [ "FloatControls2", "FPFastMathModeINTEL" ], + "version" : "None" + }, + { + "enumerant" : "AllowTransform", + "value" : "0x40000", + "capabilities" : [ "FloatControls2" ], "version" : "None" } ] @@ -9387,15 +10934,18 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "Flatten", - "value" : "0x0001" + "value" : "0x0001", + "version" : "1.0" }, { "enumerant" : "DontFlatten", - "value" : "0x0002" + "value" : "0x0002", + "version" : "1.0" } ] }, @@ -9405,15 +10955,18 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "Unroll", - "value" : "0x0001" + "value" : "0x0001", + "version" : "1.0" }, { "enumerant" : "DontUnroll", - "value" : "0x0002" + "value" : "0x0002", + "version" : "1.0" }, { "enumerant" : "DependencyInfinite", @@ -9563,28 +11116,34 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "Inline", - "value" : "0x0001" + "value" : "0x0001", + "version" : "1.0" }, { "enumerant" : "DontInline", - "value" : "0x0002" + "value" : "0x0002", + "version" : "1.0" }, { "enumerant" : "Pure", - "value" : "0x0004" + "value" : "0x0004", + "version" : "1.0" }, { "enumerant" : "Const", - "value" : "0x0008" + "value" : "0x0008", + "version" : "1.0" }, { - "enumerant" : "OptNoneINTEL", + "enumerant" : "OptNoneEXT", + "aliases" : ["OptNoneINTEL"], "value" : "0x10000", - "capabilities" : [ "OptNoneINTEL" ], + "capabilities" : [ "OptNoneEXT" ], "version" : "None" } ] @@ -9595,62 +11154,65 @@ "enumerants" : [ { "enumerant" : "Relaxed", - "value" : "0x0000" - }, - { - "enumerant" : "None", - "value" : "0x0000" + "aliases" : ["None"], + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "Acquire", - "value" : "0x0002" + "value" : "0x0002", + "version" : "1.0" }, { "enumerant" : "Release", - "value" : "0x0004" + "value" : "0x0004", + "version" : "1.0" }, { "enumerant" : "AcquireRelease", - "value" : "0x0008" + "value" : "0x0008", + "version" : "1.0" }, { "enumerant" : "SequentiallyConsistent", - "value" : "0x0010" + "value" : "0x0010", + "version" : "1.0" }, { "enumerant" : "UniformMemory", "value" : "0x0040", - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SubgroupMemory", - "value" : "0x0080" + "value" : "0x0080", + "version" : "1.0" }, { "enumerant" : "WorkgroupMemory", - "value" : "0x0100" + "value" : "0x0100", + "version" : "1.0" }, { "enumerant" : "CrossWorkgroupMemory", - "value" : "0x0200" + "value" : "0x0200", + "version" : "1.0" }, { "enumerant" : "AtomicCounterMemory", "value" : "0x0400", - "capabilities" : [ "AtomicStorage" ] + "capabilities" : [ "AtomicStorage" ], + "version": "1.0" }, { "enumerant" : "ImageMemory", - "value" : "0x0800" + "value" : "0x0800", + "version" : "1.0" }, { "enumerant" : "OutputMemory", - "value" : "0x1000", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "OutputMemoryKHR", + "aliases" : ["OutputMemoryKHR"], "value" : "0x1000", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9658,12 +11220,7 @@ }, { "enumerant" : "MakeAvailable", - "value" : "0x2000", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "MakeAvailableKHR", + "aliases" : ["MakeAvailableKHR"], "value" : "0x2000", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9671,12 +11228,7 @@ }, { "enumerant" : "MakeVisible", - "value" : "0x4000", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "MakeVisibleKHR", + "aliases" : ["MakeVisibleKHR"], "value" : "0x4000", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9697,34 +11249,30 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "Volatile", - "value" : "0x0001" + "value" : "0x0001", + "version" : "1.0" }, { "enumerant" : "Aligned", "value" : "0x0002", "parameters" : [ { "kind" : "LiteralInteger" } - ] + ], + "version" : "1.0" }, { "enumerant" : "Nontemporal", - "value" : "0x0004" + "value" : "0x0004", + "version" : "1.0" }, { "enumerant" : "MakePointerAvailable", - "value" : "0x0008", - "parameters" : [ - { "kind" : "IdScope" } - ], - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "MakePointerAvailableKHR", + "aliases" : ["MakePointerAvailableKHR"], "value" : "0x0008", "parameters" : [ { "kind" : "IdScope" } @@ -9735,15 +11283,7 @@ }, { "enumerant" : "MakePointerVisible", - "value" : "0x0010", - "parameters" : [ - { "kind" : "IdScope" } - ], - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "MakePointerVisibleKHR", + "aliases" : ["MakePointerVisibleKHR"], "value" : "0x0010", "parameters" : [ { "kind" : "IdScope" } @@ -9754,12 +11294,7 @@ }, { "enumerant" : "NonPrivatePointer", - "value" : "0x0020", - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "NonPrivatePointerKHR", + "aliases" : ["NonPrivatePointerKHR"], "value" : "0x0020", "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -9793,12 +11328,14 @@ "enumerants" : [ { "enumerant" : "None", - "value" : "0x0000" + "value" : "0x0000", + "version" : "1.0" }, { "enumerant" : "CmdExecTime", "value" : "0x0001", - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" } ] }, @@ -9862,6 +11399,7 @@ }, { "enumerant" : "SkipTrianglesKHR", + "aliases" : ["SkipBuiltinPrimitivesNV"], "value" : "0x0100", "capabilities" : [ "RayTraversalPrimitiveCullingKHR" ], "version" : "None" @@ -9910,41 +11448,101 @@ } ] }, + { + "category" : "BitEnum", + "kind" : "RawAccessChainOperands", + "enumerants" : [ + { + "enumerant" : "None", + "value" : "0x0000" + }, + { + "enumerant" : "RobustnessPerComponentNV", + "value" : "0x0001", + "capabilities" : [ "RawAccessChainsNV" ], + "version" : "None" + }, + { + "enumerant" : "RobustnessPerElementNV", + "value" : "0x0002", + "capabilities" : [ "RawAccessChainsNV" ], + "version" : "None" + } + ] + }, { "category" : "ValueEnum", "kind" : "SourceLanguage", "enumerants" : [ { "enumerant" : "Unknown", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "ESSL", - "value" : 1 + "value" : 1, + "version" : "1.0" }, { "enumerant" : "GLSL", - "value" : 2 + "value" : 2, + "version" : "1.0" }, { "enumerant" : "OpenCL_C", - "value" : 3 + "value" : 3, + "version" : "1.0" }, { "enumerant" : "OpenCL_CPP", - "value" : 4 + "value" : 4, + "version" : "1.0" }, { "enumerant" : "HLSL", - "value" : 5 + "value" : 5, + "version" : "1.0" }, { "enumerant" : "CPP_for_OpenCL", - "value" : 6 + "value" : 6, + "version" : "1.0" }, { "enumerant" : "SYCL", - "value" : 7 + "value" : 7, + "version" : "1.0" + }, + { + "enumerant" : "HERO_C", + "value" : 8, + "version" : "1.0" + }, + { + "enumerant" : "NZSL", + "value" : 9, + "version" : "1.0" + }, + { + "enumerant" : "WGSL", + "value" : 10, + "version" : "1.0" + }, + { + "enumerant" : "Slang", + "value" : 11, + "version" : "1.0" + }, + { + "enumerant" : "Zig", + "value" : 12, + "version" : "1.0" + }, + { + "enumerant" : "Rust", + "value" : 13, + "version" : "1.0" } ] }, @@ -9955,37 +11553,44 @@ { "enumerant" : "Vertex", "value" : 0, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "TessellationControl", "value" : 1, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "TessellationEvaluation", "value" : 2, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "Geometry", "value" : 3, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "Fragment", "value" : 4, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "GLCompute", "value" : 5, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Kernel", "value" : 6, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "TaskNV", @@ -9999,74 +11604,44 @@ "capabilities" : [ "MeshShadingNV" ], "version" : "None" }, - { - "enumerant" : "RayGenerationNV", - "value" : 5313, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "RayGenerationKHR", + "aliases" : ["RayGenerationNV"], "value" : 5313, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "IntersectionNV", - "value" : 5314, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "IntersectionKHR", + "aliases" : ["IntersectionNV"], "value" : 5314, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "AnyHitNV", - "value" : 5315, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "AnyHitKHR", + "aliases" : ["AnyHitNV"], "value" : 5315, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "ClosestHitNV", - "value" : 5316, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "ClosestHitKHR", + "aliases" : ["ClosestHitNV"], "value" : 5316, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "MissNV", - "value" : 5317, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "MissKHR", + "aliases" : ["MissNV"], "value" : 5317, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "CallableNV", - "value" : 5318, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "CallableKHR", + "aliases" : ["CallableNV"], "value" : 5318, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" @@ -10091,31 +11666,28 @@ "enumerants" : [ { "enumerant" : "Logical", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "Physical32", "value" : 1, - "capabilities" : [ "Addresses" ] + "capabilities" : [ "Addresses" ], + "version": "1.0" }, { "enumerant" : "Physical64", "value" : 2, - "capabilities" : [ "Addresses" ] + "capabilities" : [ "Addresses" ], + "version": "1.0" }, { "enumerant" : "PhysicalStorageBuffer64", + "aliases" : ["PhysicalStorageBuffer64EXT"], "value" : 5348, "extensions" : [ "SPV_EXT_physical_storage_buffer", "SPV_KHR_physical_storage_buffer" ], "capabilities" : [ "PhysicalStorageBufferAddresses" ], "version" : "1.5" - }, - { - "enumerant" : "PhysicalStorageBuffer64EXT", - "value" : 5348, - "extensions" : [ "SPV_EXT_physical_storage_buffer" ], - "capabilities" : [ "PhysicalStorageBufferAddresses" ], - "version" : "1.5" } ] }, @@ -10126,26 +11698,24 @@ { "enumerant" : "Simple", "value" : 0, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "GLSL450", "value" : 1, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "OpenCL", "value" : 2, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Vulkan", - "value" : 3, - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "VulkanKHR", + "aliases" : ["VulkanKHR"], "value" : 3, "capabilities" : [ "VulkanMemoryModel" ], "extensions" : [ "SPV_KHR_vulkan_memory_model" ], @@ -10163,82 +11733,98 @@ "capabilities" : [ "Geometry" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Number of <>'" } - ] + ], + "version": "1.0" }, { "enumerant" : "SpacingEqual", "value" : 1, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "SpacingFractionalEven", "value" : 2, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "SpacingFractionalOdd", "value" : 3, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "VertexOrderCw", "value" : 4, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "VertexOrderCcw", "value" : 5, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "PixelCenterInteger", "value" : 6, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "OriginUpperLeft", "value" : 7, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "OriginLowerLeft", "value" : 8, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "EarlyFragmentTests", "value" : 9, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "PointMode", "value" : 10, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "Xfb", "value" : 11, - "capabilities" : [ "TransformFeedback" ] + "capabilities" : [ "TransformFeedback" ], + "version": "1.0" }, { "enumerant" : "DepthReplacing", "value" : 12, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "DepthGreater", "value" : 14, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "DepthLess", "value" : 15, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "DepthUnchanged", "value" : 16, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "LocalSize", @@ -10247,7 +11833,8 @@ { "kind" : "LiteralInteger", "name" : "'x size'" }, { "kind" : "LiteralInteger", "name" : "'y size'" }, { "kind" : "LiteralInteger", "name" : "'z size'" } - ] + ], + "version": "1.0" }, { "enumerant" : "LocalSizeHint", @@ -10257,42 +11844,50 @@ { "kind" : "LiteralInteger", "name" : "'x size'" }, { "kind" : "LiteralInteger", "name" : "'y size'" }, { "kind" : "LiteralInteger", "name" : "'z size'" } - ] + ], + "version": "1.0" }, { "enumerant" : "InputPoints", "value" : 19, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "InputLines", "value" : 20, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "InputLinesAdjacency", "value" : 21, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "Triangles", "value" : 22, - "capabilities" : [ "Geometry", "Tessellation" ] + "capabilities" : [ "Geometry", "Tessellation" ], + "version": "1.0" }, { "enumerant" : "InputTrianglesAdjacency", "value" : 23, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "Quads", "value" : 24, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "Isolines", "value" : 25, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "OutputVertices", @@ -10300,22 +11895,26 @@ "capabilities" : [ "Geometry", "Tessellation", "MeshShadingNV", "MeshShadingEXT" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Vertex count'" } - ] + ], + "version": "1.0" }, { "enumerant" : "OutputPoints", "value" : 27, - "capabilities" : [ "Geometry", "MeshShadingNV", "MeshShadingEXT" ] + "capabilities" : [ "Geometry", "MeshShadingNV", "MeshShadingEXT" ], + "version": "1.0" }, { "enumerant" : "OutputLineStrip", "value" : 28, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "OutputTriangleStrip", "value" : 29, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "VecTypeHint", @@ -10323,12 +11922,14 @@ "capabilities" : [ "Kernel" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Vector type'" } - ] + ], + "version": "1.0" }, { "enumerant" : "ContractionOff", "value" : 31, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Initializer", @@ -10390,6 +11991,24 @@ ], "version" : "1.2" }, + { + "enumerant" : "NonCoherentColorAttachmentReadEXT", + "value" : 4169, + "capabilities" : [ "TileImageColorReadAccessEXT" ], + "version" : "None" + }, + { + "enumerant" : "NonCoherentDepthAttachmentReadEXT", + "value" : 4170, + "capabilities" : [ "TileImageDepthReadAccessEXT" ], + "version" : "None" + }, + { + "enumerant" : "NonCoherentStencilAttachmentReadEXT", + "value" : 4171, + "capabilities" : [ "TileImageStencilReadAccessEXT" ], + "version" : "None" + }, { "enumerant" : "SubgroupUniformControlFlowKHR", "value" : 4421, @@ -10468,6 +12087,67 @@ "extensions" : [ "SPV_EXT_shader_stencil_export" ], "version" : "None" }, + { + "enumerant" : "CoalescingAMDX", + "value" : 5069, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "IsApiEntryAMDX", + "value" : 5070, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Is Entry'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "MaxNodeRecursionAMDX", + "value" : 5071, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Number of recursions'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "StaticNumWorkgroupsAMDX", + "value" : 5072, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'x size'" }, + { "kind" : "IdRef", "name" : "'y size'" }, + { "kind" : "IdRef", "name" : "'z size'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "ShaderIndexAMDX", + "value" : 5073, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Shader Index'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "MaxNumWorkgroupsAMDX", + "value" : 5077, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'x size'" }, + { "kind" : "IdRef", "name" : "'y size'" }, + { "kind" : "IdRef", "name" : "'z size'" } + ], + "provisional" : true, + "version" : "None" + }, { "enumerant": "StencilRefUnchangedFrontAMD", "value": 5079, @@ -10511,31 +12191,39 @@ "version": "None" }, { - "enumerant" : "OutputLinesNV", - "value" : 5269, - "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], - "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], + "enumerant": "QuadDerivativesKHR", + "value": 5088, + "capabilities": [ "QuadControlKHR" ], + "version": "None" + }, + { + "enumerant" : "RequireFullQuadsKHR", + "value" : 5089, + "capabilities" : [ "QuadControlKHR" ], + "version" : "None" + }, + { + "enumerant" : "SharesInputWithAMDX", + "value" : 5102, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Node Name'" }, + { "kind" : "IdRef", "name" : "'Shader Index'" } + ], + "provisional" : true, "version" : "None" }, { "enumerant" : "OutputLinesEXT", + "aliases" : ["OutputLinesNV"], "value" : 5269, "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], "version" : "None" }, - { - "enumerant" : "OutputPrimitivesNV", - "value" : 5270, - "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], - "parameters" : [ - { "kind" : "LiteralInteger", "name" : "'Primitive count'" } - ], - "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], - "version" : "None" - }, { "enumerant" : "OutputPrimitivesEXT", + "aliases" : ["OutputPrimitivesNV"], "value" : 5270, "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], "parameters" : [ @@ -10545,28 +12233,24 @@ "version" : "None" }, { - "enumerant" : "DerivativeGroupQuadsNV", + "enumerant" : "DerivativeGroupQuadsKHR", + "aliases" : ["DerivativeGroupQuadsNV"], "value" : 5289, - "capabilities" : [ "ComputeDerivativeGroupQuadsNV" ], - "extensions" : [ "SPV_NV_compute_shader_derivatives" ], + "capabilities" : [ "ComputeDerivativeGroupQuadsNV", "ComputeDerivativeGroupQuadsKHR" ], + "extensions" : [ "SPV_NV_compute_shader_derivatives", "SPV_KHR_compute_shader_derivatives" ], "version" : "None" }, { - "enumerant" : "DerivativeGroupLinearNV", + "enumerant" : "DerivativeGroupLinearKHR", + "aliases" : ["DerivativeGroupLinearNV"], "value" : 5290, - "capabilities" : [ "ComputeDerivativeGroupLinearNV" ], - "extensions" : [ "SPV_NV_compute_shader_derivatives" ], - "version" : "None" - }, - { - "enumerant" : "OutputTrianglesNV", - "value" : 5298, - "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], - "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], + "capabilities" : [ "ComputeDerivativeGroupLinearNV", "ComputeDerivativeGroupLinearKHR" ], + "extensions" : [ "SPV_NV_compute_shader_derivatives", "SPV_KHR_compute_shader_derivatives" ], "version" : "None" }, { "enumerant" : "OutputTrianglesEXT", + "aliases" : ["OutputTrianglesNV"], "value" : 5298, "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], @@ -10708,6 +12392,23 @@ "version" : "None" }, { + "enumerant" : "MaximallyReconvergesKHR", + "value" : 6023, + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_KHR_maximal_reconvergence" ], + "version" : "None" + }, + { + "enumerant" : "FPFastMathDefault", + "value" : 6028, + "parameters" : [ + { "kind" : "IdRef", "name" : "'Target Type'" }, + { "kind" : "IdRef", "name" : "'Fast-Math Mode'" } + ], + "capabilities" : [ "FloatControls2" ], + "version" : "None" + }, + { "enumerant" : "StreamingInterfaceINTEL", "value" : 6154, "parameters" : [ @@ -10716,6 +12417,15 @@ "capabilities" : [ "FPGAKernelAttributesINTEL" ], "version" : "None" }, + { + "enumerant" : "RegisterMapInterfaceINTEL", + "value" : 6160, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'WaitForDoneWrite'" } + ], + "capabilities" : [ "FPGAKernelAttributesv2INTEL" ], + "version" : "None" + }, { "enumerant" : "NamedBarrierCountINTEL", "value" : 6417, @@ -10724,6 +12434,33 @@ ], "capabilities" : [ "VectorComputeINTEL" ], "version" : "None" + }, + { + "enumerant" : "MaximumRegistersINTEL", + "value" : 6461, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Number of Registers'" } + ], + "capabilities" : [ "RegisterLimitsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "MaximumRegistersIdINTEL", + "value" : 6462, + "parameters" : [ + { "kind" : "IdRef", "name" : "'Number of Registers'" } + ], + "capabilities" : [ "RegisterLimitsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "NamedMaximumRegistersINTEL", + "value" : 6463, + "parameters" : [ + { "kind" : "NamedMaximumNumberOfRegisters", "name" : "'Named Maximum Number of Registers'" } + ], + "capabilities" : [ "RegisterLimitsINTEL" ], + "version" : "None" } ] }, @@ -10733,57 +12470,69 @@ "enumerants" : [ { "enumerant" : "UniformConstant", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "Input", - "value" : 1 + "value" : 1, + "version" : "1.0" }, { "enumerant" : "Uniform", "value" : 2, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Output", "value" : 3, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Workgroup", - "value" : 4 + "value" : 4, + "version" : "1.0" }, { "enumerant" : "CrossWorkgroup", - "value" : 5 + "value" : 5, + "version" : "1.0" }, { "enumerant" : "Private", "value" : 6, - "capabilities" : [ "Shader", "VectorComputeINTEL" ] + "capabilities" : [ "Shader", "VectorComputeINTEL" ], + "version": "1.0" }, { "enumerant" : "Function", - "value" : 7 + "value" : 7, + "version" : "1.0" }, { "enumerant" : "Generic", "value" : 8, - "capabilities" : [ "GenericPointer" ] + "capabilities" : [ "GenericPointer" ], + "version": "1.0" }, { "enumerant" : "PushConstant", "value" : 9, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "AtomicCounter", "value" : 10, - "capabilities" : [ "AtomicStorage" ] + "capabilities" : [ "AtomicStorage" ], + "version": "1.0" }, { "enumerant" : "Image", - "value" : 11 + "value" : 11, + "version" : "1.0" }, { "enumerant" : "StorageBuffer", @@ -10796,84 +12545,61 @@ "version" : "1.3" }, { - "enumerant" : "CallableDataNV", - "value" : 5328, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], + "enumerant" : "TileImageEXT", + "value" : 4172, + "capabilities" : [ "TileImageColorReadAccessEXT" ], + "version" : "None" + }, + { + "enumerant" : "NodePayloadAMDX", + "value" : 5068, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, "version" : "None" }, { "enumerant" : "CallableDataKHR", + "aliases" : ["CallableDataNV"], "value" : 5328, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "IncomingCallableDataNV", - "value" : 5329, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "IncomingCallableDataKHR", + "aliases" : ["IncomingCallableDataNV"], "value" : 5329, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "RayPayloadNV", - "value" : 5338, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "RayPayloadKHR", + "aliases" : ["RayPayloadNV"], "value" : 5338, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "HitAttributeNV", - "value" : 5339, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "HitAttributeKHR", + "aliases" : ["HitAttributeNV"], "value" : 5339, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "IncomingRayPayloadNV", - "value" : 5342, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "IncomingRayPayloadKHR", + "aliases" : ["IncomingRayPayloadNV"], "value" : 5342, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "version" : "None" }, - { - "enumerant" : "ShaderRecordBufferNV", - "value" : 5343, - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "version" : "None" - }, { "enumerant" : "ShaderRecordBufferKHR", + "aliases" : ["ShaderRecordBufferNV"], "value" : 5343, "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], @@ -10881,18 +12607,12 @@ }, { "enumerant" : "PhysicalStorageBuffer", + "aliases" : ["PhysicalStorageBufferEXT"], "value" : 5349, "extensions" : [ "SPV_EXT_physical_storage_buffer", "SPV_KHR_physical_storage_buffer" ], "capabilities" : [ "PhysicalStorageBufferAddresses" ], "version" : "1.5" }, - { - "enumerant" : "PhysicalStorageBufferEXT", - "value" : 5349, - "extensions" : [ "SPV_EXT_physical_storage_buffer" ], - "capabilities" : [ "PhysicalStorageBufferAddresses" ], - "version" : "1.5" - }, { "enumerant" : "HitObjectAttributeNV", "value" : 5385, @@ -10940,36 +12660,48 @@ { "enumerant" : "1D", "value" : 0, - "capabilities" : [ "Sampled1D", "Image1D" ] + "capabilities" : [ "Sampled1D" ], + "version": "1.0" }, { "enumerant" : "2D", "value" : 1, - "capabilities" : [ "Shader", "Kernel", "ImageMSArray" ] + "version" : "1.0" }, { "enumerant" : "3D", - "value" : 2 + "value" : 2, + "version" : "1.0" }, { "enumerant" : "Cube", "value" : 3, - "capabilities" : [ "Shader", "ImageCubeArray" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rect", "value" : 4, - "capabilities" : [ "SampledRect", "ImageRect" ] + "capabilities" : [ "SampledRect" ], + "version": "1.0" }, { "enumerant" : "Buffer", "value" : 5, - "capabilities" : [ "SampledBuffer", "ImageBuffer" ] + "capabilities" : [ "SampledBuffer" ], + "version": "1.0" }, { "enumerant" : "SubpassData", "value" : 6, - "capabilities" : [ "InputAttachment" ] + "capabilities" : [ "InputAttachment" ], + "version": "1.0" + }, + { + "enumerant" : "TileImageDataEXT", + "value" : 4173, + "capabilities" : [ "TileImageColorReadAccessEXT" ], + "version" : "None" } ] }, @@ -10980,27 +12712,27 @@ { "enumerant" : "None", "value" : 0, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "ClampToEdge", "value" : 1, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Clamp", "value" : 2, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Repeat", "value" : 3, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RepeatMirrored", "value" : 4, - "capabilities" : [ "Kernel" ] + "version": "1.0" } ] }, @@ -11011,12 +12743,12 @@ { "enumerant" : "Nearest", "value" : 0, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Linear", "value" : 1, - "capabilities" : [ "Kernel" ] + "version": "1.0" } ] }, @@ -11026,212 +12758,254 @@ "enumerants" : [ { "enumerant" : "Unknown", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "Rgba32f", "value" : 1, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba16f", "value" : 2, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "R32f", "value" : 3, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba8", "value" : 4, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba8Snorm", "value" : 5, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rg32f", "value" : 6, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg16f", "value" : 7, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R11fG11fB10f", "value" : 8, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R16f", "value" : 9, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rgba16", "value" : 10, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rgb10A2", "value" : 11, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg16", "value" : 12, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg8", "value" : 13, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R16", "value" : 14, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R8", "value" : 15, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rgba16Snorm", "value" : 16, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg16Snorm", "value" : 17, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg8Snorm", "value" : 18, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R16Snorm", "value" : 19, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R8Snorm", "value" : 20, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rgba32i", "value" : 21, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba16i", "value" : 22, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba8i", "value" : 23, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "R32i", "value" : 24, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rg32i", "value" : 25, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg16i", "value" : 26, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg8i", "value" : 27, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R16i", "value" : 28, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R8i", "value" : 29, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rgba32ui", "value" : 30, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba16ui", "value" : 31, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgba8ui", "value" : 32, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "R32ui", "value" : 33, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Rgb10a2ui", "value" : 34, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg32ui", "value" : 35, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg16ui", "value" : 36, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "Rg8ui", "value" : 37, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R16ui", "value" : 38, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, { "enumerant" : "R8ui", "value" : 39, - "capabilities" : [ "StorageImageExtendedFormats" ] + "capabilities" : [ "StorageImageExtendedFormats" ], + "version": "1.0" }, - { + { "enumerant" : "R64ui", "value" : 40, - "capabilities" : [ "Int64ImageEXT" ] + "capabilities" : [ "Int64ImageEXT" ], + "version": "1.0" }, { "enumerant" : "R64i", "value" : 41, - "capabilities" : [ "Int64ImageEXT" ] + "capabilities" : [ "Int64ImageEXT" ], + "version": "1.0" } ] }, @@ -11242,102 +13016,102 @@ { "enumerant" : "R", "value" : 0, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "A", "value" : 1, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RG", "value" : 2, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RA", "value" : 3, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RGB", "value" : 4, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RGBA", "value" : 5, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "BGRA", "value" : 6, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "ARGB", "value" : 7, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Intensity", "value" : 8, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Luminance", "value" : 9, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Rx", "value" : 10, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RGx", "value" : 11, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "RGBx", "value" : 12, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Depth", "value" : 13, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "DepthStencil", "value" : 14, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "sRGB", "value" : 15, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "sRGBx", "value" : 16, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "sRGBA", "value" : 17, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "sBGRA", "value" : 18, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "ABGR", "value" : 19, - "capabilities" : [ "Kernel" ] + "version": "1.0" } ] }, @@ -11348,87 +13122,102 @@ { "enumerant" : "SnormInt8", "value" : 0, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "SnormInt16", "value" : 1, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormInt8", "value" : 2, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormInt16", "value" : 3, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormShort565", "value" : 4, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormShort555", "value" : 5, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormInt101010", "value" : 6, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "SignedInt8", "value" : 7, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "SignedInt16", "value" : 8, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "SignedInt32", "value" : 9, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnsignedInt8", "value" : 10, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnsignedInt16", "value" : 11, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnsignedInt32", "value" : 12, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "HalfFloat", "value" : 13, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "Float", "value" : 14, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormInt24", "value" : 15, - "capabilities" : [ "Kernel" ] + "version": "1.0" }, { "enumerant" : "UnormInt101010_2", "value" : 16, - "capabilities" : [ "Kernel" ] + "version": "1.0" + }, + { + "enumerant" : "UnsignedIntRaw10EXT", + "value" : 19, + "version": "1.0" + }, + { + "enumerant" : "UnsignedIntRaw12EXT", + "value" : 20, + "version": "1.0" + }, + { + "enumerant" : "UnormInt2_101010EXT", + "value" : 21, + "version": "1.0" } ] }, @@ -11438,19 +13227,23 @@ "enumerants" : [ { "enumerant" : "RTE", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "RTZ", - "value" : 1 + "value" : 1, + "version" : "1.0" }, { "enumerant" : "RTP", - "value" : 2 + "value" : 2, + "version" : "1.0" }, { "enumerant" : "RTN", - "value" : 3 + "value" : 3, + "version" : "1.0" } ] }, @@ -11469,7 +13262,7 @@ "value" : 1, "capabilities" : [ "FunctionFloatControlINTEL" ], "version" : "None" - } + } ] }, { @@ -11581,12 +13374,14 @@ { "enumerant" : "Export", "value" : 0, - "capabilities" : [ "Linkage" ] + "capabilities" : [ "Linkage" ], + "version": "1.0" }, { "enumerant" : "Import", "value" : 1, - "capabilities" : [ "Linkage" ] + "capabilities" : [ "Linkage" ], + "version": "1.0" }, { "enumerant" : "LinkOnceODR", @@ -11604,17 +13399,50 @@ { "enumerant" : "ReadOnly", "value" : 0, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "WriteOnly", "value" : 1, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "ReadWrite", "value" : 2, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "HostAccessQualifier", + "enumerants" : [ + { + "enumerant" : "NoneINTEL", + "value" : 0, + "capabilities" : [ "GlobalVariableHostAccessINTEL" ], + "version" : "None" + }, + { + "enumerant" : "ReadINTEL", + "value" : 1, + "capabilities" : [ "GlobalVariableHostAccessINTEL" ], + "version" : "None" + }, + { + "enumerant" : "WriteINTEL", + "value" : 2, + "capabilities" : [ "GlobalVariableHostAccessINTEL" ], + "version" : "None" + }, + { + "enumerant" : "ReadWriteINTEL", + "value" : 3, + "capabilities" : [ "GlobalVariableHostAccessINTEL" ], + "version" : "None" } ] }, @@ -11625,47 +13453,56 @@ { "enumerant" : "Zext", "value" : 0, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Sext", "value" : 1, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "ByVal", "value" : 2, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Sret", "value" : 3, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "NoAlias", "value" : 4, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "NoCapture", "value" : 5, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "NoWrite", "value" : 6, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "NoReadWrite", "value" : 7, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "RuntimeAlignedINTEL", "value" : 5940, - "capabilities" : [ "RuntimeAlignedAttributeINTEL" ] + "capabilities" : [ "RuntimeAlignedAttributeINTEL" ], + "version": "1.0" } ] }, @@ -11676,7 +13513,8 @@ { "enumerant" : "RelaxedPrecision", "value" : 0, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SpecId", @@ -11684,28 +13522,33 @@ "capabilities" : [ "Shader", "Kernel" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Specialization Constant ID'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Block", "value" : 2, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "BufferBlock", "value" : 3, "capabilities" : [ "Shader" ], + "version": "1.0", "lastVersion" : "1.3" }, { "enumerant" : "RowMajor", "value" : 4, - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "enumerant" : "ColMajor", "value" : 5, - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "enumerant" : "ArrayStride", @@ -11713,7 +13556,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Array Stride'" } - ] + ], + "version": "1.0" }, { "enumerant" : "MatrixStride", @@ -11721,93 +13565,112 @@ "capabilities" : [ "Matrix" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Matrix Stride'" } - ] + ], + "version": "1.0" }, { "enumerant" : "GLSLShared", "value" : 8, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "GLSLPacked", "value" : 9, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "CPacked", "value" : 10, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "BuiltIn", "value" : 11, "parameters" : [ { "kind" : "BuiltIn" } - ] + ], + "version": "1.0" }, { "enumerant" : "NoPerspective", "value" : 13, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Flat", "value" : 14, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Patch", "value" : 15, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "Centroid", "value" : 16, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Sample", "value" : 17, - "capabilities" : [ "SampleRateShading" ] + "capabilities" : [ "SampleRateShading" ], + "version": "1.0" }, { "enumerant" : "Invariant", "value" : 18, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Restrict", - "value" : 19 + "value" : 19, + "version" : "1.0" }, { "enumerant" : "Aliased", - "value" : 20 + "value" : 20, + "version" : "1.0" }, { "enumerant" : "Volatile", - "value" : 21 + "value" : 21, + "version" : "1.0" }, { "enumerant" : "Constant", "value" : 22, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Coherent", - "value" : 23 + "value" : 23, + "version": "1.0" }, { "enumerant" : "NonWritable", - "value" : 24 + "value" : 24, + "version": "1.0" }, { "enumerant" : "NonReadable", - "value" : 25 + "value" : 25, + "version": "1.0" }, { "enumerant" : "Uniform", "value" : 26, - "capabilities" : [ "Shader", "UniformDecoration" ] + "capabilities" : [ "Shader", "UniformDecoration" ], + "version": "1.0" }, { "enumerant" : "UniformId", @@ -11821,7 +13684,8 @@ { "enumerant" : "SaturatedConversion", "value" : 28, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Stream", @@ -11829,7 +13693,8 @@ "capabilities" : [ "GeometryStreams" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Stream Number'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Location", @@ -11837,7 +13702,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Location'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Component", @@ -11845,7 +13711,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Component'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Index", @@ -11853,7 +13720,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Index'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Binding", @@ -11861,7 +13729,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Binding Point'" } - ] + ], + "version": "1.0" }, { "enumerant" : "DescriptorSet", @@ -11869,7 +13738,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Descriptor Set'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Offset", @@ -11877,7 +13747,8 @@ "capabilities" : [ "Shader" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Byte Offset'" } - ] + ], + "version": "1.0" }, { "enumerant" : "XfbBuffer", @@ -11885,7 +13756,8 @@ "capabilities" : [ "TransformFeedback" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'XFB Buffer Number'" } - ] + ], + "version": "1.0" }, { "enumerant" : "XfbStride", @@ -11893,7 +13765,8 @@ "capabilities" : [ "TransformFeedback" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'XFB Stride'" } - ] + ], + "version": "1.0" }, { "enumerant" : "FuncParamAttr", @@ -11901,22 +13774,25 @@ "capabilities" : [ "Kernel" ], "parameters" : [ { "kind" : "FunctionParameterAttribute", "name" : "'Function Parameter Attribute'" } - ] + ], + "version": "1.0" }, { "enumerant" : "FPRoundingMode", "value" : 39, "parameters" : [ { "kind" : "FPRoundingMode", "name" : "'Floating-Point Rounding Mode'" } - ] + ], + "version": "1.0" }, { "enumerant" : "FPFastMathMode", "value" : 40, - "capabilities" : [ "Kernel" ], + "capabilities" : [ "Kernel", "FloatControls2" ], "parameters" : [ { "kind" : "FPFastMathMode", "name" : "'Fast-Math Mode'" } - ] + ], + "version": "1.0" }, { "enumerant" : "LinkageAttributes", @@ -11925,12 +13801,14 @@ "parameters" : [ { "kind" : "LiteralString", "name" : "'Name'" }, { "kind" : "LinkageType", "name" : "'Linkage Type'" } - ] + ], + "version": "1.0" }, { "enumerant" : "NoContraction", "value" : 42, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "InputAttachmentIndex", @@ -11938,7 +13816,8 @@ "capabilities" : [ "InputAttachment" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Attachment Index'" } - ] + ], + "version": "1.0" }, { "enumerant" : "Alignment", @@ -11946,7 +13825,8 @@ "capabilities" : [ "Kernel" ], "parameters" : [ { "kind" : "LiteralInteger", "name" : "'Alignment'" } - ] + ], + "version": "1.0" }, { "enumerant" : "MaxByteOffset", @@ -11987,12 +13867,101 @@ "extensions" : [ "SPV_KHR_no_integer_wrap_decoration" ], "version" : "1.4" }, + { + "enumerant" : "WeightTextureQCOM", + "value" : 4487, + "extensions" : [ "SPV_QCOM_image_processing" ], + "version" : "None" + }, + { + "enumerant" : "BlockMatchTextureQCOM", + "value" : 4488, + "extensions" : [ "SPV_QCOM_image_processing" ], + "version" : "None" + }, + { + "enumerant" : "BlockMatchSamplerQCOM", + "value" : 4499, + "extensions" : [ "SPV_QCOM_image_processing2" ], + "version" : "None" + }, { "enumerant" : "ExplicitInterpAMD", "value" : 4999, "extensions" : [ "SPV_AMD_shader_explicit_vertex_parameter" ], "version" : "None" }, + { + "enumerant" : "NodeSharesPayloadLimitsWithAMDX", + "value" : 5019, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Payload Type'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "NodeMaxPayloadsAMDX", + "value" : 5020, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Max number of payloads'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "TrackFinishWritingAMDX", + "value" : 5078, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "PayloadNodeNameAMDX", + "value" : 5091, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Node Name'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "PayloadNodeBaseIndexAMDX", + "value" : 5098, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Base Index'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "PayloadNodeSparseArrayAMDX", + "value" : 5099, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "PayloadNodeArraySizeAMDX", + "value" : 5100, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "parameters" : [ + { "kind" : "IdRef", "name" : "'Array Size'" } + ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "PayloadDispatchIndirectAMDX", + "value" : 5105, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, { "enumerant" : "OverrideCoverageNV", "value" : 5248, @@ -12023,15 +13992,9 @@ { "kind" : "LiteralInteger", "name" : "'Offset'" } ] }, - { - "enumerant" : "PerPrimitiveNV", - "value" : 5271, - "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], - "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], - "version" : "None" - }, { "enumerant" : "PerPrimitiveEXT", + "aliases" : ["PerPrimitiveNV"], "value" : 5271, "capabilities" : [ "MeshShadingNV", "MeshShadingEXT" ], "extensions" : [ "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader" ], @@ -12053,26 +14016,15 @@ }, { "enumerant" : "PerVertexKHR", + "aliases" : ["PerVertexNV"], "value" : 5285, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], - "version" : "None" - }, - { - "enumerant" : "PerVertexNV", - "value" : 5285, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "capabilities" : [ "FragmentBarycentricKHR" ], "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { "enumerant" : "NonUniform", - "value" : 5300, - "capabilities" : [ "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "NonUniformEXT", + "aliases" : ["NonUniformEXT"], "value" : 5300, "capabilities" : [ "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -12080,32 +14032,20 @@ }, { "enumerant" : "RestrictPointer", + "aliases" : ["RestrictPointerEXT"], "value" : 5355, "capabilities" : [ "PhysicalStorageBufferAddresses" ], "extensions" : [ "SPV_EXT_physical_storage_buffer", "SPV_KHR_physical_storage_buffer" ], "version" : "1.5" }, - { - "enumerant" : "RestrictPointerEXT", - "value" : 5355, - "capabilities" : [ "PhysicalStorageBufferAddresses" ], - "extensions" : [ "SPV_EXT_physical_storage_buffer" ], - "version" : "1.5" - }, { "enumerant" : "AliasedPointer", + "aliases" : ["AliasedPointerEXT"], "value" : 5356, "capabilities" : [ "PhysicalStorageBufferAddresses" ], "extensions" : [ "SPV_EXT_physical_storage_buffer", "SPV_KHR_physical_storage_buffer" ], "version" : "1.5" }, - { - "enumerant" : "AliasedPointerEXT", - "value" : 5356, - "capabilities" : [ "PhysicalStorageBufferAddresses" ], - "extensions" : [ "SPV_EXT_physical_storage_buffer" ], - "version" : "1.5" - }, { "enumerant" : "HitObjectShaderRecordBufferNV", "value" : 5386, @@ -12205,37 +14145,23 @@ }, { "enumerant" : "CounterBuffer", - "value" : 5634, - "parameters" : [ - { "kind" : "IdRef", "name" : "'Counter Buffer'" } - ], - "version" : "1.4" - }, - { - "enumerant" : "HlslCounterBufferGOOGLE", + "aliases" : ["HlslCounterBufferGOOGLE"], "value" : 5634, "parameters" : [ { "kind" : "IdRef", "name" : "'Counter Buffer'" } ], "extensions" : [ "SPV_GOOGLE_hlsl_functionality1" ], - "version" : "None" + "version" : "1.4" }, { "enumerant" : "UserSemantic", - "value" : 5635, - "parameters" : [ - { "kind" : "LiteralString", "name" : "'Semantic'" } - ], - "version" : "1.4" - }, - { - "enumerant" : "HlslSemanticGOOGLE", + "aliases" : ["HlslSemanticGOOGLE"], "value" : 5635, "parameters" : [ { "kind" : "LiteralString", "name" : "'Semantic'" } ], "extensions" : [ "SPV_GOOGLE_hlsl_functionality1" ], - "version" : "None" + "version" : "1.4" }, { "enumerant" : "UserTypeGOOGLE", @@ -12375,6 +14301,30 @@ "extensions" : [ "SPV_INTEL_fpga_memory_attributes" ], "version" : "None" }, + { + "enumerant" : "StridesizeINTEL", + "value" : 5883, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Stride Size'" } + ], + "capabilities" : [ "FPGAMemoryAttributesINTEL" ], + "version" : "None" + }, + { + "enumerant" : "WordsizeINTEL", + "value" : 5884, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Word Size'" } + ], + "capabilities" : [ "FPGAMemoryAttributesINTEL" ], + "version" : "None" + }, + { + "enumerant" : "TrueDualPortINTEL", + "value" : 5885, + "capabilities" : [ "FPGAMemoryAttributesINTEL" ], + "version" : "None" + }, { "enumerant" : "BurstCoalesceINTEL", "value" : 5899, @@ -12517,6 +14467,161 @@ "value" : 6140, "capabilities" : [ "VectorComputeINTEL" ], "version" : "None" + }, + { + "enumerant" : "StallFreeINTEL", + "value" : 6151, + "capabilities" : [ "FPGAClusterAttributesV2INTEL" ], + "version" : "None" + }, + { + "enumerant" : "FPMaxErrorDecorationINTEL", + "value" : 6170, + "parameters" : [ + { "kind" : "LiteralFloat", "name" : "'Max Error'" } + ], + "capabilities" : [ "FPMaxErrorINTEL" ], + "version" : "None" + }, + { + "enumerant" : "LatencyControlLabelINTEL", + "value" : 6172, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Latency Label'" } + ], + "capabilities" : [ "FPGALatencyControlINTEL" ], + "version" : "None" + }, + { + "enumerant" : "LatencyControlConstraintINTEL", + "value" : 6173, + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Relative To'" }, + { "kind" : "LiteralInteger", "name" : "'Control Type'" }, + { "kind" : "LiteralInteger", "name" : "'Relative Cycle'" } + ], + "capabilities" : [ "FPGALatencyControlINTEL" ], + "version" : "None" + }, + { + "enumerant" : "ConduitKernelArgumentINTEL", + "value" : 6175, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "version" : "None" + }, + { + "enumerant" : "RegisterMapKernelArgumentINTEL", + "value" : 6176, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceAddressWidthINTEL", + "value" : 6177, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'AddressWidth'" } + ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceDataWidthINTEL", + "value" : 6178, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'DataWidth'" } + ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceLatencyINTEL", + "value" : 6179, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Latency'" } + ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceReadWriteModeINTEL", + "value" : 6180, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "AccessQualifier", "name" : "'ReadWriteMode'" } + ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceMaxBurstINTEL", + "value" : 6181, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'MaxBurstCount'" } + ], + "version" : "None" + }, + { + "enumerant" : "MMHostInterfaceWaitRequestINTEL", + "value" : 6182, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Waitrequest'" } + ], + "version" : "None" + }, + { + "enumerant" : "StableKernelArgumentINTEL", + "value" : 6183, + "capabilities" : [ "FPGAArgumentInterfacesINTEL" ], + "version" : "None" + }, + { + "enumerant" : "HostAccessINTEL", + "value" : 6188, + "parameters": [ + { "kind" : "HostAccessQualifier", "name" : "'Access'" }, + { "kind" : "LiteralString", "name" : "'Name'" } + ], + "capabilities" : [ "GlobalVariableHostAccessINTEL" ], + "version" : "None" + }, + { + "enumerant" : "InitModeINTEL", + "value" : 6190, + "parameters": [ + { "kind" : "InitializationModeQualifier", "name" : "'Trigger'" } + ], + "capabilities" : [ "GlobalVariableFPGADecorationsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "ImplementInRegisterMapINTEL", + "value" : 6191, + "parameters": [ + { "kind" : "LiteralInteger", "name" : "Value" } + ], + "capabilities" : [ "GlobalVariableFPGADecorationsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "CacheControlLoadINTEL", + "value" : 6442, + "capabilities" : [ "CacheControlsINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Cache Level'" }, + { "kind" : "LoadCacheControl", "name" : "'Cache Control'" } + ], + "version" : "None" + }, + { + "enumerant" : "CacheControlStoreINTEL", + "value" : 6443, + "capabilities" : [ "CacheControlsINTEL" ], + "parameters" : [ + { "kind" : "LiteralInteger", "name" : "'Cache Level'" }, + { "kind" : "StoreCacheControl", "name" : "'Cache Control'" } + ], + "version" : "None" } ] }, @@ -12527,235 +14632,276 @@ { "enumerant" : "Position", "value" : 0, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "PointSize", "value" : 1, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "ClipDistance", "value" : 3, - "capabilities" : [ "ClipDistance" ] + "capabilities" : [ "ClipDistance" ], + "version": "1.0" }, { "enumerant" : "CullDistance", "value" : 4, - "capabilities" : [ "CullDistance" ] + "capabilities" : [ "CullDistance" ], + "version": "1.0" }, { "enumerant" : "VertexId", "value" : 5, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "InstanceId", "value" : 6, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "PrimitiveId", "value" : 7, - "capabilities" : [ "Geometry", "Tessellation", "RayTracingNV", "RayTracingKHR", "MeshShadingNV", "MeshShadingEXT" ] + "capabilities" : [ "Geometry", "Tessellation", "RayTracingNV", "RayTracingKHR", "MeshShadingNV", "MeshShadingEXT" ], + "version": "1.0" }, { "enumerant" : "InvocationId", "value" : 8, - "capabilities" : [ "Geometry", "Tessellation" ] + "capabilities" : [ "Geometry", "Tessellation" ], + "version": "1.0" }, { "enumerant" : "Layer", "value" : 9, - "capabilities" : [ "Geometry", "ShaderLayer", "ShaderViewportIndexLayerEXT", "MeshShadingNV", "MeshShadingEXT" ] + "capabilities" : [ "Geometry", "ShaderLayer", "ShaderViewportIndexLayerEXT", "MeshShadingNV", "MeshShadingEXT" ], + "version": "1.0" }, { "enumerant" : "ViewportIndex", "value" : 10, - "capabilities" : [ "MultiViewport", "ShaderViewportIndex", "ShaderViewportIndexLayerEXT", "MeshShadingNV", "MeshShadingEXT" ] + "capabilities" : [ "MultiViewport", "ShaderViewportIndex", "ShaderViewportIndexLayerEXT", "MeshShadingNV", "MeshShadingEXT" ], + "version": "1.0" }, { "enumerant" : "TessLevelOuter", "value" : 11, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "TessLevelInner", "value" : 12, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "TessCoord", "value" : 13, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "PatchVertices", "value" : 14, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "FragCoord", "value" : 15, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "PointCoord", "value" : 16, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "FrontFacing", "value" : 17, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SampleId", "value" : 18, - "capabilities" : [ "SampleRateShading" ] + "capabilities" : [ "SampleRateShading" ], + "version": "1.0" }, { "enumerant" : "SamplePosition", "value" : 19, - "capabilities" : [ "SampleRateShading" ] + "capabilities" : [ "SampleRateShading" ], + "version": "1.0" }, { "enumerant" : "SampleMask", "value" : 20, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "FragDepth", "value" : 22, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "HelperInvocation", "value" : 23, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "NumWorkgroups", - "value" : 24 + "value" : 24, + "version" : "1.0" }, { "enumerant" : "WorkgroupSize", - "value" : 25 + "value" : 25, + "version" : "1.0" }, { "enumerant" : "WorkgroupId", - "value" : 26 + "value" : 26, + "version" : "1.0" }, { "enumerant" : "LocalInvocationId", - "value" : 27 + "value" : 27, + "version" : "1.0" }, { "enumerant" : "GlobalInvocationId", - "value" : 28 + "value" : 28, + "version" : "1.0" }, { "enumerant" : "LocalInvocationIndex", - "value" : 29 + "value" : 29, + "version" : "1.0" }, { "enumerant" : "WorkDim", "value" : 30, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "GlobalSize", "value" : 31, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "EnqueuedWorkgroupSize", "value" : 32, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "GlobalOffset", "value" : 33, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "GlobalLinearId", "value" : 34, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "SubgroupSize", "value" : 36, - "capabilities" : [ "Kernel", "GroupNonUniform", "SubgroupBallotKHR" ] + "capabilities" : [ "Kernel", "GroupNonUniform", "SubgroupBallotKHR" ], + "version": "1.0" }, { "enumerant" : "SubgroupMaxSize", "value" : 37, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "NumSubgroups", "value" : 38, - "capabilities" : [ "Kernel", "GroupNonUniform" ] + "capabilities" : [ "Kernel", "GroupNonUniform" ], + "version": "1.0" }, { "enumerant" : "NumEnqueuedSubgroups", "value" : 39, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "SubgroupId", "value" : 40, - "capabilities" : [ "Kernel", "GroupNonUniform" ] + "capabilities" : [ "Kernel", "GroupNonUniform" ], + "version": "1.0" }, { "enumerant" : "SubgroupLocalInvocationId", "value" : 41, - "capabilities" : [ "Kernel", "GroupNonUniform", "SubgroupBallotKHR" ] + "capabilities" : [ "Kernel", "GroupNonUniform", "SubgroupBallotKHR" ], + "version": "1.0" }, { "enumerant" : "VertexIndex", "value" : 42, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "InstanceIndex", "value" : 43, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "CoreIDARM", "value" : 4160, - "capabilities" : [ "CoreBuiltinsARM" ] + "capabilities" : [ "CoreBuiltinsARM" ], + "version": "1.0" }, { "enumerant" : "CoreCountARM", "value" : 4161, - "capabilities" : [ "CoreBuiltinsARM" ] + "capabilities" : [ "CoreBuiltinsARM" ], + "version": "1.0" }, { "enumerant" : "CoreMaxIDARM", "value" : 4162, - "capabilities" : [ "CoreBuiltinsARM" ] + "capabilities" : [ "CoreBuiltinsARM" ], + "version": "1.0" }, { "enumerant" : "WarpIDARM", "value" : 4163, - "capabilities" : [ "CoreBuiltinsARM" ] + "capabilities" : [ "CoreBuiltinsARM" ], + "version": "1.0" }, { "enumerant" : "WarpMaxIDARM", "value" : 4164, - "capabilities" : [ "CoreBuiltinsARM" ] + "capabilities" : [ "CoreBuiltinsARM" ], + "version": "1.0" }, { "enumerant" : "SubgroupEqMask", - "value" : 4416, - "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], - "version" : "1.3" - }, - { - "enumerant" : "SubgroupEqMaskKHR", + "aliases" : ["SubgroupEqMaskKHR"], "value" : 4416, "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], "extensions" : [ "SPV_KHR_shader_ballot" ], @@ -12763,12 +14909,7 @@ }, { "enumerant" : "SubgroupGeMask", - "value" : 4417, - "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], - "version" : "1.3" - }, - { - "enumerant" : "SubgroupGeMaskKHR", + "aliases" : ["SubgroupGeMaskKHR"], "value" : 4417, "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], "extensions" : [ "SPV_KHR_shader_ballot" ], @@ -12776,12 +14917,7 @@ }, { "enumerant" : "SubgroupGtMask", - "value" : 4418, - "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], - "version" : "1.3" - }, - { - "enumerant" : "SubgroupGtMaskKHR", + "aliases" : ["SubgroupGtMaskKHR"], "value" : 4418, "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], "extensions" : [ "SPV_KHR_shader_ballot" ], @@ -12789,12 +14925,7 @@ }, { "enumerant" : "SubgroupLeMask", - "value" : 4419, - "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], - "version" : "1.3" - }, - { - "enumerant" : "SubgroupLeMaskKHR", + "aliases" : ["SubgroupLeMaskKHR"], "value" : 4419, "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], "extensions" : [ "SPV_KHR_shader_ballot" ], @@ -12802,12 +14933,7 @@ }, { "enumerant" : "SubgroupLtMask", - "value" : 4420, - "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], - "version" : "1.3" - }, - { - "enumerant" : "SubgroupLtMaskKHR", + "aliases" : ["SubgroupLtMaskKHR"], "value" : 4420, "capabilities" : [ "SubgroupBallotKHR", "GroupNonUniformBallot" ], "extensions" : [ "SPV_KHR_shader_ballot" ], @@ -12911,6 +15037,20 @@ "extensions" : [ "SPV_EXT_shader_stencil_export" ], "version" : "None" }, + { + "enumerant" : "RemainingRecursionLevelsAMDX", + "value" : 5021, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "ShaderIndexAMDX", + "value" : 5073, + "capabilities" : [ "ShaderEnqueueAMDX" ], + "provisional" : true, + "version" : "None" + }, { "enumerant" : "ViewportMaskNV", "value" : 5253, @@ -13011,60 +15151,36 @@ }, { "enumerant" : "BaryCoordKHR", + "aliases" : ["BaryCoordNV"], "value" : 5286, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], - "version" : "None" - }, - { - "enumerant" : "BaryCoordNV", - "value" : 5286, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "capabilities" : [ "FragmentBarycentricKHR" ], "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { "enumerant" : "BaryCoordNoPerspKHR", + "aliases" : ["BaryCoordNoPerspNV"], "value" : 5287, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], - "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], - "version" : "None" - }, - { - "enumerant" : "BaryCoordNoPerspNV", - "value" : 5287, - "capabilities" : [ "FragmentBarycentricNV", "FragmentBarycentricKHR" ], + "capabilities" : [ "FragmentBarycentricKHR" ], "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { "enumerant" : "FragSizeEXT", + "aliases" : ["FragmentSizeNV"], "value" : 5292 , - "capabilities" : [ "FragmentDensityEXT", "ShadingRateNV" ], + "capabilities" : [ "FragmentDensityEXT" ], "extensions" : [ "SPV_EXT_fragment_invocation_density", "SPV_NV_shading_rate" ], "version" : "None" }, - { - "enumerant" : "FragmentSizeNV", - "value" : 5292 , - "capabilities" : [ "ShadingRateNV", "FragmentDensityEXT" ], - "extensions" : [ "SPV_NV_shading_rate", "SPV_EXT_fragment_invocation_density" ], - "version" : "None" - }, { "enumerant" : "FragInvocationCountEXT", + "aliases" : ["InvocationsPerPixelNV"], "value" : 5293, - "capabilities" : [ "FragmentDensityEXT", "ShadingRateNV" ], + "capabilities" : [ "FragmentDensityEXT" ], "extensions" : [ "SPV_EXT_fragment_invocation_density", "SPV_NV_shading_rate" ], "version" : "None" }, - { - "enumerant" : "InvocationsPerPixelNV", - "value" : 5293, - "capabilities" : [ "ShadingRateNV", "FragmentDensityEXT" ], - "extensions" : [ "SPV_NV_shading_rate", "SPV_EXT_fragment_invocation_density" ], - "version" : "None" - }, { "enumerant" : "PrimitivePointIndicesEXT", "value" : 5294, @@ -13093,155 +15209,89 @@ "extensions" : [ "SPV_EXT_mesh_shader" ], "version" : "None" }, - { - "enumerant" : "LaunchIdNV", - "value" : 5319, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "LaunchIdKHR", + "aliases" : ["LaunchIdNV"], "value" : 5319, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "LaunchSizeNV", - "value" : 5320, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "LaunchSizeKHR", + "aliases" : ["LaunchSizeNV"], "value" : 5320, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "WorldRayOriginNV", - "value" : 5321, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "WorldRayOriginKHR", + "aliases" : ["WorldRayOriginNV"], "value" : 5321, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "WorldRayDirectionNV", - "value" : 5322, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "WorldRayDirectionKHR", + "aliases" : ["WorldRayDirectionNV"], "value" : 5322, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "ObjectRayOriginNV", - "value" : 5323, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "ObjectRayOriginKHR", + "aliases" : ["ObjectRayOriginNV"], "value" : 5323, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "ObjectRayDirectionNV", - "value" : 5324, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "ObjectRayDirectionKHR", + "aliases" : ["ObjectRayDirectionNV"], "value" : 5324, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "RayTminNV", - "value" : 5325, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "RayTminKHR", + "aliases" : ["RayTminNV"], "value" : 5325, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "RayTmaxNV", - "value" : 5326, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "RayTmaxKHR", + "aliases" : ["RayTmaxNV"], "value" : 5326, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "InstanceCustomIndexNV", - "value" : 5327, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "InstanceCustomIndexKHR", + "aliases" : ["InstanceCustomIndexNV"], "value" : 5327, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "ObjectToWorldNV", - "value" : 5330, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "ObjectToWorldKHR", + "aliases" : ["ObjectToWorldNV"], "value" : 5330, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "WorldToObjectNV", - "value" : 5331, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "WorldToObjectKHR", + "aliases" : ["WorldToObjectNV"], "value" : 5331, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], @@ -13254,15 +15304,9 @@ "extensions" : [ "SPV_NV_ray_tracing" ], "version" : "None" }, - { - "enumerant" : "HitKindNV", - "value" : 5333, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], - "version" : "None" - }, { "enumerant" : "HitKindKHR", + "aliases" : ["HitKindNV"], "value" : 5333, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], @@ -13276,14 +15320,26 @@ "version" : "None" }, { - "enumerant" : "IncomingRayFlagsNV", - "value" : 5351, - "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], - "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], + "enumerant" : "HitTriangleVertexPositionsKHR", + "value" : 5335, + "capabilities" : [ "RayTracingPositionFetchKHR" ], + "version" : "None" + }, + { + "enumerant" : "HitMicroTriangleVertexPositionsNV", + "value" : 5337, + "capabilities" : [ "RayTracingDisplacementMicromapNV" ], + "version" : "None" + }, + { + "enumerant" : "HitMicroTriangleVertexBarycentricsNV", + "value" : 5344, + "capabilities" : [ "RayTracingDisplacementMicromapNV" ], "version" : "None" }, { "enumerant" : "IncomingRayFlagsKHR", + "aliases" : ["IncomingRayFlagsNV"], "value" : 5351, "capabilities" : [ "RayTracingNV" , "RayTracingKHR" ], "extensions" : [ "SPV_NV_ray_tracing" , "SPV_KHR_ray_tracing" ], @@ -13296,6 +15352,27 @@ "extensions" : [ "SPV_KHR_ray_tracing" ], "version" : "None" }, + { + "enumerant" : "HitIsSphereNV", + "value" : 5359, + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "HitIsLSSNV", + "value" : 5360, + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "HitSpherePositionNV", + "value" : 5361, + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, { "enumerant" : "WarpsPerSMNV", "value" : 5374, @@ -13324,6 +15401,46 @@ "extensions" : [ "SPV_NV_shader_sm_builtins" ], "version" : "None" }, + { + "enumerant" : "HitLSSPositionsNV", + "value" : 5396, + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "HitKindFrontFacingMicroTriangleNV", + "value" : 5405, + "capabilities" : [ "RayTracingDisplacementMicromapNV" ], + "version" : "None" + }, + { + "enumerant" : "HitKindBackFacingMicroTriangleNV", + "value" : 5406, + "capabilities" : [ "RayTracingDisplacementMicromapNV" ], + "version" : "None" + }, + { + "enumerant" : "HitSphereRadiusNV", + "value" : 5420, + "capabilities" : [ "RayTracingSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "HitLSSRadiiNV", + "value" : 5421, + "capabilities" : [ "RayTracingLinearSweptSpheresGeometryNV" ], + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "ClusterIDNV", + "value" : 5436, + "capabilities" : [ "RayTracingClusterAccelerationStructureNV" ], + "extensions" : [ "SPV_NV_cluster_acceleration_structure" ], + "version" : "None" + }, { "enumerant" : "CullMaskKHR", "value" : 6021, @@ -13339,32 +15456,32 @@ "enumerants" : [ { "enumerant" : "CrossDevice", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "Device", - "value" : 1 + "value" : 1, + "version" : "1.0" }, { "enumerant" : "Workgroup", - "value" : 2 + "value" : 2, + "version" : "1.0" }, { "enumerant" : "Subgroup", - "value" : 3 + "value" : 3, + "version" : "1.0" }, { "enumerant" : "Invocation", - "value" : 4 + "value" : 4, + "version" : "1.0" }, { "enumerant" : "QueueFamily", - "value" : 5, - "capabilities" : [ "VulkanMemoryModel" ], - "version" : "1.5" - }, - { - "enumerant" : "QueueFamilyKHR", + "aliases" : ["QueueFamilyKHR"], "value" : 5, "capabilities" : [ "VulkanMemoryModel" ], "version" : "1.5" @@ -13384,17 +15501,20 @@ { "enumerant" : "Reduce", "value" : 0, - "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ] + "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ], + "version": "1.0" }, { "enumerant" : "InclusiveScan", "value" : 1, - "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ] + "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ], + "version": "1.0" }, { "enumerant" : "ExclusiveScan", "value" : 2, - "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ] + "capabilities" : [ "Kernel", "GroupNonUniformArithmetic", "GroupNonUniformBallot" ], + "version": "1.0" }, { "enumerant" : "ClusteredReduce", @@ -13432,17 +15552,20 @@ { "enumerant" : "NoWait", "value" : 0, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "WaitKernel", "value" : 1, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "WaitWorkGroup", "value" : 2, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" } ] }, @@ -13452,272 +15575,328 @@ "enumerants" : [ { "enumerant" : "Matrix", - "value" : 0 + "value" : 0, + "version" : "1.0" }, { "enumerant" : "Shader", "value" : 1, - "capabilities" : [ "Matrix" ] + "capabilities" : [ "Matrix" ], + "version": "1.0" }, { "enumerant" : "Geometry", "value" : 2, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Tessellation", "value" : 3, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Addresses", - "value" : 4 + "value" : 4, + "version" : "1.0" }, { "enumerant" : "Linkage", - "value" : 5 + "value" : 5, + "version" : "1.0" }, { "enumerant" : "Kernel", - "value" : 6 + "value" : 6, + "version" : "1.0" }, { "enumerant" : "Vector16", "value" : 7, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Float16Buffer", "value" : 8, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Float16", - "value" : 9 + "value" : 9, + "version" : "1.0" }, { "enumerant" : "Float64", - "value" : 10 + "value" : 10, + "version" : "1.0" }, { "enumerant" : "Int64", - "value" : 11 + "value" : 11, + "version" : "1.0" }, { "enumerant" : "Int64Atomics", "value" : 12, - "capabilities" : [ "Int64" ] + "capabilities" : [ "Int64" ], + "version": "1.0" }, { "enumerant" : "ImageBasic", "value" : 13, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "ImageReadWrite", "value" : 14, - "capabilities" : [ "ImageBasic" ] + "capabilities" : [ "ImageBasic" ], + "version": "1.0" }, { "enumerant" : "ImageMipmap", "value" : 15, - "capabilities" : [ "ImageBasic" ] + "capabilities" : [ "ImageBasic" ], + "version": "1.0" }, { "enumerant" : "Pipes", "value" : 17, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "Groups", "value" : 18, - "extensions" : [ "SPV_AMD_shader_ballot" ] + "extensions" : [ "SPV_AMD_shader_ballot" ], + "version": "1.0" }, { "enumerant" : "DeviceEnqueue", "value" : 19, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "LiteralSampler", "value" : 20, - "capabilities" : [ "Kernel" ] + "capabilities" : [ "Kernel" ], + "version": "1.0" }, { "enumerant" : "AtomicStorage", "value" : 21, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Int16", - "value" : 22 + "value" : 22, + "version" : "1.0" }, { "enumerant" : "TessellationPointSize", "value" : 23, - "capabilities" : [ "Tessellation" ] + "capabilities" : [ "Tessellation" ], + "version": "1.0" }, { "enumerant" : "GeometryPointSize", "value" : 24, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "ImageGatherExtended", "value" : 25, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "StorageImageMultisample", "value" : 27, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "UniformBufferArrayDynamicIndexing", "value" : 28, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SampledImageArrayDynamicIndexing", "value" : 29, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "StorageBufferArrayDynamicIndexing", "value" : 30, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "StorageImageArrayDynamicIndexing", "value" : 31, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "ClipDistance", "value" : 32, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "CullDistance", "value" : 33, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "ImageCubeArray", "value" : 34, - "capabilities" : [ "SampledCubeArray" ] + "capabilities" : [ "SampledCubeArray" ], + "version": "1.0" }, { "enumerant" : "SampleRateShading", "value" : 35, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "ImageRect", "value" : 36, - "capabilities" : [ "SampledRect" ] + "capabilities" : [ "SampledRect" ], + "version": "1.0" }, { "enumerant" : "SampledRect", "value" : 37, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "GenericPointer", "value" : 38, - "capabilities" : [ "Addresses" ] + "capabilities" : [ "Addresses" ], + "version": "1.0" }, { "enumerant" : "Int8", - "value" : 39 + "value" : 39, + "version" : "1.0" }, { "enumerant" : "InputAttachment", "value" : 40, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SparseResidency", "value" : 41, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "MinLod", "value" : 42, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "Sampled1D", - "value" : 43 + "value" : 43, + "version" : "1.0" }, { "enumerant" : "Image1D", "value" : 44, - "capabilities" : [ "Sampled1D" ] + "capabilities" : [ "Sampled1D" ], + "version": "1.0" }, { "enumerant" : "SampledCubeArray", "value" : 45, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "SampledBuffer", - "value" : 46 + "value" : 46, + "version" : "1.0" }, { "enumerant" : "ImageBuffer", "value" : 47, - "capabilities" : [ "SampledBuffer" ] + "capabilities" : [ "SampledBuffer" ], + "version": "1.0" }, { "enumerant" : "ImageMSArray", "value" : 48, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "StorageImageExtendedFormats", "value" : 49, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "ImageQuery", "value" : 50, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "DerivativeControl", "value" : 51, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "InterpolationFunction", "value" : 52, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "TransformFeedback", "value" : 53, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "GeometryStreams", "value" : 54, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "StorageImageReadWithoutFormat", "value" : 55, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "StorageImageWriteWithoutFormat", "value" : 56, - "capabilities" : [ "Shader" ] + "capabilities" : [ "Shader" ], + "version": "1.0" }, { "enumerant" : "MultiViewport", "value" : 57, - "capabilities" : [ "Geometry" ] + "capabilities" : [ "Geometry" ], + "version": "1.0" }, { "enumerant" : "SubgroupDispatch", @@ -13802,7 +15981,32 @@ { "enumerant" : "CoreBuiltinsARM", "value" : 4165, - "extensions" : [ "SPV_ARM_core_builtins" ] + "extensions" : [ "SPV_ARM_core_builtins" ], + "version": "None" + }, + { + "enumerant" : "TileImageColorReadAccessEXT", + "value" : 4166, + "extensions" : [ "SPV_EXT_shader_tile_image" ], + "version" : "None" + }, + { + "enumerant" : "TileImageDepthReadAccessEXT", + "value" : 4167, + "extensions" : [ "SPV_EXT_shader_tile_image" ], + "version" : "None" + }, + { + "enumerant" : "TileImageStencilReadAccessEXT", + "value" : 4168, + "extensions" : [ "SPV_EXT_shader_tile_image" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixLayoutsARM", + "value" : 4201, + "extensions" : [ "SPV_ARM_cooperative_matrix_layouts" ], + "version" : "None" }, { "enumerant" : "FragmentShadingRateKHR", @@ -13841,7 +16045,7 @@ { "enumerant" : "WorkgroupMemoryExplicitLayout16BitAccessKHR", "value" : 4430, - "capabilities" : [ "Shader" ], + "capabilities" : [ "WorkgroupMemoryExplicitLayoutKHR" ], "extensions" : [ "SPV_KHR_workgroup_memory_explicit_layout" ], "version" : "None" }, @@ -13853,33 +16057,16 @@ }, { "enumerant" : "StorageBuffer16BitAccess", - "value" : 4433, - "extensions" : [ "SPV_KHR_16bit_storage" ], - "version" : "1.3" - }, - { - "enumerant" : "StorageUniformBufferBlock16", + "aliases" : ["StorageUniformBufferBlock16"], "value" : 4433, "extensions" : [ "SPV_KHR_16bit_storage" ], "version" : "1.3" }, { "enumerant" : "UniformAndStorageBuffer16BitAccess", + "aliases" : ["StorageUniform16"], "value" : 4434, - "capabilities" : [ - "StorageBuffer16BitAccess", - "StorageUniformBufferBlock16" - ], - "extensions" : [ "SPV_KHR_16bit_storage" ], - "version" : "1.3" - }, - { - "enumerant" : "StorageUniform16", - "value" : 4434, - "capabilities" : [ - "StorageBuffer16BitAccess", - "StorageUniformBufferBlock16" - ], + "capabilities" : [ "StorageBuffer16BitAccess" ], "extensions" : [ "SPV_KHR_16bit_storage" ], "version" : "1.3" }, @@ -13997,6 +16184,13 @@ "extensions" : [ "SPV_KHR_ray_query" ], "version" : "None" }, + { + "enumerant" : "UntypedPointersKHR", + "value" : 4473, + "extensions" : [ "SPV_KHR_untyped_pointers" ], + "provisional" : true, + "version" : "None" + }, { "enumerant" : "RayTraversalPrimitiveCullingKHR", "value" : 4478, @@ -14011,6 +16205,30 @@ "extensions" : [ "SPV_KHR_ray_tracing" ], "version" : "None" }, + { + "enumerant" : "TextureSampleWeightedQCOM", + "value" : 4484, + "extensions" : [ "SPV_QCOM_image_processing" ], + "version" : "None" + }, + { + "enumerant" : "TextureBoxFilterQCOM", + "value" : 4485, + "extensions" : [ "SPV_QCOM_image_processing" ], + "version" : "None" + }, + { + "enumerant" : "TextureBlockMatchQCOM", + "value" : 4486, + "extensions" : [ "SPV_QCOM_image_processing" ], + "version" : "None" + }, + { + "enumerant" : "TextureBlockMatch2QCOM", + "value" : 4498, + "extensions" : [ "SPV_QCOM_image_processing2" ], + "version" : "None" + }, { "enumerant" : "Float16ImageAMD", "value" : 5008, @@ -14056,10 +16274,23 @@ { "enumerant" : "ShaderClockKHR", "value" : 5055, - "capabilities" : [ "Shader" ], "extensions" : [ "SPV_KHR_shader_clock" ], "version" : "None" }, + { + "enumerant" : "ShaderEnqueueAMDX", + "value" : 5067, + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_AMDX_shader_enqueue" ], + "provisional" : true, + "version" : "None" + }, + { + "enumerant" : "QuadControlKHR", + "value" : 5087, + "extensions" : [ "SPV_KHR_quad_control" ], + "version" : "None" + }, { "enumerant" : "SampleMaskOverrideCoverageNV", "value" : 5249, @@ -14076,22 +16307,16 @@ }, { "enumerant" : "ShaderViewportIndexLayerEXT", + "aliases" : ["ShaderViewportIndexLayerNV"], "value" : 5254, "capabilities" : [ "MultiViewport" ], - "extensions" : [ "SPV_EXT_shader_viewport_index_layer" ], - "version" : "None" - }, - { - "enumerant" : "ShaderViewportIndexLayerNV", - "value" : 5254, - "capabilities" : [ "MultiViewport" ], - "extensions" : [ "SPV_NV_viewport_array2" ], + "extensions" : [ "SPV_EXT_shader_viewport_index_layer", "SPV_NV_viewport_array2" ], "version" : "None" }, { "enumerant" : "ShaderViewportMaskNV", "value" : 5255, - "capabilities" : [ "ShaderViewportIndexLayerNV" ], + "capabilities" : [ "ShaderViewportIndexLayerEXT" ], "extensions" : [ "SPV_NV_viewport_array2" ], "version" : "None" }, @@ -14138,36 +16363,27 @@ }, { "enumerant" : "FragmentBarycentricKHR", + "aliases" : ["FragmentBarycentricNV"], "value" : 5284, "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], "version" : "None" }, { - "enumerant" : "FragmentBarycentricNV", - "value" : 5284, - "extensions" : [ "SPV_NV_fragment_shader_barycentric", "SPV_KHR_fragment_shader_barycentric" ], - "version" : "None" - }, - { - "enumerant" : "ComputeDerivativeGroupQuadsNV", + "enumerant" : "ComputeDerivativeGroupQuadsKHR", + "aliases" : ["ComputeDerivativeGroupQuadsNV"], "value" : 5288, - "extensions" : [ "SPV_NV_compute_shader_derivatives" ], + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_NV_compute_shader_derivatives", "SPV_KHR_compute_shader_derivatives" ], "version" : "None" }, { "enumerant" : "FragmentDensityEXT", + "aliases" : ["ShadingRateNV"], "value" : 5291, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_fragment_invocation_density", "SPV_NV_shading_rate" ], "version" : "None" }, - { - "enumerant" : "ShadingRateNV", - "value" : 5291, - "capabilities" : [ "Shader" ], - "extensions" : [ "SPV_NV_shading_rate", "SPV_EXT_fragment_invocation_density" ], - "version" : "None" - }, { "enumerant" : "GroupNonUniformPartitionedNV", "value" : 5297, @@ -14176,12 +16392,7 @@ }, { "enumerant" : "ShaderNonUniform", - "value" : 5301, - "capabilities" : [ "Shader" ], - "version" : "1.5" - }, - { - "enumerant" : "ShaderNonUniformEXT", + "aliases" : ["ShaderNonUniformEXT"], "value" : 5301, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14189,12 +16400,7 @@ }, { "enumerant" : "RuntimeDescriptorArray", - "value" : 5302, - "capabilities" : [ "Shader" ], - "version" : "1.5" - }, - { - "enumerant" : "RuntimeDescriptorArrayEXT", + "aliases" : ["RuntimeDescriptorArrayEXT"], "value" : 5302, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14202,12 +16408,7 @@ }, { "enumerant" : "InputAttachmentArrayDynamicIndexing", - "value" : 5303, - "capabilities" : [ "InputAttachment" ], - "version" : "1.5" - }, - { - "enumerant" : "InputAttachmentArrayDynamicIndexingEXT", + "aliases" : ["InputAttachmentArrayDynamicIndexingEXT"], "value" : 5303, "capabilities" : [ "InputAttachment" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14215,12 +16416,7 @@ }, { "enumerant" : "UniformTexelBufferArrayDynamicIndexing", - "value" : 5304, - "capabilities" : [ "SampledBuffer" ], - "version" : "1.5" - }, - { - "enumerant" : "UniformTexelBufferArrayDynamicIndexingEXT", + "aliases" : ["UniformTexelBufferArrayDynamicIndexingEXT"], "value" : 5304, "capabilities" : [ "SampledBuffer" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14228,12 +16424,7 @@ }, { "enumerant" : "StorageTexelBufferArrayDynamicIndexing", - "value" : 5305, - "capabilities" : [ "ImageBuffer" ], - "version" : "1.5" - }, - { - "enumerant" : "StorageTexelBufferArrayDynamicIndexingEXT", + "aliases" : ["StorageTexelBufferArrayDynamicIndexingEXT"], "value" : 5305, "capabilities" : [ "ImageBuffer" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14241,12 +16432,7 @@ }, { "enumerant" : "UniformBufferArrayNonUniformIndexing", - "value" : 5306, - "capabilities" : [ "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "UniformBufferArrayNonUniformIndexingEXT", + "aliases" : ["UniformBufferArrayNonUniformIndexingEXT"], "value" : 5306, "capabilities" : [ "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14254,12 +16440,7 @@ }, { "enumerant" : "SampledImageArrayNonUniformIndexing", - "value" : 5307, - "capabilities" : [ "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "SampledImageArrayNonUniformIndexingEXT", + "aliases" : ["SampledImageArrayNonUniformIndexingEXT"], "value" : 5307, "capabilities" : [ "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14267,12 +16448,7 @@ }, { "enumerant" : "StorageBufferArrayNonUniformIndexing", - "value" : 5308, - "capabilities" : [ "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "StorageBufferArrayNonUniformIndexingEXT", + "aliases" : ["StorageBufferArrayNonUniformIndexingEXT"], "value" : 5308, "capabilities" : [ "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14280,12 +16456,7 @@ }, { "enumerant" : "StorageImageArrayNonUniformIndexing", - "value" : 5309, - "capabilities" : [ "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "StorageImageArrayNonUniformIndexingEXT", + "aliases" : ["StorageImageArrayNonUniformIndexingEXT"], "value" : 5309, "capabilities" : [ "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14293,12 +16464,7 @@ }, { "enumerant" : "InputAttachmentArrayNonUniformIndexing", - "value" : 5310, - "capabilities" : [ "InputAttachment", "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "InputAttachmentArrayNonUniformIndexingEXT", + "aliases" : ["InputAttachmentArrayNonUniformIndexingEXT"], "value" : 5310, "capabilities" : [ "InputAttachment", "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14306,12 +16472,7 @@ }, { "enumerant" : "UniformTexelBufferArrayNonUniformIndexing", - "value" : 5311, - "capabilities" : [ "SampledBuffer", "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "UniformTexelBufferArrayNonUniformIndexingEXT", + "aliases" : ["UniformTexelBufferArrayNonUniformIndexingEXT"], "value" : 5311, "capabilities" : [ "SampledBuffer", "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], @@ -14319,17 +16480,19 @@ }, { "enumerant" : "StorageTexelBufferArrayNonUniformIndexing", - "value" : 5312, - "capabilities" : [ "ImageBuffer", "ShaderNonUniform" ], - "version" : "1.5" - }, - { - "enumerant" : "StorageTexelBufferArrayNonUniformIndexingEXT", + "aliases" : ["StorageTexelBufferArrayNonUniformIndexingEXT"], "value" : 5312, "capabilities" : [ "ImageBuffer", "ShaderNonUniform" ], "extensions" : [ "SPV_EXT_descriptor_indexing" ], "version" : "1.5" }, + { + "enumerant" : "RayTracingPositionFetchKHR", + "value" : 5336, + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_KHR_ray_tracing_position_fetch" ], + "version" : "None" + }, { "enumerant" : "RayTracingNV", "value" : 5340, @@ -14346,44 +16509,32 @@ }, { "enumerant" : "VulkanMemoryModel", - "value" : 5345, - "version" : "1.5" - }, - { - "enumerant" : "VulkanMemoryModelKHR", + "aliases" : ["VulkanMemoryModelKHR"], "value" : 5345, "extensions" : [ "SPV_KHR_vulkan_memory_model" ], "version" : "1.5" }, { "enumerant" : "VulkanMemoryModelDeviceScope", - "value" : 5346, - "version" : "1.5" - }, - { - "enumerant" : "VulkanMemoryModelDeviceScopeKHR", + "aliases" : ["VulkanMemoryModelDeviceScopeKHR"], "value" : 5346, "extensions" : [ "SPV_KHR_vulkan_memory_model" ], "version" : "1.5" }, { "enumerant" : "PhysicalStorageBufferAddresses", + "aliases" : ["PhysicalStorageBufferAddressesEXT"], "value" : 5347, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_physical_storage_buffer", "SPV_KHR_physical_storage_buffer" ], "version" : "1.5" }, { - "enumerant" : "PhysicalStorageBufferAddressesEXT", - "value" : 5347, - "capabilities" : [ "Shader" ], - "extensions" : [ "SPV_EXT_physical_storage_buffer" ], - "version" : "1.5" - }, - { - "enumerant" : "ComputeDerivativeGroupLinearNV", + "enumerant" : "ComputeDerivativeGroupLinearKHR", + "aliases" : ["ComputeDerivativeGroupLinearNV"], "value" : 5350, - "extensions" : [ "SPV_NV_compute_shader_derivatives" ], + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_NV_compute_shader_derivatives", "SPV_KHR_compute_shader_derivatives" ], "version" : "None" }, { @@ -14430,17 +16581,19 @@ }, { "enumerant" : "DemoteToHelperInvocation", - "value" : 5379, - "capabilities" : [ "Shader" ], - "version" : "1.6" - }, - { - "enumerant" : "DemoteToHelperInvocationEXT", + "aliases" : ["DemoteToHelperInvocationEXT"], "value" : 5379, "capabilities" : [ "Shader" ], "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ], "version" : "1.6" }, + { + "enumerant" : "DisplacementMicromapNV", + "value" : 5380, + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_NV_displacement_micromap" ], + "version" : "None" + }, { "enumerant" : "RayTracingOpacityMicromapEXT", "value" : 5381, @@ -14461,6 +16614,99 @@ "extensions" : [ "SPV_NV_bindless_texture" ], "version" : "None" }, + { + "enumerant" : "RayQueryPositionFetchKHR", + "value" : 5391, + "capabilities" : [ "Shader" ], + "extensions" : [ "SPV_KHR_ray_tracing_position_fetch" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeVectorNV", + "value" : 5394, + "extensions" : [ "SPV_NV_cooperative_vector" ], + "version" : "None" + }, + { + "enumerant" : "AtomicFloat16VectorNV", + "value" : 5404, + "extensions" : [ "SPV_NV_shader_atomic_fp16_vector" ], + "version" : "None" + }, + { + "enumerant" : "RayTracingDisplacementMicromapNV", + "value" : 5409, + "capabilities" : [ "RayTracingKHR" ], + "extensions" : [ "SPV_NV_displacement_micromap" ], + "version" : "None" + }, + { + "enumerant" : "RawAccessChainsNV", + "value" : 5414, + "extensions" : [ "SPV_NV_raw_access_chains" ], + "version" : "None" + }, + { + "enumerant" : "RayTracingSpheresGeometryNV", + "value" : 5418, + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "RayTracingLinearSweptSpheresGeometryNV", + "value" : 5419, + "extensions" : [ "SPV_NV_linear_swept_spheres" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixReductionsNV", + "value" : 5430, + "extensions" : [ "SPV_NV_cooperative_matrix2" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixConversionsNV", + "value" : 5431, + "extensions" : [ "SPV_NV_cooperative_matrix2" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixPerElementOperationsNV", + "value" : 5432, + "extensions" : [ "SPV_NV_cooperative_matrix2" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixTensorAddressingNV", + "value" : 5433, + "extensions" : [ "SPV_NV_cooperative_matrix2" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeMatrixBlockLoadsNV", + "value" : 5434, + "extensions" : [ "SPV_NV_cooperative_matrix2" ], + "version" : "None" + }, + { + "enumerant" : "CooperativeVectorTrainingNV", + "value" : 5435, + "extensions" : [ "SPV_NV_cooperative_vector" ], + "version" : "None" + }, + { + "enumerant" : "RayTracingClusterAccelerationStructureNV", + "value" : 5437, + "capabilities" : [ "RayTracingKHR" ], + "extensions" : [ "SPV_NV_cluster_acceleration_structure" ], + "version" : "None" + }, + { + "enumerant" : "TensorAddressingNV", + "value" : 5439, + "extensions" : [ "SPV_NV_tensor_addressing" ], + "version" : "None" + }, { "enumerant" : "SubgroupShuffleINTEL", "value" : 5568, @@ -14500,7 +16746,6 @@ { "enumerant" : "IntegerFunctions2INTEL", "value" : 5584, - "capabilities" : [ "Shader" ], "extensions" : [ "SPV_INTEL_shader_integer_functions2" ], "version" : "None" }, @@ -14718,23 +16963,14 @@ }, { "enumerant" : "DotProductInputAll", - "value" : 6016, - "version" : "1.6" - }, - { - "enumerant" : "DotProductInputAllKHR", + "aliases" : ["DotProductInputAllKHR"], "value" : 6016, "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "enumerant" : "DotProductInput4x8Bit", - "value" : 6017, - "capabilities" : [ "Int8" ], - "version" : "1.6" - }, - { - "enumerant" : "DotProductInput4x8BitKHR", + "aliases" : ["DotProductInput4x8BitKHR"], "value" : 6017, "capabilities" : [ "Int8" ], "extensions" : [ "SPV_KHR_integer_dot_product" ], @@ -14742,22 +16978,14 @@ }, { "enumerant" : "DotProductInput4x8BitPacked", - "value" : 6018, - "version" : "1.6" - }, - { - "enumerant" : "DotProductInput4x8BitPackedKHR", + "aliases" : ["DotProductInput4x8BitPackedKHR"], "value" : 6018, "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" }, { "enumerant" : "DotProduct", - "value" : 6019, - "version" : "1.6" - }, - { - "enumerant" : "DotProductKHR", + "aliases" : ["DotProductKHR"], "value" : 6019, "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" @@ -14768,6 +16996,18 @@ "extensions" : [ "SPV_KHR_ray_cull_mask" ], "version" : "None" }, + { + "enumerant" : "CooperativeMatrixKHR", + "value" : 6022, + "extensions" : [ "SPV_KHR_cooperative_matrix" ], + "version" : "None" + }, + { + "enumerant" : "ReplicatedCompositesEXT", + "value" : 6024, + "extensions" : [ "SPV_EXT_replicated_composites" ], + "version" : "None" + }, { "enumerant" : "BitInstructions", "value" : 6025, @@ -14781,6 +17021,12 @@ "extensions" : [ "SPV_KHR_subgroup_rotate" ], "version" : "None" }, + { + "enumerant" : "FloatControls2", + "value" : 6029, + "extensions" : [ "SPV_KHR_float_controls2" ], + "version" : "None" + }, { "enumerant" : "AtomicFloat32AddEXT", "value" : 6033, @@ -14794,15 +17040,16 @@ "version" : "None" }, { - "enumerant" : "LongConstantCompositeINTEL", + "enumerant" : "LongCompositesINTEL", "value" : 6089, - "extensions" : [ "SPV_INTEL_long_constant_composite" ], + "extensions" : [ "SPV_INTEL_long_composites" ], "version" : "None" }, { - "enumerant" : "OptNoneINTEL", + "enumerant" : "OptNoneEXT", + "aliases" : ["OptNoneINTEL"], "value" : 6094, - "extensions" : [ "SPV_INTEL_optnone" ], + "extensions" : [ "SPV_EXT_optnone", "SPV_INTEL_optnone" ], "version" : "None" }, { @@ -14817,17 +17064,123 @@ "extensions" : [ "SPV_INTEL_debug_module" ], "version" : "None" }, + { + "enumerant" : "BFloat16ConversionINTEL", + "value" : 6115, + "extensions" : [ "SPV_INTEL_bfloat16_conversion" ], + "version" : "None" + }, { "enumerant" : "SplitBarrierINTEL", "value" : 6141, "extensions" : [ "SPV_INTEL_split_barrier" ], "version" : "None" }, + { + "enumerant" : "ArithmeticFenceEXT", + "value" : 6144, + "extensions" : [ "SPV_EXT_arithmetic_fence" ], + "version" : "None" + }, + { + "enumerant" : "FPGAClusterAttributesV2INTEL", + "value" : 6150, + "capabilities" : [ "FPGAClusterAttributesINTEL" ], + "extensions" : [ "SPV_INTEL_fpga_cluster_attributes" ], + "version" : "None" + }, + { + "enumerant" : "FPGAKernelAttributesv2INTEL", + "value" : 6161, + "capabilities" : [ "FPGAKernelAttributesINTEL" ], + "extensions" : [ "SPV_INTEL_kernel_attributes" ], + "version" : "None" + }, + { + "enumerant" : "FPMaxErrorINTEL", + "value" : 6169, + "extensions" : [ "SPV_INTEL_fp_max_error" ], + "version" : "None" + }, + { + "enumerant" : "FPGALatencyControlINTEL", + "value" : 6171, + "extensions" : [ "SPV_INTEL_fpga_latency_control" ], + "version" : "None" + }, + { + "enumerant" : "FPGAArgumentInterfacesINTEL", + "value" : 6174, + "extensions" : [ "SPV_INTEL_fpga_argument_interfaces" ], + "version" : "None" + }, + { + "enumerant" : "GlobalVariableHostAccessINTEL", + "value" : 6187, + "extensions": [ "SPV_INTEL_global_variable_host_access" ], + "version" : "None" + }, + { + "enumerant" : "GlobalVariableFPGADecorationsINTEL", + "value" : 6189, + "extensions": [ "SPV_INTEL_global_variable_fpga_decorations" ], + "version" : "None" + }, + { + "enumerant" : "SubgroupBufferPrefetchINTEL", + "value" : 6220, + "extensions": [ "SPV_INTEL_subgroup_buffer_prefetch" ], + "version" : "None" + }, + { + "enumerant" : "Subgroup2DBlockIOINTEL", + "value" : 6228, + "extensions": [ "SPV_INTEL_2d_block_io" ], + "version" : "None" + }, + { + "enumerant" : "Subgroup2DBlockTransformINTEL", + "value" : 6229, + "capabilities" : [ "Subgroup2DBlockIOINTEL" ], + "extensions": [ "SPV_INTEL_2d_block_io" ], + "version" : "None" + }, + { + "enumerant" : "Subgroup2DBlockTransposeINTEL", + "value" : 6230, + "capabilities" : [ "Subgroup2DBlockIOINTEL" ], + "extensions": [ "SPV_INTEL_2d_block_io" ], + "version" : "None" + }, + { + "enumerant" : "SubgroupMatrixMultiplyAccumulateINTEL", + "value" : 6236, + "extensions": [ "SPV_INTEL_subgroup_matrix_multiply_accumulate" ], + "version" : "None" + }, { "enumerant" : "GroupUniformArithmeticKHR", "value" : 6400, "extensions" : [ "SPV_KHR_uniform_group_instructions"], "version" : "None" + }, + { + "enumerant" : "MaskedGatherScatterINTEL", + "value" : 6427, + "extensions" : [ "SPV_INTEL_masked_gather_scatter"], + "version" : "None" + }, + { + "enumerant" : "CacheControlsINTEL", + "value" : 6441, + "extensions" : [ "SPV_INTEL_cache_controls" ], + "version" : "None" + }, + { + "enumerant" : "RegisterLimitsINTEL", + "value" : 6460, + "extensions" : [ "SPV_INTEL_maximum_registers" ], + "version" : "None" } ] }, @@ -14897,17 +17250,467 @@ "enumerants" : [ { "enumerant" : "PackedVectorFormat4x8Bit", - "value" : 0, - "version" : "1.6" - }, - { - "enumerant" : "PackedVectorFormat4x8BitKHR", + "aliases" : ["PackedVectorFormat4x8BitKHR"], "value" : 0, "extensions" : [ "SPV_KHR_integer_dot_product" ], "version" : "1.6" } ] }, + { + "category" : "BitEnum", + "kind" : "CooperativeMatrixOperands", + "enumerants" : [ + { + "enumerant" : "NoneKHR", + "value" : "0x0000", + "version" : "None" + }, + { + "enumerant" : "MatrixASignedComponentsKHR", + "value" : "0x0001", + "version" : "None" + }, + { + "enumerant" : "MatrixBSignedComponentsKHR", + "value" : "0x0002", + "version" : "None" + }, + { + "enumerant" : "MatrixCSignedComponentsKHR", + "value" : "0x0004", + "version" : "None" + }, + { + "enumerant" : "MatrixResultSignedComponentsKHR", + "value" : "0x0008", + "version" : "None" + }, + { + "enumerant" : "SaturatingAccumulationKHR", + "value" : "0x0010", + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "CooperativeMatrixLayout", + "enumerants" : [ + { + "enumerant" : "RowMajorKHR", + "value" : 0, + "version" : "None" + }, + { + "enumerant" : "ColumnMajorKHR", + "value" : 1, + "version" : "None" + }, + { + "enumerant" : "RowBlockedInterleavedARM", + "value" : 4202, + "version" : "None" + }, + { + "enumerant" : "ColumnBlockedInterleavedARM", + "value" : 4203, + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "CooperativeMatrixUse", + "enumerants" : [ + { + "enumerant" : "MatrixAKHR", + "value" : 0, + "version" : "None" + }, + { + "enumerant" : "MatrixBKHR", + "value" : 1, + "version" : "None" + }, + { + "enumerant" : "MatrixAccumulatorKHR", + "value" : 2, + "version" : "None" + } + ] + }, + { + "category" : "BitEnum", + "kind" : "CooperativeMatrixReduce", + "enumerants" : [ + { + "enumerant" : "Row", + "value" : "0x0001", + "version" : "None" + }, + { + "enumerant" : "Column", + "value" : "0x0002", + "version" : "None" + }, + { + "enumerant" : "2x2", + "value" : "0x0004", + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "TensorClampMode", + "enumerants" : [ + { + "enumerant" : "Undefined", + "value" : 0, + "version": "None" + }, + { + "enumerant" : "Constant", + "value" : 1, + "version": "None" + }, + { + "enumerant" : "ClampToEdge", + "value" : 2, + "version": "None" + }, + { + "enumerant" : "Repeat", + "value" : 3, + "version": "None" + }, + { + "enumerant" : "RepeatMirrored", + "value" : 4, + "version": "None" + } + ] + }, + { + "category" : "BitEnum", + "kind" : "TensorAddressingOperands", + "enumerants" : [ + { + "enumerant" : "None", + "value" : "0x0000", + "version" : "None" + }, + { + "enumerant" : "TensorView", + "value" : "0x0001", + "parameters" : [ + { "kind" : "IdRef" } + ], + "capabilities" : [ "CooperativeMatrixTensorAddressingNV" ], + "version" : "None" + }, + { + "enumerant" : "DecodeFunc", + "value" : "0x0002", + "parameters" : [ + { "kind" : "IdRef" } + ], + "capabilities" : [ "CooperativeMatrixBlockLoadsNV" ], + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "InitializationModeQualifier", + "enumerants" : [ + { + "enumerant" : "InitOnDeviceReprogramINTEL", + "value" : 0, + "capabilities" : [ "GlobalVariableFPGADecorationsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "InitOnDeviceResetINTEL", + "value" : 1, + "capabilities" : [ "GlobalVariableFPGADecorationsINTEL" ], + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "LoadCacheControl", + "enumerants" : [ + { + "enumerant" : "UncachedINTEL", + "value" : 0, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "CachedINTEL", + "value" : 1, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "StreamingINTEL", + "value" : 2, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "InvalidateAfterReadINTEL", + "value" : 3, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "ConstCachedINTEL", + "value" : 4, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "StoreCacheControl", + "enumerants" : [ + { + "enumerant" : "UncachedINTEL", + "value" : 0, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "WriteThroughINTEL", + "value" : 1, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "WriteBackINTEL", + "value" : 2, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + }, + { + "enumerant" : "StreamingINTEL", + "value" : 3, + "capabilities" : [ "CacheControlsINTEL" ], + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "NamedMaximumNumberOfRegisters", + "enumerants" : [ + { + "enumerant" : "AutoINTEL", + "value" : 0, + "capabilities" : [ "RegisterLimitsINTEL" ], + "version" : "None" + } + ] + }, + { + "category" : "BitEnum", + "kind" : "MatrixMultiplyAccumulateOperands", + "enumerants" : [ + { + "enumerant" : "None", + "value" : "0x0", + "version" : "None" + }, + { + "enumerant" : "MatrixASignedComponentsINTEL", + "value" : "0x1", + "version" : "None" + }, + { + "enumerant" : "MatrixBSignedComponentsINTEL", + "value" : "0x2", + "version" : "None" + }, + { + "enumerant" : "MatrixCBFloat16INTEL", + "value" : "0x4", + "version" : "None" + }, + { + "enumerant" : "MatrixResultBFloat16INTEL", + "value" : "0x8", + "version" : "None" + }, + { + "enumerant" : "MatrixAPackedInt8INTEL", + "value" : "0x10", + "version" : "None" + }, + { + "enumerant" : "MatrixBPackedInt8INTEL", + "value" : "0x20", + "version" : "None" + }, + { + "enumerant" : "MatrixAPackedInt4INTEL", + "value" : "0x40", + "version" : "None" + }, + { + "enumerant" : "MatrixBPackedInt4INTEL", + "value" : "0x80", + "version" : "None" + }, + { + "enumerant" : "MatrixATF32INTEL", + "value" : "0x100", + "version" : "None" + }, + { + "enumerant" : "MatrixBTF32INTEL", + "value" : "0x200", + "version" : "None" + }, + { + "enumerant" : "MatrixAPackedFloat16INTEL", + "value" : "0x400", + "version" : "None" + }, + { + "enumerant" : "MatrixBPackedFloat16INTEL", + "value" : "0x800", + "version" : "None" + }, + { + "enumerant" : "MatrixAPackedBFloat16INTEL", + "value" : "0x1000", + "version" : "None" + }, + { + "enumerant" : "MatrixBPackedBFloat16INTEL", + "value" : "0x2000", + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "FPEncoding", + "enumerants" : [ + ] + }, + { + "category" : "ValueEnum", + "kind" : "CooperativeVectorMatrixLayout", + "enumerants" : [ + { + "enumerant" : "RowMajorNV", + "value" : 0, + "version" : "None" + }, + { + "enumerant" : "ColumnMajorNV", + "value" : 1, + "version" : "None" + }, + { + "enumerant" : "InferencingOptimalNV", + "value" : 2, + "version" : "None" + }, + { + "enumerant" : "TrainingOptimalNV", + "value" : 3, + "version" : "None" + } + ] + }, + { + "category" : "ValueEnum", + "kind" : "ComponentType", + "enumerants" : [ + { + "enumerant" : "Float16NV", + "value" : 0, + "version" : "None" + }, + { + "enumerant" : "Float32NV", + "value" : 1, + "version" : "None" + }, + { + "enumerant" : "Float64NV", + "value" : 2, + "version" : "None" + }, + { + "enumerant" : "SignedInt8NV", + "value" : 3, + "version" : "None" + }, + { + "enumerant" : "SignedInt16NV", + "value" : 4, + "version" : "None" + }, + { + "enumerant" : "SignedInt32NV", + "value" : 5, + "version" : "None" + }, + { + "enumerant" : "SignedInt64NV", + "value" : 6, + "version" : "None" + }, + { + "enumerant" : "UnsignedInt8NV", + "value" : 7, + "version" : "None" + }, + { + "enumerant" : "UnsignedInt16NV", + "value" : 8, + "version" : "None" + }, + { + "enumerant" : "UnsignedInt32NV", + "value" : 9, + "version" : "None" + }, + { + "enumerant" : "UnsignedInt64NV", + "value" : 10, + "version" : "None" + }, + { + "enumerant" : "SignedInt8PackedNV", + "value" : 1000491000, + "version" : "None" + }, + { + "enumerant" : "UnsignedInt8PackedNV", + "value" : 1000491001, + "version" : "None" + }, + { + "enumerant" : "FloatE4M3NV", + "value" : 1000491002, + "version" : "None" + }, + { + "enumerant" : "FloatE5M2NV", + "value" : 1000491003, + "version" : "None" + } + ] + }, { "category" : "Id", "kind" : "IdResultType", @@ -14943,6 +17746,11 @@ "kind" : "LiteralString", "doc" : "A null-terminated stream of characters consuming an integral number of words" }, + { + "category" : "Literal", + "kind" : "LiteralFloat", + "doc" : "A float consuming one word" + }, { "category" : "Literal", "kind" : "LiteralContextDependentNumber", diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.cs b/third_party/spirv-headers/include/spirv/unified1/spirv.cs index f836fc9092..a9bd1e23a8 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.cs +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -65,6 +65,13 @@ namespace Spv HLSL = 5, CPP_for_OpenCL = 6, SYCL = 7, + HERO_C = 8, + NZSL = 9, + WGSL = 10, + Slang = 11, + Zig = 12, + Rust = 13, + Max = 0x7fffffff, } public enum ExecutionModel @@ -92,6 +99,7 @@ namespace Spv CallableNV = 5318, TaskEXT = 5364, MeshEXT = 5365, + Max = 0x7fffffff, } public enum AddressingModel @@ -101,6 +109,7 @@ namespace Spv Physical64 = 2, PhysicalStorageBuffer64 = 5348, PhysicalStorageBuffer64EXT = 5348, + Max = 0x7fffffff, } public enum MemoryModel @@ -110,6 +119,7 @@ namespace Spv OpenCL = 2, Vulkan = 3, VulkanKHR = 3, + Max = 0x7fffffff, } public enum ExecutionMode @@ -152,6 +162,9 @@ namespace Spv SubgroupsPerWorkgroupId = 37, LocalSizeId = 38, LocalSizeHintId = 39, + NonCoherentColorAttachmentReadEXT = 4169, + NonCoherentDepthAttachmentReadEXT = 4170, + NonCoherentStencilAttachmentReadEXT = 4171, SubgroupUniformControlFlowKHR = 4421, PostDepthCoverage = 4446, DenormPreserve = 4459, @@ -161,17 +174,28 @@ namespace Spv RoundingModeRTZ = 4463, EarlyAndLateFragmentTestsAMD = 5017, StencilRefReplacingEXT = 5027, + CoalescingAMDX = 5069, + IsApiEntryAMDX = 5070, + MaxNodeRecursionAMDX = 5071, + StaticNumWorkgroupsAMDX = 5072, + ShaderIndexAMDX = 5073, + MaxNumWorkgroupsAMDX = 5077, StencilRefUnchangedFrontAMD = 5079, StencilRefGreaterFrontAMD = 5080, StencilRefLessFrontAMD = 5081, StencilRefUnchangedBackAMD = 5082, StencilRefGreaterBackAMD = 5083, StencilRefLessBackAMD = 5084, + QuadDerivativesKHR = 5088, + RequireFullQuadsKHR = 5089, + SharesInputWithAMDX = 5102, OutputLinesEXT = 5269, OutputLinesNV = 5269, OutputPrimitivesEXT = 5270, OutputPrimitivesNV = 5270, + DerivativeGroupQuadsKHR = 5289, DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearKHR = 5290, DerivativeGroupLinearNV = 5290, OutputTrianglesEXT = 5298, OutputTrianglesNV = 5298, @@ -191,8 +215,15 @@ namespace Spv NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + MaximallyReconvergesKHR = 6023, + FPFastMathDefault = 6028, StreamingInterfaceINTEL = 6154, + RegisterMapInterfaceINTEL = 6160, NamedBarrierCountINTEL = 6417, + MaximumRegistersINTEL = 6461, + MaximumRegistersIdINTEL = 6462, + NamedMaximumRegistersINTEL = 6463, + Max = 0x7fffffff, } public enum StorageClass @@ -210,6 +241,8 @@ namespace Spv AtomicCounter = 10, Image = 11, StorageBuffer = 12, + TileImageEXT = 4172, + NodePayloadAMDX = 5068, CallableDataKHR = 5328, CallableDataNV = 5328, IncomingCallableDataKHR = 5329, @@ -229,6 +262,7 @@ namespace Spv CodeSectionINTEL = 5605, DeviceOnlyINTEL = 5936, HostOnlyINTEL = 5937, + Max = 0x7fffffff, } public enum Dim @@ -240,6 +274,8 @@ namespace Spv Rect = 4, Buffer = 5, SubpassData = 6, + TileImageDataEXT = 4173, + Max = 0x7fffffff, } public enum SamplerAddressingMode @@ -249,12 +285,14 @@ namespace Spv Clamp = 2, Repeat = 3, RepeatMirrored = 4, + Max = 0x7fffffff, } public enum SamplerFilterMode { Nearest = 0, Linear = 1, + Max = 0x7fffffff, } public enum ImageFormat @@ -301,6 +339,7 @@ namespace Spv R8ui = 39, R64ui = 40, R64i = 41, + Max = 0x7fffffff, } public enum ImageChannelOrder @@ -325,6 +364,7 @@ namespace Spv sRGBA = 17, sBGRA = 18, ABGR = 19, + Max = 0x7fffffff, } public enum ImageChannelDataType @@ -346,6 +386,10 @@ namespace Spv Float = 14, UnormInt24 = 15, UnormInt101010_2 = 16, + UnsignedIntRaw10EXT = 19, + UnsignedIntRaw12EXT = 20, + UnormInt2_101010EXT = 21, + Max = 0x7fffffff, } public enum ImageOperandsShift @@ -370,6 +414,7 @@ namespace Spv ZeroExtend = 13, Nontemporal = 14, Offsets = 16, + Max = 0x7fffffff, } public enum ImageOperandsMask @@ -404,8 +449,12 @@ namespace Spv NSZ = 2, AllowRecip = 3, Fast = 4, + AllowContract = 16, AllowContractFastINTEL = 16, + AllowReassoc = 17, AllowReassocINTEL = 17, + AllowTransform = 18, + Max = 0x7fffffff, } public enum FPFastMathModeMask @@ -416,8 +465,11 @@ namespace Spv NSZ = 0x00000004, AllowRecip = 0x00000008, Fast = 0x00000010, + AllowContract = 0x00010000, AllowContractFastINTEL = 0x00010000, + AllowReassoc = 0x00020000, AllowReassocINTEL = 0x00020000, + AllowTransform = 0x00040000, } public enum FPRoundingMode @@ -426,6 +478,7 @@ namespace Spv RTZ = 1, RTP = 2, RTN = 3, + Max = 0x7fffffff, } public enum LinkageType @@ -433,6 +486,7 @@ namespace Spv Export = 0, Import = 1, LinkOnceODR = 2, + Max = 0x7fffffff, } public enum AccessQualifier @@ -440,6 +494,7 @@ namespace Spv ReadOnly = 0, WriteOnly = 1, ReadWrite = 2, + Max = 0x7fffffff, } public enum FunctionParameterAttribute @@ -453,6 +508,7 @@ namespace Spv NoWrite = 6, NoReadWrite = 7, RuntimeAlignedINTEL = 5940, + Max = 0x7fffffff, } public enum Decoration @@ -506,7 +562,18 @@ namespace Spv MaxByteOffsetId = 47, NoSignedWrap = 4469, NoUnsignedWrap = 4470, + WeightTextureQCOM = 4487, + BlockMatchTextureQCOM = 4488, + BlockMatchSamplerQCOM = 4499, ExplicitInterpAMD = 4999, + NodeSharesPayloadLimitsWithAMDX = 5019, + NodeMaxPayloadsAMDX = 5020, + TrackFinishWritingAMDX = 5078, + PayloadNodeNameAMDX = 5091, + PayloadNodeBaseIndexAMDX = 5098, + PayloadNodeSparseArrayAMDX = 5099, + PayloadNodeArraySizeAMDX = 5100, + PayloadDispatchIndirectAMDX = 5105, OverrideCoverageNV = 5248, PassthroughNV = 5250, ViewportRelativeNV = 5252, @@ -556,6 +623,9 @@ namespace Spv MergeINTEL = 5834, BankBitsINTEL = 5835, ForcePow2DepthINTEL = 5836, + StridesizeINTEL = 5883, + WordsizeINTEL = 5884, + TrueDualPortINTEL = 5885, BurstCoalesceINTEL = 5899, CacheSizeINTEL = 5900, DontStaticallyCoalesceINTEL = 5901, @@ -574,6 +644,25 @@ namespace Spv SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, MediaBlockIOINTEL = 6140, + StallFreeINTEL = 6151, + FPMaxErrorDecorationINTEL = 6170, + LatencyControlLabelINTEL = 6172, + LatencyControlConstraintINTEL = 6173, + ConduitKernelArgumentINTEL = 6175, + RegisterMapKernelArgumentINTEL = 6176, + MMHostInterfaceAddressWidthINTEL = 6177, + MMHostInterfaceDataWidthINTEL = 6178, + MMHostInterfaceLatencyINTEL = 6179, + MMHostInterfaceReadWriteModeINTEL = 6180, + MMHostInterfaceMaxBurstINTEL = 6181, + MMHostInterfaceWaitRequestINTEL = 6182, + StableKernelArgumentINTEL = 6183, + HostAccessINTEL = 6188, + InitModeINTEL = 6190, + ImplementInRegisterMapINTEL = 6191, + CacheControlLoadINTEL = 6442, + CacheControlStoreINTEL = 6443, + Max = 0x7fffffff, } public enum BuiltIn @@ -649,6 +738,8 @@ namespace Spv BaryCoordSmoothSampleAMD = 4997, BaryCoordPullModelAMD = 4998, FragStencilRefEXT = 5014, + RemainingRecursionLevelsAMDX = 5021, + ShaderIndexAMDX = 5073, ViewportMaskNV = 5253, SecondaryPositionNV = 5257, SecondaryViewportMaskNV = 5258, @@ -701,20 +792,34 @@ namespace Spv HitKindKHR = 5333, HitKindNV = 5333, CurrentRayTimeNV = 5334, + HitTriangleVertexPositionsKHR = 5335, + HitMicroTriangleVertexPositionsNV = 5337, + HitMicroTriangleVertexBarycentricsNV = 5344, IncomingRayFlagsKHR = 5351, IncomingRayFlagsNV = 5351, RayGeometryIndexKHR = 5352, + HitIsSphereNV = 5359, + HitIsLSSNV = 5360, + HitSpherePositionNV = 5361, WarpsPerSMNV = 5374, SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + HitLSSPositionsNV = 5396, + HitKindFrontFacingMicroTriangleNV = 5405, + HitKindBackFacingMicroTriangleNV = 5406, + HitSphereRadiusNV = 5420, + HitLSSRadiiNV = 5421, + ClusterIDNV = 5436, CullMaskKHR = 6021, + Max = 0x7fffffff, } public enum SelectionControlShift { Flatten = 0, DontFlatten = 1, + Max = 0x7fffffff, } public enum SelectionControlMask @@ -745,6 +850,7 @@ namespace Spv NoFusionINTEL = 23, LoopCountINTEL = 24, MaxReinvocationDelayINTEL = 25, + Max = 0x7fffffff, } public enum LoopControlMask @@ -777,7 +883,9 @@ namespace Spv DontInline = 1, Pure = 2, Const = 3, + OptNoneEXT = 16, OptNoneINTEL = 16, + Max = 0x7fffffff, } public enum FunctionControlMask @@ -787,6 +895,7 @@ namespace Spv DontInline = 0x00000002, Pure = 0x00000004, Const = 0x00000008, + OptNoneEXT = 0x00010000, OptNoneINTEL = 0x00010000, } @@ -809,6 +918,7 @@ namespace Spv MakeVisible = 14, MakeVisibleKHR = 14, Volatile = 15, + Max = 0x7fffffff, } public enum MemorySemanticsMask @@ -846,6 +956,7 @@ namespace Spv NonPrivatePointerKHR = 5, AliasScopeINTELMask = 16, NoAliasINTELMask = 17, + Max = 0x7fffffff, } public enum MemoryAccessMask @@ -874,6 +985,7 @@ namespace Spv QueueFamily = 5, QueueFamilyKHR = 5, ShaderCallKHR = 6, + Max = 0x7fffffff, } public enum GroupOperation @@ -885,6 +997,7 @@ namespace Spv PartitionedReduceNV = 6, PartitionedInclusiveScanNV = 7, PartitionedExclusiveScanNV = 8, + Max = 0x7fffffff, } public enum KernelEnqueueFlags @@ -892,11 +1005,13 @@ namespace Spv NoWait = 0, WaitKernel = 1, WaitWorkGroup = 2, + Max = 0x7fffffff, } public enum KernelProfilingInfoShift { CmdExecTime = 0, + Max = 0x7fffffff, } public enum KernelProfilingInfoMask @@ -978,6 +1093,10 @@ namespace Spv ShaderViewportIndex = 70, UniformDecoration = 71, CoreBuiltinsARM = 4165, + TileImageColorReadAccessEXT = 4166, + TileImageDepthReadAccessEXT = 4167, + TileImageStencilReadAccessEXT = 4168, + CooperativeMatrixLayoutsARM = 4201, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -1007,8 +1126,13 @@ namespace Spv RoundingModeRTZ = 4468, RayQueryProvisionalKHR = 4471, RayQueryKHR = 4472, + UntypedPointersKHR = 4473, RayTraversalPrimitiveCullingKHR = 4478, RayTracingKHR = 4479, + TextureSampleWeightedQCOM = 4484, + TextureBoxFilterQCOM = 4485, + TextureBlockMatchQCOM = 4486, + TextureBlockMatch2QCOM = 4498, Float16ImageAMD = 5008, ImageGatherBiasLodAMD = 5009, FragmentMaskAMD = 5010, @@ -1016,6 +1140,8 @@ namespace Spv ImageReadWriteLodAMD = 5015, Int64ImageEXT = 5016, ShaderClockKHR = 5055, + ShaderEnqueueAMDX = 5067, + QuadControlKHR = 5087, SampleMaskOverrideCoverageNV = 5249, GeometryShaderPassthroughNV = 5251, ShaderViewportIndexLayerEXT = 5254, @@ -1029,6 +1155,7 @@ namespace Spv MeshShadingEXT = 5283, FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsKHR = 5288, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, ShadingRateNV = 5291, @@ -1057,6 +1184,7 @@ namespace Spv UniformTexelBufferArrayNonUniformIndexingEXT = 5311, StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingPositionFetchKHR = 5336, RayTracingNV = 5340, RayTracingMotionBlurNV = 5341, VulkanMemoryModel = 5345, @@ -1065,6 +1193,7 @@ namespace Spv VulkanMemoryModelDeviceScopeKHR = 5346, PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearKHR = 5350, ComputeDerivativeGroupLinearNV = 5350, RayTracingProvisionalKHR = 5353, CooperativeMatrixNV = 5357, @@ -1074,9 +1203,25 @@ namespace Spv FragmentShaderPixelInterlockEXT = 5378, DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, + DisplacementMicromapNV = 5380, RayTracingOpacityMicromapEXT = 5381, ShaderInvocationReorderNV = 5383, BindlessTextureNV = 5390, + RayQueryPositionFetchKHR = 5391, + CooperativeVectorNV = 5394, + AtomicFloat16VectorNV = 5404, + RayTracingDisplacementMicromapNV = 5409, + RawAccessChainsNV = 5414, + RayTracingSpheresGeometryNV = 5418, + RayTracingLinearSweptSpheresGeometryNV = 5419, + CooperativeMatrixReductionsNV = 5430, + CooperativeMatrixConversionsNV = 5431, + CooperativeMatrixPerElementOperationsNV = 5432, + CooperativeMatrixTensorAddressingNV = 5433, + CooperativeMatrixBlockLoadsNV = 5434, + CooperativeVectorTrainingNV = 5435, + RayTracingClusterAccelerationStructureNV = 5437, + TensorAddressingNV = 5439, SubgroupShuffleINTEL = 5568, SubgroupBufferBlockIOINTEL = 5569, SubgroupImageBlockIOINTEL = 5570, @@ -1128,16 +1273,38 @@ namespace Spv DotProduct = 6019, DotProductKHR = 6019, RayCullMaskKHR = 6020, + CooperativeMatrixKHR = 6022, + ReplicatedCompositesEXT = 6024, BitInstructions = 6025, GroupNonUniformRotateKHR = 6026, + FloatControls2 = 6029, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, - LongConstantCompositeINTEL = 6089, + LongCompositesINTEL = 6089, + OptNoneEXT = 6094, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + BFloat16ConversionINTEL = 6115, SplitBarrierINTEL = 6141, + ArithmeticFenceEXT = 6144, + FPGAClusterAttributesV2INTEL = 6150, + FPGAKernelAttributesv2INTEL = 6161, + FPMaxErrorINTEL = 6169, + FPGALatencyControlINTEL = 6171, + FPGAArgumentInterfacesINTEL = 6174, + GlobalVariableHostAccessINTEL = 6187, + GlobalVariableFPGADecorationsINTEL = 6189, + SubgroupBufferPrefetchINTEL = 6220, + Subgroup2DBlockIOINTEL = 6228, + Subgroup2DBlockTransformINTEL = 6229, + Subgroup2DBlockTransposeINTEL = 6230, + SubgroupMatrixMultiplyAccumulateINTEL = 6236, GroupUniformArithmeticKHR = 6400, + MaskedGatherScatterINTEL = 6427, + CacheControlsINTEL = 6441, + RegisterLimitsINTEL = 6460, + Max = 0x7fffffff, } public enum RayFlagsShift @@ -1150,9 +1317,11 @@ namespace Spv CullFrontFacingTrianglesKHR = 5, CullOpaqueKHR = 6, CullNoOpaqueKHR = 7, + SkipBuiltinPrimitivesNV = 8, SkipTrianglesKHR = 8, SkipAABBsKHR = 9, ForceOpacityMicromap2StateEXT = 10, + Max = 0x7fffffff, } public enum RayFlagsMask @@ -1166,6 +1335,7 @@ namespace Spv CullFrontFacingTrianglesKHR = 0x00000020, CullOpaqueKHR = 0x00000040, CullNoOpaqueKHR = 0x00000080, + SkipBuiltinPrimitivesNV = 0x00000100, SkipTrianglesKHR = 0x00000100, SkipAABBsKHR = 0x00000200, ForceOpacityMicromap2StateEXT = 0x00000400, @@ -1175,6 +1345,7 @@ namespace Spv { RayQueryCandidateIntersectionKHR = 0, RayQueryCommittedIntersectionKHR = 1, + Max = 0x7fffffff, } public enum RayQueryCommittedIntersectionType @@ -1182,12 +1353,14 @@ namespace Spv RayQueryCommittedIntersectionNoneKHR = 0, RayQueryCommittedIntersectionTriangleKHR = 1, RayQueryCommittedIntersectionGeneratedKHR = 2, + Max = 0x7fffffff, } public enum RayQueryCandidateIntersectionType { RayQueryCandidateIntersectionTriangleKHR = 0, RayQueryCandidateIntersectionAABBKHR = 1, + Max = 0x7fffffff, } public enum FragmentShadingRateShift @@ -1196,6 +1369,7 @@ namespace Spv Vertical4Pixels = 1, Horizontal2Pixels = 2, Horizontal4Pixels = 3, + Max = 0x7fffffff, } public enum FragmentShadingRateMask @@ -1211,12 +1385,14 @@ namespace Spv { Preserve = 0, FlushToZero = 1, + Max = 0x7fffffff, } public enum FPOperationMode { IEEE = 0, ALT = 1, + Max = 0x7fffffff, } public enum QuantizationModes @@ -1229,6 +1405,7 @@ namespace Spv RND_MIN_INF = 5, RND_CONV = 6, RND_CONV_ODD = 7, + Max = 0x7fffffff, } public enum OverflowModes @@ -1237,12 +1414,218 @@ namespace Spv SAT = 1, SAT_ZERO = 2, SAT_SYM = 3, + Max = 0x7fffffff, } public enum PackedVectorFormat { PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, + Max = 0x7fffffff, + } + + public enum CooperativeMatrixOperandsShift + { + MatrixASignedComponentsKHR = 0, + MatrixBSignedComponentsKHR = 1, + MatrixCSignedComponentsKHR = 2, + MatrixResultSignedComponentsKHR = 3, + SaturatingAccumulationKHR = 4, + Max = 0x7fffffff, + } + + public enum CooperativeMatrixOperandsMask + { + MaskNone = 0, + MatrixASignedComponentsKHR = 0x00000001, + MatrixBSignedComponentsKHR = 0x00000002, + MatrixCSignedComponentsKHR = 0x00000004, + MatrixResultSignedComponentsKHR = 0x00000008, + SaturatingAccumulationKHR = 0x00000010, + } + + public enum CooperativeMatrixLayout + { + RowMajorKHR = 0, + ColumnMajorKHR = 1, + RowBlockedInterleavedARM = 4202, + ColumnBlockedInterleavedARM = 4203, + Max = 0x7fffffff, + } + + public enum CooperativeMatrixUse + { + MatrixAKHR = 0, + MatrixBKHR = 1, + MatrixAccumulatorKHR = 2, + Max = 0x7fffffff, + } + + public enum CooperativeMatrixReduceShift + { + Row = 0, + Column = 1, + CooperativeMatrixReduce2x2 = 2, + Max = 0x7fffffff, + } + + public enum CooperativeMatrixReduceMask + { + MaskNone = 0, + Row = 0x00000001, + Column = 0x00000002, + CooperativeMatrixReduce2x2 = 0x00000004, + } + + public enum TensorClampMode + { + Undefined = 0, + Constant = 1, + ClampToEdge = 2, + Repeat = 3, + RepeatMirrored = 4, + Max = 0x7fffffff, + } + + public enum TensorAddressingOperandsShift + { + TensorView = 0, + DecodeFunc = 1, + Max = 0x7fffffff, + } + + public enum TensorAddressingOperandsMask + { + MaskNone = 0, + TensorView = 0x00000001, + DecodeFunc = 0x00000002, + } + + public enum InitializationModeQualifier + { + InitOnDeviceReprogramINTEL = 0, + InitOnDeviceResetINTEL = 1, + Max = 0x7fffffff, + } + + public enum HostAccessQualifier + { + NoneINTEL = 0, + ReadINTEL = 1, + WriteINTEL = 2, + ReadWriteINTEL = 3, + Max = 0x7fffffff, + } + + public enum LoadCacheControl + { + UncachedINTEL = 0, + CachedINTEL = 1, + StreamingINTEL = 2, + InvalidateAfterReadINTEL = 3, + ConstCachedINTEL = 4, + Max = 0x7fffffff, + } + + public enum StoreCacheControl + { + UncachedINTEL = 0, + WriteThroughINTEL = 1, + WriteBackINTEL = 2, + StreamingINTEL = 3, + Max = 0x7fffffff, + } + + public enum NamedMaximumNumberOfRegisters + { + AutoINTEL = 0, + Max = 0x7fffffff, + } + + public enum MatrixMultiplyAccumulateOperandsShift + { + MatrixASignedComponentsINTEL = 0, + MatrixBSignedComponentsINTEL = 1, + MatrixCBFloat16INTEL = 2, + MatrixResultBFloat16INTEL = 3, + MatrixAPackedInt8INTEL = 4, + MatrixBPackedInt8INTEL = 5, + MatrixAPackedInt4INTEL = 6, + MatrixBPackedInt4INTEL = 7, + MatrixATF32INTEL = 8, + MatrixBTF32INTEL = 9, + MatrixAPackedFloat16INTEL = 10, + MatrixBPackedFloat16INTEL = 11, + MatrixAPackedBFloat16INTEL = 12, + MatrixBPackedBFloat16INTEL = 13, + Max = 0x7fffffff, + } + + public enum MatrixMultiplyAccumulateOperandsMask + { + MaskNone = 0, + MatrixASignedComponentsINTEL = 0x00000001, + MatrixBSignedComponentsINTEL = 0x00000002, + MatrixCBFloat16INTEL = 0x00000004, + MatrixResultBFloat16INTEL = 0x00000008, + MatrixAPackedInt8INTEL = 0x00000010, + MatrixBPackedInt8INTEL = 0x00000020, + MatrixAPackedInt4INTEL = 0x00000040, + MatrixBPackedInt4INTEL = 0x00000080, + MatrixATF32INTEL = 0x00000100, + MatrixBTF32INTEL = 0x00000200, + MatrixAPackedFloat16INTEL = 0x00000400, + MatrixBPackedFloat16INTEL = 0x00000800, + MatrixAPackedBFloat16INTEL = 0x00001000, + MatrixBPackedBFloat16INTEL = 0x00002000, + } + + public enum RawAccessChainOperandsShift + { + RobustnessPerComponentNV = 0, + RobustnessPerElementNV = 1, + Max = 0x7fffffff, + } + + public enum RawAccessChainOperandsMask + { + MaskNone = 0, + RobustnessPerComponentNV = 0x00000001, + RobustnessPerElementNV = 0x00000002, + } + + public enum FPEncoding + { + Max = 0x7fffffff, + } + + public enum CooperativeVectorMatrixLayout + { + RowMajorNV = 0, + ColumnMajorNV = 1, + InferencingOptimalNV = 2, + TrainingOptimalNV = 3, + Max = 0x7fffffff, + } + + public enum ComponentType + { + Float16NV = 0, + Float32NV = 1, + Float64NV = 2, + SignedInt8NV = 3, + SignedInt16NV = 4, + SignedInt32NV = 5, + SignedInt64NV = 6, + UnsignedInt8NV = 7, + UnsignedInt16NV = 8, + UnsignedInt32NV = 9, + UnsignedInt64NV = 10, + SignedInt8PackedNV = 1000491000, + UnsignedInt8PackedNV = 1000491001, + FloatE4M3NV = 1000491002, + FloatE5M2NV = 1000491003, + Max = 0x7fffffff, } public enum Op @@ -1591,14 +1974,26 @@ namespace Spv OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1616,6 +2011,14 @@ namespace Spv OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1623,6 +2026,14 @@ namespace Spv OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1634,6 +2045,16 @@ namespace Spv OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1668,10 +2089,20 @@ namespace Spv OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1679,9 +2110,12 @@ namespace Spv OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1689,9 +2123,26 @@ namespace Spv OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1699,6 +2150,20 @@ namespace Spv OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1940,8 +2405,19 @@ namespace Spv OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1950,6 +2426,9 @@ namespace Spv OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, + Max = 0x7fffffff, } } } diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.h b/third_party/spirv-headers/include/spirv/unified1/spirv.h index 366b55608e..a6a46c1c46 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.h +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2014-2020 The Khronos Group Inc. +** Copyright (c) 2014-2024 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"), @@ -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, @@ -73,6 +73,12 @@ typedef enum SpvSourceLanguage_ { SpvSourceLanguageHLSL = 5, SpvSourceLanguageCPP_for_OpenCL = 6, SpvSourceLanguageSYCL = 7, + SpvSourceLanguageHERO_C = 8, + SpvSourceLanguageNZSL = 9, + SpvSourceLanguageWGSL = 10, + SpvSourceLanguageSlang = 11, + SpvSourceLanguageZig = 12, + SpvSourceLanguageRust = 13, SpvSourceLanguageMax = 0x7fffffff, } SpvSourceLanguage; @@ -160,6 +166,9 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeSubgroupsPerWorkgroupId = 37, SpvExecutionModeLocalSizeId = 38, SpvExecutionModeLocalSizeHintId = 39, + SpvExecutionModeNonCoherentColorAttachmentReadEXT = 4169, + SpvExecutionModeNonCoherentDepthAttachmentReadEXT = 4170, + SpvExecutionModeNonCoherentStencilAttachmentReadEXT = 4171, SpvExecutionModeSubgroupUniformControlFlowKHR = 4421, SpvExecutionModePostDepthCoverage = 4446, SpvExecutionModeDenormPreserve = 4459, @@ -169,17 +178,28 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeRoundingModeRTZ = 4463, SpvExecutionModeEarlyAndLateFragmentTestsAMD = 5017, SpvExecutionModeStencilRefReplacingEXT = 5027, + SpvExecutionModeCoalescingAMDX = 5069, + SpvExecutionModeIsApiEntryAMDX = 5070, + SpvExecutionModeMaxNodeRecursionAMDX = 5071, + SpvExecutionModeStaticNumWorkgroupsAMDX = 5072, + SpvExecutionModeShaderIndexAMDX = 5073, + SpvExecutionModeMaxNumWorkgroupsAMDX = 5077, SpvExecutionModeStencilRefUnchangedFrontAMD = 5079, SpvExecutionModeStencilRefGreaterFrontAMD = 5080, SpvExecutionModeStencilRefLessFrontAMD = 5081, SpvExecutionModeStencilRefUnchangedBackAMD = 5082, SpvExecutionModeStencilRefGreaterBackAMD = 5083, SpvExecutionModeStencilRefLessBackAMD = 5084, + SpvExecutionModeQuadDerivativesKHR = 5088, + SpvExecutionModeRequireFullQuadsKHR = 5089, + SpvExecutionModeSharesInputWithAMDX = 5102, SpvExecutionModeOutputLinesEXT = 5269, SpvExecutionModeOutputLinesNV = 5269, SpvExecutionModeOutputPrimitivesEXT = 5270, SpvExecutionModeOutputPrimitivesNV = 5270, + SpvExecutionModeDerivativeGroupQuadsKHR = 5289, SpvExecutionModeDerivativeGroupQuadsNV = 5289, + SpvExecutionModeDerivativeGroupLinearKHR = 5290, SpvExecutionModeDerivativeGroupLinearNV = 5290, SpvExecutionModeOutputTrianglesEXT = 5298, SpvExecutionModeOutputTrianglesNV = 5298, @@ -199,8 +219,14 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeNoGlobalOffsetINTEL = 5895, SpvExecutionModeNumSIMDWorkitemsINTEL = 5896, SpvExecutionModeSchedulerTargetFmaxMhzINTEL = 5903, + SpvExecutionModeMaximallyReconvergesKHR = 6023, + SpvExecutionModeFPFastMathDefault = 6028, SpvExecutionModeStreamingInterfaceINTEL = 6154, + SpvExecutionModeRegisterMapInterfaceINTEL = 6160, SpvExecutionModeNamedBarrierCountINTEL = 6417, + SpvExecutionModeMaximumRegistersINTEL = 6461, + SpvExecutionModeMaximumRegistersIdINTEL = 6462, + SpvExecutionModeNamedMaximumRegistersINTEL = 6463, SpvExecutionModeMax = 0x7fffffff, } SpvExecutionMode; @@ -218,6 +244,8 @@ typedef enum SpvStorageClass_ { SpvStorageClassAtomicCounter = 10, SpvStorageClassImage = 11, SpvStorageClassStorageBuffer = 12, + SpvStorageClassTileImageEXT = 4172, + SpvStorageClassNodePayloadAMDX = 5068, SpvStorageClassCallableDataKHR = 5328, SpvStorageClassCallableDataNV = 5328, SpvStorageClassIncomingCallableDataKHR = 5329, @@ -248,6 +276,7 @@ typedef enum SpvDim_ { SpvDimRect = 4, SpvDimBuffer = 5, SpvDimSubpassData = 6, + SpvDimTileImageDataEXT = 4173, SpvDimMax = 0x7fffffff, } SpvDim; @@ -354,6 +383,9 @@ typedef enum SpvImageChannelDataType_ { SpvImageChannelDataTypeFloat = 14, SpvImageChannelDataTypeUnormInt24 = 15, SpvImageChannelDataTypeUnormInt101010_2 = 16, + SpvImageChannelDataTypeUnsignedIntRaw10EXT = 19, + SpvImageChannelDataTypeUnsignedIntRaw12EXT = 20, + SpvImageChannelDataTypeUnormInt2_101010EXT = 21, SpvImageChannelDataTypeMax = 0x7fffffff, } SpvImageChannelDataType; @@ -411,8 +443,11 @@ typedef enum SpvFPFastMathModeShift_ { SpvFPFastMathModeNSZShift = 2, SpvFPFastMathModeAllowRecipShift = 3, SpvFPFastMathModeFastShift = 4, + SpvFPFastMathModeAllowContractShift = 16, SpvFPFastMathModeAllowContractFastINTELShift = 16, + SpvFPFastMathModeAllowReassocShift = 17, SpvFPFastMathModeAllowReassocINTELShift = 17, + SpvFPFastMathModeAllowTransformShift = 18, SpvFPFastMathModeMax = 0x7fffffff, } SpvFPFastMathModeShift; @@ -423,8 +458,11 @@ typedef enum SpvFPFastMathModeMask_ { SpvFPFastMathModeNSZMask = 0x00000004, SpvFPFastMathModeAllowRecipMask = 0x00000008, SpvFPFastMathModeFastMask = 0x00000010, + SpvFPFastMathModeAllowContractMask = 0x00010000, SpvFPFastMathModeAllowContractFastINTELMask = 0x00010000, + SpvFPFastMathModeAllowReassocMask = 0x00020000, SpvFPFastMathModeAllowReassocINTELMask = 0x00020000, + SpvFPFastMathModeAllowTransformMask = 0x00040000, } SpvFPFastMathModeMask; typedef enum SpvFPRoundingMode_ { @@ -512,7 +550,18 @@ typedef enum SpvDecoration_ { SpvDecorationMaxByteOffsetId = 47, SpvDecorationNoSignedWrap = 4469, SpvDecorationNoUnsignedWrap = 4470, + SpvDecorationWeightTextureQCOM = 4487, + SpvDecorationBlockMatchTextureQCOM = 4488, + SpvDecorationBlockMatchSamplerQCOM = 4499, SpvDecorationExplicitInterpAMD = 4999, + SpvDecorationNodeSharesPayloadLimitsWithAMDX = 5019, + SpvDecorationNodeMaxPayloadsAMDX = 5020, + SpvDecorationTrackFinishWritingAMDX = 5078, + SpvDecorationPayloadNodeNameAMDX = 5091, + SpvDecorationPayloadNodeBaseIndexAMDX = 5098, + SpvDecorationPayloadNodeSparseArrayAMDX = 5099, + SpvDecorationPayloadNodeArraySizeAMDX = 5100, + SpvDecorationPayloadDispatchIndirectAMDX = 5105, SpvDecorationOverrideCoverageNV = 5248, SpvDecorationPassthroughNV = 5250, SpvDecorationViewportRelativeNV = 5252, @@ -562,6 +611,9 @@ typedef enum SpvDecoration_ { SpvDecorationMergeINTEL = 5834, SpvDecorationBankBitsINTEL = 5835, SpvDecorationForcePow2DepthINTEL = 5836, + SpvDecorationStridesizeINTEL = 5883, + SpvDecorationWordsizeINTEL = 5884, + SpvDecorationTrueDualPortINTEL = 5885, SpvDecorationBurstCoalesceINTEL = 5899, SpvDecorationCacheSizeINTEL = 5900, SpvDecorationDontStaticallyCoalesceINTEL = 5901, @@ -580,6 +632,24 @@ typedef enum SpvDecoration_ { SpvDecorationSingleElementVectorINTEL = 6085, SpvDecorationVectorComputeCallableFunctionINTEL = 6087, SpvDecorationMediaBlockIOINTEL = 6140, + SpvDecorationStallFreeINTEL = 6151, + SpvDecorationFPMaxErrorDecorationINTEL = 6170, + SpvDecorationLatencyControlLabelINTEL = 6172, + SpvDecorationLatencyControlConstraintINTEL = 6173, + SpvDecorationConduitKernelArgumentINTEL = 6175, + SpvDecorationRegisterMapKernelArgumentINTEL = 6176, + SpvDecorationMMHostInterfaceAddressWidthINTEL = 6177, + SpvDecorationMMHostInterfaceDataWidthINTEL = 6178, + SpvDecorationMMHostInterfaceLatencyINTEL = 6179, + SpvDecorationMMHostInterfaceReadWriteModeINTEL = 6180, + SpvDecorationMMHostInterfaceMaxBurstINTEL = 6181, + SpvDecorationMMHostInterfaceWaitRequestINTEL = 6182, + SpvDecorationStableKernelArgumentINTEL = 6183, + SpvDecorationHostAccessINTEL = 6188, + SpvDecorationInitModeINTEL = 6190, + SpvDecorationImplementInRegisterMapINTEL = 6191, + SpvDecorationCacheControlLoadINTEL = 6442, + SpvDecorationCacheControlStoreINTEL = 6443, SpvDecorationMax = 0x7fffffff, } SpvDecoration; @@ -655,6 +725,8 @@ typedef enum SpvBuiltIn_ { SpvBuiltInBaryCoordSmoothSampleAMD = 4997, SpvBuiltInBaryCoordPullModelAMD = 4998, SpvBuiltInFragStencilRefEXT = 5014, + SpvBuiltInRemainingRecursionLevelsAMDX = 5021, + SpvBuiltInShaderIndexAMDX = 5073, SpvBuiltInViewportMaskNV = 5253, SpvBuiltInSecondaryPositionNV = 5257, SpvBuiltInSecondaryViewportMaskNV = 5258, @@ -707,13 +779,25 @@ typedef enum SpvBuiltIn_ { SpvBuiltInHitKindKHR = 5333, SpvBuiltInHitKindNV = 5333, SpvBuiltInCurrentRayTimeNV = 5334, + SpvBuiltInHitTriangleVertexPositionsKHR = 5335, + SpvBuiltInHitMicroTriangleVertexPositionsNV = 5337, + SpvBuiltInHitMicroTriangleVertexBarycentricsNV = 5344, SpvBuiltInIncomingRayFlagsKHR = 5351, SpvBuiltInIncomingRayFlagsNV = 5351, SpvBuiltInRayGeometryIndexKHR = 5352, + SpvBuiltInHitIsSphereNV = 5359, + SpvBuiltInHitIsLSSNV = 5360, + SpvBuiltInHitSpherePositionNV = 5361, SpvBuiltInWarpsPerSMNV = 5374, SpvBuiltInSMCountNV = 5375, SpvBuiltInWarpIDNV = 5376, SpvBuiltInSMIDNV = 5377, + SpvBuiltInHitLSSPositionsNV = 5396, + SpvBuiltInHitKindFrontFacingMicroTriangleNV = 5405, + SpvBuiltInHitKindBackFacingMicroTriangleNV = 5406, + SpvBuiltInHitSphereRadiusNV = 5420, + SpvBuiltInHitLSSRadiiNV = 5421, + SpvBuiltInClusterIDNV = 5436, SpvBuiltInCullMaskKHR = 6021, SpvBuiltInMax = 0x7fffffff, } SpvBuiltIn; @@ -781,6 +865,7 @@ typedef enum SpvFunctionControlShift_ { SpvFunctionControlDontInlineShift = 1, SpvFunctionControlPureShift = 2, SpvFunctionControlConstShift = 3, + SpvFunctionControlOptNoneEXTShift = 16, SpvFunctionControlOptNoneINTELShift = 16, SpvFunctionControlMax = 0x7fffffff, } SpvFunctionControlShift; @@ -791,6 +876,7 @@ typedef enum SpvFunctionControlMask_ { SpvFunctionControlDontInlineMask = 0x00000002, SpvFunctionControlPureMask = 0x00000004, SpvFunctionControlConstMask = 0x00000008, + SpvFunctionControlOptNoneEXTMask = 0x00010000, SpvFunctionControlOptNoneINTELMask = 0x00010000, } SpvFunctionControlMask; @@ -978,6 +1064,10 @@ typedef enum SpvCapability_ { SpvCapabilityShaderViewportIndex = 70, SpvCapabilityUniformDecoration = 71, SpvCapabilityCoreBuiltinsARM = 4165, + SpvCapabilityTileImageColorReadAccessEXT = 4166, + SpvCapabilityTileImageDepthReadAccessEXT = 4167, + SpvCapabilityTileImageStencilReadAccessEXT = 4168, + SpvCapabilityCooperativeMatrixLayoutsARM = 4201, SpvCapabilityFragmentShadingRateKHR = 4422, SpvCapabilitySubgroupBallotKHR = 4423, SpvCapabilityDrawParameters = 4427, @@ -1007,8 +1097,13 @@ typedef enum SpvCapability_ { SpvCapabilityRoundingModeRTZ = 4468, SpvCapabilityRayQueryProvisionalKHR = 4471, SpvCapabilityRayQueryKHR = 4472, + SpvCapabilityUntypedPointersKHR = 4473, SpvCapabilityRayTraversalPrimitiveCullingKHR = 4478, SpvCapabilityRayTracingKHR = 4479, + SpvCapabilityTextureSampleWeightedQCOM = 4484, + SpvCapabilityTextureBoxFilterQCOM = 4485, + SpvCapabilityTextureBlockMatchQCOM = 4486, + SpvCapabilityTextureBlockMatch2QCOM = 4498, SpvCapabilityFloat16ImageAMD = 5008, SpvCapabilityImageGatherBiasLodAMD = 5009, SpvCapabilityFragmentMaskAMD = 5010, @@ -1016,6 +1111,8 @@ typedef enum SpvCapability_ { SpvCapabilityImageReadWriteLodAMD = 5015, SpvCapabilityInt64ImageEXT = 5016, SpvCapabilityShaderClockKHR = 5055, + SpvCapabilityShaderEnqueueAMDX = 5067, + SpvCapabilityQuadControlKHR = 5087, SpvCapabilitySampleMaskOverrideCoverageNV = 5249, SpvCapabilityGeometryShaderPassthroughNV = 5251, SpvCapabilityShaderViewportIndexLayerEXT = 5254, @@ -1029,6 +1126,7 @@ typedef enum SpvCapability_ { SpvCapabilityMeshShadingEXT = 5283, SpvCapabilityFragmentBarycentricKHR = 5284, SpvCapabilityFragmentBarycentricNV = 5284, + SpvCapabilityComputeDerivativeGroupQuadsKHR = 5288, SpvCapabilityComputeDerivativeGroupQuadsNV = 5288, SpvCapabilityFragmentDensityEXT = 5291, SpvCapabilityShadingRateNV = 5291, @@ -1057,6 +1155,7 @@ typedef enum SpvCapability_ { SpvCapabilityUniformTexelBufferArrayNonUniformIndexingEXT = 5311, SpvCapabilityStorageTexelBufferArrayNonUniformIndexing = 5312, SpvCapabilityStorageTexelBufferArrayNonUniformIndexingEXT = 5312, + SpvCapabilityRayTracingPositionFetchKHR = 5336, SpvCapabilityRayTracingNV = 5340, SpvCapabilityRayTracingMotionBlurNV = 5341, SpvCapabilityVulkanMemoryModel = 5345, @@ -1065,6 +1164,7 @@ typedef enum SpvCapability_ { SpvCapabilityVulkanMemoryModelDeviceScopeKHR = 5346, SpvCapabilityPhysicalStorageBufferAddresses = 5347, SpvCapabilityPhysicalStorageBufferAddressesEXT = 5347, + SpvCapabilityComputeDerivativeGroupLinearKHR = 5350, SpvCapabilityComputeDerivativeGroupLinearNV = 5350, SpvCapabilityRayTracingProvisionalKHR = 5353, SpvCapabilityCooperativeMatrixNV = 5357, @@ -1074,9 +1174,25 @@ typedef enum SpvCapability_ { SpvCapabilityFragmentShaderPixelInterlockEXT = 5378, SpvCapabilityDemoteToHelperInvocation = 5379, SpvCapabilityDemoteToHelperInvocationEXT = 5379, + SpvCapabilityDisplacementMicromapNV = 5380, SpvCapabilityRayTracingOpacityMicromapEXT = 5381, SpvCapabilityShaderInvocationReorderNV = 5383, SpvCapabilityBindlessTextureNV = 5390, + SpvCapabilityRayQueryPositionFetchKHR = 5391, + SpvCapabilityCooperativeVectorNV = 5394, + SpvCapabilityAtomicFloat16VectorNV = 5404, + SpvCapabilityRayTracingDisplacementMicromapNV = 5409, + SpvCapabilityRawAccessChainsNV = 5414, + SpvCapabilityRayTracingSpheresGeometryNV = 5418, + SpvCapabilityRayTracingLinearSweptSpheresGeometryNV = 5419, + SpvCapabilityCooperativeMatrixReductionsNV = 5430, + SpvCapabilityCooperativeMatrixConversionsNV = 5431, + SpvCapabilityCooperativeMatrixPerElementOperationsNV = 5432, + SpvCapabilityCooperativeMatrixTensorAddressingNV = 5433, + SpvCapabilityCooperativeMatrixBlockLoadsNV = 5434, + SpvCapabilityCooperativeVectorTrainingNV = 5435, + SpvCapabilityRayTracingClusterAccelerationStructureNV = 5437, + SpvCapabilityTensorAddressingNV = 5439, SpvCapabilitySubgroupShuffleINTEL = 5568, SpvCapabilitySubgroupBufferBlockIOINTEL = 5569, SpvCapabilitySubgroupImageBlockIOINTEL = 5570, @@ -1128,16 +1244,37 @@ typedef enum SpvCapability_ { SpvCapabilityDotProduct = 6019, SpvCapabilityDotProductKHR = 6019, SpvCapabilityRayCullMaskKHR = 6020, + SpvCapabilityCooperativeMatrixKHR = 6022, + SpvCapabilityReplicatedCompositesEXT = 6024, SpvCapabilityBitInstructions = 6025, SpvCapabilityGroupNonUniformRotateKHR = 6026, + SpvCapabilityFloatControls2 = 6029, SpvCapabilityAtomicFloat32AddEXT = 6033, SpvCapabilityAtomicFloat64AddEXT = 6034, - SpvCapabilityLongConstantCompositeINTEL = 6089, + SpvCapabilityLongCompositesINTEL = 6089, + SpvCapabilityOptNoneEXT = 6094, SpvCapabilityOptNoneINTEL = 6094, SpvCapabilityAtomicFloat16AddEXT = 6095, SpvCapabilityDebugInfoModuleINTEL = 6114, + SpvCapabilityBFloat16ConversionINTEL = 6115, SpvCapabilitySplitBarrierINTEL = 6141, + SpvCapabilityArithmeticFenceEXT = 6144, + SpvCapabilityFPGAClusterAttributesV2INTEL = 6150, + SpvCapabilityFPGAKernelAttributesv2INTEL = 6161, + SpvCapabilityFPMaxErrorINTEL = 6169, + SpvCapabilityFPGALatencyControlINTEL = 6171, + SpvCapabilityFPGAArgumentInterfacesINTEL = 6174, + SpvCapabilityGlobalVariableHostAccessINTEL = 6187, + SpvCapabilityGlobalVariableFPGADecorationsINTEL = 6189, + SpvCapabilitySubgroupBufferPrefetchINTEL = 6220, + SpvCapabilitySubgroup2DBlockIOINTEL = 6228, + SpvCapabilitySubgroup2DBlockTransformINTEL = 6229, + SpvCapabilitySubgroup2DBlockTransposeINTEL = 6230, + SpvCapabilitySubgroupMatrixMultiplyAccumulateINTEL = 6236, SpvCapabilityGroupUniformArithmeticKHR = 6400, + SpvCapabilityMaskedGatherScatterINTEL = 6427, + SpvCapabilityCacheControlsINTEL = 6441, + SpvCapabilityRegisterLimitsINTEL = 6460, SpvCapabilityMax = 0x7fffffff, } SpvCapability; @@ -1150,6 +1287,7 @@ typedef enum SpvRayFlagsShift_ { SpvRayFlagsCullFrontFacingTrianglesKHRShift = 5, SpvRayFlagsCullOpaqueKHRShift = 6, SpvRayFlagsCullNoOpaqueKHRShift = 7, + SpvRayFlagsSkipBuiltinPrimitivesNVShift = 8, SpvRayFlagsSkipTrianglesKHRShift = 8, SpvRayFlagsSkipAABBsKHRShift = 9, SpvRayFlagsForceOpacityMicromap2StateEXTShift = 10, @@ -1166,6 +1304,7 @@ typedef enum SpvRayFlagsMask_ { SpvRayFlagsCullFrontFacingTrianglesKHRMask = 0x00000020, SpvRayFlagsCullOpaqueKHRMask = 0x00000040, SpvRayFlagsCullNoOpaqueKHRMask = 0x00000080, + SpvRayFlagsSkipBuiltinPrimitivesNVMask = 0x00000100, SpvRayFlagsSkipTrianglesKHRMask = 0x00000100, SpvRayFlagsSkipAABBsKHRMask = 0x00000200, SpvRayFlagsForceOpacityMicromap2StateEXTMask = 0x00000400, @@ -1244,6 +1383,189 @@ typedef enum SpvPackedVectorFormat_ { SpvPackedVectorFormatMax = 0x7fffffff, } SpvPackedVectorFormat; +typedef enum SpvCooperativeMatrixOperandsShift_ { + SpvCooperativeMatrixOperandsMatrixASignedComponentsKHRShift = 0, + SpvCooperativeMatrixOperandsMatrixBSignedComponentsKHRShift = 1, + SpvCooperativeMatrixOperandsMatrixCSignedComponentsKHRShift = 2, + SpvCooperativeMatrixOperandsMatrixResultSignedComponentsKHRShift = 3, + SpvCooperativeMatrixOperandsSaturatingAccumulationKHRShift = 4, + SpvCooperativeMatrixOperandsMax = 0x7fffffff, +} SpvCooperativeMatrixOperandsShift; + +typedef enum SpvCooperativeMatrixOperandsMask_ { + SpvCooperativeMatrixOperandsMaskNone = 0, + SpvCooperativeMatrixOperandsMatrixASignedComponentsKHRMask = 0x00000001, + SpvCooperativeMatrixOperandsMatrixBSignedComponentsKHRMask = 0x00000002, + SpvCooperativeMatrixOperandsMatrixCSignedComponentsKHRMask = 0x00000004, + SpvCooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask = 0x00000008, + SpvCooperativeMatrixOperandsSaturatingAccumulationKHRMask = 0x00000010, +} SpvCooperativeMatrixOperandsMask; + +typedef enum SpvCooperativeMatrixLayout_ { + SpvCooperativeMatrixLayoutRowMajorKHR = 0, + SpvCooperativeMatrixLayoutColumnMajorKHR = 1, + SpvCooperativeMatrixLayoutRowBlockedInterleavedARM = 4202, + SpvCooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203, + SpvCooperativeMatrixLayoutMax = 0x7fffffff, +} SpvCooperativeMatrixLayout; + +typedef enum SpvCooperativeMatrixUse_ { + SpvCooperativeMatrixUseMatrixAKHR = 0, + SpvCooperativeMatrixUseMatrixBKHR = 1, + SpvCooperativeMatrixUseMatrixAccumulatorKHR = 2, + SpvCooperativeMatrixUseMax = 0x7fffffff, +} SpvCooperativeMatrixUse; + +typedef enum SpvCooperativeMatrixReduceShift_ { + SpvCooperativeMatrixReduceRowShift = 0, + SpvCooperativeMatrixReduceColumnShift = 1, + SpvCooperativeMatrixReduce2x2Shift = 2, + SpvCooperativeMatrixReduceMax = 0x7fffffff, +} SpvCooperativeMatrixReduceShift; + +typedef enum SpvCooperativeMatrixReduceMask_ { + SpvCooperativeMatrixReduceMaskNone = 0, + SpvCooperativeMatrixReduceRowMask = 0x00000001, + SpvCooperativeMatrixReduceColumnMask = 0x00000002, + SpvCooperativeMatrixReduce2x2Mask = 0x00000004, +} SpvCooperativeMatrixReduceMask; + +typedef enum SpvTensorClampMode_ { + SpvTensorClampModeUndefined = 0, + SpvTensorClampModeConstant = 1, + SpvTensorClampModeClampToEdge = 2, + SpvTensorClampModeRepeat = 3, + SpvTensorClampModeRepeatMirrored = 4, + SpvTensorClampModeMax = 0x7fffffff, +} SpvTensorClampMode; + +typedef enum SpvTensorAddressingOperandsShift_ { + SpvTensorAddressingOperandsTensorViewShift = 0, + SpvTensorAddressingOperandsDecodeFuncShift = 1, + SpvTensorAddressingOperandsMax = 0x7fffffff, +} SpvTensorAddressingOperandsShift; + +typedef enum SpvTensorAddressingOperandsMask_ { + SpvTensorAddressingOperandsMaskNone = 0, + SpvTensorAddressingOperandsTensorViewMask = 0x00000001, + SpvTensorAddressingOperandsDecodeFuncMask = 0x00000002, +} SpvTensorAddressingOperandsMask; + +typedef enum SpvInitializationModeQualifier_ { + SpvInitializationModeQualifierInitOnDeviceReprogramINTEL = 0, + SpvInitializationModeQualifierInitOnDeviceResetINTEL = 1, + SpvInitializationModeQualifierMax = 0x7fffffff, +} SpvInitializationModeQualifier; + +typedef enum SpvHostAccessQualifier_ { + SpvHostAccessQualifierNoneINTEL = 0, + SpvHostAccessQualifierReadINTEL = 1, + SpvHostAccessQualifierWriteINTEL = 2, + SpvHostAccessQualifierReadWriteINTEL = 3, + SpvHostAccessQualifierMax = 0x7fffffff, +} SpvHostAccessQualifier; + +typedef enum SpvLoadCacheControl_ { + SpvLoadCacheControlUncachedINTEL = 0, + SpvLoadCacheControlCachedINTEL = 1, + SpvLoadCacheControlStreamingINTEL = 2, + SpvLoadCacheControlInvalidateAfterReadINTEL = 3, + SpvLoadCacheControlConstCachedINTEL = 4, + SpvLoadCacheControlMax = 0x7fffffff, +} SpvLoadCacheControl; + +typedef enum SpvStoreCacheControl_ { + SpvStoreCacheControlUncachedINTEL = 0, + SpvStoreCacheControlWriteThroughINTEL = 1, + SpvStoreCacheControlWriteBackINTEL = 2, + SpvStoreCacheControlStreamingINTEL = 3, + SpvStoreCacheControlMax = 0x7fffffff, +} SpvStoreCacheControl; + +typedef enum SpvNamedMaximumNumberOfRegisters_ { + SpvNamedMaximumNumberOfRegistersAutoINTEL = 0, + SpvNamedMaximumNumberOfRegistersMax = 0x7fffffff, +} SpvNamedMaximumNumberOfRegisters; + +typedef enum SpvMatrixMultiplyAccumulateOperandsShift_ { + SpvMatrixMultiplyAccumulateOperandsMatrixASignedComponentsINTELShift = 0, + SpvMatrixMultiplyAccumulateOperandsMatrixBSignedComponentsINTELShift = 1, + SpvMatrixMultiplyAccumulateOperandsMatrixCBFloat16INTELShift = 2, + SpvMatrixMultiplyAccumulateOperandsMatrixResultBFloat16INTELShift = 3, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedInt8INTELShift = 4, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedInt8INTELShift = 5, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedInt4INTELShift = 6, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedInt4INTELShift = 7, + SpvMatrixMultiplyAccumulateOperandsMatrixATF32INTELShift = 8, + SpvMatrixMultiplyAccumulateOperandsMatrixBTF32INTELShift = 9, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedFloat16INTELShift = 10, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedFloat16INTELShift = 11, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedBFloat16INTELShift = 12, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedBFloat16INTELShift = 13, + SpvMatrixMultiplyAccumulateOperandsMax = 0x7fffffff, +} SpvMatrixMultiplyAccumulateOperandsShift; + +typedef enum SpvMatrixMultiplyAccumulateOperandsMask_ { + SpvMatrixMultiplyAccumulateOperandsMaskNone = 0, + SpvMatrixMultiplyAccumulateOperandsMatrixASignedComponentsINTELMask = 0x00000001, + SpvMatrixMultiplyAccumulateOperandsMatrixBSignedComponentsINTELMask = 0x00000002, + SpvMatrixMultiplyAccumulateOperandsMatrixCBFloat16INTELMask = 0x00000004, + SpvMatrixMultiplyAccumulateOperandsMatrixResultBFloat16INTELMask = 0x00000008, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedInt8INTELMask = 0x00000010, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedInt8INTELMask = 0x00000020, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedInt4INTELMask = 0x00000040, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedInt4INTELMask = 0x00000080, + SpvMatrixMultiplyAccumulateOperandsMatrixATF32INTELMask = 0x00000100, + SpvMatrixMultiplyAccumulateOperandsMatrixBTF32INTELMask = 0x00000200, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedFloat16INTELMask = 0x00000400, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedFloat16INTELMask = 0x00000800, + SpvMatrixMultiplyAccumulateOperandsMatrixAPackedBFloat16INTELMask = 0x00001000, + SpvMatrixMultiplyAccumulateOperandsMatrixBPackedBFloat16INTELMask = 0x00002000, +} SpvMatrixMultiplyAccumulateOperandsMask; + +typedef enum SpvRawAccessChainOperandsShift_ { + SpvRawAccessChainOperandsRobustnessPerComponentNVShift = 0, + SpvRawAccessChainOperandsRobustnessPerElementNVShift = 1, + SpvRawAccessChainOperandsMax = 0x7fffffff, +} SpvRawAccessChainOperandsShift; + +typedef enum SpvRawAccessChainOperandsMask_ { + SpvRawAccessChainOperandsMaskNone = 0, + SpvRawAccessChainOperandsRobustnessPerComponentNVMask = 0x00000001, + SpvRawAccessChainOperandsRobustnessPerElementNVMask = 0x00000002, +} SpvRawAccessChainOperandsMask; + +typedef enum SpvFPEncoding_ { + SpvFPEncodingMax = 0x7fffffff, +} SpvFPEncoding; + +typedef enum SpvCooperativeVectorMatrixLayout_ { + SpvCooperativeVectorMatrixLayoutRowMajorNV = 0, + SpvCooperativeVectorMatrixLayoutColumnMajorNV = 1, + SpvCooperativeVectorMatrixLayoutInferencingOptimalNV = 2, + SpvCooperativeVectorMatrixLayoutTrainingOptimalNV = 3, + SpvCooperativeVectorMatrixLayoutMax = 0x7fffffff, +} SpvCooperativeVectorMatrixLayout; + +typedef enum SpvComponentType_ { + SpvComponentTypeFloat16NV = 0, + SpvComponentTypeFloat32NV = 1, + SpvComponentTypeFloat64NV = 2, + SpvComponentTypeSignedInt8NV = 3, + SpvComponentTypeSignedInt16NV = 4, + SpvComponentTypeSignedInt32NV = 5, + SpvComponentTypeSignedInt64NV = 6, + SpvComponentTypeUnsignedInt8NV = 7, + SpvComponentTypeUnsignedInt16NV = 8, + SpvComponentTypeUnsignedInt32NV = 9, + SpvComponentTypeUnsignedInt64NV = 10, + SpvComponentTypeSignedInt8PackedNV = 1000491000, + SpvComponentTypeUnsignedInt8PackedNV = 1000491001, + SpvComponentTypeFloatE4M3NV = 1000491002, + SpvComponentTypeFloatE5M2NV = 1000491003, + SpvComponentTypeMax = 0x7fffffff, +} SpvComponentType; + typedef enum SpvOp_ { SpvOpNop = 0, SpvOpUndef = 1, @@ -1589,14 +1911,26 @@ typedef enum SpvOp_ { SpvOpPtrEqual = 401, SpvOpPtrNotEqual = 402, SpvOpPtrDiff = 403, + SpvOpColorAttachmentReadEXT = 4160, + SpvOpDepthAttachmentReadEXT = 4161, + SpvOpStencilAttachmentReadEXT = 4162, SpvOpTerminateInvocation = 4416, + SpvOpTypeUntypedPointerKHR = 4417, + SpvOpUntypedVariableKHR = 4418, + SpvOpUntypedAccessChainKHR = 4419, + SpvOpUntypedInBoundsAccessChainKHR = 4420, SpvOpSubgroupBallotKHR = 4421, SpvOpSubgroupFirstInvocationKHR = 4422, + SpvOpUntypedPtrAccessChainKHR = 4423, + SpvOpUntypedInBoundsPtrAccessChainKHR = 4424, + SpvOpUntypedArrayLengthKHR = 4425, + SpvOpUntypedPrefetchKHR = 4426, SpvOpSubgroupAllKHR = 4428, SpvOpSubgroupAnyKHR = 4429, SpvOpSubgroupAllEqualKHR = 4430, SpvOpGroupNonUniformRotateKHR = 4431, SpvOpSubgroupReadInvocationKHR = 4432, + SpvOpExtInstWithForwardRefsKHR = 4433, SpvOpTraceRayKHR = 4445, SpvOpExecuteCallableKHR = 4446, SpvOpConvertUToAccelerationStructureKHR = 4447, @@ -1614,6 +1948,14 @@ typedef enum SpvOp_ { SpvOpUDotAccSatKHR = 4454, SpvOpSUDotAccSat = 4455, SpvOpSUDotAccSatKHR = 4455, + SpvOpTypeCooperativeMatrixKHR = 4456, + SpvOpCooperativeMatrixLoadKHR = 4457, + SpvOpCooperativeMatrixStoreKHR = 4458, + SpvOpCooperativeMatrixMulAddKHR = 4459, + SpvOpCooperativeMatrixLengthKHR = 4460, + SpvOpConstantCompositeReplicateEXT = 4461, + SpvOpSpecConstantCompositeReplicateEXT = 4462, + SpvOpCompositeConstructReplicateEXT = 4463, SpvOpTypeRayQueryKHR = 4472, SpvOpRayQueryInitializeKHR = 4473, SpvOpRayQueryTerminateKHR = 4474, @@ -1621,6 +1963,14 @@ typedef enum SpvOp_ { SpvOpRayQueryConfirmIntersectionKHR = 4476, SpvOpRayQueryProceedKHR = 4477, SpvOpRayQueryGetIntersectionTypeKHR = 4479, + SpvOpImageSampleWeightedQCOM = 4480, + SpvOpImageBoxFilterQCOM = 4481, + SpvOpImageBlockMatchSSDQCOM = 4482, + SpvOpImageBlockMatchSADQCOM = 4483, + SpvOpImageBlockMatchWindowSSDQCOM = 4500, + SpvOpImageBlockMatchWindowSADQCOM = 4501, + SpvOpImageBlockMatchGatherSSDQCOM = 4502, + SpvOpImageBlockMatchGatherSADQCOM = 4503, SpvOpGroupIAddNonUniformAMD = 5000, SpvOpGroupFAddNonUniformAMD = 5001, SpvOpGroupFMinNonUniformAMD = 5002, @@ -1632,6 +1982,16 @@ typedef enum SpvOp_ { SpvOpFragmentMaskFetchAMD = 5011, SpvOpFragmentFetchAMD = 5012, SpvOpReadClockKHR = 5056, + SpvOpAllocateNodePayloadsAMDX = 5074, + SpvOpEnqueueNodePayloadsAMDX = 5075, + SpvOpTypeNodePayloadArrayAMDX = 5076, + SpvOpFinishWritingNodePayloadAMDX = 5078, + SpvOpNodePayloadArrayLengthAMDX = 5090, + SpvOpIsNodePayloadValidAMDX = 5101, + SpvOpConstantStringAMDX = 5103, + SpvOpSpecConstantStringAMDX = 5104, + SpvOpGroupNonUniformQuadAllKHR = 5110, + SpvOpGroupNonUniformQuadAnyKHR = 5111, SpvOpHitObjectRecordHitMotionNV = 5249, SpvOpHitObjectRecordHitWithIndexMotionNV = 5250, SpvOpHitObjectRecordMissMotionNV = 5251, @@ -1666,10 +2026,20 @@ typedef enum SpvOp_ { SpvOpReorderThreadWithHintNV = 5280, SpvOpTypeHitObjectNV = 5281, SpvOpImageSampleFootprintNV = 5283, + SpvOpTypeCooperativeVectorNV = 5288, + SpvOpCooperativeVectorMatrixMulNV = 5289, + SpvOpCooperativeVectorOuterProductAccumulateNV = 5290, + SpvOpCooperativeVectorReduceSumAccumulateNV = 5291, + SpvOpCooperativeVectorMatrixMulAddNV = 5292, + SpvOpCooperativeMatrixConvertNV = 5293, SpvOpEmitMeshTasksEXT = 5294, SpvOpSetMeshOutputsEXT = 5295, SpvOpGroupNonUniformPartitionNV = 5296, SpvOpWritePackedPrimitiveIndices4x8NV = 5299, + SpvOpFetchMicroTriangleVertexPositionNV = 5300, + SpvOpFetchMicroTriangleVertexBarycentricNV = 5301, + SpvOpCooperativeVectorLoadNV = 5302, + SpvOpCooperativeVectorStoreNV = 5303, SpvOpReportIntersectionKHR = 5334, SpvOpReportIntersectionNV = 5334, SpvOpIgnoreIntersectionNV = 5335, @@ -1677,9 +2047,12 @@ typedef enum SpvOp_ { SpvOpTraceNV = 5337, SpvOpTraceMotionNV = 5338, SpvOpTraceRayMotionNV = 5339, + SpvOpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, SpvOpTypeAccelerationStructureKHR = 5341, SpvOpTypeAccelerationStructureNV = 5341, SpvOpExecuteCallableNV = 5344, + SpvOpRayQueryGetClusterIdNV = 5345, + SpvOpHitObjectGetClusterIdNV = 5346, SpvOpTypeCooperativeMatrixNV = 5358, SpvOpCooperativeMatrixLoadNV = 5359, SpvOpCooperativeMatrixStoreNV = 5360, @@ -1687,9 +2060,26 @@ typedef enum SpvOp_ { SpvOpCooperativeMatrixLengthNV = 5362, SpvOpBeginInvocationInterlockEXT = 5364, SpvOpEndInvocationInterlockEXT = 5365, + SpvOpCooperativeMatrixReduceNV = 5366, + SpvOpCooperativeMatrixLoadTensorNV = 5367, + SpvOpCooperativeMatrixStoreTensorNV = 5368, + SpvOpCooperativeMatrixPerElementOpNV = 5369, + SpvOpTypeTensorLayoutNV = 5370, + SpvOpTypeTensorViewNV = 5371, + SpvOpCreateTensorLayoutNV = 5372, + SpvOpTensorLayoutSetDimensionNV = 5373, + SpvOpTensorLayoutSetStrideNV = 5374, + SpvOpTensorLayoutSliceNV = 5375, + SpvOpTensorLayoutSetClampValueNV = 5376, + SpvOpCreateTensorViewNV = 5377, + SpvOpTensorViewSetDimensionNV = 5378, + SpvOpTensorViewSetStrideNV = 5379, SpvOpDemoteToHelperInvocation = 5380, SpvOpDemoteToHelperInvocationEXT = 5380, SpvOpIsHelperInvocationEXT = 5381, + SpvOpTensorViewSetClipNV = 5382, + SpvOpTensorLayoutSetBlockSizeNV = 5384, + SpvOpCooperativeMatrixTransposeNV = 5390, SpvOpConvertUToImageNV = 5391, SpvOpConvertUToSamplerNV = 5392, SpvOpConvertImageToUNV = 5393, @@ -1697,6 +2087,20 @@ typedef enum SpvOp_ { SpvOpConvertUToSampledImageNV = 5395, SpvOpConvertSampledImageToUNV = 5396, SpvOpSamplerImageAddressingModeNV = 5397, + SpvOpRawAccessChainNV = 5398, + SpvOpRayQueryGetIntersectionSpherePositionNV = 5427, + SpvOpRayQueryGetIntersectionSphereRadiusNV = 5428, + SpvOpRayQueryGetIntersectionLSSPositionsNV = 5429, + SpvOpRayQueryGetIntersectionLSSRadiiNV = 5430, + SpvOpRayQueryGetIntersectionLSSHitValueNV = 5431, + SpvOpHitObjectGetSpherePositionNV = 5432, + SpvOpHitObjectGetSphereRadiusNV = 5433, + SpvOpHitObjectGetLSSPositionsNV = 5434, + SpvOpHitObjectGetLSSRadiiNV = 5435, + SpvOpHitObjectIsSphereHitNV = 5436, + SpvOpHitObjectIsLSSHitNV = 5437, + SpvOpRayQueryIsSphereHitNV = 5438, + SpvOpRayQueryIsLSSHitNV = 5439, SpvOpSubgroupShuffleINTEL = 5571, SpvOpSubgroupShuffleDownINTEL = 5572, SpvOpSubgroupShuffleUpINTEL = 5573, @@ -1938,8 +2342,19 @@ typedef enum SpvOp_ { SpvOpTypeStructContinuedINTEL = 6090, SpvOpConstantCompositeContinuedINTEL = 6091, SpvOpSpecConstantCompositeContinuedINTEL = 6092, + SpvOpCompositeConstructContinuedINTEL = 6096, + SpvOpConvertFToBF16INTEL = 6116, + SpvOpConvertBF16ToFINTEL = 6117, SpvOpControlBarrierArriveINTEL = 6142, SpvOpControlBarrierWaitINTEL = 6143, + SpvOpArithmeticFenceEXT = 6145, + SpvOpSubgroupBlockPrefetchINTEL = 6221, + SpvOpSubgroup2DBlockLoadINTEL = 6231, + SpvOpSubgroup2DBlockLoadTransformINTEL = 6232, + SpvOpSubgroup2DBlockLoadTransposeINTEL = 6233, + SpvOpSubgroup2DBlockPrefetchINTEL = 6234, + SpvOpSubgroup2DBlockStoreINTEL = 6235, + SpvOpSubgroupMatrixMultiplyAccumulateINTEL = 6237, SpvOpGroupIMulKHR = 6401, SpvOpGroupFMulKHR = 6402, SpvOpGroupBitwiseAndKHR = 6403, @@ -1948,6 +2363,8 @@ typedef enum SpvOp_ { SpvOpGroupLogicalAndKHR = 6406, SpvOpGroupLogicalOrKHR = 6407, SpvOpGroupLogicalXorKHR = 6408, + SpvOpMaskedGatherINTEL = 6428, + SpvOpMaskedScatterINTEL = 6429, SpvOpMax = 0x7fffffff, } SpvOp; @@ -2303,14 +2720,26 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpPtrEqual: *hasResult = true; *hasResultType = true; break; case SpvOpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case SpvOpPtrDiff: *hasResult = true; *hasResultType = true; break; + case SpvOpColorAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpDepthAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpStencilAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case SpvOpTerminateInvocation: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeUntypedPointerKHR: *hasResult = true; *hasResultType = false; break; + case SpvOpUntypedVariableKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedInBoundsAccessChainKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedInBoundsPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedArrayLengthKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpUntypedPrefetchKHR: *hasResult = false; *hasResultType = false; break; case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpExtInstWithForwardRefsKHR: *hasResult = true; *hasResultType = true; break; case SpvOpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case SpvOpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case SpvOpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; @@ -2322,6 +2751,14 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpSDotAccSat: *hasResult = true; *hasResultType = true; break; case SpvOpUDotAccSat: *hasResult = true; *hasResultType = true; break; case SpvOpSUDotAccSat: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeCooperativeMatrixKHR: *hasResult = true; *hasResultType = false; break; + case SpvOpCooperativeMatrixLoadKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixStoreKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeMatrixMulAddKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixLengthKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpCompositeConstructReplicateEXT: *hasResult = true; *hasResultType = true; break; case SpvOpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case SpvOpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2329,6 +2766,14 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break; + case SpvOpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break; case SpvOpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case SpvOpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case SpvOpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; @@ -2340,6 +2785,16 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break; case SpvOpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break; case SpvOpReadClockKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpAllocateNodePayloadsAMDX: *hasResult = true; *hasResultType = true; break; + case SpvOpEnqueueNodePayloadsAMDX: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeNodePayloadArrayAMDX: *hasResult = true; *hasResultType = false; break; + case SpvOpFinishWritingNodePayloadAMDX: *hasResult = true; *hasResultType = true; break; + case SpvOpNodePayloadArrayLengthAMDX: *hasResult = true; *hasResultType = true; break; + case SpvOpIsNodePayloadValidAMDX: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case SpvOpSpecConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case SpvOpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break; case SpvOpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break; case SpvOpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break; case SpvOpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break; @@ -2374,18 +2829,31 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpReorderThreadWithHintNV: *hasResult = false; *hasResultType = false; break; case SpvOpTypeHitObjectNV: *hasResult = true; *hasResultType = false; break; case SpvOpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeCooperativeVectorNV: *hasResult = true; *hasResultType = false; break; + case SpvOpCooperativeVectorMatrixMulNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeVectorOuterProductAccumulateNV: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeVectorReduceSumAccumulateNV: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeVectorMatrixMulAddNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixConvertNV: *hasResult = true; *hasResultType = true; break; case SpvOpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break; case SpvOpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break; case SpvOpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; case SpvOpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; - case SpvOpReportIntersectionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpFetchMicroTriangleVertexPositionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpFetchMicroTriangleVertexBarycentricNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeVectorLoadNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeVectorStoreNV: *hasResult = false; *hasResultType = false; break; + case SpvOpReportIntersectionKHR: *hasResult = true; *hasResultType = true; break; case SpvOpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; case SpvOpTerminateRayNV: *hasResult = false; *hasResultType = false; break; case SpvOpTraceNV: *hasResult = false; *hasResultType = false; break; case SpvOpTraceMotionNV: *hasResult = false; *hasResultType = false; break; case SpvOpTraceRayMotionNV: *hasResult = false; *hasResultType = false; break; - case SpvOpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break; + case SpvOpRayQueryGetIntersectionTriangleVertexPositionsKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeAccelerationStructureKHR: *hasResult = true; *hasResultType = false; break; case SpvOpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; + case SpvOpRayQueryGetClusterIdNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetClusterIdNV: *hasResult = true; *hasResultType = true; break; case SpvOpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case SpvOpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case SpvOpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; @@ -2393,8 +2861,25 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case SpvOpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case SpvOpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeMatrixReduceNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixLoadTensorNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixStoreTensorNV: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeMatrixPerElementOpNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeTensorLayoutNV: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeTensorViewNV: *hasResult = true; *hasResultType = false; break; + case SpvOpCreateTensorLayoutNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorLayoutSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorLayoutSetStrideNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorLayoutSliceNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorLayoutSetClampValueNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCreateTensorViewNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorViewSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorViewSetStrideNV: *hasResult = true; *hasResultType = true; break; case SpvOpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case SpvOpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorViewSetClipNV: *hasResult = true; *hasResultType = true; break; + case SpvOpTensorLayoutSetBlockSizeNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixTransposeNV: *hasResult = true; *hasResultType = true; break; case SpvOpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case SpvOpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; case SpvOpConvertImageToUNV: *hasResult = true; *hasResultType = true; break; @@ -2402,6 +2887,20 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpConvertUToSampledImageNV: *hasResult = true; *hasResultType = true; break; case SpvOpConvertSampledImageToUNV: *hasResult = true; *hasResultType = true; break; case SpvOpSamplerImageAddressingModeNV: *hasResult = false; *hasResultType = false; break; + case SpvOpRawAccessChainNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionLSSHitValueNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectIsLSSHitNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryIsLSSHitNV: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break; @@ -2428,7 +2927,7 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; case SpvOpConstantFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpAsmTargetINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpAsmTargetINTEL: *hasResult = true; *hasResultType = false; break; case SpvOpAsmINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpAsmCallINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpAtomicFMinEXT: *hasResult = true; *hasResultType = true; break; @@ -2641,8 +3140,19 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpCompositeConstructContinuedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertFToBF16INTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertBF16ToFINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpArithmeticFenceEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroup2DBlockLoadINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroup2DBlockLoadTransformINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroup2DBlockLoadTransposeINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroup2DBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroup2DBlockStoreINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroupMatrixMultiplyAccumulateINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; @@ -2651,8 +3161,1932 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpMaskedGatherINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpMaskedScatterINTEL: *hasResult = false; *hasResultType = false; break; } } +inline const char* SpvSourceLanguageToString(SpvSourceLanguage value) { + switch (value) { + case SpvSourceLanguageUnknown: return "Unknown"; + case SpvSourceLanguageESSL: return "ESSL"; + case SpvSourceLanguageGLSL: return "GLSL"; + case SpvSourceLanguageOpenCL_C: return "OpenCL_C"; + case SpvSourceLanguageOpenCL_CPP: return "OpenCL_CPP"; + case SpvSourceLanguageHLSL: return "HLSL"; + case SpvSourceLanguageCPP_for_OpenCL: return "CPP_for_OpenCL"; + case SpvSourceLanguageSYCL: return "SYCL"; + case SpvSourceLanguageHERO_C: return "HERO_C"; + case SpvSourceLanguageNZSL: return "NZSL"; + case SpvSourceLanguageWGSL: return "WGSL"; + case SpvSourceLanguageSlang: return "Slang"; + case SpvSourceLanguageZig: return "Zig"; + case SpvSourceLanguageRust: return "Rust"; + default: return "Unknown"; + } +} + +inline const char* SpvExecutionModelToString(SpvExecutionModel value) { + switch (value) { + case SpvExecutionModelVertex: return "Vertex"; + case SpvExecutionModelTessellationControl: return "TessellationControl"; + case SpvExecutionModelTessellationEvaluation: return "TessellationEvaluation"; + case SpvExecutionModelGeometry: return "Geometry"; + case SpvExecutionModelFragment: return "Fragment"; + case SpvExecutionModelGLCompute: return "GLCompute"; + case SpvExecutionModelKernel: return "Kernel"; + case SpvExecutionModelTaskNV: return "TaskNV"; + case SpvExecutionModelMeshNV: return "MeshNV"; + case SpvExecutionModelRayGenerationKHR: return "RayGenerationKHR"; + case SpvExecutionModelIntersectionKHR: return "IntersectionKHR"; + case SpvExecutionModelAnyHitKHR: return "AnyHitKHR"; + case SpvExecutionModelClosestHitKHR: return "ClosestHitKHR"; + case SpvExecutionModelMissKHR: return "MissKHR"; + case SpvExecutionModelCallableKHR: return "CallableKHR"; + case SpvExecutionModelTaskEXT: return "TaskEXT"; + case SpvExecutionModelMeshEXT: return "MeshEXT"; + default: return "Unknown"; + } +} + +inline const char* SpvAddressingModelToString(SpvAddressingModel value) { + switch (value) { + case SpvAddressingModelLogical: return "Logical"; + case SpvAddressingModelPhysical32: return "Physical32"; + case SpvAddressingModelPhysical64: return "Physical64"; + case SpvAddressingModelPhysicalStorageBuffer64: return "PhysicalStorageBuffer64"; + default: return "Unknown"; + } +} + +inline const char* SpvMemoryModelToString(SpvMemoryModel value) { + switch (value) { + case SpvMemoryModelSimple: return "Simple"; + case SpvMemoryModelGLSL450: return "GLSL450"; + case SpvMemoryModelOpenCL: return "OpenCL"; + case SpvMemoryModelVulkan: return "Vulkan"; + default: return "Unknown"; + } +} + +inline const char* SpvExecutionModeToString(SpvExecutionMode value) { + switch (value) { + case SpvExecutionModeInvocations: return "Invocations"; + case SpvExecutionModeSpacingEqual: return "SpacingEqual"; + case SpvExecutionModeSpacingFractionalEven: return "SpacingFractionalEven"; + case SpvExecutionModeSpacingFractionalOdd: return "SpacingFractionalOdd"; + case SpvExecutionModeVertexOrderCw: return "VertexOrderCw"; + case SpvExecutionModeVertexOrderCcw: return "VertexOrderCcw"; + case SpvExecutionModePixelCenterInteger: return "PixelCenterInteger"; + case SpvExecutionModeOriginUpperLeft: return "OriginUpperLeft"; + case SpvExecutionModeOriginLowerLeft: return "OriginLowerLeft"; + case SpvExecutionModeEarlyFragmentTests: return "EarlyFragmentTests"; + case SpvExecutionModePointMode: return "PointMode"; + case SpvExecutionModeXfb: return "Xfb"; + case SpvExecutionModeDepthReplacing: return "DepthReplacing"; + case SpvExecutionModeDepthGreater: return "DepthGreater"; + case SpvExecutionModeDepthLess: return "DepthLess"; + case SpvExecutionModeDepthUnchanged: return "DepthUnchanged"; + case SpvExecutionModeLocalSize: return "LocalSize"; + case SpvExecutionModeLocalSizeHint: return "LocalSizeHint"; + case SpvExecutionModeInputPoints: return "InputPoints"; + case SpvExecutionModeInputLines: return "InputLines"; + case SpvExecutionModeInputLinesAdjacency: return "InputLinesAdjacency"; + case SpvExecutionModeTriangles: return "Triangles"; + case SpvExecutionModeInputTrianglesAdjacency: return "InputTrianglesAdjacency"; + case SpvExecutionModeQuads: return "Quads"; + case SpvExecutionModeIsolines: return "Isolines"; + case SpvExecutionModeOutputVertices: return "OutputVertices"; + case SpvExecutionModeOutputPoints: return "OutputPoints"; + case SpvExecutionModeOutputLineStrip: return "OutputLineStrip"; + case SpvExecutionModeOutputTriangleStrip: return "OutputTriangleStrip"; + case SpvExecutionModeVecTypeHint: return "VecTypeHint"; + case SpvExecutionModeContractionOff: return "ContractionOff"; + case SpvExecutionModeInitializer: return "Initializer"; + case SpvExecutionModeFinalizer: return "Finalizer"; + case SpvExecutionModeSubgroupSize: return "SubgroupSize"; + case SpvExecutionModeSubgroupsPerWorkgroup: return "SubgroupsPerWorkgroup"; + case SpvExecutionModeSubgroupsPerWorkgroupId: return "SubgroupsPerWorkgroupId"; + case SpvExecutionModeLocalSizeId: return "LocalSizeId"; + case SpvExecutionModeLocalSizeHintId: return "LocalSizeHintId"; + case SpvExecutionModeNonCoherentColorAttachmentReadEXT: return "NonCoherentColorAttachmentReadEXT"; + case SpvExecutionModeNonCoherentDepthAttachmentReadEXT: return "NonCoherentDepthAttachmentReadEXT"; + case SpvExecutionModeNonCoherentStencilAttachmentReadEXT: return "NonCoherentStencilAttachmentReadEXT"; + case SpvExecutionModeSubgroupUniformControlFlowKHR: return "SubgroupUniformControlFlowKHR"; + case SpvExecutionModePostDepthCoverage: return "PostDepthCoverage"; + case SpvExecutionModeDenormPreserve: return "DenormPreserve"; + case SpvExecutionModeDenormFlushToZero: return "DenormFlushToZero"; + case SpvExecutionModeSignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case SpvExecutionModeRoundingModeRTE: return "RoundingModeRTE"; + case SpvExecutionModeRoundingModeRTZ: return "RoundingModeRTZ"; + case SpvExecutionModeEarlyAndLateFragmentTestsAMD: return "EarlyAndLateFragmentTestsAMD"; + case SpvExecutionModeStencilRefReplacingEXT: return "StencilRefReplacingEXT"; + case SpvExecutionModeCoalescingAMDX: return "CoalescingAMDX"; + case SpvExecutionModeIsApiEntryAMDX: return "IsApiEntryAMDX"; + case SpvExecutionModeMaxNodeRecursionAMDX: return "MaxNodeRecursionAMDX"; + case SpvExecutionModeStaticNumWorkgroupsAMDX: return "StaticNumWorkgroupsAMDX"; + case SpvExecutionModeShaderIndexAMDX: return "ShaderIndexAMDX"; + case SpvExecutionModeMaxNumWorkgroupsAMDX: return "MaxNumWorkgroupsAMDX"; + case SpvExecutionModeStencilRefUnchangedFrontAMD: return "StencilRefUnchangedFrontAMD"; + case SpvExecutionModeStencilRefGreaterFrontAMD: return "StencilRefGreaterFrontAMD"; + case SpvExecutionModeStencilRefLessFrontAMD: return "StencilRefLessFrontAMD"; + case SpvExecutionModeStencilRefUnchangedBackAMD: return "StencilRefUnchangedBackAMD"; + case SpvExecutionModeStencilRefGreaterBackAMD: return "StencilRefGreaterBackAMD"; + case SpvExecutionModeStencilRefLessBackAMD: return "StencilRefLessBackAMD"; + case SpvExecutionModeQuadDerivativesKHR: return "QuadDerivativesKHR"; + case SpvExecutionModeRequireFullQuadsKHR: return "RequireFullQuadsKHR"; + case SpvExecutionModeSharesInputWithAMDX: return "SharesInputWithAMDX"; + case SpvExecutionModeOutputLinesEXT: return "OutputLinesEXT"; + case SpvExecutionModeOutputPrimitivesEXT: return "OutputPrimitivesEXT"; + case SpvExecutionModeDerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR"; + case SpvExecutionModeDerivativeGroupLinearKHR: return "DerivativeGroupLinearKHR"; + case SpvExecutionModeOutputTrianglesEXT: return "OutputTrianglesEXT"; + case SpvExecutionModePixelInterlockOrderedEXT: return "PixelInterlockOrderedEXT"; + case SpvExecutionModePixelInterlockUnorderedEXT: return "PixelInterlockUnorderedEXT"; + case SpvExecutionModeSampleInterlockOrderedEXT: return "SampleInterlockOrderedEXT"; + case SpvExecutionModeSampleInterlockUnorderedEXT: return "SampleInterlockUnorderedEXT"; + case SpvExecutionModeShadingRateInterlockOrderedEXT: return "ShadingRateInterlockOrderedEXT"; + case SpvExecutionModeShadingRateInterlockUnorderedEXT: return "ShadingRateInterlockUnorderedEXT"; + case SpvExecutionModeSharedLocalMemorySizeINTEL: return "SharedLocalMemorySizeINTEL"; + case SpvExecutionModeRoundingModeRTPINTEL: return "RoundingModeRTPINTEL"; + case SpvExecutionModeRoundingModeRTNINTEL: return "RoundingModeRTNINTEL"; + case SpvExecutionModeFloatingPointModeALTINTEL: return "FloatingPointModeALTINTEL"; + case SpvExecutionModeFloatingPointModeIEEEINTEL: return "FloatingPointModeIEEEINTEL"; + case SpvExecutionModeMaxWorkgroupSizeINTEL: return "MaxWorkgroupSizeINTEL"; + case SpvExecutionModeMaxWorkDimINTEL: return "MaxWorkDimINTEL"; + case SpvExecutionModeNoGlobalOffsetINTEL: return "NoGlobalOffsetINTEL"; + case SpvExecutionModeNumSIMDWorkitemsINTEL: return "NumSIMDWorkitemsINTEL"; + case SpvExecutionModeSchedulerTargetFmaxMhzINTEL: return "SchedulerTargetFmaxMhzINTEL"; + case SpvExecutionModeMaximallyReconvergesKHR: return "MaximallyReconvergesKHR"; + case SpvExecutionModeFPFastMathDefault: return "FPFastMathDefault"; + case SpvExecutionModeStreamingInterfaceINTEL: return "StreamingInterfaceINTEL"; + case SpvExecutionModeRegisterMapInterfaceINTEL: return "RegisterMapInterfaceINTEL"; + case SpvExecutionModeNamedBarrierCountINTEL: return "NamedBarrierCountINTEL"; + case SpvExecutionModeMaximumRegistersINTEL: return "MaximumRegistersINTEL"; + case SpvExecutionModeMaximumRegistersIdINTEL: return "MaximumRegistersIdINTEL"; + case SpvExecutionModeNamedMaximumRegistersINTEL: return "NamedMaximumRegistersINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvStorageClassToString(SpvStorageClass value) { + switch (value) { + case SpvStorageClassUniformConstant: return "UniformConstant"; + case SpvStorageClassInput: return "Input"; + case SpvStorageClassUniform: return "Uniform"; + case SpvStorageClassOutput: return "Output"; + case SpvStorageClassWorkgroup: return "Workgroup"; + case SpvStorageClassCrossWorkgroup: return "CrossWorkgroup"; + case SpvStorageClassPrivate: return "Private"; + case SpvStorageClassFunction: return "Function"; + case SpvStorageClassGeneric: return "Generic"; + case SpvStorageClassPushConstant: return "PushConstant"; + case SpvStorageClassAtomicCounter: return "AtomicCounter"; + case SpvStorageClassImage: return "Image"; + case SpvStorageClassStorageBuffer: return "StorageBuffer"; + case SpvStorageClassTileImageEXT: return "TileImageEXT"; + case SpvStorageClassNodePayloadAMDX: return "NodePayloadAMDX"; + case SpvStorageClassCallableDataKHR: return "CallableDataKHR"; + case SpvStorageClassIncomingCallableDataKHR: return "IncomingCallableDataKHR"; + case SpvStorageClassRayPayloadKHR: return "RayPayloadKHR"; + case SpvStorageClassHitAttributeKHR: return "HitAttributeKHR"; + case SpvStorageClassIncomingRayPayloadKHR: return "IncomingRayPayloadKHR"; + case SpvStorageClassShaderRecordBufferKHR: return "ShaderRecordBufferKHR"; + case SpvStorageClassPhysicalStorageBuffer: return "PhysicalStorageBuffer"; + case SpvStorageClassHitObjectAttributeNV: return "HitObjectAttributeNV"; + case SpvStorageClassTaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT"; + case SpvStorageClassCodeSectionINTEL: return "CodeSectionINTEL"; + case SpvStorageClassDeviceOnlyINTEL: return "DeviceOnlyINTEL"; + case SpvStorageClassHostOnlyINTEL: return "HostOnlyINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvDimToString(SpvDim value) { + switch (value) { + case SpvDim1D: return "1D"; + case SpvDim2D: return "2D"; + case SpvDim3D: return "3D"; + case SpvDimCube: return "Cube"; + case SpvDimRect: return "Rect"; + case SpvDimBuffer: return "Buffer"; + case SpvDimSubpassData: return "SubpassData"; + case SpvDimTileImageDataEXT: return "TileImageDataEXT"; + default: return "Unknown"; + } +} + +inline const char* SpvSamplerAddressingModeToString(SpvSamplerAddressingMode value) { + switch (value) { + case SpvSamplerAddressingModeNone: return "None"; + case SpvSamplerAddressingModeClampToEdge: return "ClampToEdge"; + case SpvSamplerAddressingModeClamp: return "Clamp"; + case SpvSamplerAddressingModeRepeat: return "Repeat"; + case SpvSamplerAddressingModeRepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* SpvSamplerFilterModeToString(SpvSamplerFilterMode value) { + switch (value) { + case SpvSamplerFilterModeNearest: return "Nearest"; + case SpvSamplerFilterModeLinear: return "Linear"; + default: return "Unknown"; + } +} + +inline const char* SpvImageFormatToString(SpvImageFormat value) { + switch (value) { + case SpvImageFormatUnknown: return "Unknown"; + case SpvImageFormatRgba32f: return "Rgba32f"; + case SpvImageFormatRgba16f: return "Rgba16f"; + case SpvImageFormatR32f: return "R32f"; + case SpvImageFormatRgba8: return "Rgba8"; + case SpvImageFormatRgba8Snorm: return "Rgba8Snorm"; + case SpvImageFormatRg32f: return "Rg32f"; + case SpvImageFormatRg16f: return "Rg16f"; + case SpvImageFormatR11fG11fB10f: return "R11fG11fB10f"; + case SpvImageFormatR16f: return "R16f"; + case SpvImageFormatRgba16: return "Rgba16"; + case SpvImageFormatRgb10A2: return "Rgb10A2"; + case SpvImageFormatRg16: return "Rg16"; + case SpvImageFormatRg8: return "Rg8"; + case SpvImageFormatR16: return "R16"; + case SpvImageFormatR8: return "R8"; + case SpvImageFormatRgba16Snorm: return "Rgba16Snorm"; + case SpvImageFormatRg16Snorm: return "Rg16Snorm"; + case SpvImageFormatRg8Snorm: return "Rg8Snorm"; + case SpvImageFormatR16Snorm: return "R16Snorm"; + case SpvImageFormatR8Snorm: return "R8Snorm"; + case SpvImageFormatRgba32i: return "Rgba32i"; + case SpvImageFormatRgba16i: return "Rgba16i"; + case SpvImageFormatRgba8i: return "Rgba8i"; + case SpvImageFormatR32i: return "R32i"; + case SpvImageFormatRg32i: return "Rg32i"; + case SpvImageFormatRg16i: return "Rg16i"; + case SpvImageFormatRg8i: return "Rg8i"; + case SpvImageFormatR16i: return "R16i"; + case SpvImageFormatR8i: return "R8i"; + case SpvImageFormatRgba32ui: return "Rgba32ui"; + case SpvImageFormatRgba16ui: return "Rgba16ui"; + case SpvImageFormatRgba8ui: return "Rgba8ui"; + case SpvImageFormatR32ui: return "R32ui"; + case SpvImageFormatRgb10a2ui: return "Rgb10a2ui"; + case SpvImageFormatRg32ui: return "Rg32ui"; + case SpvImageFormatRg16ui: return "Rg16ui"; + case SpvImageFormatRg8ui: return "Rg8ui"; + case SpvImageFormatR16ui: return "R16ui"; + case SpvImageFormatR8ui: return "R8ui"; + case SpvImageFormatR64ui: return "R64ui"; + case SpvImageFormatR64i: return "R64i"; + default: return "Unknown"; + } +} + +inline const char* SpvImageChannelOrderToString(SpvImageChannelOrder value) { + switch (value) { + case SpvImageChannelOrderR: return "R"; + case SpvImageChannelOrderA: return "A"; + case SpvImageChannelOrderRG: return "RG"; + case SpvImageChannelOrderRA: return "RA"; + case SpvImageChannelOrderRGB: return "RGB"; + case SpvImageChannelOrderRGBA: return "RGBA"; + case SpvImageChannelOrderBGRA: return "BGRA"; + case SpvImageChannelOrderARGB: return "ARGB"; + case SpvImageChannelOrderIntensity: return "Intensity"; + case SpvImageChannelOrderLuminance: return "Luminance"; + case SpvImageChannelOrderRx: return "Rx"; + case SpvImageChannelOrderRGx: return "RGx"; + case SpvImageChannelOrderRGBx: return "RGBx"; + case SpvImageChannelOrderDepth: return "Depth"; + case SpvImageChannelOrderDepthStencil: return "DepthStencil"; + case SpvImageChannelOrdersRGB: return "sRGB"; + case SpvImageChannelOrdersRGBx: return "sRGBx"; + case SpvImageChannelOrdersRGBA: return "sRGBA"; + case SpvImageChannelOrdersBGRA: return "sBGRA"; + case SpvImageChannelOrderABGR: return "ABGR"; + default: return "Unknown"; + } +} + +inline const char* SpvImageChannelDataTypeToString(SpvImageChannelDataType value) { + switch (value) { + case SpvImageChannelDataTypeSnormInt8: return "SnormInt8"; + case SpvImageChannelDataTypeSnormInt16: return "SnormInt16"; + case SpvImageChannelDataTypeUnormInt8: return "UnormInt8"; + case SpvImageChannelDataTypeUnormInt16: return "UnormInt16"; + case SpvImageChannelDataTypeUnormShort565: return "UnormShort565"; + case SpvImageChannelDataTypeUnormShort555: return "UnormShort555"; + case SpvImageChannelDataTypeUnormInt101010: return "UnormInt101010"; + case SpvImageChannelDataTypeSignedInt8: return "SignedInt8"; + case SpvImageChannelDataTypeSignedInt16: return "SignedInt16"; + case SpvImageChannelDataTypeSignedInt32: return "SignedInt32"; + case SpvImageChannelDataTypeUnsignedInt8: return "UnsignedInt8"; + case SpvImageChannelDataTypeUnsignedInt16: return "UnsignedInt16"; + case SpvImageChannelDataTypeUnsignedInt32: return "UnsignedInt32"; + case SpvImageChannelDataTypeHalfFloat: return "HalfFloat"; + case SpvImageChannelDataTypeFloat: return "Float"; + case SpvImageChannelDataTypeUnormInt24: return "UnormInt24"; + case SpvImageChannelDataTypeUnormInt101010_2: return "UnormInt101010_2"; + case SpvImageChannelDataTypeUnsignedIntRaw10EXT: return "UnsignedIntRaw10EXT"; + case SpvImageChannelDataTypeUnsignedIntRaw12EXT: return "UnsignedIntRaw12EXT"; + case SpvImageChannelDataTypeUnormInt2_101010EXT: return "UnormInt2_101010EXT"; + default: return "Unknown"; + } +} + +inline const char* SpvFPRoundingModeToString(SpvFPRoundingMode value) { + switch (value) { + case SpvFPRoundingModeRTE: return "RTE"; + case SpvFPRoundingModeRTZ: return "RTZ"; + case SpvFPRoundingModeRTP: return "RTP"; + case SpvFPRoundingModeRTN: return "RTN"; + default: return "Unknown"; + } +} + +inline const char* SpvLinkageTypeToString(SpvLinkageType value) { + switch (value) { + case SpvLinkageTypeExport: return "Export"; + case SpvLinkageTypeImport: return "Import"; + case SpvLinkageTypeLinkOnceODR: return "LinkOnceODR"; + default: return "Unknown"; + } +} + +inline const char* SpvAccessQualifierToString(SpvAccessQualifier value) { + switch (value) { + case SpvAccessQualifierReadOnly: return "ReadOnly"; + case SpvAccessQualifierWriteOnly: return "WriteOnly"; + case SpvAccessQualifierReadWrite: return "ReadWrite"; + default: return "Unknown"; + } +} + +inline const char* SpvFunctionParameterAttributeToString(SpvFunctionParameterAttribute value) { + switch (value) { + case SpvFunctionParameterAttributeZext: return "Zext"; + case SpvFunctionParameterAttributeSext: return "Sext"; + case SpvFunctionParameterAttributeByVal: return "ByVal"; + case SpvFunctionParameterAttributeSret: return "Sret"; + case SpvFunctionParameterAttributeNoAlias: return "NoAlias"; + case SpvFunctionParameterAttributeNoCapture: return "NoCapture"; + case SpvFunctionParameterAttributeNoWrite: return "NoWrite"; + case SpvFunctionParameterAttributeNoReadWrite: return "NoReadWrite"; + case SpvFunctionParameterAttributeRuntimeAlignedINTEL: return "RuntimeAlignedINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvDecorationToString(SpvDecoration value) { + switch (value) { + case SpvDecorationRelaxedPrecision: return "RelaxedPrecision"; + case SpvDecorationSpecId: return "SpecId"; + case SpvDecorationBlock: return "Block"; + case SpvDecorationBufferBlock: return "BufferBlock"; + case SpvDecorationRowMajor: return "RowMajor"; + case SpvDecorationColMajor: return "ColMajor"; + case SpvDecorationArrayStride: return "ArrayStride"; + case SpvDecorationMatrixStride: return "MatrixStride"; + case SpvDecorationGLSLShared: return "GLSLShared"; + case SpvDecorationGLSLPacked: return "GLSLPacked"; + case SpvDecorationCPacked: return "CPacked"; + case SpvDecorationBuiltIn: return "BuiltIn"; + case SpvDecorationNoPerspective: return "NoPerspective"; + case SpvDecorationFlat: return "Flat"; + case SpvDecorationPatch: return "Patch"; + case SpvDecorationCentroid: return "Centroid"; + case SpvDecorationSample: return "Sample"; + case SpvDecorationInvariant: return "Invariant"; + case SpvDecorationRestrict: return "Restrict"; + case SpvDecorationAliased: return "Aliased"; + case SpvDecorationVolatile: return "Volatile"; + case SpvDecorationConstant: return "Constant"; + case SpvDecorationCoherent: return "Coherent"; + case SpvDecorationNonWritable: return "NonWritable"; + case SpvDecorationNonReadable: return "NonReadable"; + case SpvDecorationUniform: return "Uniform"; + case SpvDecorationUniformId: return "UniformId"; + case SpvDecorationSaturatedConversion: return "SaturatedConversion"; + case SpvDecorationStream: return "Stream"; + case SpvDecorationLocation: return "Location"; + case SpvDecorationComponent: return "Component"; + case SpvDecorationIndex: return "Index"; + case SpvDecorationBinding: return "Binding"; + case SpvDecorationDescriptorSet: return "DescriptorSet"; + case SpvDecorationOffset: return "Offset"; + case SpvDecorationXfbBuffer: return "XfbBuffer"; + case SpvDecorationXfbStride: return "XfbStride"; + case SpvDecorationFuncParamAttr: return "FuncParamAttr"; + case SpvDecorationFPRoundingMode: return "FPRoundingMode"; + case SpvDecorationFPFastMathMode: return "FPFastMathMode"; + case SpvDecorationLinkageAttributes: return "LinkageAttributes"; + case SpvDecorationNoContraction: return "NoContraction"; + case SpvDecorationInputAttachmentIndex: return "InputAttachmentIndex"; + case SpvDecorationAlignment: return "Alignment"; + case SpvDecorationMaxByteOffset: return "MaxByteOffset"; + case SpvDecorationAlignmentId: return "AlignmentId"; + case SpvDecorationMaxByteOffsetId: return "MaxByteOffsetId"; + case SpvDecorationNoSignedWrap: return "NoSignedWrap"; + case SpvDecorationNoUnsignedWrap: return "NoUnsignedWrap"; + case SpvDecorationWeightTextureQCOM: return "WeightTextureQCOM"; + case SpvDecorationBlockMatchTextureQCOM: return "BlockMatchTextureQCOM"; + case SpvDecorationBlockMatchSamplerQCOM: return "BlockMatchSamplerQCOM"; + case SpvDecorationExplicitInterpAMD: return "ExplicitInterpAMD"; + case SpvDecorationNodeSharesPayloadLimitsWithAMDX: return "NodeSharesPayloadLimitsWithAMDX"; + case SpvDecorationNodeMaxPayloadsAMDX: return "NodeMaxPayloadsAMDX"; + case SpvDecorationTrackFinishWritingAMDX: return "TrackFinishWritingAMDX"; + case SpvDecorationPayloadNodeNameAMDX: return "PayloadNodeNameAMDX"; + case SpvDecorationPayloadNodeBaseIndexAMDX: return "PayloadNodeBaseIndexAMDX"; + case SpvDecorationPayloadNodeSparseArrayAMDX: return "PayloadNodeSparseArrayAMDX"; + case SpvDecorationPayloadNodeArraySizeAMDX: return "PayloadNodeArraySizeAMDX"; + case SpvDecorationPayloadDispatchIndirectAMDX: return "PayloadDispatchIndirectAMDX"; + case SpvDecorationOverrideCoverageNV: return "OverrideCoverageNV"; + case SpvDecorationPassthroughNV: return "PassthroughNV"; + case SpvDecorationViewportRelativeNV: return "ViewportRelativeNV"; + case SpvDecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV"; + case SpvDecorationPerPrimitiveEXT: return "PerPrimitiveEXT"; + case SpvDecorationPerViewNV: return "PerViewNV"; + case SpvDecorationPerTaskNV: return "PerTaskNV"; + case SpvDecorationPerVertexKHR: return "PerVertexKHR"; + case SpvDecorationNonUniform: return "NonUniform"; + case SpvDecorationRestrictPointer: return "RestrictPointer"; + case SpvDecorationAliasedPointer: return "AliasedPointer"; + case SpvDecorationHitObjectShaderRecordBufferNV: return "HitObjectShaderRecordBufferNV"; + case SpvDecorationBindlessSamplerNV: return "BindlessSamplerNV"; + case SpvDecorationBindlessImageNV: return "BindlessImageNV"; + case SpvDecorationBoundSamplerNV: return "BoundSamplerNV"; + case SpvDecorationBoundImageNV: return "BoundImageNV"; + case SpvDecorationSIMTCallINTEL: return "SIMTCallINTEL"; + case SpvDecorationReferencedIndirectlyINTEL: return "ReferencedIndirectlyINTEL"; + case SpvDecorationClobberINTEL: return "ClobberINTEL"; + case SpvDecorationSideEffectsINTEL: return "SideEffectsINTEL"; + case SpvDecorationVectorComputeVariableINTEL: return "VectorComputeVariableINTEL"; + case SpvDecorationFuncParamIOKindINTEL: return "FuncParamIOKindINTEL"; + case SpvDecorationVectorComputeFunctionINTEL: return "VectorComputeFunctionINTEL"; + case SpvDecorationStackCallINTEL: return "StackCallINTEL"; + case SpvDecorationGlobalVariableOffsetINTEL: return "GlobalVariableOffsetINTEL"; + case SpvDecorationCounterBuffer: return "CounterBuffer"; + case SpvDecorationHlslSemanticGOOGLE: return "HlslSemanticGOOGLE"; + case SpvDecorationUserTypeGOOGLE: return "UserTypeGOOGLE"; + case SpvDecorationFunctionRoundingModeINTEL: return "FunctionRoundingModeINTEL"; + case SpvDecorationFunctionDenormModeINTEL: return "FunctionDenormModeINTEL"; + case SpvDecorationRegisterINTEL: return "RegisterINTEL"; + case SpvDecorationMemoryINTEL: return "MemoryINTEL"; + case SpvDecorationNumbanksINTEL: return "NumbanksINTEL"; + case SpvDecorationBankwidthINTEL: return "BankwidthINTEL"; + case SpvDecorationMaxPrivateCopiesINTEL: return "MaxPrivateCopiesINTEL"; + case SpvDecorationSinglepumpINTEL: return "SinglepumpINTEL"; + case SpvDecorationDoublepumpINTEL: return "DoublepumpINTEL"; + case SpvDecorationMaxReplicatesINTEL: return "MaxReplicatesINTEL"; + case SpvDecorationSimpleDualPortINTEL: return "SimpleDualPortINTEL"; + case SpvDecorationMergeINTEL: return "MergeINTEL"; + case SpvDecorationBankBitsINTEL: return "BankBitsINTEL"; + case SpvDecorationForcePow2DepthINTEL: return "ForcePow2DepthINTEL"; + case SpvDecorationStridesizeINTEL: return "StridesizeINTEL"; + case SpvDecorationWordsizeINTEL: return "WordsizeINTEL"; + case SpvDecorationTrueDualPortINTEL: return "TrueDualPortINTEL"; + case SpvDecorationBurstCoalesceINTEL: return "BurstCoalesceINTEL"; + case SpvDecorationCacheSizeINTEL: return "CacheSizeINTEL"; + case SpvDecorationDontStaticallyCoalesceINTEL: return "DontStaticallyCoalesceINTEL"; + case SpvDecorationPrefetchINTEL: return "PrefetchINTEL"; + case SpvDecorationStallEnableINTEL: return "StallEnableINTEL"; + case SpvDecorationFuseLoopsInFunctionINTEL: return "FuseLoopsInFunctionINTEL"; + case SpvDecorationMathOpDSPModeINTEL: return "MathOpDSPModeINTEL"; + case SpvDecorationAliasScopeINTEL: return "AliasScopeINTEL"; + case SpvDecorationNoAliasINTEL: return "NoAliasINTEL"; + case SpvDecorationInitiationIntervalINTEL: return "InitiationIntervalINTEL"; + case SpvDecorationMaxConcurrencyINTEL: return "MaxConcurrencyINTEL"; + case SpvDecorationPipelineEnableINTEL: return "PipelineEnableINTEL"; + case SpvDecorationBufferLocationINTEL: return "BufferLocationINTEL"; + case SpvDecorationIOPipeStorageINTEL: return "IOPipeStorageINTEL"; + case SpvDecorationFunctionFloatingPointModeINTEL: return "FunctionFloatingPointModeINTEL"; + case SpvDecorationSingleElementVectorINTEL: return "SingleElementVectorINTEL"; + case SpvDecorationVectorComputeCallableFunctionINTEL: return "VectorComputeCallableFunctionINTEL"; + case SpvDecorationMediaBlockIOINTEL: return "MediaBlockIOINTEL"; + case SpvDecorationStallFreeINTEL: return "StallFreeINTEL"; + case SpvDecorationFPMaxErrorDecorationINTEL: return "FPMaxErrorDecorationINTEL"; + case SpvDecorationLatencyControlLabelINTEL: return "LatencyControlLabelINTEL"; + case SpvDecorationLatencyControlConstraintINTEL: return "LatencyControlConstraintINTEL"; + case SpvDecorationConduitKernelArgumentINTEL: return "ConduitKernelArgumentINTEL"; + case SpvDecorationRegisterMapKernelArgumentINTEL: return "RegisterMapKernelArgumentINTEL"; + case SpvDecorationMMHostInterfaceAddressWidthINTEL: return "MMHostInterfaceAddressWidthINTEL"; + case SpvDecorationMMHostInterfaceDataWidthINTEL: return "MMHostInterfaceDataWidthINTEL"; + case SpvDecorationMMHostInterfaceLatencyINTEL: return "MMHostInterfaceLatencyINTEL"; + case SpvDecorationMMHostInterfaceReadWriteModeINTEL: return "MMHostInterfaceReadWriteModeINTEL"; + case SpvDecorationMMHostInterfaceMaxBurstINTEL: return "MMHostInterfaceMaxBurstINTEL"; + case SpvDecorationMMHostInterfaceWaitRequestINTEL: return "MMHostInterfaceWaitRequestINTEL"; + case SpvDecorationStableKernelArgumentINTEL: return "StableKernelArgumentINTEL"; + case SpvDecorationHostAccessINTEL: return "HostAccessINTEL"; + case SpvDecorationInitModeINTEL: return "InitModeINTEL"; + case SpvDecorationImplementInRegisterMapINTEL: return "ImplementInRegisterMapINTEL"; + case SpvDecorationCacheControlLoadINTEL: return "CacheControlLoadINTEL"; + case SpvDecorationCacheControlStoreINTEL: return "CacheControlStoreINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvBuiltInToString(SpvBuiltIn value) { + switch (value) { + case SpvBuiltInPosition: return "Position"; + case SpvBuiltInPointSize: return "PointSize"; + case SpvBuiltInClipDistance: return "ClipDistance"; + case SpvBuiltInCullDistance: return "CullDistance"; + case SpvBuiltInVertexId: return "VertexId"; + case SpvBuiltInInstanceId: return "InstanceId"; + case SpvBuiltInPrimitiveId: return "PrimitiveId"; + case SpvBuiltInInvocationId: return "InvocationId"; + case SpvBuiltInLayer: return "Layer"; + case SpvBuiltInViewportIndex: return "ViewportIndex"; + case SpvBuiltInTessLevelOuter: return "TessLevelOuter"; + case SpvBuiltInTessLevelInner: return "TessLevelInner"; + case SpvBuiltInTessCoord: return "TessCoord"; + case SpvBuiltInPatchVertices: return "PatchVertices"; + case SpvBuiltInFragCoord: return "FragCoord"; + case SpvBuiltInPointCoord: return "PointCoord"; + case SpvBuiltInFrontFacing: return "FrontFacing"; + case SpvBuiltInSampleId: return "SampleId"; + case SpvBuiltInSamplePosition: return "SamplePosition"; + case SpvBuiltInSampleMask: return "SampleMask"; + case SpvBuiltInFragDepth: return "FragDepth"; + case SpvBuiltInHelperInvocation: return "HelperInvocation"; + case SpvBuiltInNumWorkgroups: return "NumWorkgroups"; + case SpvBuiltInWorkgroupSize: return "WorkgroupSize"; + case SpvBuiltInWorkgroupId: return "WorkgroupId"; + case SpvBuiltInLocalInvocationId: return "LocalInvocationId"; + case SpvBuiltInGlobalInvocationId: return "GlobalInvocationId"; + case SpvBuiltInLocalInvocationIndex: return "LocalInvocationIndex"; + case SpvBuiltInWorkDim: return "WorkDim"; + case SpvBuiltInGlobalSize: return "GlobalSize"; + case SpvBuiltInEnqueuedWorkgroupSize: return "EnqueuedWorkgroupSize"; + case SpvBuiltInGlobalOffset: return "GlobalOffset"; + case SpvBuiltInGlobalLinearId: return "GlobalLinearId"; + case SpvBuiltInSubgroupSize: return "SubgroupSize"; + case SpvBuiltInSubgroupMaxSize: return "SubgroupMaxSize"; + case SpvBuiltInNumSubgroups: return "NumSubgroups"; + case SpvBuiltInNumEnqueuedSubgroups: return "NumEnqueuedSubgroups"; + case SpvBuiltInSubgroupId: return "SubgroupId"; + case SpvBuiltInSubgroupLocalInvocationId: return "SubgroupLocalInvocationId"; + case SpvBuiltInVertexIndex: return "VertexIndex"; + case SpvBuiltInInstanceIndex: return "InstanceIndex"; + case SpvBuiltInCoreIDARM: return "CoreIDARM"; + case SpvBuiltInCoreCountARM: return "CoreCountARM"; + case SpvBuiltInCoreMaxIDARM: return "CoreMaxIDARM"; + case SpvBuiltInWarpIDARM: return "WarpIDARM"; + case SpvBuiltInWarpMaxIDARM: return "WarpMaxIDARM"; + case SpvBuiltInSubgroupEqMask: return "SubgroupEqMask"; + case SpvBuiltInSubgroupGeMask: return "SubgroupGeMask"; + case SpvBuiltInSubgroupGtMask: return "SubgroupGtMask"; + case SpvBuiltInSubgroupLeMask: return "SubgroupLeMask"; + case SpvBuiltInSubgroupLtMask: return "SubgroupLtMask"; + case SpvBuiltInBaseVertex: return "BaseVertex"; + case SpvBuiltInBaseInstance: return "BaseInstance"; + case SpvBuiltInDrawIndex: return "DrawIndex"; + case SpvBuiltInPrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR"; + case SpvBuiltInDeviceIndex: return "DeviceIndex"; + case SpvBuiltInViewIndex: return "ViewIndex"; + case SpvBuiltInShadingRateKHR: return "ShadingRateKHR"; + case SpvBuiltInBaryCoordNoPerspAMD: return "BaryCoordNoPerspAMD"; + case SpvBuiltInBaryCoordNoPerspCentroidAMD: return "BaryCoordNoPerspCentroidAMD"; + case SpvBuiltInBaryCoordNoPerspSampleAMD: return "BaryCoordNoPerspSampleAMD"; + case SpvBuiltInBaryCoordSmoothAMD: return "BaryCoordSmoothAMD"; + case SpvBuiltInBaryCoordSmoothCentroidAMD: return "BaryCoordSmoothCentroidAMD"; + case SpvBuiltInBaryCoordSmoothSampleAMD: return "BaryCoordSmoothSampleAMD"; + case SpvBuiltInBaryCoordPullModelAMD: return "BaryCoordPullModelAMD"; + case SpvBuiltInFragStencilRefEXT: return "FragStencilRefEXT"; + case SpvBuiltInRemainingRecursionLevelsAMDX: return "RemainingRecursionLevelsAMDX"; + case SpvBuiltInShaderIndexAMDX: return "ShaderIndexAMDX"; + case SpvBuiltInViewportMaskNV: return "ViewportMaskNV"; + case SpvBuiltInSecondaryPositionNV: return "SecondaryPositionNV"; + case SpvBuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; + case SpvBuiltInPositionPerViewNV: return "PositionPerViewNV"; + case SpvBuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; + case SpvBuiltInFullyCoveredEXT: return "FullyCoveredEXT"; + case SpvBuiltInTaskCountNV: return "TaskCountNV"; + case SpvBuiltInPrimitiveCountNV: return "PrimitiveCountNV"; + case SpvBuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV"; + case SpvBuiltInClipDistancePerViewNV: return "ClipDistancePerViewNV"; + case SpvBuiltInCullDistancePerViewNV: return "CullDistancePerViewNV"; + case SpvBuiltInLayerPerViewNV: return "LayerPerViewNV"; + case SpvBuiltInMeshViewCountNV: return "MeshViewCountNV"; + case SpvBuiltInMeshViewIndicesNV: return "MeshViewIndicesNV"; + case SpvBuiltInBaryCoordKHR: return "BaryCoordKHR"; + case SpvBuiltInBaryCoordNoPerspKHR: return "BaryCoordNoPerspKHR"; + case SpvBuiltInFragSizeEXT: return "FragSizeEXT"; + case SpvBuiltInFragInvocationCountEXT: return "FragInvocationCountEXT"; + case SpvBuiltInPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT"; + case SpvBuiltInPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT"; + case SpvBuiltInPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT"; + case SpvBuiltInCullPrimitiveEXT: return "CullPrimitiveEXT"; + case SpvBuiltInLaunchIdKHR: return "LaunchIdKHR"; + case SpvBuiltInLaunchSizeKHR: return "LaunchSizeKHR"; + case SpvBuiltInWorldRayOriginKHR: return "WorldRayOriginKHR"; + case SpvBuiltInWorldRayDirectionKHR: return "WorldRayDirectionKHR"; + case SpvBuiltInObjectRayOriginKHR: return "ObjectRayOriginKHR"; + case SpvBuiltInObjectRayDirectionKHR: return "ObjectRayDirectionKHR"; + case SpvBuiltInRayTminKHR: return "RayTminKHR"; + case SpvBuiltInRayTmaxKHR: return "RayTmaxKHR"; + case SpvBuiltInInstanceCustomIndexKHR: return "InstanceCustomIndexKHR"; + case SpvBuiltInObjectToWorldKHR: return "ObjectToWorldKHR"; + case SpvBuiltInWorldToObjectKHR: return "WorldToObjectKHR"; + case SpvBuiltInHitTNV: return "HitTNV"; + case SpvBuiltInHitKindKHR: return "HitKindKHR"; + case SpvBuiltInCurrentRayTimeNV: return "CurrentRayTimeNV"; + case SpvBuiltInHitTriangleVertexPositionsKHR: return "HitTriangleVertexPositionsKHR"; + case SpvBuiltInHitMicroTriangleVertexPositionsNV: return "HitMicroTriangleVertexPositionsNV"; + case SpvBuiltInHitMicroTriangleVertexBarycentricsNV: return "HitMicroTriangleVertexBarycentricsNV"; + case SpvBuiltInIncomingRayFlagsKHR: return "IncomingRayFlagsKHR"; + case SpvBuiltInRayGeometryIndexKHR: return "RayGeometryIndexKHR"; + case SpvBuiltInHitIsSphereNV: return "HitIsSphereNV"; + case SpvBuiltInHitIsLSSNV: return "HitIsLSSNV"; + case SpvBuiltInHitSpherePositionNV: return "HitSpherePositionNV"; + case SpvBuiltInWarpsPerSMNV: return "WarpsPerSMNV"; + case SpvBuiltInSMCountNV: return "SMCountNV"; + case SpvBuiltInWarpIDNV: return "WarpIDNV"; + case SpvBuiltInSMIDNV: return "SMIDNV"; + case SpvBuiltInHitLSSPositionsNV: return "HitLSSPositionsNV"; + case SpvBuiltInHitKindFrontFacingMicroTriangleNV: return "HitKindFrontFacingMicroTriangleNV"; + case SpvBuiltInHitKindBackFacingMicroTriangleNV: return "HitKindBackFacingMicroTriangleNV"; + case SpvBuiltInHitSphereRadiusNV: return "HitSphereRadiusNV"; + case SpvBuiltInHitLSSRadiiNV: return "HitLSSRadiiNV"; + case SpvBuiltInClusterIDNV: return "ClusterIDNV"; + case SpvBuiltInCullMaskKHR: return "CullMaskKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvScopeToString(SpvScope value) { + switch (value) { + case SpvScopeCrossDevice: return "CrossDevice"; + case SpvScopeDevice: return "Device"; + case SpvScopeWorkgroup: return "Workgroup"; + case SpvScopeSubgroup: return "Subgroup"; + case SpvScopeInvocation: return "Invocation"; + case SpvScopeQueueFamily: return "QueueFamily"; + case SpvScopeShaderCallKHR: return "ShaderCallKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvGroupOperationToString(SpvGroupOperation value) { + switch (value) { + case SpvGroupOperationReduce: return "Reduce"; + case SpvGroupOperationInclusiveScan: return "InclusiveScan"; + case SpvGroupOperationExclusiveScan: return "ExclusiveScan"; + case SpvGroupOperationClusteredReduce: return "ClusteredReduce"; + case SpvGroupOperationPartitionedReduceNV: return "PartitionedReduceNV"; + case SpvGroupOperationPartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV"; + case SpvGroupOperationPartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV"; + default: return "Unknown"; + } +} + +inline const char* SpvKernelEnqueueFlagsToString(SpvKernelEnqueueFlags value) { + switch (value) { + case SpvKernelEnqueueFlagsNoWait: return "NoWait"; + case SpvKernelEnqueueFlagsWaitKernel: return "WaitKernel"; + case SpvKernelEnqueueFlagsWaitWorkGroup: return "WaitWorkGroup"; + default: return "Unknown"; + } +} + +inline const char* SpvCapabilityToString(SpvCapability value) { + switch (value) { + case SpvCapabilityMatrix: return "Matrix"; + case SpvCapabilityShader: return "Shader"; + case SpvCapabilityGeometry: return "Geometry"; + case SpvCapabilityTessellation: return "Tessellation"; + case SpvCapabilityAddresses: return "Addresses"; + case SpvCapabilityLinkage: return "Linkage"; + case SpvCapabilityKernel: return "Kernel"; + case SpvCapabilityVector16: return "Vector16"; + case SpvCapabilityFloat16Buffer: return "Float16Buffer"; + case SpvCapabilityFloat16: return "Float16"; + case SpvCapabilityFloat64: return "Float64"; + case SpvCapabilityInt64: return "Int64"; + case SpvCapabilityInt64Atomics: return "Int64Atomics"; + case SpvCapabilityImageBasic: return "ImageBasic"; + case SpvCapabilityImageReadWrite: return "ImageReadWrite"; + case SpvCapabilityImageMipmap: return "ImageMipmap"; + case SpvCapabilityPipes: return "Pipes"; + case SpvCapabilityGroups: return "Groups"; + case SpvCapabilityDeviceEnqueue: return "DeviceEnqueue"; + case SpvCapabilityLiteralSampler: return "LiteralSampler"; + case SpvCapabilityAtomicStorage: return "AtomicStorage"; + case SpvCapabilityInt16: return "Int16"; + case SpvCapabilityTessellationPointSize: return "TessellationPointSize"; + case SpvCapabilityGeometryPointSize: return "GeometryPointSize"; + case SpvCapabilityImageGatherExtended: return "ImageGatherExtended"; + case SpvCapabilityStorageImageMultisample: return "StorageImageMultisample"; + case SpvCapabilityUniformBufferArrayDynamicIndexing: return "UniformBufferArrayDynamicIndexing"; + case SpvCapabilitySampledImageArrayDynamicIndexing: return "SampledImageArrayDynamicIndexing"; + case SpvCapabilityStorageBufferArrayDynamicIndexing: return "StorageBufferArrayDynamicIndexing"; + case SpvCapabilityStorageImageArrayDynamicIndexing: return "StorageImageArrayDynamicIndexing"; + case SpvCapabilityClipDistance: return "ClipDistance"; + case SpvCapabilityCullDistance: return "CullDistance"; + case SpvCapabilityImageCubeArray: return "ImageCubeArray"; + case SpvCapabilitySampleRateShading: return "SampleRateShading"; + case SpvCapabilityImageRect: return "ImageRect"; + case SpvCapabilitySampledRect: return "SampledRect"; + case SpvCapabilityGenericPointer: return "GenericPointer"; + case SpvCapabilityInt8: return "Int8"; + case SpvCapabilityInputAttachment: return "InputAttachment"; + case SpvCapabilitySparseResidency: return "SparseResidency"; + case SpvCapabilityMinLod: return "MinLod"; + case SpvCapabilitySampled1D: return "Sampled1D"; + case SpvCapabilityImage1D: return "Image1D"; + case SpvCapabilitySampledCubeArray: return "SampledCubeArray"; + case SpvCapabilitySampledBuffer: return "SampledBuffer"; + case SpvCapabilityImageBuffer: return "ImageBuffer"; + case SpvCapabilityImageMSArray: return "ImageMSArray"; + case SpvCapabilityStorageImageExtendedFormats: return "StorageImageExtendedFormats"; + case SpvCapabilityImageQuery: return "ImageQuery"; + case SpvCapabilityDerivativeControl: return "DerivativeControl"; + case SpvCapabilityInterpolationFunction: return "InterpolationFunction"; + case SpvCapabilityTransformFeedback: return "TransformFeedback"; + case SpvCapabilityGeometryStreams: return "GeometryStreams"; + case SpvCapabilityStorageImageReadWithoutFormat: return "StorageImageReadWithoutFormat"; + case SpvCapabilityStorageImageWriteWithoutFormat: return "StorageImageWriteWithoutFormat"; + case SpvCapabilityMultiViewport: return "MultiViewport"; + case SpvCapabilitySubgroupDispatch: return "SubgroupDispatch"; + case SpvCapabilityNamedBarrier: return "NamedBarrier"; + case SpvCapabilityPipeStorage: return "PipeStorage"; + case SpvCapabilityGroupNonUniform: return "GroupNonUniform"; + case SpvCapabilityGroupNonUniformVote: return "GroupNonUniformVote"; + case SpvCapabilityGroupNonUniformArithmetic: return "GroupNonUniformArithmetic"; + case SpvCapabilityGroupNonUniformBallot: return "GroupNonUniformBallot"; + case SpvCapabilityGroupNonUniformShuffle: return "GroupNonUniformShuffle"; + case SpvCapabilityGroupNonUniformShuffleRelative: return "GroupNonUniformShuffleRelative"; + case SpvCapabilityGroupNonUniformClustered: return "GroupNonUniformClustered"; + case SpvCapabilityGroupNonUniformQuad: return "GroupNonUniformQuad"; + case SpvCapabilityShaderLayer: return "ShaderLayer"; + case SpvCapabilityShaderViewportIndex: return "ShaderViewportIndex"; + case SpvCapabilityUniformDecoration: return "UniformDecoration"; + case SpvCapabilityCoreBuiltinsARM: return "CoreBuiltinsARM"; + case SpvCapabilityTileImageColorReadAccessEXT: return "TileImageColorReadAccessEXT"; + case SpvCapabilityTileImageDepthReadAccessEXT: return "TileImageDepthReadAccessEXT"; + case SpvCapabilityTileImageStencilReadAccessEXT: return "TileImageStencilReadAccessEXT"; + case SpvCapabilityCooperativeMatrixLayoutsARM: return "CooperativeMatrixLayoutsARM"; + case SpvCapabilityFragmentShadingRateKHR: return "FragmentShadingRateKHR"; + case SpvCapabilitySubgroupBallotKHR: return "SubgroupBallotKHR"; + case SpvCapabilityDrawParameters: return "DrawParameters"; + case SpvCapabilityWorkgroupMemoryExplicitLayoutKHR: return "WorkgroupMemoryExplicitLayoutKHR"; + case SpvCapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR: return "WorkgroupMemoryExplicitLayout8BitAccessKHR"; + case SpvCapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR: return "WorkgroupMemoryExplicitLayout16BitAccessKHR"; + case SpvCapabilitySubgroupVoteKHR: return "SubgroupVoteKHR"; + case SpvCapabilityStorageBuffer16BitAccess: return "StorageBuffer16BitAccess"; + case SpvCapabilityStorageUniform16: return "StorageUniform16"; + case SpvCapabilityStoragePushConstant16: return "StoragePushConstant16"; + case SpvCapabilityStorageInputOutput16: return "StorageInputOutput16"; + case SpvCapabilityDeviceGroup: return "DeviceGroup"; + case SpvCapabilityMultiView: return "MultiView"; + case SpvCapabilityVariablePointersStorageBuffer: return "VariablePointersStorageBuffer"; + case SpvCapabilityVariablePointers: return "VariablePointers"; + case SpvCapabilityAtomicStorageOps: return "AtomicStorageOps"; + case SpvCapabilitySampleMaskPostDepthCoverage: return "SampleMaskPostDepthCoverage"; + case SpvCapabilityStorageBuffer8BitAccess: return "StorageBuffer8BitAccess"; + case SpvCapabilityUniformAndStorageBuffer8BitAccess: return "UniformAndStorageBuffer8BitAccess"; + case SpvCapabilityStoragePushConstant8: return "StoragePushConstant8"; + case SpvCapabilityDenormPreserve: return "DenormPreserve"; + case SpvCapabilityDenormFlushToZero: return "DenormFlushToZero"; + case SpvCapabilitySignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case SpvCapabilityRoundingModeRTE: return "RoundingModeRTE"; + case SpvCapabilityRoundingModeRTZ: return "RoundingModeRTZ"; + case SpvCapabilityRayQueryProvisionalKHR: return "RayQueryProvisionalKHR"; + case SpvCapabilityRayQueryKHR: return "RayQueryKHR"; + case SpvCapabilityUntypedPointersKHR: return "UntypedPointersKHR"; + case SpvCapabilityRayTraversalPrimitiveCullingKHR: return "RayTraversalPrimitiveCullingKHR"; + case SpvCapabilityRayTracingKHR: return "RayTracingKHR"; + case SpvCapabilityTextureSampleWeightedQCOM: return "TextureSampleWeightedQCOM"; + case SpvCapabilityTextureBoxFilterQCOM: return "TextureBoxFilterQCOM"; + case SpvCapabilityTextureBlockMatchQCOM: return "TextureBlockMatchQCOM"; + case SpvCapabilityTextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM"; + case SpvCapabilityFloat16ImageAMD: return "Float16ImageAMD"; + case SpvCapabilityImageGatherBiasLodAMD: return "ImageGatherBiasLodAMD"; + case SpvCapabilityFragmentMaskAMD: return "FragmentMaskAMD"; + case SpvCapabilityStencilExportEXT: return "StencilExportEXT"; + case SpvCapabilityImageReadWriteLodAMD: return "ImageReadWriteLodAMD"; + case SpvCapabilityInt64ImageEXT: return "Int64ImageEXT"; + case SpvCapabilityShaderClockKHR: return "ShaderClockKHR"; + case SpvCapabilityShaderEnqueueAMDX: return "ShaderEnqueueAMDX"; + case SpvCapabilityQuadControlKHR: return "QuadControlKHR"; + case SpvCapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV"; + case SpvCapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV"; + case SpvCapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT"; + case SpvCapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV"; + case SpvCapabilityShaderStereoViewNV: return "ShaderStereoViewNV"; + case SpvCapabilityPerViewAttributesNV: return "PerViewAttributesNV"; + case SpvCapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT"; + case SpvCapabilityMeshShadingNV: return "MeshShadingNV"; + case SpvCapabilityImageFootprintNV: return "ImageFootprintNV"; + case SpvCapabilityMeshShadingEXT: return "MeshShadingEXT"; + case SpvCapabilityFragmentBarycentricKHR: return "FragmentBarycentricKHR"; + case SpvCapabilityComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR"; + case SpvCapabilityFragmentDensityEXT: return "FragmentDensityEXT"; + case SpvCapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; + case SpvCapabilityShaderNonUniform: return "ShaderNonUniform"; + case SpvCapabilityRuntimeDescriptorArray: return "RuntimeDescriptorArray"; + case SpvCapabilityInputAttachmentArrayDynamicIndexing: return "InputAttachmentArrayDynamicIndexing"; + case SpvCapabilityUniformTexelBufferArrayDynamicIndexing: return "UniformTexelBufferArrayDynamicIndexing"; + case SpvCapabilityStorageTexelBufferArrayDynamicIndexing: return "StorageTexelBufferArrayDynamicIndexing"; + case SpvCapabilityUniformBufferArrayNonUniformIndexing: return "UniformBufferArrayNonUniformIndexing"; + case SpvCapabilitySampledImageArrayNonUniformIndexing: return "SampledImageArrayNonUniformIndexing"; + case SpvCapabilityStorageBufferArrayNonUniformIndexing: return "StorageBufferArrayNonUniformIndexing"; + case SpvCapabilityStorageImageArrayNonUniformIndexing: return "StorageImageArrayNonUniformIndexing"; + case SpvCapabilityInputAttachmentArrayNonUniformIndexing: return "InputAttachmentArrayNonUniformIndexing"; + case SpvCapabilityUniformTexelBufferArrayNonUniformIndexing: return "UniformTexelBufferArrayNonUniformIndexing"; + case SpvCapabilityStorageTexelBufferArrayNonUniformIndexing: return "StorageTexelBufferArrayNonUniformIndexing"; + case SpvCapabilityRayTracingPositionFetchKHR: return "RayTracingPositionFetchKHR"; + case SpvCapabilityRayTracingNV: return "RayTracingNV"; + case SpvCapabilityRayTracingMotionBlurNV: return "RayTracingMotionBlurNV"; + case SpvCapabilityVulkanMemoryModel: return "VulkanMemoryModel"; + case SpvCapabilityVulkanMemoryModelDeviceScope: return "VulkanMemoryModelDeviceScope"; + case SpvCapabilityPhysicalStorageBufferAddresses: return "PhysicalStorageBufferAddresses"; + case SpvCapabilityComputeDerivativeGroupLinearKHR: return "ComputeDerivativeGroupLinearKHR"; + case SpvCapabilityRayTracingProvisionalKHR: return "RayTracingProvisionalKHR"; + case SpvCapabilityCooperativeMatrixNV: return "CooperativeMatrixNV"; + case SpvCapabilityFragmentShaderSampleInterlockEXT: return "FragmentShaderSampleInterlockEXT"; + case SpvCapabilityFragmentShaderShadingRateInterlockEXT: return "FragmentShaderShadingRateInterlockEXT"; + case SpvCapabilityShaderSMBuiltinsNV: return "ShaderSMBuiltinsNV"; + case SpvCapabilityFragmentShaderPixelInterlockEXT: return "FragmentShaderPixelInterlockEXT"; + case SpvCapabilityDemoteToHelperInvocation: return "DemoteToHelperInvocation"; + case SpvCapabilityDisplacementMicromapNV: return "DisplacementMicromapNV"; + case SpvCapabilityRayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT"; + case SpvCapabilityShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + case SpvCapabilityBindlessTextureNV: return "BindlessTextureNV"; + case SpvCapabilityRayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR"; + case SpvCapabilityCooperativeVectorNV: return "CooperativeVectorNV"; + case SpvCapabilityAtomicFloat16VectorNV: return "AtomicFloat16VectorNV"; + case SpvCapabilityRayTracingDisplacementMicromapNV: return "RayTracingDisplacementMicromapNV"; + case SpvCapabilityRawAccessChainsNV: return "RawAccessChainsNV"; + case SpvCapabilityRayTracingSpheresGeometryNV: return "RayTracingSpheresGeometryNV"; + case SpvCapabilityRayTracingLinearSweptSpheresGeometryNV: return "RayTracingLinearSweptSpheresGeometryNV"; + case SpvCapabilityCooperativeMatrixReductionsNV: return "CooperativeMatrixReductionsNV"; + case SpvCapabilityCooperativeMatrixConversionsNV: return "CooperativeMatrixConversionsNV"; + case SpvCapabilityCooperativeMatrixPerElementOperationsNV: return "CooperativeMatrixPerElementOperationsNV"; + case SpvCapabilityCooperativeMatrixTensorAddressingNV: return "CooperativeMatrixTensorAddressingNV"; + case SpvCapabilityCooperativeMatrixBlockLoadsNV: return "CooperativeMatrixBlockLoadsNV"; + case SpvCapabilityCooperativeVectorTrainingNV: return "CooperativeVectorTrainingNV"; + case SpvCapabilityRayTracingClusterAccelerationStructureNV: return "RayTracingClusterAccelerationStructureNV"; + case SpvCapabilityTensorAddressingNV: return "TensorAddressingNV"; + case SpvCapabilitySubgroupShuffleINTEL: return "SubgroupShuffleINTEL"; + case SpvCapabilitySubgroupBufferBlockIOINTEL: return "SubgroupBufferBlockIOINTEL"; + case SpvCapabilitySubgroupImageBlockIOINTEL: return "SubgroupImageBlockIOINTEL"; + case SpvCapabilitySubgroupImageMediaBlockIOINTEL: return "SubgroupImageMediaBlockIOINTEL"; + case SpvCapabilityRoundToInfinityINTEL: return "RoundToInfinityINTEL"; + case SpvCapabilityFloatingPointModeINTEL: return "FloatingPointModeINTEL"; + case SpvCapabilityIntegerFunctions2INTEL: return "IntegerFunctions2INTEL"; + case SpvCapabilityFunctionPointersINTEL: return "FunctionPointersINTEL"; + case SpvCapabilityIndirectReferencesINTEL: return "IndirectReferencesINTEL"; + case SpvCapabilityAsmINTEL: return "AsmINTEL"; + case SpvCapabilityAtomicFloat32MinMaxEXT: return "AtomicFloat32MinMaxEXT"; + case SpvCapabilityAtomicFloat64MinMaxEXT: return "AtomicFloat64MinMaxEXT"; + case SpvCapabilityAtomicFloat16MinMaxEXT: return "AtomicFloat16MinMaxEXT"; + case SpvCapabilityVectorComputeINTEL: return "VectorComputeINTEL"; + case SpvCapabilityVectorAnyINTEL: return "VectorAnyINTEL"; + case SpvCapabilityExpectAssumeKHR: return "ExpectAssumeKHR"; + case SpvCapabilitySubgroupAvcMotionEstimationINTEL: return "SubgroupAvcMotionEstimationINTEL"; + case SpvCapabilitySubgroupAvcMotionEstimationIntraINTEL: return "SubgroupAvcMotionEstimationIntraINTEL"; + case SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL: return "SubgroupAvcMotionEstimationChromaINTEL"; + case SpvCapabilityVariableLengthArrayINTEL: return "VariableLengthArrayINTEL"; + case SpvCapabilityFunctionFloatControlINTEL: return "FunctionFloatControlINTEL"; + case SpvCapabilityFPGAMemoryAttributesINTEL: return "FPGAMemoryAttributesINTEL"; + case SpvCapabilityFPFastMathModeINTEL: return "FPFastMathModeINTEL"; + case SpvCapabilityArbitraryPrecisionIntegersINTEL: return "ArbitraryPrecisionIntegersINTEL"; + case SpvCapabilityArbitraryPrecisionFloatingPointINTEL: return "ArbitraryPrecisionFloatingPointINTEL"; + case SpvCapabilityUnstructuredLoopControlsINTEL: return "UnstructuredLoopControlsINTEL"; + case SpvCapabilityFPGALoopControlsINTEL: return "FPGALoopControlsINTEL"; + case SpvCapabilityKernelAttributesINTEL: return "KernelAttributesINTEL"; + case SpvCapabilityFPGAKernelAttributesINTEL: return "FPGAKernelAttributesINTEL"; + case SpvCapabilityFPGAMemoryAccessesINTEL: return "FPGAMemoryAccessesINTEL"; + case SpvCapabilityFPGAClusterAttributesINTEL: return "FPGAClusterAttributesINTEL"; + case SpvCapabilityLoopFuseINTEL: return "LoopFuseINTEL"; + case SpvCapabilityFPGADSPControlINTEL: return "FPGADSPControlINTEL"; + case SpvCapabilityMemoryAccessAliasingINTEL: return "MemoryAccessAliasingINTEL"; + case SpvCapabilityFPGAInvocationPipeliningAttributesINTEL: return "FPGAInvocationPipeliningAttributesINTEL"; + case SpvCapabilityFPGABufferLocationINTEL: return "FPGABufferLocationINTEL"; + case SpvCapabilityArbitraryPrecisionFixedPointINTEL: return "ArbitraryPrecisionFixedPointINTEL"; + case SpvCapabilityUSMStorageClassesINTEL: return "USMStorageClassesINTEL"; + case SpvCapabilityRuntimeAlignedAttributeINTEL: return "RuntimeAlignedAttributeINTEL"; + case SpvCapabilityIOPipesINTEL: return "IOPipesINTEL"; + case SpvCapabilityBlockingPipesINTEL: return "BlockingPipesINTEL"; + case SpvCapabilityFPGARegINTEL: return "FPGARegINTEL"; + case SpvCapabilityDotProductInputAll: return "DotProductInputAll"; + case SpvCapabilityDotProductInput4x8Bit: return "DotProductInput4x8Bit"; + case SpvCapabilityDotProductInput4x8BitPacked: return "DotProductInput4x8BitPacked"; + case SpvCapabilityDotProduct: return "DotProduct"; + case SpvCapabilityRayCullMaskKHR: return "RayCullMaskKHR"; + case SpvCapabilityCooperativeMatrixKHR: return "CooperativeMatrixKHR"; + case SpvCapabilityReplicatedCompositesEXT: return "ReplicatedCompositesEXT"; + case SpvCapabilityBitInstructions: return "BitInstructions"; + case SpvCapabilityGroupNonUniformRotateKHR: return "GroupNonUniformRotateKHR"; + case SpvCapabilityFloatControls2: return "FloatControls2"; + case SpvCapabilityAtomicFloat32AddEXT: return "AtomicFloat32AddEXT"; + case SpvCapabilityAtomicFloat64AddEXT: return "AtomicFloat64AddEXT"; + case SpvCapabilityLongCompositesINTEL: return "LongCompositesINTEL"; + case SpvCapabilityOptNoneEXT: return "OptNoneEXT"; + case SpvCapabilityAtomicFloat16AddEXT: return "AtomicFloat16AddEXT"; + case SpvCapabilityDebugInfoModuleINTEL: return "DebugInfoModuleINTEL"; + case SpvCapabilityBFloat16ConversionINTEL: return "BFloat16ConversionINTEL"; + case SpvCapabilitySplitBarrierINTEL: return "SplitBarrierINTEL"; + case SpvCapabilityArithmeticFenceEXT: return "ArithmeticFenceEXT"; + case SpvCapabilityFPGAClusterAttributesV2INTEL: return "FPGAClusterAttributesV2INTEL"; + case SpvCapabilityFPGAKernelAttributesv2INTEL: return "FPGAKernelAttributesv2INTEL"; + case SpvCapabilityFPMaxErrorINTEL: return "FPMaxErrorINTEL"; + case SpvCapabilityFPGALatencyControlINTEL: return "FPGALatencyControlINTEL"; + case SpvCapabilityFPGAArgumentInterfacesINTEL: return "FPGAArgumentInterfacesINTEL"; + case SpvCapabilityGlobalVariableHostAccessINTEL: return "GlobalVariableHostAccessINTEL"; + case SpvCapabilityGlobalVariableFPGADecorationsINTEL: return "GlobalVariableFPGADecorationsINTEL"; + case SpvCapabilitySubgroupBufferPrefetchINTEL: return "SubgroupBufferPrefetchINTEL"; + case SpvCapabilitySubgroup2DBlockIOINTEL: return "Subgroup2DBlockIOINTEL"; + case SpvCapabilitySubgroup2DBlockTransformINTEL: return "Subgroup2DBlockTransformINTEL"; + case SpvCapabilitySubgroup2DBlockTransposeINTEL: return "Subgroup2DBlockTransposeINTEL"; + case SpvCapabilitySubgroupMatrixMultiplyAccumulateINTEL: return "SubgroupMatrixMultiplyAccumulateINTEL"; + case SpvCapabilityGroupUniformArithmeticKHR: return "GroupUniformArithmeticKHR"; + case SpvCapabilityMaskedGatherScatterINTEL: return "MaskedGatherScatterINTEL"; + case SpvCapabilityCacheControlsINTEL: return "CacheControlsINTEL"; + case SpvCapabilityRegisterLimitsINTEL: return "RegisterLimitsINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvRayQueryIntersectionToString(SpvRayQueryIntersection value) { + switch (value) { + case SpvRayQueryIntersectionRayQueryCandidateIntersectionKHR: return "RayQueryCandidateIntersectionKHR"; + case SpvRayQueryIntersectionRayQueryCommittedIntersectionKHR: return "RayQueryCommittedIntersectionKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvRayQueryCommittedIntersectionTypeToString(SpvRayQueryCommittedIntersectionType value) { + switch (value) { + case SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionNoneKHR: return "RayQueryCommittedIntersectionNoneKHR"; + case SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionTriangleKHR: return "RayQueryCommittedIntersectionTriangleKHR"; + case SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionGeneratedKHR: return "RayQueryCommittedIntersectionGeneratedKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvRayQueryCandidateIntersectionTypeToString(SpvRayQueryCandidateIntersectionType value) { + switch (value) { + case SpvRayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionTriangleKHR: return "RayQueryCandidateIntersectionTriangleKHR"; + case SpvRayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionAABBKHR: return "RayQueryCandidateIntersectionAABBKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvFPDenormModeToString(SpvFPDenormMode value) { + switch (value) { + case SpvFPDenormModePreserve: return "Preserve"; + case SpvFPDenormModeFlushToZero: return "FlushToZero"; + default: return "Unknown"; + } +} + +inline const char* SpvFPOperationModeToString(SpvFPOperationMode value) { + switch (value) { + case SpvFPOperationModeIEEE: return "IEEE"; + case SpvFPOperationModeALT: return "ALT"; + default: return "Unknown"; + } +} + +inline const char* SpvQuantizationModesToString(SpvQuantizationModes value) { + switch (value) { + case SpvQuantizationModesTRN: return "TRN"; + case SpvQuantizationModesTRN_ZERO: return "TRN_ZERO"; + case SpvQuantizationModesRND: return "RND"; + case SpvQuantizationModesRND_ZERO: return "RND_ZERO"; + case SpvQuantizationModesRND_INF: return "RND_INF"; + case SpvQuantizationModesRND_MIN_INF: return "RND_MIN_INF"; + case SpvQuantizationModesRND_CONV: return "RND_CONV"; + case SpvQuantizationModesRND_CONV_ODD: return "RND_CONV_ODD"; + default: return "Unknown"; + } +} + +inline const char* SpvOverflowModesToString(SpvOverflowModes value) { + switch (value) { + case SpvOverflowModesWRAP: return "WRAP"; + case SpvOverflowModesSAT: return "SAT"; + case SpvOverflowModesSAT_ZERO: return "SAT_ZERO"; + case SpvOverflowModesSAT_SYM: return "SAT_SYM"; + default: return "Unknown"; + } +} + +inline const char* SpvPackedVectorFormatToString(SpvPackedVectorFormat value) { + switch (value) { + case SpvPackedVectorFormatPackedVectorFormat4x8Bit: return "PackedVectorFormat4x8Bit"; + default: return "Unknown"; + } +} + +inline const char* SpvCooperativeMatrixLayoutToString(SpvCooperativeMatrixLayout value) { + switch (value) { + case SpvCooperativeMatrixLayoutRowMajorKHR: return "RowMajorKHR"; + case SpvCooperativeMatrixLayoutColumnMajorKHR: return "ColumnMajorKHR"; + case SpvCooperativeMatrixLayoutRowBlockedInterleavedARM: return "RowBlockedInterleavedARM"; + case SpvCooperativeMatrixLayoutColumnBlockedInterleavedARM: return "ColumnBlockedInterleavedARM"; + default: return "Unknown"; + } +} + +inline const char* SpvCooperativeMatrixUseToString(SpvCooperativeMatrixUse value) { + switch (value) { + case SpvCooperativeMatrixUseMatrixAKHR: return "MatrixAKHR"; + case SpvCooperativeMatrixUseMatrixBKHR: return "MatrixBKHR"; + case SpvCooperativeMatrixUseMatrixAccumulatorKHR: return "MatrixAccumulatorKHR"; + default: return "Unknown"; + } +} + +inline const char* SpvTensorClampModeToString(SpvTensorClampMode value) { + switch (value) { + case SpvTensorClampModeUndefined: return "Undefined"; + case SpvTensorClampModeConstant: return "Constant"; + case SpvTensorClampModeClampToEdge: return "ClampToEdge"; + case SpvTensorClampModeRepeat: return "Repeat"; + case SpvTensorClampModeRepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* SpvInitializationModeQualifierToString(SpvInitializationModeQualifier value) { + switch (value) { + case SpvInitializationModeQualifierInitOnDeviceReprogramINTEL: return "InitOnDeviceReprogramINTEL"; + case SpvInitializationModeQualifierInitOnDeviceResetINTEL: return "InitOnDeviceResetINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvHostAccessQualifierToString(SpvHostAccessQualifier value) { + switch (value) { + case SpvHostAccessQualifierNoneINTEL: return "NoneINTEL"; + case SpvHostAccessQualifierReadINTEL: return "ReadINTEL"; + case SpvHostAccessQualifierWriteINTEL: return "WriteINTEL"; + case SpvHostAccessQualifierReadWriteINTEL: return "ReadWriteINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvLoadCacheControlToString(SpvLoadCacheControl value) { + switch (value) { + case SpvLoadCacheControlUncachedINTEL: return "UncachedINTEL"; + case SpvLoadCacheControlCachedINTEL: return "CachedINTEL"; + case SpvLoadCacheControlStreamingINTEL: return "StreamingINTEL"; + case SpvLoadCacheControlInvalidateAfterReadINTEL: return "InvalidateAfterReadINTEL"; + case SpvLoadCacheControlConstCachedINTEL: return "ConstCachedINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvStoreCacheControlToString(SpvStoreCacheControl value) { + switch (value) { + case SpvStoreCacheControlUncachedINTEL: return "UncachedINTEL"; + case SpvStoreCacheControlWriteThroughINTEL: return "WriteThroughINTEL"; + case SpvStoreCacheControlWriteBackINTEL: return "WriteBackINTEL"; + case SpvStoreCacheControlStreamingINTEL: return "StreamingINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvNamedMaximumNumberOfRegistersToString(SpvNamedMaximumNumberOfRegisters value) { + switch (value) { + case SpvNamedMaximumNumberOfRegistersAutoINTEL: return "AutoINTEL"; + default: return "Unknown"; + } +} + +inline const char* SpvFPEncodingToString(SpvFPEncoding value) { + switch (value) { + default: return "Unknown"; + } +} + +inline const char* SpvCooperativeVectorMatrixLayoutToString(SpvCooperativeVectorMatrixLayout value) { + switch (value) { + case SpvCooperativeVectorMatrixLayoutRowMajorNV: return "RowMajorNV"; + case SpvCooperativeVectorMatrixLayoutColumnMajorNV: return "ColumnMajorNV"; + case SpvCooperativeVectorMatrixLayoutInferencingOptimalNV: return "InferencingOptimalNV"; + case SpvCooperativeVectorMatrixLayoutTrainingOptimalNV: return "TrainingOptimalNV"; + default: return "Unknown"; + } +} + +inline const char* SpvComponentTypeToString(SpvComponentType value) { + switch (value) { + case SpvComponentTypeFloat16NV: return "Float16NV"; + case SpvComponentTypeFloat32NV: return "Float32NV"; + case SpvComponentTypeFloat64NV: return "Float64NV"; + case SpvComponentTypeSignedInt8NV: return "SignedInt8NV"; + case SpvComponentTypeSignedInt16NV: return "SignedInt16NV"; + case SpvComponentTypeSignedInt32NV: return "SignedInt32NV"; + case SpvComponentTypeSignedInt64NV: return "SignedInt64NV"; + case SpvComponentTypeUnsignedInt8NV: return "UnsignedInt8NV"; + case SpvComponentTypeUnsignedInt16NV: return "UnsignedInt16NV"; + case SpvComponentTypeUnsignedInt32NV: return "UnsignedInt32NV"; + case SpvComponentTypeUnsignedInt64NV: return "UnsignedInt64NV"; + case SpvComponentTypeSignedInt8PackedNV: return "SignedInt8PackedNV"; + case SpvComponentTypeUnsignedInt8PackedNV: return "UnsignedInt8PackedNV"; + case SpvComponentTypeFloatE4M3NV: return "FloatE4M3NV"; + case SpvComponentTypeFloatE5M2NV: return "FloatE5M2NV"; + default: return "Unknown"; + } +} + +inline const char* SpvOpToString(SpvOp value) { + switch (value) { + case SpvOpNop: return "OpNop"; + case SpvOpUndef: return "OpUndef"; + case SpvOpSourceContinued: return "OpSourceContinued"; + case SpvOpSource: return "OpSource"; + case SpvOpSourceExtension: return "OpSourceExtension"; + case SpvOpName: return "OpName"; + case SpvOpMemberName: return "OpMemberName"; + case SpvOpString: return "OpString"; + case SpvOpLine: return "OpLine"; + case SpvOpExtension: return "OpExtension"; + case SpvOpExtInstImport: return "OpExtInstImport"; + case SpvOpExtInst: return "OpExtInst"; + case SpvOpMemoryModel: return "OpMemoryModel"; + case SpvOpEntryPoint: return "OpEntryPoint"; + case SpvOpExecutionMode: return "OpExecutionMode"; + case SpvOpCapability: return "OpCapability"; + case SpvOpTypeVoid: return "OpTypeVoid"; + case SpvOpTypeBool: return "OpTypeBool"; + case SpvOpTypeInt: return "OpTypeInt"; + case SpvOpTypeFloat: return "OpTypeFloat"; + case SpvOpTypeVector: return "OpTypeVector"; + case SpvOpTypeMatrix: return "OpTypeMatrix"; + case SpvOpTypeImage: return "OpTypeImage"; + case SpvOpTypeSampler: return "OpTypeSampler"; + case SpvOpTypeSampledImage: return "OpTypeSampledImage"; + case SpvOpTypeArray: return "OpTypeArray"; + case SpvOpTypeRuntimeArray: return "OpTypeRuntimeArray"; + case SpvOpTypeStruct: return "OpTypeStruct"; + case SpvOpTypeOpaque: return "OpTypeOpaque"; + case SpvOpTypePointer: return "OpTypePointer"; + case SpvOpTypeFunction: return "OpTypeFunction"; + case SpvOpTypeEvent: return "OpTypeEvent"; + case SpvOpTypeDeviceEvent: return "OpTypeDeviceEvent"; + case SpvOpTypeReserveId: return "OpTypeReserveId"; + case SpvOpTypeQueue: return "OpTypeQueue"; + case SpvOpTypePipe: return "OpTypePipe"; + case SpvOpTypeForwardPointer: return "OpTypeForwardPointer"; + case SpvOpConstantTrue: return "OpConstantTrue"; + case SpvOpConstantFalse: return "OpConstantFalse"; + case SpvOpConstant: return "OpConstant"; + case SpvOpConstantComposite: return "OpConstantComposite"; + case SpvOpConstantSampler: return "OpConstantSampler"; + case SpvOpConstantNull: return "OpConstantNull"; + case SpvOpSpecConstantTrue: return "OpSpecConstantTrue"; + case SpvOpSpecConstantFalse: return "OpSpecConstantFalse"; + case SpvOpSpecConstant: return "OpSpecConstant"; + case SpvOpSpecConstantComposite: return "OpSpecConstantComposite"; + case SpvOpSpecConstantOp: return "OpSpecConstantOp"; + case SpvOpFunction: return "OpFunction"; + case SpvOpFunctionParameter: return "OpFunctionParameter"; + case SpvOpFunctionEnd: return "OpFunctionEnd"; + case SpvOpFunctionCall: return "OpFunctionCall"; + case SpvOpVariable: return "OpVariable"; + case SpvOpImageTexelPointer: return "OpImageTexelPointer"; + case SpvOpLoad: return "OpLoad"; + case SpvOpStore: return "OpStore"; + case SpvOpCopyMemory: return "OpCopyMemory"; + case SpvOpCopyMemorySized: return "OpCopyMemorySized"; + case SpvOpAccessChain: return "OpAccessChain"; + case SpvOpInBoundsAccessChain: return "OpInBoundsAccessChain"; + case SpvOpPtrAccessChain: return "OpPtrAccessChain"; + case SpvOpArrayLength: return "OpArrayLength"; + case SpvOpGenericPtrMemSemantics: return "OpGenericPtrMemSemantics"; + case SpvOpInBoundsPtrAccessChain: return "OpInBoundsPtrAccessChain"; + case SpvOpDecorate: return "OpDecorate"; + case SpvOpMemberDecorate: return "OpMemberDecorate"; + case SpvOpDecorationGroup: return "OpDecorationGroup"; + case SpvOpGroupDecorate: return "OpGroupDecorate"; + case SpvOpGroupMemberDecorate: return "OpGroupMemberDecorate"; + case SpvOpVectorExtractDynamic: return "OpVectorExtractDynamic"; + case SpvOpVectorInsertDynamic: return "OpVectorInsertDynamic"; + case SpvOpVectorShuffle: return "OpVectorShuffle"; + case SpvOpCompositeConstruct: return "OpCompositeConstruct"; + case SpvOpCompositeExtract: return "OpCompositeExtract"; + case SpvOpCompositeInsert: return "OpCompositeInsert"; + case SpvOpCopyObject: return "OpCopyObject"; + case SpvOpTranspose: return "OpTranspose"; + case SpvOpSampledImage: return "OpSampledImage"; + case SpvOpImageSampleImplicitLod: return "OpImageSampleImplicitLod"; + case SpvOpImageSampleExplicitLod: return "OpImageSampleExplicitLod"; + case SpvOpImageSampleDrefImplicitLod: return "OpImageSampleDrefImplicitLod"; + case SpvOpImageSampleDrefExplicitLod: return "OpImageSampleDrefExplicitLod"; + case SpvOpImageSampleProjImplicitLod: return "OpImageSampleProjImplicitLod"; + case SpvOpImageSampleProjExplicitLod: return "OpImageSampleProjExplicitLod"; + case SpvOpImageSampleProjDrefImplicitLod: return "OpImageSampleProjDrefImplicitLod"; + case SpvOpImageSampleProjDrefExplicitLod: return "OpImageSampleProjDrefExplicitLod"; + case SpvOpImageFetch: return "OpImageFetch"; + case SpvOpImageGather: return "OpImageGather"; + case SpvOpImageDrefGather: return "OpImageDrefGather"; + case SpvOpImageRead: return "OpImageRead"; + case SpvOpImageWrite: return "OpImageWrite"; + case SpvOpImage: return "OpImage"; + case SpvOpImageQueryFormat: return "OpImageQueryFormat"; + case SpvOpImageQueryOrder: return "OpImageQueryOrder"; + case SpvOpImageQuerySizeLod: return "OpImageQuerySizeLod"; + case SpvOpImageQuerySize: return "OpImageQuerySize"; + case SpvOpImageQueryLod: return "OpImageQueryLod"; + case SpvOpImageQueryLevels: return "OpImageQueryLevels"; + case SpvOpImageQuerySamples: return "OpImageQuerySamples"; + case SpvOpConvertFToU: return "OpConvertFToU"; + case SpvOpConvertFToS: return "OpConvertFToS"; + case SpvOpConvertSToF: return "OpConvertSToF"; + case SpvOpConvertUToF: return "OpConvertUToF"; + case SpvOpUConvert: return "OpUConvert"; + case SpvOpSConvert: return "OpSConvert"; + case SpvOpFConvert: return "OpFConvert"; + case SpvOpQuantizeToF16: return "OpQuantizeToF16"; + case SpvOpConvertPtrToU: return "OpConvertPtrToU"; + case SpvOpSatConvertSToU: return "OpSatConvertSToU"; + case SpvOpSatConvertUToS: return "OpSatConvertUToS"; + case SpvOpConvertUToPtr: return "OpConvertUToPtr"; + case SpvOpPtrCastToGeneric: return "OpPtrCastToGeneric"; + case SpvOpGenericCastToPtr: return "OpGenericCastToPtr"; + case SpvOpGenericCastToPtrExplicit: return "OpGenericCastToPtrExplicit"; + case SpvOpBitcast: return "OpBitcast"; + case SpvOpSNegate: return "OpSNegate"; + case SpvOpFNegate: return "OpFNegate"; + case SpvOpIAdd: return "OpIAdd"; + case SpvOpFAdd: return "OpFAdd"; + case SpvOpISub: return "OpISub"; + case SpvOpFSub: return "OpFSub"; + case SpvOpIMul: return "OpIMul"; + case SpvOpFMul: return "OpFMul"; + case SpvOpUDiv: return "OpUDiv"; + case SpvOpSDiv: return "OpSDiv"; + case SpvOpFDiv: return "OpFDiv"; + case SpvOpUMod: return "OpUMod"; + case SpvOpSRem: return "OpSRem"; + case SpvOpSMod: return "OpSMod"; + case SpvOpFRem: return "OpFRem"; + case SpvOpFMod: return "OpFMod"; + case SpvOpVectorTimesScalar: return "OpVectorTimesScalar"; + case SpvOpMatrixTimesScalar: return "OpMatrixTimesScalar"; + case SpvOpVectorTimesMatrix: return "OpVectorTimesMatrix"; + case SpvOpMatrixTimesVector: return "OpMatrixTimesVector"; + case SpvOpMatrixTimesMatrix: return "OpMatrixTimesMatrix"; + case SpvOpOuterProduct: return "OpOuterProduct"; + case SpvOpDot: return "OpDot"; + case SpvOpIAddCarry: return "OpIAddCarry"; + case SpvOpISubBorrow: return "OpISubBorrow"; + case SpvOpUMulExtended: return "OpUMulExtended"; + case SpvOpSMulExtended: return "OpSMulExtended"; + case SpvOpAny: return "OpAny"; + case SpvOpAll: return "OpAll"; + case SpvOpIsNan: return "OpIsNan"; + case SpvOpIsInf: return "OpIsInf"; + case SpvOpIsFinite: return "OpIsFinite"; + case SpvOpIsNormal: return "OpIsNormal"; + case SpvOpSignBitSet: return "OpSignBitSet"; + case SpvOpLessOrGreater: return "OpLessOrGreater"; + case SpvOpOrdered: return "OpOrdered"; + case SpvOpUnordered: return "OpUnordered"; + case SpvOpLogicalEqual: return "OpLogicalEqual"; + case SpvOpLogicalNotEqual: return "OpLogicalNotEqual"; + case SpvOpLogicalOr: return "OpLogicalOr"; + case SpvOpLogicalAnd: return "OpLogicalAnd"; + case SpvOpLogicalNot: return "OpLogicalNot"; + case SpvOpSelect: return "OpSelect"; + case SpvOpIEqual: return "OpIEqual"; + case SpvOpINotEqual: return "OpINotEqual"; + case SpvOpUGreaterThan: return "OpUGreaterThan"; + case SpvOpSGreaterThan: return "OpSGreaterThan"; + case SpvOpUGreaterThanEqual: return "OpUGreaterThanEqual"; + case SpvOpSGreaterThanEqual: return "OpSGreaterThanEqual"; + case SpvOpULessThan: return "OpULessThan"; + case SpvOpSLessThan: return "OpSLessThan"; + case SpvOpULessThanEqual: return "OpULessThanEqual"; + case SpvOpSLessThanEqual: return "OpSLessThanEqual"; + case SpvOpFOrdEqual: return "OpFOrdEqual"; + case SpvOpFUnordEqual: return "OpFUnordEqual"; + case SpvOpFOrdNotEqual: return "OpFOrdNotEqual"; + case SpvOpFUnordNotEqual: return "OpFUnordNotEqual"; + case SpvOpFOrdLessThan: return "OpFOrdLessThan"; + case SpvOpFUnordLessThan: return "OpFUnordLessThan"; + case SpvOpFOrdGreaterThan: return "OpFOrdGreaterThan"; + case SpvOpFUnordGreaterThan: return "OpFUnordGreaterThan"; + case SpvOpFOrdLessThanEqual: return "OpFOrdLessThanEqual"; + case SpvOpFUnordLessThanEqual: return "OpFUnordLessThanEqual"; + case SpvOpFOrdGreaterThanEqual: return "OpFOrdGreaterThanEqual"; + case SpvOpFUnordGreaterThanEqual: return "OpFUnordGreaterThanEqual"; + case SpvOpShiftRightLogical: return "OpShiftRightLogical"; + case SpvOpShiftRightArithmetic: return "OpShiftRightArithmetic"; + case SpvOpShiftLeftLogical: return "OpShiftLeftLogical"; + case SpvOpBitwiseOr: return "OpBitwiseOr"; + case SpvOpBitwiseXor: return "OpBitwiseXor"; + case SpvOpBitwiseAnd: return "OpBitwiseAnd"; + case SpvOpNot: return "OpNot"; + case SpvOpBitFieldInsert: return "OpBitFieldInsert"; + case SpvOpBitFieldSExtract: return "OpBitFieldSExtract"; + case SpvOpBitFieldUExtract: return "OpBitFieldUExtract"; + case SpvOpBitReverse: return "OpBitReverse"; + case SpvOpBitCount: return "OpBitCount"; + case SpvOpDPdx: return "OpDPdx"; + case SpvOpDPdy: return "OpDPdy"; + case SpvOpFwidth: return "OpFwidth"; + case SpvOpDPdxFine: return "OpDPdxFine"; + case SpvOpDPdyFine: return "OpDPdyFine"; + case SpvOpFwidthFine: return "OpFwidthFine"; + case SpvOpDPdxCoarse: return "OpDPdxCoarse"; + case SpvOpDPdyCoarse: return "OpDPdyCoarse"; + case SpvOpFwidthCoarse: return "OpFwidthCoarse"; + case SpvOpEmitVertex: return "OpEmitVertex"; + case SpvOpEndPrimitive: return "OpEndPrimitive"; + case SpvOpEmitStreamVertex: return "OpEmitStreamVertex"; + case SpvOpEndStreamPrimitive: return "OpEndStreamPrimitive"; + case SpvOpControlBarrier: return "OpControlBarrier"; + case SpvOpMemoryBarrier: return "OpMemoryBarrier"; + case SpvOpAtomicLoad: return "OpAtomicLoad"; + case SpvOpAtomicStore: return "OpAtomicStore"; + case SpvOpAtomicExchange: return "OpAtomicExchange"; + case SpvOpAtomicCompareExchange: return "OpAtomicCompareExchange"; + case SpvOpAtomicCompareExchangeWeak: return "OpAtomicCompareExchangeWeak"; + case SpvOpAtomicIIncrement: return "OpAtomicIIncrement"; + case SpvOpAtomicIDecrement: return "OpAtomicIDecrement"; + case SpvOpAtomicIAdd: return "OpAtomicIAdd"; + case SpvOpAtomicISub: return "OpAtomicISub"; + case SpvOpAtomicSMin: return "OpAtomicSMin"; + case SpvOpAtomicUMin: return "OpAtomicUMin"; + case SpvOpAtomicSMax: return "OpAtomicSMax"; + case SpvOpAtomicUMax: return "OpAtomicUMax"; + case SpvOpAtomicAnd: return "OpAtomicAnd"; + case SpvOpAtomicOr: return "OpAtomicOr"; + case SpvOpAtomicXor: return "OpAtomicXor"; + case SpvOpPhi: return "OpPhi"; + case SpvOpLoopMerge: return "OpLoopMerge"; + case SpvOpSelectionMerge: return "OpSelectionMerge"; + case SpvOpLabel: return "OpLabel"; + case SpvOpBranch: return "OpBranch"; + case SpvOpBranchConditional: return "OpBranchConditional"; + case SpvOpSwitch: return "OpSwitch"; + case SpvOpKill: return "OpKill"; + case SpvOpReturn: return "OpReturn"; + case SpvOpReturnValue: return "OpReturnValue"; + case SpvOpUnreachable: return "OpUnreachable"; + case SpvOpLifetimeStart: return "OpLifetimeStart"; + case SpvOpLifetimeStop: return "OpLifetimeStop"; + case SpvOpGroupAsyncCopy: return "OpGroupAsyncCopy"; + case SpvOpGroupWaitEvents: return "OpGroupWaitEvents"; + case SpvOpGroupAll: return "OpGroupAll"; + case SpvOpGroupAny: return "OpGroupAny"; + case SpvOpGroupBroadcast: return "OpGroupBroadcast"; + case SpvOpGroupIAdd: return "OpGroupIAdd"; + case SpvOpGroupFAdd: return "OpGroupFAdd"; + case SpvOpGroupFMin: return "OpGroupFMin"; + case SpvOpGroupUMin: return "OpGroupUMin"; + case SpvOpGroupSMin: return "OpGroupSMin"; + case SpvOpGroupFMax: return "OpGroupFMax"; + case SpvOpGroupUMax: return "OpGroupUMax"; + case SpvOpGroupSMax: return "OpGroupSMax"; + case SpvOpReadPipe: return "OpReadPipe"; + case SpvOpWritePipe: return "OpWritePipe"; + case SpvOpReservedReadPipe: return "OpReservedReadPipe"; + case SpvOpReservedWritePipe: return "OpReservedWritePipe"; + case SpvOpReserveReadPipePackets: return "OpReserveReadPipePackets"; + case SpvOpReserveWritePipePackets: return "OpReserveWritePipePackets"; + case SpvOpCommitReadPipe: return "OpCommitReadPipe"; + case SpvOpCommitWritePipe: return "OpCommitWritePipe"; + case SpvOpIsValidReserveId: return "OpIsValidReserveId"; + case SpvOpGetNumPipePackets: return "OpGetNumPipePackets"; + case SpvOpGetMaxPipePackets: return "OpGetMaxPipePackets"; + case SpvOpGroupReserveReadPipePackets: return "OpGroupReserveReadPipePackets"; + case SpvOpGroupReserveWritePipePackets: return "OpGroupReserveWritePipePackets"; + case SpvOpGroupCommitReadPipe: return "OpGroupCommitReadPipe"; + case SpvOpGroupCommitWritePipe: return "OpGroupCommitWritePipe"; + case SpvOpEnqueueMarker: return "OpEnqueueMarker"; + case SpvOpEnqueueKernel: return "OpEnqueueKernel"; + case SpvOpGetKernelNDrangeSubGroupCount: return "OpGetKernelNDrangeSubGroupCount"; + case SpvOpGetKernelNDrangeMaxSubGroupSize: return "OpGetKernelNDrangeMaxSubGroupSize"; + case SpvOpGetKernelWorkGroupSize: return "OpGetKernelWorkGroupSize"; + case SpvOpGetKernelPreferredWorkGroupSizeMultiple: return "OpGetKernelPreferredWorkGroupSizeMultiple"; + case SpvOpRetainEvent: return "OpRetainEvent"; + case SpvOpReleaseEvent: return "OpReleaseEvent"; + case SpvOpCreateUserEvent: return "OpCreateUserEvent"; + case SpvOpIsValidEvent: return "OpIsValidEvent"; + case SpvOpSetUserEventStatus: return "OpSetUserEventStatus"; + case SpvOpCaptureEventProfilingInfo: return "OpCaptureEventProfilingInfo"; + case SpvOpGetDefaultQueue: return "OpGetDefaultQueue"; + case SpvOpBuildNDRange: return "OpBuildNDRange"; + case SpvOpImageSparseSampleImplicitLod: return "OpImageSparseSampleImplicitLod"; + case SpvOpImageSparseSampleExplicitLod: return "OpImageSparseSampleExplicitLod"; + case SpvOpImageSparseSampleDrefImplicitLod: return "OpImageSparseSampleDrefImplicitLod"; + case SpvOpImageSparseSampleDrefExplicitLod: return "OpImageSparseSampleDrefExplicitLod"; + case SpvOpImageSparseSampleProjImplicitLod: return "OpImageSparseSampleProjImplicitLod"; + case SpvOpImageSparseSampleProjExplicitLod: return "OpImageSparseSampleProjExplicitLod"; + case SpvOpImageSparseSampleProjDrefImplicitLod: return "OpImageSparseSampleProjDrefImplicitLod"; + case SpvOpImageSparseSampleProjDrefExplicitLod: return "OpImageSparseSampleProjDrefExplicitLod"; + case SpvOpImageSparseFetch: return "OpImageSparseFetch"; + case SpvOpImageSparseGather: return "OpImageSparseGather"; + case SpvOpImageSparseDrefGather: return "OpImageSparseDrefGather"; + case SpvOpImageSparseTexelsResident: return "OpImageSparseTexelsResident"; + case SpvOpNoLine: return "OpNoLine"; + case SpvOpAtomicFlagTestAndSet: return "OpAtomicFlagTestAndSet"; + case SpvOpAtomicFlagClear: return "OpAtomicFlagClear"; + case SpvOpImageSparseRead: return "OpImageSparseRead"; + case SpvOpSizeOf: return "OpSizeOf"; + case SpvOpTypePipeStorage: return "OpTypePipeStorage"; + case SpvOpConstantPipeStorage: return "OpConstantPipeStorage"; + case SpvOpCreatePipeFromPipeStorage: return "OpCreatePipeFromPipeStorage"; + case SpvOpGetKernelLocalSizeForSubgroupCount: return "OpGetKernelLocalSizeForSubgroupCount"; + case SpvOpGetKernelMaxNumSubgroups: return "OpGetKernelMaxNumSubgroups"; + case SpvOpTypeNamedBarrier: return "OpTypeNamedBarrier"; + case SpvOpNamedBarrierInitialize: return "OpNamedBarrierInitialize"; + case SpvOpMemoryNamedBarrier: return "OpMemoryNamedBarrier"; + case SpvOpModuleProcessed: return "OpModuleProcessed"; + case SpvOpExecutionModeId: return "OpExecutionModeId"; + case SpvOpDecorateId: return "OpDecorateId"; + case SpvOpGroupNonUniformElect: return "OpGroupNonUniformElect"; + case SpvOpGroupNonUniformAll: return "OpGroupNonUniformAll"; + case SpvOpGroupNonUniformAny: return "OpGroupNonUniformAny"; + case SpvOpGroupNonUniformAllEqual: return "OpGroupNonUniformAllEqual"; + case SpvOpGroupNonUniformBroadcast: return "OpGroupNonUniformBroadcast"; + case SpvOpGroupNonUniformBroadcastFirst: return "OpGroupNonUniformBroadcastFirst"; + case SpvOpGroupNonUniformBallot: return "OpGroupNonUniformBallot"; + case SpvOpGroupNonUniformInverseBallot: return "OpGroupNonUniformInverseBallot"; + case SpvOpGroupNonUniformBallotBitExtract: return "OpGroupNonUniformBallotBitExtract"; + case SpvOpGroupNonUniformBallotBitCount: return "OpGroupNonUniformBallotBitCount"; + case SpvOpGroupNonUniformBallotFindLSB: return "OpGroupNonUniformBallotFindLSB"; + case SpvOpGroupNonUniformBallotFindMSB: return "OpGroupNonUniformBallotFindMSB"; + case SpvOpGroupNonUniformShuffle: return "OpGroupNonUniformShuffle"; + case SpvOpGroupNonUniformShuffleXor: return "OpGroupNonUniformShuffleXor"; + case SpvOpGroupNonUniformShuffleUp: return "OpGroupNonUniformShuffleUp"; + case SpvOpGroupNonUniformShuffleDown: return "OpGroupNonUniformShuffleDown"; + case SpvOpGroupNonUniformIAdd: return "OpGroupNonUniformIAdd"; + case SpvOpGroupNonUniformFAdd: return "OpGroupNonUniformFAdd"; + case SpvOpGroupNonUniformIMul: return "OpGroupNonUniformIMul"; + case SpvOpGroupNonUniformFMul: return "OpGroupNonUniformFMul"; + case SpvOpGroupNonUniformSMin: return "OpGroupNonUniformSMin"; + case SpvOpGroupNonUniformUMin: return "OpGroupNonUniformUMin"; + case SpvOpGroupNonUniformFMin: return "OpGroupNonUniformFMin"; + case SpvOpGroupNonUniformSMax: return "OpGroupNonUniformSMax"; + case SpvOpGroupNonUniformUMax: return "OpGroupNonUniformUMax"; + case SpvOpGroupNonUniformFMax: return "OpGroupNonUniformFMax"; + case SpvOpGroupNonUniformBitwiseAnd: return "OpGroupNonUniformBitwiseAnd"; + case SpvOpGroupNonUniformBitwiseOr: return "OpGroupNonUniformBitwiseOr"; + case SpvOpGroupNonUniformBitwiseXor: return "OpGroupNonUniformBitwiseXor"; + case SpvOpGroupNonUniformLogicalAnd: return "OpGroupNonUniformLogicalAnd"; + case SpvOpGroupNonUniformLogicalOr: return "OpGroupNonUniformLogicalOr"; + case SpvOpGroupNonUniformLogicalXor: return "OpGroupNonUniformLogicalXor"; + case SpvOpGroupNonUniformQuadBroadcast: return "OpGroupNonUniformQuadBroadcast"; + case SpvOpGroupNonUniformQuadSwap: return "OpGroupNonUniformQuadSwap"; + case SpvOpCopyLogical: return "OpCopyLogical"; + case SpvOpPtrEqual: return "OpPtrEqual"; + case SpvOpPtrNotEqual: return "OpPtrNotEqual"; + case SpvOpPtrDiff: return "OpPtrDiff"; + case SpvOpColorAttachmentReadEXT: return "OpColorAttachmentReadEXT"; + case SpvOpDepthAttachmentReadEXT: return "OpDepthAttachmentReadEXT"; + case SpvOpStencilAttachmentReadEXT: return "OpStencilAttachmentReadEXT"; + case SpvOpTerminateInvocation: return "OpTerminateInvocation"; + case SpvOpTypeUntypedPointerKHR: return "OpTypeUntypedPointerKHR"; + case SpvOpUntypedVariableKHR: return "OpUntypedVariableKHR"; + case SpvOpUntypedAccessChainKHR: return "OpUntypedAccessChainKHR"; + case SpvOpUntypedInBoundsAccessChainKHR: return "OpUntypedInBoundsAccessChainKHR"; + case SpvOpSubgroupBallotKHR: return "OpSubgroupBallotKHR"; + case SpvOpSubgroupFirstInvocationKHR: return "OpSubgroupFirstInvocationKHR"; + case SpvOpUntypedPtrAccessChainKHR: return "OpUntypedPtrAccessChainKHR"; + case SpvOpUntypedInBoundsPtrAccessChainKHR: return "OpUntypedInBoundsPtrAccessChainKHR"; + case SpvOpUntypedArrayLengthKHR: return "OpUntypedArrayLengthKHR"; + case SpvOpUntypedPrefetchKHR: return "OpUntypedPrefetchKHR"; + case SpvOpSubgroupAllKHR: return "OpSubgroupAllKHR"; + case SpvOpSubgroupAnyKHR: return "OpSubgroupAnyKHR"; + case SpvOpSubgroupAllEqualKHR: return "OpSubgroupAllEqualKHR"; + case SpvOpGroupNonUniformRotateKHR: return "OpGroupNonUniformRotateKHR"; + case SpvOpSubgroupReadInvocationKHR: return "OpSubgroupReadInvocationKHR"; + case SpvOpExtInstWithForwardRefsKHR: return "OpExtInstWithForwardRefsKHR"; + case SpvOpTraceRayKHR: return "OpTraceRayKHR"; + case SpvOpExecuteCallableKHR: return "OpExecuteCallableKHR"; + case SpvOpConvertUToAccelerationStructureKHR: return "OpConvertUToAccelerationStructureKHR"; + case SpvOpIgnoreIntersectionKHR: return "OpIgnoreIntersectionKHR"; + case SpvOpTerminateRayKHR: return "OpTerminateRayKHR"; + case SpvOpSDot: return "OpSDot"; + case SpvOpUDot: return "OpUDot"; + case SpvOpSUDot: return "OpSUDot"; + case SpvOpSDotAccSat: return "OpSDotAccSat"; + case SpvOpUDotAccSat: return "OpUDotAccSat"; + case SpvOpSUDotAccSat: return "OpSUDotAccSat"; + case SpvOpTypeCooperativeMatrixKHR: return "OpTypeCooperativeMatrixKHR"; + case SpvOpCooperativeMatrixLoadKHR: return "OpCooperativeMatrixLoadKHR"; + case SpvOpCooperativeMatrixStoreKHR: return "OpCooperativeMatrixStoreKHR"; + case SpvOpCooperativeMatrixMulAddKHR: return "OpCooperativeMatrixMulAddKHR"; + case SpvOpCooperativeMatrixLengthKHR: return "OpCooperativeMatrixLengthKHR"; + case SpvOpConstantCompositeReplicateEXT: return "OpConstantCompositeReplicateEXT"; + case SpvOpSpecConstantCompositeReplicateEXT: return "OpSpecConstantCompositeReplicateEXT"; + case SpvOpCompositeConstructReplicateEXT: return "OpCompositeConstructReplicateEXT"; + case SpvOpTypeRayQueryKHR: return "OpTypeRayQueryKHR"; + case SpvOpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR"; + case SpvOpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR"; + case SpvOpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR"; + case SpvOpRayQueryConfirmIntersectionKHR: return "OpRayQueryConfirmIntersectionKHR"; + case SpvOpRayQueryProceedKHR: return "OpRayQueryProceedKHR"; + case SpvOpRayQueryGetIntersectionTypeKHR: return "OpRayQueryGetIntersectionTypeKHR"; + case SpvOpImageSampleWeightedQCOM: return "OpImageSampleWeightedQCOM"; + case SpvOpImageBoxFilterQCOM: return "OpImageBoxFilterQCOM"; + case SpvOpImageBlockMatchSSDQCOM: return "OpImageBlockMatchSSDQCOM"; + case SpvOpImageBlockMatchSADQCOM: return "OpImageBlockMatchSADQCOM"; + case SpvOpImageBlockMatchWindowSSDQCOM: return "OpImageBlockMatchWindowSSDQCOM"; + case SpvOpImageBlockMatchWindowSADQCOM: return "OpImageBlockMatchWindowSADQCOM"; + case SpvOpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM"; + case SpvOpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM"; + case SpvOpGroupIAddNonUniformAMD: return "OpGroupIAddNonUniformAMD"; + case SpvOpGroupFAddNonUniformAMD: return "OpGroupFAddNonUniformAMD"; + case SpvOpGroupFMinNonUniformAMD: return "OpGroupFMinNonUniformAMD"; + case SpvOpGroupUMinNonUniformAMD: return "OpGroupUMinNonUniformAMD"; + case SpvOpGroupSMinNonUniformAMD: return "OpGroupSMinNonUniformAMD"; + case SpvOpGroupFMaxNonUniformAMD: return "OpGroupFMaxNonUniformAMD"; + case SpvOpGroupUMaxNonUniformAMD: return "OpGroupUMaxNonUniformAMD"; + case SpvOpGroupSMaxNonUniformAMD: return "OpGroupSMaxNonUniformAMD"; + case SpvOpFragmentMaskFetchAMD: return "OpFragmentMaskFetchAMD"; + case SpvOpFragmentFetchAMD: return "OpFragmentFetchAMD"; + case SpvOpReadClockKHR: return "OpReadClockKHR"; + case SpvOpAllocateNodePayloadsAMDX: return "OpAllocateNodePayloadsAMDX"; + case SpvOpEnqueueNodePayloadsAMDX: return "OpEnqueueNodePayloadsAMDX"; + case SpvOpTypeNodePayloadArrayAMDX: return "OpTypeNodePayloadArrayAMDX"; + case SpvOpFinishWritingNodePayloadAMDX: return "OpFinishWritingNodePayloadAMDX"; + case SpvOpNodePayloadArrayLengthAMDX: return "OpNodePayloadArrayLengthAMDX"; + case SpvOpIsNodePayloadValidAMDX: return "OpIsNodePayloadValidAMDX"; + case SpvOpConstantStringAMDX: return "OpConstantStringAMDX"; + case SpvOpSpecConstantStringAMDX: return "OpSpecConstantStringAMDX"; + case SpvOpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; + case SpvOpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; + case SpvOpHitObjectRecordHitMotionNV: return "OpHitObjectRecordHitMotionNV"; + case SpvOpHitObjectRecordHitWithIndexMotionNV: return "OpHitObjectRecordHitWithIndexMotionNV"; + case SpvOpHitObjectRecordMissMotionNV: return "OpHitObjectRecordMissMotionNV"; + case SpvOpHitObjectGetWorldToObjectNV: return "OpHitObjectGetWorldToObjectNV"; + case SpvOpHitObjectGetObjectToWorldNV: return "OpHitObjectGetObjectToWorldNV"; + case SpvOpHitObjectGetObjectRayDirectionNV: return "OpHitObjectGetObjectRayDirectionNV"; + case SpvOpHitObjectGetObjectRayOriginNV: return "OpHitObjectGetObjectRayOriginNV"; + case SpvOpHitObjectTraceRayMotionNV: return "OpHitObjectTraceRayMotionNV"; + case SpvOpHitObjectGetShaderRecordBufferHandleNV: return "OpHitObjectGetShaderRecordBufferHandleNV"; + case SpvOpHitObjectGetShaderBindingTableRecordIndexNV: return "OpHitObjectGetShaderBindingTableRecordIndexNV"; + case SpvOpHitObjectRecordEmptyNV: return "OpHitObjectRecordEmptyNV"; + case SpvOpHitObjectTraceRayNV: return "OpHitObjectTraceRayNV"; + case SpvOpHitObjectRecordHitNV: return "OpHitObjectRecordHitNV"; + case SpvOpHitObjectRecordHitWithIndexNV: return "OpHitObjectRecordHitWithIndexNV"; + case SpvOpHitObjectRecordMissNV: return "OpHitObjectRecordMissNV"; + case SpvOpHitObjectExecuteShaderNV: return "OpHitObjectExecuteShaderNV"; + case SpvOpHitObjectGetCurrentTimeNV: return "OpHitObjectGetCurrentTimeNV"; + case SpvOpHitObjectGetAttributesNV: return "OpHitObjectGetAttributesNV"; + case SpvOpHitObjectGetHitKindNV: return "OpHitObjectGetHitKindNV"; + case SpvOpHitObjectGetPrimitiveIndexNV: return "OpHitObjectGetPrimitiveIndexNV"; + case SpvOpHitObjectGetGeometryIndexNV: return "OpHitObjectGetGeometryIndexNV"; + case SpvOpHitObjectGetInstanceIdNV: return "OpHitObjectGetInstanceIdNV"; + case SpvOpHitObjectGetInstanceCustomIndexNV: return "OpHitObjectGetInstanceCustomIndexNV"; + case SpvOpHitObjectGetWorldRayDirectionNV: return "OpHitObjectGetWorldRayDirectionNV"; + case SpvOpHitObjectGetWorldRayOriginNV: return "OpHitObjectGetWorldRayOriginNV"; + case SpvOpHitObjectGetRayTMaxNV: return "OpHitObjectGetRayTMaxNV"; + case SpvOpHitObjectGetRayTMinNV: return "OpHitObjectGetRayTMinNV"; + case SpvOpHitObjectIsEmptyNV: return "OpHitObjectIsEmptyNV"; + case SpvOpHitObjectIsHitNV: return "OpHitObjectIsHitNV"; + case SpvOpHitObjectIsMissNV: return "OpHitObjectIsMissNV"; + case SpvOpReorderThreadWithHitObjectNV: return "OpReorderThreadWithHitObjectNV"; + case SpvOpReorderThreadWithHintNV: return "OpReorderThreadWithHintNV"; + case SpvOpTypeHitObjectNV: return "OpTypeHitObjectNV"; + case SpvOpImageSampleFootprintNV: return "OpImageSampleFootprintNV"; + case SpvOpTypeCooperativeVectorNV: return "OpTypeCooperativeVectorNV"; + case SpvOpCooperativeVectorMatrixMulNV: return "OpCooperativeVectorMatrixMulNV"; + case SpvOpCooperativeVectorOuterProductAccumulateNV: return "OpCooperativeVectorOuterProductAccumulateNV"; + case SpvOpCooperativeVectorReduceSumAccumulateNV: return "OpCooperativeVectorReduceSumAccumulateNV"; + case SpvOpCooperativeVectorMatrixMulAddNV: return "OpCooperativeVectorMatrixMulAddNV"; + case SpvOpCooperativeMatrixConvertNV: return "OpCooperativeMatrixConvertNV"; + case SpvOpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT"; + case SpvOpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT"; + case SpvOpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; + case SpvOpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; + case SpvOpFetchMicroTriangleVertexPositionNV: return "OpFetchMicroTriangleVertexPositionNV"; + case SpvOpFetchMicroTriangleVertexBarycentricNV: return "OpFetchMicroTriangleVertexBarycentricNV"; + case SpvOpCooperativeVectorLoadNV: return "OpCooperativeVectorLoadNV"; + case SpvOpCooperativeVectorStoreNV: return "OpCooperativeVectorStoreNV"; + case SpvOpReportIntersectionKHR: return "OpReportIntersectionKHR"; + case SpvOpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV"; + case SpvOpTerminateRayNV: return "OpTerminateRayNV"; + case SpvOpTraceNV: return "OpTraceNV"; + case SpvOpTraceMotionNV: return "OpTraceMotionNV"; + case SpvOpTraceRayMotionNV: return "OpTraceRayMotionNV"; + case SpvOpRayQueryGetIntersectionTriangleVertexPositionsKHR: return "OpRayQueryGetIntersectionTriangleVertexPositionsKHR"; + case SpvOpTypeAccelerationStructureKHR: return "OpTypeAccelerationStructureKHR"; + case SpvOpExecuteCallableNV: return "OpExecuteCallableNV"; + case SpvOpRayQueryGetClusterIdNV: return "OpRayQueryGetClusterIdNV"; + case SpvOpHitObjectGetClusterIdNV: return "OpHitObjectGetClusterIdNV"; + case SpvOpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV"; + case SpvOpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV"; + case SpvOpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV"; + case SpvOpCooperativeMatrixMulAddNV: return "OpCooperativeMatrixMulAddNV"; + case SpvOpCooperativeMatrixLengthNV: return "OpCooperativeMatrixLengthNV"; + case SpvOpBeginInvocationInterlockEXT: return "OpBeginInvocationInterlockEXT"; + case SpvOpEndInvocationInterlockEXT: return "OpEndInvocationInterlockEXT"; + case SpvOpCooperativeMatrixReduceNV: return "OpCooperativeMatrixReduceNV"; + case SpvOpCooperativeMatrixLoadTensorNV: return "OpCooperativeMatrixLoadTensorNV"; + case SpvOpCooperativeMatrixStoreTensorNV: return "OpCooperativeMatrixStoreTensorNV"; + case SpvOpCooperativeMatrixPerElementOpNV: return "OpCooperativeMatrixPerElementOpNV"; + case SpvOpTypeTensorLayoutNV: return "OpTypeTensorLayoutNV"; + case SpvOpTypeTensorViewNV: return "OpTypeTensorViewNV"; + case SpvOpCreateTensorLayoutNV: return "OpCreateTensorLayoutNV"; + case SpvOpTensorLayoutSetDimensionNV: return "OpTensorLayoutSetDimensionNV"; + case SpvOpTensorLayoutSetStrideNV: return "OpTensorLayoutSetStrideNV"; + case SpvOpTensorLayoutSliceNV: return "OpTensorLayoutSliceNV"; + case SpvOpTensorLayoutSetClampValueNV: return "OpTensorLayoutSetClampValueNV"; + case SpvOpCreateTensorViewNV: return "OpCreateTensorViewNV"; + case SpvOpTensorViewSetDimensionNV: return "OpTensorViewSetDimensionNV"; + case SpvOpTensorViewSetStrideNV: return "OpTensorViewSetStrideNV"; + case SpvOpDemoteToHelperInvocation: return "OpDemoteToHelperInvocation"; + case SpvOpIsHelperInvocationEXT: return "OpIsHelperInvocationEXT"; + case SpvOpTensorViewSetClipNV: return "OpTensorViewSetClipNV"; + case SpvOpTensorLayoutSetBlockSizeNV: return "OpTensorLayoutSetBlockSizeNV"; + case SpvOpCooperativeMatrixTransposeNV: return "OpCooperativeMatrixTransposeNV"; + case SpvOpConvertUToImageNV: return "OpConvertUToImageNV"; + case SpvOpConvertUToSamplerNV: return "OpConvertUToSamplerNV"; + case SpvOpConvertImageToUNV: return "OpConvertImageToUNV"; + case SpvOpConvertSamplerToUNV: return "OpConvertSamplerToUNV"; + case SpvOpConvertUToSampledImageNV: return "OpConvertUToSampledImageNV"; + case SpvOpConvertSampledImageToUNV: return "OpConvertSampledImageToUNV"; + case SpvOpSamplerImageAddressingModeNV: return "OpSamplerImageAddressingModeNV"; + case SpvOpRawAccessChainNV: return "OpRawAccessChainNV"; + case SpvOpRayQueryGetIntersectionSpherePositionNV: return "OpRayQueryGetIntersectionSpherePositionNV"; + case SpvOpRayQueryGetIntersectionSphereRadiusNV: return "OpRayQueryGetIntersectionSphereRadiusNV"; + case SpvOpRayQueryGetIntersectionLSSPositionsNV: return "OpRayQueryGetIntersectionLSSPositionsNV"; + case SpvOpRayQueryGetIntersectionLSSRadiiNV: return "OpRayQueryGetIntersectionLSSRadiiNV"; + case SpvOpRayQueryGetIntersectionLSSHitValueNV: return "OpRayQueryGetIntersectionLSSHitValueNV"; + case SpvOpHitObjectGetSpherePositionNV: return "OpHitObjectGetSpherePositionNV"; + case SpvOpHitObjectGetSphereRadiusNV: return "OpHitObjectGetSphereRadiusNV"; + case SpvOpHitObjectGetLSSPositionsNV: return "OpHitObjectGetLSSPositionsNV"; + case SpvOpHitObjectGetLSSRadiiNV: return "OpHitObjectGetLSSRadiiNV"; + case SpvOpHitObjectIsSphereHitNV: return "OpHitObjectIsSphereHitNV"; + case SpvOpHitObjectIsLSSHitNV: return "OpHitObjectIsLSSHitNV"; + case SpvOpRayQueryIsSphereHitNV: return "OpRayQueryIsSphereHitNV"; + case SpvOpRayQueryIsLSSHitNV: return "OpRayQueryIsLSSHitNV"; + case SpvOpSubgroupShuffleINTEL: return "OpSubgroupShuffleINTEL"; + case SpvOpSubgroupShuffleDownINTEL: return "OpSubgroupShuffleDownINTEL"; + case SpvOpSubgroupShuffleUpINTEL: return "OpSubgroupShuffleUpINTEL"; + case SpvOpSubgroupShuffleXorINTEL: return "OpSubgroupShuffleXorINTEL"; + case SpvOpSubgroupBlockReadINTEL: return "OpSubgroupBlockReadINTEL"; + case SpvOpSubgroupBlockWriteINTEL: return "OpSubgroupBlockWriteINTEL"; + case SpvOpSubgroupImageBlockReadINTEL: return "OpSubgroupImageBlockReadINTEL"; + case SpvOpSubgroupImageBlockWriteINTEL: return "OpSubgroupImageBlockWriteINTEL"; + case SpvOpSubgroupImageMediaBlockReadINTEL: return "OpSubgroupImageMediaBlockReadINTEL"; + case SpvOpSubgroupImageMediaBlockWriteINTEL: return "OpSubgroupImageMediaBlockWriteINTEL"; + case SpvOpUCountLeadingZerosINTEL: return "OpUCountLeadingZerosINTEL"; + case SpvOpUCountTrailingZerosINTEL: return "OpUCountTrailingZerosINTEL"; + case SpvOpAbsISubINTEL: return "OpAbsISubINTEL"; + case SpvOpAbsUSubINTEL: return "OpAbsUSubINTEL"; + case SpvOpIAddSatINTEL: return "OpIAddSatINTEL"; + case SpvOpUAddSatINTEL: return "OpUAddSatINTEL"; + case SpvOpIAverageINTEL: return "OpIAverageINTEL"; + case SpvOpUAverageINTEL: return "OpUAverageINTEL"; + case SpvOpIAverageRoundedINTEL: return "OpIAverageRoundedINTEL"; + case SpvOpUAverageRoundedINTEL: return "OpUAverageRoundedINTEL"; + case SpvOpISubSatINTEL: return "OpISubSatINTEL"; + case SpvOpUSubSatINTEL: return "OpUSubSatINTEL"; + case SpvOpIMul32x16INTEL: return "OpIMul32x16INTEL"; + case SpvOpUMul32x16INTEL: return "OpUMul32x16INTEL"; + case SpvOpConstantFunctionPointerINTEL: return "OpConstantFunctionPointerINTEL"; + case SpvOpFunctionPointerCallINTEL: return "OpFunctionPointerCallINTEL"; + case SpvOpAsmTargetINTEL: return "OpAsmTargetINTEL"; + case SpvOpAsmINTEL: return "OpAsmINTEL"; + case SpvOpAsmCallINTEL: return "OpAsmCallINTEL"; + case SpvOpAtomicFMinEXT: return "OpAtomicFMinEXT"; + case SpvOpAtomicFMaxEXT: return "OpAtomicFMaxEXT"; + case SpvOpAssumeTrueKHR: return "OpAssumeTrueKHR"; + case SpvOpExpectKHR: return "OpExpectKHR"; + case SpvOpDecorateString: return "OpDecorateString"; + case SpvOpMemberDecorateString: return "OpMemberDecorateString"; + case SpvOpVmeImageINTEL: return "OpVmeImageINTEL"; + case SpvOpTypeVmeImageINTEL: return "OpTypeVmeImageINTEL"; + case SpvOpTypeAvcImePayloadINTEL: return "OpTypeAvcImePayloadINTEL"; + case SpvOpTypeAvcRefPayloadINTEL: return "OpTypeAvcRefPayloadINTEL"; + case SpvOpTypeAvcSicPayloadINTEL: return "OpTypeAvcSicPayloadINTEL"; + case SpvOpTypeAvcMcePayloadINTEL: return "OpTypeAvcMcePayloadINTEL"; + case SpvOpTypeAvcMceResultINTEL: return "OpTypeAvcMceResultINTEL"; + case SpvOpTypeAvcImeResultINTEL: return "OpTypeAvcImeResultINTEL"; + case SpvOpTypeAvcImeResultSingleReferenceStreamoutINTEL: return "OpTypeAvcImeResultSingleReferenceStreamoutINTEL"; + case SpvOpTypeAvcImeResultDualReferenceStreamoutINTEL: return "OpTypeAvcImeResultDualReferenceStreamoutINTEL"; + case SpvOpTypeAvcImeSingleReferenceStreaminINTEL: return "OpTypeAvcImeSingleReferenceStreaminINTEL"; + case SpvOpTypeAvcImeDualReferenceStreaminINTEL: return "OpTypeAvcImeDualReferenceStreaminINTEL"; + case SpvOpTypeAvcRefResultINTEL: return "OpTypeAvcRefResultINTEL"; + case SpvOpTypeAvcSicResultINTEL: return "OpTypeAvcSicResultINTEL"; + case SpvOpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL"; + case SpvOpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL"; + case SpvOpSubgroupAvcMceSetInterShapePenaltyINTEL: return "OpSubgroupAvcMceSetInterShapePenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL"; + case SpvOpSubgroupAvcMceSetInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceSetInterDirectionPenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL: return "OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL"; + case SpvOpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL"; + case SpvOpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL"; + case SpvOpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL"; + case SpvOpSubgroupAvcMceSetMotionVectorCostFunctionINTEL: return "OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL"; + case SpvOpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL"; + case SpvOpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL"; + case SpvOpSubgroupAvcMceSetAcOnlyHaarINTEL: return "OpSubgroupAvcMceSetAcOnlyHaarINTEL"; + case SpvOpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL"; + case SpvOpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL"; + case SpvOpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL"; + case SpvOpSubgroupAvcMceConvertToImePayloadINTEL: return "OpSubgroupAvcMceConvertToImePayloadINTEL"; + case SpvOpSubgroupAvcMceConvertToImeResultINTEL: return "OpSubgroupAvcMceConvertToImeResultINTEL"; + case SpvOpSubgroupAvcMceConvertToRefPayloadINTEL: return "OpSubgroupAvcMceConvertToRefPayloadINTEL"; + case SpvOpSubgroupAvcMceConvertToRefResultINTEL: return "OpSubgroupAvcMceConvertToRefResultINTEL"; + case SpvOpSubgroupAvcMceConvertToSicPayloadINTEL: return "OpSubgroupAvcMceConvertToSicPayloadINTEL"; + case SpvOpSubgroupAvcMceConvertToSicResultINTEL: return "OpSubgroupAvcMceConvertToSicResultINTEL"; + case SpvOpSubgroupAvcMceGetMotionVectorsINTEL: return "OpSubgroupAvcMceGetMotionVectorsINTEL"; + case SpvOpSubgroupAvcMceGetInterDistortionsINTEL: return "OpSubgroupAvcMceGetInterDistortionsINTEL"; + case SpvOpSubgroupAvcMceGetBestInterDistortionsINTEL: return "OpSubgroupAvcMceGetBestInterDistortionsINTEL"; + case SpvOpSubgroupAvcMceGetInterMajorShapeINTEL: return "OpSubgroupAvcMceGetInterMajorShapeINTEL"; + case SpvOpSubgroupAvcMceGetInterMinorShapeINTEL: return "OpSubgroupAvcMceGetInterMinorShapeINTEL"; + case SpvOpSubgroupAvcMceGetInterDirectionsINTEL: return "OpSubgroupAvcMceGetInterDirectionsINTEL"; + case SpvOpSubgroupAvcMceGetInterMotionVectorCountINTEL: return "OpSubgroupAvcMceGetInterMotionVectorCountINTEL"; + case SpvOpSubgroupAvcMceGetInterReferenceIdsINTEL: return "OpSubgroupAvcMceGetInterReferenceIdsINTEL"; + case SpvOpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL"; + case SpvOpSubgroupAvcImeInitializeINTEL: return "OpSubgroupAvcImeInitializeINTEL"; + case SpvOpSubgroupAvcImeSetSingleReferenceINTEL: return "OpSubgroupAvcImeSetSingleReferenceINTEL"; + case SpvOpSubgroupAvcImeSetDualReferenceINTEL: return "OpSubgroupAvcImeSetDualReferenceINTEL"; + case SpvOpSubgroupAvcImeRefWindowSizeINTEL: return "OpSubgroupAvcImeRefWindowSizeINTEL"; + case SpvOpSubgroupAvcImeAdjustRefOffsetINTEL: return "OpSubgroupAvcImeAdjustRefOffsetINTEL"; + case SpvOpSubgroupAvcImeConvertToMcePayloadINTEL: return "OpSubgroupAvcImeConvertToMcePayloadINTEL"; + case SpvOpSubgroupAvcImeSetMaxMotionVectorCountINTEL: return "OpSubgroupAvcImeSetMaxMotionVectorCountINTEL"; + case SpvOpSubgroupAvcImeSetUnidirectionalMixDisableINTEL: return "OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL"; + case SpvOpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL: return "OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL"; + case SpvOpSubgroupAvcImeSetWeightedSadINTEL: return "OpSubgroupAvcImeSetWeightedSadINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL"; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL"; + case SpvOpSubgroupAvcImeConvertToMceResultINTEL: return "OpSubgroupAvcImeConvertToMceResultINTEL"; + case SpvOpSubgroupAvcImeGetSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeGetSingleReferenceStreaminINTEL"; + case SpvOpSubgroupAvcImeGetDualReferenceStreaminINTEL: return "OpSubgroupAvcImeGetDualReferenceStreaminINTEL"; + case SpvOpSubgroupAvcImeStripSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL"; + case SpvOpSubgroupAvcImeStripDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripDualReferenceStreamoutINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL"; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL"; + case SpvOpSubgroupAvcImeGetBorderReachedINTEL: return "OpSubgroupAvcImeGetBorderReachedINTEL"; + case SpvOpSubgroupAvcImeGetTruncatedSearchIndicationINTEL: return "OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL"; + case SpvOpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL: return "OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL"; + case SpvOpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL"; + case SpvOpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL"; + case SpvOpSubgroupAvcFmeInitializeINTEL: return "OpSubgroupAvcFmeInitializeINTEL"; + case SpvOpSubgroupAvcBmeInitializeINTEL: return "OpSubgroupAvcBmeInitializeINTEL"; + case SpvOpSubgroupAvcRefConvertToMcePayloadINTEL: return "OpSubgroupAvcRefConvertToMcePayloadINTEL"; + case SpvOpSubgroupAvcRefSetBidirectionalMixDisableINTEL: return "OpSubgroupAvcRefSetBidirectionalMixDisableINTEL"; + case SpvOpSubgroupAvcRefSetBilinearFilterEnableINTEL: return "OpSubgroupAvcRefSetBilinearFilterEnableINTEL"; + case SpvOpSubgroupAvcRefEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL"; + case SpvOpSubgroupAvcRefEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithDualReferenceINTEL"; + case SpvOpSubgroupAvcRefEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL"; + case SpvOpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL"; + case SpvOpSubgroupAvcRefConvertToMceResultINTEL: return "OpSubgroupAvcRefConvertToMceResultINTEL"; + case SpvOpSubgroupAvcSicInitializeINTEL: return "OpSubgroupAvcSicInitializeINTEL"; + case SpvOpSubgroupAvcSicConfigureSkcINTEL: return "OpSubgroupAvcSicConfigureSkcINTEL"; + case SpvOpSubgroupAvcSicConfigureIpeLumaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaINTEL"; + case SpvOpSubgroupAvcSicConfigureIpeLumaChromaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaChromaINTEL"; + case SpvOpSubgroupAvcSicGetMotionVectorMaskINTEL: return "OpSubgroupAvcSicGetMotionVectorMaskINTEL"; + case SpvOpSubgroupAvcSicConvertToMcePayloadINTEL: return "OpSubgroupAvcSicConvertToMcePayloadINTEL"; + case SpvOpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL"; + case SpvOpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL"; + case SpvOpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL"; + case SpvOpSubgroupAvcSicSetBilinearFilterEnableINTEL: return "OpSubgroupAvcSicSetBilinearFilterEnableINTEL"; + case SpvOpSubgroupAvcSicSetSkcForwardTransformEnableINTEL: return "OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL"; + case SpvOpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL: return "OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL"; + case SpvOpSubgroupAvcSicEvaluateIpeINTEL: return "OpSubgroupAvcSicEvaluateIpeINTEL"; + case SpvOpSubgroupAvcSicEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL"; + case SpvOpSubgroupAvcSicEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithDualReferenceINTEL"; + case SpvOpSubgroupAvcSicEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL"; + case SpvOpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL"; + case SpvOpSubgroupAvcSicConvertToMceResultINTEL: return "OpSubgroupAvcSicConvertToMceResultINTEL"; + case SpvOpSubgroupAvcSicGetIpeLumaShapeINTEL: return "OpSubgroupAvcSicGetIpeLumaShapeINTEL"; + case SpvOpSubgroupAvcSicGetBestIpeLumaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL"; + case SpvOpSubgroupAvcSicGetBestIpeChromaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL"; + case SpvOpSubgroupAvcSicGetPackedIpeLumaModesINTEL: return "OpSubgroupAvcSicGetPackedIpeLumaModesINTEL"; + case SpvOpSubgroupAvcSicGetIpeChromaModeINTEL: return "OpSubgroupAvcSicGetIpeChromaModeINTEL"; + case SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL"; + case SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL"; + case SpvOpSubgroupAvcSicGetInterRawSadsINTEL: return "OpSubgroupAvcSicGetInterRawSadsINTEL"; + case SpvOpVariableLengthArrayINTEL: return "OpVariableLengthArrayINTEL"; + case SpvOpSaveMemoryINTEL: return "OpSaveMemoryINTEL"; + case SpvOpRestoreMemoryINTEL: return "OpRestoreMemoryINTEL"; + case SpvOpArbitraryFloatSinCosPiINTEL: return "OpArbitraryFloatSinCosPiINTEL"; + case SpvOpArbitraryFloatCastINTEL: return "OpArbitraryFloatCastINTEL"; + case SpvOpArbitraryFloatCastFromIntINTEL: return "OpArbitraryFloatCastFromIntINTEL"; + case SpvOpArbitraryFloatCastToIntINTEL: return "OpArbitraryFloatCastToIntINTEL"; + case SpvOpArbitraryFloatAddINTEL: return "OpArbitraryFloatAddINTEL"; + case SpvOpArbitraryFloatSubINTEL: return "OpArbitraryFloatSubINTEL"; + case SpvOpArbitraryFloatMulINTEL: return "OpArbitraryFloatMulINTEL"; + case SpvOpArbitraryFloatDivINTEL: return "OpArbitraryFloatDivINTEL"; + case SpvOpArbitraryFloatGTINTEL: return "OpArbitraryFloatGTINTEL"; + case SpvOpArbitraryFloatGEINTEL: return "OpArbitraryFloatGEINTEL"; + case SpvOpArbitraryFloatLTINTEL: return "OpArbitraryFloatLTINTEL"; + case SpvOpArbitraryFloatLEINTEL: return "OpArbitraryFloatLEINTEL"; + case SpvOpArbitraryFloatEQINTEL: return "OpArbitraryFloatEQINTEL"; + case SpvOpArbitraryFloatRecipINTEL: return "OpArbitraryFloatRecipINTEL"; + case SpvOpArbitraryFloatRSqrtINTEL: return "OpArbitraryFloatRSqrtINTEL"; + case SpvOpArbitraryFloatCbrtINTEL: return "OpArbitraryFloatCbrtINTEL"; + case SpvOpArbitraryFloatHypotINTEL: return "OpArbitraryFloatHypotINTEL"; + case SpvOpArbitraryFloatSqrtINTEL: return "OpArbitraryFloatSqrtINTEL"; + case SpvOpArbitraryFloatLogINTEL: return "OpArbitraryFloatLogINTEL"; + case SpvOpArbitraryFloatLog2INTEL: return "OpArbitraryFloatLog2INTEL"; + case SpvOpArbitraryFloatLog10INTEL: return "OpArbitraryFloatLog10INTEL"; + case SpvOpArbitraryFloatLog1pINTEL: return "OpArbitraryFloatLog1pINTEL"; + case SpvOpArbitraryFloatExpINTEL: return "OpArbitraryFloatExpINTEL"; + case SpvOpArbitraryFloatExp2INTEL: return "OpArbitraryFloatExp2INTEL"; + case SpvOpArbitraryFloatExp10INTEL: return "OpArbitraryFloatExp10INTEL"; + case SpvOpArbitraryFloatExpm1INTEL: return "OpArbitraryFloatExpm1INTEL"; + case SpvOpArbitraryFloatSinINTEL: return "OpArbitraryFloatSinINTEL"; + case SpvOpArbitraryFloatCosINTEL: return "OpArbitraryFloatCosINTEL"; + case SpvOpArbitraryFloatSinCosINTEL: return "OpArbitraryFloatSinCosINTEL"; + case SpvOpArbitraryFloatSinPiINTEL: return "OpArbitraryFloatSinPiINTEL"; + case SpvOpArbitraryFloatCosPiINTEL: return "OpArbitraryFloatCosPiINTEL"; + case SpvOpArbitraryFloatASinINTEL: return "OpArbitraryFloatASinINTEL"; + case SpvOpArbitraryFloatASinPiINTEL: return "OpArbitraryFloatASinPiINTEL"; + case SpvOpArbitraryFloatACosINTEL: return "OpArbitraryFloatACosINTEL"; + case SpvOpArbitraryFloatACosPiINTEL: return "OpArbitraryFloatACosPiINTEL"; + case SpvOpArbitraryFloatATanINTEL: return "OpArbitraryFloatATanINTEL"; + case SpvOpArbitraryFloatATanPiINTEL: return "OpArbitraryFloatATanPiINTEL"; + case SpvOpArbitraryFloatATan2INTEL: return "OpArbitraryFloatATan2INTEL"; + case SpvOpArbitraryFloatPowINTEL: return "OpArbitraryFloatPowINTEL"; + case SpvOpArbitraryFloatPowRINTEL: return "OpArbitraryFloatPowRINTEL"; + case SpvOpArbitraryFloatPowNINTEL: return "OpArbitraryFloatPowNINTEL"; + case SpvOpLoopControlINTEL: return "OpLoopControlINTEL"; + case SpvOpAliasDomainDeclINTEL: return "OpAliasDomainDeclINTEL"; + case SpvOpAliasScopeDeclINTEL: return "OpAliasScopeDeclINTEL"; + case SpvOpAliasScopeListDeclINTEL: return "OpAliasScopeListDeclINTEL"; + case SpvOpFixedSqrtINTEL: return "OpFixedSqrtINTEL"; + case SpvOpFixedRecipINTEL: return "OpFixedRecipINTEL"; + case SpvOpFixedRsqrtINTEL: return "OpFixedRsqrtINTEL"; + case SpvOpFixedSinINTEL: return "OpFixedSinINTEL"; + case SpvOpFixedCosINTEL: return "OpFixedCosINTEL"; + case SpvOpFixedSinCosINTEL: return "OpFixedSinCosINTEL"; + case SpvOpFixedSinPiINTEL: return "OpFixedSinPiINTEL"; + case SpvOpFixedCosPiINTEL: return "OpFixedCosPiINTEL"; + case SpvOpFixedSinCosPiINTEL: return "OpFixedSinCosPiINTEL"; + case SpvOpFixedLogINTEL: return "OpFixedLogINTEL"; + case SpvOpFixedExpINTEL: return "OpFixedExpINTEL"; + case SpvOpPtrCastToCrossWorkgroupINTEL: return "OpPtrCastToCrossWorkgroupINTEL"; + case SpvOpCrossWorkgroupCastToPtrINTEL: return "OpCrossWorkgroupCastToPtrINTEL"; + case SpvOpReadPipeBlockingINTEL: return "OpReadPipeBlockingINTEL"; + case SpvOpWritePipeBlockingINTEL: return "OpWritePipeBlockingINTEL"; + case SpvOpFPGARegINTEL: return "OpFPGARegINTEL"; + case SpvOpRayQueryGetRayTMinKHR: return "OpRayQueryGetRayTMinKHR"; + case SpvOpRayQueryGetRayFlagsKHR: return "OpRayQueryGetRayFlagsKHR"; + case SpvOpRayQueryGetIntersectionTKHR: return "OpRayQueryGetIntersectionTKHR"; + case SpvOpRayQueryGetIntersectionInstanceCustomIndexKHR: return "OpRayQueryGetIntersectionInstanceCustomIndexKHR"; + case SpvOpRayQueryGetIntersectionInstanceIdKHR: return "OpRayQueryGetIntersectionInstanceIdKHR"; + case SpvOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR: return "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR"; + case SpvOpRayQueryGetIntersectionGeometryIndexKHR: return "OpRayQueryGetIntersectionGeometryIndexKHR"; + case SpvOpRayQueryGetIntersectionPrimitiveIndexKHR: return "OpRayQueryGetIntersectionPrimitiveIndexKHR"; + case SpvOpRayQueryGetIntersectionBarycentricsKHR: return "OpRayQueryGetIntersectionBarycentricsKHR"; + case SpvOpRayQueryGetIntersectionFrontFaceKHR: return "OpRayQueryGetIntersectionFrontFaceKHR"; + case SpvOpRayQueryGetIntersectionCandidateAABBOpaqueKHR: return "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR"; + case SpvOpRayQueryGetIntersectionObjectRayDirectionKHR: return "OpRayQueryGetIntersectionObjectRayDirectionKHR"; + case SpvOpRayQueryGetIntersectionObjectRayOriginKHR: return "OpRayQueryGetIntersectionObjectRayOriginKHR"; + case SpvOpRayQueryGetWorldRayDirectionKHR: return "OpRayQueryGetWorldRayDirectionKHR"; + case SpvOpRayQueryGetWorldRayOriginKHR: return "OpRayQueryGetWorldRayOriginKHR"; + case SpvOpRayQueryGetIntersectionObjectToWorldKHR: return "OpRayQueryGetIntersectionObjectToWorldKHR"; + case SpvOpRayQueryGetIntersectionWorldToObjectKHR: return "OpRayQueryGetIntersectionWorldToObjectKHR"; + case SpvOpAtomicFAddEXT: return "OpAtomicFAddEXT"; + case SpvOpTypeBufferSurfaceINTEL: return "OpTypeBufferSurfaceINTEL"; + case SpvOpTypeStructContinuedINTEL: return "OpTypeStructContinuedINTEL"; + case SpvOpConstantCompositeContinuedINTEL: return "OpConstantCompositeContinuedINTEL"; + case SpvOpSpecConstantCompositeContinuedINTEL: return "OpSpecConstantCompositeContinuedINTEL"; + case SpvOpCompositeConstructContinuedINTEL: return "OpCompositeConstructContinuedINTEL"; + case SpvOpConvertFToBF16INTEL: return "OpConvertFToBF16INTEL"; + case SpvOpConvertBF16ToFINTEL: return "OpConvertBF16ToFINTEL"; + case SpvOpControlBarrierArriveINTEL: return "OpControlBarrierArriveINTEL"; + case SpvOpControlBarrierWaitINTEL: return "OpControlBarrierWaitINTEL"; + case SpvOpArithmeticFenceEXT: return "OpArithmeticFenceEXT"; + case SpvOpSubgroupBlockPrefetchINTEL: return "OpSubgroupBlockPrefetchINTEL"; + case SpvOpSubgroup2DBlockLoadINTEL: return "OpSubgroup2DBlockLoadINTEL"; + case SpvOpSubgroup2DBlockLoadTransformINTEL: return "OpSubgroup2DBlockLoadTransformINTEL"; + case SpvOpSubgroup2DBlockLoadTransposeINTEL: return "OpSubgroup2DBlockLoadTransposeINTEL"; + case SpvOpSubgroup2DBlockPrefetchINTEL: return "OpSubgroup2DBlockPrefetchINTEL"; + case SpvOpSubgroup2DBlockStoreINTEL: return "OpSubgroup2DBlockStoreINTEL"; + case SpvOpSubgroupMatrixMultiplyAccumulateINTEL: return "OpSubgroupMatrixMultiplyAccumulateINTEL"; + case SpvOpGroupIMulKHR: return "OpGroupIMulKHR"; + case SpvOpGroupFMulKHR: return "OpGroupFMulKHR"; + case SpvOpGroupBitwiseAndKHR: return "OpGroupBitwiseAndKHR"; + case SpvOpGroupBitwiseOrKHR: return "OpGroupBitwiseOrKHR"; + case SpvOpGroupBitwiseXorKHR: return "OpGroupBitwiseXorKHR"; + case SpvOpGroupLogicalAndKHR: return "OpGroupLogicalAndKHR"; + case SpvOpGroupLogicalOrKHR: return "OpGroupLogicalOrKHR"; + case SpvOpGroupLogicalXorKHR: return "OpGroupLogicalXorKHR"; + case SpvOpMaskedGatherINTEL: return "OpMaskedGatherINTEL"; + case SpvOpMaskedScatterINTEL: return "OpMaskedScatterINTEL"; + default: return "Unknown"; + } +} + #endif /* SPV_ENABLE_UTILITY_CODE */ #endif diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.hpp b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp index 65d84e2abb..b5dc2d5814 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.hpp +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -69,6 +69,12 @@ enum SourceLanguage { SourceLanguageHLSL = 5, SourceLanguageCPP_for_OpenCL = 6, SourceLanguageSYCL = 7, + SourceLanguageHERO_C = 8, + SourceLanguageNZSL = 9, + SourceLanguageWGSL = 10, + SourceLanguageSlang = 11, + SourceLanguageZig = 12, + SourceLanguageRust = 13, SourceLanguageMax = 0x7fffffff, }; @@ -156,6 +162,9 @@ enum ExecutionMode { ExecutionModeSubgroupsPerWorkgroupId = 37, ExecutionModeLocalSizeId = 38, ExecutionModeLocalSizeHintId = 39, + ExecutionModeNonCoherentColorAttachmentReadEXT = 4169, + ExecutionModeNonCoherentDepthAttachmentReadEXT = 4170, + ExecutionModeNonCoherentStencilAttachmentReadEXT = 4171, ExecutionModeSubgroupUniformControlFlowKHR = 4421, ExecutionModePostDepthCoverage = 4446, ExecutionModeDenormPreserve = 4459, @@ -165,17 +174,28 @@ enum ExecutionMode { ExecutionModeRoundingModeRTZ = 4463, ExecutionModeEarlyAndLateFragmentTestsAMD = 5017, ExecutionModeStencilRefReplacingEXT = 5027, + ExecutionModeCoalescingAMDX = 5069, + ExecutionModeIsApiEntryAMDX = 5070, + ExecutionModeMaxNodeRecursionAMDX = 5071, + ExecutionModeStaticNumWorkgroupsAMDX = 5072, + ExecutionModeShaderIndexAMDX = 5073, + ExecutionModeMaxNumWorkgroupsAMDX = 5077, ExecutionModeStencilRefUnchangedFrontAMD = 5079, ExecutionModeStencilRefGreaterFrontAMD = 5080, ExecutionModeStencilRefLessFrontAMD = 5081, ExecutionModeStencilRefUnchangedBackAMD = 5082, ExecutionModeStencilRefGreaterBackAMD = 5083, ExecutionModeStencilRefLessBackAMD = 5084, + ExecutionModeQuadDerivativesKHR = 5088, + ExecutionModeRequireFullQuadsKHR = 5089, + ExecutionModeSharesInputWithAMDX = 5102, ExecutionModeOutputLinesEXT = 5269, ExecutionModeOutputLinesNV = 5269, ExecutionModeOutputPrimitivesEXT = 5270, ExecutionModeOutputPrimitivesNV = 5270, + ExecutionModeDerivativeGroupQuadsKHR = 5289, ExecutionModeDerivativeGroupQuadsNV = 5289, + ExecutionModeDerivativeGroupLinearKHR = 5290, ExecutionModeDerivativeGroupLinearNV = 5290, ExecutionModeOutputTrianglesEXT = 5298, ExecutionModeOutputTrianglesNV = 5298, @@ -195,8 +215,14 @@ enum ExecutionMode { ExecutionModeNoGlobalOffsetINTEL = 5895, ExecutionModeNumSIMDWorkitemsINTEL = 5896, ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903, + ExecutionModeMaximallyReconvergesKHR = 6023, + ExecutionModeFPFastMathDefault = 6028, ExecutionModeStreamingInterfaceINTEL = 6154, + ExecutionModeRegisterMapInterfaceINTEL = 6160, ExecutionModeNamedBarrierCountINTEL = 6417, + ExecutionModeMaximumRegistersINTEL = 6461, + ExecutionModeMaximumRegistersIdINTEL = 6462, + ExecutionModeNamedMaximumRegistersINTEL = 6463, ExecutionModeMax = 0x7fffffff, }; @@ -214,6 +240,8 @@ enum StorageClass { StorageClassAtomicCounter = 10, StorageClassImage = 11, StorageClassStorageBuffer = 12, + StorageClassTileImageEXT = 4172, + StorageClassNodePayloadAMDX = 5068, StorageClassCallableDataKHR = 5328, StorageClassCallableDataNV = 5328, StorageClassIncomingCallableDataKHR = 5329, @@ -244,6 +272,7 @@ enum Dim { DimRect = 4, DimBuffer = 5, DimSubpassData = 6, + DimTileImageDataEXT = 4173, DimMax = 0x7fffffff, }; @@ -350,6 +379,9 @@ enum ImageChannelDataType { ImageChannelDataTypeFloat = 14, ImageChannelDataTypeUnormInt24 = 15, ImageChannelDataTypeUnormInt101010_2 = 16, + ImageChannelDataTypeUnsignedIntRaw10EXT = 19, + ImageChannelDataTypeUnsignedIntRaw12EXT = 20, + ImageChannelDataTypeUnormInt2_101010EXT = 21, ImageChannelDataTypeMax = 0x7fffffff, }; @@ -407,8 +439,11 @@ enum FPFastMathModeShift { FPFastMathModeNSZShift = 2, FPFastMathModeAllowRecipShift = 3, FPFastMathModeFastShift = 4, + FPFastMathModeAllowContractShift = 16, FPFastMathModeAllowContractFastINTELShift = 16, + FPFastMathModeAllowReassocShift = 17, FPFastMathModeAllowReassocINTELShift = 17, + FPFastMathModeAllowTransformShift = 18, FPFastMathModeMax = 0x7fffffff, }; @@ -419,8 +454,11 @@ enum FPFastMathModeMask { FPFastMathModeNSZMask = 0x00000004, FPFastMathModeAllowRecipMask = 0x00000008, FPFastMathModeFastMask = 0x00000010, + FPFastMathModeAllowContractMask = 0x00010000, FPFastMathModeAllowContractFastINTELMask = 0x00010000, + FPFastMathModeAllowReassocMask = 0x00020000, FPFastMathModeAllowReassocINTELMask = 0x00020000, + FPFastMathModeAllowTransformMask = 0x00040000, }; enum FPRoundingMode { @@ -508,7 +546,18 @@ enum Decoration { DecorationMaxByteOffsetId = 47, DecorationNoSignedWrap = 4469, DecorationNoUnsignedWrap = 4470, + DecorationWeightTextureQCOM = 4487, + DecorationBlockMatchTextureQCOM = 4488, + DecorationBlockMatchSamplerQCOM = 4499, DecorationExplicitInterpAMD = 4999, + DecorationNodeSharesPayloadLimitsWithAMDX = 5019, + DecorationNodeMaxPayloadsAMDX = 5020, + DecorationTrackFinishWritingAMDX = 5078, + DecorationPayloadNodeNameAMDX = 5091, + DecorationPayloadNodeBaseIndexAMDX = 5098, + DecorationPayloadNodeSparseArrayAMDX = 5099, + DecorationPayloadNodeArraySizeAMDX = 5100, + DecorationPayloadDispatchIndirectAMDX = 5105, DecorationOverrideCoverageNV = 5248, DecorationPassthroughNV = 5250, DecorationViewportRelativeNV = 5252, @@ -558,6 +607,9 @@ enum Decoration { DecorationMergeINTEL = 5834, DecorationBankBitsINTEL = 5835, DecorationForcePow2DepthINTEL = 5836, + DecorationStridesizeINTEL = 5883, + DecorationWordsizeINTEL = 5884, + DecorationTrueDualPortINTEL = 5885, DecorationBurstCoalesceINTEL = 5899, DecorationCacheSizeINTEL = 5900, DecorationDontStaticallyCoalesceINTEL = 5901, @@ -576,6 +628,24 @@ enum Decoration { DecorationSingleElementVectorINTEL = 6085, DecorationVectorComputeCallableFunctionINTEL = 6087, DecorationMediaBlockIOINTEL = 6140, + DecorationStallFreeINTEL = 6151, + DecorationFPMaxErrorDecorationINTEL = 6170, + DecorationLatencyControlLabelINTEL = 6172, + DecorationLatencyControlConstraintINTEL = 6173, + DecorationConduitKernelArgumentINTEL = 6175, + DecorationRegisterMapKernelArgumentINTEL = 6176, + DecorationMMHostInterfaceAddressWidthINTEL = 6177, + DecorationMMHostInterfaceDataWidthINTEL = 6178, + DecorationMMHostInterfaceLatencyINTEL = 6179, + DecorationMMHostInterfaceReadWriteModeINTEL = 6180, + DecorationMMHostInterfaceMaxBurstINTEL = 6181, + DecorationMMHostInterfaceWaitRequestINTEL = 6182, + DecorationStableKernelArgumentINTEL = 6183, + DecorationHostAccessINTEL = 6188, + DecorationInitModeINTEL = 6190, + DecorationImplementInRegisterMapINTEL = 6191, + DecorationCacheControlLoadINTEL = 6442, + DecorationCacheControlStoreINTEL = 6443, DecorationMax = 0x7fffffff, }; @@ -651,6 +721,8 @@ enum BuiltIn { BuiltInBaryCoordSmoothSampleAMD = 4997, BuiltInBaryCoordPullModelAMD = 4998, BuiltInFragStencilRefEXT = 5014, + BuiltInRemainingRecursionLevelsAMDX = 5021, + BuiltInShaderIndexAMDX = 5073, BuiltInViewportMaskNV = 5253, BuiltInSecondaryPositionNV = 5257, BuiltInSecondaryViewportMaskNV = 5258, @@ -703,13 +775,25 @@ enum BuiltIn { BuiltInHitKindKHR = 5333, BuiltInHitKindNV = 5333, BuiltInCurrentRayTimeNV = 5334, + BuiltInHitTriangleVertexPositionsKHR = 5335, + BuiltInHitMicroTriangleVertexPositionsNV = 5337, + BuiltInHitMicroTriangleVertexBarycentricsNV = 5344, BuiltInIncomingRayFlagsKHR = 5351, BuiltInIncomingRayFlagsNV = 5351, BuiltInRayGeometryIndexKHR = 5352, + BuiltInHitIsSphereNV = 5359, + BuiltInHitIsLSSNV = 5360, + BuiltInHitSpherePositionNV = 5361, BuiltInWarpsPerSMNV = 5374, BuiltInSMCountNV = 5375, BuiltInWarpIDNV = 5376, BuiltInSMIDNV = 5377, + BuiltInHitLSSPositionsNV = 5396, + BuiltInHitKindFrontFacingMicroTriangleNV = 5405, + BuiltInHitKindBackFacingMicroTriangleNV = 5406, + BuiltInHitSphereRadiusNV = 5420, + BuiltInHitLSSRadiiNV = 5421, + BuiltInClusterIDNV = 5436, BuiltInCullMaskKHR = 6021, BuiltInMax = 0x7fffffff, }; @@ -777,6 +861,7 @@ enum FunctionControlShift { FunctionControlDontInlineShift = 1, FunctionControlPureShift = 2, FunctionControlConstShift = 3, + FunctionControlOptNoneEXTShift = 16, FunctionControlOptNoneINTELShift = 16, FunctionControlMax = 0x7fffffff, }; @@ -787,6 +872,7 @@ enum FunctionControlMask { FunctionControlDontInlineMask = 0x00000002, FunctionControlPureMask = 0x00000004, FunctionControlConstMask = 0x00000008, + FunctionControlOptNoneEXTMask = 0x00010000, FunctionControlOptNoneINTELMask = 0x00010000, }; @@ -974,6 +1060,10 @@ enum Capability { CapabilityShaderViewportIndex = 70, CapabilityUniformDecoration = 71, CapabilityCoreBuiltinsARM = 4165, + CapabilityTileImageColorReadAccessEXT = 4166, + CapabilityTileImageDepthReadAccessEXT = 4167, + CapabilityTileImageStencilReadAccessEXT = 4168, + CapabilityCooperativeMatrixLayoutsARM = 4201, CapabilityFragmentShadingRateKHR = 4422, CapabilitySubgroupBallotKHR = 4423, CapabilityDrawParameters = 4427, @@ -1003,8 +1093,13 @@ enum Capability { CapabilityRoundingModeRTZ = 4468, CapabilityRayQueryProvisionalKHR = 4471, CapabilityRayQueryKHR = 4472, + CapabilityUntypedPointersKHR = 4473, CapabilityRayTraversalPrimitiveCullingKHR = 4478, CapabilityRayTracingKHR = 4479, + CapabilityTextureSampleWeightedQCOM = 4484, + CapabilityTextureBoxFilterQCOM = 4485, + CapabilityTextureBlockMatchQCOM = 4486, + CapabilityTextureBlockMatch2QCOM = 4498, CapabilityFloat16ImageAMD = 5008, CapabilityImageGatherBiasLodAMD = 5009, CapabilityFragmentMaskAMD = 5010, @@ -1012,6 +1107,8 @@ enum Capability { CapabilityImageReadWriteLodAMD = 5015, CapabilityInt64ImageEXT = 5016, CapabilityShaderClockKHR = 5055, + CapabilityShaderEnqueueAMDX = 5067, + CapabilityQuadControlKHR = 5087, CapabilitySampleMaskOverrideCoverageNV = 5249, CapabilityGeometryShaderPassthroughNV = 5251, CapabilityShaderViewportIndexLayerEXT = 5254, @@ -1025,6 +1122,7 @@ enum Capability { CapabilityMeshShadingEXT = 5283, CapabilityFragmentBarycentricKHR = 5284, CapabilityFragmentBarycentricNV = 5284, + CapabilityComputeDerivativeGroupQuadsKHR = 5288, CapabilityComputeDerivativeGroupQuadsNV = 5288, CapabilityFragmentDensityEXT = 5291, CapabilityShadingRateNV = 5291, @@ -1053,6 +1151,7 @@ enum Capability { CapabilityUniformTexelBufferArrayNonUniformIndexingEXT = 5311, CapabilityStorageTexelBufferArrayNonUniformIndexing = 5312, CapabilityStorageTexelBufferArrayNonUniformIndexingEXT = 5312, + CapabilityRayTracingPositionFetchKHR = 5336, CapabilityRayTracingNV = 5340, CapabilityRayTracingMotionBlurNV = 5341, CapabilityVulkanMemoryModel = 5345, @@ -1061,6 +1160,7 @@ enum Capability { CapabilityVulkanMemoryModelDeviceScopeKHR = 5346, CapabilityPhysicalStorageBufferAddresses = 5347, CapabilityPhysicalStorageBufferAddressesEXT = 5347, + CapabilityComputeDerivativeGroupLinearKHR = 5350, CapabilityComputeDerivativeGroupLinearNV = 5350, CapabilityRayTracingProvisionalKHR = 5353, CapabilityCooperativeMatrixNV = 5357, @@ -1070,9 +1170,25 @@ enum Capability { CapabilityFragmentShaderPixelInterlockEXT = 5378, CapabilityDemoteToHelperInvocation = 5379, CapabilityDemoteToHelperInvocationEXT = 5379, + CapabilityDisplacementMicromapNV = 5380, CapabilityRayTracingOpacityMicromapEXT = 5381, CapabilityShaderInvocationReorderNV = 5383, CapabilityBindlessTextureNV = 5390, + CapabilityRayQueryPositionFetchKHR = 5391, + CapabilityCooperativeVectorNV = 5394, + CapabilityAtomicFloat16VectorNV = 5404, + CapabilityRayTracingDisplacementMicromapNV = 5409, + CapabilityRawAccessChainsNV = 5414, + CapabilityRayTracingSpheresGeometryNV = 5418, + CapabilityRayTracingLinearSweptSpheresGeometryNV = 5419, + CapabilityCooperativeMatrixReductionsNV = 5430, + CapabilityCooperativeMatrixConversionsNV = 5431, + CapabilityCooperativeMatrixPerElementOperationsNV = 5432, + CapabilityCooperativeMatrixTensorAddressingNV = 5433, + CapabilityCooperativeMatrixBlockLoadsNV = 5434, + CapabilityCooperativeVectorTrainingNV = 5435, + CapabilityRayTracingClusterAccelerationStructureNV = 5437, + CapabilityTensorAddressingNV = 5439, CapabilitySubgroupShuffleINTEL = 5568, CapabilitySubgroupBufferBlockIOINTEL = 5569, CapabilitySubgroupImageBlockIOINTEL = 5570, @@ -1124,16 +1240,37 @@ enum Capability { CapabilityDotProduct = 6019, CapabilityDotProductKHR = 6019, CapabilityRayCullMaskKHR = 6020, + CapabilityCooperativeMatrixKHR = 6022, + CapabilityReplicatedCompositesEXT = 6024, CapabilityBitInstructions = 6025, CapabilityGroupNonUniformRotateKHR = 6026, + CapabilityFloatControls2 = 6029, CapabilityAtomicFloat32AddEXT = 6033, CapabilityAtomicFloat64AddEXT = 6034, - CapabilityLongConstantCompositeINTEL = 6089, + CapabilityLongCompositesINTEL = 6089, + CapabilityOptNoneEXT = 6094, CapabilityOptNoneINTEL = 6094, CapabilityAtomicFloat16AddEXT = 6095, CapabilityDebugInfoModuleINTEL = 6114, + CapabilityBFloat16ConversionINTEL = 6115, CapabilitySplitBarrierINTEL = 6141, + CapabilityArithmeticFenceEXT = 6144, + CapabilityFPGAClusterAttributesV2INTEL = 6150, + CapabilityFPGAKernelAttributesv2INTEL = 6161, + CapabilityFPMaxErrorINTEL = 6169, + CapabilityFPGALatencyControlINTEL = 6171, + CapabilityFPGAArgumentInterfacesINTEL = 6174, + CapabilityGlobalVariableHostAccessINTEL = 6187, + CapabilityGlobalVariableFPGADecorationsINTEL = 6189, + CapabilitySubgroupBufferPrefetchINTEL = 6220, + CapabilitySubgroup2DBlockIOINTEL = 6228, + CapabilitySubgroup2DBlockTransformINTEL = 6229, + CapabilitySubgroup2DBlockTransposeINTEL = 6230, + CapabilitySubgroupMatrixMultiplyAccumulateINTEL = 6236, CapabilityGroupUniformArithmeticKHR = 6400, + CapabilityMaskedGatherScatterINTEL = 6427, + CapabilityCacheControlsINTEL = 6441, + CapabilityRegisterLimitsINTEL = 6460, CapabilityMax = 0x7fffffff, }; @@ -1146,6 +1283,7 @@ enum RayFlagsShift { RayFlagsCullFrontFacingTrianglesKHRShift = 5, RayFlagsCullOpaqueKHRShift = 6, RayFlagsCullNoOpaqueKHRShift = 7, + RayFlagsSkipBuiltinPrimitivesNVShift = 8, RayFlagsSkipTrianglesKHRShift = 8, RayFlagsSkipAABBsKHRShift = 9, RayFlagsForceOpacityMicromap2StateEXTShift = 10, @@ -1162,6 +1300,7 @@ enum RayFlagsMask { RayFlagsCullFrontFacingTrianglesKHRMask = 0x00000020, RayFlagsCullOpaqueKHRMask = 0x00000040, RayFlagsCullNoOpaqueKHRMask = 0x00000080, + RayFlagsSkipBuiltinPrimitivesNVMask = 0x00000100, RayFlagsSkipTrianglesKHRMask = 0x00000100, RayFlagsSkipAABBsKHRMask = 0x00000200, RayFlagsForceOpacityMicromap2StateEXTMask = 0x00000400, @@ -1240,6 +1379,189 @@ enum PackedVectorFormat { PackedVectorFormatMax = 0x7fffffff, }; +enum CooperativeMatrixOperandsShift { + CooperativeMatrixOperandsMatrixASignedComponentsKHRShift = 0, + CooperativeMatrixOperandsMatrixBSignedComponentsKHRShift = 1, + CooperativeMatrixOperandsMatrixCSignedComponentsKHRShift = 2, + CooperativeMatrixOperandsMatrixResultSignedComponentsKHRShift = 3, + CooperativeMatrixOperandsSaturatingAccumulationKHRShift = 4, + CooperativeMatrixOperandsMax = 0x7fffffff, +}; + +enum CooperativeMatrixOperandsMask { + CooperativeMatrixOperandsMaskNone = 0, + CooperativeMatrixOperandsMatrixASignedComponentsKHRMask = 0x00000001, + CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask = 0x00000002, + CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask = 0x00000004, + CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask = 0x00000008, + CooperativeMatrixOperandsSaturatingAccumulationKHRMask = 0x00000010, +}; + +enum CooperativeMatrixLayout { + CooperativeMatrixLayoutRowMajorKHR = 0, + CooperativeMatrixLayoutColumnMajorKHR = 1, + CooperativeMatrixLayoutRowBlockedInterleavedARM = 4202, + CooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203, + CooperativeMatrixLayoutMax = 0x7fffffff, +}; + +enum CooperativeMatrixUse { + CooperativeMatrixUseMatrixAKHR = 0, + CooperativeMatrixUseMatrixBKHR = 1, + CooperativeMatrixUseMatrixAccumulatorKHR = 2, + CooperativeMatrixUseMax = 0x7fffffff, +}; + +enum CooperativeMatrixReduceShift { + CooperativeMatrixReduceRowShift = 0, + CooperativeMatrixReduceColumnShift = 1, + CooperativeMatrixReduce2x2Shift = 2, + CooperativeMatrixReduceMax = 0x7fffffff, +}; + +enum CooperativeMatrixReduceMask { + CooperativeMatrixReduceMaskNone = 0, + CooperativeMatrixReduceRowMask = 0x00000001, + CooperativeMatrixReduceColumnMask = 0x00000002, + CooperativeMatrixReduce2x2Mask = 0x00000004, +}; + +enum TensorClampMode { + TensorClampModeUndefined = 0, + TensorClampModeConstant = 1, + TensorClampModeClampToEdge = 2, + TensorClampModeRepeat = 3, + TensorClampModeRepeatMirrored = 4, + TensorClampModeMax = 0x7fffffff, +}; + +enum TensorAddressingOperandsShift { + TensorAddressingOperandsTensorViewShift = 0, + TensorAddressingOperandsDecodeFuncShift = 1, + TensorAddressingOperandsMax = 0x7fffffff, +}; + +enum TensorAddressingOperandsMask { + TensorAddressingOperandsMaskNone = 0, + TensorAddressingOperandsTensorViewMask = 0x00000001, + TensorAddressingOperandsDecodeFuncMask = 0x00000002, +}; + +enum InitializationModeQualifier { + InitializationModeQualifierInitOnDeviceReprogramINTEL = 0, + InitializationModeQualifierInitOnDeviceResetINTEL = 1, + InitializationModeQualifierMax = 0x7fffffff, +}; + +enum HostAccessQualifier { + HostAccessQualifierNoneINTEL = 0, + HostAccessQualifierReadINTEL = 1, + HostAccessQualifierWriteINTEL = 2, + HostAccessQualifierReadWriteINTEL = 3, + HostAccessQualifierMax = 0x7fffffff, +}; + +enum LoadCacheControl { + LoadCacheControlUncachedINTEL = 0, + LoadCacheControlCachedINTEL = 1, + LoadCacheControlStreamingINTEL = 2, + LoadCacheControlInvalidateAfterReadINTEL = 3, + LoadCacheControlConstCachedINTEL = 4, + LoadCacheControlMax = 0x7fffffff, +}; + +enum StoreCacheControl { + StoreCacheControlUncachedINTEL = 0, + StoreCacheControlWriteThroughINTEL = 1, + StoreCacheControlWriteBackINTEL = 2, + StoreCacheControlStreamingINTEL = 3, + StoreCacheControlMax = 0x7fffffff, +}; + +enum NamedMaximumNumberOfRegisters { + NamedMaximumNumberOfRegistersAutoINTEL = 0, + NamedMaximumNumberOfRegistersMax = 0x7fffffff, +}; + +enum MatrixMultiplyAccumulateOperandsShift { + MatrixMultiplyAccumulateOperandsMatrixASignedComponentsINTELShift = 0, + MatrixMultiplyAccumulateOperandsMatrixBSignedComponentsINTELShift = 1, + MatrixMultiplyAccumulateOperandsMatrixCBFloat16INTELShift = 2, + MatrixMultiplyAccumulateOperandsMatrixResultBFloat16INTELShift = 3, + MatrixMultiplyAccumulateOperandsMatrixAPackedInt8INTELShift = 4, + MatrixMultiplyAccumulateOperandsMatrixBPackedInt8INTELShift = 5, + MatrixMultiplyAccumulateOperandsMatrixAPackedInt4INTELShift = 6, + MatrixMultiplyAccumulateOperandsMatrixBPackedInt4INTELShift = 7, + MatrixMultiplyAccumulateOperandsMatrixATF32INTELShift = 8, + MatrixMultiplyAccumulateOperandsMatrixBTF32INTELShift = 9, + MatrixMultiplyAccumulateOperandsMatrixAPackedFloat16INTELShift = 10, + MatrixMultiplyAccumulateOperandsMatrixBPackedFloat16INTELShift = 11, + MatrixMultiplyAccumulateOperandsMatrixAPackedBFloat16INTELShift = 12, + MatrixMultiplyAccumulateOperandsMatrixBPackedBFloat16INTELShift = 13, + MatrixMultiplyAccumulateOperandsMax = 0x7fffffff, +}; + +enum MatrixMultiplyAccumulateOperandsMask { + MatrixMultiplyAccumulateOperandsMaskNone = 0, + MatrixMultiplyAccumulateOperandsMatrixASignedComponentsINTELMask = 0x00000001, + MatrixMultiplyAccumulateOperandsMatrixBSignedComponentsINTELMask = 0x00000002, + MatrixMultiplyAccumulateOperandsMatrixCBFloat16INTELMask = 0x00000004, + MatrixMultiplyAccumulateOperandsMatrixResultBFloat16INTELMask = 0x00000008, + MatrixMultiplyAccumulateOperandsMatrixAPackedInt8INTELMask = 0x00000010, + MatrixMultiplyAccumulateOperandsMatrixBPackedInt8INTELMask = 0x00000020, + MatrixMultiplyAccumulateOperandsMatrixAPackedInt4INTELMask = 0x00000040, + MatrixMultiplyAccumulateOperandsMatrixBPackedInt4INTELMask = 0x00000080, + MatrixMultiplyAccumulateOperandsMatrixATF32INTELMask = 0x00000100, + MatrixMultiplyAccumulateOperandsMatrixBTF32INTELMask = 0x00000200, + MatrixMultiplyAccumulateOperandsMatrixAPackedFloat16INTELMask = 0x00000400, + MatrixMultiplyAccumulateOperandsMatrixBPackedFloat16INTELMask = 0x00000800, + MatrixMultiplyAccumulateOperandsMatrixAPackedBFloat16INTELMask = 0x00001000, + MatrixMultiplyAccumulateOperandsMatrixBPackedBFloat16INTELMask = 0x00002000, +}; + +enum RawAccessChainOperandsShift { + RawAccessChainOperandsRobustnessPerComponentNVShift = 0, + RawAccessChainOperandsRobustnessPerElementNVShift = 1, + RawAccessChainOperandsMax = 0x7fffffff, +}; + +enum RawAccessChainOperandsMask { + RawAccessChainOperandsMaskNone = 0, + RawAccessChainOperandsRobustnessPerComponentNVMask = 0x00000001, + RawAccessChainOperandsRobustnessPerElementNVMask = 0x00000002, +}; + +enum FPEncoding { + FPEncodingMax = 0x7fffffff, +}; + +enum CooperativeVectorMatrixLayout { + CooperativeVectorMatrixLayoutRowMajorNV = 0, + CooperativeVectorMatrixLayoutColumnMajorNV = 1, + CooperativeVectorMatrixLayoutInferencingOptimalNV = 2, + CooperativeVectorMatrixLayoutTrainingOptimalNV = 3, + CooperativeVectorMatrixLayoutMax = 0x7fffffff, +}; + +enum ComponentType { + ComponentTypeFloat16NV = 0, + ComponentTypeFloat32NV = 1, + ComponentTypeFloat64NV = 2, + ComponentTypeSignedInt8NV = 3, + ComponentTypeSignedInt16NV = 4, + ComponentTypeSignedInt32NV = 5, + ComponentTypeSignedInt64NV = 6, + ComponentTypeUnsignedInt8NV = 7, + ComponentTypeUnsignedInt16NV = 8, + ComponentTypeUnsignedInt32NV = 9, + ComponentTypeUnsignedInt64NV = 10, + ComponentTypeSignedInt8PackedNV = 1000491000, + ComponentTypeUnsignedInt8PackedNV = 1000491001, + ComponentTypeFloatE4M3NV = 1000491002, + ComponentTypeFloatE5M2NV = 1000491003, + ComponentTypeMax = 0x7fffffff, +}; + enum Op { OpNop = 0, OpUndef = 1, @@ -1585,14 +1907,26 @@ enum Op { OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1610,6 +1944,14 @@ enum Op { OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1617,6 +1959,14 @@ enum Op { OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1628,6 +1978,16 @@ enum Op { OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1662,10 +2022,20 @@ enum Op { OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1673,9 +2043,12 @@ enum Op { OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1683,9 +2056,26 @@ enum Op { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1693,6 +2083,20 @@ enum Op { OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1934,8 +2338,19 @@ enum Op { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1944,6 +2359,8 @@ enum Op { OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, OpMax = 0x7fffffff, }; @@ -2299,14 +2716,26 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpPtrEqual: *hasResult = true; *hasResultType = true; break; case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case OpPtrDiff: *hasResult = true; *hasResultType = true; break; + case OpColorAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case OpDepthAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case OpStencilAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case OpTerminateInvocation: *hasResult = false; *hasResultType = false; break; + case OpTypeUntypedPointerKHR: *hasResult = true; *hasResultType = false; break; + case OpUntypedVariableKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedInBoundsAccessChainKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedInBoundsPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedArrayLengthKHR: *hasResult = true; *hasResultType = true; break; + case OpUntypedPrefetchKHR: *hasResult = false; *hasResultType = false; break; case OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case OpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; + case OpExtInstWithForwardRefsKHR: *hasResult = true; *hasResultType = true; break; case OpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case OpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; @@ -2318,6 +2747,14 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpSDotAccSat: *hasResult = true; *hasResultType = true; break; case OpUDotAccSat: *hasResult = true; *hasResultType = true; break; case OpSUDotAccSat: *hasResult = true; *hasResultType = true; break; + case OpTypeCooperativeMatrixKHR: *hasResult = true; *hasResultType = false; break; + case OpCooperativeMatrixLoadKHR: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixStoreKHR: *hasResult = false; *hasResultType = false; break; + case OpCooperativeMatrixMulAddKHR: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixLengthKHR: *hasResult = true; *hasResultType = true; break; + case OpConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case OpSpecConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case OpCompositeConstructReplicateEXT: *hasResult = true; *hasResultType = true; break; case OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2325,6 +2762,14 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case OpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break; case OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; @@ -2336,6 +2781,16 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break; case OpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break; case OpReadClockKHR: *hasResult = true; *hasResultType = true; break; + case OpAllocateNodePayloadsAMDX: *hasResult = true; *hasResultType = true; break; + case OpEnqueueNodePayloadsAMDX: *hasResult = false; *hasResultType = false; break; + case OpTypeNodePayloadArrayAMDX: *hasResult = true; *hasResultType = false; break; + case OpFinishWritingNodePayloadAMDX: *hasResult = true; *hasResultType = true; break; + case OpNodePayloadArrayLengthAMDX: *hasResult = true; *hasResultType = true; break; + case OpIsNodePayloadValidAMDX: *hasResult = true; *hasResultType = true; break; + case OpConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case OpSpecConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case OpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break; + case OpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break; case OpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break; case OpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break; case OpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break; @@ -2370,18 +2825,31 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpReorderThreadWithHintNV: *hasResult = false; *hasResultType = false; break; case OpTypeHitObjectNV: *hasResult = true; *hasResultType = false; break; case OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; + case OpTypeCooperativeVectorNV: *hasResult = true; *hasResultType = false; break; + case OpCooperativeVectorMatrixMulNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeVectorOuterProductAccumulateNV: *hasResult = false; *hasResultType = false; break; + case OpCooperativeVectorReduceSumAccumulateNV: *hasResult = false; *hasResultType = false; break; + case OpCooperativeVectorMatrixMulAddNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixConvertNV: *hasResult = true; *hasResultType = true; break; case OpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break; case OpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break; case OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; case OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; - case OpReportIntersectionNV: *hasResult = true; *hasResultType = true; break; + case OpFetchMicroTriangleVertexPositionNV: *hasResult = true; *hasResultType = true; break; + case OpFetchMicroTriangleVertexBarycentricNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeVectorLoadNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeVectorStoreNV: *hasResult = false; *hasResultType = false; break; + case OpReportIntersectionKHR: *hasResult = true; *hasResultType = true; break; case OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; case OpTerminateRayNV: *hasResult = false; *hasResultType = false; break; case OpTraceNV: *hasResult = false; *hasResultType = false; break; case OpTraceMotionNV: *hasResult = false; *hasResultType = false; break; case OpTraceRayMotionNV: *hasResult = false; *hasResultType = false; break; - case OpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break; + case OpRayQueryGetIntersectionTriangleVertexPositionsKHR: *hasResult = true; *hasResultType = true; break; + case OpTypeAccelerationStructureKHR: *hasResult = true; *hasResultType = false; break; case OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; + case OpRayQueryGetClusterIdNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetClusterIdNV: *hasResult = true; *hasResultType = true; break; case OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; @@ -2389,8 +2857,25 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; + case OpCooperativeMatrixReduceNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixLoadTensorNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixStoreTensorNV: *hasResult = false; *hasResultType = false; break; + case OpCooperativeMatrixPerElementOpNV: *hasResult = true; *hasResultType = true; break; + case OpTypeTensorLayoutNV: *hasResult = true; *hasResultType = false; break; + case OpTypeTensorViewNV: *hasResult = true; *hasResultType = false; break; + case OpCreateTensorLayoutNV: *hasResult = true; *hasResultType = true; break; + case OpTensorLayoutSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case OpTensorLayoutSetStrideNV: *hasResult = true; *hasResultType = true; break; + case OpTensorLayoutSliceNV: *hasResult = true; *hasResultType = true; break; + case OpTensorLayoutSetClampValueNV: *hasResult = true; *hasResultType = true; break; + case OpCreateTensorViewNV: *hasResult = true; *hasResultType = true; break; + case OpTensorViewSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case OpTensorViewSetStrideNV: *hasResult = true; *hasResultType = true; break; case OpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; + case OpTensorViewSetClipNV: *hasResult = true; *hasResultType = true; break; + case OpTensorLayoutSetBlockSizeNV: *hasResult = true; *hasResultType = true; break; + case OpCooperativeMatrixTransposeNV: *hasResult = true; *hasResultType = true; break; case OpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case OpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; case OpConvertImageToUNV: *hasResult = true; *hasResultType = true; break; @@ -2398,6 +2883,20 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpConvertUToSampledImageNV: *hasResult = true; *hasResultType = true; break; case OpConvertSampledImageToUNV: *hasResult = true; *hasResultType = true; break; case OpSamplerImageAddressingModeNV: *hasResult = false; *hasResultType = false; break; + case OpRawAccessChainNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryGetIntersectionSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryGetIntersectionSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryGetIntersectionLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryGetIntersectionLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryGetIntersectionLSSHitValueNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectIsLSSHitNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case OpRayQueryIsLSSHitNV: *hasResult = true; *hasResultType = true; break; case OpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break; case OpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break; case OpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break; @@ -2424,7 +2923,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; case OpConstantFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; case OpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; - case OpAsmTargetINTEL: *hasResult = true; *hasResultType = true; break; + case OpAsmTargetINTEL: *hasResult = true; *hasResultType = false; break; case OpAsmINTEL: *hasResult = true; *hasResultType = true; break; case OpAsmCallINTEL: *hasResult = true; *hasResultType = true; break; case OpAtomicFMinEXT: *hasResult = true; *hasResultType = true; break; @@ -2637,8 +3136,19 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case OpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case OpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case OpCompositeConstructContinuedINTEL: *hasResult = true; *hasResultType = true; break; + case OpConvertFToBF16INTEL: *hasResult = true; *hasResultType = true; break; + case OpConvertBF16ToFINTEL: *hasResult = true; *hasResultType = true; break; case OpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; case OpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case OpArithmeticFenceEXT: *hasResult = true; *hasResultType = true; break; + case OpSubgroupBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroup2DBlockLoadINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroup2DBlockLoadTransformINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroup2DBlockLoadTransposeINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroup2DBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroup2DBlockStoreINTEL: *hasResult = false; *hasResultType = false; break; + case OpSubgroupMatrixMultiplyAccumulateINTEL: *hasResult = true; *hasResultType = true; break; case OpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; case OpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; case OpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; @@ -2647,8 +3157,1932 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; case OpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; case OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; + case OpMaskedGatherINTEL: *hasResult = true; *hasResultType = true; break; + case OpMaskedScatterINTEL: *hasResult = false; *hasResultType = false; break; } } +inline const char* SourceLanguageToString(SourceLanguage value) { + switch (value) { + case SourceLanguageUnknown: return "Unknown"; + case SourceLanguageESSL: return "ESSL"; + case SourceLanguageGLSL: return "GLSL"; + case SourceLanguageOpenCL_C: return "OpenCL_C"; + case SourceLanguageOpenCL_CPP: return "OpenCL_CPP"; + case SourceLanguageHLSL: return "HLSL"; + case SourceLanguageCPP_for_OpenCL: return "CPP_for_OpenCL"; + case SourceLanguageSYCL: return "SYCL"; + case SourceLanguageHERO_C: return "HERO_C"; + case SourceLanguageNZSL: return "NZSL"; + case SourceLanguageWGSL: return "WGSL"; + case SourceLanguageSlang: return "Slang"; + case SourceLanguageZig: return "Zig"; + case SourceLanguageRust: return "Rust"; + default: return "Unknown"; + } +} + +inline const char* ExecutionModelToString(ExecutionModel value) { + switch (value) { + case ExecutionModelVertex: return "Vertex"; + case ExecutionModelTessellationControl: return "TessellationControl"; + case ExecutionModelTessellationEvaluation: return "TessellationEvaluation"; + case ExecutionModelGeometry: return "Geometry"; + case ExecutionModelFragment: return "Fragment"; + case ExecutionModelGLCompute: return "GLCompute"; + case ExecutionModelKernel: return "Kernel"; + case ExecutionModelTaskNV: return "TaskNV"; + case ExecutionModelMeshNV: return "MeshNV"; + case ExecutionModelRayGenerationKHR: return "RayGenerationKHR"; + case ExecutionModelIntersectionKHR: return "IntersectionKHR"; + case ExecutionModelAnyHitKHR: return "AnyHitKHR"; + case ExecutionModelClosestHitKHR: return "ClosestHitKHR"; + case ExecutionModelMissKHR: return "MissKHR"; + case ExecutionModelCallableKHR: return "CallableKHR"; + case ExecutionModelTaskEXT: return "TaskEXT"; + case ExecutionModelMeshEXT: return "MeshEXT"; + default: return "Unknown"; + } +} + +inline const char* AddressingModelToString(AddressingModel value) { + switch (value) { + case AddressingModelLogical: return "Logical"; + case AddressingModelPhysical32: return "Physical32"; + case AddressingModelPhysical64: return "Physical64"; + case AddressingModelPhysicalStorageBuffer64: return "PhysicalStorageBuffer64"; + default: return "Unknown"; + } +} + +inline const char* MemoryModelToString(MemoryModel value) { + switch (value) { + case MemoryModelSimple: return "Simple"; + case MemoryModelGLSL450: return "GLSL450"; + case MemoryModelOpenCL: return "OpenCL"; + case MemoryModelVulkan: return "Vulkan"; + default: return "Unknown"; + } +} + +inline const char* ExecutionModeToString(ExecutionMode value) { + switch (value) { + case ExecutionModeInvocations: return "Invocations"; + case ExecutionModeSpacingEqual: return "SpacingEqual"; + case ExecutionModeSpacingFractionalEven: return "SpacingFractionalEven"; + case ExecutionModeSpacingFractionalOdd: return "SpacingFractionalOdd"; + case ExecutionModeVertexOrderCw: return "VertexOrderCw"; + case ExecutionModeVertexOrderCcw: return "VertexOrderCcw"; + case ExecutionModePixelCenterInteger: return "PixelCenterInteger"; + case ExecutionModeOriginUpperLeft: return "OriginUpperLeft"; + case ExecutionModeOriginLowerLeft: return "OriginLowerLeft"; + case ExecutionModeEarlyFragmentTests: return "EarlyFragmentTests"; + case ExecutionModePointMode: return "PointMode"; + case ExecutionModeXfb: return "Xfb"; + case ExecutionModeDepthReplacing: return "DepthReplacing"; + case ExecutionModeDepthGreater: return "DepthGreater"; + case ExecutionModeDepthLess: return "DepthLess"; + case ExecutionModeDepthUnchanged: return "DepthUnchanged"; + case ExecutionModeLocalSize: return "LocalSize"; + case ExecutionModeLocalSizeHint: return "LocalSizeHint"; + case ExecutionModeInputPoints: return "InputPoints"; + case ExecutionModeInputLines: return "InputLines"; + case ExecutionModeInputLinesAdjacency: return "InputLinesAdjacency"; + case ExecutionModeTriangles: return "Triangles"; + case ExecutionModeInputTrianglesAdjacency: return "InputTrianglesAdjacency"; + case ExecutionModeQuads: return "Quads"; + case ExecutionModeIsolines: return "Isolines"; + case ExecutionModeOutputVertices: return "OutputVertices"; + case ExecutionModeOutputPoints: return "OutputPoints"; + case ExecutionModeOutputLineStrip: return "OutputLineStrip"; + case ExecutionModeOutputTriangleStrip: return "OutputTriangleStrip"; + case ExecutionModeVecTypeHint: return "VecTypeHint"; + case ExecutionModeContractionOff: return "ContractionOff"; + case ExecutionModeInitializer: return "Initializer"; + case ExecutionModeFinalizer: return "Finalizer"; + case ExecutionModeSubgroupSize: return "SubgroupSize"; + case ExecutionModeSubgroupsPerWorkgroup: return "SubgroupsPerWorkgroup"; + case ExecutionModeSubgroupsPerWorkgroupId: return "SubgroupsPerWorkgroupId"; + case ExecutionModeLocalSizeId: return "LocalSizeId"; + case ExecutionModeLocalSizeHintId: return "LocalSizeHintId"; + case ExecutionModeNonCoherentColorAttachmentReadEXT: return "NonCoherentColorAttachmentReadEXT"; + case ExecutionModeNonCoherentDepthAttachmentReadEXT: return "NonCoherentDepthAttachmentReadEXT"; + case ExecutionModeNonCoherentStencilAttachmentReadEXT: return "NonCoherentStencilAttachmentReadEXT"; + case ExecutionModeSubgroupUniformControlFlowKHR: return "SubgroupUniformControlFlowKHR"; + case ExecutionModePostDepthCoverage: return "PostDepthCoverage"; + case ExecutionModeDenormPreserve: return "DenormPreserve"; + case ExecutionModeDenormFlushToZero: return "DenormFlushToZero"; + case ExecutionModeSignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case ExecutionModeRoundingModeRTE: return "RoundingModeRTE"; + case ExecutionModeRoundingModeRTZ: return "RoundingModeRTZ"; + case ExecutionModeEarlyAndLateFragmentTestsAMD: return "EarlyAndLateFragmentTestsAMD"; + case ExecutionModeStencilRefReplacingEXT: return "StencilRefReplacingEXT"; + case ExecutionModeCoalescingAMDX: return "CoalescingAMDX"; + case ExecutionModeIsApiEntryAMDX: return "IsApiEntryAMDX"; + case ExecutionModeMaxNodeRecursionAMDX: return "MaxNodeRecursionAMDX"; + case ExecutionModeStaticNumWorkgroupsAMDX: return "StaticNumWorkgroupsAMDX"; + case ExecutionModeShaderIndexAMDX: return "ShaderIndexAMDX"; + case ExecutionModeMaxNumWorkgroupsAMDX: return "MaxNumWorkgroupsAMDX"; + case ExecutionModeStencilRefUnchangedFrontAMD: return "StencilRefUnchangedFrontAMD"; + case ExecutionModeStencilRefGreaterFrontAMD: return "StencilRefGreaterFrontAMD"; + case ExecutionModeStencilRefLessFrontAMD: return "StencilRefLessFrontAMD"; + case ExecutionModeStencilRefUnchangedBackAMD: return "StencilRefUnchangedBackAMD"; + case ExecutionModeStencilRefGreaterBackAMD: return "StencilRefGreaterBackAMD"; + case ExecutionModeStencilRefLessBackAMD: return "StencilRefLessBackAMD"; + case ExecutionModeQuadDerivativesKHR: return "QuadDerivativesKHR"; + case ExecutionModeRequireFullQuadsKHR: return "RequireFullQuadsKHR"; + case ExecutionModeSharesInputWithAMDX: return "SharesInputWithAMDX"; + case ExecutionModeOutputLinesEXT: return "OutputLinesEXT"; + case ExecutionModeOutputPrimitivesEXT: return "OutputPrimitivesEXT"; + case ExecutionModeDerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR"; + case ExecutionModeDerivativeGroupLinearKHR: return "DerivativeGroupLinearKHR"; + case ExecutionModeOutputTrianglesEXT: return "OutputTrianglesEXT"; + case ExecutionModePixelInterlockOrderedEXT: return "PixelInterlockOrderedEXT"; + case ExecutionModePixelInterlockUnorderedEXT: return "PixelInterlockUnorderedEXT"; + case ExecutionModeSampleInterlockOrderedEXT: return "SampleInterlockOrderedEXT"; + case ExecutionModeSampleInterlockUnorderedEXT: return "SampleInterlockUnorderedEXT"; + case ExecutionModeShadingRateInterlockOrderedEXT: return "ShadingRateInterlockOrderedEXT"; + case ExecutionModeShadingRateInterlockUnorderedEXT: return "ShadingRateInterlockUnorderedEXT"; + case ExecutionModeSharedLocalMemorySizeINTEL: return "SharedLocalMemorySizeINTEL"; + case ExecutionModeRoundingModeRTPINTEL: return "RoundingModeRTPINTEL"; + case ExecutionModeRoundingModeRTNINTEL: return "RoundingModeRTNINTEL"; + case ExecutionModeFloatingPointModeALTINTEL: return "FloatingPointModeALTINTEL"; + case ExecutionModeFloatingPointModeIEEEINTEL: return "FloatingPointModeIEEEINTEL"; + case ExecutionModeMaxWorkgroupSizeINTEL: return "MaxWorkgroupSizeINTEL"; + case ExecutionModeMaxWorkDimINTEL: return "MaxWorkDimINTEL"; + case ExecutionModeNoGlobalOffsetINTEL: return "NoGlobalOffsetINTEL"; + case ExecutionModeNumSIMDWorkitemsINTEL: return "NumSIMDWorkitemsINTEL"; + case ExecutionModeSchedulerTargetFmaxMhzINTEL: return "SchedulerTargetFmaxMhzINTEL"; + case ExecutionModeMaximallyReconvergesKHR: return "MaximallyReconvergesKHR"; + case ExecutionModeFPFastMathDefault: return "FPFastMathDefault"; + case ExecutionModeStreamingInterfaceINTEL: return "StreamingInterfaceINTEL"; + case ExecutionModeRegisterMapInterfaceINTEL: return "RegisterMapInterfaceINTEL"; + case ExecutionModeNamedBarrierCountINTEL: return "NamedBarrierCountINTEL"; + case ExecutionModeMaximumRegistersINTEL: return "MaximumRegistersINTEL"; + case ExecutionModeMaximumRegistersIdINTEL: return "MaximumRegistersIdINTEL"; + case ExecutionModeNamedMaximumRegistersINTEL: return "NamedMaximumRegistersINTEL"; + default: return "Unknown"; + } +} + +inline const char* StorageClassToString(StorageClass value) { + switch (value) { + case StorageClassUniformConstant: return "UniformConstant"; + case StorageClassInput: return "Input"; + case StorageClassUniform: return "Uniform"; + case StorageClassOutput: return "Output"; + case StorageClassWorkgroup: return "Workgroup"; + case StorageClassCrossWorkgroup: return "CrossWorkgroup"; + case StorageClassPrivate: return "Private"; + case StorageClassFunction: return "Function"; + case StorageClassGeneric: return "Generic"; + case StorageClassPushConstant: return "PushConstant"; + case StorageClassAtomicCounter: return "AtomicCounter"; + case StorageClassImage: return "Image"; + case StorageClassStorageBuffer: return "StorageBuffer"; + case StorageClassTileImageEXT: return "TileImageEXT"; + case StorageClassNodePayloadAMDX: return "NodePayloadAMDX"; + case StorageClassCallableDataKHR: return "CallableDataKHR"; + case StorageClassIncomingCallableDataKHR: return "IncomingCallableDataKHR"; + case StorageClassRayPayloadKHR: return "RayPayloadKHR"; + case StorageClassHitAttributeKHR: return "HitAttributeKHR"; + case StorageClassIncomingRayPayloadKHR: return "IncomingRayPayloadKHR"; + case StorageClassShaderRecordBufferKHR: return "ShaderRecordBufferKHR"; + case StorageClassPhysicalStorageBuffer: return "PhysicalStorageBuffer"; + case StorageClassHitObjectAttributeNV: return "HitObjectAttributeNV"; + case StorageClassTaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT"; + case StorageClassCodeSectionINTEL: return "CodeSectionINTEL"; + case StorageClassDeviceOnlyINTEL: return "DeviceOnlyINTEL"; + case StorageClassHostOnlyINTEL: return "HostOnlyINTEL"; + default: return "Unknown"; + } +} + +inline const char* DimToString(Dim value) { + switch (value) { + case Dim1D: return "1D"; + case Dim2D: return "2D"; + case Dim3D: return "3D"; + case DimCube: return "Cube"; + case DimRect: return "Rect"; + case DimBuffer: return "Buffer"; + case DimSubpassData: return "SubpassData"; + case DimTileImageDataEXT: return "TileImageDataEXT"; + default: return "Unknown"; + } +} + +inline const char* SamplerAddressingModeToString(SamplerAddressingMode value) { + switch (value) { + case SamplerAddressingModeNone: return "None"; + case SamplerAddressingModeClampToEdge: return "ClampToEdge"; + case SamplerAddressingModeClamp: return "Clamp"; + case SamplerAddressingModeRepeat: return "Repeat"; + case SamplerAddressingModeRepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* SamplerFilterModeToString(SamplerFilterMode value) { + switch (value) { + case SamplerFilterModeNearest: return "Nearest"; + case SamplerFilterModeLinear: return "Linear"; + default: return "Unknown"; + } +} + +inline const char* ImageFormatToString(ImageFormat value) { + switch (value) { + case ImageFormatUnknown: return "Unknown"; + case ImageFormatRgba32f: return "Rgba32f"; + case ImageFormatRgba16f: return "Rgba16f"; + case ImageFormatR32f: return "R32f"; + case ImageFormatRgba8: return "Rgba8"; + case ImageFormatRgba8Snorm: return "Rgba8Snorm"; + case ImageFormatRg32f: return "Rg32f"; + case ImageFormatRg16f: return "Rg16f"; + case ImageFormatR11fG11fB10f: return "R11fG11fB10f"; + case ImageFormatR16f: return "R16f"; + case ImageFormatRgba16: return "Rgba16"; + case ImageFormatRgb10A2: return "Rgb10A2"; + case ImageFormatRg16: return "Rg16"; + case ImageFormatRg8: return "Rg8"; + case ImageFormatR16: return "R16"; + case ImageFormatR8: return "R8"; + case ImageFormatRgba16Snorm: return "Rgba16Snorm"; + case ImageFormatRg16Snorm: return "Rg16Snorm"; + case ImageFormatRg8Snorm: return "Rg8Snorm"; + case ImageFormatR16Snorm: return "R16Snorm"; + case ImageFormatR8Snorm: return "R8Snorm"; + case ImageFormatRgba32i: return "Rgba32i"; + case ImageFormatRgba16i: return "Rgba16i"; + case ImageFormatRgba8i: return "Rgba8i"; + case ImageFormatR32i: return "R32i"; + case ImageFormatRg32i: return "Rg32i"; + case ImageFormatRg16i: return "Rg16i"; + case ImageFormatRg8i: return "Rg8i"; + case ImageFormatR16i: return "R16i"; + case ImageFormatR8i: return "R8i"; + case ImageFormatRgba32ui: return "Rgba32ui"; + case ImageFormatRgba16ui: return "Rgba16ui"; + case ImageFormatRgba8ui: return "Rgba8ui"; + case ImageFormatR32ui: return "R32ui"; + case ImageFormatRgb10a2ui: return "Rgb10a2ui"; + case ImageFormatRg32ui: return "Rg32ui"; + case ImageFormatRg16ui: return "Rg16ui"; + case ImageFormatRg8ui: return "Rg8ui"; + case ImageFormatR16ui: return "R16ui"; + case ImageFormatR8ui: return "R8ui"; + case ImageFormatR64ui: return "R64ui"; + case ImageFormatR64i: return "R64i"; + default: return "Unknown"; + } +} + +inline const char* ImageChannelOrderToString(ImageChannelOrder value) { + switch (value) { + case ImageChannelOrderR: return "R"; + case ImageChannelOrderA: return "A"; + case ImageChannelOrderRG: return "RG"; + case ImageChannelOrderRA: return "RA"; + case ImageChannelOrderRGB: return "RGB"; + case ImageChannelOrderRGBA: return "RGBA"; + case ImageChannelOrderBGRA: return "BGRA"; + case ImageChannelOrderARGB: return "ARGB"; + case ImageChannelOrderIntensity: return "Intensity"; + case ImageChannelOrderLuminance: return "Luminance"; + case ImageChannelOrderRx: return "Rx"; + case ImageChannelOrderRGx: return "RGx"; + case ImageChannelOrderRGBx: return "RGBx"; + case ImageChannelOrderDepth: return "Depth"; + case ImageChannelOrderDepthStencil: return "DepthStencil"; + case ImageChannelOrdersRGB: return "sRGB"; + case ImageChannelOrdersRGBx: return "sRGBx"; + case ImageChannelOrdersRGBA: return "sRGBA"; + case ImageChannelOrdersBGRA: return "sBGRA"; + case ImageChannelOrderABGR: return "ABGR"; + default: return "Unknown"; + } +} + +inline const char* ImageChannelDataTypeToString(ImageChannelDataType value) { + switch (value) { + case ImageChannelDataTypeSnormInt8: return "SnormInt8"; + case ImageChannelDataTypeSnormInt16: return "SnormInt16"; + case ImageChannelDataTypeUnormInt8: return "UnormInt8"; + case ImageChannelDataTypeUnormInt16: return "UnormInt16"; + case ImageChannelDataTypeUnormShort565: return "UnormShort565"; + case ImageChannelDataTypeUnormShort555: return "UnormShort555"; + case ImageChannelDataTypeUnormInt101010: return "UnormInt101010"; + case ImageChannelDataTypeSignedInt8: return "SignedInt8"; + case ImageChannelDataTypeSignedInt16: return "SignedInt16"; + case ImageChannelDataTypeSignedInt32: return "SignedInt32"; + case ImageChannelDataTypeUnsignedInt8: return "UnsignedInt8"; + case ImageChannelDataTypeUnsignedInt16: return "UnsignedInt16"; + case ImageChannelDataTypeUnsignedInt32: return "UnsignedInt32"; + case ImageChannelDataTypeHalfFloat: return "HalfFloat"; + case ImageChannelDataTypeFloat: return "Float"; + case ImageChannelDataTypeUnormInt24: return "UnormInt24"; + case ImageChannelDataTypeUnormInt101010_2: return "UnormInt101010_2"; + case ImageChannelDataTypeUnsignedIntRaw10EXT: return "UnsignedIntRaw10EXT"; + case ImageChannelDataTypeUnsignedIntRaw12EXT: return "UnsignedIntRaw12EXT"; + case ImageChannelDataTypeUnormInt2_101010EXT: return "UnormInt2_101010EXT"; + default: return "Unknown"; + } +} + +inline const char* FPRoundingModeToString(FPRoundingMode value) { + switch (value) { + case FPRoundingModeRTE: return "RTE"; + case FPRoundingModeRTZ: return "RTZ"; + case FPRoundingModeRTP: return "RTP"; + case FPRoundingModeRTN: return "RTN"; + default: return "Unknown"; + } +} + +inline const char* LinkageTypeToString(LinkageType value) { + switch (value) { + case LinkageTypeExport: return "Export"; + case LinkageTypeImport: return "Import"; + case LinkageTypeLinkOnceODR: return "LinkOnceODR"; + default: return "Unknown"; + } +} + +inline const char* AccessQualifierToString(AccessQualifier value) { + switch (value) { + case AccessQualifierReadOnly: return "ReadOnly"; + case AccessQualifierWriteOnly: return "WriteOnly"; + case AccessQualifierReadWrite: return "ReadWrite"; + default: return "Unknown"; + } +} + +inline const char* FunctionParameterAttributeToString(FunctionParameterAttribute value) { + switch (value) { + case FunctionParameterAttributeZext: return "Zext"; + case FunctionParameterAttributeSext: return "Sext"; + case FunctionParameterAttributeByVal: return "ByVal"; + case FunctionParameterAttributeSret: return "Sret"; + case FunctionParameterAttributeNoAlias: return "NoAlias"; + case FunctionParameterAttributeNoCapture: return "NoCapture"; + case FunctionParameterAttributeNoWrite: return "NoWrite"; + case FunctionParameterAttributeNoReadWrite: return "NoReadWrite"; + case FunctionParameterAttributeRuntimeAlignedINTEL: return "RuntimeAlignedINTEL"; + default: return "Unknown"; + } +} + +inline const char* DecorationToString(Decoration value) { + switch (value) { + case DecorationRelaxedPrecision: return "RelaxedPrecision"; + case DecorationSpecId: return "SpecId"; + case DecorationBlock: return "Block"; + case DecorationBufferBlock: return "BufferBlock"; + case DecorationRowMajor: return "RowMajor"; + case DecorationColMajor: return "ColMajor"; + case DecorationArrayStride: return "ArrayStride"; + case DecorationMatrixStride: return "MatrixStride"; + case DecorationGLSLShared: return "GLSLShared"; + case DecorationGLSLPacked: return "GLSLPacked"; + case DecorationCPacked: return "CPacked"; + case DecorationBuiltIn: return "BuiltIn"; + case DecorationNoPerspective: return "NoPerspective"; + case DecorationFlat: return "Flat"; + case DecorationPatch: return "Patch"; + case DecorationCentroid: return "Centroid"; + case DecorationSample: return "Sample"; + case DecorationInvariant: return "Invariant"; + case DecorationRestrict: return "Restrict"; + case DecorationAliased: return "Aliased"; + case DecorationVolatile: return "Volatile"; + case DecorationConstant: return "Constant"; + case DecorationCoherent: return "Coherent"; + case DecorationNonWritable: return "NonWritable"; + case DecorationNonReadable: return "NonReadable"; + case DecorationUniform: return "Uniform"; + case DecorationUniformId: return "UniformId"; + case DecorationSaturatedConversion: return "SaturatedConversion"; + case DecorationStream: return "Stream"; + case DecorationLocation: return "Location"; + case DecorationComponent: return "Component"; + case DecorationIndex: return "Index"; + case DecorationBinding: return "Binding"; + case DecorationDescriptorSet: return "DescriptorSet"; + case DecorationOffset: return "Offset"; + case DecorationXfbBuffer: return "XfbBuffer"; + case DecorationXfbStride: return "XfbStride"; + case DecorationFuncParamAttr: return "FuncParamAttr"; + case DecorationFPRoundingMode: return "FPRoundingMode"; + case DecorationFPFastMathMode: return "FPFastMathMode"; + case DecorationLinkageAttributes: return "LinkageAttributes"; + case DecorationNoContraction: return "NoContraction"; + case DecorationInputAttachmentIndex: return "InputAttachmentIndex"; + case DecorationAlignment: return "Alignment"; + case DecorationMaxByteOffset: return "MaxByteOffset"; + case DecorationAlignmentId: return "AlignmentId"; + case DecorationMaxByteOffsetId: return "MaxByteOffsetId"; + case DecorationNoSignedWrap: return "NoSignedWrap"; + case DecorationNoUnsignedWrap: return "NoUnsignedWrap"; + case DecorationWeightTextureQCOM: return "WeightTextureQCOM"; + case DecorationBlockMatchTextureQCOM: return "BlockMatchTextureQCOM"; + case DecorationBlockMatchSamplerQCOM: return "BlockMatchSamplerQCOM"; + case DecorationExplicitInterpAMD: return "ExplicitInterpAMD"; + case DecorationNodeSharesPayloadLimitsWithAMDX: return "NodeSharesPayloadLimitsWithAMDX"; + case DecorationNodeMaxPayloadsAMDX: return "NodeMaxPayloadsAMDX"; + case DecorationTrackFinishWritingAMDX: return "TrackFinishWritingAMDX"; + case DecorationPayloadNodeNameAMDX: return "PayloadNodeNameAMDX"; + case DecorationPayloadNodeBaseIndexAMDX: return "PayloadNodeBaseIndexAMDX"; + case DecorationPayloadNodeSparseArrayAMDX: return "PayloadNodeSparseArrayAMDX"; + case DecorationPayloadNodeArraySizeAMDX: return "PayloadNodeArraySizeAMDX"; + case DecorationPayloadDispatchIndirectAMDX: return "PayloadDispatchIndirectAMDX"; + case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; + case DecorationPassthroughNV: return "PassthroughNV"; + case DecorationViewportRelativeNV: return "ViewportRelativeNV"; + case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV"; + case DecorationPerPrimitiveEXT: return "PerPrimitiveEXT"; + case DecorationPerViewNV: return "PerViewNV"; + case DecorationPerTaskNV: return "PerTaskNV"; + case DecorationPerVertexKHR: return "PerVertexKHR"; + case DecorationNonUniform: return "NonUniform"; + case DecorationRestrictPointer: return "RestrictPointer"; + case DecorationAliasedPointer: return "AliasedPointer"; + case DecorationHitObjectShaderRecordBufferNV: return "HitObjectShaderRecordBufferNV"; + case DecorationBindlessSamplerNV: return "BindlessSamplerNV"; + case DecorationBindlessImageNV: return "BindlessImageNV"; + case DecorationBoundSamplerNV: return "BoundSamplerNV"; + case DecorationBoundImageNV: return "BoundImageNV"; + case DecorationSIMTCallINTEL: return "SIMTCallINTEL"; + case DecorationReferencedIndirectlyINTEL: return "ReferencedIndirectlyINTEL"; + case DecorationClobberINTEL: return "ClobberINTEL"; + case DecorationSideEffectsINTEL: return "SideEffectsINTEL"; + case DecorationVectorComputeVariableINTEL: return "VectorComputeVariableINTEL"; + case DecorationFuncParamIOKindINTEL: return "FuncParamIOKindINTEL"; + case DecorationVectorComputeFunctionINTEL: return "VectorComputeFunctionINTEL"; + case DecorationStackCallINTEL: return "StackCallINTEL"; + case DecorationGlobalVariableOffsetINTEL: return "GlobalVariableOffsetINTEL"; + case DecorationCounterBuffer: return "CounterBuffer"; + case DecorationHlslSemanticGOOGLE: return "HlslSemanticGOOGLE"; + case DecorationUserTypeGOOGLE: return "UserTypeGOOGLE"; + case DecorationFunctionRoundingModeINTEL: return "FunctionRoundingModeINTEL"; + case DecorationFunctionDenormModeINTEL: return "FunctionDenormModeINTEL"; + case DecorationRegisterINTEL: return "RegisterINTEL"; + case DecorationMemoryINTEL: return "MemoryINTEL"; + case DecorationNumbanksINTEL: return "NumbanksINTEL"; + case DecorationBankwidthINTEL: return "BankwidthINTEL"; + case DecorationMaxPrivateCopiesINTEL: return "MaxPrivateCopiesINTEL"; + case DecorationSinglepumpINTEL: return "SinglepumpINTEL"; + case DecorationDoublepumpINTEL: return "DoublepumpINTEL"; + case DecorationMaxReplicatesINTEL: return "MaxReplicatesINTEL"; + case DecorationSimpleDualPortINTEL: return "SimpleDualPortINTEL"; + case DecorationMergeINTEL: return "MergeINTEL"; + case DecorationBankBitsINTEL: return "BankBitsINTEL"; + case DecorationForcePow2DepthINTEL: return "ForcePow2DepthINTEL"; + case DecorationStridesizeINTEL: return "StridesizeINTEL"; + case DecorationWordsizeINTEL: return "WordsizeINTEL"; + case DecorationTrueDualPortINTEL: return "TrueDualPortINTEL"; + case DecorationBurstCoalesceINTEL: return "BurstCoalesceINTEL"; + case DecorationCacheSizeINTEL: return "CacheSizeINTEL"; + case DecorationDontStaticallyCoalesceINTEL: return "DontStaticallyCoalesceINTEL"; + case DecorationPrefetchINTEL: return "PrefetchINTEL"; + case DecorationStallEnableINTEL: return "StallEnableINTEL"; + case DecorationFuseLoopsInFunctionINTEL: return "FuseLoopsInFunctionINTEL"; + case DecorationMathOpDSPModeINTEL: return "MathOpDSPModeINTEL"; + case DecorationAliasScopeINTEL: return "AliasScopeINTEL"; + case DecorationNoAliasINTEL: return "NoAliasINTEL"; + case DecorationInitiationIntervalINTEL: return "InitiationIntervalINTEL"; + case DecorationMaxConcurrencyINTEL: return "MaxConcurrencyINTEL"; + case DecorationPipelineEnableINTEL: return "PipelineEnableINTEL"; + case DecorationBufferLocationINTEL: return "BufferLocationINTEL"; + case DecorationIOPipeStorageINTEL: return "IOPipeStorageINTEL"; + case DecorationFunctionFloatingPointModeINTEL: return "FunctionFloatingPointModeINTEL"; + case DecorationSingleElementVectorINTEL: return "SingleElementVectorINTEL"; + case DecorationVectorComputeCallableFunctionINTEL: return "VectorComputeCallableFunctionINTEL"; + case DecorationMediaBlockIOINTEL: return "MediaBlockIOINTEL"; + case DecorationStallFreeINTEL: return "StallFreeINTEL"; + case DecorationFPMaxErrorDecorationINTEL: return "FPMaxErrorDecorationINTEL"; + case DecorationLatencyControlLabelINTEL: return "LatencyControlLabelINTEL"; + case DecorationLatencyControlConstraintINTEL: return "LatencyControlConstraintINTEL"; + case DecorationConduitKernelArgumentINTEL: return "ConduitKernelArgumentINTEL"; + case DecorationRegisterMapKernelArgumentINTEL: return "RegisterMapKernelArgumentINTEL"; + case DecorationMMHostInterfaceAddressWidthINTEL: return "MMHostInterfaceAddressWidthINTEL"; + case DecorationMMHostInterfaceDataWidthINTEL: return "MMHostInterfaceDataWidthINTEL"; + case DecorationMMHostInterfaceLatencyINTEL: return "MMHostInterfaceLatencyINTEL"; + case DecorationMMHostInterfaceReadWriteModeINTEL: return "MMHostInterfaceReadWriteModeINTEL"; + case DecorationMMHostInterfaceMaxBurstINTEL: return "MMHostInterfaceMaxBurstINTEL"; + case DecorationMMHostInterfaceWaitRequestINTEL: return "MMHostInterfaceWaitRequestINTEL"; + case DecorationStableKernelArgumentINTEL: return "StableKernelArgumentINTEL"; + case DecorationHostAccessINTEL: return "HostAccessINTEL"; + case DecorationInitModeINTEL: return "InitModeINTEL"; + case DecorationImplementInRegisterMapINTEL: return "ImplementInRegisterMapINTEL"; + case DecorationCacheControlLoadINTEL: return "CacheControlLoadINTEL"; + case DecorationCacheControlStoreINTEL: return "CacheControlStoreINTEL"; + default: return "Unknown"; + } +} + +inline const char* BuiltInToString(BuiltIn value) { + switch (value) { + case BuiltInPosition: return "Position"; + case BuiltInPointSize: return "PointSize"; + case BuiltInClipDistance: return "ClipDistance"; + case BuiltInCullDistance: return "CullDistance"; + case BuiltInVertexId: return "VertexId"; + case BuiltInInstanceId: return "InstanceId"; + case BuiltInPrimitiveId: return "PrimitiveId"; + case BuiltInInvocationId: return "InvocationId"; + case BuiltInLayer: return "Layer"; + case BuiltInViewportIndex: return "ViewportIndex"; + case BuiltInTessLevelOuter: return "TessLevelOuter"; + case BuiltInTessLevelInner: return "TessLevelInner"; + case BuiltInTessCoord: return "TessCoord"; + case BuiltInPatchVertices: return "PatchVertices"; + case BuiltInFragCoord: return "FragCoord"; + case BuiltInPointCoord: return "PointCoord"; + case BuiltInFrontFacing: return "FrontFacing"; + case BuiltInSampleId: return "SampleId"; + case BuiltInSamplePosition: return "SamplePosition"; + case BuiltInSampleMask: return "SampleMask"; + case BuiltInFragDepth: return "FragDepth"; + case BuiltInHelperInvocation: return "HelperInvocation"; + case BuiltInNumWorkgroups: return "NumWorkgroups"; + case BuiltInWorkgroupSize: return "WorkgroupSize"; + case BuiltInWorkgroupId: return "WorkgroupId"; + case BuiltInLocalInvocationId: return "LocalInvocationId"; + case BuiltInGlobalInvocationId: return "GlobalInvocationId"; + case BuiltInLocalInvocationIndex: return "LocalInvocationIndex"; + case BuiltInWorkDim: return "WorkDim"; + case BuiltInGlobalSize: return "GlobalSize"; + case BuiltInEnqueuedWorkgroupSize: return "EnqueuedWorkgroupSize"; + case BuiltInGlobalOffset: return "GlobalOffset"; + case BuiltInGlobalLinearId: return "GlobalLinearId"; + case BuiltInSubgroupSize: return "SubgroupSize"; + case BuiltInSubgroupMaxSize: return "SubgroupMaxSize"; + case BuiltInNumSubgroups: return "NumSubgroups"; + case BuiltInNumEnqueuedSubgroups: return "NumEnqueuedSubgroups"; + case BuiltInSubgroupId: return "SubgroupId"; + case BuiltInSubgroupLocalInvocationId: return "SubgroupLocalInvocationId"; + case BuiltInVertexIndex: return "VertexIndex"; + case BuiltInInstanceIndex: return "InstanceIndex"; + case BuiltInCoreIDARM: return "CoreIDARM"; + case BuiltInCoreCountARM: return "CoreCountARM"; + case BuiltInCoreMaxIDARM: return "CoreMaxIDARM"; + case BuiltInWarpIDARM: return "WarpIDARM"; + case BuiltInWarpMaxIDARM: return "WarpMaxIDARM"; + case BuiltInSubgroupEqMask: return "SubgroupEqMask"; + case BuiltInSubgroupGeMask: return "SubgroupGeMask"; + case BuiltInSubgroupGtMask: return "SubgroupGtMask"; + case BuiltInSubgroupLeMask: return "SubgroupLeMask"; + case BuiltInSubgroupLtMask: return "SubgroupLtMask"; + case BuiltInBaseVertex: return "BaseVertex"; + case BuiltInBaseInstance: return "BaseInstance"; + case BuiltInDrawIndex: return "DrawIndex"; + case BuiltInPrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR"; + case BuiltInDeviceIndex: return "DeviceIndex"; + case BuiltInViewIndex: return "ViewIndex"; + case BuiltInShadingRateKHR: return "ShadingRateKHR"; + case BuiltInBaryCoordNoPerspAMD: return "BaryCoordNoPerspAMD"; + case BuiltInBaryCoordNoPerspCentroidAMD: return "BaryCoordNoPerspCentroidAMD"; + case BuiltInBaryCoordNoPerspSampleAMD: return "BaryCoordNoPerspSampleAMD"; + case BuiltInBaryCoordSmoothAMD: return "BaryCoordSmoothAMD"; + case BuiltInBaryCoordSmoothCentroidAMD: return "BaryCoordSmoothCentroidAMD"; + case BuiltInBaryCoordSmoothSampleAMD: return "BaryCoordSmoothSampleAMD"; + case BuiltInBaryCoordPullModelAMD: return "BaryCoordPullModelAMD"; + case BuiltInFragStencilRefEXT: return "FragStencilRefEXT"; + case BuiltInRemainingRecursionLevelsAMDX: return "RemainingRecursionLevelsAMDX"; + case BuiltInShaderIndexAMDX: return "ShaderIndexAMDX"; + case BuiltInViewportMaskNV: return "ViewportMaskNV"; + case BuiltInSecondaryPositionNV: return "SecondaryPositionNV"; + case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; + case BuiltInPositionPerViewNV: return "PositionPerViewNV"; + case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; + case BuiltInFullyCoveredEXT: return "FullyCoveredEXT"; + case BuiltInTaskCountNV: return "TaskCountNV"; + case BuiltInPrimitiveCountNV: return "PrimitiveCountNV"; + case BuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV"; + case BuiltInClipDistancePerViewNV: return "ClipDistancePerViewNV"; + case BuiltInCullDistancePerViewNV: return "CullDistancePerViewNV"; + case BuiltInLayerPerViewNV: return "LayerPerViewNV"; + case BuiltInMeshViewCountNV: return "MeshViewCountNV"; + case BuiltInMeshViewIndicesNV: return "MeshViewIndicesNV"; + case BuiltInBaryCoordKHR: return "BaryCoordKHR"; + case BuiltInBaryCoordNoPerspKHR: return "BaryCoordNoPerspKHR"; + case BuiltInFragSizeEXT: return "FragSizeEXT"; + case BuiltInFragInvocationCountEXT: return "FragInvocationCountEXT"; + case BuiltInPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT"; + case BuiltInPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT"; + case BuiltInPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT"; + case BuiltInCullPrimitiveEXT: return "CullPrimitiveEXT"; + case BuiltInLaunchIdKHR: return "LaunchIdKHR"; + case BuiltInLaunchSizeKHR: return "LaunchSizeKHR"; + case BuiltInWorldRayOriginKHR: return "WorldRayOriginKHR"; + case BuiltInWorldRayDirectionKHR: return "WorldRayDirectionKHR"; + case BuiltInObjectRayOriginKHR: return "ObjectRayOriginKHR"; + case BuiltInObjectRayDirectionKHR: return "ObjectRayDirectionKHR"; + case BuiltInRayTminKHR: return "RayTminKHR"; + case BuiltInRayTmaxKHR: return "RayTmaxKHR"; + case BuiltInInstanceCustomIndexKHR: return "InstanceCustomIndexKHR"; + case BuiltInObjectToWorldKHR: return "ObjectToWorldKHR"; + case BuiltInWorldToObjectKHR: return "WorldToObjectKHR"; + case BuiltInHitTNV: return "HitTNV"; + case BuiltInHitKindKHR: return "HitKindKHR"; + case BuiltInCurrentRayTimeNV: return "CurrentRayTimeNV"; + case BuiltInHitTriangleVertexPositionsKHR: return "HitTriangleVertexPositionsKHR"; + case BuiltInHitMicroTriangleVertexPositionsNV: return "HitMicroTriangleVertexPositionsNV"; + case BuiltInHitMicroTriangleVertexBarycentricsNV: return "HitMicroTriangleVertexBarycentricsNV"; + case BuiltInIncomingRayFlagsKHR: return "IncomingRayFlagsKHR"; + case BuiltInRayGeometryIndexKHR: return "RayGeometryIndexKHR"; + case BuiltInHitIsSphereNV: return "HitIsSphereNV"; + case BuiltInHitIsLSSNV: return "HitIsLSSNV"; + case BuiltInHitSpherePositionNV: return "HitSpherePositionNV"; + case BuiltInWarpsPerSMNV: return "WarpsPerSMNV"; + case BuiltInSMCountNV: return "SMCountNV"; + case BuiltInWarpIDNV: return "WarpIDNV"; + case BuiltInSMIDNV: return "SMIDNV"; + case BuiltInHitLSSPositionsNV: return "HitLSSPositionsNV"; + case BuiltInHitKindFrontFacingMicroTriangleNV: return "HitKindFrontFacingMicroTriangleNV"; + case BuiltInHitKindBackFacingMicroTriangleNV: return "HitKindBackFacingMicroTriangleNV"; + case BuiltInHitSphereRadiusNV: return "HitSphereRadiusNV"; + case BuiltInHitLSSRadiiNV: return "HitLSSRadiiNV"; + case BuiltInClusterIDNV: return "ClusterIDNV"; + case BuiltInCullMaskKHR: return "CullMaskKHR"; + default: return "Unknown"; + } +} + +inline const char* ScopeToString(Scope value) { + switch (value) { + case ScopeCrossDevice: return "CrossDevice"; + case ScopeDevice: return "Device"; + case ScopeWorkgroup: return "Workgroup"; + case ScopeSubgroup: return "Subgroup"; + case ScopeInvocation: return "Invocation"; + case ScopeQueueFamily: return "QueueFamily"; + case ScopeShaderCallKHR: return "ShaderCallKHR"; + default: return "Unknown"; + } +} + +inline const char* GroupOperationToString(GroupOperation value) { + switch (value) { + case GroupOperationReduce: return "Reduce"; + case GroupOperationInclusiveScan: return "InclusiveScan"; + case GroupOperationExclusiveScan: return "ExclusiveScan"; + case GroupOperationClusteredReduce: return "ClusteredReduce"; + case GroupOperationPartitionedReduceNV: return "PartitionedReduceNV"; + case GroupOperationPartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV"; + case GroupOperationPartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV"; + default: return "Unknown"; + } +} + +inline const char* KernelEnqueueFlagsToString(KernelEnqueueFlags value) { + switch (value) { + case KernelEnqueueFlagsNoWait: return "NoWait"; + case KernelEnqueueFlagsWaitKernel: return "WaitKernel"; + case KernelEnqueueFlagsWaitWorkGroup: return "WaitWorkGroup"; + default: return "Unknown"; + } +} + +inline const char* CapabilityToString(Capability value) { + switch (value) { + case CapabilityMatrix: return "Matrix"; + case CapabilityShader: return "Shader"; + case CapabilityGeometry: return "Geometry"; + case CapabilityTessellation: return "Tessellation"; + case CapabilityAddresses: return "Addresses"; + case CapabilityLinkage: return "Linkage"; + case CapabilityKernel: return "Kernel"; + case CapabilityVector16: return "Vector16"; + case CapabilityFloat16Buffer: return "Float16Buffer"; + case CapabilityFloat16: return "Float16"; + case CapabilityFloat64: return "Float64"; + case CapabilityInt64: return "Int64"; + case CapabilityInt64Atomics: return "Int64Atomics"; + case CapabilityImageBasic: return "ImageBasic"; + case CapabilityImageReadWrite: return "ImageReadWrite"; + case CapabilityImageMipmap: return "ImageMipmap"; + case CapabilityPipes: return "Pipes"; + case CapabilityGroups: return "Groups"; + case CapabilityDeviceEnqueue: return "DeviceEnqueue"; + case CapabilityLiteralSampler: return "LiteralSampler"; + case CapabilityAtomicStorage: return "AtomicStorage"; + case CapabilityInt16: return "Int16"; + case CapabilityTessellationPointSize: return "TessellationPointSize"; + case CapabilityGeometryPointSize: return "GeometryPointSize"; + case CapabilityImageGatherExtended: return "ImageGatherExtended"; + case CapabilityStorageImageMultisample: return "StorageImageMultisample"; + case CapabilityUniformBufferArrayDynamicIndexing: return "UniformBufferArrayDynamicIndexing"; + case CapabilitySampledImageArrayDynamicIndexing: return "SampledImageArrayDynamicIndexing"; + case CapabilityStorageBufferArrayDynamicIndexing: return "StorageBufferArrayDynamicIndexing"; + case CapabilityStorageImageArrayDynamicIndexing: return "StorageImageArrayDynamicIndexing"; + case CapabilityClipDistance: return "ClipDistance"; + case CapabilityCullDistance: return "CullDistance"; + case CapabilityImageCubeArray: return "ImageCubeArray"; + case CapabilitySampleRateShading: return "SampleRateShading"; + case CapabilityImageRect: return "ImageRect"; + case CapabilitySampledRect: return "SampledRect"; + case CapabilityGenericPointer: return "GenericPointer"; + case CapabilityInt8: return "Int8"; + case CapabilityInputAttachment: return "InputAttachment"; + case CapabilitySparseResidency: return "SparseResidency"; + case CapabilityMinLod: return "MinLod"; + case CapabilitySampled1D: return "Sampled1D"; + case CapabilityImage1D: return "Image1D"; + case CapabilitySampledCubeArray: return "SampledCubeArray"; + case CapabilitySampledBuffer: return "SampledBuffer"; + case CapabilityImageBuffer: return "ImageBuffer"; + case CapabilityImageMSArray: return "ImageMSArray"; + case CapabilityStorageImageExtendedFormats: return "StorageImageExtendedFormats"; + case CapabilityImageQuery: return "ImageQuery"; + case CapabilityDerivativeControl: return "DerivativeControl"; + case CapabilityInterpolationFunction: return "InterpolationFunction"; + case CapabilityTransformFeedback: return "TransformFeedback"; + case CapabilityGeometryStreams: return "GeometryStreams"; + case CapabilityStorageImageReadWithoutFormat: return "StorageImageReadWithoutFormat"; + case CapabilityStorageImageWriteWithoutFormat: return "StorageImageWriteWithoutFormat"; + case CapabilityMultiViewport: return "MultiViewport"; + case CapabilitySubgroupDispatch: return "SubgroupDispatch"; + case CapabilityNamedBarrier: return "NamedBarrier"; + case CapabilityPipeStorage: return "PipeStorage"; + case CapabilityGroupNonUniform: return "GroupNonUniform"; + case CapabilityGroupNonUniformVote: return "GroupNonUniformVote"; + case CapabilityGroupNonUniformArithmetic: return "GroupNonUniformArithmetic"; + case CapabilityGroupNonUniformBallot: return "GroupNonUniformBallot"; + case CapabilityGroupNonUniformShuffle: return "GroupNonUniformShuffle"; + case CapabilityGroupNonUniformShuffleRelative: return "GroupNonUniformShuffleRelative"; + case CapabilityGroupNonUniformClustered: return "GroupNonUniformClustered"; + case CapabilityGroupNonUniformQuad: return "GroupNonUniformQuad"; + case CapabilityShaderLayer: return "ShaderLayer"; + case CapabilityShaderViewportIndex: return "ShaderViewportIndex"; + case CapabilityUniformDecoration: return "UniformDecoration"; + case CapabilityCoreBuiltinsARM: return "CoreBuiltinsARM"; + case CapabilityTileImageColorReadAccessEXT: return "TileImageColorReadAccessEXT"; + case CapabilityTileImageDepthReadAccessEXT: return "TileImageDepthReadAccessEXT"; + case CapabilityTileImageStencilReadAccessEXT: return "TileImageStencilReadAccessEXT"; + case CapabilityCooperativeMatrixLayoutsARM: return "CooperativeMatrixLayoutsARM"; + case CapabilityFragmentShadingRateKHR: return "FragmentShadingRateKHR"; + case CapabilitySubgroupBallotKHR: return "SubgroupBallotKHR"; + case CapabilityDrawParameters: return "DrawParameters"; + case CapabilityWorkgroupMemoryExplicitLayoutKHR: return "WorkgroupMemoryExplicitLayoutKHR"; + case CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR: return "WorkgroupMemoryExplicitLayout8BitAccessKHR"; + case CapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR: return "WorkgroupMemoryExplicitLayout16BitAccessKHR"; + case CapabilitySubgroupVoteKHR: return "SubgroupVoteKHR"; + case CapabilityStorageBuffer16BitAccess: return "StorageBuffer16BitAccess"; + case CapabilityStorageUniform16: return "StorageUniform16"; + case CapabilityStoragePushConstant16: return "StoragePushConstant16"; + case CapabilityStorageInputOutput16: return "StorageInputOutput16"; + case CapabilityDeviceGroup: return "DeviceGroup"; + case CapabilityMultiView: return "MultiView"; + case CapabilityVariablePointersStorageBuffer: return "VariablePointersStorageBuffer"; + case CapabilityVariablePointers: return "VariablePointers"; + case CapabilityAtomicStorageOps: return "AtomicStorageOps"; + case CapabilitySampleMaskPostDepthCoverage: return "SampleMaskPostDepthCoverage"; + case CapabilityStorageBuffer8BitAccess: return "StorageBuffer8BitAccess"; + case CapabilityUniformAndStorageBuffer8BitAccess: return "UniformAndStorageBuffer8BitAccess"; + case CapabilityStoragePushConstant8: return "StoragePushConstant8"; + case CapabilityDenormPreserve: return "DenormPreserve"; + case CapabilityDenormFlushToZero: return "DenormFlushToZero"; + case CapabilitySignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case CapabilityRoundingModeRTE: return "RoundingModeRTE"; + case CapabilityRoundingModeRTZ: return "RoundingModeRTZ"; + case CapabilityRayQueryProvisionalKHR: return "RayQueryProvisionalKHR"; + case CapabilityRayQueryKHR: return "RayQueryKHR"; + case CapabilityUntypedPointersKHR: return "UntypedPointersKHR"; + case CapabilityRayTraversalPrimitiveCullingKHR: return "RayTraversalPrimitiveCullingKHR"; + case CapabilityRayTracingKHR: return "RayTracingKHR"; + case CapabilityTextureSampleWeightedQCOM: return "TextureSampleWeightedQCOM"; + case CapabilityTextureBoxFilterQCOM: return "TextureBoxFilterQCOM"; + case CapabilityTextureBlockMatchQCOM: return "TextureBlockMatchQCOM"; + case CapabilityTextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM"; + case CapabilityFloat16ImageAMD: return "Float16ImageAMD"; + case CapabilityImageGatherBiasLodAMD: return "ImageGatherBiasLodAMD"; + case CapabilityFragmentMaskAMD: return "FragmentMaskAMD"; + case CapabilityStencilExportEXT: return "StencilExportEXT"; + case CapabilityImageReadWriteLodAMD: return "ImageReadWriteLodAMD"; + case CapabilityInt64ImageEXT: return "Int64ImageEXT"; + case CapabilityShaderClockKHR: return "ShaderClockKHR"; + case CapabilityShaderEnqueueAMDX: return "ShaderEnqueueAMDX"; + case CapabilityQuadControlKHR: return "QuadControlKHR"; + case CapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV"; + case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV"; + case CapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT"; + case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV"; + case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV"; + case CapabilityPerViewAttributesNV: return "PerViewAttributesNV"; + case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT"; + case CapabilityMeshShadingNV: return "MeshShadingNV"; + case CapabilityImageFootprintNV: return "ImageFootprintNV"; + case CapabilityMeshShadingEXT: return "MeshShadingEXT"; + case CapabilityFragmentBarycentricKHR: return "FragmentBarycentricKHR"; + case CapabilityComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR"; + case CapabilityFragmentDensityEXT: return "FragmentDensityEXT"; + case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; + case CapabilityShaderNonUniform: return "ShaderNonUniform"; + case CapabilityRuntimeDescriptorArray: return "RuntimeDescriptorArray"; + case CapabilityInputAttachmentArrayDynamicIndexing: return "InputAttachmentArrayDynamicIndexing"; + case CapabilityUniformTexelBufferArrayDynamicIndexing: return "UniformTexelBufferArrayDynamicIndexing"; + case CapabilityStorageTexelBufferArrayDynamicIndexing: return "StorageTexelBufferArrayDynamicIndexing"; + case CapabilityUniformBufferArrayNonUniformIndexing: return "UniformBufferArrayNonUniformIndexing"; + case CapabilitySampledImageArrayNonUniformIndexing: return "SampledImageArrayNonUniformIndexing"; + case CapabilityStorageBufferArrayNonUniformIndexing: return "StorageBufferArrayNonUniformIndexing"; + case CapabilityStorageImageArrayNonUniformIndexing: return "StorageImageArrayNonUniformIndexing"; + case CapabilityInputAttachmentArrayNonUniformIndexing: return "InputAttachmentArrayNonUniformIndexing"; + case CapabilityUniformTexelBufferArrayNonUniformIndexing: return "UniformTexelBufferArrayNonUniformIndexing"; + case CapabilityStorageTexelBufferArrayNonUniformIndexing: return "StorageTexelBufferArrayNonUniformIndexing"; + case CapabilityRayTracingPositionFetchKHR: return "RayTracingPositionFetchKHR"; + case CapabilityRayTracingNV: return "RayTracingNV"; + case CapabilityRayTracingMotionBlurNV: return "RayTracingMotionBlurNV"; + case CapabilityVulkanMemoryModel: return "VulkanMemoryModel"; + case CapabilityVulkanMemoryModelDeviceScope: return "VulkanMemoryModelDeviceScope"; + case CapabilityPhysicalStorageBufferAddresses: return "PhysicalStorageBufferAddresses"; + case CapabilityComputeDerivativeGroupLinearKHR: return "ComputeDerivativeGroupLinearKHR"; + case CapabilityRayTracingProvisionalKHR: return "RayTracingProvisionalKHR"; + case CapabilityCooperativeMatrixNV: return "CooperativeMatrixNV"; + case CapabilityFragmentShaderSampleInterlockEXT: return "FragmentShaderSampleInterlockEXT"; + case CapabilityFragmentShaderShadingRateInterlockEXT: return "FragmentShaderShadingRateInterlockEXT"; + case CapabilityShaderSMBuiltinsNV: return "ShaderSMBuiltinsNV"; + case CapabilityFragmentShaderPixelInterlockEXT: return "FragmentShaderPixelInterlockEXT"; + case CapabilityDemoteToHelperInvocation: return "DemoteToHelperInvocation"; + case CapabilityDisplacementMicromapNV: return "DisplacementMicromapNV"; + case CapabilityRayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT"; + case CapabilityShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + case CapabilityBindlessTextureNV: return "BindlessTextureNV"; + case CapabilityRayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR"; + case CapabilityCooperativeVectorNV: return "CooperativeVectorNV"; + case CapabilityAtomicFloat16VectorNV: return "AtomicFloat16VectorNV"; + case CapabilityRayTracingDisplacementMicromapNV: return "RayTracingDisplacementMicromapNV"; + case CapabilityRawAccessChainsNV: return "RawAccessChainsNV"; + case CapabilityRayTracingSpheresGeometryNV: return "RayTracingSpheresGeometryNV"; + case CapabilityRayTracingLinearSweptSpheresGeometryNV: return "RayTracingLinearSweptSpheresGeometryNV"; + case CapabilityCooperativeMatrixReductionsNV: return "CooperativeMatrixReductionsNV"; + case CapabilityCooperativeMatrixConversionsNV: return "CooperativeMatrixConversionsNV"; + case CapabilityCooperativeMatrixPerElementOperationsNV: return "CooperativeMatrixPerElementOperationsNV"; + case CapabilityCooperativeMatrixTensorAddressingNV: return "CooperativeMatrixTensorAddressingNV"; + case CapabilityCooperativeMatrixBlockLoadsNV: return "CooperativeMatrixBlockLoadsNV"; + case CapabilityCooperativeVectorTrainingNV: return "CooperativeVectorTrainingNV"; + case CapabilityRayTracingClusterAccelerationStructureNV: return "RayTracingClusterAccelerationStructureNV"; + case CapabilityTensorAddressingNV: return "TensorAddressingNV"; + case CapabilitySubgroupShuffleINTEL: return "SubgroupShuffleINTEL"; + case CapabilitySubgroupBufferBlockIOINTEL: return "SubgroupBufferBlockIOINTEL"; + case CapabilitySubgroupImageBlockIOINTEL: return "SubgroupImageBlockIOINTEL"; + case CapabilitySubgroupImageMediaBlockIOINTEL: return "SubgroupImageMediaBlockIOINTEL"; + case CapabilityRoundToInfinityINTEL: return "RoundToInfinityINTEL"; + case CapabilityFloatingPointModeINTEL: return "FloatingPointModeINTEL"; + case CapabilityIntegerFunctions2INTEL: return "IntegerFunctions2INTEL"; + case CapabilityFunctionPointersINTEL: return "FunctionPointersINTEL"; + case CapabilityIndirectReferencesINTEL: return "IndirectReferencesINTEL"; + case CapabilityAsmINTEL: return "AsmINTEL"; + case CapabilityAtomicFloat32MinMaxEXT: return "AtomicFloat32MinMaxEXT"; + case CapabilityAtomicFloat64MinMaxEXT: return "AtomicFloat64MinMaxEXT"; + case CapabilityAtomicFloat16MinMaxEXT: return "AtomicFloat16MinMaxEXT"; + case CapabilityVectorComputeINTEL: return "VectorComputeINTEL"; + case CapabilityVectorAnyINTEL: return "VectorAnyINTEL"; + case CapabilityExpectAssumeKHR: return "ExpectAssumeKHR"; + case CapabilitySubgroupAvcMotionEstimationINTEL: return "SubgroupAvcMotionEstimationINTEL"; + case CapabilitySubgroupAvcMotionEstimationIntraINTEL: return "SubgroupAvcMotionEstimationIntraINTEL"; + case CapabilitySubgroupAvcMotionEstimationChromaINTEL: return "SubgroupAvcMotionEstimationChromaINTEL"; + case CapabilityVariableLengthArrayINTEL: return "VariableLengthArrayINTEL"; + case CapabilityFunctionFloatControlINTEL: return "FunctionFloatControlINTEL"; + case CapabilityFPGAMemoryAttributesINTEL: return "FPGAMemoryAttributesINTEL"; + case CapabilityFPFastMathModeINTEL: return "FPFastMathModeINTEL"; + case CapabilityArbitraryPrecisionIntegersINTEL: return "ArbitraryPrecisionIntegersINTEL"; + case CapabilityArbitraryPrecisionFloatingPointINTEL: return "ArbitraryPrecisionFloatingPointINTEL"; + case CapabilityUnstructuredLoopControlsINTEL: return "UnstructuredLoopControlsINTEL"; + case CapabilityFPGALoopControlsINTEL: return "FPGALoopControlsINTEL"; + case CapabilityKernelAttributesINTEL: return "KernelAttributesINTEL"; + case CapabilityFPGAKernelAttributesINTEL: return "FPGAKernelAttributesINTEL"; + case CapabilityFPGAMemoryAccessesINTEL: return "FPGAMemoryAccessesINTEL"; + case CapabilityFPGAClusterAttributesINTEL: return "FPGAClusterAttributesINTEL"; + case CapabilityLoopFuseINTEL: return "LoopFuseINTEL"; + case CapabilityFPGADSPControlINTEL: return "FPGADSPControlINTEL"; + case CapabilityMemoryAccessAliasingINTEL: return "MemoryAccessAliasingINTEL"; + case CapabilityFPGAInvocationPipeliningAttributesINTEL: return "FPGAInvocationPipeliningAttributesINTEL"; + case CapabilityFPGABufferLocationINTEL: return "FPGABufferLocationINTEL"; + case CapabilityArbitraryPrecisionFixedPointINTEL: return "ArbitraryPrecisionFixedPointINTEL"; + case CapabilityUSMStorageClassesINTEL: return "USMStorageClassesINTEL"; + case CapabilityRuntimeAlignedAttributeINTEL: return "RuntimeAlignedAttributeINTEL"; + case CapabilityIOPipesINTEL: return "IOPipesINTEL"; + case CapabilityBlockingPipesINTEL: return "BlockingPipesINTEL"; + case CapabilityFPGARegINTEL: return "FPGARegINTEL"; + case CapabilityDotProductInputAll: return "DotProductInputAll"; + case CapabilityDotProductInput4x8Bit: return "DotProductInput4x8Bit"; + case CapabilityDotProductInput4x8BitPacked: return "DotProductInput4x8BitPacked"; + case CapabilityDotProduct: return "DotProduct"; + case CapabilityRayCullMaskKHR: return "RayCullMaskKHR"; + case CapabilityCooperativeMatrixKHR: return "CooperativeMatrixKHR"; + case CapabilityReplicatedCompositesEXT: return "ReplicatedCompositesEXT"; + case CapabilityBitInstructions: return "BitInstructions"; + case CapabilityGroupNonUniformRotateKHR: return "GroupNonUniformRotateKHR"; + case CapabilityFloatControls2: return "FloatControls2"; + case CapabilityAtomicFloat32AddEXT: return "AtomicFloat32AddEXT"; + case CapabilityAtomicFloat64AddEXT: return "AtomicFloat64AddEXT"; + case CapabilityLongCompositesINTEL: return "LongCompositesINTEL"; + case CapabilityOptNoneEXT: return "OptNoneEXT"; + case CapabilityAtomicFloat16AddEXT: return "AtomicFloat16AddEXT"; + case CapabilityDebugInfoModuleINTEL: return "DebugInfoModuleINTEL"; + case CapabilityBFloat16ConversionINTEL: return "BFloat16ConversionINTEL"; + case CapabilitySplitBarrierINTEL: return "SplitBarrierINTEL"; + case CapabilityArithmeticFenceEXT: return "ArithmeticFenceEXT"; + case CapabilityFPGAClusterAttributesV2INTEL: return "FPGAClusterAttributesV2INTEL"; + case CapabilityFPGAKernelAttributesv2INTEL: return "FPGAKernelAttributesv2INTEL"; + case CapabilityFPMaxErrorINTEL: return "FPMaxErrorINTEL"; + case CapabilityFPGALatencyControlINTEL: return "FPGALatencyControlINTEL"; + case CapabilityFPGAArgumentInterfacesINTEL: return "FPGAArgumentInterfacesINTEL"; + case CapabilityGlobalVariableHostAccessINTEL: return "GlobalVariableHostAccessINTEL"; + case CapabilityGlobalVariableFPGADecorationsINTEL: return "GlobalVariableFPGADecorationsINTEL"; + case CapabilitySubgroupBufferPrefetchINTEL: return "SubgroupBufferPrefetchINTEL"; + case CapabilitySubgroup2DBlockIOINTEL: return "Subgroup2DBlockIOINTEL"; + case CapabilitySubgroup2DBlockTransformINTEL: return "Subgroup2DBlockTransformINTEL"; + case CapabilitySubgroup2DBlockTransposeINTEL: return "Subgroup2DBlockTransposeINTEL"; + case CapabilitySubgroupMatrixMultiplyAccumulateINTEL: return "SubgroupMatrixMultiplyAccumulateINTEL"; + case CapabilityGroupUniformArithmeticKHR: return "GroupUniformArithmeticKHR"; + case CapabilityMaskedGatherScatterINTEL: return "MaskedGatherScatterINTEL"; + case CapabilityCacheControlsINTEL: return "CacheControlsINTEL"; + case CapabilityRegisterLimitsINTEL: return "RegisterLimitsINTEL"; + default: return "Unknown"; + } +} + +inline const char* RayQueryIntersectionToString(RayQueryIntersection value) { + switch (value) { + case RayQueryIntersectionRayQueryCandidateIntersectionKHR: return "RayQueryCandidateIntersectionKHR"; + case RayQueryIntersectionRayQueryCommittedIntersectionKHR: return "RayQueryCommittedIntersectionKHR"; + default: return "Unknown"; + } +} + +inline const char* RayQueryCommittedIntersectionTypeToString(RayQueryCommittedIntersectionType value) { + switch (value) { + case RayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionNoneKHR: return "RayQueryCommittedIntersectionNoneKHR"; + case RayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionTriangleKHR: return "RayQueryCommittedIntersectionTriangleKHR"; + case RayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionGeneratedKHR: return "RayQueryCommittedIntersectionGeneratedKHR"; + default: return "Unknown"; + } +} + +inline const char* RayQueryCandidateIntersectionTypeToString(RayQueryCandidateIntersectionType value) { + switch (value) { + case RayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionTriangleKHR: return "RayQueryCandidateIntersectionTriangleKHR"; + case RayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionAABBKHR: return "RayQueryCandidateIntersectionAABBKHR"; + default: return "Unknown"; + } +} + +inline const char* FPDenormModeToString(FPDenormMode value) { + switch (value) { + case FPDenormModePreserve: return "Preserve"; + case FPDenormModeFlushToZero: return "FlushToZero"; + default: return "Unknown"; + } +} + +inline const char* FPOperationModeToString(FPOperationMode value) { + switch (value) { + case FPOperationModeIEEE: return "IEEE"; + case FPOperationModeALT: return "ALT"; + default: return "Unknown"; + } +} + +inline const char* QuantizationModesToString(QuantizationModes value) { + switch (value) { + case QuantizationModesTRN: return "TRN"; + case QuantizationModesTRN_ZERO: return "TRN_ZERO"; + case QuantizationModesRND: return "RND"; + case QuantizationModesRND_ZERO: return "RND_ZERO"; + case QuantizationModesRND_INF: return "RND_INF"; + case QuantizationModesRND_MIN_INF: return "RND_MIN_INF"; + case QuantizationModesRND_CONV: return "RND_CONV"; + case QuantizationModesRND_CONV_ODD: return "RND_CONV_ODD"; + default: return "Unknown"; + } +} + +inline const char* OverflowModesToString(OverflowModes value) { + switch (value) { + case OverflowModesWRAP: return "WRAP"; + case OverflowModesSAT: return "SAT"; + case OverflowModesSAT_ZERO: return "SAT_ZERO"; + case OverflowModesSAT_SYM: return "SAT_SYM"; + default: return "Unknown"; + } +} + +inline const char* PackedVectorFormatToString(PackedVectorFormat value) { + switch (value) { + case PackedVectorFormatPackedVectorFormat4x8Bit: return "PackedVectorFormat4x8Bit"; + default: return "Unknown"; + } +} + +inline const char* CooperativeMatrixLayoutToString(CooperativeMatrixLayout value) { + switch (value) { + case CooperativeMatrixLayoutRowMajorKHR: return "RowMajorKHR"; + case CooperativeMatrixLayoutColumnMajorKHR: return "ColumnMajorKHR"; + case CooperativeMatrixLayoutRowBlockedInterleavedARM: return "RowBlockedInterleavedARM"; + case CooperativeMatrixLayoutColumnBlockedInterleavedARM: return "ColumnBlockedInterleavedARM"; + default: return "Unknown"; + } +} + +inline const char* CooperativeMatrixUseToString(CooperativeMatrixUse value) { + switch (value) { + case CooperativeMatrixUseMatrixAKHR: return "MatrixAKHR"; + case CooperativeMatrixUseMatrixBKHR: return "MatrixBKHR"; + case CooperativeMatrixUseMatrixAccumulatorKHR: return "MatrixAccumulatorKHR"; + default: return "Unknown"; + } +} + +inline const char* TensorClampModeToString(TensorClampMode value) { + switch (value) { + case TensorClampModeUndefined: return "Undefined"; + case TensorClampModeConstant: return "Constant"; + case TensorClampModeClampToEdge: return "ClampToEdge"; + case TensorClampModeRepeat: return "Repeat"; + case TensorClampModeRepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* InitializationModeQualifierToString(InitializationModeQualifier value) { + switch (value) { + case InitializationModeQualifierInitOnDeviceReprogramINTEL: return "InitOnDeviceReprogramINTEL"; + case InitializationModeQualifierInitOnDeviceResetINTEL: return "InitOnDeviceResetINTEL"; + default: return "Unknown"; + } +} + +inline const char* HostAccessQualifierToString(HostAccessQualifier value) { + switch (value) { + case HostAccessQualifierNoneINTEL: return "NoneINTEL"; + case HostAccessQualifierReadINTEL: return "ReadINTEL"; + case HostAccessQualifierWriteINTEL: return "WriteINTEL"; + case HostAccessQualifierReadWriteINTEL: return "ReadWriteINTEL"; + default: return "Unknown"; + } +} + +inline const char* LoadCacheControlToString(LoadCacheControl value) { + switch (value) { + case LoadCacheControlUncachedINTEL: return "UncachedINTEL"; + case LoadCacheControlCachedINTEL: return "CachedINTEL"; + case LoadCacheControlStreamingINTEL: return "StreamingINTEL"; + case LoadCacheControlInvalidateAfterReadINTEL: return "InvalidateAfterReadINTEL"; + case LoadCacheControlConstCachedINTEL: return "ConstCachedINTEL"; + default: return "Unknown"; + } +} + +inline const char* StoreCacheControlToString(StoreCacheControl value) { + switch (value) { + case StoreCacheControlUncachedINTEL: return "UncachedINTEL"; + case StoreCacheControlWriteThroughINTEL: return "WriteThroughINTEL"; + case StoreCacheControlWriteBackINTEL: return "WriteBackINTEL"; + case StoreCacheControlStreamingINTEL: return "StreamingINTEL"; + default: return "Unknown"; + } +} + +inline const char* NamedMaximumNumberOfRegistersToString(NamedMaximumNumberOfRegisters value) { + switch (value) { + case NamedMaximumNumberOfRegistersAutoINTEL: return "AutoINTEL"; + default: return "Unknown"; + } +} + +inline const char* FPEncodingToString(FPEncoding value) { + switch (value) { + default: return "Unknown"; + } +} + +inline const char* CooperativeVectorMatrixLayoutToString(CooperativeVectorMatrixLayout value) { + switch (value) { + case CooperativeVectorMatrixLayoutRowMajorNV: return "RowMajorNV"; + case CooperativeVectorMatrixLayoutColumnMajorNV: return "ColumnMajorNV"; + case CooperativeVectorMatrixLayoutInferencingOptimalNV: return "InferencingOptimalNV"; + case CooperativeVectorMatrixLayoutTrainingOptimalNV: return "TrainingOptimalNV"; + default: return "Unknown"; + } +} + +inline const char* ComponentTypeToString(ComponentType value) { + switch (value) { + case ComponentTypeFloat16NV: return "Float16NV"; + case ComponentTypeFloat32NV: return "Float32NV"; + case ComponentTypeFloat64NV: return "Float64NV"; + case ComponentTypeSignedInt8NV: return "SignedInt8NV"; + case ComponentTypeSignedInt16NV: return "SignedInt16NV"; + case ComponentTypeSignedInt32NV: return "SignedInt32NV"; + case ComponentTypeSignedInt64NV: return "SignedInt64NV"; + case ComponentTypeUnsignedInt8NV: return "UnsignedInt8NV"; + case ComponentTypeUnsignedInt16NV: return "UnsignedInt16NV"; + case ComponentTypeUnsignedInt32NV: return "UnsignedInt32NV"; + case ComponentTypeUnsignedInt64NV: return "UnsignedInt64NV"; + case ComponentTypeSignedInt8PackedNV: return "SignedInt8PackedNV"; + case ComponentTypeUnsignedInt8PackedNV: return "UnsignedInt8PackedNV"; + case ComponentTypeFloatE4M3NV: return "FloatE4M3NV"; + case ComponentTypeFloatE5M2NV: return "FloatE5M2NV"; + default: return "Unknown"; + } +} + +inline const char* OpToString(Op value) { + switch (value) { + case OpNop: return "OpNop"; + case OpUndef: return "OpUndef"; + case OpSourceContinued: return "OpSourceContinued"; + case OpSource: return "OpSource"; + case OpSourceExtension: return "OpSourceExtension"; + case OpName: return "OpName"; + case OpMemberName: return "OpMemberName"; + case OpString: return "OpString"; + case OpLine: return "OpLine"; + case OpExtension: return "OpExtension"; + case OpExtInstImport: return "OpExtInstImport"; + case OpExtInst: return "OpExtInst"; + case OpMemoryModel: return "OpMemoryModel"; + case OpEntryPoint: return "OpEntryPoint"; + case OpExecutionMode: return "OpExecutionMode"; + case OpCapability: return "OpCapability"; + case OpTypeVoid: return "OpTypeVoid"; + case OpTypeBool: return "OpTypeBool"; + case OpTypeInt: return "OpTypeInt"; + case OpTypeFloat: return "OpTypeFloat"; + case OpTypeVector: return "OpTypeVector"; + case OpTypeMatrix: return "OpTypeMatrix"; + case OpTypeImage: return "OpTypeImage"; + case OpTypeSampler: return "OpTypeSampler"; + case OpTypeSampledImage: return "OpTypeSampledImage"; + case OpTypeArray: return "OpTypeArray"; + case OpTypeRuntimeArray: return "OpTypeRuntimeArray"; + case OpTypeStruct: return "OpTypeStruct"; + case OpTypeOpaque: return "OpTypeOpaque"; + case OpTypePointer: return "OpTypePointer"; + case OpTypeFunction: return "OpTypeFunction"; + case OpTypeEvent: return "OpTypeEvent"; + case OpTypeDeviceEvent: return "OpTypeDeviceEvent"; + case OpTypeReserveId: return "OpTypeReserveId"; + case OpTypeQueue: return "OpTypeQueue"; + case OpTypePipe: return "OpTypePipe"; + case OpTypeForwardPointer: return "OpTypeForwardPointer"; + case OpConstantTrue: return "OpConstantTrue"; + case OpConstantFalse: return "OpConstantFalse"; + case OpConstant: return "OpConstant"; + case OpConstantComposite: return "OpConstantComposite"; + case OpConstantSampler: return "OpConstantSampler"; + case OpConstantNull: return "OpConstantNull"; + case OpSpecConstantTrue: return "OpSpecConstantTrue"; + case OpSpecConstantFalse: return "OpSpecConstantFalse"; + case OpSpecConstant: return "OpSpecConstant"; + case OpSpecConstantComposite: return "OpSpecConstantComposite"; + case OpSpecConstantOp: return "OpSpecConstantOp"; + case OpFunction: return "OpFunction"; + case OpFunctionParameter: return "OpFunctionParameter"; + case OpFunctionEnd: return "OpFunctionEnd"; + case OpFunctionCall: return "OpFunctionCall"; + case OpVariable: return "OpVariable"; + case OpImageTexelPointer: return "OpImageTexelPointer"; + case OpLoad: return "OpLoad"; + case OpStore: return "OpStore"; + case OpCopyMemory: return "OpCopyMemory"; + case OpCopyMemorySized: return "OpCopyMemorySized"; + case OpAccessChain: return "OpAccessChain"; + case OpInBoundsAccessChain: return "OpInBoundsAccessChain"; + case OpPtrAccessChain: return "OpPtrAccessChain"; + case OpArrayLength: return "OpArrayLength"; + case OpGenericPtrMemSemantics: return "OpGenericPtrMemSemantics"; + case OpInBoundsPtrAccessChain: return "OpInBoundsPtrAccessChain"; + case OpDecorate: return "OpDecorate"; + case OpMemberDecorate: return "OpMemberDecorate"; + case OpDecorationGroup: return "OpDecorationGroup"; + case OpGroupDecorate: return "OpGroupDecorate"; + case OpGroupMemberDecorate: return "OpGroupMemberDecorate"; + case OpVectorExtractDynamic: return "OpVectorExtractDynamic"; + case OpVectorInsertDynamic: return "OpVectorInsertDynamic"; + case OpVectorShuffle: return "OpVectorShuffle"; + case OpCompositeConstruct: return "OpCompositeConstruct"; + case OpCompositeExtract: return "OpCompositeExtract"; + case OpCompositeInsert: return "OpCompositeInsert"; + case OpCopyObject: return "OpCopyObject"; + case OpTranspose: return "OpTranspose"; + case OpSampledImage: return "OpSampledImage"; + case OpImageSampleImplicitLod: return "OpImageSampleImplicitLod"; + case OpImageSampleExplicitLod: return "OpImageSampleExplicitLod"; + case OpImageSampleDrefImplicitLod: return "OpImageSampleDrefImplicitLod"; + case OpImageSampleDrefExplicitLod: return "OpImageSampleDrefExplicitLod"; + case OpImageSampleProjImplicitLod: return "OpImageSampleProjImplicitLod"; + case OpImageSampleProjExplicitLod: return "OpImageSampleProjExplicitLod"; + case OpImageSampleProjDrefImplicitLod: return "OpImageSampleProjDrefImplicitLod"; + case OpImageSampleProjDrefExplicitLod: return "OpImageSampleProjDrefExplicitLod"; + case OpImageFetch: return "OpImageFetch"; + case OpImageGather: return "OpImageGather"; + case OpImageDrefGather: return "OpImageDrefGather"; + case OpImageRead: return "OpImageRead"; + case OpImageWrite: return "OpImageWrite"; + case OpImage: return "OpImage"; + case OpImageQueryFormat: return "OpImageQueryFormat"; + case OpImageQueryOrder: return "OpImageQueryOrder"; + case OpImageQuerySizeLod: return "OpImageQuerySizeLod"; + case OpImageQuerySize: return "OpImageQuerySize"; + case OpImageQueryLod: return "OpImageQueryLod"; + case OpImageQueryLevels: return "OpImageQueryLevels"; + case OpImageQuerySamples: return "OpImageQuerySamples"; + case OpConvertFToU: return "OpConvertFToU"; + case OpConvertFToS: return "OpConvertFToS"; + case OpConvertSToF: return "OpConvertSToF"; + case OpConvertUToF: return "OpConvertUToF"; + case OpUConvert: return "OpUConvert"; + case OpSConvert: return "OpSConvert"; + case OpFConvert: return "OpFConvert"; + case OpQuantizeToF16: return "OpQuantizeToF16"; + case OpConvertPtrToU: return "OpConvertPtrToU"; + case OpSatConvertSToU: return "OpSatConvertSToU"; + case OpSatConvertUToS: return "OpSatConvertUToS"; + case OpConvertUToPtr: return "OpConvertUToPtr"; + case OpPtrCastToGeneric: return "OpPtrCastToGeneric"; + case OpGenericCastToPtr: return "OpGenericCastToPtr"; + case OpGenericCastToPtrExplicit: return "OpGenericCastToPtrExplicit"; + case OpBitcast: return "OpBitcast"; + case OpSNegate: return "OpSNegate"; + case OpFNegate: return "OpFNegate"; + case OpIAdd: return "OpIAdd"; + case OpFAdd: return "OpFAdd"; + case OpISub: return "OpISub"; + case OpFSub: return "OpFSub"; + case OpIMul: return "OpIMul"; + case OpFMul: return "OpFMul"; + case OpUDiv: return "OpUDiv"; + case OpSDiv: return "OpSDiv"; + case OpFDiv: return "OpFDiv"; + case OpUMod: return "OpUMod"; + case OpSRem: return "OpSRem"; + case OpSMod: return "OpSMod"; + case OpFRem: return "OpFRem"; + case OpFMod: return "OpFMod"; + case OpVectorTimesScalar: return "OpVectorTimesScalar"; + case OpMatrixTimesScalar: return "OpMatrixTimesScalar"; + case OpVectorTimesMatrix: return "OpVectorTimesMatrix"; + case OpMatrixTimesVector: return "OpMatrixTimesVector"; + case OpMatrixTimesMatrix: return "OpMatrixTimesMatrix"; + case OpOuterProduct: return "OpOuterProduct"; + case OpDot: return "OpDot"; + case OpIAddCarry: return "OpIAddCarry"; + case OpISubBorrow: return "OpISubBorrow"; + case OpUMulExtended: return "OpUMulExtended"; + case OpSMulExtended: return "OpSMulExtended"; + case OpAny: return "OpAny"; + case OpAll: return "OpAll"; + case OpIsNan: return "OpIsNan"; + case OpIsInf: return "OpIsInf"; + case OpIsFinite: return "OpIsFinite"; + case OpIsNormal: return "OpIsNormal"; + case OpSignBitSet: return "OpSignBitSet"; + case OpLessOrGreater: return "OpLessOrGreater"; + case OpOrdered: return "OpOrdered"; + case OpUnordered: return "OpUnordered"; + case OpLogicalEqual: return "OpLogicalEqual"; + case OpLogicalNotEqual: return "OpLogicalNotEqual"; + case OpLogicalOr: return "OpLogicalOr"; + case OpLogicalAnd: return "OpLogicalAnd"; + case OpLogicalNot: return "OpLogicalNot"; + case OpSelect: return "OpSelect"; + case OpIEqual: return "OpIEqual"; + case OpINotEqual: return "OpINotEqual"; + case OpUGreaterThan: return "OpUGreaterThan"; + case OpSGreaterThan: return "OpSGreaterThan"; + case OpUGreaterThanEqual: return "OpUGreaterThanEqual"; + case OpSGreaterThanEqual: return "OpSGreaterThanEqual"; + case OpULessThan: return "OpULessThan"; + case OpSLessThan: return "OpSLessThan"; + case OpULessThanEqual: return "OpULessThanEqual"; + case OpSLessThanEqual: return "OpSLessThanEqual"; + case OpFOrdEqual: return "OpFOrdEqual"; + case OpFUnordEqual: return "OpFUnordEqual"; + case OpFOrdNotEqual: return "OpFOrdNotEqual"; + case OpFUnordNotEqual: return "OpFUnordNotEqual"; + case OpFOrdLessThan: return "OpFOrdLessThan"; + case OpFUnordLessThan: return "OpFUnordLessThan"; + case OpFOrdGreaterThan: return "OpFOrdGreaterThan"; + case OpFUnordGreaterThan: return "OpFUnordGreaterThan"; + case OpFOrdLessThanEqual: return "OpFOrdLessThanEqual"; + case OpFUnordLessThanEqual: return "OpFUnordLessThanEqual"; + case OpFOrdGreaterThanEqual: return "OpFOrdGreaterThanEqual"; + case OpFUnordGreaterThanEqual: return "OpFUnordGreaterThanEqual"; + case OpShiftRightLogical: return "OpShiftRightLogical"; + case OpShiftRightArithmetic: return "OpShiftRightArithmetic"; + case OpShiftLeftLogical: return "OpShiftLeftLogical"; + case OpBitwiseOr: return "OpBitwiseOr"; + case OpBitwiseXor: return "OpBitwiseXor"; + case OpBitwiseAnd: return "OpBitwiseAnd"; + case OpNot: return "OpNot"; + case OpBitFieldInsert: return "OpBitFieldInsert"; + case OpBitFieldSExtract: return "OpBitFieldSExtract"; + case OpBitFieldUExtract: return "OpBitFieldUExtract"; + case OpBitReverse: return "OpBitReverse"; + case OpBitCount: return "OpBitCount"; + case OpDPdx: return "OpDPdx"; + case OpDPdy: return "OpDPdy"; + case OpFwidth: return "OpFwidth"; + case OpDPdxFine: return "OpDPdxFine"; + case OpDPdyFine: return "OpDPdyFine"; + case OpFwidthFine: return "OpFwidthFine"; + case OpDPdxCoarse: return "OpDPdxCoarse"; + case OpDPdyCoarse: return "OpDPdyCoarse"; + case OpFwidthCoarse: return "OpFwidthCoarse"; + case OpEmitVertex: return "OpEmitVertex"; + case OpEndPrimitive: return "OpEndPrimitive"; + case OpEmitStreamVertex: return "OpEmitStreamVertex"; + case OpEndStreamPrimitive: return "OpEndStreamPrimitive"; + case OpControlBarrier: return "OpControlBarrier"; + case OpMemoryBarrier: return "OpMemoryBarrier"; + case OpAtomicLoad: return "OpAtomicLoad"; + case OpAtomicStore: return "OpAtomicStore"; + case OpAtomicExchange: return "OpAtomicExchange"; + case OpAtomicCompareExchange: return "OpAtomicCompareExchange"; + case OpAtomicCompareExchangeWeak: return "OpAtomicCompareExchangeWeak"; + case OpAtomicIIncrement: return "OpAtomicIIncrement"; + case OpAtomicIDecrement: return "OpAtomicIDecrement"; + case OpAtomicIAdd: return "OpAtomicIAdd"; + case OpAtomicISub: return "OpAtomicISub"; + case OpAtomicSMin: return "OpAtomicSMin"; + case OpAtomicUMin: return "OpAtomicUMin"; + case OpAtomicSMax: return "OpAtomicSMax"; + case OpAtomicUMax: return "OpAtomicUMax"; + case OpAtomicAnd: return "OpAtomicAnd"; + case OpAtomicOr: return "OpAtomicOr"; + case OpAtomicXor: return "OpAtomicXor"; + case OpPhi: return "OpPhi"; + case OpLoopMerge: return "OpLoopMerge"; + case OpSelectionMerge: return "OpSelectionMerge"; + case OpLabel: return "OpLabel"; + case OpBranch: return "OpBranch"; + case OpBranchConditional: return "OpBranchConditional"; + case OpSwitch: return "OpSwitch"; + case OpKill: return "OpKill"; + case OpReturn: return "OpReturn"; + case OpReturnValue: return "OpReturnValue"; + case OpUnreachable: return "OpUnreachable"; + case OpLifetimeStart: return "OpLifetimeStart"; + case OpLifetimeStop: return "OpLifetimeStop"; + case OpGroupAsyncCopy: return "OpGroupAsyncCopy"; + case OpGroupWaitEvents: return "OpGroupWaitEvents"; + case OpGroupAll: return "OpGroupAll"; + case OpGroupAny: return "OpGroupAny"; + case OpGroupBroadcast: return "OpGroupBroadcast"; + case OpGroupIAdd: return "OpGroupIAdd"; + case OpGroupFAdd: return "OpGroupFAdd"; + case OpGroupFMin: return "OpGroupFMin"; + case OpGroupUMin: return "OpGroupUMin"; + case OpGroupSMin: return "OpGroupSMin"; + case OpGroupFMax: return "OpGroupFMax"; + case OpGroupUMax: return "OpGroupUMax"; + case OpGroupSMax: return "OpGroupSMax"; + case OpReadPipe: return "OpReadPipe"; + case OpWritePipe: return "OpWritePipe"; + case OpReservedReadPipe: return "OpReservedReadPipe"; + case OpReservedWritePipe: return "OpReservedWritePipe"; + case OpReserveReadPipePackets: return "OpReserveReadPipePackets"; + case OpReserveWritePipePackets: return "OpReserveWritePipePackets"; + case OpCommitReadPipe: return "OpCommitReadPipe"; + case OpCommitWritePipe: return "OpCommitWritePipe"; + case OpIsValidReserveId: return "OpIsValidReserveId"; + case OpGetNumPipePackets: return "OpGetNumPipePackets"; + case OpGetMaxPipePackets: return "OpGetMaxPipePackets"; + case OpGroupReserveReadPipePackets: return "OpGroupReserveReadPipePackets"; + case OpGroupReserveWritePipePackets: return "OpGroupReserveWritePipePackets"; + case OpGroupCommitReadPipe: return "OpGroupCommitReadPipe"; + case OpGroupCommitWritePipe: return "OpGroupCommitWritePipe"; + case OpEnqueueMarker: return "OpEnqueueMarker"; + case OpEnqueueKernel: return "OpEnqueueKernel"; + case OpGetKernelNDrangeSubGroupCount: return "OpGetKernelNDrangeSubGroupCount"; + case OpGetKernelNDrangeMaxSubGroupSize: return "OpGetKernelNDrangeMaxSubGroupSize"; + case OpGetKernelWorkGroupSize: return "OpGetKernelWorkGroupSize"; + case OpGetKernelPreferredWorkGroupSizeMultiple: return "OpGetKernelPreferredWorkGroupSizeMultiple"; + case OpRetainEvent: return "OpRetainEvent"; + case OpReleaseEvent: return "OpReleaseEvent"; + case OpCreateUserEvent: return "OpCreateUserEvent"; + case OpIsValidEvent: return "OpIsValidEvent"; + case OpSetUserEventStatus: return "OpSetUserEventStatus"; + case OpCaptureEventProfilingInfo: return "OpCaptureEventProfilingInfo"; + case OpGetDefaultQueue: return "OpGetDefaultQueue"; + case OpBuildNDRange: return "OpBuildNDRange"; + case OpImageSparseSampleImplicitLod: return "OpImageSparseSampleImplicitLod"; + case OpImageSparseSampleExplicitLod: return "OpImageSparseSampleExplicitLod"; + case OpImageSparseSampleDrefImplicitLod: return "OpImageSparseSampleDrefImplicitLod"; + case OpImageSparseSampleDrefExplicitLod: return "OpImageSparseSampleDrefExplicitLod"; + case OpImageSparseSampleProjImplicitLod: return "OpImageSparseSampleProjImplicitLod"; + case OpImageSparseSampleProjExplicitLod: return "OpImageSparseSampleProjExplicitLod"; + case OpImageSparseSampleProjDrefImplicitLod: return "OpImageSparseSampleProjDrefImplicitLod"; + case OpImageSparseSampleProjDrefExplicitLod: return "OpImageSparseSampleProjDrefExplicitLod"; + case OpImageSparseFetch: return "OpImageSparseFetch"; + case OpImageSparseGather: return "OpImageSparseGather"; + case OpImageSparseDrefGather: return "OpImageSparseDrefGather"; + case OpImageSparseTexelsResident: return "OpImageSparseTexelsResident"; + case OpNoLine: return "OpNoLine"; + case OpAtomicFlagTestAndSet: return "OpAtomicFlagTestAndSet"; + case OpAtomicFlagClear: return "OpAtomicFlagClear"; + case OpImageSparseRead: return "OpImageSparseRead"; + case OpSizeOf: return "OpSizeOf"; + case OpTypePipeStorage: return "OpTypePipeStorage"; + case OpConstantPipeStorage: return "OpConstantPipeStorage"; + case OpCreatePipeFromPipeStorage: return "OpCreatePipeFromPipeStorage"; + case OpGetKernelLocalSizeForSubgroupCount: return "OpGetKernelLocalSizeForSubgroupCount"; + case OpGetKernelMaxNumSubgroups: return "OpGetKernelMaxNumSubgroups"; + case OpTypeNamedBarrier: return "OpTypeNamedBarrier"; + case OpNamedBarrierInitialize: return "OpNamedBarrierInitialize"; + case OpMemoryNamedBarrier: return "OpMemoryNamedBarrier"; + case OpModuleProcessed: return "OpModuleProcessed"; + case OpExecutionModeId: return "OpExecutionModeId"; + case OpDecorateId: return "OpDecorateId"; + case OpGroupNonUniformElect: return "OpGroupNonUniformElect"; + case OpGroupNonUniformAll: return "OpGroupNonUniformAll"; + case OpGroupNonUniformAny: return "OpGroupNonUniformAny"; + case OpGroupNonUniformAllEqual: return "OpGroupNonUniformAllEqual"; + case OpGroupNonUniformBroadcast: return "OpGroupNonUniformBroadcast"; + case OpGroupNonUniformBroadcastFirst: return "OpGroupNonUniformBroadcastFirst"; + case OpGroupNonUniformBallot: return "OpGroupNonUniformBallot"; + case OpGroupNonUniformInverseBallot: return "OpGroupNonUniformInverseBallot"; + case OpGroupNonUniformBallotBitExtract: return "OpGroupNonUniformBallotBitExtract"; + case OpGroupNonUniformBallotBitCount: return "OpGroupNonUniformBallotBitCount"; + case OpGroupNonUniformBallotFindLSB: return "OpGroupNonUniformBallotFindLSB"; + case OpGroupNonUniformBallotFindMSB: return "OpGroupNonUniformBallotFindMSB"; + case OpGroupNonUniformShuffle: return "OpGroupNonUniformShuffle"; + case OpGroupNonUniformShuffleXor: return "OpGroupNonUniformShuffleXor"; + case OpGroupNonUniformShuffleUp: return "OpGroupNonUniformShuffleUp"; + case OpGroupNonUniformShuffleDown: return "OpGroupNonUniformShuffleDown"; + case OpGroupNonUniformIAdd: return "OpGroupNonUniformIAdd"; + case OpGroupNonUniformFAdd: return "OpGroupNonUniformFAdd"; + case OpGroupNonUniformIMul: return "OpGroupNonUniformIMul"; + case OpGroupNonUniformFMul: return "OpGroupNonUniformFMul"; + case OpGroupNonUniformSMin: return "OpGroupNonUniformSMin"; + case OpGroupNonUniformUMin: return "OpGroupNonUniformUMin"; + case OpGroupNonUniformFMin: return "OpGroupNonUniformFMin"; + case OpGroupNonUniformSMax: return "OpGroupNonUniformSMax"; + case OpGroupNonUniformUMax: return "OpGroupNonUniformUMax"; + case OpGroupNonUniformFMax: return "OpGroupNonUniformFMax"; + case OpGroupNonUniformBitwiseAnd: return "OpGroupNonUniformBitwiseAnd"; + case OpGroupNonUniformBitwiseOr: return "OpGroupNonUniformBitwiseOr"; + case OpGroupNonUniformBitwiseXor: return "OpGroupNonUniformBitwiseXor"; + case OpGroupNonUniformLogicalAnd: return "OpGroupNonUniformLogicalAnd"; + case OpGroupNonUniformLogicalOr: return "OpGroupNonUniformLogicalOr"; + case OpGroupNonUniformLogicalXor: return "OpGroupNonUniformLogicalXor"; + case OpGroupNonUniformQuadBroadcast: return "OpGroupNonUniformQuadBroadcast"; + case OpGroupNonUniformQuadSwap: return "OpGroupNonUniformQuadSwap"; + case OpCopyLogical: return "OpCopyLogical"; + case OpPtrEqual: return "OpPtrEqual"; + case OpPtrNotEqual: return "OpPtrNotEqual"; + case OpPtrDiff: return "OpPtrDiff"; + case OpColorAttachmentReadEXT: return "OpColorAttachmentReadEXT"; + case OpDepthAttachmentReadEXT: return "OpDepthAttachmentReadEXT"; + case OpStencilAttachmentReadEXT: return "OpStencilAttachmentReadEXT"; + case OpTerminateInvocation: return "OpTerminateInvocation"; + case OpTypeUntypedPointerKHR: return "OpTypeUntypedPointerKHR"; + case OpUntypedVariableKHR: return "OpUntypedVariableKHR"; + case OpUntypedAccessChainKHR: return "OpUntypedAccessChainKHR"; + case OpUntypedInBoundsAccessChainKHR: return "OpUntypedInBoundsAccessChainKHR"; + case OpSubgroupBallotKHR: return "OpSubgroupBallotKHR"; + case OpSubgroupFirstInvocationKHR: return "OpSubgroupFirstInvocationKHR"; + case OpUntypedPtrAccessChainKHR: return "OpUntypedPtrAccessChainKHR"; + case OpUntypedInBoundsPtrAccessChainKHR: return "OpUntypedInBoundsPtrAccessChainKHR"; + case OpUntypedArrayLengthKHR: return "OpUntypedArrayLengthKHR"; + case OpUntypedPrefetchKHR: return "OpUntypedPrefetchKHR"; + case OpSubgroupAllKHR: return "OpSubgroupAllKHR"; + case OpSubgroupAnyKHR: return "OpSubgroupAnyKHR"; + case OpSubgroupAllEqualKHR: return "OpSubgroupAllEqualKHR"; + case OpGroupNonUniformRotateKHR: return "OpGroupNonUniformRotateKHR"; + case OpSubgroupReadInvocationKHR: return "OpSubgroupReadInvocationKHR"; + case OpExtInstWithForwardRefsKHR: return "OpExtInstWithForwardRefsKHR"; + case OpTraceRayKHR: return "OpTraceRayKHR"; + case OpExecuteCallableKHR: return "OpExecuteCallableKHR"; + case OpConvertUToAccelerationStructureKHR: return "OpConvertUToAccelerationStructureKHR"; + case OpIgnoreIntersectionKHR: return "OpIgnoreIntersectionKHR"; + case OpTerminateRayKHR: return "OpTerminateRayKHR"; + case OpSDot: return "OpSDot"; + case OpUDot: return "OpUDot"; + case OpSUDot: return "OpSUDot"; + case OpSDotAccSat: return "OpSDotAccSat"; + case OpUDotAccSat: return "OpUDotAccSat"; + case OpSUDotAccSat: return "OpSUDotAccSat"; + case OpTypeCooperativeMatrixKHR: return "OpTypeCooperativeMatrixKHR"; + case OpCooperativeMatrixLoadKHR: return "OpCooperativeMatrixLoadKHR"; + case OpCooperativeMatrixStoreKHR: return "OpCooperativeMatrixStoreKHR"; + case OpCooperativeMatrixMulAddKHR: return "OpCooperativeMatrixMulAddKHR"; + case OpCooperativeMatrixLengthKHR: return "OpCooperativeMatrixLengthKHR"; + case OpConstantCompositeReplicateEXT: return "OpConstantCompositeReplicateEXT"; + case OpSpecConstantCompositeReplicateEXT: return "OpSpecConstantCompositeReplicateEXT"; + case OpCompositeConstructReplicateEXT: return "OpCompositeConstructReplicateEXT"; + case OpTypeRayQueryKHR: return "OpTypeRayQueryKHR"; + case OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR"; + case OpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR"; + case OpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR"; + case OpRayQueryConfirmIntersectionKHR: return "OpRayQueryConfirmIntersectionKHR"; + case OpRayQueryProceedKHR: return "OpRayQueryProceedKHR"; + case OpRayQueryGetIntersectionTypeKHR: return "OpRayQueryGetIntersectionTypeKHR"; + case OpImageSampleWeightedQCOM: return "OpImageSampleWeightedQCOM"; + case OpImageBoxFilterQCOM: return "OpImageBoxFilterQCOM"; + case OpImageBlockMatchSSDQCOM: return "OpImageBlockMatchSSDQCOM"; + case OpImageBlockMatchSADQCOM: return "OpImageBlockMatchSADQCOM"; + case OpImageBlockMatchWindowSSDQCOM: return "OpImageBlockMatchWindowSSDQCOM"; + case OpImageBlockMatchWindowSADQCOM: return "OpImageBlockMatchWindowSADQCOM"; + case OpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM"; + case OpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM"; + case OpGroupIAddNonUniformAMD: return "OpGroupIAddNonUniformAMD"; + case OpGroupFAddNonUniformAMD: return "OpGroupFAddNonUniformAMD"; + case OpGroupFMinNonUniformAMD: return "OpGroupFMinNonUniformAMD"; + case OpGroupUMinNonUniformAMD: return "OpGroupUMinNonUniformAMD"; + case OpGroupSMinNonUniformAMD: return "OpGroupSMinNonUniformAMD"; + case OpGroupFMaxNonUniformAMD: return "OpGroupFMaxNonUniformAMD"; + case OpGroupUMaxNonUniformAMD: return "OpGroupUMaxNonUniformAMD"; + case OpGroupSMaxNonUniformAMD: return "OpGroupSMaxNonUniformAMD"; + case OpFragmentMaskFetchAMD: return "OpFragmentMaskFetchAMD"; + case OpFragmentFetchAMD: return "OpFragmentFetchAMD"; + case OpReadClockKHR: return "OpReadClockKHR"; + case OpAllocateNodePayloadsAMDX: return "OpAllocateNodePayloadsAMDX"; + case OpEnqueueNodePayloadsAMDX: return "OpEnqueueNodePayloadsAMDX"; + case OpTypeNodePayloadArrayAMDX: return "OpTypeNodePayloadArrayAMDX"; + case OpFinishWritingNodePayloadAMDX: return "OpFinishWritingNodePayloadAMDX"; + case OpNodePayloadArrayLengthAMDX: return "OpNodePayloadArrayLengthAMDX"; + case OpIsNodePayloadValidAMDX: return "OpIsNodePayloadValidAMDX"; + case OpConstantStringAMDX: return "OpConstantStringAMDX"; + case OpSpecConstantStringAMDX: return "OpSpecConstantStringAMDX"; + case OpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; + case OpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; + case OpHitObjectRecordHitMotionNV: return "OpHitObjectRecordHitMotionNV"; + case OpHitObjectRecordHitWithIndexMotionNV: return "OpHitObjectRecordHitWithIndexMotionNV"; + case OpHitObjectRecordMissMotionNV: return "OpHitObjectRecordMissMotionNV"; + case OpHitObjectGetWorldToObjectNV: return "OpHitObjectGetWorldToObjectNV"; + case OpHitObjectGetObjectToWorldNV: return "OpHitObjectGetObjectToWorldNV"; + case OpHitObjectGetObjectRayDirectionNV: return "OpHitObjectGetObjectRayDirectionNV"; + case OpHitObjectGetObjectRayOriginNV: return "OpHitObjectGetObjectRayOriginNV"; + case OpHitObjectTraceRayMotionNV: return "OpHitObjectTraceRayMotionNV"; + case OpHitObjectGetShaderRecordBufferHandleNV: return "OpHitObjectGetShaderRecordBufferHandleNV"; + case OpHitObjectGetShaderBindingTableRecordIndexNV: return "OpHitObjectGetShaderBindingTableRecordIndexNV"; + case OpHitObjectRecordEmptyNV: return "OpHitObjectRecordEmptyNV"; + case OpHitObjectTraceRayNV: return "OpHitObjectTraceRayNV"; + case OpHitObjectRecordHitNV: return "OpHitObjectRecordHitNV"; + case OpHitObjectRecordHitWithIndexNV: return "OpHitObjectRecordHitWithIndexNV"; + case OpHitObjectRecordMissNV: return "OpHitObjectRecordMissNV"; + case OpHitObjectExecuteShaderNV: return "OpHitObjectExecuteShaderNV"; + case OpHitObjectGetCurrentTimeNV: return "OpHitObjectGetCurrentTimeNV"; + case OpHitObjectGetAttributesNV: return "OpHitObjectGetAttributesNV"; + case OpHitObjectGetHitKindNV: return "OpHitObjectGetHitKindNV"; + case OpHitObjectGetPrimitiveIndexNV: return "OpHitObjectGetPrimitiveIndexNV"; + case OpHitObjectGetGeometryIndexNV: return "OpHitObjectGetGeometryIndexNV"; + case OpHitObjectGetInstanceIdNV: return "OpHitObjectGetInstanceIdNV"; + case OpHitObjectGetInstanceCustomIndexNV: return "OpHitObjectGetInstanceCustomIndexNV"; + case OpHitObjectGetWorldRayDirectionNV: return "OpHitObjectGetWorldRayDirectionNV"; + case OpHitObjectGetWorldRayOriginNV: return "OpHitObjectGetWorldRayOriginNV"; + case OpHitObjectGetRayTMaxNV: return "OpHitObjectGetRayTMaxNV"; + case OpHitObjectGetRayTMinNV: return "OpHitObjectGetRayTMinNV"; + case OpHitObjectIsEmptyNV: return "OpHitObjectIsEmptyNV"; + case OpHitObjectIsHitNV: return "OpHitObjectIsHitNV"; + case OpHitObjectIsMissNV: return "OpHitObjectIsMissNV"; + case OpReorderThreadWithHitObjectNV: return "OpReorderThreadWithHitObjectNV"; + case OpReorderThreadWithHintNV: return "OpReorderThreadWithHintNV"; + case OpTypeHitObjectNV: return "OpTypeHitObjectNV"; + case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV"; + case OpTypeCooperativeVectorNV: return "OpTypeCooperativeVectorNV"; + case OpCooperativeVectorMatrixMulNV: return "OpCooperativeVectorMatrixMulNV"; + case OpCooperativeVectorOuterProductAccumulateNV: return "OpCooperativeVectorOuterProductAccumulateNV"; + case OpCooperativeVectorReduceSumAccumulateNV: return "OpCooperativeVectorReduceSumAccumulateNV"; + case OpCooperativeVectorMatrixMulAddNV: return "OpCooperativeVectorMatrixMulAddNV"; + case OpCooperativeMatrixConvertNV: return "OpCooperativeMatrixConvertNV"; + case OpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT"; + case OpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT"; + case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; + case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; + case OpFetchMicroTriangleVertexPositionNV: return "OpFetchMicroTriangleVertexPositionNV"; + case OpFetchMicroTriangleVertexBarycentricNV: return "OpFetchMicroTriangleVertexBarycentricNV"; + case OpCooperativeVectorLoadNV: return "OpCooperativeVectorLoadNV"; + case OpCooperativeVectorStoreNV: return "OpCooperativeVectorStoreNV"; + case OpReportIntersectionKHR: return "OpReportIntersectionKHR"; + case OpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV"; + case OpTerminateRayNV: return "OpTerminateRayNV"; + case OpTraceNV: return "OpTraceNV"; + case OpTraceMotionNV: return "OpTraceMotionNV"; + case OpTraceRayMotionNV: return "OpTraceRayMotionNV"; + case OpRayQueryGetIntersectionTriangleVertexPositionsKHR: return "OpRayQueryGetIntersectionTriangleVertexPositionsKHR"; + case OpTypeAccelerationStructureKHR: return "OpTypeAccelerationStructureKHR"; + case OpExecuteCallableNV: return "OpExecuteCallableNV"; + case OpRayQueryGetClusterIdNV: return "OpRayQueryGetClusterIdNV"; + case OpHitObjectGetClusterIdNV: return "OpHitObjectGetClusterIdNV"; + case OpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV"; + case OpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV"; + case OpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV"; + case OpCooperativeMatrixMulAddNV: return "OpCooperativeMatrixMulAddNV"; + case OpCooperativeMatrixLengthNV: return "OpCooperativeMatrixLengthNV"; + case OpBeginInvocationInterlockEXT: return "OpBeginInvocationInterlockEXT"; + case OpEndInvocationInterlockEXT: return "OpEndInvocationInterlockEXT"; + case OpCooperativeMatrixReduceNV: return "OpCooperativeMatrixReduceNV"; + case OpCooperativeMatrixLoadTensorNV: return "OpCooperativeMatrixLoadTensorNV"; + case OpCooperativeMatrixStoreTensorNV: return "OpCooperativeMatrixStoreTensorNV"; + case OpCooperativeMatrixPerElementOpNV: return "OpCooperativeMatrixPerElementOpNV"; + case OpTypeTensorLayoutNV: return "OpTypeTensorLayoutNV"; + case OpTypeTensorViewNV: return "OpTypeTensorViewNV"; + case OpCreateTensorLayoutNV: return "OpCreateTensorLayoutNV"; + case OpTensorLayoutSetDimensionNV: return "OpTensorLayoutSetDimensionNV"; + case OpTensorLayoutSetStrideNV: return "OpTensorLayoutSetStrideNV"; + case OpTensorLayoutSliceNV: return "OpTensorLayoutSliceNV"; + case OpTensorLayoutSetClampValueNV: return "OpTensorLayoutSetClampValueNV"; + case OpCreateTensorViewNV: return "OpCreateTensorViewNV"; + case OpTensorViewSetDimensionNV: return "OpTensorViewSetDimensionNV"; + case OpTensorViewSetStrideNV: return "OpTensorViewSetStrideNV"; + case OpDemoteToHelperInvocation: return "OpDemoteToHelperInvocation"; + case OpIsHelperInvocationEXT: return "OpIsHelperInvocationEXT"; + case OpTensorViewSetClipNV: return "OpTensorViewSetClipNV"; + case OpTensorLayoutSetBlockSizeNV: return "OpTensorLayoutSetBlockSizeNV"; + case OpCooperativeMatrixTransposeNV: return "OpCooperativeMatrixTransposeNV"; + case OpConvertUToImageNV: return "OpConvertUToImageNV"; + case OpConvertUToSamplerNV: return "OpConvertUToSamplerNV"; + case OpConvertImageToUNV: return "OpConvertImageToUNV"; + case OpConvertSamplerToUNV: return "OpConvertSamplerToUNV"; + case OpConvertUToSampledImageNV: return "OpConvertUToSampledImageNV"; + case OpConvertSampledImageToUNV: return "OpConvertSampledImageToUNV"; + case OpSamplerImageAddressingModeNV: return "OpSamplerImageAddressingModeNV"; + case OpRawAccessChainNV: return "OpRawAccessChainNV"; + case OpRayQueryGetIntersectionSpherePositionNV: return "OpRayQueryGetIntersectionSpherePositionNV"; + case OpRayQueryGetIntersectionSphereRadiusNV: return "OpRayQueryGetIntersectionSphereRadiusNV"; + case OpRayQueryGetIntersectionLSSPositionsNV: return "OpRayQueryGetIntersectionLSSPositionsNV"; + case OpRayQueryGetIntersectionLSSRadiiNV: return "OpRayQueryGetIntersectionLSSRadiiNV"; + case OpRayQueryGetIntersectionLSSHitValueNV: return "OpRayQueryGetIntersectionLSSHitValueNV"; + case OpHitObjectGetSpherePositionNV: return "OpHitObjectGetSpherePositionNV"; + case OpHitObjectGetSphereRadiusNV: return "OpHitObjectGetSphereRadiusNV"; + case OpHitObjectGetLSSPositionsNV: return "OpHitObjectGetLSSPositionsNV"; + case OpHitObjectGetLSSRadiiNV: return "OpHitObjectGetLSSRadiiNV"; + case OpHitObjectIsSphereHitNV: return "OpHitObjectIsSphereHitNV"; + case OpHitObjectIsLSSHitNV: return "OpHitObjectIsLSSHitNV"; + case OpRayQueryIsSphereHitNV: return "OpRayQueryIsSphereHitNV"; + case OpRayQueryIsLSSHitNV: return "OpRayQueryIsLSSHitNV"; + case OpSubgroupShuffleINTEL: return "OpSubgroupShuffleINTEL"; + case OpSubgroupShuffleDownINTEL: return "OpSubgroupShuffleDownINTEL"; + case OpSubgroupShuffleUpINTEL: return "OpSubgroupShuffleUpINTEL"; + case OpSubgroupShuffleXorINTEL: return "OpSubgroupShuffleXorINTEL"; + case OpSubgroupBlockReadINTEL: return "OpSubgroupBlockReadINTEL"; + case OpSubgroupBlockWriteINTEL: return "OpSubgroupBlockWriteINTEL"; + case OpSubgroupImageBlockReadINTEL: return "OpSubgroupImageBlockReadINTEL"; + case OpSubgroupImageBlockWriteINTEL: return "OpSubgroupImageBlockWriteINTEL"; + case OpSubgroupImageMediaBlockReadINTEL: return "OpSubgroupImageMediaBlockReadINTEL"; + case OpSubgroupImageMediaBlockWriteINTEL: return "OpSubgroupImageMediaBlockWriteINTEL"; + case OpUCountLeadingZerosINTEL: return "OpUCountLeadingZerosINTEL"; + case OpUCountTrailingZerosINTEL: return "OpUCountTrailingZerosINTEL"; + case OpAbsISubINTEL: return "OpAbsISubINTEL"; + case OpAbsUSubINTEL: return "OpAbsUSubINTEL"; + case OpIAddSatINTEL: return "OpIAddSatINTEL"; + case OpUAddSatINTEL: return "OpUAddSatINTEL"; + case OpIAverageINTEL: return "OpIAverageINTEL"; + case OpUAverageINTEL: return "OpUAverageINTEL"; + case OpIAverageRoundedINTEL: return "OpIAverageRoundedINTEL"; + case OpUAverageRoundedINTEL: return "OpUAverageRoundedINTEL"; + case OpISubSatINTEL: return "OpISubSatINTEL"; + case OpUSubSatINTEL: return "OpUSubSatINTEL"; + case OpIMul32x16INTEL: return "OpIMul32x16INTEL"; + case OpUMul32x16INTEL: return "OpUMul32x16INTEL"; + case OpConstantFunctionPointerINTEL: return "OpConstantFunctionPointerINTEL"; + case OpFunctionPointerCallINTEL: return "OpFunctionPointerCallINTEL"; + case OpAsmTargetINTEL: return "OpAsmTargetINTEL"; + case OpAsmINTEL: return "OpAsmINTEL"; + case OpAsmCallINTEL: return "OpAsmCallINTEL"; + case OpAtomicFMinEXT: return "OpAtomicFMinEXT"; + case OpAtomicFMaxEXT: return "OpAtomicFMaxEXT"; + case OpAssumeTrueKHR: return "OpAssumeTrueKHR"; + case OpExpectKHR: return "OpExpectKHR"; + case OpDecorateString: return "OpDecorateString"; + case OpMemberDecorateString: return "OpMemberDecorateString"; + case OpVmeImageINTEL: return "OpVmeImageINTEL"; + case OpTypeVmeImageINTEL: return "OpTypeVmeImageINTEL"; + case OpTypeAvcImePayloadINTEL: return "OpTypeAvcImePayloadINTEL"; + case OpTypeAvcRefPayloadINTEL: return "OpTypeAvcRefPayloadINTEL"; + case OpTypeAvcSicPayloadINTEL: return "OpTypeAvcSicPayloadINTEL"; + case OpTypeAvcMcePayloadINTEL: return "OpTypeAvcMcePayloadINTEL"; + case OpTypeAvcMceResultINTEL: return "OpTypeAvcMceResultINTEL"; + case OpTypeAvcImeResultINTEL: return "OpTypeAvcImeResultINTEL"; + case OpTypeAvcImeResultSingleReferenceStreamoutINTEL: return "OpTypeAvcImeResultSingleReferenceStreamoutINTEL"; + case OpTypeAvcImeResultDualReferenceStreamoutINTEL: return "OpTypeAvcImeResultDualReferenceStreamoutINTEL"; + case OpTypeAvcImeSingleReferenceStreaminINTEL: return "OpTypeAvcImeSingleReferenceStreaminINTEL"; + case OpTypeAvcImeDualReferenceStreaminINTEL: return "OpTypeAvcImeDualReferenceStreaminINTEL"; + case OpTypeAvcRefResultINTEL: return "OpTypeAvcRefResultINTEL"; + case OpTypeAvcSicResultINTEL: return "OpTypeAvcSicResultINTEL"; + case OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL"; + case OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL"; + case OpSubgroupAvcMceSetInterShapePenaltyINTEL: return "OpSubgroupAvcMceSetInterShapePenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL"; + case OpSubgroupAvcMceSetInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceSetInterDirectionPenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL: return "OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL"; + case OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL"; + case OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL"; + case OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL"; + case OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL: return "OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL"; + case OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL"; + case OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL"; + case OpSubgroupAvcMceSetAcOnlyHaarINTEL: return "OpSubgroupAvcMceSetAcOnlyHaarINTEL"; + case OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL"; + case OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL"; + case OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL"; + case OpSubgroupAvcMceConvertToImePayloadINTEL: return "OpSubgroupAvcMceConvertToImePayloadINTEL"; + case OpSubgroupAvcMceConvertToImeResultINTEL: return "OpSubgroupAvcMceConvertToImeResultINTEL"; + case OpSubgroupAvcMceConvertToRefPayloadINTEL: return "OpSubgroupAvcMceConvertToRefPayloadINTEL"; + case OpSubgroupAvcMceConvertToRefResultINTEL: return "OpSubgroupAvcMceConvertToRefResultINTEL"; + case OpSubgroupAvcMceConvertToSicPayloadINTEL: return "OpSubgroupAvcMceConvertToSicPayloadINTEL"; + case OpSubgroupAvcMceConvertToSicResultINTEL: return "OpSubgroupAvcMceConvertToSicResultINTEL"; + case OpSubgroupAvcMceGetMotionVectorsINTEL: return "OpSubgroupAvcMceGetMotionVectorsINTEL"; + case OpSubgroupAvcMceGetInterDistortionsINTEL: return "OpSubgroupAvcMceGetInterDistortionsINTEL"; + case OpSubgroupAvcMceGetBestInterDistortionsINTEL: return "OpSubgroupAvcMceGetBestInterDistortionsINTEL"; + case OpSubgroupAvcMceGetInterMajorShapeINTEL: return "OpSubgroupAvcMceGetInterMajorShapeINTEL"; + case OpSubgroupAvcMceGetInterMinorShapeINTEL: return "OpSubgroupAvcMceGetInterMinorShapeINTEL"; + case OpSubgroupAvcMceGetInterDirectionsINTEL: return "OpSubgroupAvcMceGetInterDirectionsINTEL"; + case OpSubgroupAvcMceGetInterMotionVectorCountINTEL: return "OpSubgroupAvcMceGetInterMotionVectorCountINTEL"; + case OpSubgroupAvcMceGetInterReferenceIdsINTEL: return "OpSubgroupAvcMceGetInterReferenceIdsINTEL"; + case OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL"; + case OpSubgroupAvcImeInitializeINTEL: return "OpSubgroupAvcImeInitializeINTEL"; + case OpSubgroupAvcImeSetSingleReferenceINTEL: return "OpSubgroupAvcImeSetSingleReferenceINTEL"; + case OpSubgroupAvcImeSetDualReferenceINTEL: return "OpSubgroupAvcImeSetDualReferenceINTEL"; + case OpSubgroupAvcImeRefWindowSizeINTEL: return "OpSubgroupAvcImeRefWindowSizeINTEL"; + case OpSubgroupAvcImeAdjustRefOffsetINTEL: return "OpSubgroupAvcImeAdjustRefOffsetINTEL"; + case OpSubgroupAvcImeConvertToMcePayloadINTEL: return "OpSubgroupAvcImeConvertToMcePayloadINTEL"; + case OpSubgroupAvcImeSetMaxMotionVectorCountINTEL: return "OpSubgroupAvcImeSetMaxMotionVectorCountINTEL"; + case OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL: return "OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL"; + case OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL: return "OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL"; + case OpSubgroupAvcImeSetWeightedSadINTEL: return "OpSubgroupAvcImeSetWeightedSadINTEL"; + case OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL"; + case OpSubgroupAvcImeEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceINTEL"; + case OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL"; + case OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL"; + case OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL"; + case OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL"; + case OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL"; + case OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL"; + case OpSubgroupAvcImeConvertToMceResultINTEL: return "OpSubgroupAvcImeConvertToMceResultINTEL"; + case OpSubgroupAvcImeGetSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeGetSingleReferenceStreaminINTEL"; + case OpSubgroupAvcImeGetDualReferenceStreaminINTEL: return "OpSubgroupAvcImeGetDualReferenceStreaminINTEL"; + case OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL"; + case OpSubgroupAvcImeStripDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripDualReferenceStreamoutINTEL"; + case OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL"; + case OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL"; + case OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL"; + case OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL"; + case OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL"; + case OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL"; + case OpSubgroupAvcImeGetBorderReachedINTEL: return "OpSubgroupAvcImeGetBorderReachedINTEL"; + case OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL: return "OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL"; + case OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL: return "OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL"; + case OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL"; + case OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL"; + case OpSubgroupAvcFmeInitializeINTEL: return "OpSubgroupAvcFmeInitializeINTEL"; + case OpSubgroupAvcBmeInitializeINTEL: return "OpSubgroupAvcBmeInitializeINTEL"; + case OpSubgroupAvcRefConvertToMcePayloadINTEL: return "OpSubgroupAvcRefConvertToMcePayloadINTEL"; + case OpSubgroupAvcRefSetBidirectionalMixDisableINTEL: return "OpSubgroupAvcRefSetBidirectionalMixDisableINTEL"; + case OpSubgroupAvcRefSetBilinearFilterEnableINTEL: return "OpSubgroupAvcRefSetBilinearFilterEnableINTEL"; + case OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL"; + case OpSubgroupAvcRefEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithDualReferenceINTEL"; + case OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL"; + case OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL"; + case OpSubgroupAvcRefConvertToMceResultINTEL: return "OpSubgroupAvcRefConvertToMceResultINTEL"; + case OpSubgroupAvcSicInitializeINTEL: return "OpSubgroupAvcSicInitializeINTEL"; + case OpSubgroupAvcSicConfigureSkcINTEL: return "OpSubgroupAvcSicConfigureSkcINTEL"; + case OpSubgroupAvcSicConfigureIpeLumaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaINTEL"; + case OpSubgroupAvcSicConfigureIpeLumaChromaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaChromaINTEL"; + case OpSubgroupAvcSicGetMotionVectorMaskINTEL: return "OpSubgroupAvcSicGetMotionVectorMaskINTEL"; + case OpSubgroupAvcSicConvertToMcePayloadINTEL: return "OpSubgroupAvcSicConvertToMcePayloadINTEL"; + case OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL"; + case OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL"; + case OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL"; + case OpSubgroupAvcSicSetBilinearFilterEnableINTEL: return "OpSubgroupAvcSicSetBilinearFilterEnableINTEL"; + case OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL: return "OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL"; + case OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL: return "OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL"; + case OpSubgroupAvcSicEvaluateIpeINTEL: return "OpSubgroupAvcSicEvaluateIpeINTEL"; + case OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL"; + case OpSubgroupAvcSicEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithDualReferenceINTEL"; + case OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL"; + case OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL"; + case OpSubgroupAvcSicConvertToMceResultINTEL: return "OpSubgroupAvcSicConvertToMceResultINTEL"; + case OpSubgroupAvcSicGetIpeLumaShapeINTEL: return "OpSubgroupAvcSicGetIpeLumaShapeINTEL"; + case OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL"; + case OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL"; + case OpSubgroupAvcSicGetPackedIpeLumaModesINTEL: return "OpSubgroupAvcSicGetPackedIpeLumaModesINTEL"; + case OpSubgroupAvcSicGetIpeChromaModeINTEL: return "OpSubgroupAvcSicGetIpeChromaModeINTEL"; + case OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL"; + case OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL"; + case OpSubgroupAvcSicGetInterRawSadsINTEL: return "OpSubgroupAvcSicGetInterRawSadsINTEL"; + case OpVariableLengthArrayINTEL: return "OpVariableLengthArrayINTEL"; + case OpSaveMemoryINTEL: return "OpSaveMemoryINTEL"; + case OpRestoreMemoryINTEL: return "OpRestoreMemoryINTEL"; + case OpArbitraryFloatSinCosPiINTEL: return "OpArbitraryFloatSinCosPiINTEL"; + case OpArbitraryFloatCastINTEL: return "OpArbitraryFloatCastINTEL"; + case OpArbitraryFloatCastFromIntINTEL: return "OpArbitraryFloatCastFromIntINTEL"; + case OpArbitraryFloatCastToIntINTEL: return "OpArbitraryFloatCastToIntINTEL"; + case OpArbitraryFloatAddINTEL: return "OpArbitraryFloatAddINTEL"; + case OpArbitraryFloatSubINTEL: return "OpArbitraryFloatSubINTEL"; + case OpArbitraryFloatMulINTEL: return "OpArbitraryFloatMulINTEL"; + case OpArbitraryFloatDivINTEL: return "OpArbitraryFloatDivINTEL"; + case OpArbitraryFloatGTINTEL: return "OpArbitraryFloatGTINTEL"; + case OpArbitraryFloatGEINTEL: return "OpArbitraryFloatGEINTEL"; + case OpArbitraryFloatLTINTEL: return "OpArbitraryFloatLTINTEL"; + case OpArbitraryFloatLEINTEL: return "OpArbitraryFloatLEINTEL"; + case OpArbitraryFloatEQINTEL: return "OpArbitraryFloatEQINTEL"; + case OpArbitraryFloatRecipINTEL: return "OpArbitraryFloatRecipINTEL"; + case OpArbitraryFloatRSqrtINTEL: return "OpArbitraryFloatRSqrtINTEL"; + case OpArbitraryFloatCbrtINTEL: return "OpArbitraryFloatCbrtINTEL"; + case OpArbitraryFloatHypotINTEL: return "OpArbitraryFloatHypotINTEL"; + case OpArbitraryFloatSqrtINTEL: return "OpArbitraryFloatSqrtINTEL"; + case OpArbitraryFloatLogINTEL: return "OpArbitraryFloatLogINTEL"; + case OpArbitraryFloatLog2INTEL: return "OpArbitraryFloatLog2INTEL"; + case OpArbitraryFloatLog10INTEL: return "OpArbitraryFloatLog10INTEL"; + case OpArbitraryFloatLog1pINTEL: return "OpArbitraryFloatLog1pINTEL"; + case OpArbitraryFloatExpINTEL: return "OpArbitraryFloatExpINTEL"; + case OpArbitraryFloatExp2INTEL: return "OpArbitraryFloatExp2INTEL"; + case OpArbitraryFloatExp10INTEL: return "OpArbitraryFloatExp10INTEL"; + case OpArbitraryFloatExpm1INTEL: return "OpArbitraryFloatExpm1INTEL"; + case OpArbitraryFloatSinINTEL: return "OpArbitraryFloatSinINTEL"; + case OpArbitraryFloatCosINTEL: return "OpArbitraryFloatCosINTEL"; + case OpArbitraryFloatSinCosINTEL: return "OpArbitraryFloatSinCosINTEL"; + case OpArbitraryFloatSinPiINTEL: return "OpArbitraryFloatSinPiINTEL"; + case OpArbitraryFloatCosPiINTEL: return "OpArbitraryFloatCosPiINTEL"; + case OpArbitraryFloatASinINTEL: return "OpArbitraryFloatASinINTEL"; + case OpArbitraryFloatASinPiINTEL: return "OpArbitraryFloatASinPiINTEL"; + case OpArbitraryFloatACosINTEL: return "OpArbitraryFloatACosINTEL"; + case OpArbitraryFloatACosPiINTEL: return "OpArbitraryFloatACosPiINTEL"; + case OpArbitraryFloatATanINTEL: return "OpArbitraryFloatATanINTEL"; + case OpArbitraryFloatATanPiINTEL: return "OpArbitraryFloatATanPiINTEL"; + case OpArbitraryFloatATan2INTEL: return "OpArbitraryFloatATan2INTEL"; + case OpArbitraryFloatPowINTEL: return "OpArbitraryFloatPowINTEL"; + case OpArbitraryFloatPowRINTEL: return "OpArbitraryFloatPowRINTEL"; + case OpArbitraryFloatPowNINTEL: return "OpArbitraryFloatPowNINTEL"; + case OpLoopControlINTEL: return "OpLoopControlINTEL"; + case OpAliasDomainDeclINTEL: return "OpAliasDomainDeclINTEL"; + case OpAliasScopeDeclINTEL: return "OpAliasScopeDeclINTEL"; + case OpAliasScopeListDeclINTEL: return "OpAliasScopeListDeclINTEL"; + case OpFixedSqrtINTEL: return "OpFixedSqrtINTEL"; + case OpFixedRecipINTEL: return "OpFixedRecipINTEL"; + case OpFixedRsqrtINTEL: return "OpFixedRsqrtINTEL"; + case OpFixedSinINTEL: return "OpFixedSinINTEL"; + case OpFixedCosINTEL: return "OpFixedCosINTEL"; + case OpFixedSinCosINTEL: return "OpFixedSinCosINTEL"; + case OpFixedSinPiINTEL: return "OpFixedSinPiINTEL"; + case OpFixedCosPiINTEL: return "OpFixedCosPiINTEL"; + case OpFixedSinCosPiINTEL: return "OpFixedSinCosPiINTEL"; + case OpFixedLogINTEL: return "OpFixedLogINTEL"; + case OpFixedExpINTEL: return "OpFixedExpINTEL"; + case OpPtrCastToCrossWorkgroupINTEL: return "OpPtrCastToCrossWorkgroupINTEL"; + case OpCrossWorkgroupCastToPtrINTEL: return "OpCrossWorkgroupCastToPtrINTEL"; + case OpReadPipeBlockingINTEL: return "OpReadPipeBlockingINTEL"; + case OpWritePipeBlockingINTEL: return "OpWritePipeBlockingINTEL"; + case OpFPGARegINTEL: return "OpFPGARegINTEL"; + case OpRayQueryGetRayTMinKHR: return "OpRayQueryGetRayTMinKHR"; + case OpRayQueryGetRayFlagsKHR: return "OpRayQueryGetRayFlagsKHR"; + case OpRayQueryGetIntersectionTKHR: return "OpRayQueryGetIntersectionTKHR"; + case OpRayQueryGetIntersectionInstanceCustomIndexKHR: return "OpRayQueryGetIntersectionInstanceCustomIndexKHR"; + case OpRayQueryGetIntersectionInstanceIdKHR: return "OpRayQueryGetIntersectionInstanceIdKHR"; + case OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR: return "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR"; + case OpRayQueryGetIntersectionGeometryIndexKHR: return "OpRayQueryGetIntersectionGeometryIndexKHR"; + case OpRayQueryGetIntersectionPrimitiveIndexKHR: return "OpRayQueryGetIntersectionPrimitiveIndexKHR"; + case OpRayQueryGetIntersectionBarycentricsKHR: return "OpRayQueryGetIntersectionBarycentricsKHR"; + case OpRayQueryGetIntersectionFrontFaceKHR: return "OpRayQueryGetIntersectionFrontFaceKHR"; + case OpRayQueryGetIntersectionCandidateAABBOpaqueKHR: return "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR"; + case OpRayQueryGetIntersectionObjectRayDirectionKHR: return "OpRayQueryGetIntersectionObjectRayDirectionKHR"; + case OpRayQueryGetIntersectionObjectRayOriginKHR: return "OpRayQueryGetIntersectionObjectRayOriginKHR"; + case OpRayQueryGetWorldRayDirectionKHR: return "OpRayQueryGetWorldRayDirectionKHR"; + case OpRayQueryGetWorldRayOriginKHR: return "OpRayQueryGetWorldRayOriginKHR"; + case OpRayQueryGetIntersectionObjectToWorldKHR: return "OpRayQueryGetIntersectionObjectToWorldKHR"; + case OpRayQueryGetIntersectionWorldToObjectKHR: return "OpRayQueryGetIntersectionWorldToObjectKHR"; + case OpAtomicFAddEXT: return "OpAtomicFAddEXT"; + case OpTypeBufferSurfaceINTEL: return "OpTypeBufferSurfaceINTEL"; + case OpTypeStructContinuedINTEL: return "OpTypeStructContinuedINTEL"; + case OpConstantCompositeContinuedINTEL: return "OpConstantCompositeContinuedINTEL"; + case OpSpecConstantCompositeContinuedINTEL: return "OpSpecConstantCompositeContinuedINTEL"; + case OpCompositeConstructContinuedINTEL: return "OpCompositeConstructContinuedINTEL"; + case OpConvertFToBF16INTEL: return "OpConvertFToBF16INTEL"; + case OpConvertBF16ToFINTEL: return "OpConvertBF16ToFINTEL"; + case OpControlBarrierArriveINTEL: return "OpControlBarrierArriveINTEL"; + case OpControlBarrierWaitINTEL: return "OpControlBarrierWaitINTEL"; + case OpArithmeticFenceEXT: return "OpArithmeticFenceEXT"; + case OpSubgroupBlockPrefetchINTEL: return "OpSubgroupBlockPrefetchINTEL"; + case OpSubgroup2DBlockLoadINTEL: return "OpSubgroup2DBlockLoadINTEL"; + case OpSubgroup2DBlockLoadTransformINTEL: return "OpSubgroup2DBlockLoadTransformINTEL"; + case OpSubgroup2DBlockLoadTransposeINTEL: return "OpSubgroup2DBlockLoadTransposeINTEL"; + case OpSubgroup2DBlockPrefetchINTEL: return "OpSubgroup2DBlockPrefetchINTEL"; + case OpSubgroup2DBlockStoreINTEL: return "OpSubgroup2DBlockStoreINTEL"; + case OpSubgroupMatrixMultiplyAccumulateINTEL: return "OpSubgroupMatrixMultiplyAccumulateINTEL"; + case OpGroupIMulKHR: return "OpGroupIMulKHR"; + case OpGroupFMulKHR: return "OpGroupFMulKHR"; + case OpGroupBitwiseAndKHR: return "OpGroupBitwiseAndKHR"; + case OpGroupBitwiseOrKHR: return "OpGroupBitwiseOrKHR"; + case OpGroupBitwiseXorKHR: return "OpGroupBitwiseXorKHR"; + case OpGroupLogicalAndKHR: return "OpGroupLogicalAndKHR"; + case OpGroupLogicalOrKHR: return "OpGroupLogicalOrKHR"; + case OpGroupLogicalXorKHR: return "OpGroupLogicalXorKHR"; + case OpMaskedGatherINTEL: return "OpMaskedGatherINTEL"; + case OpMaskedScatterINTEL: return "OpMaskedScatterINTEL"; + default: return "Unknown"; + } +} + #endif /* SPV_ENABLE_UTILITY_CODE */ // Overload bitwise operators for mask bit combining @@ -2693,6 +5127,26 @@ inline FragmentShadingRateMask operator|(FragmentShadingRateMask a, FragmentShad inline FragmentShadingRateMask operator&(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) & unsigned(b)); } inline FragmentShadingRateMask operator^(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) ^ unsigned(b)); } inline FragmentShadingRateMask operator~(FragmentShadingRateMask a) { return FragmentShadingRateMask(~unsigned(a)); } +inline CooperativeMatrixOperandsMask operator|(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) | unsigned(b)); } +inline CooperativeMatrixOperandsMask operator&(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) & unsigned(b)); } +inline CooperativeMatrixOperandsMask operator^(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) ^ unsigned(b)); } +inline CooperativeMatrixOperandsMask operator~(CooperativeMatrixOperandsMask a) { return CooperativeMatrixOperandsMask(~unsigned(a)); } +inline CooperativeMatrixReduceMask operator|(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) | unsigned(b)); } +inline CooperativeMatrixReduceMask operator&(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) & unsigned(b)); } +inline CooperativeMatrixReduceMask operator^(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) ^ unsigned(b)); } +inline CooperativeMatrixReduceMask operator~(CooperativeMatrixReduceMask a) { return CooperativeMatrixReduceMask(~unsigned(a)); } +inline TensorAddressingOperandsMask operator|(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) | unsigned(b)); } +inline TensorAddressingOperandsMask operator&(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) & unsigned(b)); } +inline TensorAddressingOperandsMask operator^(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) ^ unsigned(b)); } +inline TensorAddressingOperandsMask operator~(TensorAddressingOperandsMask a) { return TensorAddressingOperandsMask(~unsigned(a)); } +inline MatrixMultiplyAccumulateOperandsMask operator|(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) | unsigned(b)); } +inline MatrixMultiplyAccumulateOperandsMask operator&(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) & unsigned(b)); } +inline MatrixMultiplyAccumulateOperandsMask operator^(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) ^ unsigned(b)); } +inline MatrixMultiplyAccumulateOperandsMask operator~(MatrixMultiplyAccumulateOperandsMask a) { return MatrixMultiplyAccumulateOperandsMask(~unsigned(a)); } +inline RawAccessChainOperandsMask operator|(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) | unsigned(b)); } +inline RawAccessChainOperandsMask operator&(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) & unsigned(b)); } +inline RawAccessChainOperandsMask operator^(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) ^ unsigned(b)); } +inline RawAccessChainOperandsMask operator~(RawAccessChainOperandsMask a) { return RawAccessChainOperandsMask(~unsigned(a)); } } // end namespace spv diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 index 341d333dae..7e99a5cee9 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -69,6 +69,12 @@ enum class SourceLanguage : unsigned { HLSL = 5, CPP_for_OpenCL = 6, SYCL = 7, + HERO_C = 8, + NZSL = 9, + WGSL = 10, + Slang = 11, + Zig = 12, + Rust = 13, Max = 0x7fffffff, }; @@ -156,6 +162,9 @@ enum class ExecutionMode : unsigned { SubgroupsPerWorkgroupId = 37, LocalSizeId = 38, LocalSizeHintId = 39, + NonCoherentColorAttachmentReadEXT = 4169, + NonCoherentDepthAttachmentReadEXT = 4170, + NonCoherentStencilAttachmentReadEXT = 4171, SubgroupUniformControlFlowKHR = 4421, PostDepthCoverage = 4446, DenormPreserve = 4459, @@ -165,17 +174,28 @@ enum class ExecutionMode : unsigned { RoundingModeRTZ = 4463, EarlyAndLateFragmentTestsAMD = 5017, StencilRefReplacingEXT = 5027, + CoalescingAMDX = 5069, + IsApiEntryAMDX = 5070, + MaxNodeRecursionAMDX = 5071, + StaticNumWorkgroupsAMDX = 5072, + ShaderIndexAMDX = 5073, + MaxNumWorkgroupsAMDX = 5077, StencilRefUnchangedFrontAMD = 5079, StencilRefGreaterFrontAMD = 5080, StencilRefLessFrontAMD = 5081, StencilRefUnchangedBackAMD = 5082, StencilRefGreaterBackAMD = 5083, StencilRefLessBackAMD = 5084, + QuadDerivativesKHR = 5088, + RequireFullQuadsKHR = 5089, + SharesInputWithAMDX = 5102, OutputLinesEXT = 5269, OutputLinesNV = 5269, OutputPrimitivesEXT = 5270, OutputPrimitivesNV = 5270, + DerivativeGroupQuadsKHR = 5289, DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearKHR = 5290, DerivativeGroupLinearNV = 5290, OutputTrianglesEXT = 5298, OutputTrianglesNV = 5298, @@ -195,8 +215,14 @@ enum class ExecutionMode : unsigned { NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + MaximallyReconvergesKHR = 6023, + FPFastMathDefault = 6028, StreamingInterfaceINTEL = 6154, + RegisterMapInterfaceINTEL = 6160, NamedBarrierCountINTEL = 6417, + MaximumRegistersINTEL = 6461, + MaximumRegistersIdINTEL = 6462, + NamedMaximumRegistersINTEL = 6463, Max = 0x7fffffff, }; @@ -214,6 +240,8 @@ enum class StorageClass : unsigned { AtomicCounter = 10, Image = 11, StorageBuffer = 12, + TileImageEXT = 4172, + NodePayloadAMDX = 5068, CallableDataKHR = 5328, CallableDataNV = 5328, IncomingCallableDataKHR = 5329, @@ -244,6 +272,7 @@ enum class Dim : unsigned { Rect = 4, Buffer = 5, SubpassData = 6, + TileImageDataEXT = 4173, Max = 0x7fffffff, }; @@ -350,6 +379,9 @@ enum class ImageChannelDataType : unsigned { Float = 14, UnormInt24 = 15, UnormInt101010_2 = 16, + UnsignedIntRaw10EXT = 19, + UnsignedIntRaw12EXT = 20, + UnormInt2_101010EXT = 21, Max = 0x7fffffff, }; @@ -407,8 +439,11 @@ enum class FPFastMathModeShift : unsigned { NSZ = 2, AllowRecip = 3, Fast = 4, + AllowContract = 16, AllowContractFastINTEL = 16, + AllowReassoc = 17, AllowReassocINTEL = 17, + AllowTransform = 18, Max = 0x7fffffff, }; @@ -419,8 +454,11 @@ enum class FPFastMathModeMask : unsigned { NSZ = 0x00000004, AllowRecip = 0x00000008, Fast = 0x00000010, + AllowContract = 0x00010000, AllowContractFastINTEL = 0x00010000, + AllowReassoc = 0x00020000, AllowReassocINTEL = 0x00020000, + AllowTransform = 0x00040000, }; enum class FPRoundingMode : unsigned { @@ -508,7 +546,18 @@ enum class Decoration : unsigned { MaxByteOffsetId = 47, NoSignedWrap = 4469, NoUnsignedWrap = 4470, + WeightTextureQCOM = 4487, + BlockMatchTextureQCOM = 4488, + BlockMatchSamplerQCOM = 4499, ExplicitInterpAMD = 4999, + NodeSharesPayloadLimitsWithAMDX = 5019, + NodeMaxPayloadsAMDX = 5020, + TrackFinishWritingAMDX = 5078, + PayloadNodeNameAMDX = 5091, + PayloadNodeBaseIndexAMDX = 5098, + PayloadNodeSparseArrayAMDX = 5099, + PayloadNodeArraySizeAMDX = 5100, + PayloadDispatchIndirectAMDX = 5105, OverrideCoverageNV = 5248, PassthroughNV = 5250, ViewportRelativeNV = 5252, @@ -558,6 +607,9 @@ enum class Decoration : unsigned { MergeINTEL = 5834, BankBitsINTEL = 5835, ForcePow2DepthINTEL = 5836, + StridesizeINTEL = 5883, + WordsizeINTEL = 5884, + TrueDualPortINTEL = 5885, BurstCoalesceINTEL = 5899, CacheSizeINTEL = 5900, DontStaticallyCoalesceINTEL = 5901, @@ -576,6 +628,24 @@ enum class Decoration : unsigned { SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, MediaBlockIOINTEL = 6140, + StallFreeINTEL = 6151, + FPMaxErrorDecorationINTEL = 6170, + LatencyControlLabelINTEL = 6172, + LatencyControlConstraintINTEL = 6173, + ConduitKernelArgumentINTEL = 6175, + RegisterMapKernelArgumentINTEL = 6176, + MMHostInterfaceAddressWidthINTEL = 6177, + MMHostInterfaceDataWidthINTEL = 6178, + MMHostInterfaceLatencyINTEL = 6179, + MMHostInterfaceReadWriteModeINTEL = 6180, + MMHostInterfaceMaxBurstINTEL = 6181, + MMHostInterfaceWaitRequestINTEL = 6182, + StableKernelArgumentINTEL = 6183, + HostAccessINTEL = 6188, + InitModeINTEL = 6190, + ImplementInRegisterMapINTEL = 6191, + CacheControlLoadINTEL = 6442, + CacheControlStoreINTEL = 6443, Max = 0x7fffffff, }; @@ -651,6 +721,8 @@ enum class BuiltIn : unsigned { BaryCoordSmoothSampleAMD = 4997, BaryCoordPullModelAMD = 4998, FragStencilRefEXT = 5014, + RemainingRecursionLevelsAMDX = 5021, + ShaderIndexAMDX = 5073, ViewportMaskNV = 5253, SecondaryPositionNV = 5257, SecondaryViewportMaskNV = 5258, @@ -703,13 +775,25 @@ enum class BuiltIn : unsigned { HitKindKHR = 5333, HitKindNV = 5333, CurrentRayTimeNV = 5334, + HitTriangleVertexPositionsKHR = 5335, + HitMicroTriangleVertexPositionsNV = 5337, + HitMicroTriangleVertexBarycentricsNV = 5344, IncomingRayFlagsKHR = 5351, IncomingRayFlagsNV = 5351, RayGeometryIndexKHR = 5352, + HitIsSphereNV = 5359, + HitIsLSSNV = 5360, + HitSpherePositionNV = 5361, WarpsPerSMNV = 5374, SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + HitLSSPositionsNV = 5396, + HitKindFrontFacingMicroTriangleNV = 5405, + HitKindBackFacingMicroTriangleNV = 5406, + HitSphereRadiusNV = 5420, + HitLSSRadiiNV = 5421, + ClusterIDNV = 5436, CullMaskKHR = 6021, Max = 0x7fffffff, }; @@ -777,6 +861,7 @@ enum class FunctionControlShift : unsigned { DontInline = 1, Pure = 2, Const = 3, + OptNoneEXT = 16, OptNoneINTEL = 16, Max = 0x7fffffff, }; @@ -787,6 +872,7 @@ enum class FunctionControlMask : unsigned { DontInline = 0x00000002, Pure = 0x00000004, Const = 0x00000008, + OptNoneEXT = 0x00010000, OptNoneINTEL = 0x00010000, }; @@ -974,6 +1060,10 @@ enum class Capability : unsigned { ShaderViewportIndex = 70, UniformDecoration = 71, CoreBuiltinsARM = 4165, + TileImageColorReadAccessEXT = 4166, + TileImageDepthReadAccessEXT = 4167, + TileImageStencilReadAccessEXT = 4168, + CooperativeMatrixLayoutsARM = 4201, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -1003,8 +1093,13 @@ enum class Capability : unsigned { RoundingModeRTZ = 4468, RayQueryProvisionalKHR = 4471, RayQueryKHR = 4472, + UntypedPointersKHR = 4473, RayTraversalPrimitiveCullingKHR = 4478, RayTracingKHR = 4479, + TextureSampleWeightedQCOM = 4484, + TextureBoxFilterQCOM = 4485, + TextureBlockMatchQCOM = 4486, + TextureBlockMatch2QCOM = 4498, Float16ImageAMD = 5008, ImageGatherBiasLodAMD = 5009, FragmentMaskAMD = 5010, @@ -1012,6 +1107,8 @@ enum class Capability : unsigned { ImageReadWriteLodAMD = 5015, Int64ImageEXT = 5016, ShaderClockKHR = 5055, + ShaderEnqueueAMDX = 5067, + QuadControlKHR = 5087, SampleMaskOverrideCoverageNV = 5249, GeometryShaderPassthroughNV = 5251, ShaderViewportIndexLayerEXT = 5254, @@ -1025,6 +1122,7 @@ enum class Capability : unsigned { MeshShadingEXT = 5283, FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsKHR = 5288, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, ShadingRateNV = 5291, @@ -1053,6 +1151,7 @@ enum class Capability : unsigned { UniformTexelBufferArrayNonUniformIndexingEXT = 5311, StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingPositionFetchKHR = 5336, RayTracingNV = 5340, RayTracingMotionBlurNV = 5341, VulkanMemoryModel = 5345, @@ -1061,6 +1160,7 @@ enum class Capability : unsigned { VulkanMemoryModelDeviceScopeKHR = 5346, PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearKHR = 5350, ComputeDerivativeGroupLinearNV = 5350, RayTracingProvisionalKHR = 5353, CooperativeMatrixNV = 5357, @@ -1070,9 +1170,25 @@ enum class Capability : unsigned { FragmentShaderPixelInterlockEXT = 5378, DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, + DisplacementMicromapNV = 5380, RayTracingOpacityMicromapEXT = 5381, ShaderInvocationReorderNV = 5383, BindlessTextureNV = 5390, + RayQueryPositionFetchKHR = 5391, + CooperativeVectorNV = 5394, + AtomicFloat16VectorNV = 5404, + RayTracingDisplacementMicromapNV = 5409, + RawAccessChainsNV = 5414, + RayTracingSpheresGeometryNV = 5418, + RayTracingLinearSweptSpheresGeometryNV = 5419, + CooperativeMatrixReductionsNV = 5430, + CooperativeMatrixConversionsNV = 5431, + CooperativeMatrixPerElementOperationsNV = 5432, + CooperativeMatrixTensorAddressingNV = 5433, + CooperativeMatrixBlockLoadsNV = 5434, + CooperativeVectorTrainingNV = 5435, + RayTracingClusterAccelerationStructureNV = 5437, + TensorAddressingNV = 5439, SubgroupShuffleINTEL = 5568, SubgroupBufferBlockIOINTEL = 5569, SubgroupImageBlockIOINTEL = 5570, @@ -1124,16 +1240,37 @@ enum class Capability : unsigned { DotProduct = 6019, DotProductKHR = 6019, RayCullMaskKHR = 6020, + CooperativeMatrixKHR = 6022, + ReplicatedCompositesEXT = 6024, BitInstructions = 6025, GroupNonUniformRotateKHR = 6026, + FloatControls2 = 6029, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, - LongConstantCompositeINTEL = 6089, + LongCompositesINTEL = 6089, + OptNoneEXT = 6094, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + BFloat16ConversionINTEL = 6115, SplitBarrierINTEL = 6141, + ArithmeticFenceEXT = 6144, + FPGAClusterAttributesV2INTEL = 6150, + FPGAKernelAttributesv2INTEL = 6161, + FPMaxErrorINTEL = 6169, + FPGALatencyControlINTEL = 6171, + FPGAArgumentInterfacesINTEL = 6174, + GlobalVariableHostAccessINTEL = 6187, + GlobalVariableFPGADecorationsINTEL = 6189, + SubgroupBufferPrefetchINTEL = 6220, + Subgroup2DBlockIOINTEL = 6228, + Subgroup2DBlockTransformINTEL = 6229, + Subgroup2DBlockTransposeINTEL = 6230, + SubgroupMatrixMultiplyAccumulateINTEL = 6236, GroupUniformArithmeticKHR = 6400, + MaskedGatherScatterINTEL = 6427, + CacheControlsINTEL = 6441, + RegisterLimitsINTEL = 6460, Max = 0x7fffffff, }; @@ -1146,6 +1283,7 @@ enum class RayFlagsShift : unsigned { CullFrontFacingTrianglesKHR = 5, CullOpaqueKHR = 6, CullNoOpaqueKHR = 7, + SkipBuiltinPrimitivesNV = 8, SkipTrianglesKHR = 8, SkipAABBsKHR = 9, ForceOpacityMicromap2StateEXT = 10, @@ -1162,6 +1300,7 @@ enum class RayFlagsMask : unsigned { CullFrontFacingTrianglesKHR = 0x00000020, CullOpaqueKHR = 0x00000040, CullNoOpaqueKHR = 0x00000080, + SkipBuiltinPrimitivesNV = 0x00000100, SkipTrianglesKHR = 0x00000100, SkipAABBsKHR = 0x00000200, ForceOpacityMicromap2StateEXT = 0x00000400, @@ -1240,6 +1379,189 @@ enum class PackedVectorFormat : unsigned { Max = 0x7fffffff, }; +enum class CooperativeMatrixOperandsShift : unsigned { + MatrixASignedComponentsKHR = 0, + MatrixBSignedComponentsKHR = 1, + MatrixCSignedComponentsKHR = 2, + MatrixResultSignedComponentsKHR = 3, + SaturatingAccumulationKHR = 4, + Max = 0x7fffffff, +}; + +enum class CooperativeMatrixOperandsMask : unsigned { + MaskNone = 0, + MatrixASignedComponentsKHR = 0x00000001, + MatrixBSignedComponentsKHR = 0x00000002, + MatrixCSignedComponentsKHR = 0x00000004, + MatrixResultSignedComponentsKHR = 0x00000008, + SaturatingAccumulationKHR = 0x00000010, +}; + +enum class CooperativeMatrixLayout : unsigned { + RowMajorKHR = 0, + ColumnMajorKHR = 1, + RowBlockedInterleavedARM = 4202, + ColumnBlockedInterleavedARM = 4203, + Max = 0x7fffffff, +}; + +enum class CooperativeMatrixUse : unsigned { + MatrixAKHR = 0, + MatrixBKHR = 1, + MatrixAccumulatorKHR = 2, + Max = 0x7fffffff, +}; + +enum class CooperativeMatrixReduceShift : unsigned { + Row = 0, + Column = 1, + CooperativeMatrixReduce2x2 = 2, + Max = 0x7fffffff, +}; + +enum class CooperativeMatrixReduceMask : unsigned { + MaskNone = 0, + Row = 0x00000001, + Column = 0x00000002, + CooperativeMatrixReduce2x2 = 0x00000004, +}; + +enum class TensorClampMode : unsigned { + Undefined = 0, + Constant = 1, + ClampToEdge = 2, + Repeat = 3, + RepeatMirrored = 4, + Max = 0x7fffffff, +}; + +enum class TensorAddressingOperandsShift : unsigned { + TensorView = 0, + DecodeFunc = 1, + Max = 0x7fffffff, +}; + +enum class TensorAddressingOperandsMask : unsigned { + MaskNone = 0, + TensorView = 0x00000001, + DecodeFunc = 0x00000002, +}; + +enum class InitializationModeQualifier : unsigned { + InitOnDeviceReprogramINTEL = 0, + InitOnDeviceResetINTEL = 1, + Max = 0x7fffffff, +}; + +enum class HostAccessQualifier : unsigned { + NoneINTEL = 0, + ReadINTEL = 1, + WriteINTEL = 2, + ReadWriteINTEL = 3, + Max = 0x7fffffff, +}; + +enum class LoadCacheControl : unsigned { + UncachedINTEL = 0, + CachedINTEL = 1, + StreamingINTEL = 2, + InvalidateAfterReadINTEL = 3, + ConstCachedINTEL = 4, + Max = 0x7fffffff, +}; + +enum class StoreCacheControl : unsigned { + UncachedINTEL = 0, + WriteThroughINTEL = 1, + WriteBackINTEL = 2, + StreamingINTEL = 3, + Max = 0x7fffffff, +}; + +enum class NamedMaximumNumberOfRegisters : unsigned { + AutoINTEL = 0, + Max = 0x7fffffff, +}; + +enum class MatrixMultiplyAccumulateOperandsShift : unsigned { + MatrixASignedComponentsINTEL = 0, + MatrixBSignedComponentsINTEL = 1, + MatrixCBFloat16INTEL = 2, + MatrixResultBFloat16INTEL = 3, + MatrixAPackedInt8INTEL = 4, + MatrixBPackedInt8INTEL = 5, + MatrixAPackedInt4INTEL = 6, + MatrixBPackedInt4INTEL = 7, + MatrixATF32INTEL = 8, + MatrixBTF32INTEL = 9, + MatrixAPackedFloat16INTEL = 10, + MatrixBPackedFloat16INTEL = 11, + MatrixAPackedBFloat16INTEL = 12, + MatrixBPackedBFloat16INTEL = 13, + Max = 0x7fffffff, +}; + +enum class MatrixMultiplyAccumulateOperandsMask : unsigned { + MaskNone = 0, + MatrixASignedComponentsINTEL = 0x00000001, + MatrixBSignedComponentsINTEL = 0x00000002, + MatrixCBFloat16INTEL = 0x00000004, + MatrixResultBFloat16INTEL = 0x00000008, + MatrixAPackedInt8INTEL = 0x00000010, + MatrixBPackedInt8INTEL = 0x00000020, + MatrixAPackedInt4INTEL = 0x00000040, + MatrixBPackedInt4INTEL = 0x00000080, + MatrixATF32INTEL = 0x00000100, + MatrixBTF32INTEL = 0x00000200, + MatrixAPackedFloat16INTEL = 0x00000400, + MatrixBPackedFloat16INTEL = 0x00000800, + MatrixAPackedBFloat16INTEL = 0x00001000, + MatrixBPackedBFloat16INTEL = 0x00002000, +}; + +enum class RawAccessChainOperandsShift : unsigned { + RobustnessPerComponentNV = 0, + RobustnessPerElementNV = 1, + Max = 0x7fffffff, +}; + +enum class RawAccessChainOperandsMask : unsigned { + MaskNone = 0, + RobustnessPerComponentNV = 0x00000001, + RobustnessPerElementNV = 0x00000002, +}; + +enum class FPEncoding : unsigned { + Max = 0x7fffffff, +}; + +enum class CooperativeVectorMatrixLayout : unsigned { + RowMajorNV = 0, + ColumnMajorNV = 1, + InferencingOptimalNV = 2, + TrainingOptimalNV = 3, + Max = 0x7fffffff, +}; + +enum class ComponentType : unsigned { + Float16NV = 0, + Float32NV = 1, + Float64NV = 2, + SignedInt8NV = 3, + SignedInt16NV = 4, + SignedInt32NV = 5, + SignedInt64NV = 6, + UnsignedInt8NV = 7, + UnsignedInt16NV = 8, + UnsignedInt32NV = 9, + UnsignedInt64NV = 10, + SignedInt8PackedNV = 1000491000, + UnsignedInt8PackedNV = 1000491001, + FloatE4M3NV = 1000491002, + FloatE5M2NV = 1000491003, + Max = 0x7fffffff, +}; + enum class Op : unsigned { OpNop = 0, OpUndef = 1, @@ -1585,14 +1907,26 @@ enum class Op : unsigned { OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1610,6 +1944,14 @@ enum class Op : unsigned { OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1617,6 +1959,14 @@ enum class Op : unsigned { OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1628,6 +1978,16 @@ enum class Op : unsigned { OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1662,10 +2022,20 @@ enum class Op : unsigned { OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1673,9 +2043,12 @@ enum class Op : unsigned { OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1683,9 +2056,26 @@ enum class Op : unsigned { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1693,6 +2083,20 @@ enum class Op : unsigned { OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1934,8 +2338,19 @@ enum class Op : unsigned { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1944,6 +2359,8 @@ enum class Op : unsigned { OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, Max = 0x7fffffff, }; @@ -2299,14 +2716,26 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpPtrEqual: *hasResult = true; *hasResultType = true; break; case Op::OpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case Op::OpPtrDiff: *hasResult = true; *hasResultType = true; break; + case Op::OpColorAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpDepthAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpStencilAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case Op::OpTerminateInvocation: *hasResult = false; *hasResultType = false; break; + case Op::OpTypeUntypedPointerKHR: *hasResult = true; *hasResultType = false; break; + case Op::OpUntypedVariableKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedInBoundsAccessChainKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedInBoundsPtrAccessChainKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedArrayLengthKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpUntypedPrefetchKHR: *hasResult = false; *hasResultType = false; break; case Op::OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case Op::OpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpExtInstWithForwardRefsKHR: *hasResult = true; *hasResultType = true; break; case Op::OpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case Op::OpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case Op::OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; @@ -2318,6 +2747,14 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpSDotAccSat: *hasResult = true; *hasResultType = true; break; case Op::OpUDotAccSat: *hasResult = true; *hasResultType = true; break; case Op::OpSUDotAccSat: *hasResult = true; *hasResultType = true; break; + case Op::OpTypeCooperativeMatrixKHR: *hasResult = true; *hasResultType = false; break; + case Op::OpCooperativeMatrixLoadKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixStoreKHR: *hasResult = false; *hasResultType = false; break; + case Op::OpCooperativeMatrixMulAddKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixLengthKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpSpecConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpCompositeConstructReplicateEXT: *hasResult = true; *hasResultType = true; break; case Op::OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case Op::OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case Op::OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; @@ -2325,6 +2762,14 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case Op::OpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case Op::OpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break; + case Op::OpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break; case Op::OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case Op::OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case Op::OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; @@ -2336,6 +2781,16 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break; case Op::OpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break; case Op::OpReadClockKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpAllocateNodePayloadsAMDX: *hasResult = true; *hasResultType = true; break; + case Op::OpEnqueueNodePayloadsAMDX: *hasResult = false; *hasResultType = false; break; + case Op::OpTypeNodePayloadArrayAMDX: *hasResult = true; *hasResultType = false; break; + case Op::OpFinishWritingNodePayloadAMDX: *hasResult = true; *hasResultType = true; break; + case Op::OpNodePayloadArrayLengthAMDX: *hasResult = true; *hasResultType = true; break; + case Op::OpIsNodePayloadValidAMDX: *hasResult = true; *hasResultType = true; break; + case Op::OpConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case Op::OpSpecConstantStringAMDX: *hasResult = true; *hasResultType = false; break; + case Op::OpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break; case Op::OpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break; case Op::OpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break; case Op::OpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break; @@ -2370,18 +2825,31 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpReorderThreadWithHintNV: *hasResult = false; *hasResultType = false; break; case Op::OpTypeHitObjectNV: *hasResult = true; *hasResultType = false; break; case Op::OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTypeCooperativeVectorNV: *hasResult = true; *hasResultType = false; break; + case Op::OpCooperativeVectorMatrixMulNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeVectorOuterProductAccumulateNV: *hasResult = false; *hasResultType = false; break; + case Op::OpCooperativeVectorReduceSumAccumulateNV: *hasResult = false; *hasResultType = false; break; + case Op::OpCooperativeVectorMatrixMulAddNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixConvertNV: *hasResult = true; *hasResultType = true; break; case Op::OpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break; case Op::OpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break; case Op::OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; case Op::OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; - case Op::OpReportIntersectionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpFetchMicroTriangleVertexPositionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpFetchMicroTriangleVertexBarycentricNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeVectorLoadNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeVectorStoreNV: *hasResult = false; *hasResultType = false; break; + case Op::OpReportIntersectionKHR: *hasResult = true; *hasResultType = true; break; case Op::OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; case Op::OpTerminateRayNV: *hasResult = false; *hasResultType = false; break; case Op::OpTraceNV: *hasResult = false; *hasResultType = false; break; case Op::OpTraceMotionNV: *hasResult = false; *hasResultType = false; break; case Op::OpTraceRayMotionNV: *hasResult = false; *hasResultType = false; break; - case Op::OpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break; + case Op::OpRayQueryGetIntersectionTriangleVertexPositionsKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpTypeAccelerationStructureKHR: *hasResult = true; *hasResultType = false; break; case Op::OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; + case Op::OpRayQueryGetClusterIdNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectGetClusterIdNV: *hasResult = true; *hasResultType = true; break; case Op::OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case Op::OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case Op::OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; @@ -2389,8 +2857,25 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; case Op::OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; case Op::OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; + case Op::OpCooperativeMatrixReduceNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixLoadTensorNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixStoreTensorNV: *hasResult = false; *hasResultType = false; break; + case Op::OpCooperativeMatrixPerElementOpNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTypeTensorLayoutNV: *hasResult = true; *hasResultType = false; break; + case Op::OpTypeTensorViewNV: *hasResult = true; *hasResultType = false; break; + case Op::OpCreateTensorLayoutNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorLayoutSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorLayoutSetStrideNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorLayoutSliceNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorLayoutSetClampValueNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCreateTensorViewNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorViewSetDimensionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorViewSetStrideNV: *hasResult = true; *hasResultType = true; break; case Op::OpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break; case Op::OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorViewSetClipNV: *hasResult = true; *hasResultType = true; break; + case Op::OpTensorLayoutSetBlockSizeNV: *hasResult = true; *hasResultType = true; break; + case Op::OpCooperativeMatrixTransposeNV: *hasResult = true; *hasResultType = true; break; case Op::OpConvertUToImageNV: *hasResult = true; *hasResultType = true; break; case Op::OpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break; case Op::OpConvertImageToUNV: *hasResult = true; *hasResultType = true; break; @@ -2398,6 +2883,20 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpConvertUToSampledImageNV: *hasResult = true; *hasResultType = true; break; case Op::OpConvertSampledImageToUNV: *hasResult = true; *hasResultType = true; break; case Op::OpSamplerImageAddressingModeNV: *hasResult = false; *hasResultType = false; break; + case Op::OpRawAccessChainNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryGetIntersectionSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryGetIntersectionSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryGetIntersectionLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryGetIntersectionLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryGetIntersectionLSSHitValueNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectGetSpherePositionNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectGetSphereRadiusNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectGetLSSPositionsNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectGetLSSRadiiNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case Op::OpHitObjectIsLSSHitNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryIsSphereHitNV: *hasResult = true; *hasResultType = true; break; + case Op::OpRayQueryIsLSSHitNV: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break; @@ -2424,7 +2923,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; case Op::OpConstantFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; - case Op::OpAsmTargetINTEL: *hasResult = true; *hasResultType = true; break; + case Op::OpAsmTargetINTEL: *hasResult = true; *hasResultType = false; break; case Op::OpAsmINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpAsmCallINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpAtomicFMinEXT: *hasResult = true; *hasResultType = true; break; @@ -2637,8 +3136,19 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case Op::OpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case Op::OpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpCompositeConstructContinuedINTEL: *hasResult = true; *hasResultType = true; break; + case Op::OpConvertFToBF16INTEL: *hasResult = true; *hasResultType = true; break; + case Op::OpConvertBF16ToFINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; case Op::OpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpArithmeticFenceEXT: *hasResult = true; *hasResultType = true; break; + case Op::OpSubgroupBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroup2DBlockLoadINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroup2DBlockLoadTransformINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroup2DBlockLoadTransposeINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroup2DBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroup2DBlockStoreINTEL: *hasResult = false; *hasResultType = false; break; + case Op::OpSubgroupMatrixMultiplyAccumulateINTEL: *hasResult = true; *hasResultType = true; break; case Op::OpGroupIMulKHR: *hasResult = true; *hasResultType = true; break; case Op::OpGroupFMulKHR: *hasResult = true; *hasResultType = true; break; case Op::OpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break; @@ -2647,52 +3157,1996 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case Op::OpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break; case Op::OpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break; case Op::OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; + case Op::OpMaskedGatherINTEL: *hasResult = true; *hasResultType = true; break; + case Op::OpMaskedScatterINTEL: *hasResult = false; *hasResultType = false; break; } } +inline const char* SourceLanguageToString(SourceLanguage value) { + switch (value) { + case SourceLanguage::Unknown: return "Unknown"; + case SourceLanguage::ESSL: return "ESSL"; + case SourceLanguage::GLSL: return "GLSL"; + case SourceLanguage::OpenCL_C: return "OpenCL_C"; + case SourceLanguage::OpenCL_CPP: return "OpenCL_CPP"; + case SourceLanguage::HLSL: return "HLSL"; + case SourceLanguage::CPP_for_OpenCL: return "CPP_for_OpenCL"; + case SourceLanguage::SYCL: return "SYCL"; + case SourceLanguage::HERO_C: return "HERO_C"; + case SourceLanguage::NZSL: return "NZSL"; + case SourceLanguage::WGSL: return "WGSL"; + case SourceLanguage::Slang: return "Slang"; + case SourceLanguage::Zig: return "Zig"; + case SourceLanguage::Rust: return "Rust"; + default: return "Unknown"; + } +} + +inline const char* ExecutionModelToString(ExecutionModel value) { + switch (value) { + case ExecutionModel::Vertex: return "Vertex"; + case ExecutionModel::TessellationControl: return "TessellationControl"; + case ExecutionModel::TessellationEvaluation: return "TessellationEvaluation"; + case ExecutionModel::Geometry: return "Geometry"; + case ExecutionModel::Fragment: return "Fragment"; + case ExecutionModel::GLCompute: return "GLCompute"; + case ExecutionModel::Kernel: return "Kernel"; + case ExecutionModel::TaskNV: return "TaskNV"; + case ExecutionModel::MeshNV: return "MeshNV"; + case ExecutionModel::RayGenerationKHR: return "RayGenerationKHR"; + case ExecutionModel::IntersectionKHR: return "IntersectionKHR"; + case ExecutionModel::AnyHitKHR: return "AnyHitKHR"; + case ExecutionModel::ClosestHitKHR: return "ClosestHitKHR"; + case ExecutionModel::MissKHR: return "MissKHR"; + case ExecutionModel::CallableKHR: return "CallableKHR"; + case ExecutionModel::TaskEXT: return "TaskEXT"; + case ExecutionModel::MeshEXT: return "MeshEXT"; + default: return "Unknown"; + } +} + +inline const char* AddressingModelToString(AddressingModel value) { + switch (value) { + case AddressingModel::Logical: return "Logical"; + case AddressingModel::Physical32: return "Physical32"; + case AddressingModel::Physical64: return "Physical64"; + case AddressingModel::PhysicalStorageBuffer64: return "PhysicalStorageBuffer64"; + default: return "Unknown"; + } +} + +inline const char* MemoryModelToString(MemoryModel value) { + switch (value) { + case MemoryModel::Simple: return "Simple"; + case MemoryModel::GLSL450: return "GLSL450"; + case MemoryModel::OpenCL: return "OpenCL"; + case MemoryModel::Vulkan: return "Vulkan"; + default: return "Unknown"; + } +} + +inline const char* ExecutionModeToString(ExecutionMode value) { + switch (value) { + case ExecutionMode::Invocations: return "Invocations"; + case ExecutionMode::SpacingEqual: return "SpacingEqual"; + case ExecutionMode::SpacingFractionalEven: return "SpacingFractionalEven"; + case ExecutionMode::SpacingFractionalOdd: return "SpacingFractionalOdd"; + case ExecutionMode::VertexOrderCw: return "VertexOrderCw"; + case ExecutionMode::VertexOrderCcw: return "VertexOrderCcw"; + case ExecutionMode::PixelCenterInteger: return "PixelCenterInteger"; + case ExecutionMode::OriginUpperLeft: return "OriginUpperLeft"; + case ExecutionMode::OriginLowerLeft: return "OriginLowerLeft"; + case ExecutionMode::EarlyFragmentTests: return "EarlyFragmentTests"; + case ExecutionMode::PointMode: return "PointMode"; + case ExecutionMode::Xfb: return "Xfb"; + case ExecutionMode::DepthReplacing: return "DepthReplacing"; + case ExecutionMode::DepthGreater: return "DepthGreater"; + case ExecutionMode::DepthLess: return "DepthLess"; + case ExecutionMode::DepthUnchanged: return "DepthUnchanged"; + case ExecutionMode::LocalSize: return "LocalSize"; + case ExecutionMode::LocalSizeHint: return "LocalSizeHint"; + case ExecutionMode::InputPoints: return "InputPoints"; + case ExecutionMode::InputLines: return "InputLines"; + case ExecutionMode::InputLinesAdjacency: return "InputLinesAdjacency"; + case ExecutionMode::Triangles: return "Triangles"; + case ExecutionMode::InputTrianglesAdjacency: return "InputTrianglesAdjacency"; + case ExecutionMode::Quads: return "Quads"; + case ExecutionMode::Isolines: return "Isolines"; + case ExecutionMode::OutputVertices: return "OutputVertices"; + case ExecutionMode::OutputPoints: return "OutputPoints"; + case ExecutionMode::OutputLineStrip: return "OutputLineStrip"; + case ExecutionMode::OutputTriangleStrip: return "OutputTriangleStrip"; + case ExecutionMode::VecTypeHint: return "VecTypeHint"; + case ExecutionMode::ContractionOff: return "ContractionOff"; + case ExecutionMode::Initializer: return "Initializer"; + case ExecutionMode::Finalizer: return "Finalizer"; + case ExecutionMode::SubgroupSize: return "SubgroupSize"; + case ExecutionMode::SubgroupsPerWorkgroup: return "SubgroupsPerWorkgroup"; + case ExecutionMode::SubgroupsPerWorkgroupId: return "SubgroupsPerWorkgroupId"; + case ExecutionMode::LocalSizeId: return "LocalSizeId"; + case ExecutionMode::LocalSizeHintId: return "LocalSizeHintId"; + case ExecutionMode::NonCoherentColorAttachmentReadEXT: return "NonCoherentColorAttachmentReadEXT"; + case ExecutionMode::NonCoherentDepthAttachmentReadEXT: return "NonCoherentDepthAttachmentReadEXT"; + case ExecutionMode::NonCoherentStencilAttachmentReadEXT: return "NonCoherentStencilAttachmentReadEXT"; + case ExecutionMode::SubgroupUniformControlFlowKHR: return "SubgroupUniformControlFlowKHR"; + case ExecutionMode::PostDepthCoverage: return "PostDepthCoverage"; + case ExecutionMode::DenormPreserve: return "DenormPreserve"; + case ExecutionMode::DenormFlushToZero: return "DenormFlushToZero"; + case ExecutionMode::SignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case ExecutionMode::RoundingModeRTE: return "RoundingModeRTE"; + case ExecutionMode::RoundingModeRTZ: return "RoundingModeRTZ"; + case ExecutionMode::EarlyAndLateFragmentTestsAMD: return "EarlyAndLateFragmentTestsAMD"; + case ExecutionMode::StencilRefReplacingEXT: return "StencilRefReplacingEXT"; + case ExecutionMode::CoalescingAMDX: return "CoalescingAMDX"; + case ExecutionMode::IsApiEntryAMDX: return "IsApiEntryAMDX"; + case ExecutionMode::MaxNodeRecursionAMDX: return "MaxNodeRecursionAMDX"; + case ExecutionMode::StaticNumWorkgroupsAMDX: return "StaticNumWorkgroupsAMDX"; + case ExecutionMode::ShaderIndexAMDX: return "ShaderIndexAMDX"; + case ExecutionMode::MaxNumWorkgroupsAMDX: return "MaxNumWorkgroupsAMDX"; + case ExecutionMode::StencilRefUnchangedFrontAMD: return "StencilRefUnchangedFrontAMD"; + case ExecutionMode::StencilRefGreaterFrontAMD: return "StencilRefGreaterFrontAMD"; + case ExecutionMode::StencilRefLessFrontAMD: return "StencilRefLessFrontAMD"; + case ExecutionMode::StencilRefUnchangedBackAMD: return "StencilRefUnchangedBackAMD"; + case ExecutionMode::StencilRefGreaterBackAMD: return "StencilRefGreaterBackAMD"; + case ExecutionMode::StencilRefLessBackAMD: return "StencilRefLessBackAMD"; + case ExecutionMode::QuadDerivativesKHR: return "QuadDerivativesKHR"; + case ExecutionMode::RequireFullQuadsKHR: return "RequireFullQuadsKHR"; + case ExecutionMode::SharesInputWithAMDX: return "SharesInputWithAMDX"; + case ExecutionMode::OutputLinesEXT: return "OutputLinesEXT"; + case ExecutionMode::OutputPrimitivesEXT: return "OutputPrimitivesEXT"; + case ExecutionMode::DerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR"; + case ExecutionMode::DerivativeGroupLinearKHR: return "DerivativeGroupLinearKHR"; + case ExecutionMode::OutputTrianglesEXT: return "OutputTrianglesEXT"; + case ExecutionMode::PixelInterlockOrderedEXT: return "PixelInterlockOrderedEXT"; + case ExecutionMode::PixelInterlockUnorderedEXT: return "PixelInterlockUnorderedEXT"; + case ExecutionMode::SampleInterlockOrderedEXT: return "SampleInterlockOrderedEXT"; + case ExecutionMode::SampleInterlockUnorderedEXT: return "SampleInterlockUnorderedEXT"; + case ExecutionMode::ShadingRateInterlockOrderedEXT: return "ShadingRateInterlockOrderedEXT"; + case ExecutionMode::ShadingRateInterlockUnorderedEXT: return "ShadingRateInterlockUnorderedEXT"; + case ExecutionMode::SharedLocalMemorySizeINTEL: return "SharedLocalMemorySizeINTEL"; + case ExecutionMode::RoundingModeRTPINTEL: return "RoundingModeRTPINTEL"; + case ExecutionMode::RoundingModeRTNINTEL: return "RoundingModeRTNINTEL"; + case ExecutionMode::FloatingPointModeALTINTEL: return "FloatingPointModeALTINTEL"; + case ExecutionMode::FloatingPointModeIEEEINTEL: return "FloatingPointModeIEEEINTEL"; + case ExecutionMode::MaxWorkgroupSizeINTEL: return "MaxWorkgroupSizeINTEL"; + case ExecutionMode::MaxWorkDimINTEL: return "MaxWorkDimINTEL"; + case ExecutionMode::NoGlobalOffsetINTEL: return "NoGlobalOffsetINTEL"; + case ExecutionMode::NumSIMDWorkitemsINTEL: return "NumSIMDWorkitemsINTEL"; + case ExecutionMode::SchedulerTargetFmaxMhzINTEL: return "SchedulerTargetFmaxMhzINTEL"; + case ExecutionMode::MaximallyReconvergesKHR: return "MaximallyReconvergesKHR"; + case ExecutionMode::FPFastMathDefault: return "FPFastMathDefault"; + case ExecutionMode::StreamingInterfaceINTEL: return "StreamingInterfaceINTEL"; + case ExecutionMode::RegisterMapInterfaceINTEL: return "RegisterMapInterfaceINTEL"; + case ExecutionMode::NamedBarrierCountINTEL: return "NamedBarrierCountINTEL"; + case ExecutionMode::MaximumRegistersINTEL: return "MaximumRegistersINTEL"; + case ExecutionMode::MaximumRegistersIdINTEL: return "MaximumRegistersIdINTEL"; + case ExecutionMode::NamedMaximumRegistersINTEL: return "NamedMaximumRegistersINTEL"; + default: return "Unknown"; + } +} + +inline const char* StorageClassToString(StorageClass value) { + switch (value) { + case StorageClass::UniformConstant: return "UniformConstant"; + case StorageClass::Input: return "Input"; + case StorageClass::Uniform: return "Uniform"; + case StorageClass::Output: return "Output"; + case StorageClass::Workgroup: return "Workgroup"; + case StorageClass::CrossWorkgroup: return "CrossWorkgroup"; + case StorageClass::Private: return "Private"; + case StorageClass::Function: return "Function"; + case StorageClass::Generic: return "Generic"; + case StorageClass::PushConstant: return "PushConstant"; + case StorageClass::AtomicCounter: return "AtomicCounter"; + case StorageClass::Image: return "Image"; + case StorageClass::StorageBuffer: return "StorageBuffer"; + case StorageClass::TileImageEXT: return "TileImageEXT"; + case StorageClass::NodePayloadAMDX: return "NodePayloadAMDX"; + case StorageClass::CallableDataKHR: return "CallableDataKHR"; + case StorageClass::IncomingCallableDataKHR: return "IncomingCallableDataKHR"; + case StorageClass::RayPayloadKHR: return "RayPayloadKHR"; + case StorageClass::HitAttributeKHR: return "HitAttributeKHR"; + case StorageClass::IncomingRayPayloadKHR: return "IncomingRayPayloadKHR"; + case StorageClass::ShaderRecordBufferKHR: return "ShaderRecordBufferKHR"; + case StorageClass::PhysicalStorageBuffer: return "PhysicalStorageBuffer"; + case StorageClass::HitObjectAttributeNV: return "HitObjectAttributeNV"; + case StorageClass::TaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT"; + case StorageClass::CodeSectionINTEL: return "CodeSectionINTEL"; + case StorageClass::DeviceOnlyINTEL: return "DeviceOnlyINTEL"; + case StorageClass::HostOnlyINTEL: return "HostOnlyINTEL"; + default: return "Unknown"; + } +} + +inline const char* DimToString(Dim value) { + switch (value) { + case Dim::Dim1D: return "1D"; + case Dim::Dim2D: return "2D"; + case Dim::Dim3D: return "3D"; + case Dim::Cube: return "Cube"; + case Dim::Rect: return "Rect"; + case Dim::Buffer: return "Buffer"; + case Dim::SubpassData: return "SubpassData"; + case Dim::TileImageDataEXT: return "TileImageDataEXT"; + default: return "Unknown"; + } +} + +inline const char* SamplerAddressingModeToString(SamplerAddressingMode value) { + switch (value) { + case SamplerAddressingMode::None: return "None"; + case SamplerAddressingMode::ClampToEdge: return "ClampToEdge"; + case SamplerAddressingMode::Clamp: return "Clamp"; + case SamplerAddressingMode::Repeat: return "Repeat"; + case SamplerAddressingMode::RepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* SamplerFilterModeToString(SamplerFilterMode value) { + switch (value) { + case SamplerFilterMode::Nearest: return "Nearest"; + case SamplerFilterMode::Linear: return "Linear"; + default: return "Unknown"; + } +} + +inline const char* ImageFormatToString(ImageFormat value) { + switch (value) { + case ImageFormat::Unknown: return "Unknown"; + case ImageFormat::Rgba32f: return "Rgba32f"; + case ImageFormat::Rgba16f: return "Rgba16f"; + case ImageFormat::R32f: return "R32f"; + case ImageFormat::Rgba8: return "Rgba8"; + case ImageFormat::Rgba8Snorm: return "Rgba8Snorm"; + case ImageFormat::Rg32f: return "Rg32f"; + case ImageFormat::Rg16f: return "Rg16f"; + case ImageFormat::R11fG11fB10f: return "R11fG11fB10f"; + case ImageFormat::R16f: return "R16f"; + case ImageFormat::Rgba16: return "Rgba16"; + case ImageFormat::Rgb10A2: return "Rgb10A2"; + case ImageFormat::Rg16: return "Rg16"; + case ImageFormat::Rg8: return "Rg8"; + case ImageFormat::R16: return "R16"; + case ImageFormat::R8: return "R8"; + case ImageFormat::Rgba16Snorm: return "Rgba16Snorm"; + case ImageFormat::Rg16Snorm: return "Rg16Snorm"; + case ImageFormat::Rg8Snorm: return "Rg8Snorm"; + case ImageFormat::R16Snorm: return "R16Snorm"; + case ImageFormat::R8Snorm: return "R8Snorm"; + case ImageFormat::Rgba32i: return "Rgba32i"; + case ImageFormat::Rgba16i: return "Rgba16i"; + case ImageFormat::Rgba8i: return "Rgba8i"; + case ImageFormat::R32i: return "R32i"; + case ImageFormat::Rg32i: return "Rg32i"; + case ImageFormat::Rg16i: return "Rg16i"; + case ImageFormat::Rg8i: return "Rg8i"; + case ImageFormat::R16i: return "R16i"; + case ImageFormat::R8i: return "R8i"; + case ImageFormat::Rgba32ui: return "Rgba32ui"; + case ImageFormat::Rgba16ui: return "Rgba16ui"; + case ImageFormat::Rgba8ui: return "Rgba8ui"; + case ImageFormat::R32ui: return "R32ui"; + case ImageFormat::Rgb10a2ui: return "Rgb10a2ui"; + case ImageFormat::Rg32ui: return "Rg32ui"; + case ImageFormat::Rg16ui: return "Rg16ui"; + case ImageFormat::Rg8ui: return "Rg8ui"; + case ImageFormat::R16ui: return "R16ui"; + case ImageFormat::R8ui: return "R8ui"; + case ImageFormat::R64ui: return "R64ui"; + case ImageFormat::R64i: return "R64i"; + default: return "Unknown"; + } +} + +inline const char* ImageChannelOrderToString(ImageChannelOrder value) { + switch (value) { + case ImageChannelOrder::R: return "R"; + case ImageChannelOrder::A: return "A"; + case ImageChannelOrder::RG: return "RG"; + case ImageChannelOrder::RA: return "RA"; + case ImageChannelOrder::RGB: return "RGB"; + case ImageChannelOrder::RGBA: return "RGBA"; + case ImageChannelOrder::BGRA: return "BGRA"; + case ImageChannelOrder::ARGB: return "ARGB"; + case ImageChannelOrder::Intensity: return "Intensity"; + case ImageChannelOrder::Luminance: return "Luminance"; + case ImageChannelOrder::Rx: return "Rx"; + case ImageChannelOrder::RGx: return "RGx"; + case ImageChannelOrder::RGBx: return "RGBx"; + case ImageChannelOrder::Depth: return "Depth"; + case ImageChannelOrder::DepthStencil: return "DepthStencil"; + case ImageChannelOrder::sRGB: return "sRGB"; + case ImageChannelOrder::sRGBx: return "sRGBx"; + case ImageChannelOrder::sRGBA: return "sRGBA"; + case ImageChannelOrder::sBGRA: return "sBGRA"; + case ImageChannelOrder::ABGR: return "ABGR"; + default: return "Unknown"; + } +} + +inline const char* ImageChannelDataTypeToString(ImageChannelDataType value) { + switch (value) { + case ImageChannelDataType::SnormInt8: return "SnormInt8"; + case ImageChannelDataType::SnormInt16: return "SnormInt16"; + case ImageChannelDataType::UnormInt8: return "UnormInt8"; + case ImageChannelDataType::UnormInt16: return "UnormInt16"; + case ImageChannelDataType::UnormShort565: return "UnormShort565"; + case ImageChannelDataType::UnormShort555: return "UnormShort555"; + case ImageChannelDataType::UnormInt101010: return "UnormInt101010"; + case ImageChannelDataType::SignedInt8: return "SignedInt8"; + case ImageChannelDataType::SignedInt16: return "SignedInt16"; + case ImageChannelDataType::SignedInt32: return "SignedInt32"; + case ImageChannelDataType::UnsignedInt8: return "UnsignedInt8"; + case ImageChannelDataType::UnsignedInt16: return "UnsignedInt16"; + case ImageChannelDataType::UnsignedInt32: return "UnsignedInt32"; + case ImageChannelDataType::HalfFloat: return "HalfFloat"; + case ImageChannelDataType::Float: return "Float"; + case ImageChannelDataType::UnormInt24: return "UnormInt24"; + case ImageChannelDataType::UnormInt101010_2: return "UnormInt101010_2"; + case ImageChannelDataType::UnsignedIntRaw10EXT: return "UnsignedIntRaw10EXT"; + case ImageChannelDataType::UnsignedIntRaw12EXT: return "UnsignedIntRaw12EXT"; + case ImageChannelDataType::UnormInt2_101010EXT: return "UnormInt2_101010EXT"; + default: return "Unknown"; + } +} + +inline const char* FPRoundingModeToString(FPRoundingMode value) { + switch (value) { + case FPRoundingMode::RTE: return "RTE"; + case FPRoundingMode::RTZ: return "RTZ"; + case FPRoundingMode::RTP: return "RTP"; + case FPRoundingMode::RTN: return "RTN"; + default: return "Unknown"; + } +} + +inline const char* LinkageTypeToString(LinkageType value) { + switch (value) { + case LinkageType::Export: return "Export"; + case LinkageType::Import: return "Import"; + case LinkageType::LinkOnceODR: return "LinkOnceODR"; + default: return "Unknown"; + } +} + +inline const char* AccessQualifierToString(AccessQualifier value) { + switch (value) { + case AccessQualifier::ReadOnly: return "ReadOnly"; + case AccessQualifier::WriteOnly: return "WriteOnly"; + case AccessQualifier::ReadWrite: return "ReadWrite"; + default: return "Unknown"; + } +} + +inline const char* FunctionParameterAttributeToString(FunctionParameterAttribute value) { + switch (value) { + case FunctionParameterAttribute::Zext: return "Zext"; + case FunctionParameterAttribute::Sext: return "Sext"; + case FunctionParameterAttribute::ByVal: return "ByVal"; + case FunctionParameterAttribute::Sret: return "Sret"; + case FunctionParameterAttribute::NoAlias: return "NoAlias"; + case FunctionParameterAttribute::NoCapture: return "NoCapture"; + case FunctionParameterAttribute::NoWrite: return "NoWrite"; + case FunctionParameterAttribute::NoReadWrite: return "NoReadWrite"; + case FunctionParameterAttribute::RuntimeAlignedINTEL: return "RuntimeAlignedINTEL"; + default: return "Unknown"; + } +} + +inline const char* DecorationToString(Decoration value) { + switch (value) { + case Decoration::RelaxedPrecision: return "RelaxedPrecision"; + case Decoration::SpecId: return "SpecId"; + case Decoration::Block: return "Block"; + case Decoration::BufferBlock: return "BufferBlock"; + case Decoration::RowMajor: return "RowMajor"; + case Decoration::ColMajor: return "ColMajor"; + case Decoration::ArrayStride: return "ArrayStride"; + case Decoration::MatrixStride: return "MatrixStride"; + case Decoration::GLSLShared: return "GLSLShared"; + case Decoration::GLSLPacked: return "GLSLPacked"; + case Decoration::CPacked: return "CPacked"; + case Decoration::BuiltIn: return "BuiltIn"; + case Decoration::NoPerspective: return "NoPerspective"; + case Decoration::Flat: return "Flat"; + case Decoration::Patch: return "Patch"; + case Decoration::Centroid: return "Centroid"; + case Decoration::Sample: return "Sample"; + case Decoration::Invariant: return "Invariant"; + case Decoration::Restrict: return "Restrict"; + case Decoration::Aliased: return "Aliased"; + case Decoration::Volatile: return "Volatile"; + case Decoration::Constant: return "Constant"; + case Decoration::Coherent: return "Coherent"; + case Decoration::NonWritable: return "NonWritable"; + case Decoration::NonReadable: return "NonReadable"; + case Decoration::Uniform: return "Uniform"; + case Decoration::UniformId: return "UniformId"; + case Decoration::SaturatedConversion: return "SaturatedConversion"; + case Decoration::Stream: return "Stream"; + case Decoration::Location: return "Location"; + case Decoration::Component: return "Component"; + case Decoration::Index: return "Index"; + case Decoration::Binding: return "Binding"; + case Decoration::DescriptorSet: return "DescriptorSet"; + case Decoration::Offset: return "Offset"; + case Decoration::XfbBuffer: return "XfbBuffer"; + case Decoration::XfbStride: return "XfbStride"; + case Decoration::FuncParamAttr: return "FuncParamAttr"; + case Decoration::FPRoundingMode: return "FPRoundingMode"; + case Decoration::FPFastMathMode: return "FPFastMathMode"; + case Decoration::LinkageAttributes: return "LinkageAttributes"; + case Decoration::NoContraction: return "NoContraction"; + case Decoration::InputAttachmentIndex: return "InputAttachmentIndex"; + case Decoration::Alignment: return "Alignment"; + case Decoration::MaxByteOffset: return "MaxByteOffset"; + case Decoration::AlignmentId: return "AlignmentId"; + case Decoration::MaxByteOffsetId: return "MaxByteOffsetId"; + case Decoration::NoSignedWrap: return "NoSignedWrap"; + case Decoration::NoUnsignedWrap: return "NoUnsignedWrap"; + case Decoration::WeightTextureQCOM: return "WeightTextureQCOM"; + case Decoration::BlockMatchTextureQCOM: return "BlockMatchTextureQCOM"; + case Decoration::BlockMatchSamplerQCOM: return "BlockMatchSamplerQCOM"; + case Decoration::ExplicitInterpAMD: return "ExplicitInterpAMD"; + case Decoration::NodeSharesPayloadLimitsWithAMDX: return "NodeSharesPayloadLimitsWithAMDX"; + case Decoration::NodeMaxPayloadsAMDX: return "NodeMaxPayloadsAMDX"; + case Decoration::TrackFinishWritingAMDX: return "TrackFinishWritingAMDX"; + case Decoration::PayloadNodeNameAMDX: return "PayloadNodeNameAMDX"; + case Decoration::PayloadNodeBaseIndexAMDX: return "PayloadNodeBaseIndexAMDX"; + case Decoration::PayloadNodeSparseArrayAMDX: return "PayloadNodeSparseArrayAMDX"; + case Decoration::PayloadNodeArraySizeAMDX: return "PayloadNodeArraySizeAMDX"; + case Decoration::PayloadDispatchIndirectAMDX: return "PayloadDispatchIndirectAMDX"; + case Decoration::OverrideCoverageNV: return "OverrideCoverageNV"; + case Decoration::PassthroughNV: return "PassthroughNV"; + case Decoration::ViewportRelativeNV: return "ViewportRelativeNV"; + case Decoration::SecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV"; + case Decoration::PerPrimitiveEXT: return "PerPrimitiveEXT"; + case Decoration::PerViewNV: return "PerViewNV"; + case Decoration::PerTaskNV: return "PerTaskNV"; + case Decoration::PerVertexKHR: return "PerVertexKHR"; + case Decoration::NonUniform: return "NonUniform"; + case Decoration::RestrictPointer: return "RestrictPointer"; + case Decoration::AliasedPointer: return "AliasedPointer"; + case Decoration::HitObjectShaderRecordBufferNV: return "HitObjectShaderRecordBufferNV"; + case Decoration::BindlessSamplerNV: return "BindlessSamplerNV"; + case Decoration::BindlessImageNV: return "BindlessImageNV"; + case Decoration::BoundSamplerNV: return "BoundSamplerNV"; + case Decoration::BoundImageNV: return "BoundImageNV"; + case Decoration::SIMTCallINTEL: return "SIMTCallINTEL"; + case Decoration::ReferencedIndirectlyINTEL: return "ReferencedIndirectlyINTEL"; + case Decoration::ClobberINTEL: return "ClobberINTEL"; + case Decoration::SideEffectsINTEL: return "SideEffectsINTEL"; + case Decoration::VectorComputeVariableINTEL: return "VectorComputeVariableINTEL"; + case Decoration::FuncParamIOKindINTEL: return "FuncParamIOKindINTEL"; + case Decoration::VectorComputeFunctionINTEL: return "VectorComputeFunctionINTEL"; + case Decoration::StackCallINTEL: return "StackCallINTEL"; + case Decoration::GlobalVariableOffsetINTEL: return "GlobalVariableOffsetINTEL"; + case Decoration::CounterBuffer: return "CounterBuffer"; + case Decoration::HlslSemanticGOOGLE: return "HlslSemanticGOOGLE"; + case Decoration::UserTypeGOOGLE: return "UserTypeGOOGLE"; + case Decoration::FunctionRoundingModeINTEL: return "FunctionRoundingModeINTEL"; + case Decoration::FunctionDenormModeINTEL: return "FunctionDenormModeINTEL"; + case Decoration::RegisterINTEL: return "RegisterINTEL"; + case Decoration::MemoryINTEL: return "MemoryINTEL"; + case Decoration::NumbanksINTEL: return "NumbanksINTEL"; + case Decoration::BankwidthINTEL: return "BankwidthINTEL"; + case Decoration::MaxPrivateCopiesINTEL: return "MaxPrivateCopiesINTEL"; + case Decoration::SinglepumpINTEL: return "SinglepumpINTEL"; + case Decoration::DoublepumpINTEL: return "DoublepumpINTEL"; + case Decoration::MaxReplicatesINTEL: return "MaxReplicatesINTEL"; + case Decoration::SimpleDualPortINTEL: return "SimpleDualPortINTEL"; + case Decoration::MergeINTEL: return "MergeINTEL"; + case Decoration::BankBitsINTEL: return "BankBitsINTEL"; + case Decoration::ForcePow2DepthINTEL: return "ForcePow2DepthINTEL"; + case Decoration::StridesizeINTEL: return "StridesizeINTEL"; + case Decoration::WordsizeINTEL: return "WordsizeINTEL"; + case Decoration::TrueDualPortINTEL: return "TrueDualPortINTEL"; + case Decoration::BurstCoalesceINTEL: return "BurstCoalesceINTEL"; + case Decoration::CacheSizeINTEL: return "CacheSizeINTEL"; + case Decoration::DontStaticallyCoalesceINTEL: return "DontStaticallyCoalesceINTEL"; + case Decoration::PrefetchINTEL: return "PrefetchINTEL"; + case Decoration::StallEnableINTEL: return "StallEnableINTEL"; + case Decoration::FuseLoopsInFunctionINTEL: return "FuseLoopsInFunctionINTEL"; + case Decoration::MathOpDSPModeINTEL: return "MathOpDSPModeINTEL"; + case Decoration::AliasScopeINTEL: return "AliasScopeINTEL"; + case Decoration::NoAliasINTEL: return "NoAliasINTEL"; + case Decoration::InitiationIntervalINTEL: return "InitiationIntervalINTEL"; + case Decoration::MaxConcurrencyINTEL: return "MaxConcurrencyINTEL"; + case Decoration::PipelineEnableINTEL: return "PipelineEnableINTEL"; + case Decoration::BufferLocationINTEL: return "BufferLocationINTEL"; + case Decoration::IOPipeStorageINTEL: return "IOPipeStorageINTEL"; + case Decoration::FunctionFloatingPointModeINTEL: return "FunctionFloatingPointModeINTEL"; + case Decoration::SingleElementVectorINTEL: return "SingleElementVectorINTEL"; + case Decoration::VectorComputeCallableFunctionINTEL: return "VectorComputeCallableFunctionINTEL"; + case Decoration::MediaBlockIOINTEL: return "MediaBlockIOINTEL"; + case Decoration::StallFreeINTEL: return "StallFreeINTEL"; + case Decoration::FPMaxErrorDecorationINTEL: return "FPMaxErrorDecorationINTEL"; + case Decoration::LatencyControlLabelINTEL: return "LatencyControlLabelINTEL"; + case Decoration::LatencyControlConstraintINTEL: return "LatencyControlConstraintINTEL"; + case Decoration::ConduitKernelArgumentINTEL: return "ConduitKernelArgumentINTEL"; + case Decoration::RegisterMapKernelArgumentINTEL: return "RegisterMapKernelArgumentINTEL"; + case Decoration::MMHostInterfaceAddressWidthINTEL: return "MMHostInterfaceAddressWidthINTEL"; + case Decoration::MMHostInterfaceDataWidthINTEL: return "MMHostInterfaceDataWidthINTEL"; + case Decoration::MMHostInterfaceLatencyINTEL: return "MMHostInterfaceLatencyINTEL"; + case Decoration::MMHostInterfaceReadWriteModeINTEL: return "MMHostInterfaceReadWriteModeINTEL"; + case Decoration::MMHostInterfaceMaxBurstINTEL: return "MMHostInterfaceMaxBurstINTEL"; + case Decoration::MMHostInterfaceWaitRequestINTEL: return "MMHostInterfaceWaitRequestINTEL"; + case Decoration::StableKernelArgumentINTEL: return "StableKernelArgumentINTEL"; + case Decoration::HostAccessINTEL: return "HostAccessINTEL"; + case Decoration::InitModeINTEL: return "InitModeINTEL"; + case Decoration::ImplementInRegisterMapINTEL: return "ImplementInRegisterMapINTEL"; + case Decoration::CacheControlLoadINTEL: return "CacheControlLoadINTEL"; + case Decoration::CacheControlStoreINTEL: return "CacheControlStoreINTEL"; + default: return "Unknown"; + } +} + +inline const char* BuiltInToString(BuiltIn value) { + switch (value) { + case BuiltIn::Position: return "Position"; + case BuiltIn::PointSize: return "PointSize"; + case BuiltIn::ClipDistance: return "ClipDistance"; + case BuiltIn::CullDistance: return "CullDistance"; + case BuiltIn::VertexId: return "VertexId"; + case BuiltIn::InstanceId: return "InstanceId"; + case BuiltIn::PrimitiveId: return "PrimitiveId"; + case BuiltIn::InvocationId: return "InvocationId"; + case BuiltIn::Layer: return "Layer"; + case BuiltIn::ViewportIndex: return "ViewportIndex"; + case BuiltIn::TessLevelOuter: return "TessLevelOuter"; + case BuiltIn::TessLevelInner: return "TessLevelInner"; + case BuiltIn::TessCoord: return "TessCoord"; + case BuiltIn::PatchVertices: return "PatchVertices"; + case BuiltIn::FragCoord: return "FragCoord"; + case BuiltIn::PointCoord: return "PointCoord"; + case BuiltIn::FrontFacing: return "FrontFacing"; + case BuiltIn::SampleId: return "SampleId"; + case BuiltIn::SamplePosition: return "SamplePosition"; + case BuiltIn::SampleMask: return "SampleMask"; + case BuiltIn::FragDepth: return "FragDepth"; + case BuiltIn::HelperInvocation: return "HelperInvocation"; + case BuiltIn::NumWorkgroups: return "NumWorkgroups"; + case BuiltIn::WorkgroupSize: return "WorkgroupSize"; + case BuiltIn::WorkgroupId: return "WorkgroupId"; + case BuiltIn::LocalInvocationId: return "LocalInvocationId"; + case BuiltIn::GlobalInvocationId: return "GlobalInvocationId"; + case BuiltIn::LocalInvocationIndex: return "LocalInvocationIndex"; + case BuiltIn::WorkDim: return "WorkDim"; + case BuiltIn::GlobalSize: return "GlobalSize"; + case BuiltIn::EnqueuedWorkgroupSize: return "EnqueuedWorkgroupSize"; + case BuiltIn::GlobalOffset: return "GlobalOffset"; + case BuiltIn::GlobalLinearId: return "GlobalLinearId"; + case BuiltIn::SubgroupSize: return "SubgroupSize"; + case BuiltIn::SubgroupMaxSize: return "SubgroupMaxSize"; + case BuiltIn::NumSubgroups: return "NumSubgroups"; + case BuiltIn::NumEnqueuedSubgroups: return "NumEnqueuedSubgroups"; + case BuiltIn::SubgroupId: return "SubgroupId"; + case BuiltIn::SubgroupLocalInvocationId: return "SubgroupLocalInvocationId"; + case BuiltIn::VertexIndex: return "VertexIndex"; + case BuiltIn::InstanceIndex: return "InstanceIndex"; + case BuiltIn::CoreIDARM: return "CoreIDARM"; + case BuiltIn::CoreCountARM: return "CoreCountARM"; + case BuiltIn::CoreMaxIDARM: return "CoreMaxIDARM"; + case BuiltIn::WarpIDARM: return "WarpIDARM"; + case BuiltIn::WarpMaxIDARM: return "WarpMaxIDARM"; + case BuiltIn::SubgroupEqMask: return "SubgroupEqMask"; + case BuiltIn::SubgroupGeMask: return "SubgroupGeMask"; + case BuiltIn::SubgroupGtMask: return "SubgroupGtMask"; + case BuiltIn::SubgroupLeMask: return "SubgroupLeMask"; + case BuiltIn::SubgroupLtMask: return "SubgroupLtMask"; + case BuiltIn::BaseVertex: return "BaseVertex"; + case BuiltIn::BaseInstance: return "BaseInstance"; + case BuiltIn::DrawIndex: return "DrawIndex"; + case BuiltIn::PrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR"; + case BuiltIn::DeviceIndex: return "DeviceIndex"; + case BuiltIn::ViewIndex: return "ViewIndex"; + case BuiltIn::ShadingRateKHR: return "ShadingRateKHR"; + case BuiltIn::BaryCoordNoPerspAMD: return "BaryCoordNoPerspAMD"; + case BuiltIn::BaryCoordNoPerspCentroidAMD: return "BaryCoordNoPerspCentroidAMD"; + case BuiltIn::BaryCoordNoPerspSampleAMD: return "BaryCoordNoPerspSampleAMD"; + case BuiltIn::BaryCoordSmoothAMD: return "BaryCoordSmoothAMD"; + case BuiltIn::BaryCoordSmoothCentroidAMD: return "BaryCoordSmoothCentroidAMD"; + case BuiltIn::BaryCoordSmoothSampleAMD: return "BaryCoordSmoothSampleAMD"; + case BuiltIn::BaryCoordPullModelAMD: return "BaryCoordPullModelAMD"; + case BuiltIn::FragStencilRefEXT: return "FragStencilRefEXT"; + case BuiltIn::RemainingRecursionLevelsAMDX: return "RemainingRecursionLevelsAMDX"; + case BuiltIn::ShaderIndexAMDX: return "ShaderIndexAMDX"; + case BuiltIn::ViewportMaskNV: return "ViewportMaskNV"; + case BuiltIn::SecondaryPositionNV: return "SecondaryPositionNV"; + case BuiltIn::SecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; + case BuiltIn::PositionPerViewNV: return "PositionPerViewNV"; + case BuiltIn::ViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; + case BuiltIn::FullyCoveredEXT: return "FullyCoveredEXT"; + case BuiltIn::TaskCountNV: return "TaskCountNV"; + case BuiltIn::PrimitiveCountNV: return "PrimitiveCountNV"; + case BuiltIn::PrimitiveIndicesNV: return "PrimitiveIndicesNV"; + case BuiltIn::ClipDistancePerViewNV: return "ClipDistancePerViewNV"; + case BuiltIn::CullDistancePerViewNV: return "CullDistancePerViewNV"; + case BuiltIn::LayerPerViewNV: return "LayerPerViewNV"; + case BuiltIn::MeshViewCountNV: return "MeshViewCountNV"; + case BuiltIn::MeshViewIndicesNV: return "MeshViewIndicesNV"; + case BuiltIn::BaryCoordKHR: return "BaryCoordKHR"; + case BuiltIn::BaryCoordNoPerspKHR: return "BaryCoordNoPerspKHR"; + case BuiltIn::FragSizeEXT: return "FragSizeEXT"; + case BuiltIn::FragInvocationCountEXT: return "FragInvocationCountEXT"; + case BuiltIn::PrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT"; + case BuiltIn::PrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT"; + case BuiltIn::PrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT"; + case BuiltIn::CullPrimitiveEXT: return "CullPrimitiveEXT"; + case BuiltIn::LaunchIdKHR: return "LaunchIdKHR"; + case BuiltIn::LaunchSizeKHR: return "LaunchSizeKHR"; + case BuiltIn::WorldRayOriginKHR: return "WorldRayOriginKHR"; + case BuiltIn::WorldRayDirectionKHR: return "WorldRayDirectionKHR"; + case BuiltIn::ObjectRayOriginKHR: return "ObjectRayOriginKHR"; + case BuiltIn::ObjectRayDirectionKHR: return "ObjectRayDirectionKHR"; + case BuiltIn::RayTminKHR: return "RayTminKHR"; + case BuiltIn::RayTmaxKHR: return "RayTmaxKHR"; + case BuiltIn::InstanceCustomIndexKHR: return "InstanceCustomIndexKHR"; + case BuiltIn::ObjectToWorldKHR: return "ObjectToWorldKHR"; + case BuiltIn::WorldToObjectKHR: return "WorldToObjectKHR"; + case BuiltIn::HitTNV: return "HitTNV"; + case BuiltIn::HitKindKHR: return "HitKindKHR"; + case BuiltIn::CurrentRayTimeNV: return "CurrentRayTimeNV"; + case BuiltIn::HitTriangleVertexPositionsKHR: return "HitTriangleVertexPositionsKHR"; + case BuiltIn::HitMicroTriangleVertexPositionsNV: return "HitMicroTriangleVertexPositionsNV"; + case BuiltIn::HitMicroTriangleVertexBarycentricsNV: return "HitMicroTriangleVertexBarycentricsNV"; + case BuiltIn::IncomingRayFlagsKHR: return "IncomingRayFlagsKHR"; + case BuiltIn::RayGeometryIndexKHR: return "RayGeometryIndexKHR"; + case BuiltIn::HitIsSphereNV: return "HitIsSphereNV"; + case BuiltIn::HitIsLSSNV: return "HitIsLSSNV"; + case BuiltIn::HitSpherePositionNV: return "HitSpherePositionNV"; + case BuiltIn::WarpsPerSMNV: return "WarpsPerSMNV"; + case BuiltIn::SMCountNV: return "SMCountNV"; + case BuiltIn::WarpIDNV: return "WarpIDNV"; + case BuiltIn::SMIDNV: return "SMIDNV"; + case BuiltIn::HitLSSPositionsNV: return "HitLSSPositionsNV"; + case BuiltIn::HitKindFrontFacingMicroTriangleNV: return "HitKindFrontFacingMicroTriangleNV"; + case BuiltIn::HitKindBackFacingMicroTriangleNV: return "HitKindBackFacingMicroTriangleNV"; + case BuiltIn::HitSphereRadiusNV: return "HitSphereRadiusNV"; + case BuiltIn::HitLSSRadiiNV: return "HitLSSRadiiNV"; + case BuiltIn::ClusterIDNV: return "ClusterIDNV"; + case BuiltIn::CullMaskKHR: return "CullMaskKHR"; + default: return "Unknown"; + } +} + +inline const char* ScopeToString(Scope value) { + switch (value) { + case Scope::CrossDevice: return "CrossDevice"; + case Scope::Device: return "Device"; + case Scope::Workgroup: return "Workgroup"; + case Scope::Subgroup: return "Subgroup"; + case Scope::Invocation: return "Invocation"; + case Scope::QueueFamily: return "QueueFamily"; + case Scope::ShaderCallKHR: return "ShaderCallKHR"; + default: return "Unknown"; + } +} + +inline const char* GroupOperationToString(GroupOperation value) { + switch (value) { + case GroupOperation::Reduce: return "Reduce"; + case GroupOperation::InclusiveScan: return "InclusiveScan"; + case GroupOperation::ExclusiveScan: return "ExclusiveScan"; + case GroupOperation::ClusteredReduce: return "ClusteredReduce"; + case GroupOperation::PartitionedReduceNV: return "PartitionedReduceNV"; + case GroupOperation::PartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV"; + case GroupOperation::PartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV"; + default: return "Unknown"; + } +} + +inline const char* KernelEnqueueFlagsToString(KernelEnqueueFlags value) { + switch (value) { + case KernelEnqueueFlags::NoWait: return "NoWait"; + case KernelEnqueueFlags::WaitKernel: return "WaitKernel"; + case KernelEnqueueFlags::WaitWorkGroup: return "WaitWorkGroup"; + default: return "Unknown"; + } +} + +inline const char* CapabilityToString(Capability value) { + switch (value) { + case Capability::Matrix: return "Matrix"; + case Capability::Shader: return "Shader"; + case Capability::Geometry: return "Geometry"; + case Capability::Tessellation: return "Tessellation"; + case Capability::Addresses: return "Addresses"; + case Capability::Linkage: return "Linkage"; + case Capability::Kernel: return "Kernel"; + case Capability::Vector16: return "Vector16"; + case Capability::Float16Buffer: return "Float16Buffer"; + case Capability::Float16: return "Float16"; + case Capability::Float64: return "Float64"; + case Capability::Int64: return "Int64"; + case Capability::Int64Atomics: return "Int64Atomics"; + case Capability::ImageBasic: return "ImageBasic"; + case Capability::ImageReadWrite: return "ImageReadWrite"; + case Capability::ImageMipmap: return "ImageMipmap"; + case Capability::Pipes: return "Pipes"; + case Capability::Groups: return "Groups"; + case Capability::DeviceEnqueue: return "DeviceEnqueue"; + case Capability::LiteralSampler: return "LiteralSampler"; + case Capability::AtomicStorage: return "AtomicStorage"; + case Capability::Int16: return "Int16"; + case Capability::TessellationPointSize: return "TessellationPointSize"; + case Capability::GeometryPointSize: return "GeometryPointSize"; + case Capability::ImageGatherExtended: return "ImageGatherExtended"; + case Capability::StorageImageMultisample: return "StorageImageMultisample"; + case Capability::UniformBufferArrayDynamicIndexing: return "UniformBufferArrayDynamicIndexing"; + case Capability::SampledImageArrayDynamicIndexing: return "SampledImageArrayDynamicIndexing"; + case Capability::StorageBufferArrayDynamicIndexing: return "StorageBufferArrayDynamicIndexing"; + case Capability::StorageImageArrayDynamicIndexing: return "StorageImageArrayDynamicIndexing"; + case Capability::ClipDistance: return "ClipDistance"; + case Capability::CullDistance: return "CullDistance"; + case Capability::ImageCubeArray: return "ImageCubeArray"; + case Capability::SampleRateShading: return "SampleRateShading"; + case Capability::ImageRect: return "ImageRect"; + case Capability::SampledRect: return "SampledRect"; + case Capability::GenericPointer: return "GenericPointer"; + case Capability::Int8: return "Int8"; + case Capability::InputAttachment: return "InputAttachment"; + case Capability::SparseResidency: return "SparseResidency"; + case Capability::MinLod: return "MinLod"; + case Capability::Sampled1D: return "Sampled1D"; + case Capability::Image1D: return "Image1D"; + case Capability::SampledCubeArray: return "SampledCubeArray"; + case Capability::SampledBuffer: return "SampledBuffer"; + case Capability::ImageBuffer: return "ImageBuffer"; + case Capability::ImageMSArray: return "ImageMSArray"; + case Capability::StorageImageExtendedFormats: return "StorageImageExtendedFormats"; + case Capability::ImageQuery: return "ImageQuery"; + case Capability::DerivativeControl: return "DerivativeControl"; + case Capability::InterpolationFunction: return "InterpolationFunction"; + case Capability::TransformFeedback: return "TransformFeedback"; + case Capability::GeometryStreams: return "GeometryStreams"; + case Capability::StorageImageReadWithoutFormat: return "StorageImageReadWithoutFormat"; + case Capability::StorageImageWriteWithoutFormat: return "StorageImageWriteWithoutFormat"; + case Capability::MultiViewport: return "MultiViewport"; + case Capability::SubgroupDispatch: return "SubgroupDispatch"; + case Capability::NamedBarrier: return "NamedBarrier"; + case Capability::PipeStorage: return "PipeStorage"; + case Capability::GroupNonUniform: return "GroupNonUniform"; + case Capability::GroupNonUniformVote: return "GroupNonUniformVote"; + case Capability::GroupNonUniformArithmetic: return "GroupNonUniformArithmetic"; + case Capability::GroupNonUniformBallot: return "GroupNonUniformBallot"; + case Capability::GroupNonUniformShuffle: return "GroupNonUniformShuffle"; + case Capability::GroupNonUniformShuffleRelative: return "GroupNonUniformShuffleRelative"; + case Capability::GroupNonUniformClustered: return "GroupNonUniformClustered"; + case Capability::GroupNonUniformQuad: return "GroupNonUniformQuad"; + case Capability::ShaderLayer: return "ShaderLayer"; + case Capability::ShaderViewportIndex: return "ShaderViewportIndex"; + case Capability::UniformDecoration: return "UniformDecoration"; + case Capability::CoreBuiltinsARM: return "CoreBuiltinsARM"; + case Capability::TileImageColorReadAccessEXT: return "TileImageColorReadAccessEXT"; + case Capability::TileImageDepthReadAccessEXT: return "TileImageDepthReadAccessEXT"; + case Capability::TileImageStencilReadAccessEXT: return "TileImageStencilReadAccessEXT"; + case Capability::CooperativeMatrixLayoutsARM: return "CooperativeMatrixLayoutsARM"; + case Capability::FragmentShadingRateKHR: return "FragmentShadingRateKHR"; + case Capability::SubgroupBallotKHR: return "SubgroupBallotKHR"; + case Capability::DrawParameters: return "DrawParameters"; + case Capability::WorkgroupMemoryExplicitLayoutKHR: return "WorkgroupMemoryExplicitLayoutKHR"; + case Capability::WorkgroupMemoryExplicitLayout8BitAccessKHR: return "WorkgroupMemoryExplicitLayout8BitAccessKHR"; + case Capability::WorkgroupMemoryExplicitLayout16BitAccessKHR: return "WorkgroupMemoryExplicitLayout16BitAccessKHR"; + case Capability::SubgroupVoteKHR: return "SubgroupVoteKHR"; + case Capability::StorageBuffer16BitAccess: return "StorageBuffer16BitAccess"; + case Capability::StorageUniform16: return "StorageUniform16"; + case Capability::StoragePushConstant16: return "StoragePushConstant16"; + case Capability::StorageInputOutput16: return "StorageInputOutput16"; + case Capability::DeviceGroup: return "DeviceGroup"; + case Capability::MultiView: return "MultiView"; + case Capability::VariablePointersStorageBuffer: return "VariablePointersStorageBuffer"; + case Capability::VariablePointers: return "VariablePointers"; + case Capability::AtomicStorageOps: return "AtomicStorageOps"; + case Capability::SampleMaskPostDepthCoverage: return "SampleMaskPostDepthCoverage"; + case Capability::StorageBuffer8BitAccess: return "StorageBuffer8BitAccess"; + case Capability::UniformAndStorageBuffer8BitAccess: return "UniformAndStorageBuffer8BitAccess"; + case Capability::StoragePushConstant8: return "StoragePushConstant8"; + case Capability::DenormPreserve: return "DenormPreserve"; + case Capability::DenormFlushToZero: return "DenormFlushToZero"; + case Capability::SignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve"; + case Capability::RoundingModeRTE: return "RoundingModeRTE"; + case Capability::RoundingModeRTZ: return "RoundingModeRTZ"; + case Capability::RayQueryProvisionalKHR: return "RayQueryProvisionalKHR"; + case Capability::RayQueryKHR: return "RayQueryKHR"; + case Capability::UntypedPointersKHR: return "UntypedPointersKHR"; + case Capability::RayTraversalPrimitiveCullingKHR: return "RayTraversalPrimitiveCullingKHR"; + case Capability::RayTracingKHR: return "RayTracingKHR"; + case Capability::TextureSampleWeightedQCOM: return "TextureSampleWeightedQCOM"; + case Capability::TextureBoxFilterQCOM: return "TextureBoxFilterQCOM"; + case Capability::TextureBlockMatchQCOM: return "TextureBlockMatchQCOM"; + case Capability::TextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM"; + case Capability::Float16ImageAMD: return "Float16ImageAMD"; + case Capability::ImageGatherBiasLodAMD: return "ImageGatherBiasLodAMD"; + case Capability::FragmentMaskAMD: return "FragmentMaskAMD"; + case Capability::StencilExportEXT: return "StencilExportEXT"; + case Capability::ImageReadWriteLodAMD: return "ImageReadWriteLodAMD"; + case Capability::Int64ImageEXT: return "Int64ImageEXT"; + case Capability::ShaderClockKHR: return "ShaderClockKHR"; + case Capability::ShaderEnqueueAMDX: return "ShaderEnqueueAMDX"; + case Capability::QuadControlKHR: return "QuadControlKHR"; + case Capability::SampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV"; + case Capability::GeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV"; + case Capability::ShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT"; + case Capability::ShaderViewportMaskNV: return "ShaderViewportMaskNV"; + case Capability::ShaderStereoViewNV: return "ShaderStereoViewNV"; + case Capability::PerViewAttributesNV: return "PerViewAttributesNV"; + case Capability::FragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT"; + case Capability::MeshShadingNV: return "MeshShadingNV"; + case Capability::ImageFootprintNV: return "ImageFootprintNV"; + case Capability::MeshShadingEXT: return "MeshShadingEXT"; + case Capability::FragmentBarycentricKHR: return "FragmentBarycentricKHR"; + case Capability::ComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR"; + case Capability::FragmentDensityEXT: return "FragmentDensityEXT"; + case Capability::GroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; + case Capability::ShaderNonUniform: return "ShaderNonUniform"; + case Capability::RuntimeDescriptorArray: return "RuntimeDescriptorArray"; + case Capability::InputAttachmentArrayDynamicIndexing: return "InputAttachmentArrayDynamicIndexing"; + case Capability::UniformTexelBufferArrayDynamicIndexing: return "UniformTexelBufferArrayDynamicIndexing"; + case Capability::StorageTexelBufferArrayDynamicIndexing: return "StorageTexelBufferArrayDynamicIndexing"; + case Capability::UniformBufferArrayNonUniformIndexing: return "UniformBufferArrayNonUniformIndexing"; + case Capability::SampledImageArrayNonUniformIndexing: return "SampledImageArrayNonUniformIndexing"; + case Capability::StorageBufferArrayNonUniformIndexing: return "StorageBufferArrayNonUniformIndexing"; + case Capability::StorageImageArrayNonUniformIndexing: return "StorageImageArrayNonUniformIndexing"; + case Capability::InputAttachmentArrayNonUniformIndexing: return "InputAttachmentArrayNonUniformIndexing"; + case Capability::UniformTexelBufferArrayNonUniformIndexing: return "UniformTexelBufferArrayNonUniformIndexing"; + case Capability::StorageTexelBufferArrayNonUniformIndexing: return "StorageTexelBufferArrayNonUniformIndexing"; + case Capability::RayTracingPositionFetchKHR: return "RayTracingPositionFetchKHR"; + case Capability::RayTracingNV: return "RayTracingNV"; + case Capability::RayTracingMotionBlurNV: return "RayTracingMotionBlurNV"; + case Capability::VulkanMemoryModel: return "VulkanMemoryModel"; + case Capability::VulkanMemoryModelDeviceScope: return "VulkanMemoryModelDeviceScope"; + case Capability::PhysicalStorageBufferAddresses: return "PhysicalStorageBufferAddresses"; + case Capability::ComputeDerivativeGroupLinearKHR: return "ComputeDerivativeGroupLinearKHR"; + case Capability::RayTracingProvisionalKHR: return "RayTracingProvisionalKHR"; + case Capability::CooperativeMatrixNV: return "CooperativeMatrixNV"; + case Capability::FragmentShaderSampleInterlockEXT: return "FragmentShaderSampleInterlockEXT"; + case Capability::FragmentShaderShadingRateInterlockEXT: return "FragmentShaderShadingRateInterlockEXT"; + case Capability::ShaderSMBuiltinsNV: return "ShaderSMBuiltinsNV"; + case Capability::FragmentShaderPixelInterlockEXT: return "FragmentShaderPixelInterlockEXT"; + case Capability::DemoteToHelperInvocation: return "DemoteToHelperInvocation"; + case Capability::DisplacementMicromapNV: return "DisplacementMicromapNV"; + case Capability::RayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT"; + case Capability::ShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + case Capability::BindlessTextureNV: return "BindlessTextureNV"; + case Capability::RayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR"; + case Capability::CooperativeVectorNV: return "CooperativeVectorNV"; + case Capability::AtomicFloat16VectorNV: return "AtomicFloat16VectorNV"; + case Capability::RayTracingDisplacementMicromapNV: return "RayTracingDisplacementMicromapNV"; + case Capability::RawAccessChainsNV: return "RawAccessChainsNV"; + case Capability::RayTracingSpheresGeometryNV: return "RayTracingSpheresGeometryNV"; + case Capability::RayTracingLinearSweptSpheresGeometryNV: return "RayTracingLinearSweptSpheresGeometryNV"; + case Capability::CooperativeMatrixReductionsNV: return "CooperativeMatrixReductionsNV"; + case Capability::CooperativeMatrixConversionsNV: return "CooperativeMatrixConversionsNV"; + case Capability::CooperativeMatrixPerElementOperationsNV: return "CooperativeMatrixPerElementOperationsNV"; + case Capability::CooperativeMatrixTensorAddressingNV: return "CooperativeMatrixTensorAddressingNV"; + case Capability::CooperativeMatrixBlockLoadsNV: return "CooperativeMatrixBlockLoadsNV"; + case Capability::CooperativeVectorTrainingNV: return "CooperativeVectorTrainingNV"; + case Capability::RayTracingClusterAccelerationStructureNV: return "RayTracingClusterAccelerationStructureNV"; + case Capability::TensorAddressingNV: return "TensorAddressingNV"; + case Capability::SubgroupShuffleINTEL: return "SubgroupShuffleINTEL"; + case Capability::SubgroupBufferBlockIOINTEL: return "SubgroupBufferBlockIOINTEL"; + case Capability::SubgroupImageBlockIOINTEL: return "SubgroupImageBlockIOINTEL"; + case Capability::SubgroupImageMediaBlockIOINTEL: return "SubgroupImageMediaBlockIOINTEL"; + case Capability::RoundToInfinityINTEL: return "RoundToInfinityINTEL"; + case Capability::FloatingPointModeINTEL: return "FloatingPointModeINTEL"; + case Capability::IntegerFunctions2INTEL: return "IntegerFunctions2INTEL"; + case Capability::FunctionPointersINTEL: return "FunctionPointersINTEL"; + case Capability::IndirectReferencesINTEL: return "IndirectReferencesINTEL"; + case Capability::AsmINTEL: return "AsmINTEL"; + case Capability::AtomicFloat32MinMaxEXT: return "AtomicFloat32MinMaxEXT"; + case Capability::AtomicFloat64MinMaxEXT: return "AtomicFloat64MinMaxEXT"; + case Capability::AtomicFloat16MinMaxEXT: return "AtomicFloat16MinMaxEXT"; + case Capability::VectorComputeINTEL: return "VectorComputeINTEL"; + case Capability::VectorAnyINTEL: return "VectorAnyINTEL"; + case Capability::ExpectAssumeKHR: return "ExpectAssumeKHR"; + case Capability::SubgroupAvcMotionEstimationINTEL: return "SubgroupAvcMotionEstimationINTEL"; + case Capability::SubgroupAvcMotionEstimationIntraINTEL: return "SubgroupAvcMotionEstimationIntraINTEL"; + case Capability::SubgroupAvcMotionEstimationChromaINTEL: return "SubgroupAvcMotionEstimationChromaINTEL"; + case Capability::VariableLengthArrayINTEL: return "VariableLengthArrayINTEL"; + case Capability::FunctionFloatControlINTEL: return "FunctionFloatControlINTEL"; + case Capability::FPGAMemoryAttributesINTEL: return "FPGAMemoryAttributesINTEL"; + case Capability::FPFastMathModeINTEL: return "FPFastMathModeINTEL"; + case Capability::ArbitraryPrecisionIntegersINTEL: return "ArbitraryPrecisionIntegersINTEL"; + case Capability::ArbitraryPrecisionFloatingPointINTEL: return "ArbitraryPrecisionFloatingPointINTEL"; + case Capability::UnstructuredLoopControlsINTEL: return "UnstructuredLoopControlsINTEL"; + case Capability::FPGALoopControlsINTEL: return "FPGALoopControlsINTEL"; + case Capability::KernelAttributesINTEL: return "KernelAttributesINTEL"; + case Capability::FPGAKernelAttributesINTEL: return "FPGAKernelAttributesINTEL"; + case Capability::FPGAMemoryAccessesINTEL: return "FPGAMemoryAccessesINTEL"; + case Capability::FPGAClusterAttributesINTEL: return "FPGAClusterAttributesINTEL"; + case Capability::LoopFuseINTEL: return "LoopFuseINTEL"; + case Capability::FPGADSPControlINTEL: return "FPGADSPControlINTEL"; + case Capability::MemoryAccessAliasingINTEL: return "MemoryAccessAliasingINTEL"; + case Capability::FPGAInvocationPipeliningAttributesINTEL: return "FPGAInvocationPipeliningAttributesINTEL"; + case Capability::FPGABufferLocationINTEL: return "FPGABufferLocationINTEL"; + case Capability::ArbitraryPrecisionFixedPointINTEL: return "ArbitraryPrecisionFixedPointINTEL"; + case Capability::USMStorageClassesINTEL: return "USMStorageClassesINTEL"; + case Capability::RuntimeAlignedAttributeINTEL: return "RuntimeAlignedAttributeINTEL"; + case Capability::IOPipesINTEL: return "IOPipesINTEL"; + case Capability::BlockingPipesINTEL: return "BlockingPipesINTEL"; + case Capability::FPGARegINTEL: return "FPGARegINTEL"; + case Capability::DotProductInputAll: return "DotProductInputAll"; + case Capability::DotProductInput4x8Bit: return "DotProductInput4x8Bit"; + case Capability::DotProductInput4x8BitPacked: return "DotProductInput4x8BitPacked"; + case Capability::DotProduct: return "DotProduct"; + case Capability::RayCullMaskKHR: return "RayCullMaskKHR"; + case Capability::CooperativeMatrixKHR: return "CooperativeMatrixKHR"; + case Capability::ReplicatedCompositesEXT: return "ReplicatedCompositesEXT"; + case Capability::BitInstructions: return "BitInstructions"; + case Capability::GroupNonUniformRotateKHR: return "GroupNonUniformRotateKHR"; + case Capability::FloatControls2: return "FloatControls2"; + case Capability::AtomicFloat32AddEXT: return "AtomicFloat32AddEXT"; + case Capability::AtomicFloat64AddEXT: return "AtomicFloat64AddEXT"; + case Capability::LongCompositesINTEL: return "LongCompositesINTEL"; + case Capability::OptNoneEXT: return "OptNoneEXT"; + case Capability::AtomicFloat16AddEXT: return "AtomicFloat16AddEXT"; + case Capability::DebugInfoModuleINTEL: return "DebugInfoModuleINTEL"; + case Capability::BFloat16ConversionINTEL: return "BFloat16ConversionINTEL"; + case Capability::SplitBarrierINTEL: return "SplitBarrierINTEL"; + case Capability::ArithmeticFenceEXT: return "ArithmeticFenceEXT"; + case Capability::FPGAClusterAttributesV2INTEL: return "FPGAClusterAttributesV2INTEL"; + case Capability::FPGAKernelAttributesv2INTEL: return "FPGAKernelAttributesv2INTEL"; + case Capability::FPMaxErrorINTEL: return "FPMaxErrorINTEL"; + case Capability::FPGALatencyControlINTEL: return "FPGALatencyControlINTEL"; + case Capability::FPGAArgumentInterfacesINTEL: return "FPGAArgumentInterfacesINTEL"; + case Capability::GlobalVariableHostAccessINTEL: return "GlobalVariableHostAccessINTEL"; + case Capability::GlobalVariableFPGADecorationsINTEL: return "GlobalVariableFPGADecorationsINTEL"; + case Capability::SubgroupBufferPrefetchINTEL: return "SubgroupBufferPrefetchINTEL"; + case Capability::Subgroup2DBlockIOINTEL: return "Subgroup2DBlockIOINTEL"; + case Capability::Subgroup2DBlockTransformINTEL: return "Subgroup2DBlockTransformINTEL"; + case Capability::Subgroup2DBlockTransposeINTEL: return "Subgroup2DBlockTransposeINTEL"; + case Capability::SubgroupMatrixMultiplyAccumulateINTEL: return "SubgroupMatrixMultiplyAccumulateINTEL"; + case Capability::GroupUniformArithmeticKHR: return "GroupUniformArithmeticKHR"; + case Capability::MaskedGatherScatterINTEL: return "MaskedGatherScatterINTEL"; + case Capability::CacheControlsINTEL: return "CacheControlsINTEL"; + case Capability::RegisterLimitsINTEL: return "RegisterLimitsINTEL"; + default: return "Unknown"; + } +} + +inline const char* RayQueryIntersectionToString(RayQueryIntersection value) { + switch (value) { + case RayQueryIntersection::RayQueryCandidateIntersectionKHR: return "RayQueryCandidateIntersectionKHR"; + case RayQueryIntersection::RayQueryCommittedIntersectionKHR: return "RayQueryCommittedIntersectionKHR"; + default: return "Unknown"; + } +} + +inline const char* RayQueryCommittedIntersectionTypeToString(RayQueryCommittedIntersectionType value) { + switch (value) { + case RayQueryCommittedIntersectionType::RayQueryCommittedIntersectionNoneKHR: return "RayQueryCommittedIntersectionNoneKHR"; + case RayQueryCommittedIntersectionType::RayQueryCommittedIntersectionTriangleKHR: return "RayQueryCommittedIntersectionTriangleKHR"; + case RayQueryCommittedIntersectionType::RayQueryCommittedIntersectionGeneratedKHR: return "RayQueryCommittedIntersectionGeneratedKHR"; + default: return "Unknown"; + } +} + +inline const char* RayQueryCandidateIntersectionTypeToString(RayQueryCandidateIntersectionType value) { + switch (value) { + case RayQueryCandidateIntersectionType::RayQueryCandidateIntersectionTriangleKHR: return "RayQueryCandidateIntersectionTriangleKHR"; + case RayQueryCandidateIntersectionType::RayQueryCandidateIntersectionAABBKHR: return "RayQueryCandidateIntersectionAABBKHR"; + default: return "Unknown"; + } +} + +inline const char* FPDenormModeToString(FPDenormMode value) { + switch (value) { + case FPDenormMode::Preserve: return "Preserve"; + case FPDenormMode::FlushToZero: return "FlushToZero"; + default: return "Unknown"; + } +} + +inline const char* FPOperationModeToString(FPOperationMode value) { + switch (value) { + case FPOperationMode::IEEE: return "IEEE"; + case FPOperationMode::ALT: return "ALT"; + default: return "Unknown"; + } +} + +inline const char* QuantizationModesToString(QuantizationModes value) { + switch (value) { + case QuantizationModes::TRN: return "TRN"; + case QuantizationModes::TRN_ZERO: return "TRN_ZERO"; + case QuantizationModes::RND: return "RND"; + case QuantizationModes::RND_ZERO: return "RND_ZERO"; + case QuantizationModes::RND_INF: return "RND_INF"; + case QuantizationModes::RND_MIN_INF: return "RND_MIN_INF"; + case QuantizationModes::RND_CONV: return "RND_CONV"; + case QuantizationModes::RND_CONV_ODD: return "RND_CONV_ODD"; + default: return "Unknown"; + } +} + +inline const char* OverflowModesToString(OverflowModes value) { + switch (value) { + case OverflowModes::WRAP: return "WRAP"; + case OverflowModes::SAT: return "SAT"; + case OverflowModes::SAT_ZERO: return "SAT_ZERO"; + case OverflowModes::SAT_SYM: return "SAT_SYM"; + default: return "Unknown"; + } +} + +inline const char* PackedVectorFormatToString(PackedVectorFormat value) { + switch (value) { + case PackedVectorFormat::PackedVectorFormat4x8Bit: return "PackedVectorFormat4x8Bit"; + default: return "Unknown"; + } +} + +inline const char* CooperativeMatrixLayoutToString(CooperativeMatrixLayout value) { + switch (value) { + case CooperativeMatrixLayout::RowMajorKHR: return "RowMajorKHR"; + case CooperativeMatrixLayout::ColumnMajorKHR: return "ColumnMajorKHR"; + case CooperativeMatrixLayout::RowBlockedInterleavedARM: return "RowBlockedInterleavedARM"; + case CooperativeMatrixLayout::ColumnBlockedInterleavedARM: return "ColumnBlockedInterleavedARM"; + default: return "Unknown"; + } +} + +inline const char* CooperativeMatrixUseToString(CooperativeMatrixUse value) { + switch (value) { + case CooperativeMatrixUse::MatrixAKHR: return "MatrixAKHR"; + case CooperativeMatrixUse::MatrixBKHR: return "MatrixBKHR"; + case CooperativeMatrixUse::MatrixAccumulatorKHR: return "MatrixAccumulatorKHR"; + default: return "Unknown"; + } +} + +inline const char* TensorClampModeToString(TensorClampMode value) { + switch (value) { + case TensorClampMode::Undefined: return "Undefined"; + case TensorClampMode::Constant: return "Constant"; + case TensorClampMode::ClampToEdge: return "ClampToEdge"; + case TensorClampMode::Repeat: return "Repeat"; + case TensorClampMode::RepeatMirrored: return "RepeatMirrored"; + default: return "Unknown"; + } +} + +inline const char* InitializationModeQualifierToString(InitializationModeQualifier value) { + switch (value) { + case InitializationModeQualifier::InitOnDeviceReprogramINTEL: return "InitOnDeviceReprogramINTEL"; + case InitializationModeQualifier::InitOnDeviceResetINTEL: return "InitOnDeviceResetINTEL"; + default: return "Unknown"; + } +} + +inline const char* HostAccessQualifierToString(HostAccessQualifier value) { + switch (value) { + case HostAccessQualifier::NoneINTEL: return "NoneINTEL"; + case HostAccessQualifier::ReadINTEL: return "ReadINTEL"; + case HostAccessQualifier::WriteINTEL: return "WriteINTEL"; + case HostAccessQualifier::ReadWriteINTEL: return "ReadWriteINTEL"; + default: return "Unknown"; + } +} + +inline const char* LoadCacheControlToString(LoadCacheControl value) { + switch (value) { + case LoadCacheControl::UncachedINTEL: return "UncachedINTEL"; + case LoadCacheControl::CachedINTEL: return "CachedINTEL"; + case LoadCacheControl::StreamingINTEL: return "StreamingINTEL"; + case LoadCacheControl::InvalidateAfterReadINTEL: return "InvalidateAfterReadINTEL"; + case LoadCacheControl::ConstCachedINTEL: return "ConstCachedINTEL"; + default: return "Unknown"; + } +} + +inline const char* StoreCacheControlToString(StoreCacheControl value) { + switch (value) { + case StoreCacheControl::UncachedINTEL: return "UncachedINTEL"; + case StoreCacheControl::WriteThroughINTEL: return "WriteThroughINTEL"; + case StoreCacheControl::WriteBackINTEL: return "WriteBackINTEL"; + case StoreCacheControl::StreamingINTEL: return "StreamingINTEL"; + default: return "Unknown"; + } +} + +inline const char* NamedMaximumNumberOfRegistersToString(NamedMaximumNumberOfRegisters value) { + switch (value) { + case NamedMaximumNumberOfRegisters::AutoINTEL: return "AutoINTEL"; + default: return "Unknown"; + } +} + +inline const char* FPEncodingToString(FPEncoding value) { + switch (value) { + default: return "Unknown"; + } +} + +inline const char* CooperativeVectorMatrixLayoutToString(CooperativeVectorMatrixLayout value) { + switch (value) { + case CooperativeVectorMatrixLayout::RowMajorNV: return "RowMajorNV"; + case CooperativeVectorMatrixLayout::ColumnMajorNV: return "ColumnMajorNV"; + case CooperativeVectorMatrixLayout::InferencingOptimalNV: return "InferencingOptimalNV"; + case CooperativeVectorMatrixLayout::TrainingOptimalNV: return "TrainingOptimalNV"; + default: return "Unknown"; + } +} + +inline const char* ComponentTypeToString(ComponentType value) { + switch (value) { + case ComponentType::Float16NV: return "Float16NV"; + case ComponentType::Float32NV: return "Float32NV"; + case ComponentType::Float64NV: return "Float64NV"; + case ComponentType::SignedInt8NV: return "SignedInt8NV"; + case ComponentType::SignedInt16NV: return "SignedInt16NV"; + case ComponentType::SignedInt32NV: return "SignedInt32NV"; + case ComponentType::SignedInt64NV: return "SignedInt64NV"; + case ComponentType::UnsignedInt8NV: return "UnsignedInt8NV"; + case ComponentType::UnsignedInt16NV: return "UnsignedInt16NV"; + case ComponentType::UnsignedInt32NV: return "UnsignedInt32NV"; + case ComponentType::UnsignedInt64NV: return "UnsignedInt64NV"; + case ComponentType::SignedInt8PackedNV: return "SignedInt8PackedNV"; + case ComponentType::UnsignedInt8PackedNV: return "UnsignedInt8PackedNV"; + case ComponentType::FloatE4M3NV: return "FloatE4M3NV"; + case ComponentType::FloatE5M2NV: return "FloatE5M2NV"; + default: return "Unknown"; + } +} + +inline const char* OpToString(Op value) { + switch (value) { + case Op::OpNop: return "OpNop"; + case Op::OpUndef: return "OpUndef"; + case Op::OpSourceContinued: return "OpSourceContinued"; + case Op::OpSource: return "OpSource"; + case Op::OpSourceExtension: return "OpSourceExtension"; + case Op::OpName: return "OpName"; + case Op::OpMemberName: return "OpMemberName"; + case Op::OpString: return "OpString"; + case Op::OpLine: return "OpLine"; + case Op::OpExtension: return "OpExtension"; + case Op::OpExtInstImport: return "OpExtInstImport"; + case Op::OpExtInst: return "OpExtInst"; + case Op::OpMemoryModel: return "OpMemoryModel"; + case Op::OpEntryPoint: return "OpEntryPoint"; + case Op::OpExecutionMode: return "OpExecutionMode"; + case Op::OpCapability: return "OpCapability"; + case Op::OpTypeVoid: return "OpTypeVoid"; + case Op::OpTypeBool: return "OpTypeBool"; + case Op::OpTypeInt: return "OpTypeInt"; + case Op::OpTypeFloat: return "OpTypeFloat"; + case Op::OpTypeVector: return "OpTypeVector"; + case Op::OpTypeMatrix: return "OpTypeMatrix"; + case Op::OpTypeImage: return "OpTypeImage"; + case Op::OpTypeSampler: return "OpTypeSampler"; + case Op::OpTypeSampledImage: return "OpTypeSampledImage"; + case Op::OpTypeArray: return "OpTypeArray"; + case Op::OpTypeRuntimeArray: return "OpTypeRuntimeArray"; + case Op::OpTypeStruct: return "OpTypeStruct"; + case Op::OpTypeOpaque: return "OpTypeOpaque"; + case Op::OpTypePointer: return "OpTypePointer"; + case Op::OpTypeFunction: return "OpTypeFunction"; + case Op::OpTypeEvent: return "OpTypeEvent"; + case Op::OpTypeDeviceEvent: return "OpTypeDeviceEvent"; + case Op::OpTypeReserveId: return "OpTypeReserveId"; + case Op::OpTypeQueue: return "OpTypeQueue"; + case Op::OpTypePipe: return "OpTypePipe"; + case Op::OpTypeForwardPointer: return "OpTypeForwardPointer"; + case Op::OpConstantTrue: return "OpConstantTrue"; + case Op::OpConstantFalse: return "OpConstantFalse"; + case Op::OpConstant: return "OpConstant"; + case Op::OpConstantComposite: return "OpConstantComposite"; + case Op::OpConstantSampler: return "OpConstantSampler"; + case Op::OpConstantNull: return "OpConstantNull"; + case Op::OpSpecConstantTrue: return "OpSpecConstantTrue"; + case Op::OpSpecConstantFalse: return "OpSpecConstantFalse"; + case Op::OpSpecConstant: return "OpSpecConstant"; + case Op::OpSpecConstantComposite: return "OpSpecConstantComposite"; + case Op::OpSpecConstantOp: return "OpSpecConstantOp"; + case Op::OpFunction: return "OpFunction"; + case Op::OpFunctionParameter: return "OpFunctionParameter"; + case Op::OpFunctionEnd: return "OpFunctionEnd"; + case Op::OpFunctionCall: return "OpFunctionCall"; + case Op::OpVariable: return "OpVariable"; + case Op::OpImageTexelPointer: return "OpImageTexelPointer"; + case Op::OpLoad: return "OpLoad"; + case Op::OpStore: return "OpStore"; + case Op::OpCopyMemory: return "OpCopyMemory"; + case Op::OpCopyMemorySized: return "OpCopyMemorySized"; + case Op::OpAccessChain: return "OpAccessChain"; + case Op::OpInBoundsAccessChain: return "OpInBoundsAccessChain"; + case Op::OpPtrAccessChain: return "OpPtrAccessChain"; + case Op::OpArrayLength: return "OpArrayLength"; + case Op::OpGenericPtrMemSemantics: return "OpGenericPtrMemSemantics"; + case Op::OpInBoundsPtrAccessChain: return "OpInBoundsPtrAccessChain"; + case Op::OpDecorate: return "OpDecorate"; + case Op::OpMemberDecorate: return "OpMemberDecorate"; + case Op::OpDecorationGroup: return "OpDecorationGroup"; + case Op::OpGroupDecorate: return "OpGroupDecorate"; + case Op::OpGroupMemberDecorate: return "OpGroupMemberDecorate"; + case Op::OpVectorExtractDynamic: return "OpVectorExtractDynamic"; + case Op::OpVectorInsertDynamic: return "OpVectorInsertDynamic"; + case Op::OpVectorShuffle: return "OpVectorShuffle"; + case Op::OpCompositeConstruct: return "OpCompositeConstruct"; + case Op::OpCompositeExtract: return "OpCompositeExtract"; + case Op::OpCompositeInsert: return "OpCompositeInsert"; + case Op::OpCopyObject: return "OpCopyObject"; + case Op::OpTranspose: return "OpTranspose"; + case Op::OpSampledImage: return "OpSampledImage"; + case Op::OpImageSampleImplicitLod: return "OpImageSampleImplicitLod"; + case Op::OpImageSampleExplicitLod: return "OpImageSampleExplicitLod"; + case Op::OpImageSampleDrefImplicitLod: return "OpImageSampleDrefImplicitLod"; + case Op::OpImageSampleDrefExplicitLod: return "OpImageSampleDrefExplicitLod"; + case Op::OpImageSampleProjImplicitLod: return "OpImageSampleProjImplicitLod"; + case Op::OpImageSampleProjExplicitLod: return "OpImageSampleProjExplicitLod"; + case Op::OpImageSampleProjDrefImplicitLod: return "OpImageSampleProjDrefImplicitLod"; + case Op::OpImageSampleProjDrefExplicitLod: return "OpImageSampleProjDrefExplicitLod"; + case Op::OpImageFetch: return "OpImageFetch"; + case Op::OpImageGather: return "OpImageGather"; + case Op::OpImageDrefGather: return "OpImageDrefGather"; + case Op::OpImageRead: return "OpImageRead"; + case Op::OpImageWrite: return "OpImageWrite"; + case Op::OpImage: return "OpImage"; + case Op::OpImageQueryFormat: return "OpImageQueryFormat"; + case Op::OpImageQueryOrder: return "OpImageQueryOrder"; + case Op::OpImageQuerySizeLod: return "OpImageQuerySizeLod"; + case Op::OpImageQuerySize: return "OpImageQuerySize"; + case Op::OpImageQueryLod: return "OpImageQueryLod"; + case Op::OpImageQueryLevels: return "OpImageQueryLevels"; + case Op::OpImageQuerySamples: return "OpImageQuerySamples"; + case Op::OpConvertFToU: return "OpConvertFToU"; + case Op::OpConvertFToS: return "OpConvertFToS"; + case Op::OpConvertSToF: return "OpConvertSToF"; + case Op::OpConvertUToF: return "OpConvertUToF"; + case Op::OpUConvert: return "OpUConvert"; + case Op::OpSConvert: return "OpSConvert"; + case Op::OpFConvert: return "OpFConvert"; + case Op::OpQuantizeToF16: return "OpQuantizeToF16"; + case Op::OpConvertPtrToU: return "OpConvertPtrToU"; + case Op::OpSatConvertSToU: return "OpSatConvertSToU"; + case Op::OpSatConvertUToS: return "OpSatConvertUToS"; + case Op::OpConvertUToPtr: return "OpConvertUToPtr"; + case Op::OpPtrCastToGeneric: return "OpPtrCastToGeneric"; + case Op::OpGenericCastToPtr: return "OpGenericCastToPtr"; + case Op::OpGenericCastToPtrExplicit: return "OpGenericCastToPtrExplicit"; + case Op::OpBitcast: return "OpBitcast"; + case Op::OpSNegate: return "OpSNegate"; + case Op::OpFNegate: return "OpFNegate"; + case Op::OpIAdd: return "OpIAdd"; + case Op::OpFAdd: return "OpFAdd"; + case Op::OpISub: return "OpISub"; + case Op::OpFSub: return "OpFSub"; + case Op::OpIMul: return "OpIMul"; + case Op::OpFMul: return "OpFMul"; + case Op::OpUDiv: return "OpUDiv"; + case Op::OpSDiv: return "OpSDiv"; + case Op::OpFDiv: return "OpFDiv"; + case Op::OpUMod: return "OpUMod"; + case Op::OpSRem: return "OpSRem"; + case Op::OpSMod: return "OpSMod"; + case Op::OpFRem: return "OpFRem"; + case Op::OpFMod: return "OpFMod"; + case Op::OpVectorTimesScalar: return "OpVectorTimesScalar"; + case Op::OpMatrixTimesScalar: return "OpMatrixTimesScalar"; + case Op::OpVectorTimesMatrix: return "OpVectorTimesMatrix"; + case Op::OpMatrixTimesVector: return "OpMatrixTimesVector"; + case Op::OpMatrixTimesMatrix: return "OpMatrixTimesMatrix"; + case Op::OpOuterProduct: return "OpOuterProduct"; + case Op::OpDot: return "OpDot"; + case Op::OpIAddCarry: return "OpIAddCarry"; + case Op::OpISubBorrow: return "OpISubBorrow"; + case Op::OpUMulExtended: return "OpUMulExtended"; + case Op::OpSMulExtended: return "OpSMulExtended"; + case Op::OpAny: return "OpAny"; + case Op::OpAll: return "OpAll"; + case Op::OpIsNan: return "OpIsNan"; + case Op::OpIsInf: return "OpIsInf"; + case Op::OpIsFinite: return "OpIsFinite"; + case Op::OpIsNormal: return "OpIsNormal"; + case Op::OpSignBitSet: return "OpSignBitSet"; + case Op::OpLessOrGreater: return "OpLessOrGreater"; + case Op::OpOrdered: return "OpOrdered"; + case Op::OpUnordered: return "OpUnordered"; + case Op::OpLogicalEqual: return "OpLogicalEqual"; + case Op::OpLogicalNotEqual: return "OpLogicalNotEqual"; + case Op::OpLogicalOr: return "OpLogicalOr"; + case Op::OpLogicalAnd: return "OpLogicalAnd"; + case Op::OpLogicalNot: return "OpLogicalNot"; + case Op::OpSelect: return "OpSelect"; + case Op::OpIEqual: return "OpIEqual"; + case Op::OpINotEqual: return "OpINotEqual"; + case Op::OpUGreaterThan: return "OpUGreaterThan"; + case Op::OpSGreaterThan: return "OpSGreaterThan"; + case Op::OpUGreaterThanEqual: return "OpUGreaterThanEqual"; + case Op::OpSGreaterThanEqual: return "OpSGreaterThanEqual"; + case Op::OpULessThan: return "OpULessThan"; + case Op::OpSLessThan: return "OpSLessThan"; + case Op::OpULessThanEqual: return "OpULessThanEqual"; + case Op::OpSLessThanEqual: return "OpSLessThanEqual"; + case Op::OpFOrdEqual: return "OpFOrdEqual"; + case Op::OpFUnordEqual: return "OpFUnordEqual"; + case Op::OpFOrdNotEqual: return "OpFOrdNotEqual"; + case Op::OpFUnordNotEqual: return "OpFUnordNotEqual"; + case Op::OpFOrdLessThan: return "OpFOrdLessThan"; + case Op::OpFUnordLessThan: return "OpFUnordLessThan"; + case Op::OpFOrdGreaterThan: return "OpFOrdGreaterThan"; + case Op::OpFUnordGreaterThan: return "OpFUnordGreaterThan"; + case Op::OpFOrdLessThanEqual: return "OpFOrdLessThanEqual"; + case Op::OpFUnordLessThanEqual: return "OpFUnordLessThanEqual"; + case Op::OpFOrdGreaterThanEqual: return "OpFOrdGreaterThanEqual"; + case Op::OpFUnordGreaterThanEqual: return "OpFUnordGreaterThanEqual"; + case Op::OpShiftRightLogical: return "OpShiftRightLogical"; + case Op::OpShiftRightArithmetic: return "OpShiftRightArithmetic"; + case Op::OpShiftLeftLogical: return "OpShiftLeftLogical"; + case Op::OpBitwiseOr: return "OpBitwiseOr"; + case Op::OpBitwiseXor: return "OpBitwiseXor"; + case Op::OpBitwiseAnd: return "OpBitwiseAnd"; + case Op::OpNot: return "OpNot"; + case Op::OpBitFieldInsert: return "OpBitFieldInsert"; + case Op::OpBitFieldSExtract: return "OpBitFieldSExtract"; + case Op::OpBitFieldUExtract: return "OpBitFieldUExtract"; + case Op::OpBitReverse: return "OpBitReverse"; + case Op::OpBitCount: return "OpBitCount"; + case Op::OpDPdx: return "OpDPdx"; + case Op::OpDPdy: return "OpDPdy"; + case Op::OpFwidth: return "OpFwidth"; + case Op::OpDPdxFine: return "OpDPdxFine"; + case Op::OpDPdyFine: return "OpDPdyFine"; + case Op::OpFwidthFine: return "OpFwidthFine"; + case Op::OpDPdxCoarse: return "OpDPdxCoarse"; + case Op::OpDPdyCoarse: return "OpDPdyCoarse"; + case Op::OpFwidthCoarse: return "OpFwidthCoarse"; + case Op::OpEmitVertex: return "OpEmitVertex"; + case Op::OpEndPrimitive: return "OpEndPrimitive"; + case Op::OpEmitStreamVertex: return "OpEmitStreamVertex"; + case Op::OpEndStreamPrimitive: return "OpEndStreamPrimitive"; + case Op::OpControlBarrier: return "OpControlBarrier"; + case Op::OpMemoryBarrier: return "OpMemoryBarrier"; + case Op::OpAtomicLoad: return "OpAtomicLoad"; + case Op::OpAtomicStore: return "OpAtomicStore"; + case Op::OpAtomicExchange: return "OpAtomicExchange"; + case Op::OpAtomicCompareExchange: return "OpAtomicCompareExchange"; + case Op::OpAtomicCompareExchangeWeak: return "OpAtomicCompareExchangeWeak"; + case Op::OpAtomicIIncrement: return "OpAtomicIIncrement"; + case Op::OpAtomicIDecrement: return "OpAtomicIDecrement"; + case Op::OpAtomicIAdd: return "OpAtomicIAdd"; + case Op::OpAtomicISub: return "OpAtomicISub"; + case Op::OpAtomicSMin: return "OpAtomicSMin"; + case Op::OpAtomicUMin: return "OpAtomicUMin"; + case Op::OpAtomicSMax: return "OpAtomicSMax"; + case Op::OpAtomicUMax: return "OpAtomicUMax"; + case Op::OpAtomicAnd: return "OpAtomicAnd"; + case Op::OpAtomicOr: return "OpAtomicOr"; + case Op::OpAtomicXor: return "OpAtomicXor"; + case Op::OpPhi: return "OpPhi"; + case Op::OpLoopMerge: return "OpLoopMerge"; + case Op::OpSelectionMerge: return "OpSelectionMerge"; + case Op::OpLabel: return "OpLabel"; + case Op::OpBranch: return "OpBranch"; + case Op::OpBranchConditional: return "OpBranchConditional"; + case Op::OpSwitch: return "OpSwitch"; + case Op::OpKill: return "OpKill"; + case Op::OpReturn: return "OpReturn"; + case Op::OpReturnValue: return "OpReturnValue"; + case Op::OpUnreachable: return "OpUnreachable"; + case Op::OpLifetimeStart: return "OpLifetimeStart"; + case Op::OpLifetimeStop: return "OpLifetimeStop"; + case Op::OpGroupAsyncCopy: return "OpGroupAsyncCopy"; + case Op::OpGroupWaitEvents: return "OpGroupWaitEvents"; + case Op::OpGroupAll: return "OpGroupAll"; + case Op::OpGroupAny: return "OpGroupAny"; + case Op::OpGroupBroadcast: return "OpGroupBroadcast"; + case Op::OpGroupIAdd: return "OpGroupIAdd"; + case Op::OpGroupFAdd: return "OpGroupFAdd"; + case Op::OpGroupFMin: return "OpGroupFMin"; + case Op::OpGroupUMin: return "OpGroupUMin"; + case Op::OpGroupSMin: return "OpGroupSMin"; + case Op::OpGroupFMax: return "OpGroupFMax"; + case Op::OpGroupUMax: return "OpGroupUMax"; + case Op::OpGroupSMax: return "OpGroupSMax"; + case Op::OpReadPipe: return "OpReadPipe"; + case Op::OpWritePipe: return "OpWritePipe"; + case Op::OpReservedReadPipe: return "OpReservedReadPipe"; + case Op::OpReservedWritePipe: return "OpReservedWritePipe"; + case Op::OpReserveReadPipePackets: return "OpReserveReadPipePackets"; + case Op::OpReserveWritePipePackets: return "OpReserveWritePipePackets"; + case Op::OpCommitReadPipe: return "OpCommitReadPipe"; + case Op::OpCommitWritePipe: return "OpCommitWritePipe"; + case Op::OpIsValidReserveId: return "OpIsValidReserveId"; + case Op::OpGetNumPipePackets: return "OpGetNumPipePackets"; + case Op::OpGetMaxPipePackets: return "OpGetMaxPipePackets"; + case Op::OpGroupReserveReadPipePackets: return "OpGroupReserveReadPipePackets"; + case Op::OpGroupReserveWritePipePackets: return "OpGroupReserveWritePipePackets"; + case Op::OpGroupCommitReadPipe: return "OpGroupCommitReadPipe"; + case Op::OpGroupCommitWritePipe: return "OpGroupCommitWritePipe"; + case Op::OpEnqueueMarker: return "OpEnqueueMarker"; + case Op::OpEnqueueKernel: return "OpEnqueueKernel"; + case Op::OpGetKernelNDrangeSubGroupCount: return "OpGetKernelNDrangeSubGroupCount"; + case Op::OpGetKernelNDrangeMaxSubGroupSize: return "OpGetKernelNDrangeMaxSubGroupSize"; + case Op::OpGetKernelWorkGroupSize: return "OpGetKernelWorkGroupSize"; + case Op::OpGetKernelPreferredWorkGroupSizeMultiple: return "OpGetKernelPreferredWorkGroupSizeMultiple"; + case Op::OpRetainEvent: return "OpRetainEvent"; + case Op::OpReleaseEvent: return "OpReleaseEvent"; + case Op::OpCreateUserEvent: return "OpCreateUserEvent"; + case Op::OpIsValidEvent: return "OpIsValidEvent"; + case Op::OpSetUserEventStatus: return "OpSetUserEventStatus"; + case Op::OpCaptureEventProfilingInfo: return "OpCaptureEventProfilingInfo"; + case Op::OpGetDefaultQueue: return "OpGetDefaultQueue"; + case Op::OpBuildNDRange: return "OpBuildNDRange"; + case Op::OpImageSparseSampleImplicitLod: return "OpImageSparseSampleImplicitLod"; + case Op::OpImageSparseSampleExplicitLod: return "OpImageSparseSampleExplicitLod"; + case Op::OpImageSparseSampleDrefImplicitLod: return "OpImageSparseSampleDrefImplicitLod"; + case Op::OpImageSparseSampleDrefExplicitLod: return "OpImageSparseSampleDrefExplicitLod"; + case Op::OpImageSparseSampleProjImplicitLod: return "OpImageSparseSampleProjImplicitLod"; + case Op::OpImageSparseSampleProjExplicitLod: return "OpImageSparseSampleProjExplicitLod"; + case Op::OpImageSparseSampleProjDrefImplicitLod: return "OpImageSparseSampleProjDrefImplicitLod"; + case Op::OpImageSparseSampleProjDrefExplicitLod: return "OpImageSparseSampleProjDrefExplicitLod"; + case Op::OpImageSparseFetch: return "OpImageSparseFetch"; + case Op::OpImageSparseGather: return "OpImageSparseGather"; + case Op::OpImageSparseDrefGather: return "OpImageSparseDrefGather"; + case Op::OpImageSparseTexelsResident: return "OpImageSparseTexelsResident"; + case Op::OpNoLine: return "OpNoLine"; + case Op::OpAtomicFlagTestAndSet: return "OpAtomicFlagTestAndSet"; + case Op::OpAtomicFlagClear: return "OpAtomicFlagClear"; + case Op::OpImageSparseRead: return "OpImageSparseRead"; + case Op::OpSizeOf: return "OpSizeOf"; + case Op::OpTypePipeStorage: return "OpTypePipeStorage"; + case Op::OpConstantPipeStorage: return "OpConstantPipeStorage"; + case Op::OpCreatePipeFromPipeStorage: return "OpCreatePipeFromPipeStorage"; + case Op::OpGetKernelLocalSizeForSubgroupCount: return "OpGetKernelLocalSizeForSubgroupCount"; + case Op::OpGetKernelMaxNumSubgroups: return "OpGetKernelMaxNumSubgroups"; + case Op::OpTypeNamedBarrier: return "OpTypeNamedBarrier"; + case Op::OpNamedBarrierInitialize: return "OpNamedBarrierInitialize"; + case Op::OpMemoryNamedBarrier: return "OpMemoryNamedBarrier"; + case Op::OpModuleProcessed: return "OpModuleProcessed"; + case Op::OpExecutionModeId: return "OpExecutionModeId"; + case Op::OpDecorateId: return "OpDecorateId"; + case Op::OpGroupNonUniformElect: return "OpGroupNonUniformElect"; + case Op::OpGroupNonUniformAll: return "OpGroupNonUniformAll"; + case Op::OpGroupNonUniformAny: return "OpGroupNonUniformAny"; + case Op::OpGroupNonUniformAllEqual: return "OpGroupNonUniformAllEqual"; + case Op::OpGroupNonUniformBroadcast: return "OpGroupNonUniformBroadcast"; + case Op::OpGroupNonUniformBroadcastFirst: return "OpGroupNonUniformBroadcastFirst"; + case Op::OpGroupNonUniformBallot: return "OpGroupNonUniformBallot"; + case Op::OpGroupNonUniformInverseBallot: return "OpGroupNonUniformInverseBallot"; + case Op::OpGroupNonUniformBallotBitExtract: return "OpGroupNonUniformBallotBitExtract"; + case Op::OpGroupNonUniformBallotBitCount: return "OpGroupNonUniformBallotBitCount"; + case Op::OpGroupNonUniformBallotFindLSB: return "OpGroupNonUniformBallotFindLSB"; + case Op::OpGroupNonUniformBallotFindMSB: return "OpGroupNonUniformBallotFindMSB"; + case Op::OpGroupNonUniformShuffle: return "OpGroupNonUniformShuffle"; + case Op::OpGroupNonUniformShuffleXor: return "OpGroupNonUniformShuffleXor"; + case Op::OpGroupNonUniformShuffleUp: return "OpGroupNonUniformShuffleUp"; + case Op::OpGroupNonUniformShuffleDown: return "OpGroupNonUniformShuffleDown"; + case Op::OpGroupNonUniformIAdd: return "OpGroupNonUniformIAdd"; + case Op::OpGroupNonUniformFAdd: return "OpGroupNonUniformFAdd"; + case Op::OpGroupNonUniformIMul: return "OpGroupNonUniformIMul"; + case Op::OpGroupNonUniformFMul: return "OpGroupNonUniformFMul"; + case Op::OpGroupNonUniformSMin: return "OpGroupNonUniformSMin"; + case Op::OpGroupNonUniformUMin: return "OpGroupNonUniformUMin"; + case Op::OpGroupNonUniformFMin: return "OpGroupNonUniformFMin"; + case Op::OpGroupNonUniformSMax: return "OpGroupNonUniformSMax"; + case Op::OpGroupNonUniformUMax: return "OpGroupNonUniformUMax"; + case Op::OpGroupNonUniformFMax: return "OpGroupNonUniformFMax"; + case Op::OpGroupNonUniformBitwiseAnd: return "OpGroupNonUniformBitwiseAnd"; + case Op::OpGroupNonUniformBitwiseOr: return "OpGroupNonUniformBitwiseOr"; + case Op::OpGroupNonUniformBitwiseXor: return "OpGroupNonUniformBitwiseXor"; + case Op::OpGroupNonUniformLogicalAnd: return "OpGroupNonUniformLogicalAnd"; + case Op::OpGroupNonUniformLogicalOr: return "OpGroupNonUniformLogicalOr"; + case Op::OpGroupNonUniformLogicalXor: return "OpGroupNonUniformLogicalXor"; + case Op::OpGroupNonUniformQuadBroadcast: return "OpGroupNonUniformQuadBroadcast"; + case Op::OpGroupNonUniformQuadSwap: return "OpGroupNonUniformQuadSwap"; + case Op::OpCopyLogical: return "OpCopyLogical"; + case Op::OpPtrEqual: return "OpPtrEqual"; + case Op::OpPtrNotEqual: return "OpPtrNotEqual"; + case Op::OpPtrDiff: return "OpPtrDiff"; + case Op::OpColorAttachmentReadEXT: return "OpColorAttachmentReadEXT"; + case Op::OpDepthAttachmentReadEXT: return "OpDepthAttachmentReadEXT"; + case Op::OpStencilAttachmentReadEXT: return "OpStencilAttachmentReadEXT"; + case Op::OpTerminateInvocation: return "OpTerminateInvocation"; + case Op::OpTypeUntypedPointerKHR: return "OpTypeUntypedPointerKHR"; + case Op::OpUntypedVariableKHR: return "OpUntypedVariableKHR"; + case Op::OpUntypedAccessChainKHR: return "OpUntypedAccessChainKHR"; + case Op::OpUntypedInBoundsAccessChainKHR: return "OpUntypedInBoundsAccessChainKHR"; + case Op::OpSubgroupBallotKHR: return "OpSubgroupBallotKHR"; + case Op::OpSubgroupFirstInvocationKHR: return "OpSubgroupFirstInvocationKHR"; + case Op::OpUntypedPtrAccessChainKHR: return "OpUntypedPtrAccessChainKHR"; + case Op::OpUntypedInBoundsPtrAccessChainKHR: return "OpUntypedInBoundsPtrAccessChainKHR"; + case Op::OpUntypedArrayLengthKHR: return "OpUntypedArrayLengthKHR"; + case Op::OpUntypedPrefetchKHR: return "OpUntypedPrefetchKHR"; + case Op::OpSubgroupAllKHR: return "OpSubgroupAllKHR"; + case Op::OpSubgroupAnyKHR: return "OpSubgroupAnyKHR"; + case Op::OpSubgroupAllEqualKHR: return "OpSubgroupAllEqualKHR"; + case Op::OpGroupNonUniformRotateKHR: return "OpGroupNonUniformRotateKHR"; + case Op::OpSubgroupReadInvocationKHR: return "OpSubgroupReadInvocationKHR"; + case Op::OpExtInstWithForwardRefsKHR: return "OpExtInstWithForwardRefsKHR"; + case Op::OpTraceRayKHR: return "OpTraceRayKHR"; + case Op::OpExecuteCallableKHR: return "OpExecuteCallableKHR"; + case Op::OpConvertUToAccelerationStructureKHR: return "OpConvertUToAccelerationStructureKHR"; + case Op::OpIgnoreIntersectionKHR: return "OpIgnoreIntersectionKHR"; + case Op::OpTerminateRayKHR: return "OpTerminateRayKHR"; + case Op::OpSDot: return "OpSDot"; + case Op::OpUDot: return "OpUDot"; + case Op::OpSUDot: return "OpSUDot"; + case Op::OpSDotAccSat: return "OpSDotAccSat"; + case Op::OpUDotAccSat: return "OpUDotAccSat"; + case Op::OpSUDotAccSat: return "OpSUDotAccSat"; + case Op::OpTypeCooperativeMatrixKHR: return "OpTypeCooperativeMatrixKHR"; + case Op::OpCooperativeMatrixLoadKHR: return "OpCooperativeMatrixLoadKHR"; + case Op::OpCooperativeMatrixStoreKHR: return "OpCooperativeMatrixStoreKHR"; + case Op::OpCooperativeMatrixMulAddKHR: return "OpCooperativeMatrixMulAddKHR"; + case Op::OpCooperativeMatrixLengthKHR: return "OpCooperativeMatrixLengthKHR"; + case Op::OpConstantCompositeReplicateEXT: return "OpConstantCompositeReplicateEXT"; + case Op::OpSpecConstantCompositeReplicateEXT: return "OpSpecConstantCompositeReplicateEXT"; + case Op::OpCompositeConstructReplicateEXT: return "OpCompositeConstructReplicateEXT"; + case Op::OpTypeRayQueryKHR: return "OpTypeRayQueryKHR"; + case Op::OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR"; + case Op::OpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR"; + case Op::OpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR"; + case Op::OpRayQueryConfirmIntersectionKHR: return "OpRayQueryConfirmIntersectionKHR"; + case Op::OpRayQueryProceedKHR: return "OpRayQueryProceedKHR"; + case Op::OpRayQueryGetIntersectionTypeKHR: return "OpRayQueryGetIntersectionTypeKHR"; + case Op::OpImageSampleWeightedQCOM: return "OpImageSampleWeightedQCOM"; + case Op::OpImageBoxFilterQCOM: return "OpImageBoxFilterQCOM"; + case Op::OpImageBlockMatchSSDQCOM: return "OpImageBlockMatchSSDQCOM"; + case Op::OpImageBlockMatchSADQCOM: return "OpImageBlockMatchSADQCOM"; + case Op::OpImageBlockMatchWindowSSDQCOM: return "OpImageBlockMatchWindowSSDQCOM"; + case Op::OpImageBlockMatchWindowSADQCOM: return "OpImageBlockMatchWindowSADQCOM"; + case Op::OpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM"; + case Op::OpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM"; + case Op::OpGroupIAddNonUniformAMD: return "OpGroupIAddNonUniformAMD"; + case Op::OpGroupFAddNonUniformAMD: return "OpGroupFAddNonUniformAMD"; + case Op::OpGroupFMinNonUniformAMD: return "OpGroupFMinNonUniformAMD"; + case Op::OpGroupUMinNonUniformAMD: return "OpGroupUMinNonUniformAMD"; + case Op::OpGroupSMinNonUniformAMD: return "OpGroupSMinNonUniformAMD"; + case Op::OpGroupFMaxNonUniformAMD: return "OpGroupFMaxNonUniformAMD"; + case Op::OpGroupUMaxNonUniformAMD: return "OpGroupUMaxNonUniformAMD"; + case Op::OpGroupSMaxNonUniformAMD: return "OpGroupSMaxNonUniformAMD"; + case Op::OpFragmentMaskFetchAMD: return "OpFragmentMaskFetchAMD"; + case Op::OpFragmentFetchAMD: return "OpFragmentFetchAMD"; + case Op::OpReadClockKHR: return "OpReadClockKHR"; + case Op::OpAllocateNodePayloadsAMDX: return "OpAllocateNodePayloadsAMDX"; + case Op::OpEnqueueNodePayloadsAMDX: return "OpEnqueueNodePayloadsAMDX"; + case Op::OpTypeNodePayloadArrayAMDX: return "OpTypeNodePayloadArrayAMDX"; + case Op::OpFinishWritingNodePayloadAMDX: return "OpFinishWritingNodePayloadAMDX"; + case Op::OpNodePayloadArrayLengthAMDX: return "OpNodePayloadArrayLengthAMDX"; + case Op::OpIsNodePayloadValidAMDX: return "OpIsNodePayloadValidAMDX"; + case Op::OpConstantStringAMDX: return "OpConstantStringAMDX"; + case Op::OpSpecConstantStringAMDX: return "OpSpecConstantStringAMDX"; + case Op::OpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; + case Op::OpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; + case Op::OpHitObjectRecordHitMotionNV: return "OpHitObjectRecordHitMotionNV"; + case Op::OpHitObjectRecordHitWithIndexMotionNV: return "OpHitObjectRecordHitWithIndexMotionNV"; + case Op::OpHitObjectRecordMissMotionNV: return "OpHitObjectRecordMissMotionNV"; + case Op::OpHitObjectGetWorldToObjectNV: return "OpHitObjectGetWorldToObjectNV"; + case Op::OpHitObjectGetObjectToWorldNV: return "OpHitObjectGetObjectToWorldNV"; + case Op::OpHitObjectGetObjectRayDirectionNV: return "OpHitObjectGetObjectRayDirectionNV"; + case Op::OpHitObjectGetObjectRayOriginNV: return "OpHitObjectGetObjectRayOriginNV"; + case Op::OpHitObjectTraceRayMotionNV: return "OpHitObjectTraceRayMotionNV"; + case Op::OpHitObjectGetShaderRecordBufferHandleNV: return "OpHitObjectGetShaderRecordBufferHandleNV"; + case Op::OpHitObjectGetShaderBindingTableRecordIndexNV: return "OpHitObjectGetShaderBindingTableRecordIndexNV"; + case Op::OpHitObjectRecordEmptyNV: return "OpHitObjectRecordEmptyNV"; + case Op::OpHitObjectTraceRayNV: return "OpHitObjectTraceRayNV"; + case Op::OpHitObjectRecordHitNV: return "OpHitObjectRecordHitNV"; + case Op::OpHitObjectRecordHitWithIndexNV: return "OpHitObjectRecordHitWithIndexNV"; + case Op::OpHitObjectRecordMissNV: return "OpHitObjectRecordMissNV"; + case Op::OpHitObjectExecuteShaderNV: return "OpHitObjectExecuteShaderNV"; + case Op::OpHitObjectGetCurrentTimeNV: return "OpHitObjectGetCurrentTimeNV"; + case Op::OpHitObjectGetAttributesNV: return "OpHitObjectGetAttributesNV"; + case Op::OpHitObjectGetHitKindNV: return "OpHitObjectGetHitKindNV"; + case Op::OpHitObjectGetPrimitiveIndexNV: return "OpHitObjectGetPrimitiveIndexNV"; + case Op::OpHitObjectGetGeometryIndexNV: return "OpHitObjectGetGeometryIndexNV"; + case Op::OpHitObjectGetInstanceIdNV: return "OpHitObjectGetInstanceIdNV"; + case Op::OpHitObjectGetInstanceCustomIndexNV: return "OpHitObjectGetInstanceCustomIndexNV"; + case Op::OpHitObjectGetWorldRayDirectionNV: return "OpHitObjectGetWorldRayDirectionNV"; + case Op::OpHitObjectGetWorldRayOriginNV: return "OpHitObjectGetWorldRayOriginNV"; + case Op::OpHitObjectGetRayTMaxNV: return "OpHitObjectGetRayTMaxNV"; + case Op::OpHitObjectGetRayTMinNV: return "OpHitObjectGetRayTMinNV"; + case Op::OpHitObjectIsEmptyNV: return "OpHitObjectIsEmptyNV"; + case Op::OpHitObjectIsHitNV: return "OpHitObjectIsHitNV"; + case Op::OpHitObjectIsMissNV: return "OpHitObjectIsMissNV"; + case Op::OpReorderThreadWithHitObjectNV: return "OpReorderThreadWithHitObjectNV"; + case Op::OpReorderThreadWithHintNV: return "OpReorderThreadWithHintNV"; + case Op::OpTypeHitObjectNV: return "OpTypeHitObjectNV"; + case Op::OpImageSampleFootprintNV: return "OpImageSampleFootprintNV"; + case Op::OpTypeCooperativeVectorNV: return "OpTypeCooperativeVectorNV"; + case Op::OpCooperativeVectorMatrixMulNV: return "OpCooperativeVectorMatrixMulNV"; + case Op::OpCooperativeVectorOuterProductAccumulateNV: return "OpCooperativeVectorOuterProductAccumulateNV"; + case Op::OpCooperativeVectorReduceSumAccumulateNV: return "OpCooperativeVectorReduceSumAccumulateNV"; + case Op::OpCooperativeVectorMatrixMulAddNV: return "OpCooperativeVectorMatrixMulAddNV"; + case Op::OpCooperativeMatrixConvertNV: return "OpCooperativeMatrixConvertNV"; + case Op::OpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT"; + case Op::OpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT"; + case Op::OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; + case Op::OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; + case Op::OpFetchMicroTriangleVertexPositionNV: return "OpFetchMicroTriangleVertexPositionNV"; + case Op::OpFetchMicroTriangleVertexBarycentricNV: return "OpFetchMicroTriangleVertexBarycentricNV"; + case Op::OpCooperativeVectorLoadNV: return "OpCooperativeVectorLoadNV"; + case Op::OpCooperativeVectorStoreNV: return "OpCooperativeVectorStoreNV"; + case Op::OpReportIntersectionKHR: return "OpReportIntersectionKHR"; + case Op::OpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV"; + case Op::OpTerminateRayNV: return "OpTerminateRayNV"; + case Op::OpTraceNV: return "OpTraceNV"; + case Op::OpTraceMotionNV: return "OpTraceMotionNV"; + case Op::OpTraceRayMotionNV: return "OpTraceRayMotionNV"; + case Op::OpRayQueryGetIntersectionTriangleVertexPositionsKHR: return "OpRayQueryGetIntersectionTriangleVertexPositionsKHR"; + case Op::OpTypeAccelerationStructureKHR: return "OpTypeAccelerationStructureKHR"; + case Op::OpExecuteCallableNV: return "OpExecuteCallableNV"; + case Op::OpRayQueryGetClusterIdNV: return "OpRayQueryGetClusterIdNV"; + case Op::OpHitObjectGetClusterIdNV: return "OpHitObjectGetClusterIdNV"; + case Op::OpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV"; + case Op::OpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV"; + case Op::OpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV"; + case Op::OpCooperativeMatrixMulAddNV: return "OpCooperativeMatrixMulAddNV"; + case Op::OpCooperativeMatrixLengthNV: return "OpCooperativeMatrixLengthNV"; + case Op::OpBeginInvocationInterlockEXT: return "OpBeginInvocationInterlockEXT"; + case Op::OpEndInvocationInterlockEXT: return "OpEndInvocationInterlockEXT"; + case Op::OpCooperativeMatrixReduceNV: return "OpCooperativeMatrixReduceNV"; + case Op::OpCooperativeMatrixLoadTensorNV: return "OpCooperativeMatrixLoadTensorNV"; + case Op::OpCooperativeMatrixStoreTensorNV: return "OpCooperativeMatrixStoreTensorNV"; + case Op::OpCooperativeMatrixPerElementOpNV: return "OpCooperativeMatrixPerElementOpNV"; + case Op::OpTypeTensorLayoutNV: return "OpTypeTensorLayoutNV"; + case Op::OpTypeTensorViewNV: return "OpTypeTensorViewNV"; + case Op::OpCreateTensorLayoutNV: return "OpCreateTensorLayoutNV"; + case Op::OpTensorLayoutSetDimensionNV: return "OpTensorLayoutSetDimensionNV"; + case Op::OpTensorLayoutSetStrideNV: return "OpTensorLayoutSetStrideNV"; + case Op::OpTensorLayoutSliceNV: return "OpTensorLayoutSliceNV"; + case Op::OpTensorLayoutSetClampValueNV: return "OpTensorLayoutSetClampValueNV"; + case Op::OpCreateTensorViewNV: return "OpCreateTensorViewNV"; + case Op::OpTensorViewSetDimensionNV: return "OpTensorViewSetDimensionNV"; + case Op::OpTensorViewSetStrideNV: return "OpTensorViewSetStrideNV"; + case Op::OpDemoteToHelperInvocation: return "OpDemoteToHelperInvocation"; + case Op::OpIsHelperInvocationEXT: return "OpIsHelperInvocationEXT"; + case Op::OpTensorViewSetClipNV: return "OpTensorViewSetClipNV"; + case Op::OpTensorLayoutSetBlockSizeNV: return "OpTensorLayoutSetBlockSizeNV"; + case Op::OpCooperativeMatrixTransposeNV: return "OpCooperativeMatrixTransposeNV"; + case Op::OpConvertUToImageNV: return "OpConvertUToImageNV"; + case Op::OpConvertUToSamplerNV: return "OpConvertUToSamplerNV"; + case Op::OpConvertImageToUNV: return "OpConvertImageToUNV"; + case Op::OpConvertSamplerToUNV: return "OpConvertSamplerToUNV"; + case Op::OpConvertUToSampledImageNV: return "OpConvertUToSampledImageNV"; + case Op::OpConvertSampledImageToUNV: return "OpConvertSampledImageToUNV"; + case Op::OpSamplerImageAddressingModeNV: return "OpSamplerImageAddressingModeNV"; + case Op::OpRawAccessChainNV: return "OpRawAccessChainNV"; + case Op::OpRayQueryGetIntersectionSpherePositionNV: return "OpRayQueryGetIntersectionSpherePositionNV"; + case Op::OpRayQueryGetIntersectionSphereRadiusNV: return "OpRayQueryGetIntersectionSphereRadiusNV"; + case Op::OpRayQueryGetIntersectionLSSPositionsNV: return "OpRayQueryGetIntersectionLSSPositionsNV"; + case Op::OpRayQueryGetIntersectionLSSRadiiNV: return "OpRayQueryGetIntersectionLSSRadiiNV"; + case Op::OpRayQueryGetIntersectionLSSHitValueNV: return "OpRayQueryGetIntersectionLSSHitValueNV"; + case Op::OpHitObjectGetSpherePositionNV: return "OpHitObjectGetSpherePositionNV"; + case Op::OpHitObjectGetSphereRadiusNV: return "OpHitObjectGetSphereRadiusNV"; + case Op::OpHitObjectGetLSSPositionsNV: return "OpHitObjectGetLSSPositionsNV"; + case Op::OpHitObjectGetLSSRadiiNV: return "OpHitObjectGetLSSRadiiNV"; + case Op::OpHitObjectIsSphereHitNV: return "OpHitObjectIsSphereHitNV"; + case Op::OpHitObjectIsLSSHitNV: return "OpHitObjectIsLSSHitNV"; + case Op::OpRayQueryIsSphereHitNV: return "OpRayQueryIsSphereHitNV"; + case Op::OpRayQueryIsLSSHitNV: return "OpRayQueryIsLSSHitNV"; + case Op::OpSubgroupShuffleINTEL: return "OpSubgroupShuffleINTEL"; + case Op::OpSubgroupShuffleDownINTEL: return "OpSubgroupShuffleDownINTEL"; + case Op::OpSubgroupShuffleUpINTEL: return "OpSubgroupShuffleUpINTEL"; + case Op::OpSubgroupShuffleXorINTEL: return "OpSubgroupShuffleXorINTEL"; + case Op::OpSubgroupBlockReadINTEL: return "OpSubgroupBlockReadINTEL"; + case Op::OpSubgroupBlockWriteINTEL: return "OpSubgroupBlockWriteINTEL"; + case Op::OpSubgroupImageBlockReadINTEL: return "OpSubgroupImageBlockReadINTEL"; + case Op::OpSubgroupImageBlockWriteINTEL: return "OpSubgroupImageBlockWriteINTEL"; + case Op::OpSubgroupImageMediaBlockReadINTEL: return "OpSubgroupImageMediaBlockReadINTEL"; + case Op::OpSubgroupImageMediaBlockWriteINTEL: return "OpSubgroupImageMediaBlockWriteINTEL"; + case Op::OpUCountLeadingZerosINTEL: return "OpUCountLeadingZerosINTEL"; + case Op::OpUCountTrailingZerosINTEL: return "OpUCountTrailingZerosINTEL"; + case Op::OpAbsISubINTEL: return "OpAbsISubINTEL"; + case Op::OpAbsUSubINTEL: return "OpAbsUSubINTEL"; + case Op::OpIAddSatINTEL: return "OpIAddSatINTEL"; + case Op::OpUAddSatINTEL: return "OpUAddSatINTEL"; + case Op::OpIAverageINTEL: return "OpIAverageINTEL"; + case Op::OpUAverageINTEL: return "OpUAverageINTEL"; + case Op::OpIAverageRoundedINTEL: return "OpIAverageRoundedINTEL"; + case Op::OpUAverageRoundedINTEL: return "OpUAverageRoundedINTEL"; + case Op::OpISubSatINTEL: return "OpISubSatINTEL"; + case Op::OpUSubSatINTEL: return "OpUSubSatINTEL"; + case Op::OpIMul32x16INTEL: return "OpIMul32x16INTEL"; + case Op::OpUMul32x16INTEL: return "OpUMul32x16INTEL"; + case Op::OpConstantFunctionPointerINTEL: return "OpConstantFunctionPointerINTEL"; + case Op::OpFunctionPointerCallINTEL: return "OpFunctionPointerCallINTEL"; + case Op::OpAsmTargetINTEL: return "OpAsmTargetINTEL"; + case Op::OpAsmINTEL: return "OpAsmINTEL"; + case Op::OpAsmCallINTEL: return "OpAsmCallINTEL"; + case Op::OpAtomicFMinEXT: return "OpAtomicFMinEXT"; + case Op::OpAtomicFMaxEXT: return "OpAtomicFMaxEXT"; + case Op::OpAssumeTrueKHR: return "OpAssumeTrueKHR"; + case Op::OpExpectKHR: return "OpExpectKHR"; + case Op::OpDecorateString: return "OpDecorateString"; + case Op::OpMemberDecorateString: return "OpMemberDecorateString"; + case Op::OpVmeImageINTEL: return "OpVmeImageINTEL"; + case Op::OpTypeVmeImageINTEL: return "OpTypeVmeImageINTEL"; + case Op::OpTypeAvcImePayloadINTEL: return "OpTypeAvcImePayloadINTEL"; + case Op::OpTypeAvcRefPayloadINTEL: return "OpTypeAvcRefPayloadINTEL"; + case Op::OpTypeAvcSicPayloadINTEL: return "OpTypeAvcSicPayloadINTEL"; + case Op::OpTypeAvcMcePayloadINTEL: return "OpTypeAvcMcePayloadINTEL"; + case Op::OpTypeAvcMceResultINTEL: return "OpTypeAvcMceResultINTEL"; + case Op::OpTypeAvcImeResultINTEL: return "OpTypeAvcImeResultINTEL"; + case Op::OpTypeAvcImeResultSingleReferenceStreamoutINTEL: return "OpTypeAvcImeResultSingleReferenceStreamoutINTEL"; + case Op::OpTypeAvcImeResultDualReferenceStreamoutINTEL: return "OpTypeAvcImeResultDualReferenceStreamoutINTEL"; + case Op::OpTypeAvcImeSingleReferenceStreaminINTEL: return "OpTypeAvcImeSingleReferenceStreaminINTEL"; + case Op::OpTypeAvcImeDualReferenceStreaminINTEL: return "OpTypeAvcImeDualReferenceStreaminINTEL"; + case Op::OpTypeAvcRefResultINTEL: return "OpTypeAvcRefResultINTEL"; + case Op::OpTypeAvcSicResultINTEL: return "OpTypeAvcSicResultINTEL"; + case Op::OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL"; + case Op::OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL: return "OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL"; + case Op::OpSubgroupAvcMceSetInterShapePenaltyINTEL: return "OpSubgroupAvcMceSetInterShapePenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL"; + case Op::OpSubgroupAvcMceSetInterDirectionPenaltyINTEL: return "OpSubgroupAvcMceSetInterDirectionPenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL: return "OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL"; + case Op::OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL"; + case Op::OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL"; + case Op::OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL: return "OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL"; + case Op::OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL: return "OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL"; + case Op::OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL: return "OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL"; + case Op::OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL: return "OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL"; + case Op::OpSubgroupAvcMceSetAcOnlyHaarINTEL: return "OpSubgroupAvcMceSetAcOnlyHaarINTEL"; + case Op::OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL"; + case Op::OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL: return "OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL"; + case Op::OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL"; + case Op::OpSubgroupAvcMceConvertToImePayloadINTEL: return "OpSubgroupAvcMceConvertToImePayloadINTEL"; + case Op::OpSubgroupAvcMceConvertToImeResultINTEL: return "OpSubgroupAvcMceConvertToImeResultINTEL"; + case Op::OpSubgroupAvcMceConvertToRefPayloadINTEL: return "OpSubgroupAvcMceConvertToRefPayloadINTEL"; + case Op::OpSubgroupAvcMceConvertToRefResultINTEL: return "OpSubgroupAvcMceConvertToRefResultINTEL"; + case Op::OpSubgroupAvcMceConvertToSicPayloadINTEL: return "OpSubgroupAvcMceConvertToSicPayloadINTEL"; + case Op::OpSubgroupAvcMceConvertToSicResultINTEL: return "OpSubgroupAvcMceConvertToSicResultINTEL"; + case Op::OpSubgroupAvcMceGetMotionVectorsINTEL: return "OpSubgroupAvcMceGetMotionVectorsINTEL"; + case Op::OpSubgroupAvcMceGetInterDistortionsINTEL: return "OpSubgroupAvcMceGetInterDistortionsINTEL"; + case Op::OpSubgroupAvcMceGetBestInterDistortionsINTEL: return "OpSubgroupAvcMceGetBestInterDistortionsINTEL"; + case Op::OpSubgroupAvcMceGetInterMajorShapeINTEL: return "OpSubgroupAvcMceGetInterMajorShapeINTEL"; + case Op::OpSubgroupAvcMceGetInterMinorShapeINTEL: return "OpSubgroupAvcMceGetInterMinorShapeINTEL"; + case Op::OpSubgroupAvcMceGetInterDirectionsINTEL: return "OpSubgroupAvcMceGetInterDirectionsINTEL"; + case Op::OpSubgroupAvcMceGetInterMotionVectorCountINTEL: return "OpSubgroupAvcMceGetInterMotionVectorCountINTEL"; + case Op::OpSubgroupAvcMceGetInterReferenceIdsINTEL: return "OpSubgroupAvcMceGetInterReferenceIdsINTEL"; + case Op::OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL: return "OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL"; + case Op::OpSubgroupAvcImeInitializeINTEL: return "OpSubgroupAvcImeInitializeINTEL"; + case Op::OpSubgroupAvcImeSetSingleReferenceINTEL: return "OpSubgroupAvcImeSetSingleReferenceINTEL"; + case Op::OpSubgroupAvcImeSetDualReferenceINTEL: return "OpSubgroupAvcImeSetDualReferenceINTEL"; + case Op::OpSubgroupAvcImeRefWindowSizeINTEL: return "OpSubgroupAvcImeRefWindowSizeINTEL"; + case Op::OpSubgroupAvcImeAdjustRefOffsetINTEL: return "OpSubgroupAvcImeAdjustRefOffsetINTEL"; + case Op::OpSubgroupAvcImeConvertToMcePayloadINTEL: return "OpSubgroupAvcImeConvertToMcePayloadINTEL"; + case Op::OpSubgroupAvcImeSetMaxMotionVectorCountINTEL: return "OpSubgroupAvcImeSetMaxMotionVectorCountINTEL"; + case Op::OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL: return "OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL"; + case Op::OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL: return "OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL"; + case Op::OpSubgroupAvcImeSetWeightedSadINTEL: return "OpSubgroupAvcImeSetWeightedSadINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL"; + case Op::OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL: return "OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL"; + case Op::OpSubgroupAvcImeConvertToMceResultINTEL: return "OpSubgroupAvcImeConvertToMceResultINTEL"; + case Op::OpSubgroupAvcImeGetSingleReferenceStreaminINTEL: return "OpSubgroupAvcImeGetSingleReferenceStreaminINTEL"; + case Op::OpSubgroupAvcImeGetDualReferenceStreaminINTEL: return "OpSubgroupAvcImeGetDualReferenceStreaminINTEL"; + case Op::OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL"; + case Op::OpSubgroupAvcImeStripDualReferenceStreamoutINTEL: return "OpSubgroupAvcImeStripDualReferenceStreamoutINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL"; + case Op::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL: return "OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL"; + case Op::OpSubgroupAvcImeGetBorderReachedINTEL: return "OpSubgroupAvcImeGetBorderReachedINTEL"; + case Op::OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL: return "OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL"; + case Op::OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL: return "OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL"; + case Op::OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL"; + case Op::OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL: return "OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL"; + case Op::OpSubgroupAvcFmeInitializeINTEL: return "OpSubgroupAvcFmeInitializeINTEL"; + case Op::OpSubgroupAvcBmeInitializeINTEL: return "OpSubgroupAvcBmeInitializeINTEL"; + case Op::OpSubgroupAvcRefConvertToMcePayloadINTEL: return "OpSubgroupAvcRefConvertToMcePayloadINTEL"; + case Op::OpSubgroupAvcRefSetBidirectionalMixDisableINTEL: return "OpSubgroupAvcRefSetBidirectionalMixDisableINTEL"; + case Op::OpSubgroupAvcRefSetBilinearFilterEnableINTEL: return "OpSubgroupAvcRefSetBilinearFilterEnableINTEL"; + case Op::OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL"; + case Op::OpSubgroupAvcRefEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithDualReferenceINTEL"; + case Op::OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL"; + case Op::OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL"; + case Op::OpSubgroupAvcRefConvertToMceResultINTEL: return "OpSubgroupAvcRefConvertToMceResultINTEL"; + case Op::OpSubgroupAvcSicInitializeINTEL: return "OpSubgroupAvcSicInitializeINTEL"; + case Op::OpSubgroupAvcSicConfigureSkcINTEL: return "OpSubgroupAvcSicConfigureSkcINTEL"; + case Op::OpSubgroupAvcSicConfigureIpeLumaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaINTEL"; + case Op::OpSubgroupAvcSicConfigureIpeLumaChromaINTEL: return "OpSubgroupAvcSicConfigureIpeLumaChromaINTEL"; + case Op::OpSubgroupAvcSicGetMotionVectorMaskINTEL: return "OpSubgroupAvcSicGetMotionVectorMaskINTEL"; + case Op::OpSubgroupAvcSicConvertToMcePayloadINTEL: return "OpSubgroupAvcSicConvertToMcePayloadINTEL"; + case Op::OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL: return "OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL"; + case Op::OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL"; + case Op::OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL: return "OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL"; + case Op::OpSubgroupAvcSicSetBilinearFilterEnableINTEL: return "OpSubgroupAvcSicSetBilinearFilterEnableINTEL"; + case Op::OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL: return "OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL"; + case Op::OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL: return "OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL"; + case Op::OpSubgroupAvcSicEvaluateIpeINTEL: return "OpSubgroupAvcSicEvaluateIpeINTEL"; + case Op::OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL"; + case Op::OpSubgroupAvcSicEvaluateWithDualReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithDualReferenceINTEL"; + case Op::OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL"; + case Op::OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL: return "OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL"; + case Op::OpSubgroupAvcSicConvertToMceResultINTEL: return "OpSubgroupAvcSicConvertToMceResultINTEL"; + case Op::OpSubgroupAvcSicGetIpeLumaShapeINTEL: return "OpSubgroupAvcSicGetIpeLumaShapeINTEL"; + case Op::OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL"; + case Op::OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL: return "OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL"; + case Op::OpSubgroupAvcSicGetPackedIpeLumaModesINTEL: return "OpSubgroupAvcSicGetPackedIpeLumaModesINTEL"; + case Op::OpSubgroupAvcSicGetIpeChromaModeINTEL: return "OpSubgroupAvcSicGetIpeChromaModeINTEL"; + case Op::OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL"; + case Op::OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: return "OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL"; + case Op::OpSubgroupAvcSicGetInterRawSadsINTEL: return "OpSubgroupAvcSicGetInterRawSadsINTEL"; + case Op::OpVariableLengthArrayINTEL: return "OpVariableLengthArrayINTEL"; + case Op::OpSaveMemoryINTEL: return "OpSaveMemoryINTEL"; + case Op::OpRestoreMemoryINTEL: return "OpRestoreMemoryINTEL"; + case Op::OpArbitraryFloatSinCosPiINTEL: return "OpArbitraryFloatSinCosPiINTEL"; + case Op::OpArbitraryFloatCastINTEL: return "OpArbitraryFloatCastINTEL"; + case Op::OpArbitraryFloatCastFromIntINTEL: return "OpArbitraryFloatCastFromIntINTEL"; + case Op::OpArbitraryFloatCastToIntINTEL: return "OpArbitraryFloatCastToIntINTEL"; + case Op::OpArbitraryFloatAddINTEL: return "OpArbitraryFloatAddINTEL"; + case Op::OpArbitraryFloatSubINTEL: return "OpArbitraryFloatSubINTEL"; + case Op::OpArbitraryFloatMulINTEL: return "OpArbitraryFloatMulINTEL"; + case Op::OpArbitraryFloatDivINTEL: return "OpArbitraryFloatDivINTEL"; + case Op::OpArbitraryFloatGTINTEL: return "OpArbitraryFloatGTINTEL"; + case Op::OpArbitraryFloatGEINTEL: return "OpArbitraryFloatGEINTEL"; + case Op::OpArbitraryFloatLTINTEL: return "OpArbitraryFloatLTINTEL"; + case Op::OpArbitraryFloatLEINTEL: return "OpArbitraryFloatLEINTEL"; + case Op::OpArbitraryFloatEQINTEL: return "OpArbitraryFloatEQINTEL"; + case Op::OpArbitraryFloatRecipINTEL: return "OpArbitraryFloatRecipINTEL"; + case Op::OpArbitraryFloatRSqrtINTEL: return "OpArbitraryFloatRSqrtINTEL"; + case Op::OpArbitraryFloatCbrtINTEL: return "OpArbitraryFloatCbrtINTEL"; + case Op::OpArbitraryFloatHypotINTEL: return "OpArbitraryFloatHypotINTEL"; + case Op::OpArbitraryFloatSqrtINTEL: return "OpArbitraryFloatSqrtINTEL"; + case Op::OpArbitraryFloatLogINTEL: return "OpArbitraryFloatLogINTEL"; + case Op::OpArbitraryFloatLog2INTEL: return "OpArbitraryFloatLog2INTEL"; + case Op::OpArbitraryFloatLog10INTEL: return "OpArbitraryFloatLog10INTEL"; + case Op::OpArbitraryFloatLog1pINTEL: return "OpArbitraryFloatLog1pINTEL"; + case Op::OpArbitraryFloatExpINTEL: return "OpArbitraryFloatExpINTEL"; + case Op::OpArbitraryFloatExp2INTEL: return "OpArbitraryFloatExp2INTEL"; + case Op::OpArbitraryFloatExp10INTEL: return "OpArbitraryFloatExp10INTEL"; + case Op::OpArbitraryFloatExpm1INTEL: return "OpArbitraryFloatExpm1INTEL"; + case Op::OpArbitraryFloatSinINTEL: return "OpArbitraryFloatSinINTEL"; + case Op::OpArbitraryFloatCosINTEL: return "OpArbitraryFloatCosINTEL"; + case Op::OpArbitraryFloatSinCosINTEL: return "OpArbitraryFloatSinCosINTEL"; + case Op::OpArbitraryFloatSinPiINTEL: return "OpArbitraryFloatSinPiINTEL"; + case Op::OpArbitraryFloatCosPiINTEL: return "OpArbitraryFloatCosPiINTEL"; + case Op::OpArbitraryFloatASinINTEL: return "OpArbitraryFloatASinINTEL"; + case Op::OpArbitraryFloatASinPiINTEL: return "OpArbitraryFloatASinPiINTEL"; + case Op::OpArbitraryFloatACosINTEL: return "OpArbitraryFloatACosINTEL"; + case Op::OpArbitraryFloatACosPiINTEL: return "OpArbitraryFloatACosPiINTEL"; + case Op::OpArbitraryFloatATanINTEL: return "OpArbitraryFloatATanINTEL"; + case Op::OpArbitraryFloatATanPiINTEL: return "OpArbitraryFloatATanPiINTEL"; + case Op::OpArbitraryFloatATan2INTEL: return "OpArbitraryFloatATan2INTEL"; + case Op::OpArbitraryFloatPowINTEL: return "OpArbitraryFloatPowINTEL"; + case Op::OpArbitraryFloatPowRINTEL: return "OpArbitraryFloatPowRINTEL"; + case Op::OpArbitraryFloatPowNINTEL: return "OpArbitraryFloatPowNINTEL"; + case Op::OpLoopControlINTEL: return "OpLoopControlINTEL"; + case Op::OpAliasDomainDeclINTEL: return "OpAliasDomainDeclINTEL"; + case Op::OpAliasScopeDeclINTEL: return "OpAliasScopeDeclINTEL"; + case Op::OpAliasScopeListDeclINTEL: return "OpAliasScopeListDeclINTEL"; + case Op::OpFixedSqrtINTEL: return "OpFixedSqrtINTEL"; + case Op::OpFixedRecipINTEL: return "OpFixedRecipINTEL"; + case Op::OpFixedRsqrtINTEL: return "OpFixedRsqrtINTEL"; + case Op::OpFixedSinINTEL: return "OpFixedSinINTEL"; + case Op::OpFixedCosINTEL: return "OpFixedCosINTEL"; + case Op::OpFixedSinCosINTEL: return "OpFixedSinCosINTEL"; + case Op::OpFixedSinPiINTEL: return "OpFixedSinPiINTEL"; + case Op::OpFixedCosPiINTEL: return "OpFixedCosPiINTEL"; + case Op::OpFixedSinCosPiINTEL: return "OpFixedSinCosPiINTEL"; + case Op::OpFixedLogINTEL: return "OpFixedLogINTEL"; + case Op::OpFixedExpINTEL: return "OpFixedExpINTEL"; + case Op::OpPtrCastToCrossWorkgroupINTEL: return "OpPtrCastToCrossWorkgroupINTEL"; + case Op::OpCrossWorkgroupCastToPtrINTEL: return "OpCrossWorkgroupCastToPtrINTEL"; + case Op::OpReadPipeBlockingINTEL: return "OpReadPipeBlockingINTEL"; + case Op::OpWritePipeBlockingINTEL: return "OpWritePipeBlockingINTEL"; + case Op::OpFPGARegINTEL: return "OpFPGARegINTEL"; + case Op::OpRayQueryGetRayTMinKHR: return "OpRayQueryGetRayTMinKHR"; + case Op::OpRayQueryGetRayFlagsKHR: return "OpRayQueryGetRayFlagsKHR"; + case Op::OpRayQueryGetIntersectionTKHR: return "OpRayQueryGetIntersectionTKHR"; + case Op::OpRayQueryGetIntersectionInstanceCustomIndexKHR: return "OpRayQueryGetIntersectionInstanceCustomIndexKHR"; + case Op::OpRayQueryGetIntersectionInstanceIdKHR: return "OpRayQueryGetIntersectionInstanceIdKHR"; + case Op::OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR: return "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR"; + case Op::OpRayQueryGetIntersectionGeometryIndexKHR: return "OpRayQueryGetIntersectionGeometryIndexKHR"; + case Op::OpRayQueryGetIntersectionPrimitiveIndexKHR: return "OpRayQueryGetIntersectionPrimitiveIndexKHR"; + case Op::OpRayQueryGetIntersectionBarycentricsKHR: return "OpRayQueryGetIntersectionBarycentricsKHR"; + case Op::OpRayQueryGetIntersectionFrontFaceKHR: return "OpRayQueryGetIntersectionFrontFaceKHR"; + case Op::OpRayQueryGetIntersectionCandidateAABBOpaqueKHR: return "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR"; + case Op::OpRayQueryGetIntersectionObjectRayDirectionKHR: return "OpRayQueryGetIntersectionObjectRayDirectionKHR"; + case Op::OpRayQueryGetIntersectionObjectRayOriginKHR: return "OpRayQueryGetIntersectionObjectRayOriginKHR"; + case Op::OpRayQueryGetWorldRayDirectionKHR: return "OpRayQueryGetWorldRayDirectionKHR"; + case Op::OpRayQueryGetWorldRayOriginKHR: return "OpRayQueryGetWorldRayOriginKHR"; + case Op::OpRayQueryGetIntersectionObjectToWorldKHR: return "OpRayQueryGetIntersectionObjectToWorldKHR"; + case Op::OpRayQueryGetIntersectionWorldToObjectKHR: return "OpRayQueryGetIntersectionWorldToObjectKHR"; + case Op::OpAtomicFAddEXT: return "OpAtomicFAddEXT"; + case Op::OpTypeBufferSurfaceINTEL: return "OpTypeBufferSurfaceINTEL"; + case Op::OpTypeStructContinuedINTEL: return "OpTypeStructContinuedINTEL"; + case Op::OpConstantCompositeContinuedINTEL: return "OpConstantCompositeContinuedINTEL"; + case Op::OpSpecConstantCompositeContinuedINTEL: return "OpSpecConstantCompositeContinuedINTEL"; + case Op::OpCompositeConstructContinuedINTEL: return "OpCompositeConstructContinuedINTEL"; + case Op::OpConvertFToBF16INTEL: return "OpConvertFToBF16INTEL"; + case Op::OpConvertBF16ToFINTEL: return "OpConvertBF16ToFINTEL"; + case Op::OpControlBarrierArriveINTEL: return "OpControlBarrierArriveINTEL"; + case Op::OpControlBarrierWaitINTEL: return "OpControlBarrierWaitINTEL"; + case Op::OpArithmeticFenceEXT: return "OpArithmeticFenceEXT"; + case Op::OpSubgroupBlockPrefetchINTEL: return "OpSubgroupBlockPrefetchINTEL"; + case Op::OpSubgroup2DBlockLoadINTEL: return "OpSubgroup2DBlockLoadINTEL"; + case Op::OpSubgroup2DBlockLoadTransformINTEL: return "OpSubgroup2DBlockLoadTransformINTEL"; + case Op::OpSubgroup2DBlockLoadTransposeINTEL: return "OpSubgroup2DBlockLoadTransposeINTEL"; + case Op::OpSubgroup2DBlockPrefetchINTEL: return "OpSubgroup2DBlockPrefetchINTEL"; + case Op::OpSubgroup2DBlockStoreINTEL: return "OpSubgroup2DBlockStoreINTEL"; + case Op::OpSubgroupMatrixMultiplyAccumulateINTEL: return "OpSubgroupMatrixMultiplyAccumulateINTEL"; + case Op::OpGroupIMulKHR: return "OpGroupIMulKHR"; + case Op::OpGroupFMulKHR: return "OpGroupFMulKHR"; + case Op::OpGroupBitwiseAndKHR: return "OpGroupBitwiseAndKHR"; + case Op::OpGroupBitwiseOrKHR: return "OpGroupBitwiseOrKHR"; + case Op::OpGroupBitwiseXorKHR: return "OpGroupBitwiseXorKHR"; + case Op::OpGroupLogicalAndKHR: return "OpGroupLogicalAndKHR"; + case Op::OpGroupLogicalOrKHR: return "OpGroupLogicalOrKHR"; + case Op::OpGroupLogicalXorKHR: return "OpGroupLogicalXorKHR"; + case Op::OpMaskedGatherINTEL: return "OpMaskedGatherINTEL"; + case Op::OpMaskedScatterINTEL: return "OpMaskedScatterINTEL"; + default: return "Unknown"; + } +} + #endif /* SPV_ENABLE_UTILITY_CODE */ // Overload bitwise operators for mask bit combining -inline ImageOperandsMask operator|(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) | unsigned(b)); } -inline ImageOperandsMask operator&(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) & unsigned(b)); } -inline ImageOperandsMask operator^(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) ^ unsigned(b)); } -inline ImageOperandsMask operator~(ImageOperandsMask a) { return ImageOperandsMask(~unsigned(a)); } -inline FPFastMathModeMask operator|(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) | unsigned(b)); } -inline FPFastMathModeMask operator&(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) & unsigned(b)); } -inline FPFastMathModeMask operator^(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) ^ unsigned(b)); } -inline FPFastMathModeMask operator~(FPFastMathModeMask a) { return FPFastMathModeMask(~unsigned(a)); } -inline SelectionControlMask operator|(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) | unsigned(b)); } -inline SelectionControlMask operator&(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) & unsigned(b)); } -inline SelectionControlMask operator^(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) ^ unsigned(b)); } -inline SelectionControlMask operator~(SelectionControlMask a) { return SelectionControlMask(~unsigned(a)); } -inline LoopControlMask operator|(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) | unsigned(b)); } -inline LoopControlMask operator&(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) & unsigned(b)); } -inline LoopControlMask operator^(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) ^ unsigned(b)); } -inline LoopControlMask operator~(LoopControlMask a) { return LoopControlMask(~unsigned(a)); } -inline FunctionControlMask operator|(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) | unsigned(b)); } -inline FunctionControlMask operator&(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) & unsigned(b)); } -inline FunctionControlMask operator^(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) ^ unsigned(b)); } -inline FunctionControlMask operator~(FunctionControlMask a) { return FunctionControlMask(~unsigned(a)); } -inline MemorySemanticsMask operator|(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) | unsigned(b)); } -inline MemorySemanticsMask operator&(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) & unsigned(b)); } -inline MemorySemanticsMask operator^(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) ^ unsigned(b)); } -inline MemorySemanticsMask operator~(MemorySemanticsMask a) { return MemorySemanticsMask(~unsigned(a)); } -inline MemoryAccessMask operator|(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) | unsigned(b)); } -inline MemoryAccessMask operator&(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) & unsigned(b)); } -inline MemoryAccessMask operator^(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) ^ unsigned(b)); } -inline MemoryAccessMask operator~(MemoryAccessMask a) { return MemoryAccessMask(~unsigned(a)); } -inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) | unsigned(b)); } -inline KernelProfilingInfoMask operator&(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) & unsigned(b)); } -inline KernelProfilingInfoMask operator^(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) ^ unsigned(b)); } -inline KernelProfilingInfoMask operator~(KernelProfilingInfoMask a) { return KernelProfilingInfoMask(~unsigned(a)); } -inline RayFlagsMask operator|(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) | unsigned(b)); } -inline RayFlagsMask operator&(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) & unsigned(b)); } -inline RayFlagsMask operator^(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) ^ unsigned(b)); } -inline RayFlagsMask operator~(RayFlagsMask a) { return RayFlagsMask(~unsigned(a)); } -inline FragmentShadingRateMask operator|(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) | unsigned(b)); } -inline FragmentShadingRateMask operator&(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) & unsigned(b)); } -inline FragmentShadingRateMask operator^(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) ^ unsigned(b)); } -inline FragmentShadingRateMask operator~(FragmentShadingRateMask a) { return FragmentShadingRateMask(~unsigned(a)); } +constexpr ImageOperandsMask operator|(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) | unsigned(b)); } +constexpr ImageOperandsMask operator&(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) & unsigned(b)); } +constexpr ImageOperandsMask operator^(ImageOperandsMask a, ImageOperandsMask b) { return ImageOperandsMask(unsigned(a) ^ unsigned(b)); } +constexpr ImageOperandsMask operator~(ImageOperandsMask a) { return ImageOperandsMask(~unsigned(a)); } +constexpr FPFastMathModeMask operator|(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) | unsigned(b)); } +constexpr FPFastMathModeMask operator&(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) & unsigned(b)); } +constexpr FPFastMathModeMask operator^(FPFastMathModeMask a, FPFastMathModeMask b) { return FPFastMathModeMask(unsigned(a) ^ unsigned(b)); } +constexpr FPFastMathModeMask operator~(FPFastMathModeMask a) { return FPFastMathModeMask(~unsigned(a)); } +constexpr SelectionControlMask operator|(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) | unsigned(b)); } +constexpr SelectionControlMask operator&(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) & unsigned(b)); } +constexpr SelectionControlMask operator^(SelectionControlMask a, SelectionControlMask b) { return SelectionControlMask(unsigned(a) ^ unsigned(b)); } +constexpr SelectionControlMask operator~(SelectionControlMask a) { return SelectionControlMask(~unsigned(a)); } +constexpr LoopControlMask operator|(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) | unsigned(b)); } +constexpr LoopControlMask operator&(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) & unsigned(b)); } +constexpr LoopControlMask operator^(LoopControlMask a, LoopControlMask b) { return LoopControlMask(unsigned(a) ^ unsigned(b)); } +constexpr LoopControlMask operator~(LoopControlMask a) { return LoopControlMask(~unsigned(a)); } +constexpr FunctionControlMask operator|(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) | unsigned(b)); } +constexpr FunctionControlMask operator&(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) & unsigned(b)); } +constexpr FunctionControlMask operator^(FunctionControlMask a, FunctionControlMask b) { return FunctionControlMask(unsigned(a) ^ unsigned(b)); } +constexpr FunctionControlMask operator~(FunctionControlMask a) { return FunctionControlMask(~unsigned(a)); } +constexpr MemorySemanticsMask operator|(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) | unsigned(b)); } +constexpr MemorySemanticsMask operator&(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) & unsigned(b)); } +constexpr MemorySemanticsMask operator^(MemorySemanticsMask a, MemorySemanticsMask b) { return MemorySemanticsMask(unsigned(a) ^ unsigned(b)); } +constexpr MemorySemanticsMask operator~(MemorySemanticsMask a) { return MemorySemanticsMask(~unsigned(a)); } +constexpr MemoryAccessMask operator|(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) | unsigned(b)); } +constexpr MemoryAccessMask operator&(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) & unsigned(b)); } +constexpr MemoryAccessMask operator^(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) ^ unsigned(b)); } +constexpr MemoryAccessMask operator~(MemoryAccessMask a) { return MemoryAccessMask(~unsigned(a)); } +constexpr KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) | unsigned(b)); } +constexpr KernelProfilingInfoMask operator&(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) & unsigned(b)); } +constexpr KernelProfilingInfoMask operator^(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) ^ unsigned(b)); } +constexpr KernelProfilingInfoMask operator~(KernelProfilingInfoMask a) { return KernelProfilingInfoMask(~unsigned(a)); } +constexpr RayFlagsMask operator|(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) | unsigned(b)); } +constexpr RayFlagsMask operator&(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) & unsigned(b)); } +constexpr RayFlagsMask operator^(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) ^ unsigned(b)); } +constexpr RayFlagsMask operator~(RayFlagsMask a) { return RayFlagsMask(~unsigned(a)); } +constexpr FragmentShadingRateMask operator|(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) | unsigned(b)); } +constexpr FragmentShadingRateMask operator&(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) & unsigned(b)); } +constexpr FragmentShadingRateMask operator^(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) ^ unsigned(b)); } +constexpr FragmentShadingRateMask operator~(FragmentShadingRateMask a) { return FragmentShadingRateMask(~unsigned(a)); } +constexpr CooperativeMatrixOperandsMask operator|(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) | unsigned(b)); } +constexpr CooperativeMatrixOperandsMask operator&(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) & unsigned(b)); } +constexpr CooperativeMatrixOperandsMask operator^(CooperativeMatrixOperandsMask a, CooperativeMatrixOperandsMask b) { return CooperativeMatrixOperandsMask(unsigned(a) ^ unsigned(b)); } +constexpr CooperativeMatrixOperandsMask operator~(CooperativeMatrixOperandsMask a) { return CooperativeMatrixOperandsMask(~unsigned(a)); } +constexpr CooperativeMatrixReduceMask operator|(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) | unsigned(b)); } +constexpr CooperativeMatrixReduceMask operator&(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) & unsigned(b)); } +constexpr CooperativeMatrixReduceMask operator^(CooperativeMatrixReduceMask a, CooperativeMatrixReduceMask b) { return CooperativeMatrixReduceMask(unsigned(a) ^ unsigned(b)); } +constexpr CooperativeMatrixReduceMask operator~(CooperativeMatrixReduceMask a) { return CooperativeMatrixReduceMask(~unsigned(a)); } +constexpr TensorAddressingOperandsMask operator|(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) | unsigned(b)); } +constexpr TensorAddressingOperandsMask operator&(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) & unsigned(b)); } +constexpr TensorAddressingOperandsMask operator^(TensorAddressingOperandsMask a, TensorAddressingOperandsMask b) { return TensorAddressingOperandsMask(unsigned(a) ^ unsigned(b)); } +constexpr TensorAddressingOperandsMask operator~(TensorAddressingOperandsMask a) { return TensorAddressingOperandsMask(~unsigned(a)); } +constexpr MatrixMultiplyAccumulateOperandsMask operator|(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) | unsigned(b)); } +constexpr MatrixMultiplyAccumulateOperandsMask operator&(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) & unsigned(b)); } +constexpr MatrixMultiplyAccumulateOperandsMask operator^(MatrixMultiplyAccumulateOperandsMask a, MatrixMultiplyAccumulateOperandsMask b) { return MatrixMultiplyAccumulateOperandsMask(unsigned(a) ^ unsigned(b)); } +constexpr MatrixMultiplyAccumulateOperandsMask operator~(MatrixMultiplyAccumulateOperandsMask a) { return MatrixMultiplyAccumulateOperandsMask(~unsigned(a)); } +constexpr RawAccessChainOperandsMask operator|(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) | unsigned(b)); } +constexpr RawAccessChainOperandsMask operator&(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) & unsigned(b)); } +constexpr RawAccessChainOperandsMask operator^(RawAccessChainOperandsMask a, RawAccessChainOperandsMask b) { return RawAccessChainOperandsMask(unsigned(a) ^ unsigned(b)); } +constexpr RawAccessChainOperandsMask operator~(RawAccessChainOperandsMask a) { return RawAccessChainOperandsMask(~unsigned(a)); } } // end namespace spv diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.json b/third_party/spirv-headers/include/spirv/unified1/spirv.json index 4cd00db243..60797644fd 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.json +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.json @@ -6,7 +6,7 @@ "Comment": [ [ - "Copyright (c) 2014-2020 The Khronos Group Inc.", + "Copyright (c) 2014-2024 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\"),", @@ -20,7 +20,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,", @@ -75,7 +75,13 @@ "OpenCL_CPP": 4, "HLSL": 5, "CPP_for_OpenCL": 6, - "SYCL": 7 + "SYCL": 7, + "HERO_C": 8, + "NZSL": 9, + "WGSL": 10, + "Slang": 11, + "Zig": 12, + "Rust": 13 } }, { @@ -175,6 +181,9 @@ "SubgroupsPerWorkgroupId": 37, "LocalSizeId": 38, "LocalSizeHintId": 39, + "NonCoherentColorAttachmentReadEXT": 4169, + "NonCoherentDepthAttachmentReadEXT": 4170, + "NonCoherentStencilAttachmentReadEXT": 4171, "SubgroupUniformControlFlowKHR": 4421, "PostDepthCoverage": 4446, "DenormPreserve": 4459, @@ -184,17 +193,28 @@ "RoundingModeRTZ": 4463, "EarlyAndLateFragmentTestsAMD": 5017, "StencilRefReplacingEXT": 5027, + "CoalescingAMDX": 5069, + "IsApiEntryAMDX": 5070, + "MaxNodeRecursionAMDX": 5071, + "StaticNumWorkgroupsAMDX": 5072, + "ShaderIndexAMDX": 5073, + "MaxNumWorkgroupsAMDX": 5077, "StencilRefUnchangedFrontAMD": 5079, "StencilRefGreaterFrontAMD": 5080, "StencilRefLessFrontAMD": 5081, "StencilRefUnchangedBackAMD": 5082, "StencilRefGreaterBackAMD": 5083, "StencilRefLessBackAMD": 5084, + "QuadDerivativesKHR": 5088, + "RequireFullQuadsKHR": 5089, + "SharesInputWithAMDX": 5102, "OutputLinesEXT": 5269, "OutputLinesNV": 5269, "OutputPrimitivesEXT": 5270, "OutputPrimitivesNV": 5270, + "DerivativeGroupQuadsKHR": 5289, "DerivativeGroupQuadsNV": 5289, + "DerivativeGroupLinearKHR": 5290, "DerivativeGroupLinearNV": 5290, "OutputTrianglesEXT": 5298, "OutputTrianglesNV": 5298, @@ -214,8 +234,14 @@ "NoGlobalOffsetINTEL": 5895, "NumSIMDWorkitemsINTEL": 5896, "SchedulerTargetFmaxMhzINTEL": 5903, + "MaximallyReconvergesKHR": 6023, + "FPFastMathDefault": 6028, "StreamingInterfaceINTEL": 6154, - "NamedBarrierCountINTEL": 6417 + "RegisterMapInterfaceINTEL": 6160, + "NamedBarrierCountINTEL": 6417, + "MaximumRegistersINTEL": 6461, + "MaximumRegistersIdINTEL": 6462, + "NamedMaximumRegistersINTEL": 6463 } }, { @@ -236,6 +262,8 @@ "AtomicCounter": 10, "Image": 11, "StorageBuffer": 12, + "TileImageEXT": 4172, + "NodePayloadAMDX": 5068, "CallableDataKHR": 5328, "CallableDataNV": 5328, "IncomingCallableDataKHR": 5329, @@ -268,7 +296,8 @@ "Cube": 3, "Rect": 4, "Buffer": 5, - "SubpassData": 6 + "SubpassData": 6, + "TileImageDataEXT": 4173 } }, { @@ -389,7 +418,10 @@ "HalfFloat": 13, "Float": 14, "UnormInt24": 15, - "UnormInt101010_2": 16 + "UnormInt101010_2": 16, + "UnsignedIntRaw10EXT": 19, + "UnsignedIntRaw12EXT": 20, + "UnormInt2_101010EXT": 21 } }, { @@ -429,8 +461,11 @@ "NSZ": 2, "AllowRecip": 3, "Fast": 4, + "AllowContract": 16, "AllowContractFastINTEL": 16, - "AllowReassocINTEL": 17 + "AllowReassoc": 17, + "AllowReassocINTEL": 17, + "AllowTransform": 18 } }, { @@ -534,7 +569,18 @@ "MaxByteOffsetId": 47, "NoSignedWrap": 4469, "NoUnsignedWrap": 4470, + "WeightTextureQCOM": 4487, + "BlockMatchTextureQCOM": 4488, + "BlockMatchSamplerQCOM": 4499, "ExplicitInterpAMD": 4999, + "NodeSharesPayloadLimitsWithAMDX": 5019, + "NodeMaxPayloadsAMDX": 5020, + "TrackFinishWritingAMDX": 5078, + "PayloadNodeNameAMDX": 5091, + "PayloadNodeBaseIndexAMDX": 5098, + "PayloadNodeSparseArrayAMDX": 5099, + "PayloadNodeArraySizeAMDX": 5100, + "PayloadDispatchIndirectAMDX": 5105, "OverrideCoverageNV": 5248, "PassthroughNV": 5250, "ViewportRelativeNV": 5252, @@ -584,6 +630,9 @@ "MergeINTEL": 5834, "BankBitsINTEL": 5835, "ForcePow2DepthINTEL": 5836, + "StridesizeINTEL": 5883, + "WordsizeINTEL": 5884, + "TrueDualPortINTEL": 5885, "BurstCoalesceINTEL": 5899, "CacheSizeINTEL": 5900, "DontStaticallyCoalesceINTEL": 5901, @@ -601,7 +650,25 @@ "FunctionFloatingPointModeINTEL": 6080, "SingleElementVectorINTEL": 6085, "VectorComputeCallableFunctionINTEL": 6087, - "MediaBlockIOINTEL": 6140 + "MediaBlockIOINTEL": 6140, + "StallFreeINTEL": 6151, + "FPMaxErrorDecorationINTEL": 6170, + "LatencyControlLabelINTEL": 6172, + "LatencyControlConstraintINTEL": 6173, + "ConduitKernelArgumentINTEL": 6175, + "RegisterMapKernelArgumentINTEL": 6176, + "MMHostInterfaceAddressWidthINTEL": 6177, + "MMHostInterfaceDataWidthINTEL": 6178, + "MMHostInterfaceLatencyINTEL": 6179, + "MMHostInterfaceReadWriteModeINTEL": 6180, + "MMHostInterfaceMaxBurstINTEL": 6181, + "MMHostInterfaceWaitRequestINTEL": 6182, + "StableKernelArgumentINTEL": 6183, + "HostAccessINTEL": 6188, + "InitModeINTEL": 6190, + "ImplementInRegisterMapINTEL": 6191, + "CacheControlLoadINTEL": 6442, + "CacheControlStoreINTEL": 6443 } }, { @@ -680,6 +747,8 @@ "BaryCoordSmoothSampleAMD": 4997, "BaryCoordPullModelAMD": 4998, "FragStencilRefEXT": 5014, + "RemainingRecursionLevelsAMDX": 5021, + "ShaderIndexAMDX": 5073, "ViewportMaskNV": 5253, "SecondaryPositionNV": 5257, "SecondaryViewportMaskNV": 5258, @@ -732,13 +801,25 @@ "HitKindKHR": 5333, "HitKindNV": 5333, "CurrentRayTimeNV": 5334, + "HitTriangleVertexPositionsKHR": 5335, + "HitMicroTriangleVertexPositionsNV": 5337, + "HitMicroTriangleVertexBarycentricsNV": 5344, "IncomingRayFlagsKHR": 5351, "IncomingRayFlagsNV": 5351, "RayGeometryIndexKHR": 5352, + "HitIsSphereNV": 5359, + "HitIsLSSNV": 5360, + "HitSpherePositionNV": 5361, "WarpsPerSMNV": 5374, "SMCountNV": 5375, "WarpIDNV": 5376, "SMIDNV": 5377, + "HitLSSPositionsNV": 5396, + "HitKindFrontFacingMicroTriangleNV": 5405, + "HitKindBackFacingMicroTriangleNV": 5406, + "HitSphereRadiusNV": 5420, + "HitLSSRadiiNV": 5421, + "ClusterIDNV": 5436, "CullMaskKHR": 6021 } }, @@ -786,6 +867,7 @@ "DontInline": 1, "Pure": 2, "Const": 3, + "OptNoneEXT": 16, "OptNoneINTEL": 16 } }, @@ -954,6 +1036,10 @@ "ShaderViewportIndex": 70, "UniformDecoration": 71, "CoreBuiltinsARM": 4165, + "TileImageColorReadAccessEXT": 4166, + "TileImageDepthReadAccessEXT": 4167, + "TileImageStencilReadAccessEXT": 4168, + "CooperativeMatrixLayoutsARM": 4201, "FragmentShadingRateKHR": 4422, "SubgroupBallotKHR": 4423, "DrawParameters": 4427, @@ -983,8 +1069,13 @@ "RoundingModeRTZ": 4468, "RayQueryProvisionalKHR": 4471, "RayQueryKHR": 4472, + "UntypedPointersKHR": 4473, "RayTraversalPrimitiveCullingKHR": 4478, "RayTracingKHR": 4479, + "TextureSampleWeightedQCOM": 4484, + "TextureBoxFilterQCOM": 4485, + "TextureBlockMatchQCOM": 4486, + "TextureBlockMatch2QCOM": 4498, "Float16ImageAMD": 5008, "ImageGatherBiasLodAMD": 5009, "FragmentMaskAMD": 5010, @@ -992,6 +1083,8 @@ "ImageReadWriteLodAMD": 5015, "Int64ImageEXT": 5016, "ShaderClockKHR": 5055, + "ShaderEnqueueAMDX": 5067, + "QuadControlKHR": 5087, "SampleMaskOverrideCoverageNV": 5249, "GeometryShaderPassthroughNV": 5251, "ShaderViewportIndexLayerEXT": 5254, @@ -1005,6 +1098,7 @@ "MeshShadingEXT": 5283, "FragmentBarycentricKHR": 5284, "FragmentBarycentricNV": 5284, + "ComputeDerivativeGroupQuadsKHR": 5288, "ComputeDerivativeGroupQuadsNV": 5288, "FragmentDensityEXT": 5291, "ShadingRateNV": 5291, @@ -1033,6 +1127,7 @@ "UniformTexelBufferArrayNonUniformIndexingEXT": 5311, "StorageTexelBufferArrayNonUniformIndexing": 5312, "StorageTexelBufferArrayNonUniformIndexingEXT": 5312, + "RayTracingPositionFetchKHR": 5336, "RayTracingNV": 5340, "RayTracingMotionBlurNV": 5341, "VulkanMemoryModel": 5345, @@ -1041,6 +1136,7 @@ "VulkanMemoryModelDeviceScopeKHR": 5346, "PhysicalStorageBufferAddresses": 5347, "PhysicalStorageBufferAddressesEXT": 5347, + "ComputeDerivativeGroupLinearKHR": 5350, "ComputeDerivativeGroupLinearNV": 5350, "RayTracingProvisionalKHR": 5353, "CooperativeMatrixNV": 5357, @@ -1050,9 +1146,25 @@ "FragmentShaderPixelInterlockEXT": 5378, "DemoteToHelperInvocation": 5379, "DemoteToHelperInvocationEXT": 5379, + "DisplacementMicromapNV": 5380, "RayTracingOpacityMicromapEXT": 5381, "ShaderInvocationReorderNV": 5383, "BindlessTextureNV": 5390, + "RayQueryPositionFetchKHR": 5391, + "CooperativeVectorNV": 5394, + "AtomicFloat16VectorNV": 5404, + "RayTracingDisplacementMicromapNV": 5409, + "RawAccessChainsNV": 5414, + "RayTracingSpheresGeometryNV": 5418, + "RayTracingLinearSweptSpheresGeometryNV": 5419, + "CooperativeMatrixReductionsNV": 5430, + "CooperativeMatrixConversionsNV": 5431, + "CooperativeMatrixPerElementOperationsNV": 5432, + "CooperativeMatrixTensorAddressingNV": 5433, + "CooperativeMatrixBlockLoadsNV": 5434, + "CooperativeVectorTrainingNV": 5435, + "RayTracingClusterAccelerationStructureNV": 5437, + "TensorAddressingNV": 5439, "SubgroupShuffleINTEL": 5568, "SubgroupBufferBlockIOINTEL": 5569, "SubgroupImageBlockIOINTEL": 5570, @@ -1104,16 +1216,37 @@ "DotProduct": 6019, "DotProductKHR": 6019, "RayCullMaskKHR": 6020, + "CooperativeMatrixKHR": 6022, + "ReplicatedCompositesEXT": 6024, "BitInstructions": 6025, "GroupNonUniformRotateKHR": 6026, + "FloatControls2": 6029, "AtomicFloat32AddEXT": 6033, "AtomicFloat64AddEXT": 6034, - "LongConstantCompositeINTEL": 6089, + "LongCompositesINTEL": 6089, + "OptNoneEXT": 6094, "OptNoneINTEL": 6094, "AtomicFloat16AddEXT": 6095, "DebugInfoModuleINTEL": 6114, + "BFloat16ConversionINTEL": 6115, "SplitBarrierINTEL": 6141, - "GroupUniformArithmeticKHR": 6400 + "ArithmeticFenceEXT": 6144, + "FPGAClusterAttributesV2INTEL": 6150, + "FPGAKernelAttributesv2INTEL": 6161, + "FPMaxErrorINTEL": 6169, + "FPGALatencyControlINTEL": 6171, + "FPGAArgumentInterfacesINTEL": 6174, + "GlobalVariableHostAccessINTEL": 6187, + "GlobalVariableFPGADecorationsINTEL": 6189, + "SubgroupBufferPrefetchINTEL": 6220, + "Subgroup2DBlockIOINTEL": 6228, + "Subgroup2DBlockTransformINTEL": 6229, + "Subgroup2DBlockTransposeINTEL": 6230, + "SubgroupMatrixMultiplyAccumulateINTEL": 6236, + "GroupUniformArithmeticKHR": 6400, + "MaskedGatherScatterINTEL": 6427, + "CacheControlsINTEL": 6441, + "RegisterLimitsINTEL": 6460 } }, { @@ -1129,6 +1262,7 @@ "CullFrontFacingTrianglesKHR": 5, "CullOpaqueKHR": 6, "CullNoOpaqueKHR": 7, + "SkipBuiltinPrimitivesNV": 8, "SkipTrianglesKHR": 8, "SkipAABBsKHR": 9, "ForceOpacityMicromap2StateEXT": 10 @@ -1226,6 +1360,191 @@ "PackedVectorFormat4x8BitKHR": 0 } }, + { + "Name": "CooperativeMatrixOperands", + "Type": "Bit", + "Values": + { + "MatrixASignedComponentsKHR": 0, + "MatrixBSignedComponentsKHR": 1, + "MatrixCSignedComponentsKHR": 2, + "MatrixResultSignedComponentsKHR": 3, + "SaturatingAccumulationKHR": 4 + } + }, + { + "Name": "CooperativeMatrixLayout", + "Type": "Value", + "Values": + { + "RowMajorKHR": 0, + "ColumnMajorKHR": 1, + "RowBlockedInterleavedARM": 4202, + "ColumnBlockedInterleavedARM": 4203 + } + }, + { + "Name": "CooperativeMatrixUse", + "Type": "Value", + "Values": + { + "MatrixAKHR": 0, + "MatrixBKHR": 1, + "MatrixAccumulatorKHR": 2 + } + }, + { + "Name": "CooperativeMatrixReduce", + "Type": "Bit", + "Values": + { + "Row": 0, + "Column": 1, + "CooperativeMatrixReduce2x2": 2 + } + }, + { + "Name": "TensorClampMode", + "Type": "Value", + "Values": + { + "Undefined": 0, + "Constant": 1, + "ClampToEdge": 2, + "Repeat": 3, + "RepeatMirrored": 4 + } + }, + { + "Name": "TensorAddressingOperands", + "Type": "Bit", + "Values": + { + "TensorView": 0, + "DecodeFunc": 1 + } + }, + { + "Name": "InitializationModeQualifier", + "Type": "Value", + "Values": + { + "InitOnDeviceReprogramINTEL": 0, + "InitOnDeviceResetINTEL": 1 + } + }, + { + "Name": "HostAccessQualifier", + "Type": "Value", + "Values": + { + "NoneINTEL": 0, + "ReadINTEL": 1, + "WriteINTEL": 2, + "ReadWriteINTEL": 3 + } + }, + { + "Name": "LoadCacheControl", + "Type": "Value", + "Values": + { + "UncachedINTEL": 0, + "CachedINTEL": 1, + "StreamingINTEL": 2, + "InvalidateAfterReadINTEL": 3, + "ConstCachedINTEL": 4 + } + }, + { + "Name": "StoreCacheControl", + "Type": "Value", + "Values": + { + "UncachedINTEL": 0, + "WriteThroughINTEL": 1, + "WriteBackINTEL": 2, + "StreamingINTEL": 3 + } + }, + { + "Name": "NamedMaximumNumberOfRegisters", + "Type": "Value", + "Values": + { + "AutoINTEL": 0 + } + }, + { + "Name": "MatrixMultiplyAccumulateOperands", + "Type": "Bit", + "Values": + { + "MatrixASignedComponentsINTEL": 0, + "MatrixBSignedComponentsINTEL": 1, + "MatrixCBFloat16INTEL": 2, + "MatrixResultBFloat16INTEL": 3, + "MatrixAPackedInt8INTEL": 4, + "MatrixBPackedInt8INTEL": 5, + "MatrixAPackedInt4INTEL": 6, + "MatrixBPackedInt4INTEL": 7, + "MatrixATF32INTEL": 8, + "MatrixBTF32INTEL": 9, + "MatrixAPackedFloat16INTEL": 10, + "MatrixBPackedFloat16INTEL": 11, + "MatrixAPackedBFloat16INTEL": 12, + "MatrixBPackedBFloat16INTEL": 13 + } + }, + { + "Name": "RawAccessChainOperands", + "Type": "Bit", + "Values": + { + "RobustnessPerComponentNV": 0, + "RobustnessPerElementNV": 1 + } + }, + { + "Name": "FPEncoding", + "Type": "Value", + "Values": + { + } + }, + { + "Name": "CooperativeVectorMatrixLayout", + "Type": "Value", + "Values": + { + "RowMajorNV": 0, + "ColumnMajorNV": 1, + "InferencingOptimalNV": 2, + "TrainingOptimalNV": 3 + } + }, + { + "Name": "ComponentType", + "Type": "Value", + "Values": + { + "Float16NV": 0, + "Float32NV": 1, + "Float64NV": 2, + "SignedInt8NV": 3, + "SignedInt16NV": 4, + "SignedInt32NV": 5, + "SignedInt64NV": 6, + "UnsignedInt8NV": 7, + "UnsignedInt16NV": 8, + "UnsignedInt32NV": 9, + "UnsignedInt64NV": 10, + "SignedInt8PackedNV": 1000491000, + "UnsignedInt8PackedNV": 1000491001, + "FloatE4M3NV": 1000491002, + "FloatE5M2NV": 1000491003 + } + }, { "Name": "Op", "Type": "Value", @@ -1575,14 +1894,26 @@ "OpPtrEqual": 401, "OpPtrNotEqual": 402, "OpPtrDiff": 403, + "OpColorAttachmentReadEXT": 4160, + "OpDepthAttachmentReadEXT": 4161, + "OpStencilAttachmentReadEXT": 4162, "OpTerminateInvocation": 4416, + "OpTypeUntypedPointerKHR": 4417, + "OpUntypedVariableKHR": 4418, + "OpUntypedAccessChainKHR": 4419, + "OpUntypedInBoundsAccessChainKHR": 4420, "OpSubgroupBallotKHR": 4421, "OpSubgroupFirstInvocationKHR": 4422, + "OpUntypedPtrAccessChainKHR": 4423, + "OpUntypedInBoundsPtrAccessChainKHR": 4424, + "OpUntypedArrayLengthKHR": 4425, + "OpUntypedPrefetchKHR": 4426, "OpSubgroupAllKHR": 4428, "OpSubgroupAnyKHR": 4429, "OpSubgroupAllEqualKHR": 4430, "OpGroupNonUniformRotateKHR": 4431, "OpSubgroupReadInvocationKHR": 4432, + "OpExtInstWithForwardRefsKHR": 4433, "OpTraceRayKHR": 4445, "OpExecuteCallableKHR": 4446, "OpConvertUToAccelerationStructureKHR": 4447, @@ -1600,6 +1931,14 @@ "OpUDotAccSatKHR": 4454, "OpSUDotAccSat": 4455, "OpSUDotAccSatKHR": 4455, + "OpTypeCooperativeMatrixKHR": 4456, + "OpCooperativeMatrixLoadKHR": 4457, + "OpCooperativeMatrixStoreKHR": 4458, + "OpCooperativeMatrixMulAddKHR": 4459, + "OpCooperativeMatrixLengthKHR": 4460, + "OpConstantCompositeReplicateEXT": 4461, + "OpSpecConstantCompositeReplicateEXT": 4462, + "OpCompositeConstructReplicateEXT": 4463, "OpTypeRayQueryKHR": 4472, "OpRayQueryInitializeKHR": 4473, "OpRayQueryTerminateKHR": 4474, @@ -1607,6 +1946,14 @@ "OpRayQueryConfirmIntersectionKHR": 4476, "OpRayQueryProceedKHR": 4477, "OpRayQueryGetIntersectionTypeKHR": 4479, + "OpImageSampleWeightedQCOM": 4480, + "OpImageBoxFilterQCOM": 4481, + "OpImageBlockMatchSSDQCOM": 4482, + "OpImageBlockMatchSADQCOM": 4483, + "OpImageBlockMatchWindowSSDQCOM": 4500, + "OpImageBlockMatchWindowSADQCOM": 4501, + "OpImageBlockMatchGatherSSDQCOM": 4502, + "OpImageBlockMatchGatherSADQCOM": 4503, "OpGroupIAddNonUniformAMD": 5000, "OpGroupFAddNonUniformAMD": 5001, "OpGroupFMinNonUniformAMD": 5002, @@ -1618,6 +1965,16 @@ "OpFragmentMaskFetchAMD": 5011, "OpFragmentFetchAMD": 5012, "OpReadClockKHR": 5056, + "OpAllocateNodePayloadsAMDX": 5074, + "OpEnqueueNodePayloadsAMDX": 5075, + "OpTypeNodePayloadArrayAMDX": 5076, + "OpFinishWritingNodePayloadAMDX": 5078, + "OpNodePayloadArrayLengthAMDX": 5090, + "OpIsNodePayloadValidAMDX": 5101, + "OpConstantStringAMDX": 5103, + "OpSpecConstantStringAMDX": 5104, + "OpGroupNonUniformQuadAllKHR": 5110, + "OpGroupNonUniformQuadAnyKHR": 5111, "OpHitObjectRecordHitMotionNV": 5249, "OpHitObjectRecordHitWithIndexMotionNV": 5250, "OpHitObjectRecordMissMotionNV": 5251, @@ -1652,10 +2009,20 @@ "OpReorderThreadWithHintNV": 5280, "OpTypeHitObjectNV": 5281, "OpImageSampleFootprintNV": 5283, + "OpTypeCooperativeVectorNV": 5288, + "OpCooperativeVectorMatrixMulNV": 5289, + "OpCooperativeVectorOuterProductAccumulateNV": 5290, + "OpCooperativeVectorReduceSumAccumulateNV": 5291, + "OpCooperativeVectorMatrixMulAddNV": 5292, + "OpCooperativeMatrixConvertNV": 5293, "OpEmitMeshTasksEXT": 5294, "OpSetMeshOutputsEXT": 5295, "OpGroupNonUniformPartitionNV": 5296, "OpWritePackedPrimitiveIndices4x8NV": 5299, + "OpFetchMicroTriangleVertexPositionNV": 5300, + "OpFetchMicroTriangleVertexBarycentricNV": 5301, + "OpCooperativeVectorLoadNV": 5302, + "OpCooperativeVectorStoreNV": 5303, "OpReportIntersectionKHR": 5334, "OpReportIntersectionNV": 5334, "OpIgnoreIntersectionNV": 5335, @@ -1663,9 +2030,12 @@ "OpTraceNV": 5337, "OpTraceMotionNV": 5338, "OpTraceRayMotionNV": 5339, + "OpRayQueryGetIntersectionTriangleVertexPositionsKHR": 5340, "OpTypeAccelerationStructureKHR": 5341, "OpTypeAccelerationStructureNV": 5341, "OpExecuteCallableNV": 5344, + "OpRayQueryGetClusterIdNV": 5345, + "OpHitObjectGetClusterIdNV": 5346, "OpTypeCooperativeMatrixNV": 5358, "OpCooperativeMatrixLoadNV": 5359, "OpCooperativeMatrixStoreNV": 5360, @@ -1673,9 +2043,26 @@ "OpCooperativeMatrixLengthNV": 5362, "OpBeginInvocationInterlockEXT": 5364, "OpEndInvocationInterlockEXT": 5365, + "OpCooperativeMatrixReduceNV": 5366, + "OpCooperativeMatrixLoadTensorNV": 5367, + "OpCooperativeMatrixStoreTensorNV": 5368, + "OpCooperativeMatrixPerElementOpNV": 5369, + "OpTypeTensorLayoutNV": 5370, + "OpTypeTensorViewNV": 5371, + "OpCreateTensorLayoutNV": 5372, + "OpTensorLayoutSetDimensionNV": 5373, + "OpTensorLayoutSetStrideNV": 5374, + "OpTensorLayoutSliceNV": 5375, + "OpTensorLayoutSetClampValueNV": 5376, + "OpCreateTensorViewNV": 5377, + "OpTensorViewSetDimensionNV": 5378, + "OpTensorViewSetStrideNV": 5379, "OpDemoteToHelperInvocation": 5380, "OpDemoteToHelperInvocationEXT": 5380, "OpIsHelperInvocationEXT": 5381, + "OpTensorViewSetClipNV": 5382, + "OpTensorLayoutSetBlockSizeNV": 5384, + "OpCooperativeMatrixTransposeNV": 5390, "OpConvertUToImageNV": 5391, "OpConvertUToSamplerNV": 5392, "OpConvertImageToUNV": 5393, @@ -1683,6 +2070,20 @@ "OpConvertUToSampledImageNV": 5395, "OpConvertSampledImageToUNV": 5396, "OpSamplerImageAddressingModeNV": 5397, + "OpRawAccessChainNV": 5398, + "OpRayQueryGetIntersectionSpherePositionNV": 5427, + "OpRayQueryGetIntersectionSphereRadiusNV": 5428, + "OpRayQueryGetIntersectionLSSPositionsNV": 5429, + "OpRayQueryGetIntersectionLSSRadiiNV": 5430, + "OpRayQueryGetIntersectionLSSHitValueNV": 5431, + "OpHitObjectGetSpherePositionNV": 5432, + "OpHitObjectGetSphereRadiusNV": 5433, + "OpHitObjectGetLSSPositionsNV": 5434, + "OpHitObjectGetLSSRadiiNV": 5435, + "OpHitObjectIsSphereHitNV": 5436, + "OpHitObjectIsLSSHitNV": 5437, + "OpRayQueryIsSphereHitNV": 5438, + "OpRayQueryIsLSSHitNV": 5439, "OpSubgroupShuffleINTEL": 5571, "OpSubgroupShuffleDownINTEL": 5572, "OpSubgroupShuffleUpINTEL": 5573, @@ -1924,8 +2325,19 @@ "OpTypeStructContinuedINTEL": 6090, "OpConstantCompositeContinuedINTEL": 6091, "OpSpecConstantCompositeContinuedINTEL": 6092, + "OpCompositeConstructContinuedINTEL": 6096, + "OpConvertFToBF16INTEL": 6116, + "OpConvertBF16ToFINTEL": 6117, "OpControlBarrierArriveINTEL": 6142, "OpControlBarrierWaitINTEL": 6143, + "OpArithmeticFenceEXT": 6145, + "OpSubgroupBlockPrefetchINTEL": 6221, + "OpSubgroup2DBlockLoadINTEL": 6231, + "OpSubgroup2DBlockLoadTransformINTEL": 6232, + "OpSubgroup2DBlockLoadTransposeINTEL": 6233, + "OpSubgroup2DBlockPrefetchINTEL": 6234, + "OpSubgroup2DBlockStoreINTEL": 6235, + "OpSubgroupMatrixMultiplyAccumulateINTEL": 6237, "OpGroupIMulKHR": 6401, "OpGroupFMulKHR": 6402, "OpGroupBitwiseAndKHR": 6403, @@ -1933,7 +2345,9 @@ "OpGroupBitwiseXorKHR": 6405, "OpGroupLogicalAndKHR": 6406, "OpGroupLogicalOrKHR": 6407, - "OpGroupLogicalXorKHR": 6408 + "OpGroupLogicalXorKHR": 6408, + "OpMaskedGatherINTEL": 6428, + "OpMaskedScatterINTEL": 6429 } } ] diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.lua b/third_party/spirv-headers/include/spirv/unified1/spirv.lua index a755d04939..a0f4e8a362 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.lua +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2014-2020 The Khronos Group Inc. +-- Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -60,6 +60,13 @@ spv = { HLSL = 5, CPP_for_OpenCL = 6, SYCL = 7, + HERO_C = 8, + NZSL = 9, + WGSL = 10, + Slang = 11, + Zig = 12, + Rust = 13, + Max = 0x7fffffff, }, ExecutionModel = { @@ -86,6 +93,7 @@ spv = { CallableNV = 5318, TaskEXT = 5364, MeshEXT = 5365, + Max = 0x7fffffff, }, AddressingModel = { @@ -94,6 +102,7 @@ spv = { Physical64 = 2, PhysicalStorageBuffer64 = 5348, PhysicalStorageBuffer64EXT = 5348, + Max = 0x7fffffff, }, MemoryModel = { @@ -102,6 +111,7 @@ spv = { OpenCL = 2, Vulkan = 3, VulkanKHR = 3, + Max = 0x7fffffff, }, ExecutionMode = { @@ -143,6 +153,9 @@ spv = { SubgroupsPerWorkgroupId = 37, LocalSizeId = 38, LocalSizeHintId = 39, + NonCoherentColorAttachmentReadEXT = 4169, + NonCoherentDepthAttachmentReadEXT = 4170, + NonCoherentStencilAttachmentReadEXT = 4171, SubgroupUniformControlFlowKHR = 4421, PostDepthCoverage = 4446, DenormPreserve = 4459, @@ -152,17 +165,28 @@ spv = { RoundingModeRTZ = 4463, EarlyAndLateFragmentTestsAMD = 5017, StencilRefReplacingEXT = 5027, + CoalescingAMDX = 5069, + IsApiEntryAMDX = 5070, + MaxNodeRecursionAMDX = 5071, + StaticNumWorkgroupsAMDX = 5072, + ShaderIndexAMDX = 5073, + MaxNumWorkgroupsAMDX = 5077, StencilRefUnchangedFrontAMD = 5079, StencilRefGreaterFrontAMD = 5080, StencilRefLessFrontAMD = 5081, StencilRefUnchangedBackAMD = 5082, StencilRefGreaterBackAMD = 5083, StencilRefLessBackAMD = 5084, + QuadDerivativesKHR = 5088, + RequireFullQuadsKHR = 5089, + SharesInputWithAMDX = 5102, OutputLinesEXT = 5269, OutputLinesNV = 5269, OutputPrimitivesEXT = 5270, OutputPrimitivesNV = 5270, + DerivativeGroupQuadsKHR = 5289, DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearKHR = 5290, DerivativeGroupLinearNV = 5290, OutputTrianglesEXT = 5298, OutputTrianglesNV = 5298, @@ -182,8 +206,15 @@ spv = { NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + MaximallyReconvergesKHR = 6023, + FPFastMathDefault = 6028, StreamingInterfaceINTEL = 6154, + RegisterMapInterfaceINTEL = 6160, NamedBarrierCountINTEL = 6417, + MaximumRegistersINTEL = 6461, + MaximumRegistersIdINTEL = 6462, + NamedMaximumRegistersINTEL = 6463, + Max = 0x7fffffff, }, StorageClass = { @@ -200,6 +231,8 @@ spv = { AtomicCounter = 10, Image = 11, StorageBuffer = 12, + TileImageEXT = 4172, + NodePayloadAMDX = 5068, CallableDataKHR = 5328, CallableDataNV = 5328, IncomingCallableDataKHR = 5329, @@ -219,6 +252,7 @@ spv = { CodeSectionINTEL = 5605, DeviceOnlyINTEL = 5936, HostOnlyINTEL = 5937, + Max = 0x7fffffff, }, Dim = { @@ -229,6 +263,8 @@ spv = { Rect = 4, Buffer = 5, SubpassData = 6, + TileImageDataEXT = 4173, + Max = 0x7fffffff, }, SamplerAddressingMode = { @@ -237,11 +273,13 @@ spv = { Clamp = 2, Repeat = 3, RepeatMirrored = 4, + Max = 0x7fffffff, }, SamplerFilterMode = { Nearest = 0, Linear = 1, + Max = 0x7fffffff, }, ImageFormat = { @@ -287,6 +325,7 @@ spv = { R8ui = 39, R64ui = 40, R64i = 41, + Max = 0x7fffffff, }, ImageChannelOrder = { @@ -310,6 +349,7 @@ spv = { sRGBA = 17, sBGRA = 18, ABGR = 19, + Max = 0x7fffffff, }, ImageChannelDataType = { @@ -330,6 +370,10 @@ spv = { Float = 14, UnormInt24 = 15, UnormInt101010_2 = 16, + UnsignedIntRaw10EXT = 19, + UnsignedIntRaw12EXT = 20, + UnormInt2_101010EXT = 21, + Max = 0x7fffffff, }, ImageOperandsShift = { @@ -353,6 +397,7 @@ spv = { ZeroExtend = 13, Nontemporal = 14, Offsets = 16, + Max = 0x7fffffff, }, ImageOperandsMask = { @@ -385,8 +430,12 @@ spv = { NSZ = 2, AllowRecip = 3, Fast = 4, + AllowContract = 16, AllowContractFastINTEL = 16, + AllowReassoc = 17, AllowReassocINTEL = 17, + AllowTransform = 18, + Max = 0x7fffffff, }, FPFastMathModeMask = { @@ -396,8 +445,11 @@ spv = { NSZ = 0x00000004, AllowRecip = 0x00000008, Fast = 0x00000010, + AllowContract = 0x00010000, AllowContractFastINTEL = 0x00010000, + AllowReassoc = 0x00020000, AllowReassocINTEL = 0x00020000, + AllowTransform = 0x00040000, }, FPRoundingMode = { @@ -405,18 +457,21 @@ spv = { RTZ = 1, RTP = 2, RTN = 3, + Max = 0x7fffffff, }, LinkageType = { Export = 0, Import = 1, LinkOnceODR = 2, + Max = 0x7fffffff, }, AccessQualifier = { ReadOnly = 0, WriteOnly = 1, ReadWrite = 2, + Max = 0x7fffffff, }, FunctionParameterAttribute = { @@ -429,6 +484,7 @@ spv = { NoWrite = 6, NoReadWrite = 7, RuntimeAlignedINTEL = 5940, + Max = 0x7fffffff, }, Decoration = { @@ -481,7 +537,18 @@ spv = { MaxByteOffsetId = 47, NoSignedWrap = 4469, NoUnsignedWrap = 4470, + WeightTextureQCOM = 4487, + BlockMatchTextureQCOM = 4488, + BlockMatchSamplerQCOM = 4499, ExplicitInterpAMD = 4999, + NodeSharesPayloadLimitsWithAMDX = 5019, + NodeMaxPayloadsAMDX = 5020, + TrackFinishWritingAMDX = 5078, + PayloadNodeNameAMDX = 5091, + PayloadNodeBaseIndexAMDX = 5098, + PayloadNodeSparseArrayAMDX = 5099, + PayloadNodeArraySizeAMDX = 5100, + PayloadDispatchIndirectAMDX = 5105, OverrideCoverageNV = 5248, PassthroughNV = 5250, ViewportRelativeNV = 5252, @@ -531,6 +598,9 @@ spv = { MergeINTEL = 5834, BankBitsINTEL = 5835, ForcePow2DepthINTEL = 5836, + StridesizeINTEL = 5883, + WordsizeINTEL = 5884, + TrueDualPortINTEL = 5885, BurstCoalesceINTEL = 5899, CacheSizeINTEL = 5900, DontStaticallyCoalesceINTEL = 5901, @@ -549,6 +619,25 @@ spv = { SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, MediaBlockIOINTEL = 6140, + StallFreeINTEL = 6151, + FPMaxErrorDecorationINTEL = 6170, + LatencyControlLabelINTEL = 6172, + LatencyControlConstraintINTEL = 6173, + ConduitKernelArgumentINTEL = 6175, + RegisterMapKernelArgumentINTEL = 6176, + MMHostInterfaceAddressWidthINTEL = 6177, + MMHostInterfaceDataWidthINTEL = 6178, + MMHostInterfaceLatencyINTEL = 6179, + MMHostInterfaceReadWriteModeINTEL = 6180, + MMHostInterfaceMaxBurstINTEL = 6181, + MMHostInterfaceWaitRequestINTEL = 6182, + StableKernelArgumentINTEL = 6183, + HostAccessINTEL = 6188, + InitModeINTEL = 6190, + ImplementInRegisterMapINTEL = 6191, + CacheControlLoadINTEL = 6442, + CacheControlStoreINTEL = 6443, + Max = 0x7fffffff, }, BuiltIn = { @@ -623,6 +712,8 @@ spv = { BaryCoordSmoothSampleAMD = 4997, BaryCoordPullModelAMD = 4998, FragStencilRefEXT = 5014, + RemainingRecursionLevelsAMDX = 5021, + ShaderIndexAMDX = 5073, ViewportMaskNV = 5253, SecondaryPositionNV = 5257, SecondaryViewportMaskNV = 5258, @@ -675,19 +766,33 @@ spv = { HitKindKHR = 5333, HitKindNV = 5333, CurrentRayTimeNV = 5334, + HitTriangleVertexPositionsKHR = 5335, + HitMicroTriangleVertexPositionsNV = 5337, + HitMicroTriangleVertexBarycentricsNV = 5344, IncomingRayFlagsKHR = 5351, IncomingRayFlagsNV = 5351, RayGeometryIndexKHR = 5352, + HitIsSphereNV = 5359, + HitIsLSSNV = 5360, + HitSpherePositionNV = 5361, WarpsPerSMNV = 5374, SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + HitLSSPositionsNV = 5396, + HitKindFrontFacingMicroTriangleNV = 5405, + HitKindBackFacingMicroTriangleNV = 5406, + HitSphereRadiusNV = 5420, + HitLSSRadiiNV = 5421, + ClusterIDNV = 5436, CullMaskKHR = 6021, + Max = 0x7fffffff, }, SelectionControlShift = { Flatten = 0, DontFlatten = 1, + Max = 0x7fffffff, }, SelectionControlMask = { @@ -716,6 +821,7 @@ spv = { NoFusionINTEL = 23, LoopCountINTEL = 24, MaxReinvocationDelayINTEL = 25, + Max = 0x7fffffff, }, LoopControlMask = { @@ -746,7 +852,9 @@ spv = { DontInline = 1, Pure = 2, Const = 3, + OptNoneEXT = 16, OptNoneINTEL = 16, + Max = 0x7fffffff, }, FunctionControlMask = { @@ -755,6 +863,7 @@ spv = { DontInline = 0x00000002, Pure = 0x00000004, Const = 0x00000008, + OptNoneEXT = 0x00010000, OptNoneINTEL = 0x00010000, }, @@ -776,6 +885,7 @@ spv = { MakeVisible = 14, MakeVisibleKHR = 14, Volatile = 15, + Max = 0x7fffffff, }, MemorySemanticsMask = { @@ -811,6 +921,7 @@ spv = { NonPrivatePointerKHR = 5, AliasScopeINTELMask = 16, NoAliasINTELMask = 17, + Max = 0x7fffffff, }, MemoryAccessMask = { @@ -837,6 +948,7 @@ spv = { QueueFamily = 5, QueueFamilyKHR = 5, ShaderCallKHR = 6, + Max = 0x7fffffff, }, GroupOperation = { @@ -847,16 +959,19 @@ spv = { PartitionedReduceNV = 6, PartitionedInclusiveScanNV = 7, PartitionedExclusiveScanNV = 8, + Max = 0x7fffffff, }, KernelEnqueueFlags = { NoWait = 0, WaitKernel = 1, WaitWorkGroup = 2, + Max = 0x7fffffff, }, KernelProfilingInfoShift = { CmdExecTime = 0, + Max = 0x7fffffff, }, KernelProfilingInfoMask = { @@ -936,6 +1051,10 @@ spv = { ShaderViewportIndex = 70, UniformDecoration = 71, CoreBuiltinsARM = 4165, + TileImageColorReadAccessEXT = 4166, + TileImageDepthReadAccessEXT = 4167, + TileImageStencilReadAccessEXT = 4168, + CooperativeMatrixLayoutsARM = 4201, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -965,8 +1084,13 @@ spv = { RoundingModeRTZ = 4468, RayQueryProvisionalKHR = 4471, RayQueryKHR = 4472, + UntypedPointersKHR = 4473, RayTraversalPrimitiveCullingKHR = 4478, RayTracingKHR = 4479, + TextureSampleWeightedQCOM = 4484, + TextureBoxFilterQCOM = 4485, + TextureBlockMatchQCOM = 4486, + TextureBlockMatch2QCOM = 4498, Float16ImageAMD = 5008, ImageGatherBiasLodAMD = 5009, FragmentMaskAMD = 5010, @@ -974,6 +1098,8 @@ spv = { ImageReadWriteLodAMD = 5015, Int64ImageEXT = 5016, ShaderClockKHR = 5055, + ShaderEnqueueAMDX = 5067, + QuadControlKHR = 5087, SampleMaskOverrideCoverageNV = 5249, GeometryShaderPassthroughNV = 5251, ShaderViewportIndexLayerEXT = 5254, @@ -987,6 +1113,7 @@ spv = { MeshShadingEXT = 5283, FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsKHR = 5288, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, ShadingRateNV = 5291, @@ -1015,6 +1142,7 @@ spv = { UniformTexelBufferArrayNonUniformIndexingEXT = 5311, StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingPositionFetchKHR = 5336, RayTracingNV = 5340, RayTracingMotionBlurNV = 5341, VulkanMemoryModel = 5345, @@ -1023,6 +1151,7 @@ spv = { VulkanMemoryModelDeviceScopeKHR = 5346, PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearKHR = 5350, ComputeDerivativeGroupLinearNV = 5350, RayTracingProvisionalKHR = 5353, CooperativeMatrixNV = 5357, @@ -1032,9 +1161,25 @@ spv = { FragmentShaderPixelInterlockEXT = 5378, DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, + DisplacementMicromapNV = 5380, RayTracingOpacityMicromapEXT = 5381, ShaderInvocationReorderNV = 5383, BindlessTextureNV = 5390, + RayQueryPositionFetchKHR = 5391, + CooperativeVectorNV = 5394, + AtomicFloat16VectorNV = 5404, + RayTracingDisplacementMicromapNV = 5409, + RawAccessChainsNV = 5414, + RayTracingSpheresGeometryNV = 5418, + RayTracingLinearSweptSpheresGeometryNV = 5419, + CooperativeMatrixReductionsNV = 5430, + CooperativeMatrixConversionsNV = 5431, + CooperativeMatrixPerElementOperationsNV = 5432, + CooperativeMatrixTensorAddressingNV = 5433, + CooperativeMatrixBlockLoadsNV = 5434, + CooperativeVectorTrainingNV = 5435, + RayTracingClusterAccelerationStructureNV = 5437, + TensorAddressingNV = 5439, SubgroupShuffleINTEL = 5568, SubgroupBufferBlockIOINTEL = 5569, SubgroupImageBlockIOINTEL = 5570, @@ -1086,16 +1231,38 @@ spv = { DotProduct = 6019, DotProductKHR = 6019, RayCullMaskKHR = 6020, + CooperativeMatrixKHR = 6022, + ReplicatedCompositesEXT = 6024, BitInstructions = 6025, GroupNonUniformRotateKHR = 6026, + FloatControls2 = 6029, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, - LongConstantCompositeINTEL = 6089, + LongCompositesINTEL = 6089, + OptNoneEXT = 6094, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + BFloat16ConversionINTEL = 6115, SplitBarrierINTEL = 6141, + ArithmeticFenceEXT = 6144, + FPGAClusterAttributesV2INTEL = 6150, + FPGAKernelAttributesv2INTEL = 6161, + FPMaxErrorINTEL = 6169, + FPGALatencyControlINTEL = 6171, + FPGAArgumentInterfacesINTEL = 6174, + GlobalVariableHostAccessINTEL = 6187, + GlobalVariableFPGADecorationsINTEL = 6189, + SubgroupBufferPrefetchINTEL = 6220, + Subgroup2DBlockIOINTEL = 6228, + Subgroup2DBlockTransformINTEL = 6229, + Subgroup2DBlockTransposeINTEL = 6230, + SubgroupMatrixMultiplyAccumulateINTEL = 6236, GroupUniformArithmeticKHR = 6400, + MaskedGatherScatterINTEL = 6427, + CacheControlsINTEL = 6441, + RegisterLimitsINTEL = 6460, + Max = 0x7fffffff, }, RayFlagsShift = { @@ -1107,9 +1274,11 @@ spv = { CullFrontFacingTrianglesKHR = 5, CullOpaqueKHR = 6, CullNoOpaqueKHR = 7, + SkipBuiltinPrimitivesNV = 8, SkipTrianglesKHR = 8, SkipAABBsKHR = 9, ForceOpacityMicromap2StateEXT = 10, + Max = 0x7fffffff, }, RayFlagsMask = { @@ -1122,6 +1291,7 @@ spv = { CullFrontFacingTrianglesKHR = 0x00000020, CullOpaqueKHR = 0x00000040, CullNoOpaqueKHR = 0x00000080, + SkipBuiltinPrimitivesNV = 0x00000100, SkipTrianglesKHR = 0x00000100, SkipAABBsKHR = 0x00000200, ForceOpacityMicromap2StateEXT = 0x00000400, @@ -1130,17 +1300,20 @@ spv = { RayQueryIntersection = { RayQueryCandidateIntersectionKHR = 0, RayQueryCommittedIntersectionKHR = 1, + Max = 0x7fffffff, }, RayQueryCommittedIntersectionType = { RayQueryCommittedIntersectionNoneKHR = 0, RayQueryCommittedIntersectionTriangleKHR = 1, RayQueryCommittedIntersectionGeneratedKHR = 2, + Max = 0x7fffffff, }, RayQueryCandidateIntersectionType = { RayQueryCandidateIntersectionTriangleKHR = 0, RayQueryCandidateIntersectionAABBKHR = 1, + Max = 0x7fffffff, }, FragmentShadingRateShift = { @@ -1148,6 +1321,7 @@ spv = { Vertical4Pixels = 1, Horizontal2Pixels = 2, Horizontal4Pixels = 3, + Max = 0x7fffffff, }, FragmentShadingRateMask = { @@ -1161,11 +1335,13 @@ spv = { FPDenormMode = { Preserve = 0, FlushToZero = 1, + Max = 0x7fffffff, }, FPOperationMode = { IEEE = 0, ALT = 1, + Max = 0x7fffffff, }, QuantizationModes = { @@ -1177,6 +1353,7 @@ spv = { RND_MIN_INF = 5, RND_CONV = 6, RND_CONV_ODD = 7, + Max = 0x7fffffff, }, OverflowModes = { @@ -1184,11 +1361,196 @@ spv = { SAT = 1, SAT_ZERO = 2, SAT_SYM = 3, + Max = 0x7fffffff, }, PackedVectorFormat = { PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, + Max = 0x7fffffff, + }, + + CooperativeMatrixOperandsShift = { + MatrixASignedComponentsKHR = 0, + MatrixBSignedComponentsKHR = 1, + MatrixCSignedComponentsKHR = 2, + MatrixResultSignedComponentsKHR = 3, + SaturatingAccumulationKHR = 4, + Max = 0x7fffffff, + }, + + CooperativeMatrixOperandsMask = { + MaskNone = 0, + MatrixASignedComponentsKHR = 0x00000001, + MatrixBSignedComponentsKHR = 0x00000002, + MatrixCSignedComponentsKHR = 0x00000004, + MatrixResultSignedComponentsKHR = 0x00000008, + SaturatingAccumulationKHR = 0x00000010, + }, + + CooperativeMatrixLayout = { + RowMajorKHR = 0, + ColumnMajorKHR = 1, + RowBlockedInterleavedARM = 4202, + ColumnBlockedInterleavedARM = 4203, + Max = 0x7fffffff, + }, + + CooperativeMatrixUse = { + MatrixAKHR = 0, + MatrixBKHR = 1, + MatrixAccumulatorKHR = 2, + Max = 0x7fffffff, + }, + + CooperativeMatrixReduceShift = { + Row = 0, + Column = 1, + CooperativeMatrixReduce2x2 = 2, + Max = 0x7fffffff, + }, + + CooperativeMatrixReduceMask = { + MaskNone = 0, + Row = 0x00000001, + Column = 0x00000002, + CooperativeMatrixReduce2x2 = 0x00000004, + }, + + TensorClampMode = { + Undefined = 0, + Constant = 1, + ClampToEdge = 2, + Repeat = 3, + RepeatMirrored = 4, + Max = 0x7fffffff, + }, + + TensorAddressingOperandsShift = { + TensorView = 0, + DecodeFunc = 1, + Max = 0x7fffffff, + }, + + TensorAddressingOperandsMask = { + MaskNone = 0, + TensorView = 0x00000001, + DecodeFunc = 0x00000002, + }, + + InitializationModeQualifier = { + InitOnDeviceReprogramINTEL = 0, + InitOnDeviceResetINTEL = 1, + Max = 0x7fffffff, + }, + + HostAccessQualifier = { + NoneINTEL = 0, + ReadINTEL = 1, + WriteINTEL = 2, + ReadWriteINTEL = 3, + Max = 0x7fffffff, + }, + + LoadCacheControl = { + UncachedINTEL = 0, + CachedINTEL = 1, + StreamingINTEL = 2, + InvalidateAfterReadINTEL = 3, + ConstCachedINTEL = 4, + Max = 0x7fffffff, + }, + + StoreCacheControl = { + UncachedINTEL = 0, + WriteThroughINTEL = 1, + WriteBackINTEL = 2, + StreamingINTEL = 3, + Max = 0x7fffffff, + }, + + NamedMaximumNumberOfRegisters = { + AutoINTEL = 0, + Max = 0x7fffffff, + }, + + MatrixMultiplyAccumulateOperandsShift = { + MatrixASignedComponentsINTEL = 0, + MatrixBSignedComponentsINTEL = 1, + MatrixCBFloat16INTEL = 2, + MatrixResultBFloat16INTEL = 3, + MatrixAPackedInt8INTEL = 4, + MatrixBPackedInt8INTEL = 5, + MatrixAPackedInt4INTEL = 6, + MatrixBPackedInt4INTEL = 7, + MatrixATF32INTEL = 8, + MatrixBTF32INTEL = 9, + MatrixAPackedFloat16INTEL = 10, + MatrixBPackedFloat16INTEL = 11, + MatrixAPackedBFloat16INTEL = 12, + MatrixBPackedBFloat16INTEL = 13, + Max = 0x7fffffff, + }, + + MatrixMultiplyAccumulateOperandsMask = { + MaskNone = 0, + MatrixASignedComponentsINTEL = 0x00000001, + MatrixBSignedComponentsINTEL = 0x00000002, + MatrixCBFloat16INTEL = 0x00000004, + MatrixResultBFloat16INTEL = 0x00000008, + MatrixAPackedInt8INTEL = 0x00000010, + MatrixBPackedInt8INTEL = 0x00000020, + MatrixAPackedInt4INTEL = 0x00000040, + MatrixBPackedInt4INTEL = 0x00000080, + MatrixATF32INTEL = 0x00000100, + MatrixBTF32INTEL = 0x00000200, + MatrixAPackedFloat16INTEL = 0x00000400, + MatrixBPackedFloat16INTEL = 0x00000800, + MatrixAPackedBFloat16INTEL = 0x00001000, + MatrixBPackedBFloat16INTEL = 0x00002000, + }, + + RawAccessChainOperandsShift = { + RobustnessPerComponentNV = 0, + RobustnessPerElementNV = 1, + Max = 0x7fffffff, + }, + + RawAccessChainOperandsMask = { + MaskNone = 0, + RobustnessPerComponentNV = 0x00000001, + RobustnessPerElementNV = 0x00000002, + }, + + FPEncoding = { + Max = 0x7fffffff, + }, + + CooperativeVectorMatrixLayout = { + RowMajorNV = 0, + ColumnMajorNV = 1, + InferencingOptimalNV = 2, + TrainingOptimalNV = 3, + Max = 0x7fffffff, + }, + + ComponentType = { + Float16NV = 0, + Float32NV = 1, + Float64NV = 2, + SignedInt8NV = 3, + SignedInt16NV = 4, + SignedInt32NV = 5, + SignedInt64NV = 6, + UnsignedInt8NV = 7, + UnsignedInt16NV = 8, + UnsignedInt32NV = 9, + UnsignedInt64NV = 10, + SignedInt8PackedNV = 1000491000, + UnsignedInt8PackedNV = 1000491001, + FloatE4M3NV = 1000491002, + FloatE5M2NV = 1000491003, + Max = 0x7fffffff, }, Op = { @@ -1536,14 +1898,26 @@ spv = { OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1561,6 +1935,14 @@ spv = { OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1568,6 +1950,14 @@ spv = { OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1579,6 +1969,16 @@ spv = { OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1613,10 +2013,20 @@ spv = { OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1624,9 +2034,12 @@ spv = { OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1634,9 +2047,26 @@ spv = { OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1644,6 +2074,20 @@ spv = { OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1885,8 +2329,19 @@ spv = { OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1895,6 +2350,9 @@ spv = { OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, + Max = 0x7fffffff, }, } diff --git a/third_party/spirv-headers/include/spirv/unified1/spirv.py b/third_party/spirv-headers/include/spirv/unified1/spirv.py index 8a8b97930d..a41ddf5fae 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spirv.py +++ b/third_party/spirv-headers/include/spirv/unified1/spirv.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2020 The Khronos Group Inc. +# Copyright (c) 2014-2024 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"), @@ -12,7 +12,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, @@ -60,6 +60,12 @@ spv = { 'HLSL' : 5, 'CPP_for_OpenCL' : 6, 'SYCL' : 7, + 'HERO_C' : 8, + 'NZSL' : 9, + 'WGSL' : 10, + 'Slang' : 11, + 'Zig' : 12, + 'Rust' : 13, }, 'ExecutionModel' : { @@ -143,6 +149,9 @@ spv = { 'SubgroupsPerWorkgroupId' : 37, 'LocalSizeId' : 38, 'LocalSizeHintId' : 39, + 'NonCoherentColorAttachmentReadEXT' : 4169, + 'NonCoherentDepthAttachmentReadEXT' : 4170, + 'NonCoherentStencilAttachmentReadEXT' : 4171, 'SubgroupUniformControlFlowKHR' : 4421, 'PostDepthCoverage' : 4446, 'DenormPreserve' : 4459, @@ -152,17 +161,28 @@ spv = { 'RoundingModeRTZ' : 4463, 'EarlyAndLateFragmentTestsAMD' : 5017, 'StencilRefReplacingEXT' : 5027, + 'CoalescingAMDX' : 5069, + 'IsApiEntryAMDX' : 5070, + 'MaxNodeRecursionAMDX' : 5071, + 'StaticNumWorkgroupsAMDX' : 5072, + 'ShaderIndexAMDX' : 5073, + 'MaxNumWorkgroupsAMDX' : 5077, 'StencilRefUnchangedFrontAMD' : 5079, 'StencilRefGreaterFrontAMD' : 5080, 'StencilRefLessFrontAMD' : 5081, 'StencilRefUnchangedBackAMD' : 5082, 'StencilRefGreaterBackAMD' : 5083, 'StencilRefLessBackAMD' : 5084, + 'QuadDerivativesKHR' : 5088, + 'RequireFullQuadsKHR' : 5089, + 'SharesInputWithAMDX' : 5102, 'OutputLinesEXT' : 5269, 'OutputLinesNV' : 5269, 'OutputPrimitivesEXT' : 5270, 'OutputPrimitivesNV' : 5270, + 'DerivativeGroupQuadsKHR' : 5289, 'DerivativeGroupQuadsNV' : 5289, + 'DerivativeGroupLinearKHR' : 5290, 'DerivativeGroupLinearNV' : 5290, 'OutputTrianglesEXT' : 5298, 'OutputTrianglesNV' : 5298, @@ -182,8 +202,14 @@ spv = { 'NoGlobalOffsetINTEL' : 5895, 'NumSIMDWorkitemsINTEL' : 5896, 'SchedulerTargetFmaxMhzINTEL' : 5903, + 'MaximallyReconvergesKHR' : 6023, + 'FPFastMathDefault' : 6028, 'StreamingInterfaceINTEL' : 6154, + 'RegisterMapInterfaceINTEL' : 6160, 'NamedBarrierCountINTEL' : 6417, + 'MaximumRegistersINTEL' : 6461, + 'MaximumRegistersIdINTEL' : 6462, + 'NamedMaximumRegistersINTEL' : 6463, }, 'StorageClass' : { @@ -200,6 +226,8 @@ spv = { 'AtomicCounter' : 10, 'Image' : 11, 'StorageBuffer' : 12, + 'TileImageEXT' : 4172, + 'NodePayloadAMDX' : 5068, 'CallableDataKHR' : 5328, 'CallableDataNV' : 5328, 'IncomingCallableDataKHR' : 5329, @@ -229,6 +257,7 @@ spv = { 'Rect' : 4, 'Buffer' : 5, 'SubpassData' : 6, + 'TileImageDataEXT' : 4173, }, 'SamplerAddressingMode' : { @@ -330,6 +359,9 @@ spv = { 'Float' : 14, 'UnormInt24' : 15, 'UnormInt101010_2' : 16, + 'UnsignedIntRaw10EXT' : 19, + 'UnsignedIntRaw12EXT' : 20, + 'UnormInt2_101010EXT' : 21, }, 'ImageOperandsShift' : { @@ -385,8 +417,11 @@ spv = { 'NSZ' : 2, 'AllowRecip' : 3, 'Fast' : 4, + 'AllowContract' : 16, 'AllowContractFastINTEL' : 16, + 'AllowReassoc' : 17, 'AllowReassocINTEL' : 17, + 'AllowTransform' : 18, }, 'FPFastMathModeMask' : { @@ -396,8 +431,11 @@ spv = { 'NSZ' : 0x00000004, 'AllowRecip' : 0x00000008, 'Fast' : 0x00000010, + 'AllowContract' : 0x00010000, 'AllowContractFastINTEL' : 0x00010000, + 'AllowReassoc' : 0x00020000, 'AllowReassocINTEL' : 0x00020000, + 'AllowTransform' : 0x00040000, }, 'FPRoundingMode' : { @@ -481,7 +519,18 @@ spv = { 'MaxByteOffsetId' : 47, 'NoSignedWrap' : 4469, 'NoUnsignedWrap' : 4470, + 'WeightTextureQCOM' : 4487, + 'BlockMatchTextureQCOM' : 4488, + 'BlockMatchSamplerQCOM' : 4499, 'ExplicitInterpAMD' : 4999, + 'NodeSharesPayloadLimitsWithAMDX' : 5019, + 'NodeMaxPayloadsAMDX' : 5020, + 'TrackFinishWritingAMDX' : 5078, + 'PayloadNodeNameAMDX' : 5091, + 'PayloadNodeBaseIndexAMDX' : 5098, + 'PayloadNodeSparseArrayAMDX' : 5099, + 'PayloadNodeArraySizeAMDX' : 5100, + 'PayloadDispatchIndirectAMDX' : 5105, 'OverrideCoverageNV' : 5248, 'PassthroughNV' : 5250, 'ViewportRelativeNV' : 5252, @@ -531,6 +580,9 @@ spv = { 'MergeINTEL' : 5834, 'BankBitsINTEL' : 5835, 'ForcePow2DepthINTEL' : 5836, + 'StridesizeINTEL' : 5883, + 'WordsizeINTEL' : 5884, + 'TrueDualPortINTEL' : 5885, 'BurstCoalesceINTEL' : 5899, 'CacheSizeINTEL' : 5900, 'DontStaticallyCoalesceINTEL' : 5901, @@ -549,6 +601,24 @@ spv = { 'SingleElementVectorINTEL' : 6085, 'VectorComputeCallableFunctionINTEL' : 6087, 'MediaBlockIOINTEL' : 6140, + 'StallFreeINTEL' : 6151, + 'FPMaxErrorDecorationINTEL' : 6170, + 'LatencyControlLabelINTEL' : 6172, + 'LatencyControlConstraintINTEL' : 6173, + 'ConduitKernelArgumentINTEL' : 6175, + 'RegisterMapKernelArgumentINTEL' : 6176, + 'MMHostInterfaceAddressWidthINTEL' : 6177, + 'MMHostInterfaceDataWidthINTEL' : 6178, + 'MMHostInterfaceLatencyINTEL' : 6179, + 'MMHostInterfaceReadWriteModeINTEL' : 6180, + 'MMHostInterfaceMaxBurstINTEL' : 6181, + 'MMHostInterfaceWaitRequestINTEL' : 6182, + 'StableKernelArgumentINTEL' : 6183, + 'HostAccessINTEL' : 6188, + 'InitModeINTEL' : 6190, + 'ImplementInRegisterMapINTEL' : 6191, + 'CacheControlLoadINTEL' : 6442, + 'CacheControlStoreINTEL' : 6443, }, 'BuiltIn' : { @@ -623,6 +693,8 @@ spv = { 'BaryCoordSmoothSampleAMD' : 4997, 'BaryCoordPullModelAMD' : 4998, 'FragStencilRefEXT' : 5014, + 'RemainingRecursionLevelsAMDX' : 5021, + 'ShaderIndexAMDX' : 5073, 'ViewportMaskNV' : 5253, 'SecondaryPositionNV' : 5257, 'SecondaryViewportMaskNV' : 5258, @@ -675,13 +747,25 @@ spv = { 'HitKindKHR' : 5333, 'HitKindNV' : 5333, 'CurrentRayTimeNV' : 5334, + 'HitTriangleVertexPositionsKHR' : 5335, + 'HitMicroTriangleVertexPositionsNV' : 5337, + 'HitMicroTriangleVertexBarycentricsNV' : 5344, 'IncomingRayFlagsKHR' : 5351, 'IncomingRayFlagsNV' : 5351, 'RayGeometryIndexKHR' : 5352, + 'HitIsSphereNV' : 5359, + 'HitIsLSSNV' : 5360, + 'HitSpherePositionNV' : 5361, 'WarpsPerSMNV' : 5374, 'SMCountNV' : 5375, 'WarpIDNV' : 5376, 'SMIDNV' : 5377, + 'HitLSSPositionsNV' : 5396, + 'HitKindFrontFacingMicroTriangleNV' : 5405, + 'HitKindBackFacingMicroTriangleNV' : 5406, + 'HitSphereRadiusNV' : 5420, + 'HitLSSRadiiNV' : 5421, + 'ClusterIDNV' : 5436, 'CullMaskKHR' : 6021, }, @@ -746,6 +830,7 @@ spv = { 'DontInline' : 1, 'Pure' : 2, 'Const' : 3, + 'OptNoneEXT' : 16, 'OptNoneINTEL' : 16, }, @@ -755,6 +840,7 @@ spv = { 'DontInline' : 0x00000002, 'Pure' : 0x00000004, 'Const' : 0x00000008, + 'OptNoneEXT' : 0x00010000, 'OptNoneINTEL' : 0x00010000, }, @@ -936,6 +1022,10 @@ spv = { 'ShaderViewportIndex' : 70, 'UniformDecoration' : 71, 'CoreBuiltinsARM' : 4165, + 'TileImageColorReadAccessEXT' : 4166, + 'TileImageDepthReadAccessEXT' : 4167, + 'TileImageStencilReadAccessEXT' : 4168, + 'CooperativeMatrixLayoutsARM' : 4201, 'FragmentShadingRateKHR' : 4422, 'SubgroupBallotKHR' : 4423, 'DrawParameters' : 4427, @@ -965,8 +1055,13 @@ spv = { 'RoundingModeRTZ' : 4468, 'RayQueryProvisionalKHR' : 4471, 'RayQueryKHR' : 4472, + 'UntypedPointersKHR' : 4473, 'RayTraversalPrimitiveCullingKHR' : 4478, 'RayTracingKHR' : 4479, + 'TextureSampleWeightedQCOM' : 4484, + 'TextureBoxFilterQCOM' : 4485, + 'TextureBlockMatchQCOM' : 4486, + 'TextureBlockMatch2QCOM' : 4498, 'Float16ImageAMD' : 5008, 'ImageGatherBiasLodAMD' : 5009, 'FragmentMaskAMD' : 5010, @@ -974,6 +1069,8 @@ spv = { 'ImageReadWriteLodAMD' : 5015, 'Int64ImageEXT' : 5016, 'ShaderClockKHR' : 5055, + 'ShaderEnqueueAMDX' : 5067, + 'QuadControlKHR' : 5087, 'SampleMaskOverrideCoverageNV' : 5249, 'GeometryShaderPassthroughNV' : 5251, 'ShaderViewportIndexLayerEXT' : 5254, @@ -987,6 +1084,7 @@ spv = { 'MeshShadingEXT' : 5283, 'FragmentBarycentricKHR' : 5284, 'FragmentBarycentricNV' : 5284, + 'ComputeDerivativeGroupQuadsKHR' : 5288, 'ComputeDerivativeGroupQuadsNV' : 5288, 'FragmentDensityEXT' : 5291, 'ShadingRateNV' : 5291, @@ -1015,6 +1113,7 @@ spv = { 'UniformTexelBufferArrayNonUniformIndexingEXT' : 5311, 'StorageTexelBufferArrayNonUniformIndexing' : 5312, 'StorageTexelBufferArrayNonUniformIndexingEXT' : 5312, + 'RayTracingPositionFetchKHR' : 5336, 'RayTracingNV' : 5340, 'RayTracingMotionBlurNV' : 5341, 'VulkanMemoryModel' : 5345, @@ -1023,6 +1122,7 @@ spv = { 'VulkanMemoryModelDeviceScopeKHR' : 5346, 'PhysicalStorageBufferAddresses' : 5347, 'PhysicalStorageBufferAddressesEXT' : 5347, + 'ComputeDerivativeGroupLinearKHR' : 5350, 'ComputeDerivativeGroupLinearNV' : 5350, 'RayTracingProvisionalKHR' : 5353, 'CooperativeMatrixNV' : 5357, @@ -1032,9 +1132,25 @@ spv = { 'FragmentShaderPixelInterlockEXT' : 5378, 'DemoteToHelperInvocation' : 5379, 'DemoteToHelperInvocationEXT' : 5379, + 'DisplacementMicromapNV' : 5380, 'RayTracingOpacityMicromapEXT' : 5381, 'ShaderInvocationReorderNV' : 5383, 'BindlessTextureNV' : 5390, + 'RayQueryPositionFetchKHR' : 5391, + 'CooperativeVectorNV' : 5394, + 'AtomicFloat16VectorNV' : 5404, + 'RayTracingDisplacementMicromapNV' : 5409, + 'RawAccessChainsNV' : 5414, + 'RayTracingSpheresGeometryNV' : 5418, + 'RayTracingLinearSweptSpheresGeometryNV' : 5419, + 'CooperativeMatrixReductionsNV' : 5430, + 'CooperativeMatrixConversionsNV' : 5431, + 'CooperativeMatrixPerElementOperationsNV' : 5432, + 'CooperativeMatrixTensorAddressingNV' : 5433, + 'CooperativeMatrixBlockLoadsNV' : 5434, + 'CooperativeVectorTrainingNV' : 5435, + 'RayTracingClusterAccelerationStructureNV' : 5437, + 'TensorAddressingNV' : 5439, 'SubgroupShuffleINTEL' : 5568, 'SubgroupBufferBlockIOINTEL' : 5569, 'SubgroupImageBlockIOINTEL' : 5570, @@ -1086,16 +1202,37 @@ spv = { 'DotProduct' : 6019, 'DotProductKHR' : 6019, 'RayCullMaskKHR' : 6020, + 'CooperativeMatrixKHR' : 6022, + 'ReplicatedCompositesEXT' : 6024, 'BitInstructions' : 6025, 'GroupNonUniformRotateKHR' : 6026, + 'FloatControls2' : 6029, 'AtomicFloat32AddEXT' : 6033, 'AtomicFloat64AddEXT' : 6034, - 'LongConstantCompositeINTEL' : 6089, + 'LongCompositesINTEL' : 6089, + 'OptNoneEXT' : 6094, 'OptNoneINTEL' : 6094, 'AtomicFloat16AddEXT' : 6095, 'DebugInfoModuleINTEL' : 6114, + 'BFloat16ConversionINTEL' : 6115, 'SplitBarrierINTEL' : 6141, + 'ArithmeticFenceEXT' : 6144, + 'FPGAClusterAttributesV2INTEL' : 6150, + 'FPGAKernelAttributesv2INTEL' : 6161, + 'FPMaxErrorINTEL' : 6169, + 'FPGALatencyControlINTEL' : 6171, + 'FPGAArgumentInterfacesINTEL' : 6174, + 'GlobalVariableHostAccessINTEL' : 6187, + 'GlobalVariableFPGADecorationsINTEL' : 6189, + 'SubgroupBufferPrefetchINTEL' : 6220, + 'Subgroup2DBlockIOINTEL' : 6228, + 'Subgroup2DBlockTransformINTEL' : 6229, + 'Subgroup2DBlockTransposeINTEL' : 6230, + 'SubgroupMatrixMultiplyAccumulateINTEL' : 6236, 'GroupUniformArithmeticKHR' : 6400, + 'MaskedGatherScatterINTEL' : 6427, + 'CacheControlsINTEL' : 6441, + 'RegisterLimitsINTEL' : 6460, }, 'RayFlagsShift' : { @@ -1107,6 +1244,7 @@ spv = { 'CullFrontFacingTrianglesKHR' : 5, 'CullOpaqueKHR' : 6, 'CullNoOpaqueKHR' : 7, + 'SkipBuiltinPrimitivesNV' : 8, 'SkipTrianglesKHR' : 8, 'SkipAABBsKHR' : 9, 'ForceOpacityMicromap2StateEXT' : 10, @@ -1122,6 +1260,7 @@ spv = { 'CullFrontFacingTrianglesKHR' : 0x00000020, 'CullOpaqueKHR' : 0x00000040, 'CullNoOpaqueKHR' : 0x00000080, + 'SkipBuiltinPrimitivesNV' : 0x00000100, 'SkipTrianglesKHR' : 0x00000100, 'SkipAABBsKHR' : 0x00000200, 'ForceOpacityMicromap2StateEXT' : 0x00000400, @@ -1191,6 +1330,173 @@ spv = { 'PackedVectorFormat4x8BitKHR' : 0, }, + 'CooperativeMatrixOperandsShift' : { + 'MatrixASignedComponentsKHR' : 0, + 'MatrixBSignedComponentsKHR' : 1, + 'MatrixCSignedComponentsKHR' : 2, + 'MatrixResultSignedComponentsKHR' : 3, + 'SaturatingAccumulationKHR' : 4, + }, + + 'CooperativeMatrixOperandsMask' : { + 'MaskNone' : 0, + 'MatrixASignedComponentsKHR' : 0x00000001, + 'MatrixBSignedComponentsKHR' : 0x00000002, + 'MatrixCSignedComponentsKHR' : 0x00000004, + 'MatrixResultSignedComponentsKHR' : 0x00000008, + 'SaturatingAccumulationKHR' : 0x00000010, + }, + + 'CooperativeMatrixLayout' : { + 'RowMajorKHR' : 0, + 'ColumnMajorKHR' : 1, + 'RowBlockedInterleavedARM' : 4202, + 'ColumnBlockedInterleavedARM' : 4203, + }, + + 'CooperativeMatrixUse' : { + 'MatrixAKHR' : 0, + 'MatrixBKHR' : 1, + 'MatrixAccumulatorKHR' : 2, + }, + + 'CooperativeMatrixReduceShift' : { + 'Row' : 0, + 'Column' : 1, + 'CooperativeMatrixReduce2x2' : 2, + }, + + 'CooperativeMatrixReduceMask' : { + 'MaskNone' : 0, + 'Row' : 0x00000001, + 'Column' : 0x00000002, + 'CooperativeMatrixReduce2x2' : 0x00000004, + }, + + 'TensorClampMode' : { + 'Undefined' : 0, + 'Constant' : 1, + 'ClampToEdge' : 2, + 'Repeat' : 3, + 'RepeatMirrored' : 4, + }, + + 'TensorAddressingOperandsShift' : { + 'TensorView' : 0, + 'DecodeFunc' : 1, + }, + + 'TensorAddressingOperandsMask' : { + 'MaskNone' : 0, + 'TensorView' : 0x00000001, + 'DecodeFunc' : 0x00000002, + }, + + 'InitializationModeQualifier' : { + 'InitOnDeviceReprogramINTEL' : 0, + 'InitOnDeviceResetINTEL' : 1, + }, + + 'HostAccessQualifier' : { + 'NoneINTEL' : 0, + 'ReadINTEL' : 1, + 'WriteINTEL' : 2, + 'ReadWriteINTEL' : 3, + }, + + 'LoadCacheControl' : { + 'UncachedINTEL' : 0, + 'CachedINTEL' : 1, + 'StreamingINTEL' : 2, + 'InvalidateAfterReadINTEL' : 3, + 'ConstCachedINTEL' : 4, + }, + + 'StoreCacheControl' : { + 'UncachedINTEL' : 0, + 'WriteThroughINTEL' : 1, + 'WriteBackINTEL' : 2, + 'StreamingINTEL' : 3, + }, + + 'NamedMaximumNumberOfRegisters' : { + 'AutoINTEL' : 0, + }, + + 'MatrixMultiplyAccumulateOperandsShift' : { + 'MatrixASignedComponentsINTEL' : 0, + 'MatrixBSignedComponentsINTEL' : 1, + 'MatrixCBFloat16INTEL' : 2, + 'MatrixResultBFloat16INTEL' : 3, + 'MatrixAPackedInt8INTEL' : 4, + 'MatrixBPackedInt8INTEL' : 5, + 'MatrixAPackedInt4INTEL' : 6, + 'MatrixBPackedInt4INTEL' : 7, + 'MatrixATF32INTEL' : 8, + 'MatrixBTF32INTEL' : 9, + 'MatrixAPackedFloat16INTEL' : 10, + 'MatrixBPackedFloat16INTEL' : 11, + 'MatrixAPackedBFloat16INTEL' : 12, + 'MatrixBPackedBFloat16INTEL' : 13, + }, + + 'MatrixMultiplyAccumulateOperandsMask' : { + 'MaskNone' : 0, + 'MatrixASignedComponentsINTEL' : 0x00000001, + 'MatrixBSignedComponentsINTEL' : 0x00000002, + 'MatrixCBFloat16INTEL' : 0x00000004, + 'MatrixResultBFloat16INTEL' : 0x00000008, + 'MatrixAPackedInt8INTEL' : 0x00000010, + 'MatrixBPackedInt8INTEL' : 0x00000020, + 'MatrixAPackedInt4INTEL' : 0x00000040, + 'MatrixBPackedInt4INTEL' : 0x00000080, + 'MatrixATF32INTEL' : 0x00000100, + 'MatrixBTF32INTEL' : 0x00000200, + 'MatrixAPackedFloat16INTEL' : 0x00000400, + 'MatrixBPackedFloat16INTEL' : 0x00000800, + 'MatrixAPackedBFloat16INTEL' : 0x00001000, + 'MatrixBPackedBFloat16INTEL' : 0x00002000, + }, + + 'RawAccessChainOperandsShift' : { + 'RobustnessPerComponentNV' : 0, + 'RobustnessPerElementNV' : 1, + }, + + 'RawAccessChainOperandsMask' : { + 'MaskNone' : 0, + 'RobustnessPerComponentNV' : 0x00000001, + 'RobustnessPerElementNV' : 0x00000002, + }, + + 'FPEncoding' : { + }, + + 'CooperativeVectorMatrixLayout' : { + 'RowMajorNV' : 0, + 'ColumnMajorNV' : 1, + 'InferencingOptimalNV' : 2, + 'TrainingOptimalNV' : 3, + }, + + 'ComponentType' : { + 'Float16NV' : 0, + 'Float32NV' : 1, + 'Float64NV' : 2, + 'SignedInt8NV' : 3, + 'SignedInt16NV' : 4, + 'SignedInt32NV' : 5, + 'SignedInt64NV' : 6, + 'UnsignedInt8NV' : 7, + 'UnsignedInt16NV' : 8, + 'UnsignedInt32NV' : 9, + 'UnsignedInt64NV' : 10, + 'SignedInt8PackedNV' : 1000491000, + 'UnsignedInt8PackedNV' : 1000491001, + 'FloatE4M3NV' : 1000491002, + 'FloatE5M2NV' : 1000491003, + }, + 'Op' : { 'OpNop' : 0, 'OpUndef' : 1, @@ -1536,14 +1842,26 @@ spv = { 'OpPtrEqual' : 401, 'OpPtrNotEqual' : 402, 'OpPtrDiff' : 403, + 'OpColorAttachmentReadEXT' : 4160, + 'OpDepthAttachmentReadEXT' : 4161, + 'OpStencilAttachmentReadEXT' : 4162, 'OpTerminateInvocation' : 4416, + 'OpTypeUntypedPointerKHR' : 4417, + 'OpUntypedVariableKHR' : 4418, + 'OpUntypedAccessChainKHR' : 4419, + 'OpUntypedInBoundsAccessChainKHR' : 4420, 'OpSubgroupBallotKHR' : 4421, 'OpSubgroupFirstInvocationKHR' : 4422, + 'OpUntypedPtrAccessChainKHR' : 4423, + 'OpUntypedInBoundsPtrAccessChainKHR' : 4424, + 'OpUntypedArrayLengthKHR' : 4425, + 'OpUntypedPrefetchKHR' : 4426, 'OpSubgroupAllKHR' : 4428, 'OpSubgroupAnyKHR' : 4429, 'OpSubgroupAllEqualKHR' : 4430, 'OpGroupNonUniformRotateKHR' : 4431, 'OpSubgroupReadInvocationKHR' : 4432, + 'OpExtInstWithForwardRefsKHR' : 4433, 'OpTraceRayKHR' : 4445, 'OpExecuteCallableKHR' : 4446, 'OpConvertUToAccelerationStructureKHR' : 4447, @@ -1561,6 +1879,14 @@ spv = { 'OpUDotAccSatKHR' : 4454, 'OpSUDotAccSat' : 4455, 'OpSUDotAccSatKHR' : 4455, + 'OpTypeCooperativeMatrixKHR' : 4456, + 'OpCooperativeMatrixLoadKHR' : 4457, + 'OpCooperativeMatrixStoreKHR' : 4458, + 'OpCooperativeMatrixMulAddKHR' : 4459, + 'OpCooperativeMatrixLengthKHR' : 4460, + 'OpConstantCompositeReplicateEXT' : 4461, + 'OpSpecConstantCompositeReplicateEXT' : 4462, + 'OpCompositeConstructReplicateEXT' : 4463, 'OpTypeRayQueryKHR' : 4472, 'OpRayQueryInitializeKHR' : 4473, 'OpRayQueryTerminateKHR' : 4474, @@ -1568,6 +1894,14 @@ spv = { 'OpRayQueryConfirmIntersectionKHR' : 4476, 'OpRayQueryProceedKHR' : 4477, 'OpRayQueryGetIntersectionTypeKHR' : 4479, + 'OpImageSampleWeightedQCOM' : 4480, + 'OpImageBoxFilterQCOM' : 4481, + 'OpImageBlockMatchSSDQCOM' : 4482, + 'OpImageBlockMatchSADQCOM' : 4483, + 'OpImageBlockMatchWindowSSDQCOM' : 4500, + 'OpImageBlockMatchWindowSADQCOM' : 4501, + 'OpImageBlockMatchGatherSSDQCOM' : 4502, + 'OpImageBlockMatchGatherSADQCOM' : 4503, 'OpGroupIAddNonUniformAMD' : 5000, 'OpGroupFAddNonUniformAMD' : 5001, 'OpGroupFMinNonUniformAMD' : 5002, @@ -1579,6 +1913,16 @@ spv = { 'OpFragmentMaskFetchAMD' : 5011, 'OpFragmentFetchAMD' : 5012, 'OpReadClockKHR' : 5056, + 'OpAllocateNodePayloadsAMDX' : 5074, + 'OpEnqueueNodePayloadsAMDX' : 5075, + 'OpTypeNodePayloadArrayAMDX' : 5076, + 'OpFinishWritingNodePayloadAMDX' : 5078, + 'OpNodePayloadArrayLengthAMDX' : 5090, + 'OpIsNodePayloadValidAMDX' : 5101, + 'OpConstantStringAMDX' : 5103, + 'OpSpecConstantStringAMDX' : 5104, + 'OpGroupNonUniformQuadAllKHR' : 5110, + 'OpGroupNonUniformQuadAnyKHR' : 5111, 'OpHitObjectRecordHitMotionNV' : 5249, 'OpHitObjectRecordHitWithIndexMotionNV' : 5250, 'OpHitObjectRecordMissMotionNV' : 5251, @@ -1613,10 +1957,20 @@ spv = { 'OpReorderThreadWithHintNV' : 5280, 'OpTypeHitObjectNV' : 5281, 'OpImageSampleFootprintNV' : 5283, + 'OpTypeCooperativeVectorNV' : 5288, + 'OpCooperativeVectorMatrixMulNV' : 5289, + 'OpCooperativeVectorOuterProductAccumulateNV' : 5290, + 'OpCooperativeVectorReduceSumAccumulateNV' : 5291, + 'OpCooperativeVectorMatrixMulAddNV' : 5292, + 'OpCooperativeMatrixConvertNV' : 5293, 'OpEmitMeshTasksEXT' : 5294, 'OpSetMeshOutputsEXT' : 5295, 'OpGroupNonUniformPartitionNV' : 5296, 'OpWritePackedPrimitiveIndices4x8NV' : 5299, + 'OpFetchMicroTriangleVertexPositionNV' : 5300, + 'OpFetchMicroTriangleVertexBarycentricNV' : 5301, + 'OpCooperativeVectorLoadNV' : 5302, + 'OpCooperativeVectorStoreNV' : 5303, 'OpReportIntersectionKHR' : 5334, 'OpReportIntersectionNV' : 5334, 'OpIgnoreIntersectionNV' : 5335, @@ -1624,9 +1978,12 @@ spv = { 'OpTraceNV' : 5337, 'OpTraceMotionNV' : 5338, 'OpTraceRayMotionNV' : 5339, + 'OpRayQueryGetIntersectionTriangleVertexPositionsKHR' : 5340, 'OpTypeAccelerationStructureKHR' : 5341, 'OpTypeAccelerationStructureNV' : 5341, 'OpExecuteCallableNV' : 5344, + 'OpRayQueryGetClusterIdNV' : 5345, + 'OpHitObjectGetClusterIdNV' : 5346, 'OpTypeCooperativeMatrixNV' : 5358, 'OpCooperativeMatrixLoadNV' : 5359, 'OpCooperativeMatrixStoreNV' : 5360, @@ -1634,9 +1991,26 @@ spv = { 'OpCooperativeMatrixLengthNV' : 5362, 'OpBeginInvocationInterlockEXT' : 5364, 'OpEndInvocationInterlockEXT' : 5365, + 'OpCooperativeMatrixReduceNV' : 5366, + 'OpCooperativeMatrixLoadTensorNV' : 5367, + 'OpCooperativeMatrixStoreTensorNV' : 5368, + 'OpCooperativeMatrixPerElementOpNV' : 5369, + 'OpTypeTensorLayoutNV' : 5370, + 'OpTypeTensorViewNV' : 5371, + 'OpCreateTensorLayoutNV' : 5372, + 'OpTensorLayoutSetDimensionNV' : 5373, + 'OpTensorLayoutSetStrideNV' : 5374, + 'OpTensorLayoutSliceNV' : 5375, + 'OpTensorLayoutSetClampValueNV' : 5376, + 'OpCreateTensorViewNV' : 5377, + 'OpTensorViewSetDimensionNV' : 5378, + 'OpTensorViewSetStrideNV' : 5379, 'OpDemoteToHelperInvocation' : 5380, 'OpDemoteToHelperInvocationEXT' : 5380, 'OpIsHelperInvocationEXT' : 5381, + 'OpTensorViewSetClipNV' : 5382, + 'OpTensorLayoutSetBlockSizeNV' : 5384, + 'OpCooperativeMatrixTransposeNV' : 5390, 'OpConvertUToImageNV' : 5391, 'OpConvertUToSamplerNV' : 5392, 'OpConvertImageToUNV' : 5393, @@ -1644,6 +2018,20 @@ spv = { 'OpConvertUToSampledImageNV' : 5395, 'OpConvertSampledImageToUNV' : 5396, 'OpSamplerImageAddressingModeNV' : 5397, + 'OpRawAccessChainNV' : 5398, + 'OpRayQueryGetIntersectionSpherePositionNV' : 5427, + 'OpRayQueryGetIntersectionSphereRadiusNV' : 5428, + 'OpRayQueryGetIntersectionLSSPositionsNV' : 5429, + 'OpRayQueryGetIntersectionLSSRadiiNV' : 5430, + 'OpRayQueryGetIntersectionLSSHitValueNV' : 5431, + 'OpHitObjectGetSpherePositionNV' : 5432, + 'OpHitObjectGetSphereRadiusNV' : 5433, + 'OpHitObjectGetLSSPositionsNV' : 5434, + 'OpHitObjectGetLSSRadiiNV' : 5435, + 'OpHitObjectIsSphereHitNV' : 5436, + 'OpHitObjectIsLSSHitNV' : 5437, + 'OpRayQueryIsSphereHitNV' : 5438, + 'OpRayQueryIsLSSHitNV' : 5439, 'OpSubgroupShuffleINTEL' : 5571, 'OpSubgroupShuffleDownINTEL' : 5572, 'OpSubgroupShuffleUpINTEL' : 5573, @@ -1885,8 +2273,19 @@ spv = { 'OpTypeStructContinuedINTEL' : 6090, 'OpConstantCompositeContinuedINTEL' : 6091, 'OpSpecConstantCompositeContinuedINTEL' : 6092, + 'OpCompositeConstructContinuedINTEL' : 6096, + 'OpConvertFToBF16INTEL' : 6116, + 'OpConvertBF16ToFINTEL' : 6117, 'OpControlBarrierArriveINTEL' : 6142, 'OpControlBarrierWaitINTEL' : 6143, + 'OpArithmeticFenceEXT' : 6145, + 'OpSubgroupBlockPrefetchINTEL' : 6221, + 'OpSubgroup2DBlockLoadINTEL' : 6231, + 'OpSubgroup2DBlockLoadTransformINTEL' : 6232, + 'OpSubgroup2DBlockLoadTransposeINTEL' : 6233, + 'OpSubgroup2DBlockPrefetchINTEL' : 6234, + 'OpSubgroup2DBlockStoreINTEL' : 6235, + 'OpSubgroupMatrixMultiplyAccumulateINTEL' : 6237, 'OpGroupIMulKHR' : 6401, 'OpGroupFMulKHR' : 6402, 'OpGroupBitwiseAndKHR' : 6403, @@ -1895,6 +2294,8 @@ spv = { 'OpGroupLogicalAndKHR' : 6406, 'OpGroupLogicalOrKHR' : 6407, 'OpGroupLogicalXorKHR' : 6408, + 'OpMaskedGatherINTEL' : 6428, + 'OpMaskedScatterINTEL' : 6429, }, } diff --git a/third_party/spirv-headers/include/spirv/unified1/spv.d b/third_party/spirv-headers/include/spirv/unified1/spv.d index 7b5f89ff09..dd4033e77e 100644 --- a/third_party/spirv-headers/include/spirv/unified1/spv.d +++ b/third_party/spirv-headers/include/spirv/unified1/spv.d @@ -1,5 +1,5 @@ /+ - + Copyright (c) 2014-2020 The Khronos Group Inc. + + Copyright (c) 2014-2024 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"), @@ -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, @@ -68,6 +68,13 @@ enum SourceLanguage : uint HLSL = 5, CPP_for_OpenCL = 6, SYCL = 7, + HERO_C = 8, + NZSL = 9, + WGSL = 10, + Slang = 11, + Zig = 12, + Rust = 13, + Max = 0x7fffffff, } enum ExecutionModel : uint @@ -95,6 +102,7 @@ enum ExecutionModel : uint CallableNV = 5318, TaskEXT = 5364, MeshEXT = 5365, + Max = 0x7fffffff, } enum AddressingModel : uint @@ -104,6 +112,7 @@ enum AddressingModel : uint Physical64 = 2, PhysicalStorageBuffer64 = 5348, PhysicalStorageBuffer64EXT = 5348, + Max = 0x7fffffff, } enum MemoryModel : uint @@ -113,6 +122,7 @@ enum MemoryModel : uint OpenCL = 2, Vulkan = 3, VulkanKHR = 3, + Max = 0x7fffffff, } enum ExecutionMode : uint @@ -155,6 +165,9 @@ enum ExecutionMode : uint SubgroupsPerWorkgroupId = 37, LocalSizeId = 38, LocalSizeHintId = 39, + NonCoherentColorAttachmentReadEXT = 4169, + NonCoherentDepthAttachmentReadEXT = 4170, + NonCoherentStencilAttachmentReadEXT = 4171, SubgroupUniformControlFlowKHR = 4421, PostDepthCoverage = 4446, DenormPreserve = 4459, @@ -164,17 +177,28 @@ enum ExecutionMode : uint RoundingModeRTZ = 4463, EarlyAndLateFragmentTestsAMD = 5017, StencilRefReplacingEXT = 5027, + CoalescingAMDX = 5069, + IsApiEntryAMDX = 5070, + MaxNodeRecursionAMDX = 5071, + StaticNumWorkgroupsAMDX = 5072, + ShaderIndexAMDX = 5073, + MaxNumWorkgroupsAMDX = 5077, StencilRefUnchangedFrontAMD = 5079, StencilRefGreaterFrontAMD = 5080, StencilRefLessFrontAMD = 5081, StencilRefUnchangedBackAMD = 5082, StencilRefGreaterBackAMD = 5083, StencilRefLessBackAMD = 5084, + QuadDerivativesKHR = 5088, + RequireFullQuadsKHR = 5089, + SharesInputWithAMDX = 5102, OutputLinesEXT = 5269, OutputLinesNV = 5269, OutputPrimitivesEXT = 5270, OutputPrimitivesNV = 5270, + DerivativeGroupQuadsKHR = 5289, DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearKHR = 5290, DerivativeGroupLinearNV = 5290, OutputTrianglesEXT = 5298, OutputTrianglesNV = 5298, @@ -194,8 +218,15 @@ enum ExecutionMode : uint NoGlobalOffsetINTEL = 5895, NumSIMDWorkitemsINTEL = 5896, SchedulerTargetFmaxMhzINTEL = 5903, + MaximallyReconvergesKHR = 6023, + FPFastMathDefault = 6028, StreamingInterfaceINTEL = 6154, + RegisterMapInterfaceINTEL = 6160, NamedBarrierCountINTEL = 6417, + MaximumRegistersINTEL = 6461, + MaximumRegistersIdINTEL = 6462, + NamedMaximumRegistersINTEL = 6463, + Max = 0x7fffffff, } enum StorageClass : uint @@ -213,6 +244,8 @@ enum StorageClass : uint AtomicCounter = 10, Image = 11, StorageBuffer = 12, + TileImageEXT = 4172, + NodePayloadAMDX = 5068, CallableDataKHR = 5328, CallableDataNV = 5328, IncomingCallableDataKHR = 5329, @@ -232,6 +265,7 @@ enum StorageClass : uint CodeSectionINTEL = 5605, DeviceOnlyINTEL = 5936, HostOnlyINTEL = 5937, + Max = 0x7fffffff, } enum Dim : uint @@ -243,6 +277,8 @@ enum Dim : uint Rect = 4, Buffer = 5, SubpassData = 6, + TileImageDataEXT = 4173, + Max = 0x7fffffff, } enum SamplerAddressingMode : uint @@ -252,12 +288,14 @@ enum SamplerAddressingMode : uint Clamp = 2, Repeat = 3, RepeatMirrored = 4, + Max = 0x7fffffff, } enum SamplerFilterMode : uint { Nearest = 0, Linear = 1, + Max = 0x7fffffff, } enum ImageFormat : uint @@ -304,6 +342,7 @@ enum ImageFormat : uint R8ui = 39, R64ui = 40, R64i = 41, + Max = 0x7fffffff, } enum ImageChannelOrder : uint @@ -328,6 +367,7 @@ enum ImageChannelOrder : uint sRGBA = 17, sBGRA = 18, ABGR = 19, + Max = 0x7fffffff, } enum ImageChannelDataType : uint @@ -349,6 +389,10 @@ enum ImageChannelDataType : uint Float = 14, UnormInt24 = 15, UnormInt101010_2 = 16, + UnsignedIntRaw10EXT = 19, + UnsignedIntRaw12EXT = 20, + UnormInt2_101010EXT = 21, + Max = 0x7fffffff, } enum ImageOperandsShift : uint @@ -373,6 +417,7 @@ enum ImageOperandsShift : uint ZeroExtend = 13, Nontemporal = 14, Offsets = 16, + Max = 0x7fffffff, } enum ImageOperandsMask : uint @@ -407,8 +452,12 @@ enum FPFastMathModeShift : uint NSZ = 2, AllowRecip = 3, Fast = 4, + AllowContract = 16, AllowContractFastINTEL = 16, + AllowReassoc = 17, AllowReassocINTEL = 17, + AllowTransform = 18, + Max = 0x7fffffff, } enum FPFastMathModeMask : uint @@ -419,8 +468,11 @@ enum FPFastMathModeMask : uint NSZ = 0x00000004, AllowRecip = 0x00000008, Fast = 0x00000010, + AllowContract = 0x00010000, AllowContractFastINTEL = 0x00010000, + AllowReassoc = 0x00020000, AllowReassocINTEL = 0x00020000, + AllowTransform = 0x00040000, } enum FPRoundingMode : uint @@ -429,6 +481,7 @@ enum FPRoundingMode : uint RTZ = 1, RTP = 2, RTN = 3, + Max = 0x7fffffff, } enum LinkageType : uint @@ -436,6 +489,7 @@ enum LinkageType : uint Export = 0, Import = 1, LinkOnceODR = 2, + Max = 0x7fffffff, } enum AccessQualifier : uint @@ -443,6 +497,7 @@ enum AccessQualifier : uint ReadOnly = 0, WriteOnly = 1, ReadWrite = 2, + Max = 0x7fffffff, } enum FunctionParameterAttribute : uint @@ -456,6 +511,7 @@ enum FunctionParameterAttribute : uint NoWrite = 6, NoReadWrite = 7, RuntimeAlignedINTEL = 5940, + Max = 0x7fffffff, } enum Decoration : uint @@ -509,7 +565,18 @@ enum Decoration : uint MaxByteOffsetId = 47, NoSignedWrap = 4469, NoUnsignedWrap = 4470, + WeightTextureQCOM = 4487, + BlockMatchTextureQCOM = 4488, + BlockMatchSamplerQCOM = 4499, ExplicitInterpAMD = 4999, + NodeSharesPayloadLimitsWithAMDX = 5019, + NodeMaxPayloadsAMDX = 5020, + TrackFinishWritingAMDX = 5078, + PayloadNodeNameAMDX = 5091, + PayloadNodeBaseIndexAMDX = 5098, + PayloadNodeSparseArrayAMDX = 5099, + PayloadNodeArraySizeAMDX = 5100, + PayloadDispatchIndirectAMDX = 5105, OverrideCoverageNV = 5248, PassthroughNV = 5250, ViewportRelativeNV = 5252, @@ -559,6 +626,9 @@ enum Decoration : uint MergeINTEL = 5834, BankBitsINTEL = 5835, ForcePow2DepthINTEL = 5836, + StridesizeINTEL = 5883, + WordsizeINTEL = 5884, + TrueDualPortINTEL = 5885, BurstCoalesceINTEL = 5899, CacheSizeINTEL = 5900, DontStaticallyCoalesceINTEL = 5901, @@ -577,6 +647,25 @@ enum Decoration : uint SingleElementVectorINTEL = 6085, VectorComputeCallableFunctionINTEL = 6087, MediaBlockIOINTEL = 6140, + StallFreeINTEL = 6151, + FPMaxErrorDecorationINTEL = 6170, + LatencyControlLabelINTEL = 6172, + LatencyControlConstraintINTEL = 6173, + ConduitKernelArgumentINTEL = 6175, + RegisterMapKernelArgumentINTEL = 6176, + MMHostInterfaceAddressWidthINTEL = 6177, + MMHostInterfaceDataWidthINTEL = 6178, + MMHostInterfaceLatencyINTEL = 6179, + MMHostInterfaceReadWriteModeINTEL = 6180, + MMHostInterfaceMaxBurstINTEL = 6181, + MMHostInterfaceWaitRequestINTEL = 6182, + StableKernelArgumentINTEL = 6183, + HostAccessINTEL = 6188, + InitModeINTEL = 6190, + ImplementInRegisterMapINTEL = 6191, + CacheControlLoadINTEL = 6442, + CacheControlStoreINTEL = 6443, + Max = 0x7fffffff, } enum BuiltIn : uint @@ -652,6 +741,8 @@ enum BuiltIn : uint BaryCoordSmoothSampleAMD = 4997, BaryCoordPullModelAMD = 4998, FragStencilRefEXT = 5014, + RemainingRecursionLevelsAMDX = 5021, + ShaderIndexAMDX = 5073, ViewportMaskNV = 5253, SecondaryPositionNV = 5257, SecondaryViewportMaskNV = 5258, @@ -704,20 +795,34 @@ enum BuiltIn : uint HitKindKHR = 5333, HitKindNV = 5333, CurrentRayTimeNV = 5334, + HitTriangleVertexPositionsKHR = 5335, + HitMicroTriangleVertexPositionsNV = 5337, + HitMicroTriangleVertexBarycentricsNV = 5344, IncomingRayFlagsKHR = 5351, IncomingRayFlagsNV = 5351, RayGeometryIndexKHR = 5352, + HitIsSphereNV = 5359, + HitIsLSSNV = 5360, + HitSpherePositionNV = 5361, WarpsPerSMNV = 5374, SMCountNV = 5375, WarpIDNV = 5376, SMIDNV = 5377, + HitLSSPositionsNV = 5396, + HitKindFrontFacingMicroTriangleNV = 5405, + HitKindBackFacingMicroTriangleNV = 5406, + HitSphereRadiusNV = 5420, + HitLSSRadiiNV = 5421, + ClusterIDNV = 5436, CullMaskKHR = 6021, + Max = 0x7fffffff, } enum SelectionControlShift : uint { Flatten = 0, DontFlatten = 1, + Max = 0x7fffffff, } enum SelectionControlMask : uint @@ -748,6 +853,7 @@ enum LoopControlShift : uint NoFusionINTEL = 23, LoopCountINTEL = 24, MaxReinvocationDelayINTEL = 25, + Max = 0x7fffffff, } enum LoopControlMask : uint @@ -780,7 +886,9 @@ enum FunctionControlShift : uint DontInline = 1, Pure = 2, Const = 3, + OptNoneEXT = 16, OptNoneINTEL = 16, + Max = 0x7fffffff, } enum FunctionControlMask : uint @@ -790,6 +898,7 @@ enum FunctionControlMask : uint DontInline = 0x00000002, Pure = 0x00000004, Const = 0x00000008, + OptNoneEXT = 0x00010000, OptNoneINTEL = 0x00010000, } @@ -812,6 +921,7 @@ enum MemorySemanticsShift : uint MakeVisible = 14, MakeVisibleKHR = 14, Volatile = 15, + Max = 0x7fffffff, } enum MemorySemanticsMask : uint @@ -849,6 +959,7 @@ enum MemoryAccessShift : uint NonPrivatePointerKHR = 5, AliasScopeINTELMask = 16, NoAliasINTELMask = 17, + Max = 0x7fffffff, } enum MemoryAccessMask : uint @@ -877,6 +988,7 @@ enum Scope : uint QueueFamily = 5, QueueFamilyKHR = 5, ShaderCallKHR = 6, + Max = 0x7fffffff, } enum GroupOperation : uint @@ -888,6 +1000,7 @@ enum GroupOperation : uint PartitionedReduceNV = 6, PartitionedInclusiveScanNV = 7, PartitionedExclusiveScanNV = 8, + Max = 0x7fffffff, } enum KernelEnqueueFlags : uint @@ -895,11 +1008,13 @@ enum KernelEnqueueFlags : uint NoWait = 0, WaitKernel = 1, WaitWorkGroup = 2, + Max = 0x7fffffff, } enum KernelProfilingInfoShift : uint { CmdExecTime = 0, + Max = 0x7fffffff, } enum KernelProfilingInfoMask : uint @@ -981,6 +1096,10 @@ enum Capability : uint ShaderViewportIndex = 70, UniformDecoration = 71, CoreBuiltinsARM = 4165, + TileImageColorReadAccessEXT = 4166, + TileImageDepthReadAccessEXT = 4167, + TileImageStencilReadAccessEXT = 4168, + CooperativeMatrixLayoutsARM = 4201, FragmentShadingRateKHR = 4422, SubgroupBallotKHR = 4423, DrawParameters = 4427, @@ -1010,8 +1129,13 @@ enum Capability : uint RoundingModeRTZ = 4468, RayQueryProvisionalKHR = 4471, RayQueryKHR = 4472, + UntypedPointersKHR = 4473, RayTraversalPrimitiveCullingKHR = 4478, RayTracingKHR = 4479, + TextureSampleWeightedQCOM = 4484, + TextureBoxFilterQCOM = 4485, + TextureBlockMatchQCOM = 4486, + TextureBlockMatch2QCOM = 4498, Float16ImageAMD = 5008, ImageGatherBiasLodAMD = 5009, FragmentMaskAMD = 5010, @@ -1019,6 +1143,8 @@ enum Capability : uint ImageReadWriteLodAMD = 5015, Int64ImageEXT = 5016, ShaderClockKHR = 5055, + ShaderEnqueueAMDX = 5067, + QuadControlKHR = 5087, SampleMaskOverrideCoverageNV = 5249, GeometryShaderPassthroughNV = 5251, ShaderViewportIndexLayerEXT = 5254, @@ -1032,6 +1158,7 @@ enum Capability : uint MeshShadingEXT = 5283, FragmentBarycentricKHR = 5284, FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsKHR = 5288, ComputeDerivativeGroupQuadsNV = 5288, FragmentDensityEXT = 5291, ShadingRateNV = 5291, @@ -1060,6 +1187,7 @@ enum Capability : uint UniformTexelBufferArrayNonUniformIndexingEXT = 5311, StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingPositionFetchKHR = 5336, RayTracingNV = 5340, RayTracingMotionBlurNV = 5341, VulkanMemoryModel = 5345, @@ -1068,6 +1196,7 @@ enum Capability : uint VulkanMemoryModelDeviceScopeKHR = 5346, PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearKHR = 5350, ComputeDerivativeGroupLinearNV = 5350, RayTracingProvisionalKHR = 5353, CooperativeMatrixNV = 5357, @@ -1077,9 +1206,25 @@ enum Capability : uint FragmentShaderPixelInterlockEXT = 5378, DemoteToHelperInvocation = 5379, DemoteToHelperInvocationEXT = 5379, + DisplacementMicromapNV = 5380, RayTracingOpacityMicromapEXT = 5381, ShaderInvocationReorderNV = 5383, BindlessTextureNV = 5390, + RayQueryPositionFetchKHR = 5391, + CooperativeVectorNV = 5394, + AtomicFloat16VectorNV = 5404, + RayTracingDisplacementMicromapNV = 5409, + RawAccessChainsNV = 5414, + RayTracingSpheresGeometryNV = 5418, + RayTracingLinearSweptSpheresGeometryNV = 5419, + CooperativeMatrixReductionsNV = 5430, + CooperativeMatrixConversionsNV = 5431, + CooperativeMatrixPerElementOperationsNV = 5432, + CooperativeMatrixTensorAddressingNV = 5433, + CooperativeMatrixBlockLoadsNV = 5434, + CooperativeVectorTrainingNV = 5435, + RayTracingClusterAccelerationStructureNV = 5437, + TensorAddressingNV = 5439, SubgroupShuffleINTEL = 5568, SubgroupBufferBlockIOINTEL = 5569, SubgroupImageBlockIOINTEL = 5570, @@ -1131,16 +1276,38 @@ enum Capability : uint DotProduct = 6019, DotProductKHR = 6019, RayCullMaskKHR = 6020, + CooperativeMatrixKHR = 6022, + ReplicatedCompositesEXT = 6024, BitInstructions = 6025, GroupNonUniformRotateKHR = 6026, + FloatControls2 = 6029, AtomicFloat32AddEXT = 6033, AtomicFloat64AddEXT = 6034, - LongConstantCompositeINTEL = 6089, + LongCompositesINTEL = 6089, + OptNoneEXT = 6094, OptNoneINTEL = 6094, AtomicFloat16AddEXT = 6095, DebugInfoModuleINTEL = 6114, + BFloat16ConversionINTEL = 6115, SplitBarrierINTEL = 6141, + ArithmeticFenceEXT = 6144, + FPGAClusterAttributesV2INTEL = 6150, + FPGAKernelAttributesv2INTEL = 6161, + FPMaxErrorINTEL = 6169, + FPGALatencyControlINTEL = 6171, + FPGAArgumentInterfacesINTEL = 6174, + GlobalVariableHostAccessINTEL = 6187, + GlobalVariableFPGADecorationsINTEL = 6189, + SubgroupBufferPrefetchINTEL = 6220, + Subgroup2DBlockIOINTEL = 6228, + Subgroup2DBlockTransformINTEL = 6229, + Subgroup2DBlockTransposeINTEL = 6230, + SubgroupMatrixMultiplyAccumulateINTEL = 6236, GroupUniformArithmeticKHR = 6400, + MaskedGatherScatterINTEL = 6427, + CacheControlsINTEL = 6441, + RegisterLimitsINTEL = 6460, + Max = 0x7fffffff, } enum RayFlagsShift : uint @@ -1153,9 +1320,11 @@ enum RayFlagsShift : uint CullFrontFacingTrianglesKHR = 5, CullOpaqueKHR = 6, CullNoOpaqueKHR = 7, + SkipBuiltinPrimitivesNV = 8, SkipTrianglesKHR = 8, SkipAABBsKHR = 9, ForceOpacityMicromap2StateEXT = 10, + Max = 0x7fffffff, } enum RayFlagsMask : uint @@ -1169,6 +1338,7 @@ enum RayFlagsMask : uint CullFrontFacingTrianglesKHR = 0x00000020, CullOpaqueKHR = 0x00000040, CullNoOpaqueKHR = 0x00000080, + SkipBuiltinPrimitivesNV = 0x00000100, SkipTrianglesKHR = 0x00000100, SkipAABBsKHR = 0x00000200, ForceOpacityMicromap2StateEXT = 0x00000400, @@ -1178,6 +1348,7 @@ enum RayQueryIntersection : uint { RayQueryCandidateIntersectionKHR = 0, RayQueryCommittedIntersectionKHR = 1, + Max = 0x7fffffff, } enum RayQueryCommittedIntersectionType : uint @@ -1185,12 +1356,14 @@ enum RayQueryCommittedIntersectionType : uint RayQueryCommittedIntersectionNoneKHR = 0, RayQueryCommittedIntersectionTriangleKHR = 1, RayQueryCommittedIntersectionGeneratedKHR = 2, + Max = 0x7fffffff, } enum RayQueryCandidateIntersectionType : uint { RayQueryCandidateIntersectionTriangleKHR = 0, RayQueryCandidateIntersectionAABBKHR = 1, + Max = 0x7fffffff, } enum FragmentShadingRateShift : uint @@ -1199,6 +1372,7 @@ enum FragmentShadingRateShift : uint Vertical4Pixels = 1, Horizontal2Pixels = 2, Horizontal4Pixels = 3, + Max = 0x7fffffff, } enum FragmentShadingRateMask : uint @@ -1214,12 +1388,14 @@ enum FPDenormMode : uint { Preserve = 0, FlushToZero = 1, + Max = 0x7fffffff, } enum FPOperationMode : uint { IEEE = 0, ALT = 1, + Max = 0x7fffffff, } enum QuantizationModes : uint @@ -1232,6 +1408,7 @@ enum QuantizationModes : uint RND_MIN_INF = 5, RND_CONV = 6, RND_CONV_ODD = 7, + Max = 0x7fffffff, } enum OverflowModes : uint @@ -1240,12 +1417,218 @@ enum OverflowModes : uint SAT = 1, SAT_ZERO = 2, SAT_SYM = 3, + Max = 0x7fffffff, } enum PackedVectorFormat : uint { PackedVectorFormat4x8Bit = 0, PackedVectorFormat4x8BitKHR = 0, + Max = 0x7fffffff, +} + +enum CooperativeMatrixOperandsShift : uint +{ + MatrixASignedComponentsKHR = 0, + MatrixBSignedComponentsKHR = 1, + MatrixCSignedComponentsKHR = 2, + MatrixResultSignedComponentsKHR = 3, + SaturatingAccumulationKHR = 4, + Max = 0x7fffffff, +} + +enum CooperativeMatrixOperandsMask : uint +{ + MaskNone = 0, + MatrixASignedComponentsKHR = 0x00000001, + MatrixBSignedComponentsKHR = 0x00000002, + MatrixCSignedComponentsKHR = 0x00000004, + MatrixResultSignedComponentsKHR = 0x00000008, + SaturatingAccumulationKHR = 0x00000010, +} + +enum CooperativeMatrixLayout : uint +{ + RowMajorKHR = 0, + ColumnMajorKHR = 1, + RowBlockedInterleavedARM = 4202, + ColumnBlockedInterleavedARM = 4203, + Max = 0x7fffffff, +} + +enum CooperativeMatrixUse : uint +{ + MatrixAKHR = 0, + MatrixBKHR = 1, + MatrixAccumulatorKHR = 2, + Max = 0x7fffffff, +} + +enum CooperativeMatrixReduceShift : uint +{ + Row = 0, + Column = 1, + _2x2 = 2, + Max = 0x7fffffff, +} + +enum CooperativeMatrixReduceMask : uint +{ + MaskNone = 0, + Row = 0x00000001, + Column = 0x00000002, + _2x2 = 0x00000004, +} + +enum TensorClampMode : uint +{ + Undefined = 0, + Constant = 1, + ClampToEdge = 2, + Repeat = 3, + RepeatMirrored = 4, + Max = 0x7fffffff, +} + +enum TensorAddressingOperandsShift : uint +{ + TensorView = 0, + DecodeFunc = 1, + Max = 0x7fffffff, +} + +enum TensorAddressingOperandsMask : uint +{ + MaskNone = 0, + TensorView = 0x00000001, + DecodeFunc = 0x00000002, +} + +enum InitializationModeQualifier : uint +{ + InitOnDeviceReprogramINTEL = 0, + InitOnDeviceResetINTEL = 1, + Max = 0x7fffffff, +} + +enum HostAccessQualifier : uint +{ + NoneINTEL = 0, + ReadINTEL = 1, + WriteINTEL = 2, + ReadWriteINTEL = 3, + Max = 0x7fffffff, +} + +enum LoadCacheControl : uint +{ + UncachedINTEL = 0, + CachedINTEL = 1, + StreamingINTEL = 2, + InvalidateAfterReadINTEL = 3, + ConstCachedINTEL = 4, + Max = 0x7fffffff, +} + +enum StoreCacheControl : uint +{ + UncachedINTEL = 0, + WriteThroughINTEL = 1, + WriteBackINTEL = 2, + StreamingINTEL = 3, + Max = 0x7fffffff, +} + +enum NamedMaximumNumberOfRegisters : uint +{ + AutoINTEL = 0, + Max = 0x7fffffff, +} + +enum MatrixMultiplyAccumulateOperandsShift : uint +{ + MatrixASignedComponentsINTEL = 0, + MatrixBSignedComponentsINTEL = 1, + MatrixCBFloat16INTEL = 2, + MatrixResultBFloat16INTEL = 3, + MatrixAPackedInt8INTEL = 4, + MatrixBPackedInt8INTEL = 5, + MatrixAPackedInt4INTEL = 6, + MatrixBPackedInt4INTEL = 7, + MatrixATF32INTEL = 8, + MatrixBTF32INTEL = 9, + MatrixAPackedFloat16INTEL = 10, + MatrixBPackedFloat16INTEL = 11, + MatrixAPackedBFloat16INTEL = 12, + MatrixBPackedBFloat16INTEL = 13, + Max = 0x7fffffff, +} + +enum MatrixMultiplyAccumulateOperandsMask : uint +{ + MaskNone = 0, + MatrixASignedComponentsINTEL = 0x00000001, + MatrixBSignedComponentsINTEL = 0x00000002, + MatrixCBFloat16INTEL = 0x00000004, + MatrixResultBFloat16INTEL = 0x00000008, + MatrixAPackedInt8INTEL = 0x00000010, + MatrixBPackedInt8INTEL = 0x00000020, + MatrixAPackedInt4INTEL = 0x00000040, + MatrixBPackedInt4INTEL = 0x00000080, + MatrixATF32INTEL = 0x00000100, + MatrixBTF32INTEL = 0x00000200, + MatrixAPackedFloat16INTEL = 0x00000400, + MatrixBPackedFloat16INTEL = 0x00000800, + MatrixAPackedBFloat16INTEL = 0x00001000, + MatrixBPackedBFloat16INTEL = 0x00002000, +} + +enum RawAccessChainOperandsShift : uint +{ + RobustnessPerComponentNV = 0, + RobustnessPerElementNV = 1, + Max = 0x7fffffff, +} + +enum RawAccessChainOperandsMask : uint +{ + MaskNone = 0, + RobustnessPerComponentNV = 0x00000001, + RobustnessPerElementNV = 0x00000002, +} + +enum FPEncoding : uint +{ + Max = 0x7fffffff, +} + +enum CooperativeVectorMatrixLayout : uint +{ + RowMajorNV = 0, + ColumnMajorNV = 1, + InferencingOptimalNV = 2, + TrainingOptimalNV = 3, + Max = 0x7fffffff, +} + +enum ComponentType : uint +{ + Float16NV = 0, + Float32NV = 1, + Float64NV = 2, + SignedInt8NV = 3, + SignedInt16NV = 4, + SignedInt32NV = 5, + SignedInt64NV = 6, + UnsignedInt8NV = 7, + UnsignedInt16NV = 8, + UnsignedInt32NV = 9, + UnsignedInt64NV = 10, + SignedInt8PackedNV = 1000491000, + UnsignedInt8PackedNV = 1000491001, + FloatE4M3NV = 1000491002, + FloatE5M2NV = 1000491003, + Max = 0x7fffffff, } enum Op : uint @@ -1594,14 +1977,26 @@ enum Op : uint OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpColorAttachmentReadEXT = 4160, + OpDepthAttachmentReadEXT = 4161, + OpStencilAttachmentReadEXT = 4162, OpTerminateInvocation = 4416, + OpTypeUntypedPointerKHR = 4417, + OpUntypedVariableKHR = 4418, + OpUntypedAccessChainKHR = 4419, + OpUntypedInBoundsAccessChainKHR = 4420, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, + OpUntypedPtrAccessChainKHR = 4423, + OpUntypedInBoundsPtrAccessChainKHR = 4424, + OpUntypedArrayLengthKHR = 4425, + OpUntypedPrefetchKHR = 4426, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -1619,6 +2014,14 @@ enum Op : uint OpUDotAccSatKHR = 4454, OpSUDotAccSat = 4455, OpSUDotAccSatKHR = 4455, + OpTypeCooperativeMatrixKHR = 4456, + OpCooperativeMatrixLoadKHR = 4457, + OpCooperativeMatrixStoreKHR = 4458, + OpCooperativeMatrixMulAddKHR = 4459, + OpCooperativeMatrixLengthKHR = 4460, + OpConstantCompositeReplicateEXT = 4461, + OpSpecConstantCompositeReplicateEXT = 4462, + OpCompositeConstructReplicateEXT = 4463, OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, @@ -1626,6 +2029,14 @@ enum Op : uint OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, + OpImageBlockMatchWindowSSDQCOM = 4500, + OpImageBlockMatchWindowSADQCOM = 4501, + OpImageBlockMatchGatherSSDQCOM = 4502, + OpImageBlockMatchGatherSADQCOM = 4503, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -1637,6 +2048,16 @@ enum Op : uint OpFragmentMaskFetchAMD = 5011, OpFragmentFetchAMD = 5012, OpReadClockKHR = 5056, + OpAllocateNodePayloadsAMDX = 5074, + OpEnqueueNodePayloadsAMDX = 5075, + OpTypeNodePayloadArrayAMDX = 5076, + OpFinishWritingNodePayloadAMDX = 5078, + OpNodePayloadArrayLengthAMDX = 5090, + OpIsNodePayloadValidAMDX = 5101, + OpConstantStringAMDX = 5103, + OpSpecConstantStringAMDX = 5104, + OpGroupNonUniformQuadAllKHR = 5110, + OpGroupNonUniformQuadAnyKHR = 5111, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -1671,10 +2092,20 @@ enum Op : uint OpReorderThreadWithHintNV = 5280, OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, + OpTypeCooperativeVectorNV = 5288, + OpCooperativeVectorMatrixMulNV = 5289, + OpCooperativeVectorOuterProductAccumulateNV = 5290, + OpCooperativeVectorReduceSumAccumulateNV = 5291, + OpCooperativeVectorMatrixMulAddNV = 5292, + OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, + OpFetchMicroTriangleVertexPositionNV = 5300, + OpFetchMicroTriangleVertexBarycentricNV = 5301, + OpCooperativeVectorLoadNV = 5302, + OpCooperativeVectorStoreNV = 5303, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -1682,9 +2113,12 @@ enum Op : uint OpTraceNV = 5337, OpTraceMotionNV = 5338, OpTraceRayMotionNV = 5339, + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, OpExecuteCallableNV = 5344, + OpRayQueryGetClusterIdNV = 5345, + OpHitObjectGetClusterIdNV = 5346, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -1692,9 +2126,26 @@ enum Op : uint OpCooperativeMatrixLengthNV = 5362, OpBeginInvocationInterlockEXT = 5364, OpEndInvocationInterlockEXT = 5365, + OpCooperativeMatrixReduceNV = 5366, + OpCooperativeMatrixLoadTensorNV = 5367, + OpCooperativeMatrixStoreTensorNV = 5368, + OpCooperativeMatrixPerElementOpNV = 5369, + OpTypeTensorLayoutNV = 5370, + OpTypeTensorViewNV = 5371, + OpCreateTensorLayoutNV = 5372, + OpTensorLayoutSetDimensionNV = 5373, + OpTensorLayoutSetStrideNV = 5374, + OpTensorLayoutSliceNV = 5375, + OpTensorLayoutSetClampValueNV = 5376, + OpCreateTensorViewNV = 5377, + OpTensorViewSetDimensionNV = 5378, + OpTensorViewSetStrideNV = 5379, OpDemoteToHelperInvocation = 5380, OpDemoteToHelperInvocationEXT = 5380, OpIsHelperInvocationEXT = 5381, + OpTensorViewSetClipNV = 5382, + OpTensorLayoutSetBlockSizeNV = 5384, + OpCooperativeMatrixTransposeNV = 5390, OpConvertUToImageNV = 5391, OpConvertUToSamplerNV = 5392, OpConvertImageToUNV = 5393, @@ -1702,6 +2153,20 @@ enum Op : uint OpConvertUToSampledImageNV = 5395, OpConvertSampledImageToUNV = 5396, OpSamplerImageAddressingModeNV = 5397, + OpRawAccessChainNV = 5398, + OpRayQueryGetIntersectionSpherePositionNV = 5427, + OpRayQueryGetIntersectionSphereRadiusNV = 5428, + OpRayQueryGetIntersectionLSSPositionsNV = 5429, + OpRayQueryGetIntersectionLSSRadiiNV = 5430, + OpRayQueryGetIntersectionLSSHitValueNV = 5431, + OpHitObjectGetSpherePositionNV = 5432, + OpHitObjectGetSphereRadiusNV = 5433, + OpHitObjectGetLSSPositionsNV = 5434, + OpHitObjectGetLSSRadiiNV = 5435, + OpHitObjectIsSphereHitNV = 5436, + OpHitObjectIsLSSHitNV = 5437, + OpRayQueryIsSphereHitNV = 5438, + OpRayQueryIsLSSHitNV = 5439, OpSubgroupShuffleINTEL = 5571, OpSubgroupShuffleDownINTEL = 5572, OpSubgroupShuffleUpINTEL = 5573, @@ -1943,8 +2408,19 @@ enum Op : uint OpTypeStructContinuedINTEL = 6090, OpConstantCompositeContinuedINTEL = 6091, OpSpecConstantCompositeContinuedINTEL = 6092, + OpCompositeConstructContinuedINTEL = 6096, + OpConvertFToBF16INTEL = 6116, + OpConvertBF16ToFINTEL = 6117, OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, + OpArithmeticFenceEXT = 6145, + OpSubgroupBlockPrefetchINTEL = 6221, + OpSubgroup2DBlockLoadINTEL = 6231, + OpSubgroup2DBlockLoadTransformINTEL = 6232, + OpSubgroup2DBlockLoadTransposeINTEL = 6233, + OpSubgroup2DBlockPrefetchINTEL = 6234, + OpSubgroup2DBlockStoreINTEL = 6235, + OpSubgroupMatrixMultiplyAccumulateINTEL = 6237, OpGroupIMulKHR = 6401, OpGroupFMulKHR = 6402, OpGroupBitwiseAndKHR = 6403, @@ -1953,6 +2429,9 @@ enum Op : uint OpGroupLogicalAndKHR = 6406, OpGroupLogicalOrKHR = 6407, OpGroupLogicalXorKHR = 6408, + OpMaskedGatherINTEL = 6428, + OpMaskedScatterINTEL = 6429, + Max = 0x7fffffff, } diff --git a/third_party/spirv-headers/tests/CMakeLists.txt b/third_party/spirv-headers/tests/CMakeLists.txt new file mode 100644 index 0000000000..88a956c4e7 --- /dev/null +++ b/third_party/spirv-headers/tests/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright (c) 2015-2024 The Khronos Group Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Materials. +# +# MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +# KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +# SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +# https://www.khronos.org/registry/ +# +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +add_executable(spirv_headers_simple_test example.cpp) +target_compile_definitions(spirv_headers_simple_test PRIVATE SPV_ENABLE_UTILITY_CODE) +target_link_libraries(spirv_headers_simple_test PRIVATE SPIRV-Headers::SPIRV-Headers) +add_test(NAME spirv_headers_simple_test COMMAND spirv_headers_simple_test) + +add_executable(spirv_headers_simple_test_cpp11 example11.cpp) +target_compile_definitions(spirv_headers_simple_test_cpp11 PRIVATE SPV_ENABLE_UTILITY_CODE) +target_link_libraries(spirv_headers_simple_test_cpp11 PRIVATE SPIRV-Headers::SPIRV-Headers) +set_target_properties(spirv_headers_simple_test_cpp11 PROPERTIES CXX_STANDARD 11) +add_test(NAME spirv_headers_simple_test_cpp11 COMMAND spirv_headers_simple_test_cpp11) + +add_executable(spirv_headers_simple_test_c example.c) +target_compile_definitions(spirv_headers_simple_test_c PRIVATE SPV_ENABLE_UTILITY_CODE) +target_link_libraries(spirv_headers_simple_test_c PRIVATE SPIRV-Headers::SPIRV-Headers) +set_target_properties(spirv_headers_simple_test_c PROPERTIES C_STANDARD 99 LINKER_LANGUAGE C) +add_test(NAME spirv_headers_simple_test_c COMMAND spirv_headers_simple_test_c) + +if (NOT TARGET SPIRV-Headers) + message(FATAL_ERROR "SPIRV-Headers target not defined!") +endif() + +if (NOT PROJECT_NAME STREQUAL "SPIRV-Headers") + message(FATAL_ERROR "PROJECT_NAME changed!") # Needed for backcompat with SPIRV-Tools. +endif() + +if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) + message(FATAL_ERROR "SPIRV-Headers_SOURCE_DIR not defined!") # Needed for backcompat with SPIRV-Tools. +endif() diff --git a/third_party/spirv-headers/tests/example.c b/third_party/spirv-headers/tests/example.c new file mode 100644 index 0000000000..11e8e815c0 --- /dev/null +++ b/third_party/spirv-headers/tests/example.c @@ -0,0 +1,37 @@ +// Copyright (c) 2016-2024 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +// https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +#include +#include +#include + +const enum GLSLstd450 kSin = GLSLstd450Sin; +const enum OpenCLstd_Entrypoints kNative_cos = OpenCLstd_Native_cos; +const SpvOp kNop = SpvOpNop; + +int main() { + return 0; +} diff --git a/third_party/spirv-headers/example/example.cpp b/third_party/spirv-headers/tests/example.cpp similarity index 94% rename from third_party/spirv-headers/example/example.cpp rename to third_party/spirv-headers/tests/example.cpp index d79b62f225..b506236430 100644 --- a/third_party/spirv-headers/example/example.cpp +++ b/third_party/spirv-headers/tests/example.cpp @@ -1,5 +1,5 @@ -// Copyright (c) 2016 The Khronos Group Inc. -// +// Copyright (c) 2016-2024 The Khronos Group Inc. +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and/or associated documentation files (the // "Materials"), to deal in the Materials without restriction, including @@ -7,15 +7,15 @@ // distribute, sublicense, and/or sell copies of the Materials, and to // permit persons to whom the Materials are furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Materials. -// +// // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS // KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS // SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT // https://www.khronos.org/registry/ -// +// // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -35,3 +35,7 @@ const OpenCLLIB::Entrypoints kNative_cos = OpenCLLIB::Native_cos; const spv::Op kNop = spv::OpNop; } // anonymous namespace + +int main() { + return 0; +} diff --git a/third_party/spirv-headers/tests/example11.cpp b/third_party/spirv-headers/tests/example11.cpp new file mode 100644 index 0000000000..c1f0a797eb --- /dev/null +++ b/third_party/spirv-headers/tests/example11.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2016-2024 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +// https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +#include +#include +#include + +namespace { + +const GLSLstd450 kSin = GLSLstd450Sin; +const OpenCLLIB::Entrypoints kNative_cos = OpenCLLIB::Native_cos; +const spv::Op kNop = spv::Op::OpNop; + +} // anonymous namespace + +int main() { + return 0; +} diff --git a/third_party/spirv-headers/tests/find_package/CMakeLists.txt b/third_party/spirv-headers/tests/find_package/CMakeLists.txt new file mode 100644 index 0000000000..4735db5b64 --- /dev/null +++ b/third_party/spirv-headers/tests/find_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.0) + +project(TEST_FIND_PACKAGE LANGUAGES CXX) + +add_library(find_package_example STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/../example.cpp +) + +find_package(SPIRV-Headers REQUIRED CONFIG) + +if (NOT TARGET SPIRV-Headers::SPIRV-Headers) + message(FATAL_ERROR "SPIRV-Headers::SPIRV-Headers target not defined") +endif() + +target_link_libraries(find_package_example PRIVATE + SPIRV-Headers::SPIRV-Headers +) + +if (NOT DEFINED SPIRV-Headers_VERSION) + message(FATAL_ERROR "SPIRV-Headers_VERSION not provided!") +endif() + +message(STATUS "SPIRV-Headers_VERSION = ${SPIRV-Headers_VERSION}") diff --git a/third_party/spirv-headers/tests/pkg_config/CMakeLists.txt b/third_party/spirv-headers/tests/pkg_config/CMakeLists.txt new file mode 100644 index 0000000000..b2897e288a --- /dev/null +++ b/third_party/spirv-headers/tests/pkg_config/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.14) + +project(TEST_PKGCONFIG LANGUAGES CXX) + +add_library(pkgconfig_example STATIC) + +target_sources(pkgconfig_example PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../example.cpp +) + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(SPIRV_HEADERS REQUIRED IMPORTED_TARGET SPIRV-Headers) + +target_link_libraries(pkgconfig_example PRIVATE + PkgConfig::SPIRV_HEADERS +) + +if (NOT DEFINED SPIRV_HEADERS_VERSION) + message(FATAL_ERROR "SPIRV_HEADERS_VERSION not defined!") +endif() + +message(STATUS "PkgConfig::SPIRV_HEADERS version = ${SPIRV_HEADERS_VERSION}") diff --git a/third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py b/third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py index c56780c1cb..ccd843b947 100755 --- a/third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py +++ b/third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2017-2020 Google LLC +# Copyright (c) 2017-2024 Google LLC # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and/or associated documentation files (the @@ -32,7 +32,7 @@ import json import os.path import re -DEFAULT_COPYRIGHT="""Copyright (c) 2020 The Khronos Group Inc. +DEFAULT_COPYRIGHT="""Copyright (c) 2020-2024 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 diff --git a/third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py b/third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py index 9359747cc9..96ce008f64 100755 --- a/third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py +++ b/third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py @@ -26,3 +26,5 @@ mk_extinst('AMD_shader_explicit_vertex_parameter', 'extinst.spv-amd-shader-expli mk_extinst('AMD_shader_trinary_minmax', 'extinst.spv-amd-shader-trinary-minmax.grammar.json') mk_extinst('NonSemanticDebugPrintf', 'extinst.nonsemantic.debugprintf.grammar.json') mk_extinst('NonSemanticClspvReflection', 'extinst.nonsemantic.clspvreflection.grammar.json') +mk_extinst('NonSemanticDebugBreak', 'extinst.nonsemantic.debugbreak.grammar.json') +mk_extinst('NonSemanticVkspReflection', 'extinst.nonsemantic.vkspreflection.grammar.json') diff --git a/third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders b/third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders index 7b4959ea07..853c46726e 100755 --- a/third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders +++ b/third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -ex + python3 bin/makeExtinstHeaders.py cd ../../include/spirv/unified1 diff --git a/third_party/spirv-headers/tools/buildHeaders/header.cpp b/third_party/spirv-headers/tools/buildHeaders/header.cpp index fbae044514..a5570971b1 100644 --- a/third_party/spirv-headers/tools/buildHeaders/header.cpp +++ b/third_party/spirv-headers/tools/buildHeaders/header.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), @@ -98,7 +98,7 @@ namespace { virtual void printEpilogue(std::ostream&) const { } virtual void printMeta(std::ostream&) const; virtual void printTypes(std::ostream&) const { } - virtual void printHasResultType(std::ostream&) const { }; + virtual void printUtility(std::ostream&) const { }; virtual std::string escapeComment(const std::string& s) const; @@ -119,9 +119,9 @@ namespace { enumStyle_t, bool isLast = false) const { return ""; } - virtual std::string maxEnumFmt(const std::string&, const valpair_t&, - enumStyle_t) const { - return ""; + virtual std::string maxEnumFmt(const std::string& s, const valpair_t& v, + enumStyle_t style) const { + return enumFmt(s, v, style, true); } virtual std::string fmtConstInt(unsigned val, const std::string& name, @@ -169,29 +169,30 @@ namespace { } const std::string TPrinter::DocCopyright = - "Copyright (c) 2014-2020 The Khronos Group Inc.\n" - "\n" - "Permission is hereby granted, free of charge, to any person obtaining a copy\n" - "of this software and/or associated documentation files (the \"Materials\"),\n" - "to deal in the Materials without restriction, including without limitation\n" - "the rights to use, copy, modify, merge, publish, distribute, sublicense,\n" - "and/or sell copies of the Materials, and to permit persons to whom the\n" - "Materials are furnished to do so, subject to the following conditions:\n" - "\n" - "The above copyright notice and this permission notice shall be included in\n" - "all copies or substantial portions of the Materials.\n" - "\n" - "MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS\n" - "STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND\n" - "HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ \n" - "\n" - "THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n" - "OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" - "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" - "THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n" - "FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS\n" - "IN THE MATERIALS.\n"; +R"(Copyright (c) 2014-2024 The Khronos Group Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and/or associated documentation files (the "Materials"), +to deal in the Materials without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Materials, and to permit persons to whom the +Materials are furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Materials. + +MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ + +THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +IN THE MATERIALS. +)"; const std::string TPrinter::DocComment1 = "This header is automatically generated by the same tool that creates\n" @@ -242,6 +243,10 @@ namespace { for (auto& enumRow : enumSet) { std::string name = enumRow.name; enums[e - spv::OperandSource]["Values"][name] = enumRow.value; + // Add aliases + for (auto& alias : enumRow.aliases) { + enums[e - spv::OperandSource]["Values"][alias] = enumRow.value; + } } enums[e - spv::OperandSource]["Type"] = mask ? "Bit" : "Value"; @@ -254,6 +259,10 @@ namespace { for (auto& enumRow : spv::InstructionDesc) { std::string name = enumRow.name; entry["Values"][name] = enumRow.value; + // Add aliases + for (auto& alias : enumRow.aliases) { + entry["Values"][alias] = enumRow.value; + } } entry["Type"] = "Value"; entry["Name"] = "Op"; @@ -368,7 +377,7 @@ namespace { printTypes(out); printMeta(out); printDefs(out); - printHasResultType(out); + printUtility(out); printEpilogue(out); } @@ -463,6 +472,10 @@ namespace { return indent(5) + '"' + prependIfDigit(s, v.second) + "\": " + fmtNum("%d", v.first) + (isLast ? "\n" : ",\n"); } + std::string maxEnumFmt(const std::string& s, const valpair_t& v, + enumStyle_t style) const override { + return ""; + } }; // base for C and C++ @@ -500,10 +513,22 @@ namespace { virtual std::string pre() const { return ""; } // C name prefix virtual std::string headerGuardSuffix() const = 0; - virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const { return pre() + name; } + virtual std::string fmtEnumUse(const std::string &opPrefix, const std::string &opEnum, const std::string &name) const { return pre() + opPrefix + name; } - virtual void printHasResultType(std::ostream& out) const override + void printUtility(std::ostream& out) const override { + out << "#ifdef SPV_ENABLE_UTILITY_CODE" << std::endl; + out << "#ifndef __cplusplus" << std::endl; + out << "#include " << std::endl; + out << "#endif" << std::endl; + + printHasResultType(out); + printStringFunctions(out); + + out << "#endif /* SPV_ENABLE_UTILITY_CODE */" << std::endl << std::endl; + } + + void printHasResultType(std::ostream& out) const { const Json::Value& enums = spvRoot["spv"]["enum"]; std::set seenValues; @@ -514,10 +539,7 @@ namespace { continue; } - out << "#ifdef SPV_ENABLE_UTILITY_CODE" << std::endl; - out << "#ifndef __cplusplus" << std::endl; - out << "#include " << std::endl; - out << "#endif" << std::endl; + out << "inline void " << pre() << "HasResultAndType(" << pre() << opName << " opcode, bool *hasResult, bool *hasResultType) {" << std::endl; out << " *hasResult = *hasResultType = false;" << std::endl; out << " switch (opcode) {" << std::endl; @@ -533,12 +555,50 @@ namespace { seenValues.insert(inst.value); std::string name = inst.name; - out << " case " << fmtEnumUse("Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl; + out << " case " << fmtEnumUse("", "Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl; } out << " }" << std::endl; out << "}" << std::endl; - out << "#endif /* SPV_ENABLE_UTILITY_CODE */" << std::endl << std::endl; + } + } + + void printStringFunctions(std::ostream& out) const { + const Json::Value& enums = spvRoot["spv"]["enum"]; + + for (auto it = enums.begin(); it != enums.end(); ++it) { + const auto type = (*it)["Type"].asString(); + // Skip bitmasks + if (type == "Bit") { + continue; + } + const auto name = (*it)["Name"].asString(); + const auto sorted = getSortedVals((*it)["Values"]); + + std::set seenValues; + std::string fullName = pre() + name; + + out << "inline const char* " << fullName << "ToString(" << fullName << " value) {" << std::endl; + out << " switch (value) {" << std::endl; + for (const auto& v : sorted) { + // Filter out duplicate enum values, which would break the switch statement. + // These are probably just extension enums promoted to core. + if (seenValues.count(v.first)) { + continue; + } + seenValues.insert(v.first); + + out << " " << "case "; + if (name == "Op") { + out << fmtEnumUse("", name, v.second); + } + else + out << fmtEnumUse(name, name, v.second); + out << ": return " << "\"" << v.second << "\";" << std::endl; + } + out << " default: return \"Unknown\";" << std::endl; + out << " }" << std::endl; + out << "}" << std::endl << std::endl; } } }; @@ -563,24 +623,14 @@ namespace { return indent() + pre() + s + v.second + styleStr(style) + " = " + fmtStyleVal(v.first, style) + ",\n"; } - std::string maxEnumFmt(const std::string& s, const valpair_t& v, - enumStyle_t style) const override { - return enumFmt(s, v, style, true); - } - std::string pre() const override { return "Spv"; } // C name prefix std::string headerGuardSuffix() const override { return "H"; } }; // C++ printer class TPrinterCPP : public TPrinterCBase { - private: - void printPrologue(std::ostream& out) const override { - TPrinterCBase::printPrologue(out); - out << "namespace spv {\n\n"; - } - - void printEpilogue(std::ostream& out) const override { + protected: + void printMaskOperators(std::ostream& out, const std::string& specifiers) const { const Json::Value& enums = spvRoot["spv"]["enum"]; out << "// Overload bitwise operators for mask bit combining\n\n"; @@ -593,20 +643,28 @@ namespace { const auto typeName = opName + styleStr(enumMask); // Overload operator| - out << "inline " << typeName << " operator|(" << typeName << " a, " << typeName << " b) { return " << + out << specifiers << " " << typeName << " operator|(" << typeName << " a, " << typeName << " b) { return " << typeName << "(unsigned(a) | unsigned(b)); }\n"; // Overload operator& - out << "inline " << typeName << " operator&(" << typeName << " a, " << typeName << " b) { return " << + out << specifiers << " " << typeName << " operator&(" << typeName << " a, " << typeName << " b) { return " << typeName << "(unsigned(a) & unsigned(b)); }\n"; // Overload operator^ - out << "inline " << typeName << " operator^(" << typeName << " a, " << typeName << " b) { return " << + out << specifiers << " " << typeName << " operator^(" << typeName << " a, " << typeName << " b) { return " << typeName << "(unsigned(a) ^ unsigned(b)); }\n"; // Overload operator~ - out << "inline " << typeName << " operator~(" << typeName << " a) { return " << + out << specifiers << " " << typeName << " operator~(" << typeName << " a) { return " << typeName << "(~unsigned(a)); }\n"; } } + } + private: + void printPrologue(std::ostream& out) const override { + TPrinterCBase::printPrologue(out); + out << "namespace spv {\n\n"; + } + void printEpilogue(std::ostream& out) const override { + printMaskOperators(out, "inline"); out << "\n} // end namespace spv\n\n"; out << "#endif // #ifndef spirv_" << headerGuardSuffix() << std::endl; } @@ -627,11 +685,6 @@ namespace { return indent() + s + v.second + styleStr(style) + " = " + fmtStyleVal(v.first, style) + ",\n"; } - virtual std::string maxEnumFmt(const std::string& s, const valpair_t& v, - enumStyle_t style) const override { - return enumFmt(s, v, style, true); - } - // The C++ and C++11 headers define types with the same name. So they // should use the same header guard. std::string headerGuardSuffix() const override { return "HPP"; } @@ -642,6 +695,11 @@ namespace { // C++11 printer (uses enum classes) class TPrinterCPP11 final : public TPrinterCPP { private: + void printEpilogue(std::ostream& out) const override { + printMaskOperators(out, "constexpr"); + out << "\n} // end namespace spv\n\n"; + out << "#endif // #ifndef spirv_" << headerGuardSuffix() << std::endl; + } std::string enumBeg(const std::string& s, enumStyle_t style) const override { return std::string("enum class ") + s + styleStr(style) + " : unsigned {\n"; } @@ -651,13 +709,8 @@ namespace { return indent() + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n"; } - std::string maxEnumFmt(const std::string& s, const valpair_t& v, - enumStyle_t style) const override { - return enumFmt(s, v, style, true); - } - // Add type prefix for scoped enum - virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const override { return opPrefix + "::" + name; } + std::string fmtEnumUse(const std::string& opPrefix, const std::string& opEnum, const std::string& name) const override { return opEnum + "::" + prependIfDigit(opEnum, name); } std::string headerGuardSuffix() const override { return "HPP"; } }; @@ -712,7 +765,10 @@ namespace { enumStyle_t style, bool isLast) const override { return indent(2) + "'" + prependIfDigit(s, v.second) + "'" + " : " + fmtStyleVal(v.first, style) + ",\n"; } - + std::string maxEnumFmt(const std::string& s, const valpair_t& v, + enumStyle_t style) const override { + return ""; + } std::string fmtConstInt(unsigned val, const std::string& name, const char* fmt, bool isLast) const override { diff --git a/third_party/spirv-headers/tools/buildHeaders/header.h b/third_party/spirv-headers/tools/buildHeaders/header.h index 1dd6e67b2c..6854f80b5d 100644 --- a/third_party/spirv-headers/tools/buildHeaders/header.h +++ b/third_party/spirv-headers/tools/buildHeaders/header.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2019 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), diff --git a/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp index 67b5bce5c0..0249cb3bed 100644 --- a/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp +++ b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp @@ -1,19 +1,19 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. -// +// Copyright (c) 2014-2024 The Khronos Group Inc. +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and/or associated documentation files (the "Materials"), // to deal in the Materials without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Materials, and to permit persons to whom the // Materials are furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Materials. -// +// // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS // STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -// +// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +// // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -24,10 +24,8 @@ #include #include -#include #include #include -#include #include #include #include @@ -36,8 +34,185 @@ #include "jsonToSpirv.h" +namespace { +// Returns true if the given string is a valid SPIR-V version. +bool validSpirvVersionString(const std::string s) { + return + s == "1.0" || + s == "1.1" || + s == "1.2" || + s == "1.3" || + s == "1.4" || + s == "1.5" || + s == "1.6"; +} + +// Returns true if the given string is a valid version +// specifier in the grammar file. +bool validSpirvVersionStringSpecifier(const std::string s) { + return s == "None" || validSpirvVersionString(s); +} +} // anonymous namespace + namespace spv { +bool IsLegacyDoublyEnabledInstruction(const std::string& instruction) { + static std::unordered_set allowed = { + "OpSubgroupBallotKHR", + "OpSubgroupFirstInvocationKHR", + "OpSubgroupAllKHR", + "OpSubgroupAnyKHR", + "OpSubgroupAllEqualKHR", + "OpSubgroupReadInvocationKHR", + "OpTraceRayKHR", + "OpExecuteCallableKHR", + "OpConvertUToAccelerationStructureKHR", + "OpIgnoreIntersectionKHR", + "OpTerminateRayKHR", + "OpTypeRayQueryKHR", + "OpRayQueryInitializeKHR", + "OpRayQueryTerminateKHR", + "OpRayQueryGenerateIntersectionKHR", + "OpRayQueryConfirmIntersectionKHR", + "OpRayQueryProceedKHR", + "OpRayQueryGetIntersectionTypeKHR", + "OpGroupIAddNonUniformAMD", + "OpGroupFAddNonUniformAMD", + "OpGroupFMinNonUniformAMD", + "OpGroupUMinNonUniformAMD", + "OpGroupSMinNonUniformAMD", + "OpGroupFMaxNonUniformAMD", + "OpGroupUMaxNonUniformAMD", + "OpGroupSMaxNonUniformAMD", + "OpFragmentMaskFetchAMD", + "OpFragmentFetchAMD", + "OpImageSampleFootprintNV", + "OpGroupNonUniformPartitionNV", + "OpWritePackedPrimitiveIndices4x8NV", + "OpReportIntersectionNV", + "OpReportIntersectionKHR", + "OpIgnoreIntersectionNV", + "OpTerminateRayNV", + "OpTraceNV", + "OpTraceMotionNV", + "OpTraceRayMotionNV", + "OpTypeAccelerationStructureNV", + "OpTypeAccelerationStructureKHR", + "OpExecuteCallableNV", + "OpTypeCooperativeMatrixNV", + "OpCooperativeMatrixLoadNV", + "OpCooperativeMatrixStoreNV", + "OpCooperativeMatrixMulAddNV", + "OpCooperativeMatrixLengthNV", + "OpBeginInvocationInterlockEXT", + "OpEndInvocationInterlockEXT", + "OpIsHelperInvocationEXT", + "OpConstantFunctionPointerINTEL", + "OpFunctionPointerCallINTEL", + "OpAssumeTrueKHR", + "OpExpectKHR", + "OpLoopControlINTEL", + "OpAliasDomainDeclINTEL", + "OpAliasScopeDeclINTEL", + "OpAliasScopeListDeclINTEL", + "OpReadPipeBlockingINTEL", + "OpWritePipeBlockingINTEL", + "OpFPGARegINTEL", + "OpRayQueryGetRayTMinKHR", + "OpRayQueryGetRayFlagsKHR", + "OpRayQueryGetIntersectionTKHR", + "OpRayQueryGetIntersectionInstanceCustomIndexKHR", + "OpRayQueryGetIntersectionInstanceIdKHR", + "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR", + "OpRayQueryGetIntersectionGeometryIndexKHR", + "OpRayQueryGetIntersectionPrimitiveIndexKHR", + "OpRayQueryGetIntersectionBarycentricsKHR", + "OpRayQueryGetIntersectionFrontFaceKHR", + "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR", + "OpRayQueryGetIntersectionObjectRayDirectionKHR", + "OpRayQueryGetIntersectionObjectRayOriginKHR", + "OpRayQueryGetWorldRayDirectionKHR", + "OpRayQueryGetWorldRayOriginKHR", + "OpRayQueryGetIntersectionObjectToWorldKHR", + "OpRayQueryGetIntersectionWorldToObjectKHR", + "OpAtomicFAddEXT", + }; + return allowed.count(instruction) != 0; +} + +bool EnumValue::IsValid(OperandClass oc, const std::string& context) const +{ + bool result = true; + if (firstVersion.empty()) { + std::cerr << "Error: " << context << " " << name << " \"version\" must be set, probably to \"None\"" << std::endl; + result = false; + } else if (!validSpirvVersionStringSpecifier(firstVersion)) { + std::cerr << "Error: " << context << " " << name << " \"version\" is invalid: " << firstVersion << std::endl; + result = false; + } + if (!lastVersion.empty() && !validSpirvVersionString(lastVersion)) { + std::cerr << "Error: " << context << " " << name << " \"lastVersion\" is invalid: " << lastVersion << std::endl; + result = false; + } + + // When a feature is introduced by an extension, the firstVersion is set to + // "None". There are three cases: + // - A new capability should be guarded/enabled by the extension + // - A new instruction should be: + // - Guarded/enabled by a new capability. + // - Not enabled by *both* a capability and an extension. + // There are many existing instructions that are already like this, + // and we grandparent them as allowed. + // - Other enums fall into two cases: + // 1. The enum is part of a new operand kind introduced by the extension. + // In this case we rely on transitivity: The use of the operand occurs + // in a new instruction that itself is guarded; or as the operand of + // another operand that itself is (recursively) guarded. + // 2. The enum is a new case in an existing operand kind. This case + // should be guarded by a capability. However, we do not check this + // here. Checking it requires more context than we have here. + if (oc == OperandOpcode) { + const bool instruction_unusable = + (firstVersion == "None") && extensions.empty() && capabilities.empty(); + if (instruction_unusable) { + std::cerr << "Error: " << context << " " << name << " is not usable: " + << "its version is set to \"None\", and it is not enabled by a " + << "capability or extension. Guard it with a capability." + << std::endl; + result = false; + } + // Complain if an instruction is not in any core version and also enabled by + // both an extension and a capability. + // It's important to check the "not in any core version" case, because, + // for example, OpTerminateInvocation is in SPIR-V 1.6 *and* enabled by an + // extension, and guarded by the Shader capability. + const bool instruction_doubly_enabled = (firstVersion == "None") && + !extensions.empty() && + !capabilities.empty(); + if (instruction_doubly_enabled && !IsLegacyDoublyEnabledInstruction(name)) { + std::cerr << "Error: " << context << " " << name << " is doubly-enabled: " + << "it is enabled by both a capability and an extension. " + << "Guard it with a capability only." << std::endl; + result = false; + } + } + if (oc == OperandCapability) { + // If capability X lists capabilities Y and Z, then Y and Z are *enabled* + // when X is enabled. They are not *guards* on X's use. + // Only versions and extensions can guard a capability. + const bool capability_unusable = + (firstVersion == "None") && extensions.empty(); + if (capability_unusable) { + std::cerr << "Error: " << context << " " << name << " is not usable: " + << "its version is set to \"None\", and it is not enabled by " + << "an extension. Guard it with an extension." << std::endl; + result = false; + } + } + + return result; +} + // The set of objects that hold all the instruction/operand // parameterization information. InstructionValues InstructionDesc; @@ -88,6 +263,22 @@ EnumValues RayQueryCommittedIntersectionTypeParams; EnumValues RayQueryCandidateIntersectionTypeParams; EnumValues FragmentShadingRateParams; EnumValues PackedVectorFormatParams; +EnumValues CooperativeMatrixOperandsParams; +EnumValues CooperativeMatrixLayoutParams; +EnumValues CooperativeMatrixUseParams; +EnumValues CooperativeMatrixReduceParams; +EnumValues TensorClampModeParams; +EnumValues TensorAddressingOperandsParams; +EnumValues InitializationModeQualifierParams; +EnumValues HostAccessQualifierParams; +EnumValues LoadCacheControlParams; +EnumValues StoreCacheControlParams; +EnumValues NamedMaximumNumberOfRegistersParams; +EnumValues MatrixMultiplyAccumulateOperandsParams; +EnumValues RawAccessChainOperandsParams; +EnumValues FPEncodingParams; +EnumValues CooperativeVectorMatrixLayoutParams; +EnumValues ComponentTypeParams; std::pair ReadFile(const std::string& path) { @@ -158,6 +349,8 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co type = OperandLiteralNumber; } else if (operandKind == "LiteralContextDependentNumber") { type = OperandAnySizeLiteralNumber; + } else if (operandKind == "LiteralFloat") { + type = OperandLiteralNumber; } else if (operandKind == "SourceLanguage") { type = OperandSource; } else if (operandKind == "ExecutionModel") { @@ -234,6 +427,38 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co type = OperandFragmentShadingRate; } else if (operandKind == "PackedVectorFormat") { type = OperandPackedVectorFormat; + } else if (operandKind == "CooperativeMatrixOperands") { + type = OperandCooperativeMatrixOperands; + } else if (operandKind == "TensorAddressingOperands") { + type = OperandTensorAddressingOperands; + } else if (operandKind == "CooperativeMatrixLayout") { + type = OperandCooperativeMatrixLayout; + } else if (operandKind == "CooperativeMatrixUse") { + type = OperandCooperativeMatrixUse; + } else if (operandKind == "CooperativeMatrixReduce") { + type = OperandCooperativeMatrixReduce; + } else if (operandKind == "TensorClampMode") { + type = OperandTensorClampMode; + } else if (operandKind == "InitializationModeQualifier") { + type = OperandInitializationModeQualifier; + } else if (operandKind == "HostAccessQualifier") { + type = OperandHostAccessQualifier; + } else if (operandKind == "LoadCacheControl") { + type = OperandLoadCacheControl; + } else if (operandKind == "StoreCacheControl") { + type = OperandStoreCacheControl; + } else if (operandKind == "NamedMaximumNumberOfRegisters") { + type = OperandNamedMaximumNumberOfRegisters; + } else if (operandKind == "MatrixMultiplyAccumulateOperands") { + type = OperandMatrixMultiplyAccumulateOperands; + } else if (operandKind == "RawAccessChainOperands") { + type = OperandRawAccessChainOperands; + } else if (operandKind == "FPEncoding") { + type = OperandFPEncoding; + } else if (operandKind == "CooperativeVectorMatrixLayout") { + type = OperandCooperativeVectorMatrixLayout; + } else if (operandKind == "ComponentType") { + type = OperandComponentType; } if (type == OperandNone) { @@ -273,6 +498,8 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) return; initialized = true; + size_t errorCount = 0; + // Read the JSON grammar file. bool fileReadOk = false; std::string content; @@ -320,14 +547,28 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) return result; }; + const auto getAliases = [](const Json::Value& object) { + Aliases result; + const auto& aliases = object["aliases"]; + if (!aliases.empty()) { + assert(aliases.isArray()); + for (const auto& alias : aliases) { + result.emplace_back(alias.asString()); + } + } + return result; + }; + // set up the printing classes std::unordered_set tags; // short-lived local for error checking below const Json::Value printingClasses = root["instruction_printing_class"]; for (const auto& printingClass : printingClasses) { if (printingClass["tag"].asString().size() > 0) tags.insert(printingClass["tag"].asString()); // just for error checking - else + else { std::cerr << "Error: each instruction_printing_class requires a non-empty \"tag\"" << std::endl; + std::exit(1); + } if (buildingHeaders || printingClass["tag"].asString() != "@exclude") { InstructionPrintingClasses.push_back({printingClass["tag"].asString(), printingClass["heading"].asString()}); @@ -337,12 +578,15 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) // process the instructions const Json::Value insts = root["instructions"]; unsigned maxOpcode = 0; + std::string maxName = ""; + bool maxCore = false; bool firstOpcode = true; for (const auto& inst : insts) { const auto printingClass = inst["class"].asString(); if (printingClass.size() == 0) { std::cerr << "Error: " << inst["opname"].asString() << " requires a non-empty printing \"class\" tag" << std::endl; + std::exit(1); } if (!buildingHeaders && printingClass == "@exclude") continue; @@ -350,11 +594,15 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) std::cerr << "Error: " << inst["opname"].asString() << " requires a \"class\" declared as a \"tag\" in \"instruction printing_class\"" << std::endl; + std::exit(1); } const auto opcode = inst["opcode"].asUInt(); const std::string name = inst["opname"].asString(); + std::string version = inst["version"].asString(); if (firstOpcode) { maxOpcode = opcode; + maxName = name; + maxCore = version != "None"; firstOpcode = false; } else { if (maxOpcode > opcode) { @@ -362,12 +610,18 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) << " is out of order. It follows the instruction with opcode " << maxOpcode << std::endl; std::exit(1); + } else if (maxOpcode == opcode) { + std::cerr << "Error: " << name << " is an alias of " << maxName + << ". Use \"aliases\" instead." << std::endl; + std::exit(1); } else { maxOpcode = opcode; + maxName = name; + maxCore = version != "None"; } } + Aliases aliases = getAliases(inst); EnumCaps caps = getCaps(inst); - std::string version = inst["version"].asString(); std::string lastVersion = inst["lastVersion"].asString(); Extensions exts = getExts(inst); OperandParameters operands; @@ -383,16 +637,19 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) } } InstructionDesc.emplace_back( - std::move(EnumValue(opcode, name, + std::move(EnumValue(opcode, name, std::move(aliases), std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(operands))), printingClass, defTypeId, defResultId); + if (!InstructionDesc.back().IsValid(OperandOpcode, "instruction")) { + errorCount++; + } } // Specific additional context-dependent operands // Populate dest with EnumValue objects constructed from source. - const auto populateEnumValues = [&getCaps,&getExts](EnumValues* dest, const Json::Value& source, bool bitEnum) { + const auto populateEnumValues = [&getCaps,&getAliases,&getExts,&errorCount](EnumValues* dest, const Json::Value& source, bool bitEnum) { // A lambda for determining the numeric value to be used for a given // enumerant in JSON form, and whether that value is a 0 in a bitfield. auto getValue = [&bitEnum](const Json::Value& enumerant) { @@ -410,28 +667,40 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) }; unsigned maxValue = 0; + std::string maxName = ""; + bool maxCore = false; bool firstValue = true; for (const auto& enumerant : source["enumerants"]) { unsigned value; bool skip_zero_in_bitfield; std::tie(value, skip_zero_in_bitfield) = getValue(enumerant); + std::string name = enumerant["enumerant"].asString(); + std::string version = enumerant["version"].asString(); if (skip_zero_in_bitfield) continue; if (firstValue) { maxValue = value; + maxName = name; + maxCore = version != "None"; firstValue = false; } else { if (maxValue > value) { - std::cerr << "Error: " << source["kind"] << " enumerant " << enumerant["enumerant"] + std::cerr << "Error: " << source["kind"] << " enumerant " << name << " is out of order. It has value " << value << " but follows the enumerant with value " << maxValue << std::endl; std::exit(1); + } else if (maxValue == value ) { + std::cerr << "Error: " << source["kind"] << " enumerant " << name + << " is an alias of " << maxName << ". Use \"aliases\" instead." << std::endl; + std::exit(1); } else { maxValue = value; + maxName = name; + maxCore = version != "None"; } } + Aliases aliases = getAliases(enumerant); EnumCaps caps(getCaps(enumerant)); - std::string version = enumerant["version"].asString(); std::string lastVersion = enumerant["lastVersion"].asString(); Extensions exts(getExts(enumerant)); OperandParameters params; @@ -446,17 +715,27 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) } } dest->emplace_back( - value, enumerant["enumerant"].asString(), + value, enumerant["enumerant"].asString(), std::move(aliases), std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(params)); } }; - const auto establishOperandClass = [&populateEnumValues]( + const auto establishOperandClass = [&populateEnumValues,&errorCount]( const std::string& enumName, spv::OperandClass operandClass, spv::EnumValues* enumValues, const Json::Value& operandEnum, const std::string& category) { assert(category == "BitEnum" || category == "ValueEnum"); bool bitEnum = (category == "BitEnum"); + if (!operandEnum["version"].empty()) { + std::cerr << "Error: container for " << enumName << " operand_kind must not have a version field" << std::endl; + errorCount++; + } populateEnumValues(enumValues, operandEnum, bitEnum); + const std::string errContext = "enum " + enumName; + for (const auto& e: *enumValues) { + if (!e.IsValid(operandClass, errContext)) { + errorCount++; + } + } OperandClassParams[operandClass].set(enumName, enumValues, bitEnum); }; @@ -544,8 +823,44 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) establishOperandClass(enumName, OperandFragmentShadingRate, &FragmentShadingRateParams, operandEnum, category); } else if (enumName == "PackedVectorFormat") { establishOperandClass(enumName, OperandPackedVectorFormat, &PackedVectorFormatParams, operandEnum, category); + } else if (enumName == "CooperativeMatrixOperands") { + establishOperandClass(enumName, OperandCooperativeMatrixOperands, &CooperativeMatrixOperandsParams, operandEnum, category); + } else if (enumName == "TensorAddressingOperands") { + establishOperandClass(enumName, OperandTensorAddressingOperands, &TensorAddressingOperandsParams, operandEnum, category); + } else if (enumName == "CooperativeMatrixLayout") { + establishOperandClass(enumName, OperandCooperativeMatrixLayout, &CooperativeMatrixLayoutParams, operandEnum, category); + } else if (enumName == "CooperativeMatrixUse") { + establishOperandClass(enumName, OperandCooperativeMatrixUse, &CooperativeMatrixUseParams, operandEnum, category); + } else if (enumName == "CooperativeMatrixReduce") { + establishOperandClass(enumName, OperandCooperativeMatrixReduce, &CooperativeMatrixReduceParams, operandEnum, category); + } else if (enumName == "TensorClampMode") { + establishOperandClass(enumName, OperandTensorClampMode, &TensorClampModeParams, operandEnum, category); + } else if (enumName == "InitializationModeQualifier") { + establishOperandClass(enumName, OperandInitializationModeQualifier, &InitializationModeQualifierParams, operandEnum, category); + } else if (enumName == "HostAccessQualifier") { + establishOperandClass(enumName, OperandHostAccessQualifier, &HostAccessQualifierParams, operandEnum, category); + } else if (enumName == "LoadCacheControl") { + establishOperandClass(enumName, OperandLoadCacheControl, &LoadCacheControlParams, operandEnum, category); + } else if (enumName == "StoreCacheControl") { + establishOperandClass(enumName, OperandStoreCacheControl, &StoreCacheControlParams, operandEnum, category); + } else if (enumName == "NamedMaximumNumberOfRegisters") { + establishOperandClass(enumName, OperandNamedMaximumNumberOfRegisters, &NamedMaximumNumberOfRegistersParams, operandEnum, category); + } else if (enumName == "MatrixMultiplyAccumulateOperands") { + establishOperandClass(enumName, OperandMatrixMultiplyAccumulateOperands, &MatrixMultiplyAccumulateOperandsParams, operandEnum, category); + } else if (enumName == "RawAccessChainOperands") { + establishOperandClass(enumName, OperandRawAccessChainOperands, &RawAccessChainOperandsParams, operandEnum, category); + } else if (enumName == "FPEncoding") { + establishOperandClass(enumName, OperandFPEncoding, &FPEncodingParams, operandEnum, category); + } else if (enumName == "CooperativeVectorMatrixLayout") { + establishOperandClass(enumName, OperandCooperativeVectorMatrixLayout, &CooperativeVectorMatrixLayoutParams, operandEnum, category); + } else if (enumName == "ComponentType") { + establishOperandClass(enumName, OperandComponentType, &ComponentTypeParams, operandEnum, category); } } + + if (errorCount > 0) { + std::exit(1); + } } }; // end namespace spv diff --git a/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h index 3be645687b..a91d0909d4 100644 --- a/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h +++ b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h @@ -1,19 +1,19 @@ -// Copyright (c) 2014-2020 The Khronos Group Inc. -// +// Copyright (c) 2014-2024 The Khronos Group Inc. +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and/or associated documentation files (the "Materials"), // to deal in the Materials without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Materials, and to permit persons to whom the // Materials are furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Materials. -// +// // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS // STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -// +// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +// // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -96,6 +96,22 @@ enum OperandClass { OperandQuantizationModes, OperandOverflowModes, OperandPackedVectorFormat, + OperandCooperativeMatrixOperands, + OperandCooperativeMatrixLayout, + OperandCooperativeMatrixUse, + OperandCooperativeMatrixReduce, + OperandTensorClampMode, + OperandTensorAddressingOperands, + OperandInitializationModeQualifier, + OperandHostAccessQualifier, + OperandLoadCacheControl, + OperandStoreCacheControl, + OperandNamedMaximumNumberOfRegisters, + OperandMatrixMultiplyAccumulateOperands, + OperandRawAccessChainOperands, + OperandFPEncoding, + OperandCooperativeVectorMatrixLayout, + OperandComponentType, OperandOpcode, @@ -115,6 +131,9 @@ typedef std::vector EnumCaps; // A set of extensions. typedef std::vector Extensions; +// A set of aliases. +typedef std::vector Aliases; + // Parameterize a set of operands with their OperandClass(es) and descriptions. class OperandParameters { public: @@ -184,6 +203,7 @@ public: iterator begin() { return values.begin(); } iterator end() { return values.end(); } + EValue& back() { return values.back(); } private: ContainerType values; @@ -194,18 +214,21 @@ private: class EnumValue { public: EnumValue() : value(0), desc(nullptr) {} - EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps, + EnumValue(unsigned int the_value, const std::string& the_name, Aliases&& the_aliases, EnumCaps&& the_caps, const std::string& the_firstVersion, const std::string& the_lastVersion, Extensions&& the_extensions, OperandParameters&& the_operands) : - value(the_value), name(the_name), capabilities(std::move(the_caps)), + value(the_value), name(the_name), aliases(std::move(the_aliases)), capabilities(std::move(the_caps)), firstVersion(std::move(the_firstVersion)), lastVersion(std::move(the_lastVersion)), extensions(std::move(the_extensions)), operands(std::move(the_operands)), desc(nullptr) { } + bool hasAliases() const { return !aliases.empty(); } + // For ValueEnum, the value from the JSON file. // For BitEnum, the index of the bit position represented by this mask. // (That is, what you shift 1 by to get the mask.) unsigned value; std::string name; + Aliases aliases; EnumCaps capabilities; std::string firstVersion; std::string lastVersion; @@ -216,6 +239,10 @@ public: Extensions extensions; OperandParameters operands; const char* desc; + + // Returns true if this enum is valid, in isolation. + // Otherwise emits a diagnostic to std::cerr and returns false. + bool IsValid(OperandClass oc, const std::string& context) const; }; using EnumValues = EnumValuesContainer; @@ -261,21 +288,16 @@ public: InstructionValue(EnumValue&& e, const std::string& printClass, bool has_type, bool has_result) : EnumValue(std::move(e)), printingClass(printClass), - opDesc("TBD"), + opDesc("TBD."), typePresent(has_type), - resultPresent(has_result), - alias(this) { } + resultPresent(has_result) { } InstructionValue(const InstructionValue& v) { *this = v; - alias = this; } bool hasResult() const { return resultPresent != 0; } bool hasType() const { return typePresent != 0; } - void setAlias(const InstructionValue& a) { alias = &a; } - const InstructionValue& getAlias() const { return *alias; } - bool isAlias() const { return alias != this; } std::string printingClass; const char* opDesc; @@ -283,7 +305,6 @@ public: protected: int typePresent : 1; int resultPresent : 1; - const InstructionValue* alias; // correct only after discovering the aliases; otherwise points to this }; using InstructionValues = EnumValuesContainer; diff --git a/third_party/spirv-headers/tools/buildHeaders/main.cpp b/third_party/spirv-headers/tools/buildHeaders/main.cpp index 9a5971408c..6e6a03b340 100644 --- a/third_party/spirv-headers/tools/buildHeaders/main.cpp +++ b/third_party/spirv-headers/tools/buildHeaders/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2019 The Khronos Group Inc. +// Copyright (c) 2014-2024 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"), diff --git a/third_party/spirv-tools/Android.mk b/third_party/spirv-tools/Android.mk index a4e7615fad..1414b52497 100644 --- a/third_party/spirv-tools/Android.mk +++ b/third_party/spirv-tools/Android.mk @@ -27,6 +27,7 @@ SPVTOOLS_SRC_FILES := \ source/table.cpp \ source/text.cpp \ source/text_handler.cpp \ + source/to_string.cpp \ source/util/bit_vector.cpp \ source/util/parse_number.cpp \ source/util/string_utils.cpp \ @@ -74,6 +75,7 @@ SPVTOOLS_SRC_FILES := \ source/val/validate_ray_tracing_reorder.cpp \ source/val/validate_scopes.cpp \ source/val/validate_small_type_uses.cpp \ + source/val/validate_tensor_layout.cpp \ source/val/validate_type.cpp SPVTOOLS_OPT_SRC_FILES := \ @@ -128,14 +130,11 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/inline_pass.cpp \ source/opt/inline_exhaustive_pass.cpp \ source/opt/inline_opaque_pass.cpp \ - source/opt/inst_bindless_check_pass.cpp \ - source/opt/inst_buff_addr_check_pass.cpp \ - source/opt/inst_debug_printf_pass.cpp \ source/opt/instruction.cpp \ source/opt/instruction_list.cpp \ - source/opt/instrument_pass.cpp \ source/opt/interface_var_sroa.cpp \ source/opt/interp_fixup_pass.cpp \ + source/opt/invocation_interlock_placement_pass.cpp \ source/opt/ir_context.cpp \ source/opt/ir_loader.cpp \ source/opt/licm_pass.cpp \ @@ -156,7 +155,9 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/loop_utils.cpp \ source/opt/mem_pass.cpp \ source/opt/merge_return_pass.cpp \ + source/opt/modify_maximal_reconvergence.cpp \ source/opt/module.cpp \ + source/opt/opextinst_forward_ref_fixup_pass.cpp \ source/opt/optimizer.cpp \ source/opt/pass.cpp \ source/opt/pass_manager.cpp \ @@ -182,6 +183,9 @@ SPVTOOLS_OPT_SRC_FILES := \ source/opt/strip_debug_info_pass.cpp \ source/opt/strip_nonsemantic_info_pass.cpp \ source/opt/struct_cfg_analysis.cpp \ + source/opt/struct_packing_pass.cpp \ + source/opt/switch_descriptorset_pass.cpp \ + source/opt/trim_capabilities_pass.cpp \ source/opt/type_manager.cpp \ source/opt/types.cpp \ source/opt/unify_const_pass.cpp \ @@ -285,6 +289,7 @@ $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-bal $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,"")) $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,"")) $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.clspvreflection,"")) +$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.vkspreflection,"")) define gen_spvtools_enum_string_mapping $(call generate-file-dir,$(1)/extension_enum.inc.inc) @@ -340,7 +345,7 @@ LOCAL_C_INCLUDES := \ $(SPVTOOLS_OUT_PATH) LOCAL_EXPORT_C_INCLUDES := \ $(LOCAL_PATH)/include -LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror +LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror LOCAL_SRC_FILES:= $(SPVTOOLS_SRC_FILES) include $(BUILD_STATIC_LIBRARY) @@ -351,7 +356,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/source \ $(SPVHEADERS_LOCAL_PATH)/include \ $(SPVTOOLS_OUT_PATH) -LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror +LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror LOCAL_STATIC_LIBRARIES:=SPIRV-Tools LOCAL_SRC_FILES:= $(SPVTOOLS_OPT_SRC_FILES) include $(BUILD_STATIC_LIBRARY) diff --git a/third_party/spirv-tools/BUILD.bazel b/third_party/spirv-tools/BUILD.bazel index 0af7700515..526d08e39f 100644 --- a/third_party/spirv-tools/BUILD.bazel +++ b/third_party/spirv-tools/BUILD.bazel @@ -1,27 +1,24 @@ load( ":build_defs.bzl", + "CLDEBUGINFO100_GRAMMAR_JSON_FILE", "COMMON_COPTS", "DEBUGINFO_GRAMMAR_JSON_FILE", - "CLDEBUGINFO100_GRAMMAR_JSON_FILE", "SHDEBUGINFO100_GRAMMAR_JSON_FILE", "TEST_COPTS", - "base_test", "generate_core_tables", "generate_enum_string_mapping", "generate_extinst_lang_headers", "generate_glsl_tables", "generate_opencl_tables", "generate_vendor_tables", - "link_test", - "lint_test", - "opt_test", - "reduce_test", - "util_test", - "val_test", + "incompatible_with", ) package( default_visibility = ["//visibility:private"], + features = [ + "layering_check", + ], ) licenses(["notice"]) @@ -41,35 +38,52 @@ py_binary( srcs = ["utils/generate_language_headers.py"], ) -generate_core_tables("unified1") +generate_core_tables(version = "unified1") -generate_enum_string_mapping("unified1") +generate_enum_string_mapping(version = "unified1") -generate_opencl_tables("unified1") +generate_opencl_tables(version = "unified1") -generate_glsl_tables("unified1") +generate_glsl_tables(version = "unified1") -generate_vendor_tables("spv-amd-shader-explicit-vertex-parameter") +generate_vendor_tables(extension = "spv-amd-shader-explicit-vertex-parameter") -generate_vendor_tables("spv-amd-shader-trinary-minmax") +generate_vendor_tables(extension = "spv-amd-shader-trinary-minmax") -generate_vendor_tables("spv-amd-gcn-shader") +generate_vendor_tables(extension = "spv-amd-gcn-shader") -generate_vendor_tables("spv-amd-shader-ballot") +generate_vendor_tables(extension = "spv-amd-shader-ballot") -generate_vendor_tables("debuginfo") +generate_vendor_tables(extension = "debuginfo") -generate_vendor_tables("opencl.debuginfo.100", "CLDEBUG100_") +generate_vendor_tables(extension = "nonsemantic.clspvreflection") -generate_vendor_tables("nonsemantic.shader.debuginfo.100", "SHDEBUG100_") +generate_vendor_tables(extension = "nonsemantic.vkspreflection") -generate_vendor_tables("nonsemantic.clspvreflection") +generate_vendor_tables( + extension = "opencl.debuginfo.100", + operand_kind_prefix = "CLDEBUG100_", +) -generate_extinst_lang_headers("DebugInfo", DEBUGINFO_GRAMMAR_JSON_FILE) +generate_vendor_tables( + extension = "nonsemantic.shader.debuginfo.100", + operand_kind_prefix = "SHDEBUG100_", +) -generate_extinst_lang_headers("OpenCLDebugInfo100", CLDEBUGINFO100_GRAMMAR_JSON_FILE) +generate_extinst_lang_headers( + name = "DebugInfo", + grammar = DEBUGINFO_GRAMMAR_JSON_FILE, +) -generate_extinst_lang_headers("NonSemanticShaderDebugInfo100", SHDEBUGINFO100_GRAMMAR_JSON_FILE) +generate_extinst_lang_headers( + name = "OpenCLDebugInfo100", + grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE, +) + +generate_extinst_lang_headers( + name = "NonSemanticShaderDebugInfo100", + grammar = SHDEBUGINFO100_GRAMMAR_JSON_FILE, +) py_binary( name = "generate_registry_tables", @@ -77,12 +91,12 @@ py_binary( ) genrule( - name = "gen_registry_tables", + name = "generators_inc", srcs = ["@spirv_headers//:spirv_xml_registry"], outs = ["generators.inc"], - cmd = "$(location generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", - cmd_bat = "$(location //:generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", - exec_tools = [":generate_registry_tables"], + cmd = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", + cmd_bat = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)", + tools = [":generate_registry_tables"], ) py_binary( @@ -91,120 +105,101 @@ py_binary( ) genrule( - name = "gen_build_version", + name = "build_version_inc", srcs = ["CHANGES"], outs = ["build-version.inc"], - cmd = "SOURCE_DATE_EPOCH=0 $(location update_build_version) $(location CHANGES) $(location build-version.inc)", - cmd_bat = "set SOURCE_DATE_EPOCH=0 && $(location //:update_build_version) $(location CHANGES) $(location build-version.inc)", - exec_tools = [":update_build_version"], + cmd = "SOURCE_DATE_EPOCH=0 $(location :update_build_version) $(location CHANGES) $(location build-version.inc)", + cmd_bat = "set SOURCE_DATE_EPOCH=0 && $(location :update_build_version) $(location CHANGES) $(location build-version.inc)", + tools = [":update_build_version"], ) # Libraries cc_library( - name = "generated_headers", + name = "spirv_tools", hdrs = [ - ":gen_build_version", + "include/spirv-tools/libspirv.h", + "include/spirv-tools/libspirv.hpp", + ], + copts = COMMON_COPTS, + includes = ["include"], + linkstatic = 1, + visibility = ["//visibility:public"], + deps = [ + ":spirv_tools_internal", + ], +) + +cc_library( + name = "spirv_tools_internal", + srcs = glob([ + "source/*.cpp", + "source/util/*.cpp", + "source/val/*.cpp", + ]) + [ + ":build_version_inc", ":gen_core_tables_unified1", ":gen_enum_string_mapping", ":gen_extinst_lang_headers_DebugInfo", - ":gen_extinst_lang_headers_OpenCLDebugInfo100", ":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100", + ":gen_extinst_lang_headers_OpenCLDebugInfo100", ":gen_glsl_tables_unified1", ":gen_opencl_tables_unified1", - ":gen_registry_tables", ":gen_vendor_tables_debuginfo", ":gen_vendor_tables_nonsemantic_clspvreflection", - ":gen_vendor_tables_opencl_debuginfo_100", + ":gen_vendor_tables_nonsemantic_vkspreflection", ":gen_vendor_tables_nonsemantic_shader_debuginfo_100", + ":gen_vendor_tables_opencl_debuginfo_100", ":gen_vendor_tables_spv_amd_gcn_shader", ":gen_vendor_tables_spv_amd_shader_ballot", ":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter", ":gen_vendor_tables_spv_amd_shader_trinary_minmax", + ":generators_inc", ], - copts = COMMON_COPTS, -) - -cc_library( - name = "spirv_tools_headers", - hdrs = glob([ + hdrs = [ "include/spirv-tools/libspirv.h", "include/spirv-tools/libspirv.hpp", + ":gen_extinst_lang_headers_DebugInfo", + ":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100", + ":gen_extinst_lang_headers_OpenCLDebugInfo100", + ] + glob([ "source/*.h", "source/util/*.h", "source/val/*.h", ]), copts = COMMON_COPTS, - includes = ["source"], - deps = [ - "@spirv_headers//:spirv_cpp11_headers", - ], -) - -cc_library( - name = "spirv_tools", - srcs = glob([ - "source/*.cpp", - "source/util/*.cpp", - "source/val/*.cpp", - ]), - hdrs = [ - "include/spirv-tools/libspirv.h", - "include/spirv-tools/libspirv.hpp", - ], - copts = COMMON_COPTS + select({ - "@bazel_tools//src/conditions:windows": [""], - "//conditions:default": ["-Wno-implicit-fallthrough"], - }), includes = ["include"], - linkstatic = 1, - visibility = ["//visibility:public"], deps = [ - ":generated_headers", - ":spirv_tools_headers", + "@spirv_headers//:spirv_common_headers", "@spirv_headers//:spirv_cpp11_headers", - "@spirv_headers//:spirv_common_headers", ], ) -cc_library( - name = "spirv_tools_comp", - srcs = glob([ - "source/comp/*.cpp", - "source/comp/*.h", - ]), - copts = COMMON_COPTS, - linkstatic = 1, - visibility = ["//visibility:public"], - deps = [ - ":generated_headers", - ":spirv_tools", - ":spirv_tools_headers", - "@spirv_headers//:spirv_common_headers", - ], -) - -cc_library( - name = "spirv_tools_opt_headers", - hdrs = glob(["source/opt/*.h"]), - copts = COMMON_COPTS, -) - cc_library( name = "spirv_tools_opt", - srcs = glob(["source/opt/*.cpp"]), hdrs = [ - "include/spirv-tools/instrument.hpp", "include/spirv-tools/optimizer.hpp", ], copts = COMMON_COPTS, - includes = ["include"], linkstatic = 1, visibility = ["//visibility:public"], deps = [ ":spirv_tools", - ":spirv_tools_headers", - ":spirv_tools_opt_headers", + ":spirv_tools_opt_internal", + ], +) + +cc_library( + name = "spirv_tools_opt_internal", + srcs = glob(["source/opt/*.cpp"]) + [ + ":gen_vendor_tables_spv_amd_shader_ballot", + ], + hdrs = glob(["source/opt/*.h"]) + [ + "include/spirv-tools/optimizer.hpp", + ], + copts = COMMON_COPTS, + deps = [ + ":spirv_tools_internal", "@spirv_headers//:spirv_common_headers", ], ) @@ -214,11 +209,9 @@ cc_library( srcs = glob(["source/reduce/*.cpp"]), hdrs = glob(["source/reduce/*.h"]), copts = COMMON_COPTS, - linkstatic = 1, - visibility = ["//visibility:public"], deps = [ - ":spirv_tools", - ":spirv_tools_opt", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", ], ) @@ -230,21 +223,38 @@ cc_library( linkstatic = 1, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", - ":spirv_tools_opt", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + ], +) + +cc_library( + name = "spirv_tools_lint_internal", + srcs = glob([ + "source/lint/*.cpp", + "source/lint/*.h", + ]), + hdrs = ["include/spirv-tools/linter.hpp"] + glob([ + "source/lint/*.h", + ]), + copts = COMMON_COPTS, + includes = ["include"], + deps = [ + ":spirv_tools_internal", + ":spirv_tools_opt_internal", ], ) cc_library( name = "spirv_tools_lint", - srcs = glob(["source/lint/*.cpp", "source/lint/*.h"]), hdrs = ["include/spirv-tools/linter.hpp"], copts = COMMON_COPTS, + includes = ["include"], linkstatic = 1, visibility = ["//visibility:public"], deps = [ ":spirv_tools", - ":spirv_tools_opt", + ":spirv_tools_lint_internal", ], ) @@ -253,23 +263,29 @@ cc_library( srcs = glob(["tools/util/*.cpp"]), hdrs = glob(["tools/util/*.h"]), copts = COMMON_COPTS, - linkstatic = 1, - visibility = ["//visibility:public"], deps = [":spirv_tools"], ) +cc_library( + name = "tools_io", + hdrs = ["tools/io.h"], + srcs = ["tools/io.cpp"], + copts = COMMON_COPTS, +) + # Tools cc_binary( name = "spirv-as", srcs = [ "tools/as/as.cpp", - "tools/io.h", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", + ":spirv_tools_internal", + ":tools_io", + ":tools_util", ], ) @@ -277,25 +293,44 @@ cc_binary( name = "spirv-dis", srcs = [ "tools/dis/dis.cpp", - "tools/io.h", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ ":spirv_tools", + ":tools_io", + ":tools_util", + ], +) + +cc_binary( + name = "spirv-objdump", + srcs = [ + "tools/objdump/extract_source.cpp", + "tools/objdump/extract_source.h", + "tools/objdump/objdump.cpp", + ], + copts = COMMON_COPTS, + visibility = ["//visibility:public"], + deps = [ + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + ":tools_io", + ":tools_util", + "@spirv_headers//:spirv_cpp_headers", ], ) cc_binary( name = "spirv-val", srcs = [ - "tools/io.h", "tools/val/val.cpp", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", + ":spirv_tools_internal", + ":tools_io", ":tools_util", ], ) @@ -303,14 +338,14 @@ cc_binary( cc_binary( name = "spirv-opt", srcs = [ - "tools/io.h", "tools/opt/opt.cpp", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", - ":spirv_tools_opt", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + ":tools_io", ":tools_util", ], ) @@ -318,15 +353,15 @@ cc_binary( cc_binary( name = "spirv-reduce", srcs = [ - "tools/io.h", "tools/reduce/reduce.cpp", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", - ":spirv_tools_opt", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", ":spirv_tools_reduce", + ":tools_io", ":tools_util", ], ) @@ -334,28 +369,29 @@ cc_binary( cc_binary( name = "spirv-link", srcs = [ - "tools/io.h", "tools/link/linker.cpp", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", + ":spirv_tools_internal", ":spirv_tools_link", + ":tools_io", + ":tools_util", ], ) cc_binary( name = "spirv-lint", srcs = [ - "tools/io.h", "tools/lint/lint.cpp", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], deps = [ - ":spirv_tools", ":spirv_tools_lint", + ":spirv_tools_opt_internal", + ":tools_io", ":tools_util", ], ) @@ -366,50 +402,144 @@ cc_binary( "tools/cfg/bin_to_dot.cpp", "tools/cfg/bin_to_dot.h", "tools/cfg/cfg.cpp", - "tools/io.h", ], copts = COMMON_COPTS, visibility = ["//visibility:public"], - deps = [":spirv_tools"], + deps = [ + ":spirv_tools_internal", + ":tools_io", + ":tools_util", + ], ) # Unit tests cc_library( - name = "test_common", + name = "test_lib", testonly = 1, srcs = [ - "test/test_fixture.h", "test/unit_spirv.cpp", + ], + hdrs = [ + "test/test_fixture.h", "test/unit_spirv.h", ], - compatible_with = [], copts = TEST_COPTS, - includes = ["test"], + deps = [ + ":spirv_tools_internal", + "@googletest//:gtest", + ], +) + +# PCH (precompiled header) tests only work when using CMake and MSVC on Windows, +# so they will be skipped in the Bazel builds. + +[cc_test( + name = "base_{testcase}_test".format(testcase = f[len("test/"):-len("_test.cpp")]), + size = "small", + srcs = [f], + copts = TEST_COPTS + ["-DTESTING"], + linkstatic = 1, + target_compatible_with = { + "test/timer_test.cpp": incompatible_with(["@bazel_tools//src/conditions:windows"]), + }.get(f, []), + deps = [ + "tools_util", + ":spirv_tools_internal", + ":test_lib", + ":tools_io", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) for f in glob( + [ + "test/*_test.cpp", + "test/tools/*_test.cpp", + ], + exclude = [ + "test/cpp_interface_test.cpp", + "test/pch_test.cpp", + ], +)] + +cc_test( + name = "base_cpp_interface_test", + size = "small", + srcs = ["test/cpp_interface_test.cpp"], + linkstatic = 1, + deps = [ + ":spirv_tools_opt_internal", + "@googletest//:gtest", + "@googletest//:gtest_main", + "@spirv_headers//:spirv_cpp11_headers", + ], +) + +cc_test( + name = "base_ilist_test", + size = "small", + srcs = ["test/util/ilist_test.cpp"], + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":spirv_tools_internal", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) + +cc_library( + name = "link_test_lib", + testonly = 1, + hdrs = ["test/link/linker_fixture.h"], + copts = TEST_COPTS, + deps = [ + ":spirv_tools_internal", + ":spirv_tools_link", + ":test_lib", + "@effcee//:effcee", + "@re2//:re2", + ], +) + +[cc_test( + name = "link_{testcase}_test".format(testcase = f[len("test/link/"):-len("_test.cpp")]), + size = "small", + srcs = [f], + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":link_test_lib", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) for f in glob( + ["test/link/*_test.cpp"], +)] + +[cc_test( + name = "lint_{testcase}_test".format(testcase = f[len("test/lint/"):-len("_test.cpp")]), + size = "small", + srcs = [f], + copts = TEST_COPTS, linkstatic = 1, deps = [ ":spirv_tools", - "@com_google_googletest//:gtest", + ":spirv_tools_lint_internal", + ":spirv_tools_opt_internal", + "@googletest//:gtest", + "@googletest//:gtest_main", ], -) +) for f in glob( + ["test/lint/*_test.cpp"], +)] cc_library( - name = "link_test_common", + name = "opt_test_lib", testonly = 1, - srcs = ["test/link/linker_fixture.h"], - compatible_with = [], - copts = TEST_COPTS, - linkstatic = 1, - deps = [ - ":spirv_tools_link", - ":test_common", + srcs = [ + "test/opt/pass_utils.cpp", ], -) - -cc_library( - name = "opt_test_common", - testonly = 1, - srcs = ["test/opt/pass_utils.cpp"], hdrs = [ "test/opt/assembly_builder.h", "test/opt/function_utils.h", @@ -417,143 +547,181 @@ cc_library( "test/opt/pass_fixture.h", "test/opt/pass_utils.h", ], - compatible_with = [], + copts = TEST_COPTS, + deps = [ + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + "@effcee//:effcee", + "@googletest//:gtest", + ], +) + +[cc_test( + name = "opt_{testcase}_test".format(testcase = f[len("test/opt/"):-len("_test.cpp")]), + size = "small", + srcs = [f], copts = TEST_COPTS, linkstatic = 1, deps = [ - ":spirv_tools_opt", - ":test_common", + ":opt_test_lib", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + ":test_lib", + "@effcee//:effcee", + "@googletest//:gtest", + "@googletest//:gtest_main", ], -) +) for f in glob(["test/opt/*_test.cpp"])] -cc_library( - name = "reduce_test_common", - testonly = 1, - srcs = [ - "test/reduce/reduce_test_util.cpp", - "tools/io.h", - ], - hdrs = ["test/reduce/reduce_test_util.h"], - compatible_with = [], +[cc_test( + name = "opt_dom_tree_{testcase}_test".format(testcase = f[len("test/opt/dominator_tree/"):-len(".cpp")]), + size = "small", + srcs = [f], copts = TEST_COPTS, linkstatic = 1, deps = [ - ":spirv_tools_reduce", - ":test_common", + ":opt_test_lib", + ":spirv_tools_opt_internal", + "@googletest//:gtest", + "@googletest//:gtest_main", ], -) - -cc_library( - name = "val_test_common", - testonly = 1, - srcs = [ - "test/val/val_code_generator.cpp", - "test/val/val_fixtures.h", - ], - hdrs = [ - "test/val/val_code_generator.h", - ], - compatible_with = [], - copts = TEST_COPTS, - linkstatic = 1, - deps = [":test_common"], -) - -# PCH (precompiled header) tests only work when using CMake and MSVC on Windows, -# so they will be skipped in the Bazel builds. - -[base_test( - name = f[5:-4], # strip test/, .cpp - srcs = [f], -) for f in glob( - ["test/*.cpp"], - exclude = [ - "test/cpp_interface_test.cpp", # has its own base_test below. - "test/log_test.cpp", # has its own base_test below. - "test/pch_test.cpp", # pch tests are skipped. - "test/timer_test.cpp", # has its own base_test below. - ], -)] - -# This test uses unistd.h and does not run on Windows. -base_test( - name = "timer_test", - srcs = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["test/timer_test.cpp"], - }), -) - -base_test( - name = "cpp_interface_test", - srcs = ["test/cpp_interface_test.cpp"], - deps = [":spirv_tools_opt"], -) - -base_test( - name = "log_test", - srcs = ["test/log_test.cpp"], - deps = [":spirv_tools_opt"], -) - -[link_test( - name = f[10:-4], # strip test/link/, .cpp - srcs = [f], -) for f in glob( - ["test/link/*.cpp"], -)] - -[lint_test( - name = f[10:-4], # strip test/lint/, .cpp - srcs = [f], -) for f in glob( - ["test/lint/*.cpp"], -)] - -[opt_test( - name = f[9:-4], # strip test/opt/, .cpp - srcs = [f], -) for f in glob( - ["test/opt/*.cpp"], - # pch tests are skipped. - exclude = ["test/opt/pch_test_opt.cpp"], -)] - -[opt_test( - name = "dom_tree_" + f[24:-4], # strip test/opt/dominator_tree/, .cpp - srcs = [f], ) for f in glob( ["test/opt/dominator_tree/*.cpp"], - # pch tests are skipped. exclude = ["test/opt/dominator_tree/pch_test_opt_dom.cpp"], )] -[opt_test( - name = "loop_" + f[28:-4], # strip test/opt/loop_optimizations/, .cpp +[cc_test( + name = "opt_loop_{testcase}_test".format(testcase = f[len("test/opt/loop_optimizations/"):-len(".cpp")]), + size = "small", srcs = [f], + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":opt_test_lib", + ":spirv_tools", + ":spirv_tools_opt_internal", + "@effcee//:effcee", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], ) for f in glob( ["test/opt/loop_optimizations/*.cpp"], - # pch tests are skipped. exclude = ["test/opt/loop_optimizations/pch_test_opt_loop.cpp"], )] -[reduce_test( - name = f[12:-4], # strip test/reduce/, .cpp - srcs = [f], -) for f in glob(["test/reduce/*.cpp"])] +cc_library( + name = "reduce_test_lib", + testonly = 1, + srcs = [ + "test/reduce/reduce_test_util.cpp", + ], + hdrs = ["test/reduce/reduce_test_util.h"], + copts = TEST_COPTS, + deps = [ + ":spirv_tools", + ":spirv_tools_opt_internal", + ":spirv_tools_reduce", + ":test_lib", + ":tools_io", + "@googletest//:gtest", + ], +) -[util_test( - name = f[10:-4], # strip test/util/, .cpp +[cc_test( + name = "reduce_{testcase}_test".format(testcase = f[len("test/reduce/"):-len("_test.cpp")]), + size = "small", srcs = [f], -) for f in glob(["test/util/*.cpp"])] + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":reduce_test_lib", + ":spirv_tools_internal", + ":spirv_tools_opt_internal", + ":spirv_tools_reduce", + "@googletest//:gtest_main", + ], +) for f in glob(["test/reduce/*_test.cpp"])] -[val_test( - name = f[9:-4], # strip test/val/, .cpp +[cc_test( + name = "util_{testcase}_test".format(testcase = f[len("test/util/"):-len("_test.cpp")]), + size = "small", srcs = [f], + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":spirv_tools_internal", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) for f in glob(["test/util/*_test.cpp"])] + +cc_library( + name = "val_test_lib", + testonly = 1, + srcs = [ + "test/val/val_code_generator.cpp", + ], + hdrs = [ + "test/val/val_code_generator.h", + "test/val/val_fixtures.h", + ], + copts = TEST_COPTS, + deps = [ + ":spirv_tools_internal", + ":test_lib", + ], +) + +[cc_test( + name = "val_{testcase}_test".format(testcase = f[len("test/val/val_"):-len("_test.cpp")]), + size = "small", + srcs = [f], + copts = TEST_COPTS, + linkstatic = 1, + deps = [ + ":spirv_tools_internal", + ":test_lib", + ":val_test_lib", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], ) for f in glob( - ["test/val/*.cpp"], + ["test/val/val_*_test.cpp"], exclude = [ - "test/val/pch_test_val.cpp", # pch tests are skipped. + "test/val/val_capability_test.cpp", + "test/val/val_limits_test.cpp", ], )] +cc_test( + name = "val_capability_test", + size = "large", + timeout = "long", + srcs = ["test/val/val_capability_test.cpp"], + copts = TEST_COPTS + ["-O3"], + linkstatic = 1, + deps = [ + ":spirv_tools_internal", + ":test_lib", + ":val_test_lib", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "val_limits_test", + size = "large", + timeout = "long", + srcs = ["test/val/val_limits_test.cpp"], + copts = TEST_COPTS + [ + "-O3", + ], + linkstatic = 1, + deps = [ + ":test_lib", + ":val_test_lib", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) diff --git a/third_party/spirv-tools/BUILD.gn b/third_party/spirv-tools/BUILD.gn index a375e9df82..7c361f0337 100644 --- a/third_party/spirv-tools/BUILD.gn +++ b/third_party/spirv-tools/BUILD.gn @@ -327,6 +327,10 @@ spvtools_vendor_tables = [ "nonsemantic.clspvreflection", "...nil...", ], + [ + "nonsemantic.vkspreflection", + "...nil...", + ], [ "nonsemantic.shader.debuginfo.100", "SHDEBUG100_", @@ -370,12 +374,20 @@ config("spvtools_internal_config") { } else if (!is_win) { # Work around a false-positive on a Skia GCC 10 builder. cflags += [ "-Wno-format-truncation" ] + } else { + # Make MSVC report the correct value for __cplusplus + cflags += [ "/Zc:__cplusplus" ] + } + + if (!is_win) { + cflags += [ "-std=c++17" ] + } else { + cflags += [ "/std:c++17" ] } } source_set("spvtools_headers") { sources = [ - "include/spirv-tools/instrument.hpp", "include/spirv-tools/libspirv.h", "include/spirv-tools/libspirv.hpp", "include/spirv-tools/linker.hpp", @@ -462,6 +474,8 @@ static_library("spvtools") { "source/text.h", "source/text_handler.cpp", "source/text_handler.h", + "source/to_string.cpp", + "source/to_string.h", "source/util/bit_vector.cpp", "source/util/bit_vector.h", "source/util/bitutils.h", @@ -543,6 +557,7 @@ static_library("spvtools_val") { "source/val/validate_scopes.cpp", "source/val/validate_scopes.h", "source/val/validate_small_type_uses.cpp", + "source/val/validate_tensor_layout.cpp", "source/val/validate_type.cpp", "source/val/validation_state.cpp", "source/val/validation_state.h", @@ -668,22 +683,16 @@ static_library("spvtools_opt") { "source/opt/inline_opaque_pass.h", "source/opt/inline_pass.cpp", "source/opt/inline_pass.h", - "source/opt/inst_bindless_check_pass.cpp", - "source/opt/inst_bindless_check_pass.h", - "source/opt/inst_buff_addr_check_pass.cpp", - "source/opt/inst_buff_addr_check_pass.h", - "source/opt/inst_debug_printf_pass.cpp", - "source/opt/inst_debug_printf_pass.h", "source/opt/instruction.cpp", "source/opt/instruction.h", "source/opt/instruction_list.cpp", "source/opt/instruction_list.h", - "source/opt/instrument_pass.cpp", - "source/opt/instrument_pass.h", "source/opt/interface_var_sroa.cpp", "source/opt/interface_var_sroa.h", "source/opt/interp_fixup_pass.cpp", "source/opt/interp_fixup_pass.h", + "source/opt/invocation_interlock_placement_pass.cpp", + "source/opt/invocation_interlock_placement_pass.h", "source/opt/ir_builder.h", "source/opt/ir_context.cpp", "source/opt/ir_context.h", @@ -726,9 +735,13 @@ static_library("spvtools_opt") { "source/opt/mem_pass.h", "source/opt/merge_return_pass.cpp", "source/opt/merge_return_pass.h", + "source/opt/modify_maximal_reconvergence.cpp", + "source/opt/modify_maximal_reconvergence.h", "source/opt/module.cpp", "source/opt/module.h", "source/opt/null_pass.h", + "source/opt/opextinst_forward_ref_fixup_pass.cpp", + "source/opt/opextinst_forward_ref_fixup_pass.h", "source/opt/optimizer.cpp", "source/opt/pass.cpp", "source/opt/pass.h", @@ -778,9 +791,15 @@ static_library("spvtools_opt") { "source/opt/strip_debug_info_pass.h", "source/opt/strip_nonsemantic_info_pass.cpp", "source/opt/strip_nonsemantic_info_pass.h", + "source/opt/struct_packing_pass.cpp", + "source/opt/struct_packing_pass.h", "source/opt/struct_cfg_analysis.cpp", "source/opt/struct_cfg_analysis.h", + "source/opt/switch_descriptorset_pass.cpp", + "source/opt/switch_descriptorset_pass.h", "source/opt/tree_iterator.h", + "source/opt/trim_capabilities_pass.cpp", + "source/opt/trim_capabilities_pass.h", "source/opt/type_manager.cpp", "source/opt/type_manager.h", "source/opt/types.cpp", @@ -1358,6 +1377,7 @@ if (build_with_chromium && spvtools_build_executables) { "test/fix_word_test.cpp", "test/generator_magic_number_test.cpp", "test/hex_float_test.cpp", + "test/hex_to_text_test.cpp", "test/immediate_int_test.cpp", "test/libspirv_macros_test.cpp", "test/name_mapper_test.cpp", @@ -1395,6 +1415,7 @@ if (build_with_chromium && spvtools_build_executables) { "test/text_to_binary.type_declaration_test.cpp", "test/text_to_binary_test.cpp", "test/text_word_get_test.cpp", + "test/to_string_test.cpp", "test/unit_spirv.cpp", "test/unit_spirv.h", ] @@ -1404,6 +1425,7 @@ if (build_with_chromium && spvtools_build_executables) { ":spvtools_language_header_cldebuginfo100", ":spvtools_language_header_debuginfo", ":spvtools_language_header_vkdebuginfo100", + ":spvtools_tools_io", ":spvtools_val", "//testing/gmock", "//testing/gtest", @@ -1427,15 +1449,6 @@ if (spirv_tools_standalone) { } } -source_set("spvtools_util_cli_consumer") { - sources = [ - "tools/util/cli_consumer.cpp", - "tools/util/cli_consumer.h", - ] - deps = [ ":spvtools_headers" ] - configs += [ ":spvtools_internal_config" ] -} - source_set("spvtools_software_version") { sources = [ "source/software_version.cpp" ] deps = [ @@ -1445,12 +1458,33 @@ source_set("spvtools_software_version") { configs += [ ":spvtools_internal_config" ] } +source_set("spvtools_tools_util") { + sources = [ + "tools/util/flags.cpp", + "tools/util/cli_consumer.cpp", + "tools/util/cli_consumer.h", + ] + deps = [ ":spvtools_headers" ] + configs += [ ":spvtools_internal_config" ] +} + +source_set("spvtools_tools_io") { + sources = [ + "tools/io.cpp", + "tools/io.h", + ] + deps = [ ":spvtools_headers" ] + configs += [ ":spvtools_internal_config" ] +} + if (spvtools_build_executables) { executable("spirv-as") { sources = [ "tools/as/as.cpp" ] deps = [ ":spvtools", ":spvtools_software_version", + ":spvtools_tools_util", + ":spvtools_tools_io", ] configs += [ ":spvtools_internal_config" ] } @@ -1460,6 +1494,8 @@ if (spvtools_build_executables) { deps = [ ":spvtools", ":spvtools_software_version", + ":spvtools_tools_util", + ":spvtools_tools_io", ] configs += [ ":spvtools_internal_config" ] } @@ -1469,7 +1505,8 @@ if (spvtools_build_executables) { deps = [ ":spvtools", ":spvtools_software_version", - ":spvtools_util_cli_consumer", + ":spvtools_tools_util", + ":spvtools_tools_io", ":spvtools_val", ] configs += [ ":spvtools_internal_config" ] @@ -1484,6 +1521,8 @@ if (spvtools_build_executables) { deps = [ ":spvtools", ":spvtools_software_version", + ":spvtools_tools_util", + ":spvtools_tools_io", ] configs += [ ":spvtools_internal_config" ] } @@ -1494,7 +1533,8 @@ if (spvtools_build_executables) { ":spvtools", ":spvtools_opt", ":spvtools_software_version", - ":spvtools_util_cli_consumer", + ":spvtools_tools_util", + ":spvtools_tools_io", ":spvtools_val", ] configs += [ ":spvtools_internal_config" ] @@ -1507,6 +1547,8 @@ if (spvtools_build_executables) { ":spvtools_link", ":spvtools_opt", ":spvtools_software_version", + ":spvtools_tools_util", + ":spvtools_tools_io", ":spvtools_val", ] configs += [ ":spvtools_internal_config" ] @@ -1526,7 +1568,8 @@ if (!is_ios && !spirv_is_winuwp && build_with_chromium && spvtools_build_executa ":spvtools_opt", ":spvtools_reduce", ":spvtools_software_version", - ":spvtools_util_cli_consumer", + ":spvtools_tools_util", + ":spvtools_tools_io", ":spvtools_val", "//third_party/protobuf:protobuf_full", ] @@ -1545,7 +1588,8 @@ if (!is_ios && !spirv_is_winuwp && spvtools_build_executables) { ":spvtools_opt", ":spvtools_reduce", ":spvtools_software_version", - ":spvtools_util_cli_consumer", + ":spvtools_tools_util", + ":spvtools_tools_io", ":spvtools_val", ] configs += [ ":spvtools_internal_config" ] diff --git a/third_party/spirv-tools/CHANGES b/third_party/spirv-tools/CHANGES index 384805c32b..007e9010a3 100644 --- a/third_party/spirv-tools/CHANGES +++ b/third_party/spirv-tools/CHANGES @@ -1,7 +1,229 @@ Revision history for SPIRV-Tools -v2022.5-dev 2022-10-12 - - Start v2022.5-dev +v2024.4 2024-12-04 + - General + - Add FPEncoding operand type. (#5726) + - Support SPV_KHR_untyped_pointers (#5736) + - add support for SPV_INTEL_global_variable_host_access (#5786) + - Add support for SPV_KHR_compute_shader_derivative (#5817) + - Accept hex representation as binary input (#5870) + - Vulkan 1.4 support (#5899) + - Optimizer + - Add knowledge of cooperative matrices (#5720) + - Add struct-packing pass and unit test. (#5778) + - Validator + - Validate presence of Stride operand to OpCooperativeMatrix{Load,Store}KHR (#5777) + - Update sampled image validation (#5789) + - Disallow stores according to VUID 06924 (#5368) + - Add validation for SPV_NV_tensor_addressing and SPV_NV_cooperative_matrix2 (#5865) + - Linker + - allow linking functions with different pointer arguments (#5534) + +v2024.3 2024-06-20 + - General + - Optimizer + - Do not fold mul and adds to generate fmas (#5682) + - add OpExtInst forward ref fixup pass (#5708) + - Validator + - Separate Location check for tess patch (#5654) + - Validate MemoryAccessMask of OpCooperativeMatrixStoreKHR (#5668) + - OpSampledImage extra validation (#5695) + - add support for OpExtInstWithForwardRefs (#5698)A + - Disassembler + - add decorations to comments (#5675) + - Add --nested-indent and --reorder-blocks (#5671) + +v2024.2 2024-04-22 + - General + - Add SPIRV_TOOLS_EXPORT to public C++ API (#5591) + - Use bazel 7 and bzlmod (#5601) + - Optimizer + - opt: add GroupNonUniformPartitionedNV capability to trim pass (#5648) + - Fix rebuilding types with circular references. (#5637) + - Add AliasedPointer decoration (#5635) + - add support for vulkan-shader-profiler external passes (#5512) + - Validator + - A fix to support of SPV_QCOM_image_processing2 (#5646) + - spirv-val: Add Vulkan check for Rect Dim in OpTypeImage (#5644) + - Validate duplicate decorations and execution modes (#5641) + - Validator: Support SPV_NV_raw_access_chains (#5568) + +v2024.1 2024-03-06 + - General + - Add tooling support for SPV_KHR_maximal_reconvergence (#5542) + - Add support for SPV_KHR_float_controls2 (#5543) + - SPV_KHR_quad_control (#5547) + - Fold 64-bit int operations (#5561) + - update image enum tests to remove Kernel capability (#5562) + - Support operand kind for SPV_INTEL_maximum_registers (#5580) + - SPV_NV_shader_atomic_fp16_vector (#5581) + - Support for SPV_QCOM_image_processing2 (#5582) + - Fix access chain struct checks (#5592) + - Optimizer + - opt: add Int16 and Float16 to capability trim pass (#5519) + - Add preserver-interface option to spirv-opt (#5524) + - spirv-opt: Fix OpCompositeExtract relaxation with struct operands (#5536) + - opt: Add VulkanMemoryModelDeviceScope to trim (#5544) + - opt: Add TrimCapabilities pass to spirv-opt tool (#5545) + - Add modify-maximal-reconvergence to spirv-opt help (#5546) + - opt: add SPV_EXT_mesh_shader to opt allowlist (#5551) + - opt: Add OpEntryPoint to DescriptorScalarReplacement pass (#5553) + - opt: prevent meld to merge block with MaximalReconvergence (#5557) + - [OPT] Use new instruction folder for for all opcodes in spec consti folding (#5569) + - [OPT] Identify arrays with unknown length in copy prop arrays (#5570) + - [OPT] Add removed unused interface var pass to legalization passes (#5579) + - Validator + - spirv-val: Re-enable OpControlBarrier VU (#5527) + - spirv-val: Add Mesh Primitive Built-In validaiton (#5529) + - spirv-val: Validate PhysicalStorageBuffer Stage Interface (#5539) + - spirv-val: Multiple interface var with same SC (#5528) + - spirv-val: Revert Validate PhysicalStorageBuffer Stage Interface (#5575) + - spirv-val: Make Constant evaluation consistent (#5587) + +v2023.6 2023-12-18 + - General + - update_build_version.py produce deterministic header. (#5426) + - Support missing git in update_build_version.py (#5473) + - Optimizer + - Add ComputeDerivativeGroup*NV capabilities to trim capabilities pass. (#5430) + - Do not crash when tryingto fold unsupported spec constant (#5496) + - instrument: Fix handling of gl_InvocationID (#5493) + - Fix nullptr argument in MarkInsertChain (#5465) + - opt: support 64-bit OpAccessChain index in FixStorageClass (#5446) + - opt: add StorageImageReadWithoutFormat to cap trim (#5475) + - opt: add PhysicalStorageBufferAddresses to trim (#5476) + - Fix array size calculation (#5463 + - Validator + - spirv-val: Loosen restriction on base type of DebugTypePointer and DebugTypeQualifier (#5479) + - spirv-val: Add WorkgroupMemoryExplicitLayoutKHR check for Block (#5461) + +v2023.5 2023-10-15 + - General + - Support 2 Intel extensions (#5357) + - SPV_QCOM_image_processing support (#5223) + - Optimizer + - opt: fix StorageInputOutput16 trimming. (#5359) + - opt: add StoragePushConstant16 to trim pass (#5366) + - opt: enable StorageUniform16 (#5371) + - opt: add bitmask support for capability trimming (#5372) + - opt: Add SwitchDescriptorSetPass (#5375) + - opt: add FragmentShader*InterlockEXT to capability trim pass (#5390) + - opt: add Int64 capability to trim pass (#5398) + - opt: add Float64 capability to trim pass (#5428) + - opt: add raytracing/rayquery to trim pass (#5397) + - opt: add ImageMSArray capability to trim pass. (#5395) + - Add SPV_KHR_physical_storage_buffer to allowlists (#5402) + - Add SPV_EXT_fragment_shader_interlock to allow lists (#5393) + - Make sure that fragment shader interlock instructions are not removed by DCE (#5400) + - instrument: Use Import linkage for instrumentation functions (#5355) + - Add a new legalization pass to dedupe invocation interlock instructions (#5409) + - instrument: Ensure linking works even of nothing is changed (#5419) + - Validator + - Move token version/cap/ext checks from parsing to validation (#5370) + - val: re-add ImageMSArray validation (#5394) + - Linker + - linker: Add --use-highest-version option + +v2023.4 2023-07-17 + - General + - Set cmake_policy CMP0128 (#5341) + - Add python3 requirement for the script (#5326) + - Add support for LiteralFloat type (#5323) + - SPV_KHR_cooperative_matrix (#5286) + - Allow OpTypeBool in UniformConstant (#5237) + - Allow physical storage buffer pointer in IO (#5251) + - Remove const zero image operands (#5232) + - Optimizer + - Enable vector constant folding (#4913) (#5272) + - Fold negation of integer vectors (#5269) + - Add folding rule for OpTranspose (#5241) + - Add SPV_NV_bindless_texture to spirv optimizations (#5231) + - Fix incorrect half float conversion (#5349) + - Add SPV_EXT_shader_atomic_float_add to allow lists (#5348) + - Instrument + - instrument: Cast gl_VertexIndex and InstanceIndex to uint (#5319) + - instrument: Fix buffer address length calculations (#5257) + - instrument: Reduce number of inst_bindless_stream_write_6 calls (#5327) + - Validator + - Validate GroupNonUniform instructions (#5296) + - spirv-val: Label SPV_KHR_cooperative_matrix VUID (#5301) + - Validate layouts for PhysicalStorageBuffer pointers (#5291) + - spirv-val: Remove VUID from 1.3.251 spec (#5244) + - Diff + - spirv-diff: Update test expectations (#5264) + - spirv-diff: Leave undefined ids unpaired. (#5262) + - spirv-diff: Properly match SPV_KHR_ray_query types. (#5259) + - diff: Don't give up entry point matching too early. (#5224) + +v2023.3 2023-05-15 + - General + - Update spirv_headers to include SPV_KHR_ray_tracing_position_fetch (#5205) + - spirv-tools: Add support for QNX (#5211) + - build: set std=c++17 for BUILD.gn (#5162) + - Optimizer + - Run ADCE when the printf extension is used. (#5215) + - Don't convert struct members to half (#5201) + - Apply scalar replacement on vars with Pointer decorations (#5208) + - opt: Fix null deref in OpMatrixTimesVector and OpVectorTimesMatrix (#5199) + - instrument: Add set and binding to bindless error records (#5204) + - instrument: Change descriptor state storage format (#5178) + - Fix LICMPass (#5087) + - Add Vulkan memory model to allow lists (#5173) + - Do not remove control barrier after spv1.3 (#5174) + - Validator + - spirv-val: Label Interface Location/Component VUIDs (#5221) + - Add support for SPV_EXT_shader_tile_image (#5188) + - Fix vector OpConstantComposite type validation (#5191) + - spirv-val: Label new Vulkan VUID 07951 (#5154) + - Fuzz + - Do not define GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE if it is already defined. (#5200) + +v2023.2 2023-03-10 + - General + - build: move from c++11 to c++17 (#4983) + - tools: refactorize tools flags parsing. (#5111) + - Add C interface for Optimizer (#5030) + - libspirv.cpp: adds c++ api for spvBinaryParse (#5109) + - build: change the way we set cxx version for bazel. (#5114) + - Optimizer + - Fix null pointer in FoldInsertWithConstants. (#5093) + - Fix removal of dependent non-semantic instructions (#5122) + - Remove duplicate lists of constant and type opcodes (#5106) + - opt: fix spirv ABI on Linux again. (#5113) + - Validator + - Validate decoration of structs with RuntimeArray (#5094) + - Validate operand type before operating on it (#5092) + - spirv-val: Conditional Branch without an exit is invalid in loop header (#5069) + - spirv-val: Initial SPV_EXT_mesh_shader builtins (#5080) + +v2023.1 2023-01-17 + - General + - Renamed "master" to "main" (issue#5051) + - Validate version 5 of clspv reflection (#5050) + - Remove testing support for VS2015 (#5027) + - Fix undef behaviour in hex float parsing (#5025) + - Require C++11 *or later* (#5020) + - Instrument + - Instrument: Fix bindless checking for BufferDeviceAddress (#5049) + - Optimizer + - Optimize allocation of spvtools::opt::Instruction::operands_ (#5024) + - spirv-opt: Fix OpCompositeInsert with Null Constant (#5008) + - spirv-opt: Handle null CompositeInsert (#4998) + - Add option to ADCE to remove output variables from interface. (#4994) + - Add support for tesc, tese and geom to EliminateDead*Components (#4990) + - Add pass to eliminate dead output components (#4982) + - spirv-opt: Add const folding for CompositeInsert (#4943) + - Add passes to eliminate dead output stores (#4970) + - Prevent eliminating case constructs in block merging (#4976) + - Validator + - Fix layout validation (#5015) + - Fix use of invalid analysis (#5013) + - Fix infinite loop in validator (#5006) + - Add validation support for SPV_NV_shader_invocation_reorder. (#4979) + - Only validate full layout in Vulkan environments (#4972) + - spirv-val: Label new Vulkan OpPtrAccessChain VUs (#4975) + - spirv-val: Add OpPtrAccessChain Base checks (#4965) + v2022.4 2022-10-12 - General diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt old mode 100755 new mode 100644 index 487a40a481..abb5450587 --- a/third_party/spirv-tools/CMakeLists.txt +++ b/third_party/spirv-tools/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016 The Khronos Group Inc. +# Copyright (c) 2015-2023 The Khronos Group Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,74 +12,50 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.19) -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) -endif() -if (POLICY CMP0054) - # Avoid dereferencing variables or interpret keywords that have been - # quoted or bracketed. - # https://cmake.org/cmake/help/v3.1/policy/CMP0054.html - cmake_policy(SET CMP0054 NEW) -endif() -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../spirv-headers) - -if (APPLE) - set(CMAKE_MACOSX_RPATH ON) -endif (APPLE) -set(SPIRV_SKIP_EXECUTABLES_OPTION ON) -set(SPIRV_SKIP_TESTS_OPTION ON) -set(SKIP_SPIRV_TOOLS_INSTALL ON) +cmake_minimum_required(VERSION 3.22.1) project(spirv-tools) + +# Avoid a bug in CMake 3.22.1. By default it will set -std=c++11 for +# targets in test/*, when those tests need -std=c++17. +# https://github.com/KhronosGroup/SPIRV-Tools/issues/5340 +# The bug is fixed in CMake 3.22.2 +if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.22.1") + if (${CMAKE_VERSION} VERSION_LESS "3.22.2") + cmake_policy(SET CMP0128 NEW) + endif() +endif() + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +enable_testing() set(SPIRV_TOOLS "SPIRV-Tools") include(GNUInstallDirs) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -# Require at least C++11 +# Require at least C++17 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD 17) endif() -if(${CMAKE_CXX_STANDARD} LESS 11) - message(FATAL_ERROR "SPIRV-Tools requires C++11 or later, but is configured for C++${CMAKE_CXX_STANDARD})") +if(${CMAKE_CXX_STANDARD} LESS 17) + message(FATAL_ERROR "SPIRV-Tools requires C++17 or later, but is configured for C++${CMAKE_CXX_STANDARD})") endif() +set(CMAKE_CXX_EXTENSIONS OFF) option(ENABLE_RTTI "Enables RTTI" OFF) option(SPIRV_ALLOW_TIMERS "Allow timers via clock_gettime on supported platforms" ON) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - add_definitions(-DSPIRV_LINUX) set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS}) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten") - add_definitions(-DSPIRV_EMSCRIPTEN) elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") add_definitions(-DSPIRV_WINDOWS) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN") add_definitions(-DSPIRV_WINDOWS) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") - add_definitions(-DSPIRV_MAC) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") - add_definitions(-DSPIRV_IOS) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "tvOS") - add_definitions(-DSPIRV_TVOS) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") - add_definitions(-DSPIRV_ANDROID) set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS}) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") - add_definitions(-DSPIRV_FREEBSD) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") - add_definitions(-DSPIRV_OPENBSD) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") - add_definitions(-DSPIRV_FUCHSIA) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU") - add_definitions(-DSPIRV_GNU) -else() - message(FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!") endif() if (${SPIRV_TIMER_ENABLED}) @@ -91,6 +67,7 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "Debug") endif() +option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL}) if(NOT ${SKIP_SPIRV_TOOLS_INSTALL}) set(ENABLE_SPIRV_TOOLS_INSTALL ON) endif() @@ -107,8 +84,7 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF) -set(SPIRV_WERROR OFF) - +option(SPIRV_WERROR "Enable error on warning" ON) if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) set(COMPILER_IS_LIKE_GNU TRUE) endif() @@ -204,10 +180,9 @@ function(spvtools_default_compile_options TARGET) target_compile_options(${TARGET} PRIVATE ${SPIRV_WARNINGS}) if (${COMPILER_IS_LIKE_GNU}) - target_compile_options(${TARGET} PRIVATE -std=c++11 -fno-exceptions) target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wno-long-long -Wshadow -Wundef -Wconversion - -Wno-sign-conversion) + -Wno-sign-conversion -fno-exceptions) if(NOT ENABLE_RTTI) add_compile_options(-fno-rtti) @@ -244,7 +219,7 @@ function(spvtools_default_compile_options TARGET) # For MinGW cross compile, statically link to the C++ runtime. # But it still depends on MSVCRT.dll. if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") + if (NOT MSVC) set_target_properties(${TARGET} PROPERTIES LINK_FLAGS -static -static-libgcc -static-libstdc++) endif() @@ -263,12 +238,7 @@ if(NOT COMMAND find_host_program) endif() # Tests require Python3 -if(CMAKE_VERSION VERSION_LESS "3.12" OR ${CMAKE_SYSTEM_NAME} MATCHES "Windows") - find_host_package(PythonInterp 3 REQUIRED) -else() - find_package(Python3 COMPONENTS Interpreter) - set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") -endif() +find_host_package(Python3 REQUIRED) # Check for symbol exports on Linux. # At the moment, this check will fail on the OSX build machines for the Android NDK. @@ -277,7 +247,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") macro(spvtools_check_symbol_exports TARGET) if (NOT "${SPIRV_SKIP_TESTS}") add_test(NAME spirv-tools-symbol-exports-${TARGET} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND Python3::Interpreter ${spirv-tools_SOURCE_DIR}/utils/check_symbol_exports.py "$") endif() endmacro() @@ -290,7 +260,7 @@ else() endif() if(ENABLE_SPIRV_TOOLS_INSTALL) - if(WIN32) + if(WIN32 AND NOT MINGW) macro(spvtools_config_package_dir TARGET PATH) set(${PATH} ${TARGET}/cmake) endmacro() @@ -310,15 +280,23 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) endmacro() endif() -# Defaults to OFF if the user didn't set it. -option(SPIRV_SKIP_EXECUTABLES - "Skip building the executable and tests along with the library" - ${SPIRV_SKIP_EXECUTABLES_OPTION}) -option(SPIRV_SKIP_TESTS - "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) -if ("${SPIRV_SKIP_EXECUTABLES}") +# Currently iOS and Android are very similar. +# They both have their own packaging (APP/APK). +# Which makes regular executables/testing problematic. +# +# Currently the only deliverables for these platforms are +# libraries (either STATIC or SHARED). +# +# Furthermore testing is equally problematic. +if (IOS OR ANDROID) + set(SPIRV_SKIP_EXECUTABLES ON) +endif() + +option(SPIRV_SKIP_EXECUTABLES "Skip building the executable and tests along with the library") +if (SPIRV_SKIP_EXECUTABLES) set(SPIRV_SKIP_TESTS ON) endif() +option(SPIRV_SKIP_TESTS "Skip building tests along with the library") # Defaults to ON. The checks can be time consuming. # Turn off if they take too long. @@ -359,6 +337,9 @@ endif() add_subdirectory(source) add_subdirectory(tools) +add_subdirectory(test) +add_subdirectory(examples) + if(ENABLE_SPIRV_TOOLS_INSTALL) install( FILES @@ -366,16 +347,55 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/optimizer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/linker.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/instrument.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spirv-tools/) endif(ENABLE_SPIRV_TOOLS_INSTALL) if (NOT "${SPIRV_SKIP_TESTS}") add_test(NAME spirv-tools-copyrights - COMMAND ${PYTHON_EXECUTABLE} utils/check_copyright.py + COMMAND Python3::Interpreter utils/check_copyright.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endif() set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link") set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") + +# Build pkg-config file +# Use a first-class target so it's regenerated when relevant files are updated. +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc + COMMAND ${CMAKE_COMMAND} + -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES + -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in + -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DSPIRV_LIBRARIES=${SPIRV_LIBRARIES} + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake + DEPENDS "CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake") +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc + COMMAND ${CMAKE_COMMAND} + -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES + -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in + -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES} + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake + DEPENDS "CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake") +add_custom_target(spirv-tools-pkg-config + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc) + +# Install pkg-config file +if (ENABLE_SPIRV_TOOLS_INSTALL) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc + ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() diff --git a/third_party/spirv-tools/CONTRIBUTING.md b/third_party/spirv-tools/CONTRIBUTING.md index 1eb8b689e8..11fb4e2c7e 100644 --- a/third_party/spirv-tools/CONTRIBUTING.md +++ b/third_party/spirv-tools/CONTRIBUTING.md @@ -2,9 +2,8 @@ ## For users: Reporting bugs and requesting features -We organize known future work in GitHub projects. See [Tracking SPIRV-Tools work -with GitHub -projects](https://github.com/KhronosGroup/SPIRV-Tools/blob/master/docs/projects.md) +We organize known future work in GitHub projects. See +[Tracking SPIRV-Tools work with GitHub projects](https://github.com/KhronosGroup/SPIRV-Tools/blob/main/docs/projects.md) for more. To report a new bug or request a new feature, please file a GitHub issue. Please @@ -36,9 +35,9 @@ create a new issue, as with bugs. In the issue provide ## For developers: Contributing a patch -Before we can use your code, you must sign the [Khronos Open Source Contributor -License Agreement](https://cla-assistant.io/KhronosGroup/SPIRV-Tools) (CLA), -which you can do online. The CLA is necessary mainly because you own the +Before we can use your code, you must sign the +[Khronos Open Source Contributor License Agreement](https://cla-assistant.io/KhronosGroup/SPIRV-Tools) +(CLA), which you can do online. The CLA is necessary mainly because you own the copyright to your changes, even after your contribution becomes part of our codebase, so we need your permission to use and distribute your code. We also need to be sure of various other things -- for instance that you'll tell us if @@ -47,20 +46,20 @@ sign the CLA until after you've submitted your code for review and a member has approved it, but you must do it before we can put your code into our codebase. See -[README.md](https://github.com/KhronosGroup/SPIRV-Tools/blob/master/README.md) +[README.md](https://github.com/KhronosGroup/SPIRV-Tools/blob/main/README.md) for instruction on how to get, build, and test the source. Once you have made your changes: -* Ensure the code follows the [Google C++ Style - Guide](https://google.github.io/styleguide/cppguide.html). Running - `clang-format -style=file -i [modified-files]` can help. +* Ensure the code follows the + [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). + Running `clang-format -style=file -i [modified-files]` can help. * Create a pull request (PR) with your patch. * Make sure the PR description clearly identified the problem, explains the solution, and references the issue if applicable. * If your patch completely fixes bug 1234, the commit message should say - `Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1234` - When you do this, the issue will be closed automatically when the commit - goes into master. Also, this helps us update the [CHANGES](CHANGES) file. + `Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1234` When you do + this, the issue will be closed automatically when the commit goes into + main. Also, this helps us update the [CHANGES](CHANGES) file. * Watch the continuous builds to make sure they pass. * Request a code review. @@ -82,8 +81,8 @@ Instructions for this are given below. The formal code reviews are done on GitHub. Reviewers are to look for all of the usual things: -* Coding style follows the [Google C++ Style - Guide](https://google.github.io/styleguide/cppguide.html) +* Coding style follows the + [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) * Identify potential functional problems. * Identify code duplication. * Ensure the unit tests have enough coverage. @@ -102,84 +101,49 @@ should pay particular attention to: updated. For example, a new instruction is added, but the def-use manager is not updated. Later on, it is possible that the def-use manager will be used, and give wrong results. +* If a pass gets the id of a type from the type manager, make sure the type is + not a struct or array. It there are two structs that look the same, the type + manager can return the wrong one. ## For maintainers: Merging a PR -We intend to maintain a linear history on the GitHub master branch, and the +We intend to maintain a linear history on the GitHub main branch, and the build and its tests should pass at each commit in that history. A linear always-working history is easier to understand and to bisect in case we want to -find which commit introduced a bug. +find which commit introduced a bug. The +[Squash and Merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits) +button on the GitHub web interface. All other ways of merging on the web +interface have been disabled. -### Initial merge setup +Before merging, we generally require: -The following steps should be done exactly once (when you are about to merge a -PR for the first time): +1. All tests except for the smoke test pass. See + [failing smoke test](#failing-smoke-test). +1. The PR is approved by at least one of the maintainers. If the PR modifies + different parts of the code, then multiple reviewers might be necessary. -* It is assumed that upstream points to - [git@github.com](mailto:git@github.com):KhronosGroup/SPIRV-Tools.git or - https://github.com/KhronosGroup/SPIRV-Tools.git. +The squash-and-merge button will turn green when these requirements are met. +Maintainers have the to power to merge even if the button is not green, but that +is discouraged. -* Find out the local name for the main github repo in your git configuration. - For example, in this configuration, it is labeled `upstream`. +### Failing smoke test - ``` - git remote -v - [ ... ] - upstream https://github.com/KhronosGroup/SPIRV-Tools.git (fetch) - upstream https://github.com/KhronosGroup/SPIRV-Tools.git (push) - ``` +The purpose of the smoke test is to let us know if +[shaderc](https://github.com/google/shaderc) fails to build with the change. If +it fails, the maintainer needs to determine if the reason for the failure is a +problem in the current PR or if another repository needs to be changed. Most of +the time [Glslang](https://github.com/KhronosGroup/glslang) needs to be updated +to account for the change in SPIR-V Tools. -* Make sure that the `upstream` remote is set to fetch from the `refs/pull` - namespace: +The PR can still be merged if the problem is not with that PR. - ``` - git config --get-all remote.upstream.fetch - +refs/heads/*:refs/remotes/upstream/* - +refs/pull/*/head:refs/remotes/upstream/pr/* - ``` +## For maintainers: Running tests -* If the line `+refs/pull/*/head:refs/remotes/upstream/pr/*` is not present in - your configuration, you can add it with the command: +For security reasons, not all tests will run automatically. When they do not, a +maintainer will have to start the tests. - ``` - git config --local --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/pr/*' - ``` +If the Github actions tests do not run on a PR, they can be initiated by closing +and reopening the PR. -### Merge workflow - -The following steps should be done for every PR that you intend to merge: - -* Make sure your local copy of the master branch is up to date: - - ``` - git checkout master - git pull - ``` - -* Fetch all pull requests refs: - - ``` - git fetch upstream - ``` - -* Checkout the particular pull request you are going to review: - - ``` - git checkout pr/1048 - ``` - -* Rebase the PR on top of the master branch. If there are conflicts, send it - back to the author and ask them to rebase. During the interactive rebase be - sure to squash all of the commits down to a single commit. - - ``` - git rebase -i master - ``` - -* **Build and test the PR.** - -* If all of the tests pass, push the commit `git push upstream HEAD:master` - -* Close the PR and add a comment saying it was push using the commit that you - just pushed. See https://github.com/KhronosGroup/SPIRV-Tools/pull/935 as an - example. +If the kokoro tests are not run, they can be run by adding the label +`kokoro:run` to the PR. diff --git a/third_party/spirv-tools/DEPS b/third_party/spirv-tools/DEPS index d6242d815f..b7f57b11d4 100644 --- a/third_party/spirv-tools/DEPS +++ b/third_party/spirv-tools/DEPS @@ -3,19 +3,33 @@ use_relative_paths = True vars = { 'github': 'https://github.com', - 'effcee_revision': '35912e1b7778ec2ddcff7e7188177761539e59e0', - 'googletest_revision': 'd9bb8412d60b993365abb53f00b6dad9b2c01b62', - 're2_revision': 'd2836d1b1c34c4e330a85a1006201db474bf2c8a', - 'spirv_headers_revision': '34d04647d384e0aed037e7a2662a655fc39841bb', + 'abseil_revision': '69b58f9227bf91a9315475579df15fbb7c5c612e', + + 'effcee_revision': '12241cbc30f20730b656db7fd5a3fa36cd420843', + + 'googletest_revision': 'e235eb34c6c4fed790ccdad4b16394301360dcd4', + + # Use protobufs before they gained the dependency on abseil + 'protobuf_revision': 'v21.12', + + 're2_revision': '6dcd83d60f7944926bfd308cc13979fc53dd69ca', + + 'spirv_headers_revision': 'e7294a8ebed84f8c5bd3686c68dbe12a4e65b644', } deps = { + 'external/abseil_cpp': + Var('github') + '/abseil/abseil-cpp.git@' + Var('abseil_revision'), + 'external/effcee': Var('github') + '/google/effcee.git@' + Var('effcee_revision'), 'external/googletest': Var('github') + '/google/googletest.git@' + Var('googletest_revision'), + 'external/protobuf': + Var('github') + '/protocolbuffers/protobuf.git@' + Var('protobuf_revision'), + 'external/re2': Var('github') + '/google/re2.git@' + Var('re2_revision'), diff --git a/third_party/spirv-tools/FILAMENT_README.md b/third_party/spirv-tools/FILAMENT_README.md deleted file mode 100644 index 9c9bb3e437..0000000000 --- a/third_party/spirv-tools/FILAMENT_README.md +++ /dev/null @@ -1,20 +0,0 @@ -When updating SPIRV-Tools to a new version, run the following from *this* directory - -``` -bash filament-update.sh [git commit hash] -``` - -This will pull in the updated source for SPRIV-Tools and pull in the right version of SPIRV-Headers. -The script will also try to apply Filament specific changes to the `CMakeLists.txt`. It could be -that the diff application will fail, in which case, the updater will need to resolve the difference -manually and update `filament-specific-changes.patch`. - -The above script will bring in the changes, but you would still need to add it to a git commit -(i.e. pull request) by doing - -``` -git add -u third_party/spriv-tools third_party/spirv-headers -``` - -from the Filament source root. - diff --git a/third_party/spirv-tools/MODULE.bazel b/third_party/spirv-tools/MODULE.bazel new file mode 100644 index 0000000000..2e28e9eff0 --- /dev/null +++ b/third_party/spirv-tools/MODULE.bazel @@ -0,0 +1,33 @@ +bazel_dep(name = "bazel_skylib", version = "1.5.0") + +bazel_dep(name = "googletest", dev_dependency = True) +local_path_override( + module_name = "googletest", + path = "external/googletest", +) + +bazel_dep(name = "re2", dev_dependency = True) +local_path_override( + module_name = "re2", + path = "external/re2", +) + +bazel_dep(name = "effcee", dev_dependency = True) +local_path_override( + module_name = "effcee", + path = "external/effcee", +) + +bazel_dep(name = "rules_python", + version = "0.34.0") + +# https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage +python = use_extension( + "@rules_python//python/extensions:python.bzl", + "python", + dev_dependency = True +) + +python.toolchain(python_version = "3.12", + is_default = True, + ignore_root_user_error = True) diff --git a/third_party/spirv-tools/README.md b/third_party/spirv-tools/README.md index 96d59b9c7e..7bf8a51ffa 100644 --- a/third_party/spirv-tools/README.md +++ b/third_party/spirv-tools/README.md @@ -1,4 +1,7 @@ # SPIR-V Tools +[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/KhronosGroup/SPIRV-Tools/badge)](https://securityscorecards.dev/viewer/?uri=github.com/KhronosGroup/SPIRV-Tools) + +NEWS 2023-01-11: Development occurs on the `main` branch. ## Overview @@ -21,9 +24,16 @@ headers, and XML registry. ## Downloads +The official releases for SPIRV-Tools can be found on LunarG's +[SDK download page](https://vulkan.lunarg.com/sdk/home). + +For convenience, here are also links to the latest builds (HEAD). +Those are untested automated builds. Those are not official releases, nor +are guaranteed to work. Official releases builds are in the Vulkan SDK. + Linux[![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html) MacOS[![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html) -Windows[![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html) +Windows[![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_vs2022_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2022_release.html) [More downloads](docs/downloads.md) @@ -46,17 +56,14 @@ version. An API call reports the software version as a C-style string. ## Releases -Some versions of SPIRV-Tools are tagged as stable releases (see -[tags](https://github.com/KhronosGroup/SPIRV-Tools/tags) on github). -These versions undergo extra testing. -Releases are not directly related to releases (or versions) of -[SPIRV-Headers][spirv-headers]. -Releases of SPIRV-Tools are tested against the version of SPIRV-Headers listed -in the [DEPS](DEPS) file. -The release generally uses the most recent compatible version of SPIRV-Headers -available at the time of release. -No version of SPIRV-Headers other than the one listed in the DEPS file is -guaranteed to work with the SPIRV-Tools release. +The official releases for SPIRV-Tools can be found on LunarG's +[SDK download page](https://vulkan.lunarg.com/sdk/home). + +You can find either the prebuilt, and QA tested binaries, or download the +SDK Config, which lists the commits to use to build the release from scratch. + +GitHub releases are deprecated, and we will not publish new releases until +further notice. ## Supported features @@ -73,6 +80,8 @@ guaranteed to work with the SPIRV-Tools release. * Assembler only does basic syntax checking. No cross validation of IDs or types is performed, except to check literal arguments to `OpConstant`, `OpSpecConstant`, and `OpSwitch`. +* Where tools expect binary input, a hex stream may be provided instead. See + `spirv-dis --help`. See [`docs/syntax.md`](docs/syntax.md) for the assembly language syntax. @@ -271,7 +280,7 @@ Contributions via merge request are welcome. Changes should: `clang-format version 5.0.0` for SPIRV-Tools. Settings are defined by the included [.clang-format](.clang-format) file. -We intend to maintain a linear history on the GitHub `master` branch. +We intend to maintain a linear history on the GitHub `main` branch. ### Getting the source @@ -290,16 +299,18 @@ For some kinds of development, you may need the latest sources from the third-pa git clone https://github.com/google/googletest.git spirv-tools/external/googletest git clone https://github.com/google/effcee.git spirv-tools/external/effcee git clone https://github.com/google/re2.git spirv-tools/external/re2 + git clone https://github.com/abseil/abseil-cpp.git spirv-tools/external/abseil_cpp #### Dependency on Effcee Some tests depend on the [Effcee][effcee] library for stateful matching. -Effcee itself depends on [RE2][re2]. +Effcee itself depends on [RE2][re2], and RE2 depends on [Abseil][abseil-cpp]. * If SPIRV-Tools is configured as part of a larger project that already uses Effcee, then that project should include Effcee before SPIRV-Tools. -* Otherwise, SPIRV-Tools expects Effcee sources to appear in `external/effcee` - and RE2 sources to appear in `external/re2`. +* Otherwise, SPIRV-Tools expects Effcee sources to appear in `external/effcee`, + RE2 sources to appear in `external/re2`, and Abseil sources to appear in + `external/abseil_cpp`. ### Source code organization @@ -311,6 +322,9 @@ Effcee itself depends on [RE2][re2]. * `external/re2`: Location of [RE2][re2] sources, if the `re2` library is not already configured by an enclosing project. (The Effcee project already requires RE2.) +* `external/abseil_cpp`: Location of [Abseil][abseil-cpp] sources, if Abseil is + not already configured by an enclosing project. + (The RE2 project already requires Abseil.) * `include/`: API clients should add this directory to the include search path * `external/spirv-headers`: Intended location for [SPIR-V headers][spirv-headers], not provided @@ -378,10 +392,11 @@ fuzzer tests. ### Build using Bazel You can also use [Bazel](https://bazel.build/) to build the project. + ```sh -cd bazel build :all ``` + ### Build a node.js package using Emscripten The SPIRV-Tools core library can be built to a WebAssembly [node.js](https://nodejs.org) @@ -417,7 +432,7 @@ targets, you need to install CMake Version 2.8.12 or later. - [Python 3](http://www.python.org/): for utility scripts and running the test suite. - [Bazel](https://bazel.build/) (optional): if building the source with Bazel, -you need to install Bazel Version 5.0.0 on your machine. Other versions may +you need to install Bazel Version 7.0.2 on your machine. Other versions may also work, but are not verified. - [Emscripten SDK](https://emscripten.org) (optional): if building the WebAssembly module. @@ -425,17 +440,17 @@ also work, but are not verified. SPIRV-Tools is regularly tested with the following compilers: On Linux -- GCC version 9.3 +- GCC version 9.4 - Clang version 10.0 On MacOS -- AppleClang 11.0 +- AppleClang 15.0 On Windows -- Visual Studio 2015 -- Visual Studio 2017 +- Visual Studio 2019 +- Visual Studio 2022 -Other compilers or later versions may work, but they are not tested. +Note: Other compilers or later versions may work, but they are not tested. ### CMake options @@ -467,12 +482,12 @@ iterator debugging. ### Android ndk-build SPIR-V Tools supports building static libraries `libSPIRV-Tools.a` and -`libSPIRV-Tools-opt.a` for Android: +`libSPIRV-Tools-opt.a` for Android. Using the Android NDK r25c or later: ``` cd -export ANDROID_NDK=/path/to/your/ndk +export ANDROID_NDK=/path/to/your/ndk # NDK r25c or later mkdir build && cd build mkdir libs @@ -496,7 +511,7 @@ The script requires Chromium's ### Usage -The internals of the library use C++11 features, and are exposed via both a C +The internals of the library use C++17 features, and are exposed via both a C and C++ API. In order to use the library from an application, the include path should point @@ -718,10 +733,16 @@ Use `bazel test :all` to run all tests. This will run tests in parallel by defau To run a single test target, specify `:my_test_target` instead of `:all`. Test target names get printed when you run `bazel test :all`. For example, you can run `opt_def_use_test` with: + +on linux: ```shell -bazel test :opt_def_use_test +bazel test --cxxopt=-std=c++17 :opt_def_use_test ``` +on windows: +```shell +bazel test --cxxopt=/std:c++17 :opt_def_use_test +``` ## Future Work @@ -779,6 +800,7 @@ limitations under the License. [googletest-issue-610]: https://github.com/google/googletest/issues/610 [effcee]: https://github.com/google/effcee [re2]: https://github.com/google/re2 +[abseil-cpp]: https://github.com/abseil/abseil-cpp [CMake]: https://cmake.org/ [cpp-style-guide]: https://google.github.io/styleguide/cppguide.html [clang-sanitizers]: http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation diff --git a/third_party/spirv-tools/SECURITY.md b/third_party/spirv-tools/SECURITY.md new file mode 100644 index 0000000000..99c5f441a3 --- /dev/null +++ b/third_party/spirv-tools/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/KhronosGroup/SPIRV-Tools/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/third_party/spirv-tools/WORKSPACE b/third_party/spirv-tools/WORKSPACE index 5abfc98bcc..054960aa06 100644 --- a/third_party/spirv-tools/WORKSPACE +++ b/third_party/spirv-tools/WORKSPACE @@ -4,16 +4,6 @@ local_repository( ) local_repository( - name = "com_google_googletest", - path = "external/googletest", -) - -local_repository( - name = "com_googlesource_code_re2", - path = "external/re2", -) - -local_repository( - name = "com_google_effcee", - path = "external/effcee", + name = "abseil-cpp", + path = "external/abseil_cpp", ) diff --git a/third_party/spirv-tools/android_test/Android.mk b/third_party/spirv-tools/android_test/Android.mk index dbaf93ba98..b9a0014158 100644 --- a/third_party/spirv-tools/android_test/Android.mk +++ b/third_party/spirv-tools/android_test/Android.mk @@ -5,7 +5,7 @@ LOCAL_CPP_EXTENSION := .cc .cpp .cxx LOCAL_SRC_FILES:=test.cpp LOCAL_MODULE:=spirvtools_test LOCAL_LDLIBS:=-landroid -LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror +LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror LOCAL_STATIC_LIBRARIES=SPIRV-Tools SPIRV-Tools-opt include $(BUILD_SHARED_LIBRARY) diff --git a/third_party/spirv-tools/android_test/jni/Application.mk b/third_party/spirv-tools/android_test/jni/Application.mk index 4e66465931..47c0acfbce 100644 --- a/third_party/spirv-tools/android_test/jni/Application.mk +++ b/third_party/spirv-tools/android_test/jni/Application.mk @@ -1,5 +1,5 @@ APP_ABI := all APP_BUILD_SCRIPT := Android.mk APP_STL := c++_static -APP_PLATFORM := android-9 +APP_PLATFORM := android-24 NDK_TOOLCHAIN_VERSION := 4.9 diff --git a/third_party/spirv-tools/build_defs.bzl b/third_party/spirv-tools/build_defs.bzl index ed726aebee..76bf3e7923 100644 --- a/third_party/spirv-tools/build_defs.bzl +++ b/third_party/spirv-tools/build_defs.bzl @@ -1,20 +1,21 @@ +"""Constants and macros for spirv-tools BUILD.""" + COMMON_COPTS = [ - "-DSPIRV_CHECK_CONTEXT", - "-DSPIRV_COLOR_TERMINAL", - ] + select({ - "@bazel_tools//src/conditions:windows": [""], + "-DSPIRV_CHECK_CONTEXT", + "-DSPIRV_COLOR_TERMINAL", +] + select({ + "@platforms//os:windows": [], "//conditions:default": [ "-DSPIRV_LINUX", "-DSPIRV_TIMER_ENABLED", + "-fvisibility=hidden", + "-fno-exceptions", + "-fno-rtti", "-Wall", "-Wextra", "-Wnon-virtual-dtor", "-Wno-missing-field-initializers", "-Werror", - "-std=c++11", - "-fvisibility=hidden", - "-fno-exceptions", - "-fno-rtti", "-Wno-long-long", "-Wshadow", "-Wundef", @@ -23,330 +24,211 @@ COMMON_COPTS = [ ], }) -TEST_COPTS = COMMON_COPTS + select({ - "@bazel_tools//src/conditions:windows": [ +TEST_COPTS = COMMON_COPTS + [ +] + select({ + "@platforms//os:windows": [ # Disable C4503 "decorated name length exceeded" warning, # triggered by some heavily templated types. # We don't care much about that in test code. # Important to do since we have warnings-as-errors. - "/wd4503" + "/wd4503", ], "//conditions:default": [ "-Wno-undef", "-Wno-self-assign", "-Wno-shadow", - "-Wno-unused-parameter" + "-Wno-unused-parameter", ], }) +def incompatible_with(incompatible_constraints): + return select(_merge_dicts([{"//conditions:default": []}, { + constraint: ["@platforms//:incompatible"] + for constraint in incompatible_constraints + }])) + DEBUGINFO_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_debuginfo_grammar_unified1" CLDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_opencl_debuginfo_100_grammar_unified1" SHDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_nonsemantic_shader_debuginfo_100_grammar_unified1" -def generate_core_tables(version = None): +def _merge_dicts(dicts): + merged = {} + for d in dicts: + merged.update(d) + return merged + +def generate_core_tables(version): if not version: fail("Must specify version", "version") - grammars = [ - "@spirv_headers//:spirv_core_grammar_" + version, - DEBUGINFO_GRAMMAR_JSON_FILE, - CLDEBUGINFO100_GRAMMAR_JSON_FILE, - ] - outs = [ - "core.insts-{}.inc".format(version), - "operand.kinds-{}.inc".format(version), - ] - fmtargs = grammars + outs + + grammars = dict( + core_grammar = "@spirv_headers//:spirv_core_grammar_{}".format(version), + debuginfo_grammar = DEBUGINFO_GRAMMAR_JSON_FILE, + cldebuginfo_grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE, + ) + + outs = dict( + core_insts_output = "core.insts-{}.inc".format(version), + operand_kinds_output = "operand.kinds-{}.inc".format(version), + ) + + cmd = ( + "$(location :generate_grammar_tables)" + + " --spirv-core-grammar=$(location {core_grammar})" + + " --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" + + " --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" + + " --core-insts-output=$(location {core_insts_output})" + + " --operand-kinds-output=$(location {operand_kinds_output})" + + " --output-language=c++" + ).format(**_merge_dicts([grammars, outs])) + native.genrule( name = "gen_core_tables_" + version, - srcs = grammars, - outs = outs, - cmd = ( - "$(location :generate_grammar_tables) " + - "--spirv-core-grammar=$(location {0}) " + - "--extinst-debuginfo-grammar=$(location {1}) " + - "--extinst-cldebuginfo100-grammar=$(location {2}) " + - "--core-insts-output=$(location {3}) " + - "--operand-kinds-output=$(location {4}) " + - "--output-language=c++" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_grammar_tables) " + - "--spirv-core-grammar=$(location {0}) " + - "--extinst-debuginfo-grammar=$(location {1}) " + - "--extinst-cldebuginfo100-grammar=$(location {2}) " + - "--core-insts-output=$(location {3}) " + - "--operand-kinds-output=$(location {4}) " + - "--output-language=c++" - ).format(*fmtargs), - exec_tools = [":generate_grammar_tables"], + srcs = grammars.values(), + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) -def generate_enum_string_mapping(version = None): +def generate_enum_string_mapping(version): if not version: fail("Must specify version", "version") - grammars = [ - "@spirv_headers//:spirv_core_grammar_" + version, - DEBUGINFO_GRAMMAR_JSON_FILE, - CLDEBUGINFO100_GRAMMAR_JSON_FILE, - ] - outs = [ - "extension_enum.inc", - "enum_string_mapping.inc", - ] - fmtargs = grammars + outs + + grammars = dict( + core_grammar = "@spirv_headers//:spirv_core_grammar_{}".format(version), + debuginfo_grammar = DEBUGINFO_GRAMMAR_JSON_FILE, + cldebuginfo_grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE, + ) + + outs = dict( + extension_enum_ouput = "extension_enum.inc", + enum_string_mapping_output = "enum_string_mapping.inc", + ) + + cmd = ( + "$(location :generate_grammar_tables)" + + " --spirv-core-grammar=$(location {core_grammar})" + + " --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" + + " --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" + + " --extension-enum-output=$(location {extension_enum_ouput})" + + " --enum-string-mapping-output=$(location {enum_string_mapping_output})" + + " --output-language=c++" + ).format(**_merge_dicts([grammars, outs])) + native.genrule( name = "gen_enum_string_mapping", - srcs = grammars, - outs = outs, - cmd = ( - "$(location :generate_grammar_tables) " + - "--spirv-core-grammar=$(location {0}) " + - "--extinst-debuginfo-grammar=$(location {1}) " + - "--extinst-cldebuginfo100-grammar=$(location {2}) " + - "--extension-enum-output=$(location {3}) " + - "--enum-string-mapping-output=$(location {4}) " + - "--output-language=c++" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_grammar_tables) " + - "--spirv-core-grammar=$(location {0}) " + - "--extinst-debuginfo-grammar=$(location {1}) " + - "--extinst-cldebuginfo100-grammar=$(location {2}) " + - "--extension-enum-output=$(location {3}) " + - "--enum-string-mapping-output=$(location {4}) " + - "--output-language=c++" - ).format(*fmtargs), - exec_tools = [":generate_grammar_tables"], + srcs = grammars.values(), + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) -def generate_opencl_tables(version = None): +def generate_opencl_tables(version): if not version: fail("Must specify version", "version") - grammars = [ - "@spirv_headers//:spirv_opencl_grammar_" + version, - ] - outs = ["opencl.std.insts.inc"] - fmtargs = grammars + outs + + grammars = dict( + opencl_grammar = "@spirv_headers//:spirv_opencl_grammar_{}".format(version), + ) + + outs = dict( + opencl_insts_output = "opencl.std.insts.inc", + ) + + cmd = ( + "$(location :generate_grammar_tables)" + + " --extinst-opencl-grammar=$(location {opencl_grammar})" + + " --opencl-insts-output=$(location {opencl_insts_output})" + ).format(**_merge_dicts([grammars, outs])) + native.genrule( name = "gen_opencl_tables_" + version, - srcs = grammars, - outs = outs, - cmd = ( - "$(location :generate_grammar_tables) " + - "--extinst-opencl-grammar=$(location {0}) " + - "--opencl-insts-output=$(location {1})" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_grammar_tables) " + - "--extinst-opencl-grammar=$(location {0}) " + - "--opencl-insts-output=$(location {1})" - ).format(*fmtargs), - exec_tools = [":generate_grammar_tables"], + srcs = grammars.values(), + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) -def generate_glsl_tables(version = None): +def generate_glsl_tables(version): if not version: fail("Must specify version", "version") - grammars = [ - "@spirv_headers//:spirv_glsl_grammar_" + version, - ] - outs = ["glsl.std.450.insts.inc"] - fmtargs = grammars + outs + + grammars = dict( + gsls_grammar = "@spirv_headers//:spirv_glsl_grammar_{}".format(version), + ) + outs = dict( + gsls_insts_outs = "glsl.std.450.insts.inc", + ) + + cmd = ( + "$(location :generate_grammar_tables)" + + " --extinst-glsl-grammar=$(location {gsls_grammar})" + + " --glsl-insts-output=$(location {gsls_insts_outs})" + + " --output-language=c++" + ).format(**_merge_dicts([grammars, outs])) + native.genrule( name = "gen_glsl_tables_" + version, - srcs = grammars, - outs = outs, - cmd = ( - "$(location :generate_grammar_tables) " + - "--extinst-glsl-grammar=$(location {0}) " + - "--glsl-insts-output=$(location {1}) " + - "--output-language=c++" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_grammar_tables) " + - "--extinst-glsl-grammar=$(location {0}) " + - "--glsl-insts-output=$(location {1}) " + - "--output-language=c++" - ).format(*fmtargs), - exec_tools = [":generate_grammar_tables"], + srcs = grammars.values(), + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) def generate_vendor_tables(extension, operand_kind_prefix = ""): if not extension: fail("Must specify extension", "extension") + extension_rule = extension.replace("-", "_").replace(".", "_") - grammars = ["@spirv_headers//:spirv_ext_inst_{}_grammar_unified1".format(extension_rule)] - outs = ["{}.insts.inc".format(extension)] - prefices = [operand_kind_prefix] - fmtargs = grammars + outs + prefices + grammars = dict( + vendor_grammar = "@spirv_headers//:spirv_ext_inst_{}_grammar_unified1".format(extension_rule), + ) + outs = dict( + vendor_insts_output = "{}.insts.inc".format(extension), + ) + cmd = ( + "$(location :generate_grammar_tables)" + + " --extinst-vendor-grammar=$(location {vendor_grammar})" + + " --vendor-insts-output=$(location {vendor_insts_output})" + + " --vendor-operand-kind-prefix={operand_kind_prefix}" + ).format(operand_kind_prefix = operand_kind_prefix, **_merge_dicts([grammars, outs])) + native.genrule( name = "gen_vendor_tables_" + extension_rule, - srcs = grammars, - outs = outs, - cmd = ( - "$(location :generate_grammar_tables) " + - "--extinst-vendor-grammar=$(location {0}) " + - "--vendor-insts-output=$(location {1}) " + - "--vendor-operand-kind-prefix={2}" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_grammar_tables) " + - "--extinst-vendor-grammar=$(location {0}) " + - "--vendor-insts-output=$(location {1}) " + - "--vendor-operand-kind-prefix={2}" - ).format(*fmtargs), - exec_tools = [":generate_grammar_tables"], + srcs = grammars.values(), + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_grammar_tables"], visibility = ["//visibility:private"], ) def generate_extinst_lang_headers(name, grammar = None): if not grammar: fail("Must specify grammar", "grammar") - outs = [name + ".h"] - fmtargs = outs + outs = dict( + extinst_output_path = name + ".h", + ) + cmd = ( + "$(location :generate_language_headers)" + + " --extinst-grammar=$<" + + " --extinst-output-path=$(location {extinst_output_path})" + ).format(**outs) + native.genrule( - name = "gen_extinst_lang_headers_" + name, + name = "gen_extinst_lang_headers_{}".format(name), srcs = [grammar], - outs = outs, - cmd = ( - "$(location :generate_language_headers) " + - "--extinst-grammar=$< " + - "--extinst-output-path=$(location {0})" - ).format(*fmtargs), - cmd_bat = ( - "$(location :generate_language_headers) " + - "--extinst-grammar=$< " + - "--extinst-output-path=$(location {0})" - ).format(*fmtargs), - exec_tools = [":generate_language_headers"], + outs = outs.values(), + cmd = cmd, + cmd_bat = cmd, + tools = [":generate_language_headers"], visibility = ["//visibility:private"], ) - -def base_test(name, srcs, deps = []): - if srcs == []: - return - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "base_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":test_common", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def lint_test(name, srcs, deps = []): - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "lint_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":spirv_tools_lint", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def link_test(name, srcs, deps = []): - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "link_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":link_test_common", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def opt_test(name, srcs, deps = []): - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "opt_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":opt_test_common", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def reduce_test(name, srcs, deps = []): - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "reduce_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":reduce_test_common", - ":spirv_tools_reduce", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def util_test(name, srcs, deps = []): - if name[-5:] != "_test": - name = name + "_test" - native.cc_test( - name = "util_" + name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS, - size = "large", - deps = [ - ":opt_test_common", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - ) - -def val_test(name, srcs = [], copts = [], deps = [], **kwargs): - if name[-5:] != "_test": - name = name + "_test" - if name[:4] != "val_": - name = "val_" + name - native.cc_test( - name = name, - srcs = srcs, - compatible_with = [], - copts = TEST_COPTS + copts, - size = "large", - deps = [ - ":val_test_common", - "@com_google_googletest//:gtest_main", - "@com_google_googletest//:gtest", - "@com_google_effcee//:effcee", - ] + deps, - **kwargs - ) diff --git a/third_party/spirv-tools/docs/downloads.md b/third_party/spirv-tools/docs/downloads.md index 168937a705..853c2bee7d 100644 --- a/third_party/spirv-tools/docs/downloads.md +++ b/third_party/spirv-tools/docs/downloads.md @@ -1,28 +1,31 @@ # Downloads -## Latest builds - -Download the latest builds of the [master](https://github.com/KhronosGroup/SPIRV-Tools/tree/master) branch. - -### Release build -| Windows | Linux | MacOS | -| --- | --- | --- | -| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html) | -| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_release.html) | | - -### Debug build -| Windows | Linux | MacOS | -| --- | --- | --- | -| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_debug.html) | -| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_debug.html) | | - - ## Vulkan SDK -SPIRV-Tools is published as part of the [LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/). +The official releases for SPIRV-Tools can be found on LunarG's +[SDK download page](https://vulkan.lunarg.com/sdk/home). The Vulkan SDK is updated approximately every six weeks. ## Android NDK SPIRV-Tools host executables, and library sources are published as part of the [Android NDK](https://developer.android.com/ndk/downloads). + +## Automated builds + +For convenience, here are also links to the latest builds (HEAD). +Those are untested automated builds. Those are not official releases, nor +are guaranteed to work. Official releases builds are in the Android NDK or +Vulkan SDK. + +Download the latest builds of the [main](https://github.com/KhronosGroup/SPIRV-Tools/tree/main) branch. + +| Platform | Processor | Compiler | Release build | Debug build | +| --- | --- | --- | --- | --- | +| Windows | x86-64 | VisualStudio 2022 (MSVC v143) | Download: status of VS 2022 release build | Download: status of VS 2022 debug build | +| Linux | x86-64 | GCC 9.4 | Download: status of Linux GCC build | Download: status of Linux GCC debug build | +| macOS | x86-64 | Clang 15 | Download: status of macOS Clang build | Download: status of macOS Clang build | + +Note: If you suspect something is wrong with the compiler versions mentioned, +check the scripts and configurations in the [kokoro](../kokoro) source tree, +or the results of the checks on the latest commits on the `main` branch. diff --git a/third_party/spirv-tools/docs/projects.md b/third_party/spirv-tools/docs/projects.md index 8f7f0bcd94..cc88cb3ff3 100644 --- a/third_party/spirv-tools/docs/projects.md +++ b/third_party/spirv-tools/docs/projects.md @@ -34,7 +34,7 @@ through the project workflow: ones. * They determine if the work for a card has been completed. * Normally they are the person (or persons) who can approve and merge a pull - request into the `master` branch. + request into the `main` branch. Our projects organize cards into the following columns: * `Ideas`: Work which could be done, captured either as Cards or Notes. @@ -51,7 +51,7 @@ Our projects organize cards into the following columns: claimed by someone. * `Done`: Issues which have been resolved, by completing their work. * The changes have been applied to the repository, typically by being pushed - into the `master` branch. + into the `main` branch. * Other kinds of work could update repository settings, for example. * `Rejected ideas`: Work which has been considered, but which we don't want implemented. diff --git a/third_party/spirv-tools/external/CMakeLists.txt b/third_party/spirv-tools/external/CMakeLists.txt index 179a4012f9..1ccab19640 100644 --- a/third_party/spirv-tools/external/CMakeLists.txt +++ b/third_party/spirv-tools/external/CMakeLists.txt @@ -30,11 +30,7 @@ if (DEFINED SPIRV-Headers_SOURCE_DIR) # This allows flexible position of the SPIRV-Headers repo. set(SPIRV_HEADER_DIR ${SPIRV-Headers_SOURCE_DIR}) else() - if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers) - set(SPIRV_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers) - else() - set(SPIRV_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers) - endif() + set(SPIRV_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers) endif() if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) @@ -45,13 +41,11 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) # Do this so enclosing projects can use SPIRV-Headers_SOURCE_DIR to find # headers to include. if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) - set(SPIRV_HEADERS_SKIP_INSTALL ON) - set(SPIRV_HEADERS_SKIP_EXAMPLES ON) add_subdirectory(${SPIRV_HEADER_DIR}) endif() else() message(FATAL_ERROR - "SPIRV-Headers was not found - please checkout a copy under external/.") + "SPIRV-Headers was not found - please checkout a copy at external/spirv-headers.") endif() if (NOT ${SPIRV_SKIP_TESTS}) @@ -60,7 +54,9 @@ if (NOT ${SPIRV_SKIP_TESTS}) if (TARGET gmock) message(STATUS "Google Mock already configured") else() - set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest) + if (NOT GMOCK_DIR) + set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest) + endif() if(EXISTS ${GMOCK_DIR}) if(MSVC) # Our tests use ::testing::Combine. Work around a compiler @@ -77,7 +73,7 @@ if (NOT ${SPIRV_SKIP_TESTS}) # gtest requires special defines for building as a shared # library, simply always build as static. push_variable(BUILD_SHARED_LIBS 0) - add_subdirectory(${GMOCK_DIR} EXCLUDE_FROM_ALL) + add_subdirectory(${GMOCK_DIR} ${CMAKE_CURRENT_BINARY_DIR}/googletest EXCLUDE_FROM_ALL) pop_variable(BUILD_SHARED_LIBS) endif() endif() @@ -95,10 +91,22 @@ if (NOT ${SPIRV_SKIP_TESTS}) # Find Effcee and RE2, for testing. + # RE2 depends on Abseil. We set absl_SOURCE_DIR if it is not already set, so + # that effcee can find abseil. + if(NOT TARGET absl::base) + if (NOT absl_SOURCE_DIR) + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/abseil_cpp) + set(absl_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/abseil_cpp" CACHE STRING "Abseil source dir" ) + endif() + endif() + endif() + # First find RE2, since Effcee depends on it. # If already configured, then use that. Otherwise, prefer to find it under 're2' # in this directory. if (NOT TARGET re2) + + # If we are configuring RE2, then turn off its testing. It takes a long time and # does not add much value for us. If an enclosing project configured RE2, then it # has already chosen whether to enable RE2 testing. @@ -156,7 +164,7 @@ if(SPIRV_BUILD_FUZZER) if(NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc) - set(SPIRV_TOOLS_PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake) + set(SPIRV_TOOLS_PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf) if (NOT IS_DIRECTORY ${SPIRV_TOOLS_PROTOBUF_DIR}) message( FATAL_ERROR diff --git a/third_party/spirv-tools/filament-specific-changes.patch b/third_party/spirv-tools/filament-specific-changes.patch deleted file mode 100644 index 8f54585742..0000000000 --- a/third_party/spirv-tools/filament-specific-changes.patch +++ /dev/null @@ -1,162 +0,0 @@ -diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt -index 76b87d8c5..53b3404d1 100755 ---- a/third_party/spirv-tools/CMakeLists.txt -+++ b/third_party/spirv-tools/CMakeLists.txt -@@ -12,7 +12,7 @@ - # See the License for the specific language governing permissions and - # limitations under the License. - --cmake_minimum_required(VERSION 2.8.12) -+cmake_minimum_required(VERSION 3.19) - if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) - endif() -@@ -24,8 +24,16 @@ if (POLICY CMP0054) - endif() - set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -+set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../spirv-headers) -+ -+if (APPLE) -+ set(CMAKE_MACOSX_RPATH ON) -+endif (APPLE) -+set(SPIRV_SKIP_EXECUTABLES_OPTION ON) -+set(SPIRV_SKIP_TESTS_OPTION ON) -+set(SKIP_SPIRV_TOOLS_INSTALL ON) -+ - project(spirv-tools) --enable_testing() - set(SPIRV_TOOLS "SPIRV-Tools") - - include(GNUInstallDirs) -@@ -71,7 +77,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE "Debug") - endif() - --option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL}) - if(NOT ${SKIP_SPIRV_TOOLS_INSTALL}) - set(ENABLE_SPIRV_TOOLS_INSTALL ON) - endif() -@@ -88,7 +93,8 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c - - option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF) - --option(SPIRV_WERROR "Enable error on warning" ON) -+set(SPIRV_WERROR OFF) -+ - if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) - set(COMPILER_IS_LIKE_GNU TRUE) - endif() -@@ -243,7 +249,12 @@ if(NOT COMMAND find_host_program) - endif() - - # Tests require Python3 --find_host_package(PythonInterp 3 REQUIRED) -+if(CMAKE_VERSION VERSION_LESS "3.12" OR ${CMAKE_SYSTEM_NAME} MATCHES "Windows") -+ find_host_package(PythonInterp 3 REQUIRED) -+else() -+ find_package(Python3 COMPONENTS Interpreter) -+ set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") -+endif() - - # Check for symbol exports on Linux. - # At the moment, this check will fail on the OSX build machines for the Android NDK. -@@ -286,11 +297,11 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) - endif() - - # Defaults to OFF if the user didn't set it. --option(SPIRV_SKIP_EXECUTABLES -- "Skip building the executable and tests along with the library" -- ${SPIRV_SKIP_EXECUTABLES}) --option(SPIRV_SKIP_TESTS -- "Skip building tests along with the library" ${SPIRV_SKIP_TESTS}) -+option(SPIRV_SKIP_EXECUTABLES -+ "Skip building the executable and tests along with the library" -+ ${SPIRV_SKIP_EXECUTABLES_OPTION}) -+option(SPIRV_SKIP_TESTS -+ "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) - if ("${SPIRV_SKIP_EXECUTABLES}") - set(SPIRV_SKIP_TESTS ON) - endif() -@@ -334,9 +347,6 @@ endif() - add_subdirectory(source) - add_subdirectory(tools) - --add_subdirectory(test) --add_subdirectory(examples) -- - if(ENABLE_SPIRV_TOOLS_INSTALL) - install( - FILES -@@ -357,38 +367,3 @@ endif() - - set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link") - set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") -- --# Build pkg-config file --# Use a first-class target so it's regenerated when relevant files are updated. --add_custom_target(spirv-tools-pkg-config ALL -- COMMAND ${CMAKE_COMMAND} -- -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -- -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in -- -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc -- -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -- -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -- -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -- -DSPIRV_LIBRARIES=${SPIRV_LIBRARIES} -- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -- DEPENDS "CHANGES" "cmake/SPIRV-Tools.pc.in" "cmake/write_pkg_config.cmake") --add_custom_target(spirv-tools-shared-pkg-config ALL -- COMMAND ${CMAKE_COMMAND} -- -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES -- -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in -- -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc -- -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -- -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -- -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -- -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES} -- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake -- DEPENDS "CHANGES" "cmake/SPIRV-Tools-shared.pc.in" "cmake/write_pkg_config.cmake") -- --# Install pkg-config file --if (ENABLE_SPIRV_TOOLS_INSTALL) -- install( -- FILES -- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc -- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc -- DESTINATION -- ${CMAKE_INSTALL_LIBDIR}/pkgconfig) --endif() -diff --git a/third_party/spirv-tools/source/CMakeLists.txt b/third_party/spirv-tools/source/CMakeLists.txt -index 98559b8fe..0734d6a82 100644 ---- a/third_party/spirv-tools/source/CMakeLists.txt -+++ b/third_party/spirv-tools/source/CMakeLists.txt -@@ -374,13 +374,6 @@ endfunction() - - # Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and - # unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. --add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) --spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) --set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) --target_compile_definitions(${SPIRV_TOOLS}-shared -- PRIVATE SPIRV_TOOLS_IMPLEMENTATION -- PUBLIC SPIRV_TOOLS_SHAREDLIB --) - - if(SPIRV_TOOLS_BUILD_STATIC) - add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) -@@ -396,11 +389,11 @@ if(SPIRV_TOOLS_BUILD_STATIC) - add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) - endif() - -- set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) -+ set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static) - else() - add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) - spirv_tools_default_target_options(${SPIRV_TOOLS}) -- set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) -+ set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}) - endif() - - if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - diff --git a/third_party/spirv-tools/filament-update.sh b/third_party/spirv-tools/filament-update.sh deleted file mode 100644 index 95149ccd44..0000000000 --- a/third_party/spirv-tools/filament-update.sh +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2023 The Android Open Source Project -# 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. - - -# This script is used to update SPIRV-Tools from source. -# This script takes in a git commit hash as an argument. - -#!/usr/bin/env bash - -TOOLS_HASH=$1 - -function sync_khronos_repo() { - local REPO=$1 - local HASH=$2 - pushd . - cd /tmp - rm -rf ${REPO} && git clone git@github.com:KhronosGroup/${REPO}.git - cd ${REPO} - git reset --hard ${HASH} - popd -} - -# First we update SPIRV-Tools to the given git hash -sync_khronos_repo SPIRV-Tools ${TOOLS_HASH} - -rsync -r /tmp/SPIRV-Tools/ ./ --delete -rm -rf .git .github -# Recover the filament specific files lost in the above rsync -git checkout filament-specific-changes.patch FILAMENT_README.md filament-update.sh -git apply filament-specific-changes.patch - -HEADERS_HASH=`grep "spirv_headers_revision':" DEPS | awk '{ print $2 }' | sed "s/[\'\,\\n]//g"` - -# Next we update SPIRV-Headers to the right hash (dependency as given by SPIRV-Tools) -sync_khronos_repo SPIRV-Headers ${HEADERS_HASH} - -pushd . -cd ../spirv-headers -rsync -r /tmp/SPIRV-Headers/ ./ --delete -rm -rf .git .github -# Recover the filament specific files lost in the above rsync -git checkout filament-specific-changes.patch FILAMENT_README.md -git apply filament-specific-changes.patch -popd diff --git a/third_party/spirv-tools/include/spirv-tools/instrument.hpp b/third_party/spirv-tools/include/spirv-tools/instrument.hpp deleted file mode 100644 index a75561b508..0000000000 --- a/third_party/spirv-tools/include/spirv-tools/instrument.hpp +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// Copyright (c) 2018 Valve Corporation -// Copyright (c) 2018 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_ -#define INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_ - -// Shader Instrumentation Interface -// -// This file provides an external interface for applications that wish to -// communicate with shaders instrumented by passes created by: -// -// CreateInstBindlessCheckPass -// CreateInstBuffAddrCheckPass -// CreateInstDebugPrintfPass -// -// More detailed documentation of these routines can be found in optimizer.hpp - -namespace spvtools { - -// Stream Output Buffer Offsets -// -// The following values provide offsets into the output buffer struct -// generated by InstrumentPass::GenDebugStreamWrite. This method is utilized -// by InstBindlessCheckPass, InstBuffAddrCheckPass, and InstDebugPrintfPass. -// -// The 1st member of the debug output buffer contains a set of flags -// controlling the behavior of instrumentation code. -static const int kDebugOutputFlagsOffset = 0; - -// Values stored at kDebugOutputFlagsOffset -enum kInstFlags : unsigned int { - kInstBufferOOBEnable = 0x1, -}; - -// The 2nd member of the debug output buffer contains the next available word -// in the data stream to be written. Shaders will atomically read and update -// this value so as not to overwrite each others records. This value must be -// initialized to zero -static const int kDebugOutputSizeOffset = 1; - -// The 3rd member of the output buffer is the start of the stream of records -// written by the instrumented shaders. Each record represents a validation -// error. The format of the records is documented below. -static const int kDebugOutputDataOffset = 2; - -// Common Stream Record Offsets -// -// The following are offsets to fields which are common to all records written -// to the output stream. -// -// Each record first contains the size of the record in 32-bit words, including -// the size word. -static const int kInstCommonOutSize = 0; - -// This is the shader id passed by the layer when the instrumentation pass is -// created. -static const int kInstCommonOutShaderId = 1; - -// This is the ordinal position of the instruction within the SPIR-V shader -// which generated the validation error. -static const int kInstCommonOutInstructionIdx = 2; - -// This is the stage which generated the validation error. This word is used -// to determine the contents of the next two words in the record. -// 0:Vert, 1:TessCtrl, 2:TessEval, 3:Geom, 4:Frag, 5:Compute -static const int kInstCommonOutStageIdx = 3; -static const int kInstCommonOutCnt = 4; - -// Stage-specific Stream Record Offsets -// -// Each stage will contain different values in the next set of words of the -// record used to identify which instantiation of the shader generated the -// validation error. -// -// Vertex Shader Output Record Offsets -static const int kInstVertOutVertexIndex = kInstCommonOutCnt; -static const int kInstVertOutInstanceIndex = kInstCommonOutCnt + 1; -static const int kInstVertOutUnused = kInstCommonOutCnt + 2; - -// Frag Shader Output Record Offsets -static const int kInstFragOutFragCoordX = kInstCommonOutCnt; -static const int kInstFragOutFragCoordY = kInstCommonOutCnt + 1; -static const int kInstFragOutUnused = kInstCommonOutCnt + 2; - -// Compute Shader Output Record Offsets -static const int kInstCompOutGlobalInvocationIdX = kInstCommonOutCnt; -static const int kInstCompOutGlobalInvocationIdY = kInstCommonOutCnt + 1; -static const int kInstCompOutGlobalInvocationIdZ = kInstCommonOutCnt + 2; - -// Tessellation Control Shader Output Record Offsets -static const int kInstTessCtlOutInvocationId = kInstCommonOutCnt; -static const int kInstTessCtlOutPrimitiveId = kInstCommonOutCnt + 1; -static const int kInstTessCtlOutUnused = kInstCommonOutCnt + 2; - -// Tessellation Eval Shader Output Record Offsets -static const int kInstTessEvalOutPrimitiveId = kInstCommonOutCnt; -static const int kInstTessEvalOutTessCoordU = kInstCommonOutCnt + 1; -static const int kInstTessEvalOutTessCoordV = kInstCommonOutCnt + 2; - -// Geometry Shader Output Record Offsets -static const int kInstGeomOutPrimitiveId = kInstCommonOutCnt; -static const int kInstGeomOutInvocationId = kInstCommonOutCnt + 1; -static const int kInstGeomOutUnused = kInstCommonOutCnt + 2; - -// Ray Tracing Shader Output Record Offsets -static const int kInstRayTracingOutLaunchIdX = kInstCommonOutCnt; -static const int kInstRayTracingOutLaunchIdY = kInstCommonOutCnt + 1; -static const int kInstRayTracingOutLaunchIdZ = kInstCommonOutCnt + 2; - -// Mesh Shader Output Record Offsets -static const int kInstMeshOutGlobalInvocationIdX = kInstCommonOutCnt; -static const int kInstMeshOutGlobalInvocationIdY = kInstCommonOutCnt + 1; -static const int kInstMeshOutGlobalInvocationIdZ = kInstCommonOutCnt + 2; - -// Task Shader Output Record Offsets -static const int kInstTaskOutGlobalInvocationIdX = kInstCommonOutCnt; -static const int kInstTaskOutGlobalInvocationIdY = kInstCommonOutCnt + 1; -static const int kInstTaskOutGlobalInvocationIdZ = kInstCommonOutCnt + 2; - -// Size of Common and Stage-specific Members -static const int kInstStageOutCnt = kInstCommonOutCnt + 3; - -// Validation Error Code Offset -// -// This identifies the validation error. It also helps to identify -// how many words follow in the record and their meaning. -static const int kInstValidationOutError = kInstStageOutCnt; - -// Validation-specific Output Record Offsets -// -// Each different validation will generate a potentially different -// number of words at the end of the record giving more specifics -// about the validation error. -// -// A bindless bounds error will output the index and the bound. -static const int kInstBindlessBoundsOutDescIndex = kInstStageOutCnt + 1; -static const int kInstBindlessBoundsOutDescBound = kInstStageOutCnt + 2; -static const int kInstBindlessBoundsOutUnused = kInstStageOutCnt + 3; -static const int kInstBindlessBoundsOutCnt = kInstStageOutCnt + 4; - -// A descriptor uninitialized error will output the index. -static const int kInstBindlessUninitOutDescIndex = kInstStageOutCnt + 1; -static const int kInstBindlessUninitOutUnused = kInstStageOutCnt + 2; -static const int kInstBindlessUninitOutUnused2 = kInstStageOutCnt + 3; -static const int kInstBindlessUninitOutCnt = kInstStageOutCnt + 4; - -// A buffer out-of-bounds error will output the descriptor -// index, the buffer offset and the buffer size -static const int kInstBindlessBuffOOBOutDescIndex = kInstStageOutCnt + 1; -static const int kInstBindlessBuffOOBOutBuffOff = kInstStageOutCnt + 2; -static const int kInstBindlessBuffOOBOutBuffSize = kInstStageOutCnt + 3; -static const int kInstBindlessBuffOOBOutCnt = kInstStageOutCnt + 4; - -// A buffer address unalloc error will output the 64-bit pointer in -// two 32-bit pieces, lower bits first. -static const int kInstBuffAddrUnallocOutDescPtrLo = kInstStageOutCnt + 1; -static const int kInstBuffAddrUnallocOutDescPtrHi = kInstStageOutCnt + 2; -static const int kInstBuffAddrUnallocOutCnt = kInstStageOutCnt + 3; - -// Maximum Output Record Member Count -static const int kInstMaxOutCnt = kInstStageOutCnt + 4; - -// Validation Error Codes -// -// These are the possible validation error codes. -static const int kInstErrorBindlessBounds = 0; -static const int kInstErrorBindlessUninit = 1; -static const int kInstErrorBuffAddrUnallocRef = 2; -// Deleted: static const int kInstErrorBindlessBuffOOB = 3; -// This comment will will remain for 2 releases to allow -// for the transition of all builds. Buffer OOB is -// generating the following four differentiated codes instead: -static const int kInstErrorBuffOOBUniform = 4; -static const int kInstErrorBuffOOBStorage = 5; -static const int kInstErrorBuffOOBUniformTexel = 6; -static const int kInstErrorBuffOOBStorageTexel = 7; -static const int kInstErrorMax = kInstErrorBuffOOBStorageTexel; - -// Direct Input Buffer Offsets -// -// The following values provide member offsets into the input buffers -// consumed by InstrumentPass::GenDebugDirectRead(). This method is utilized -// by InstBindlessCheckPass. -// -// The only object in an input buffer is a runtime array of unsigned -// integers. Each validation will have its own formatting of this array. -static const int kDebugInputDataOffset = 0; - -// Debug Buffer Bindings -// -// These are the bindings for the different buffers which are -// read or written by the instrumentation passes. -// -// This is the output buffer written by InstBindlessCheckPass, -// InstBuffAddrCheckPass, and possibly other future validations. -static const int kDebugOutputBindingStream = 0; - -// The binding for the input buffer read by InstBindlessCheckPass. -static const int kDebugInputBindingBindless = 1; - -// The binding for the input buffer read by InstBuffAddrCheckPass. -static const int kDebugInputBindingBuffAddr = 2; - -// This is the output buffer written by InstDebugPrintfPass. -static const int kDebugOutputPrintfStream = 3; - -// Bindless Validation Input Buffer Format -// -// An input buffer for bindless validation consists of a single array of -// unsigned integers we will call Data[]. This array is formatted as follows. -// -// At offset kDebugInputBindlessInitOffset in Data[] is a single uint which -// gives an offset to the start of the bindless initialization data. More -// specifically, if the following value is zero, we know that the descriptor at -// (set = s, binding = b, index = i) is not initialized; if the value is -// non-zero, and the descriptor points to a buffer, the value is the length of -// the buffer in bytes and can be used to check for out-of-bounds buffer -// references: -// Data[ i + Data[ b + Data[ s + Data[ kDebugInputBindlessInitOffset ] ] ] ] -static const int kDebugInputBindlessInitOffset = 0; - -// At offset kDebugInputBindlessOffsetLengths is some number of uints which -// provide the bindless length data. More specifically, the number of -// descriptors at (set=s, binding=b) is: -// Data[ Data[ s + kDebugInputBindlessOffsetLengths ] + b ] -static const int kDebugInputBindlessOffsetLengths = 1; - -// Buffer Device Address Input Buffer Format -// -// An input buffer for buffer device address validation consists of a single -// array of unsigned 64-bit integers we will call Data[]. This array is -// formatted as follows: -// -// At offset kDebugInputBuffAddrPtrOffset is a list of sorted valid buffer -// addresses. The list is terminated with the address 0xffffffffffffffff. -// If 0x0 is not a valid buffer address, this address is inserted at the -// start of the list. -// -static const int kDebugInputBuffAddrPtrOffset = 1; -// -// At offset kDebugInputBuffAddrLengthOffset in Data[] is a single uint64 which -// gives an offset to the start of the buffer length data. More -// specifically, for a buffer whose pointer is located at input buffer offset -// i, the length is located at: -// -// Data[ i - kDebugInputBuffAddrPtrOffset -// + Data[ kDebugInputBuffAddrLengthOffset ] ] -// -// The length associated with the 0xffffffffffffffff address is zero. If -// not a valid buffer, the length associated with the 0x0 address is zero. -static const int kDebugInputBuffAddrLengthOffset = 0; - -} // namespace spvtools - -#endif // INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_ diff --git a/third_party/spirv-tools/include/spirv-tools/libspirv.h b/third_party/spirv-tools/include/spirv-tools/libspirv.h index b549efbada..2ac36a6a1f 100644 --- a/third_party/spirv-tools/include/spirv-tools/libspirv.h +++ b/third_party/spirv-tools/include/spirv-tools/libspirv.h @@ -33,15 +33,19 @@ extern "C" { #else #define SPIRV_TOOLS_EXPORT __declspec(dllimport) #endif +#define SPIRV_TOOLS_LOCAL #else #if defined(SPIRV_TOOLS_IMPLEMENTATION) #define SPIRV_TOOLS_EXPORT __attribute__((visibility("default"))) +#define SPIRV_TOOLS_LOCAL __attribute__((visibility("hidden"))) #else #define SPIRV_TOOLS_EXPORT +#define SPIRV_TOOLS_LOCAL #endif #endif #else #define SPIRV_TOOLS_EXPORT +#define SPIRV_TOOLS_LOCAL #endif // Helpers @@ -143,6 +147,7 @@ typedef enum spv_operand_type_t { // may be larger than 32, which would require such a typed literal value to // occupy multiple SPIR-V words. SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER, + SPV_OPERAND_TYPE_LITERAL_FLOAT, // Always 32-bit float. // Set 3: The literal string operand type. SPV_OPERAND_TYPE_LITERAL_STRING, @@ -170,6 +175,7 @@ typedef enum spv_operand_type_t { SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS, // SPIR-V Sec 3.29 SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO, // SPIR-V Sec 3.30 SPV_OPERAND_TYPE_CAPABILITY, // SPIR-V Sec 3.31 + SPV_OPERAND_TYPE_FPENCODING, // SPIR-V Sec 3.51 // NOTE: New concrete enum values should be added at the end. @@ -231,6 +237,8 @@ typedef enum spv_operand_type_t { // assemble regardless of where they occur -- literals, IDs, immediate // integers, etc. SPV_OPERAND_TYPE_OPTIONAL_CIV, + // An optional floating point encoding enum + SPV_OPERAND_TYPE_OPTIONAL_FPENCODING, // A variable operand represents zero or more logical operands. // In an instruction definition, this may only appear at the end of the @@ -285,6 +293,40 @@ typedef enum spv_operand_type_t { // An optional packed vector format SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT, + // Concrete operand types for cooperative matrix. + SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS, + // An optional cooperative matrix operands + SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS, + SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_LAYOUT, + SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_USE, + + // Enum type from SPV_INTEL_global_variable_fpga_decorations + SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER, + // Enum type from SPV_INTEL_global_variable_host_access + SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER, + // Enum type from SPV_INTEL_cache_controls + SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL, + // Enum type from SPV_INTEL_cache_controls + SPV_OPERAND_TYPE_STORE_CACHE_CONTROL, + // Enum type from SPV_INTEL_maximum_registers + SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS, + // Enum type from SPV_NV_raw_access_chains + SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS, + // Optional enum type from SPV_NV_raw_access_chains + SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS, + // Enum type from SPV_NV_tensor_addressing + SPV_OPERAND_TYPE_TENSOR_CLAMP_MODE, + // Enum type from SPV_NV_cooperative_matrix2 + SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE, + // Enum type from SPV_NV_cooperative_matrix2 + SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS, + // Optional types from SPV_INTEL_subgroup_matrix_multiply_accumulate + SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS, + SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS, + + SPV_OPERAND_TYPE_COOPERATIVE_VECTOR_MATRIX_LAYOUT, + SPV_OPERAND_TYPE_COMPONENT_TYPE, + // This is a sentinel value, and does not represent an operand type. // It should come last. SPV_OPERAND_TYPE_NUM_OPERAND_TYPES, @@ -310,6 +352,7 @@ typedef enum spv_ext_inst_type_t { SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100, SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION, SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100, + SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION, // Multiple distinct extended instruction set types could return this // value, if they are prefixed with NonSemantic. and are otherwise @@ -354,6 +397,11 @@ typedef enum spv_binary_to_text_options_t { SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES = SPV_BIT(6), // Add some comments to the generated assembly SPV_BINARY_TO_TEXT_OPTION_COMMENT = SPV_BIT(7), + // Use nested indentation for more readable SPIR-V + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT = SPV_BIT(8), + // Reorder blocks to match the structured control flow of SPIR-V to increase + // readability. + SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS = SPV_BIT(9), SPV_FORCE_32_BIT_ENUM(spv_binary_to_text_options_t) } spv_binary_to_text_options_t; @@ -402,6 +450,19 @@ typedef struct spv_parsed_instruction_t { uint16_t num_operands; } spv_parsed_instruction_t; +typedef struct spv_parsed_header_t { + // The magic number of the SPIR-V module. + uint32_t magic; + // Version number. + uint32_t version; + // Generator's magic number. + uint32_t generator; + // IDs bound for this module (0 < id < bound). + uint32_t bound; + // reserved. + uint32_t reserved; +} spv_parsed_header_t; + typedef struct spv_const_binary_t { const uint32_t* code; const size_t wordCount; @@ -441,6 +502,8 @@ typedef struct spv_reducer_options_t spv_reducer_options_t; typedef struct spv_fuzzer_options_t spv_fuzzer_options_t; +typedef struct spv_optimizer_t spv_optimizer_t; + // Type Definitions typedef spv_const_binary_t* spv_const_binary; @@ -483,6 +546,7 @@ SPIRV_TOOLS_EXPORT const char* spvSoftwareVersionDetailsString(void); // SPV_ENV_VULKAN_1_1_SPIRV_1_4 -> SPIR-V 1.4 // SPV_ENV_VULKAN_1_2 -> SPIR-V 1.5 // SPV_ENV_VULKAN_1_3 -> SPIR-V 1.6 +// SPV_ENV_VULKAN_1_4 -> SPIR-V 1.6 // Consult the description of API entry points for specific rules. typedef enum { SPV_ENV_UNIVERSAL_1_0, // SPIR-V 1.0 latest revision, no other restrictions. @@ -520,6 +584,7 @@ typedef enum { SPV_ENV_UNIVERSAL_1_6, // SPIR-V 1.6 latest revision, no other restrictions. SPV_ENV_VULKAN_1_3, // Vulkan 1.3 latest revision. + SPV_ENV_VULKAN_1_4, // Vulkan 1.4 latest revision. SPV_ENV_MAX // Keep this as the last enum value. } spv_target_env; @@ -670,6 +735,11 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetSkipBlockLayout( SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetAllowLocalSizeId( spv_validator_options options, bool val); +// Allow Offset (in addition to ConstOffset) for texture operations. +// Was added for VK_KHR_maintenance8 +SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetAllowOffsetTextureOperand( + spv_validator_options options, bool val); + // Whether friendly names should be used in validation error messages. SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetFriendlyNames( spv_validator_options options, bool val); @@ -900,6 +970,70 @@ SPIRV_TOOLS_EXPORT spv_result_t spvBinaryParse( const size_t num_words, spv_parsed_header_fn_t parse_header, spv_parsed_instruction_fn_t parse_instruction, spv_diagnostic* diagnostic); +// The optimizer interface. + +// A pointer to a function that accepts a log message from an optimizer. +typedef void (*spv_message_consumer)( + spv_message_level_t, const char*, const spv_position_t*, const char*); + +// Creates and returns an optimizer object. This object must be passed to +// optimizer APIs below and is valid until passed to spvOptimizerDestroy. +SPIRV_TOOLS_EXPORT spv_optimizer_t* spvOptimizerCreate(spv_target_env env); + +// Destroys the given optimizer object. +SPIRV_TOOLS_EXPORT void spvOptimizerDestroy(spv_optimizer_t* optimizer); + +// Sets an spv_message_consumer on an optimizer object. +SPIRV_TOOLS_EXPORT void spvOptimizerSetMessageConsumer( + spv_optimizer_t* optimizer, spv_message_consumer consumer); + +// Registers passes that attempt to legalize the generated code. +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterLegalizationPasses( + spv_optimizer_t* optimizer); + +// Registers passes that attempt to improve performance of generated code. +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterPerformancePasses( + spv_optimizer_t* optimizer); + +// Registers passes that attempt to improve the size of generated code. +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterSizePasses( + spv_optimizer_t* optimizer); + +// Registers a pass specified by a flag in an optimizer object. +SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassFromFlag( + spv_optimizer_t* optimizer, const char* flag); + +// Registers passes specified by length number of flags in an optimizer object. +// Passes may remove interface variables that are unused. +SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassesFromFlags( + spv_optimizer_t* optimizer, const char** flags, const size_t flag_count); + +// Registers passes specified by length number of flags in an optimizer object. +// Passes will not remove interface variables. +SPIRV_TOOLS_EXPORT bool +spvOptimizerRegisterPassesFromFlagsWhilePreservingTheInterface( + spv_optimizer_t* optimizer, const char** flags, const size_t flag_count); + +// Optimizes the SPIR-V code of size |word_count| pointed to by |binary| and +// returns an optimized spv_binary in |optimized_binary|. +// +// Returns SPV_SUCCESS on successful optimization, whether or not the module is +// modified. Returns an SPV_ERROR_* if the module fails to validate or if +// errors occur when processing using any of the registered passes. In that +// case, no further passes are executed and the |optimized_binary| contents may +// be invalid. +// +// By default, the binary is validated before any transforms are performed, +// and optionally after each transform. Validation uses SPIR-V spec rules +// for the SPIR-V version named in the binary's header (at word offset 1). +// Additionally, if the target environment is a client API (such as +// Vulkan 1.1), then validate for that client API version, to the extent +// that it is verifiable from data in the binary itself, or from the +// validator options set on the optimizer options. +SPIRV_TOOLS_EXPORT spv_result_t spvOptimizerRun( + spv_optimizer_t* optimizer, const uint32_t* binary, const size_t word_count, + spv_binary* optimized_binary, const spv_optimizer_options options); + #ifdef __cplusplus } #endif diff --git a/third_party/spirv-tools/include/spirv-tools/libspirv.hpp b/third_party/spirv-tools/include/spirv-tools/libspirv.hpp index 408e3ebb23..1a75868a02 100644 --- a/third_party/spirv-tools/include/spirv-tools/libspirv.hpp +++ b/third_party/spirv-tools/include/spirv-tools/libspirv.hpp @@ -20,7 +20,7 @@ #include #include -#include "spirv-tools/libspirv.h" +#include "libspirv.h" namespace spvtools { @@ -31,8 +31,13 @@ using MessageConsumer = std::function; +using HeaderParser = std::function; +using InstructionParser = + std::function; + // C++ RAII wrapper around the C context object spv_context. -class Context { +class SPIRV_TOOLS_EXPORT Context { public: // Constructs a context targeting the given environment |env|. // @@ -68,7 +73,7 @@ class Context { }; // A RAII wrapper around a validator options object. -class ValidatorOptions { +class SPIRV_TOOLS_EXPORT ValidatorOptions { public: ValidatorOptions() : options_(spvValidatorOptionsCreate()) {} ~ValidatorOptions() { spvValidatorOptionsDestroy(options_); } @@ -121,6 +126,12 @@ class ValidatorOptions { spvValidatorOptionsSetAllowLocalSizeId(options_, val); } + // Allow Offset (in addition to ConstOffset) for texture + // operations. Was added for VK_KHR_maintenance8 + void SetAllowOffsetTextureOperand(bool val) { + spvValidatorOptionsSetAllowOffsetTextureOperand(options_, val); + } + // Records whether or not the validator should relax the rules on pointer // usage in logical addressing mode. // @@ -158,7 +169,7 @@ class ValidatorOptions { }; // A C++ wrapper around an optimization options object. -class OptimizerOptions { +class SPIRV_TOOLS_EXPORT OptimizerOptions { public: OptimizerOptions() : options_(spvOptimizerOptionsCreate()) {} ~OptimizerOptions() { spvOptimizerOptionsDestroy(options_); } @@ -200,7 +211,7 @@ class OptimizerOptions { }; // A C++ wrapper around a reducer options object. -class ReducerOptions { +class SPIRV_TOOLS_EXPORT ReducerOptions { public: ReducerOptions() : options_(spvReducerOptionsCreate()) {} ~ReducerOptions() { spvReducerOptionsDestroy(options_); } @@ -231,7 +242,7 @@ class ReducerOptions { }; // A C++ wrapper around a fuzzer options object. -class FuzzerOptions { +class SPIRV_TOOLS_EXPORT FuzzerOptions { public: FuzzerOptions() : options_(spvFuzzerOptionsCreate()) {} ~FuzzerOptions() { spvFuzzerOptionsDestroy(options_); } @@ -278,7 +289,7 @@ class FuzzerOptions { // provides methods for assembling, disassembling, and validating. // // Instances of this class provide basic thread-safety guarantee. -class SpirvTools { +class SPIRV_TOOLS_EXPORT SpirvTools { public: enum { // Default assembling option used by assemble(): @@ -336,6 +347,23 @@ class SpirvTools { std::string* text, uint32_t options = kDefaultDisassembleOption) const; + // Parses a SPIR-V binary, specified as counted sequence of 32-bit words. + // Parsing feedback is provided via two callbacks provided as std::function. + // In a valid parse the parsed-header callback is called once, and + // then the parsed-instruction callback is called once for each instruction + // in the stream. + // Returns true on successful parsing. + // If diagnostic is non-null, a diagnostic is emitted on failed parsing. + // If diagnostic is null the context's message consumer + // will be used to emit any errors. If a callback returns anything other than + // SPV_SUCCESS, then that status code is returned, no further callbacks are + // issued, and no additional diagnostics are emitted. + // This is a wrapper around the C API spvBinaryParse. + bool Parse(const std::vector& binary, + const HeaderParser& header_parser, + const InstructionParser& instruction_parser, + spv_diagnostic* diagnostic = nullptr); + // Validates the given SPIR-V |binary|. Returns true if no issues are found. // Otherwise, returns false and communicates issues via the message consumer // registered. @@ -366,7 +394,8 @@ class SpirvTools { bool IsValid() const; private: - struct Impl; // Opaque struct for holding the data fields used by this class. + struct SPIRV_TOOLS_LOCAL + Impl; // Opaque struct for holding the data fields used by this class. std::unique_ptr impl_; // Unique pointer to implementation data. }; diff --git a/third_party/spirv-tools/include/spirv-tools/linker.hpp b/third_party/spirv-tools/include/spirv-tools/linker.hpp index d2f3e72ca2..9037b94889 100644 --- a/third_party/spirv-tools/include/spirv-tools/linker.hpp +++ b/third_party/spirv-tools/include/spirv-tools/linker.hpp @@ -16,7 +16,6 @@ #define INCLUDE_SPIRV_TOOLS_LINKER_HPP_ #include - #include #include @@ -24,13 +23,8 @@ namespace spvtools { -class LinkerOptions { +class SPIRV_TOOLS_EXPORT LinkerOptions { public: - LinkerOptions() - : create_library_(false), - verify_ids_(false), - allow_partial_linkage_(false) {} - // Returns whether a library or an executable should be produced by the // linking phase. // @@ -63,10 +57,22 @@ class LinkerOptions { allow_partial_linkage_ = allow_partial_linkage; } + bool GetUseHighestVersion() const { return use_highest_version_; } + void SetUseHighestVersion(bool use_highest_vers) { + use_highest_version_ = use_highest_vers; + } + + bool GetAllowPtrTypeMismatch() const { return allow_ptr_type_mismatch_; } + void SetAllowPtrTypeMismatch(bool allow_ptr_type_mismatch) { + allow_ptr_type_mismatch_ = allow_ptr_type_mismatch; + } + private: - bool create_library_; - bool verify_ids_; - bool allow_partial_linkage_; + bool create_library_{false}; + bool verify_ids_{false}; + bool allow_partial_linkage_{false}; + bool use_highest_version_{false}; + bool allow_ptr_type_mismatch_{false}; }; // Links one or more SPIR-V modules into a new SPIR-V module. That is, combine @@ -83,14 +89,15 @@ class LinkerOptions { // * Some entry points were defined multiple times; // * Some imported symbols did not have an exported counterpart; // * Possibly other reasons. -spv_result_t Link(const Context& context, - const std::vector>& binaries, - std::vector* linked_binary, - const LinkerOptions& options = LinkerOptions()); -spv_result_t Link(const Context& context, const uint32_t* const* binaries, - const size_t* binary_sizes, size_t num_binaries, - std::vector* linked_binary, - const LinkerOptions& options = LinkerOptions()); +SPIRV_TOOLS_EXPORT spv_result_t +Link(const Context& context, const std::vector>& binaries, + std::vector* linked_binary, + const LinkerOptions& options = LinkerOptions()); +SPIRV_TOOLS_EXPORT spv_result_t +Link(const Context& context, const uint32_t* const* binaries, + const size_t* binary_sizes, size_t num_binaries, + std::vector* linked_binary, + const LinkerOptions& options = LinkerOptions()); } // namespace spvtools diff --git a/third_party/spirv-tools/include/spirv-tools/linter.hpp b/third_party/spirv-tools/include/spirv-tools/linter.hpp index 52ed5a4672..ccbcf0c179 100644 --- a/third_party/spirv-tools/include/spirv-tools/linter.hpp +++ b/third_party/spirv-tools/include/spirv-tools/linter.hpp @@ -24,7 +24,7 @@ namespace spvtools { // provides a method for linting. // // Instances of this class provides basic thread-safety guarantee. -class Linter { +class SPIRV_TOOLS_EXPORT Linter { public: explicit Linter(spv_target_env env); @@ -40,7 +40,7 @@ class Linter { bool Run(const uint32_t* binary, size_t binary_size); private: - struct Impl; + struct SPIRV_TOOLS_LOCAL Impl; std::unique_ptr impl_; }; } // namespace spvtools diff --git a/third_party/spirv-tools/include/spirv-tools/optimizer.hpp b/third_party/spirv-tools/include/spirv-tools/optimizer.hpp index aa6a614ea6..9427b01eb3 100644 --- a/third_party/spirv-tools/include/spirv-tools/optimizer.hpp +++ b/third_party/spirv-tools/include/spirv-tools/optimizer.hpp @@ -37,14 +37,14 @@ struct DescriptorSetAndBinding; // provides methods for registering optimization passes and optimizing. // // Instances of this class provides basic thread-safety guarantee. -class Optimizer { +class SPIRV_TOOLS_EXPORT Optimizer { public: // The token for an optimization pass. It is returned via one of the // Create*Pass() standalone functions at the end of this header file and // consumed by the RegisterPass() method. Tokens are one-time objects that // only support move; copying is not allowed. struct PassToken { - struct Impl; // Opaque struct for holding internal data. + struct SPIRV_TOOLS_LOCAL Impl; // Opaque struct for holding internal data. PassToken(std::unique_ptr); @@ -97,12 +97,20 @@ class Optimizer { // Registers passes that attempt to improve performance of generated code. // This sequence of passes is subject to constant review and will change // from time to time. + // + // If |preserve_interface| is true, all non-io variables in the entry point + // interface are considered live and are not eliminated. Optimizer& RegisterPerformancePasses(); + Optimizer& RegisterPerformancePasses(bool preserve_interface); // Registers passes that attempt to improve the size of generated code. // This sequence of passes is subject to constant review and will change // from time to time. + // + // If |preserve_interface| is true, all non-io variables in the entry point + // interface are considered live and are not eliminated. Optimizer& RegisterSizePasses(); + Optimizer& RegisterSizePasses(bool preserve_interface); // Registers passes that attempt to legalize the generated code. // @@ -112,7 +120,11 @@ class Optimizer { // // This sequence of passes is subject to constant review and will change // from time to time. + // + // If |preserve_interface| is true, all non-io variables in the entry point + // interface are considered live and are not eliminated. Optimizer& RegisterLegalizationPasses(); + Optimizer& RegisterLegalizationPasses(bool preserve_interface); // Register passes specified in the list of |flags|. Each flag must be a // string of a form accepted by Optimizer::FlagHasValidForm(). @@ -121,8 +133,13 @@ class Optimizer { // error message is emitted to the MessageConsumer object (use // Optimizer::SetMessageConsumer to define a message consumer, if needed). // + // If |preserve_interface| is true, all non-io variables in the entry point + // interface are considered live and are not eliminated. + // // If all the passes are registered successfully, it returns true. bool RegisterPassesFromFlags(const std::vector& flags); + bool RegisterPassesFromFlags(const std::vector& flags, + bool preserve_interface); // Registers the optimization pass associated with |flag|. This only accepts // |flag| values of the form "--pass_name[=pass_args]". If no such pass @@ -139,7 +156,11 @@ class Optimizer { // // --legalize-hlsl: Registers all passes that legalize SPIR-V generated by an // HLSL front-end. + // + // If |preserve_interface| is true, all non-io variables in the entry point + // interface are considered live and are not eliminated. bool RegisterPassFromFlag(const std::string& flag); + bool RegisterPassFromFlag(const std::string& flag, bool preserve_interface); // Validates that |flag| has a valid format. Strings accepted: // @@ -218,7 +239,7 @@ class Optimizer { Optimizer& SetValidateAfterAll(bool validate); private: - struct Impl; // Opaque struct for holding internal data. + struct SPIRV_TOOLS_LOCAL Impl; // Opaque struct for holding internal data. std::unique_ptr impl_; // Unique pointer to internal data. }; @@ -525,8 +546,10 @@ Optimizer::PassToken CreateDeadInsertElimPass(); // If |remove_outputs| is true, allow outputs to be removed from the interface. // This is only safe if the caller knows that there is no corresponding input // variable in the following shader. It is false by default. -Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface = false, - bool remove_outputs = false); +Optimizer::PassToken CreateAggressiveDCEPass(); +Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface); +Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface, + bool remove_outputs); // Creates a remove-unused-interface-variables pass. // Removes variables referenced on the |OpEntryPoint| instruction that are not @@ -724,76 +747,6 @@ Optimizer::PassToken CreateReduceLoadSizePass( // them into a single instruction where possible. Optimizer::PassToken CreateCombineAccessChainsPass(); -// Create a pass to instrument bindless descriptor checking -// This pass instruments all bindless references to check that descriptor -// array indices are inbounds, and if the descriptor indexing extension is -// enabled, that the descriptor has been initialized. If the reference is -// invalid, a record is written to the debug output buffer (if space allows) -// and a null value is returned. This pass is designed to support bindless -// validation in the Vulkan validation layers. -// -// TODO(greg-lunarg): Add support for buffer references. Currently only does -// checking for image references. -// -// Dead code elimination should be run after this pass as the original, -// potentially invalid code is not removed and could cause undefined behavior, -// including crashes. It may also be beneficial to run Simplification -// (ie Constant Propagation), DeadBranchElim and BlockMerge after this pass to -// optimize instrument code involving the testing of compile-time constants. -// It is also generally recommended that this pass (and all -// instrumentation passes) be run after any legalization and optimization -// passes. This will give better analysis for the instrumentation and avoid -// potentially de-optimizing the instrument code, for example, inlining -// the debug record output function throughout the module. -// -// The instrumentation will read and write buffers in debug -// descriptor set |desc_set|. It will write |shader_id| in each output record -// to identify the shader module which generated the record. -// |desc_length_enable| controls instrumentation of runtime descriptor array -// references, |desc_init_enable| controls instrumentation of descriptor -// initialization checking, and |buff_oob_enable| controls instrumentation -// of storage and uniform buffer bounds checking, all of which require input -// buffer support. |texbuff_oob_enable| controls instrumentation of texel -// buffers, which does not require input buffer support. -Optimizer::PassToken CreateInstBindlessCheckPass( - uint32_t desc_set, uint32_t shader_id, bool desc_length_enable = false, - bool desc_init_enable = false, bool buff_oob_enable = false, - bool texbuff_oob_enable = false); - -// Create a pass to instrument physical buffer address checking -// This pass instruments all physical buffer address references to check that -// all referenced bytes fall in a valid buffer. If the reference is -// invalid, a record is written to the debug output buffer (if space allows) -// and a null value is returned. This pass is designed to support buffer -// address validation in the Vulkan validation layers. -// -// Dead code elimination should be run after this pass as the original, -// potentially invalid code is not removed and could cause undefined behavior, -// including crashes. Instruction simplification would likely also be -// beneficial. It is also generally recommended that this pass (and all -// instrumentation passes) be run after any legalization and optimization -// passes. This will give better analysis for the instrumentation and avoid -// potentially de-optimizing the instrument code, for example, inlining -// the debug record output function throughout the module. -// -// The instrumentation will read and write buffers in debug -// descriptor set |desc_set|. It will write |shader_id| in each output record -// to identify the shader module which generated the record. -Optimizer::PassToken CreateInstBuffAddrCheckPass(uint32_t desc_set, - uint32_t shader_id); - -// Create a pass to instrument OpDebugPrintf instructions. -// This pass replaces all OpDebugPrintf instructions with instructions to write -// a record containing the string id and the all specified values into a special -// printf output buffer (if space allows). This pass is designed to support -// the printf validation in the Vulkan validation layers. -// -// The instrumentation will write buffers in debug descriptor set |desc_set|. -// It will write |shader_id| in each output record to identify the shader -// module which generated the record. -Optimizer::PassToken CreateInstDebugPrintfPass(uint32_t desc_set, - uint32_t shader_id); - // Create a pass to upgrade to the VulkanKHR memory model. // This pass upgrades the Logical GLSL450 memory model to Logical VulkanKHR. // Additionally, it modifies memory, image, atomic and barrier operations to @@ -862,14 +815,19 @@ Optimizer::PassToken CreateReplaceDescArrayAccessUsingVarIndexPass(); // Create descriptor scalar replacement pass. // This pass replaces every array variable |desc| that has a DescriptorSet and -// Binding decorations with a new variable for each element of the array. -// Suppose |desc| was bound at binding |b|. Then the variable corresponding to -// |desc[i]| will have binding |b+i|. The descriptor set will be the same. It -// is assumed that no other variable already has a binding that will used by one -// of the new variables. If not, the pass will generate invalid Spir-V. All -// accesses to |desc| must be OpAccessChain instructions with a literal index -// for the first index. +// Binding decorations with a new variable for each element of the +// array/composite. Suppose |desc| was bound at binding |b|. Then the variable +// corresponding to |desc[i]| will have binding |b+i|. The descriptor set will +// be the same. It is assumed that no other variable already has a binding that +// will used by one of the new variables. If not, the pass will generate +// invalid Spir-V. All accesses to |desc| must be OpAccessChain instructions +// with a literal index for the first index. This variant flattens both +// composites and arrays. Optimizer::PassToken CreateDescriptorScalarReplacementPass(); +// This variant flattens only composites. +Optimizer::PassToken CreateDescriptorCompositeScalarReplacementPass(); +// This variant flattens only arrays. +Optimizer::PassToken CreateDescriptorArrayScalarReplacementPass(); // Create a pass to replace each OpKill instruction with a function call to a // function that has a single OpKill. Also replace each OpTerminateInvocation @@ -891,6 +849,12 @@ Optimizer::PassToken CreateAmdExtToKhrPass(); // propagated into their final positions. Optimizer::PassToken CreateInterpolateFixupPass(); +// Replace OpExtInst instructions with OpExtInstWithForwardRefsKHR when +// the instruction contains a forward reference to another debug instuction. +// Replace OpExtInstWithForwardRefsKHR with OpExtInst when there are no forward +// reference to another debug instruction. +Optimizer::PassToken CreateOpExtInstWithForwardReferenceFixupPass(); + // Removes unused components from composite input variables. Current // implementation just removes trailing unused components from input arrays // and structs. The pass performs best after maximizing dead code removal. @@ -969,6 +933,41 @@ Optimizer::PassToken CreateRemoveDontInlinePass(); // object, currently the pass would remove accesschain pointer argument passed // to the function Optimizer::PassToken CreateFixFuncCallArgumentsPass(); + +// Creates a trim-capabilities pass. +// This pass removes unused capabilities for a given module, and if possible, +// associated extensions. +// See `trim_capabilities.h` for the list of supported capabilities. +// +// If the module contains unsupported capabilities, this pass will ignore them. +// This should be fine in most cases, but could yield to incorrect results if +// the unknown capability interacts with one of the trimmed capabilities. +Optimizer::PassToken CreateTrimCapabilitiesPass(); + +// Creates a struct-packing pass. +// This pass re-assigns all offset layout decorators to tightly pack +// the struct with OpName matching `structToPack` according to the given packing +// rule. Accepted packing rules are: std140, std140EnhancedLayout, std430, +// std430EnhancedLayout, hlslCbuffer, hlslCbufferPackOffset, scalar, +// scalarEnhancedLayout. +Optimizer::PassToken CreateStructPackingPass(const char* structToPack, + const char* packingRule); + +// Creates a switch-descriptorset pass. +// This pass changes any DescriptorSet decorations with the value |ds_from| to +// use the new value |ds_to|. +Optimizer::PassToken CreateSwitchDescriptorSetPass(uint32_t ds_from, + uint32_t ds_to); + +// Creates an invocation interlock placement pass. +// This pass ensures that an entry point will have at most one +// OpBeginInterlockInvocationEXT and one OpEndInterlockInvocationEXT, in that +// order. +Optimizer::PassToken CreateInvocationInterlockPlacementPass(); + +// Creates a pass to add/remove maximal reconvergence execution mode. +// This pass either adds or removes maximal reconvergence from all entry points. +Optimizer::PassToken CreateModifyMaximalReconvergencePass(bool add); } // namespace spvtools #endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_ diff --git a/third_party/spirv-tools/kokoro/android/build.sh b/third_party/spirv-tools/kokoro/android/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/check-format/build.sh b/third_party/spirv-tools/kokoro/check-format/build.sh index 8a5df9a835..96603e4476 100644 --- a/third_party/spirv-tools/kokoro/check-format/build.sh +++ b/third_party/spirv-tools/kokoro/check-format/build.sh @@ -23,6 +23,11 @@ set -x BUILD_ROOT=$PWD SRC=$PWD/github/SPIRV-Tools +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC + # Get clang-format-5.0.0. # Once kokoro upgrades the Ubuntu VMs, we can use 'apt-get install clang-format' curl -L http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz -o clang-llvm.tar.xz diff --git a/third_party/spirv-tools/kokoro/linux-clang-asan/build.sh b/third_party/spirv-tools/kokoro/linux-clang-asan/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/linux-clang-debug/build.sh b/third_party/spirv-tools/kokoro/linux-clang-debug/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/linux-clang-release-bazel/build.sh b/third_party/spirv-tools/kokoro/linux-clang-release-bazel/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/linux-clang-release/build.sh b/third_party/spirv-tools/kokoro/linux-clang-release/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/linux-gcc-debug/build.sh b/third_party/spirv-tools/kokoro/linux-gcc-debug/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/linux-gcc-release/build.sh b/third_party/spirv-tools/kokoro/linux-gcc-release/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/macos-clang-debug/build.sh b/third_party/spirv-tools/kokoro/macos-clang-debug/build.sh index 8d9a062f62..fca76fc624 100644 --- a/third_party/spirv-tools/kokoro/macos-clang-debug/build.sh +++ b/third_party/spirv-tools/kokoro/macos-clang-debug/build.sh @@ -22,4 +22,3 @@ set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` source $SCRIPT_DIR/../scripts/macos/build.sh Debug - diff --git a/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh b/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh index c62611abdd..4bb889ad09 100644 --- a/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh +++ b/third_party/spirv-tools/kokoro/macos-clang-release-bazel/build.sh @@ -24,21 +24,22 @@ CC=clang CXX=clang++ SRC=$PWD/github/SPIRV-Tools -cd $SRC -git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers -git clone https://github.com/google/googletest external/googletest -cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. -git clone --depth=1 https://github.com/google/effcee external/effcee -git clone --depth=1 https://github.com/google/re2 external/re2 +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC -# Get bazel 5.0.0 -gsutil cp gs://bazel/5.0.0/release/bazel-5.0.0-darwin-x86_64 . -chmod +x bazel-5.0.0-darwin-x86_64 +cd $SRC +/usr/bin/python3 utils/git-sync-deps --treeless + +# Get bazel 7.0.2 +gsutil cp gs://bazel/7.0.2/release/bazel-7.0.2-darwin-x86_64 . +chmod +x bazel-7.0.2-darwin-x86_64 echo $(date): Build everything... -./bazel-5.0.0-darwin-x86_64 build :all +./bazel-7.0.2-darwin-x86_64 build --cxxopt=-std=c++17 :all echo $(date): Build completed. echo $(date): Starting bazel test... -./bazel-5.0.0-darwin-x86_64 test :all +./bazel-7.0.2-darwin-x86_64 test --cxxopt=-std=c++17 :all echo $(date): Bazel test completed. diff --git a/third_party/spirv-tools/kokoro/macos-clang-release/build.sh b/third_party/spirv-tools/kokoro/macos-clang-release/build.sh index ccc8b16aa0..b1460a9716 100644 --- a/third_party/spirv-tools/kokoro/macos-clang-release/build.sh +++ b/third_party/spirv-tools/kokoro/macos-clang-release/build.sh @@ -22,4 +22,3 @@ set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` source $SCRIPT_DIR/../scripts/macos/build.sh RelWithDebInfo - diff --git a/third_party/spirv-tools/kokoro/ndk-build/build.sh b/third_party/spirv-tools/kokoro/ndk-build/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh b/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh index 80043b8a4e..33d92d546a 100755 --- a/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh +++ b/third_party/spirv-tools/kokoro/scripts/linux/build-docker.sh @@ -20,24 +20,23 @@ set -e # Display commands being run. set -x +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $ROOT_DIR + . /bin/using.sh # Declare the bash `using` function for configuring toolchains. +using python-3.12 + if [ $COMPILER = "clang" ]; then - using clang-10.0.0 + using clang-13.0.1 elif [ $COMPILER = "gcc" ]; then - using gcc-9 + using gcc-13 fi cd $ROOT_DIR -function clone_if_missing() { - url=$1 - dir=$2 - if [[ ! -d "$dir" ]]; then - git clone ${@:3} "$url" "$dir" - fi -} - function clean_dir() { dir=$1 if [[ -d "$dir" ]]; then @@ -46,15 +45,13 @@ function clean_dir() { mkdir "$dir" } -clone_if_missing https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers --depth=1 -clone_if_missing https://github.com/google/googletest external/googletest -pushd external/googletest; git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7; popd -clone_if_missing https://github.com/google/effcee external/effcee --depth=1 -clone_if_missing https://github.com/google/re2 external/re2 --depth=1 -clone_if_missing https://github.com/protocolbuffers/protobuf external/protobuf --branch v3.13.0.1 +if [ $TOOL != "cmake-smoketest" ]; then + # Get source for dependencies, as specified in the DEPS file + /usr/bin/python3 utils/git-sync-deps --treeless +fi if [ $TOOL = "cmake" ]; then - using cmake-3.17.2 + using cmake-3.31.2 using ninja-1.10.0 # Possible configurations are: @@ -119,7 +116,7 @@ if [ $TOOL = "cmake" ]; then cd $KOKORO_ARTIFACTS_DIR tar czf install.tgz install elif [ $TOOL = "cmake-smoketest" ]; then - using cmake-3.17.2 + using cmake-3.31.2 using ninja-1.10.0 # Get shaderc. @@ -136,6 +133,7 @@ elif [ $TOOL = "cmake-smoketest" ]; then git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-headers git clone https://github.com/google/re2 git clone https://github.com/google/effcee + git clone https://github.com/abseil/abseil-cpp abseil_cpp cd $SHADERC_DIR mkdir build @@ -146,7 +144,7 @@ elif [ $TOOL = "cmake-smoketest" ]; then cmake -GNinja -DRE2_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE="Release" .. echo $(date): Build glslang... - ninja glslangValidator + ninja glslang-standalone echo $(date): Build everything... ninja @@ -159,8 +157,8 @@ elif [ $TOOL = "cmake-smoketest" ]; then ctest --output-on-failure -j4 echo $(date): ctest completed. elif [ $TOOL = "cmake-android-ndk" ]; then - using cmake-3.17.2 - using ndk-r21d + using cmake-3.31.2 + using ndk-r27c using ninja-1.10.0 clean_dir "$ROOT_DIR/build" @@ -168,7 +166,7 @@ elif [ $TOOL = "cmake-android-ndk" ]; then echo $(date): Starting build... cmake -DCMAKE_BUILD_TYPE=Release \ - -DANDROID_NATIVE_API_LEVEL=android-16 \ + -DANDROID_NATIVE_API_LEVEL=android-24 \ -DANDROID_ABI="armeabi-v7a with NEON" \ -DSPIRV_SKIP_TESTS=ON \ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \ @@ -180,7 +178,7 @@ elif [ $TOOL = "cmake-android-ndk" ]; then ninja echo $(date): Build completed. elif [ $TOOL = "android-ndk-build" ]; then - using ndk-r21d + using ndk-r27c clean_dir "$ROOT_DIR/build" cd "$ROOT_DIR/build" @@ -195,13 +193,13 @@ elif [ $TOOL = "android-ndk-build" ]; then echo $(date): ndk-build completed. elif [ $TOOL = "bazel" ]; then - using bazel-5.0.0 + using bazel-7.0.2 echo $(date): Build everything... - bazel build :all + bazel build --cxxopt=-std=c++17 :all echo $(date): Build completed. echo $(date): Starting bazel test... - bazel test :all + bazel test --cxxopt=-std=c++17 :all echo $(date): Bazel test completed. fi diff --git a/third_party/spirv-tools/kokoro/scripts/linux/build.sh b/third_party/spirv-tools/kokoro/scripts/linux/build.sh index 85d4b61abb..688ba7933d 100644 --- a/third_party/spirv-tools/kokoro/scripts/linux/build.sh +++ b/third_party/spirv-tools/kokoro/scripts/linux/build.sh @@ -26,6 +26,18 @@ COMPILER=$2 TOOL=$3 BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +# chown the given directory to the current user, if it exists. +# Docker creates files with the root user - this can upset the Kokoro artifact copier. +function chown_dir() { + dir=$1 + if [[ -d "$dir" ]]; then + sudo chown -R "$(id -u):$(id -g)" "$dir" + fi +} + +set +e +# Allow build failures + # "--privileged" is required to run ptrace in the asan builds. docker run --rm -i \ --privileged \ @@ -41,16 +53,11 @@ docker run --rm -i \ --env BUILD_SHA="${BUILD_SHA}" \ --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ "gcr.io/shaderc-build/radial-build:latest" +RESULT=$? - -# chown the given directory to the current user, if it exists. -# Docker creates files with the root user - this can upset the Kokoro artifact copier. -function chown_dir() { - dir=$1 - if [[ -d "$dir" ]]; then - sudo chown -R "$(id -u):$(id -g)" "$dir" - fi -} - +# This is important. If the permissions are not fixed, kokoro will fail +# to pull build artifacts, and put the build in tool-failure state, which +# blocks the logs. chown_dir "${ROOT_DIR}/build" chown_dir "${ROOT_DIR}/external" +exit $RESULT diff --git a/third_party/spirv-tools/kokoro/scripts/macos/build.sh b/third_party/spirv-tools/kokoro/scripts/macos/build.sh index 3618e69053..8381f87de0 100644 --- a/third_party/spirv-tools/kokoro/scripts/macos/build.sh +++ b/third_party/spirv-tools/kokoro/scripts/macos/build.sh @@ -24,6 +24,11 @@ BUILD_ROOT=$PWD SRC=$PWD/github/SPIRV-Tools BUILD_TYPE=$1 +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC + # Get NINJA. wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip unzip -q ninja-mac.zip @@ -31,12 +36,7 @@ chmod +x ninja export PATH="$PWD:$PATH" cd $SRC -git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers -git clone https://github.com/google/googletest external/googletest -cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. -git clone --depth=1 https://github.com/google/effcee external/effcee -git clone --depth=1 https://github.com/google/re2 external/re2 -git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf +python3 utils/git-sync-deps --treeless mkdir build && cd $SRC/build diff --git a/third_party/spirv-tools/kokoro/scripts/windows/build.bat b/third_party/spirv-tools/kokoro/scripts/windows/build.bat index 8c9d6892c2..6e6c1577e4 100644 --- a/third_party/spirv-tools/kokoro/scripts/windows/build.bat +++ b/third_party/spirv-tools/kokoro/scripts/windows/build.bat @@ -21,29 +21,23 @@ set SRC=%cd%\github\SPIRV-Tools set BUILD_TYPE=%1 set VS_VERSION=%2 -:: Force usage of python 3.6 -set PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH% - -cd %SRC% -git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers -git clone https://github.com/google/googletest external/googletest -cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. -git clone --depth=1 https://github.com/google/effcee external/effcee -git clone --depth=1 https://github.com/google/re2 external/re2 -git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf +:: Force usage of python 3.12, cmake 3.31.2 +set PATH=C:\python312;c:\cmake-3.31.2\bin;%PATH% :: ######################################### :: set up msvc build env :: ######################################### -if %VS_VERSION% == 2017 ( - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 - echo "Using VS 2017..." -) else if %VS_VERSION% == 2015 ( - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 - echo "Using VS 2015..." +if %VS_VERSION% == 2019 ( + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 + echo "Using VS 2019..." +) else if %VS_VERSION% == 2022 ( + call "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64 + echo "Using VS 2022..." ) cd %SRC% +python utils/git-sync-deps --treeless + mkdir build cd build @@ -62,6 +56,11 @@ set CMAKE_FLAGS=-DCMAKE_INSTALL_PREFIX=%KOKORO_ARTIFACTS_DIR%\install -GNinja -D :: Build spirv-fuzz set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_BUILD_FUZZER=ON +if "%BUILD_TESTS%" == "NO" ( + set CMAKE_FLAGS=-DSPIRV_SKIP_TESTS=ON %CMAKE_FLAGS% +) + +cmake --version cmake %CMAKE_FLAGS% .. if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% @@ -77,10 +76,12 @@ setlocal ENABLEDELAYEDEXPANSION :: ################################################ :: Run the tests :: ################################################ -echo "Running Tests... %DATE% %TIME%" -ctest -C %BUILD_TYPE% --output-on-failure --timeout 300 -if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! -echo "Tests Completed %DATE% %TIME%" +if "%BUILD_TESTS%" NEQ "NO" ( + echo "Running Tests... %DATE% %TIME%" + ctest -C %BUILD_TYPE% --output-on-failure --timeout 300 + if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! + echo "Tests Completed %DATE% %TIME%" +) :: ################################################ :: Install and package. diff --git a/third_party/spirv-tools/kokoro/shaderc-smoketest/build.sh b/third_party/spirv-tools/kokoro/shaderc-smoketest/build.sh old mode 100644 new mode 100755 diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat deleted file mode 100644 index de20b0aa23..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/build.bat +++ /dev/null @@ -1,59 +0,0 @@ -:: Copyright (c) 2019 Google LLC. -:: -:: 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. -:: -:: Windows Build Script. - -@echo on - -set SRC=%cd%\github\SPIRV-Tools - -:: Force usage of python 3.6 -set PATH=C:\python36;%PATH% - -:: Get dependencies -cd %SRC% -git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers -git clone https://github.com/google/googletest external/googletest -cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. -git clone --depth=1 https://github.com/google/effcee external/effcee -git clone --depth=1 https://github.com/google/re2 external/re2 - -:: REM Install Bazel. -wget -q https://github.com/bazelbuild/bazel/releases/download/5.0.0/bazel-5.0.0-windows-x86_64.zip -unzip -q bazel-5.0.0-windows-x86_64.zip - -:: Set up MSVC -call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 -set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio 14.0 -set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC -set BAZEL_PYTHON=c:\tools\python2\python.exe - -:: ######################################### -:: Start building. -:: ######################################### -echo "Build everything... %DATE% %TIME%" -bazel.exe build :all -if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% -echo "Build Completed %DATE% %TIME%" - -:: ############## -:: Run the tests -:: ############## -echo "Running Tests... %DATE% %TIME%" -bazel.exe test :all -if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% -echo "Tests Completed %DATE% %TIME%" - -exit /b 0 - diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/presubmit.cfg deleted file mode 100644 index 148972ce8c..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/presubmit.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2019 Google LLC. -# -# 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. - -# Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2015-release-bazel/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2015-release/presubmit.cfg deleted file mode 100644 index 85a162593f..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/presubmit.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2018 Google LLC. -# -# 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. - -# Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2015-release/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/build.bat deleted file mode 100644 index c1945e25a3..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/build.bat +++ /dev/null @@ -1,57 +0,0 @@ -:: Copyright (c) 2019 Google LLC. -:: -:: 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. -:: -:: Windows Build Script. - -@echo on - -set SRC=%cd%\github\SPIRV-Tools - -:: Force usage of python 3.6 -set PATH=C:\python36;%PATH% - -:: Get dependencies -cd %SRC% -git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers -git clone https://github.com/google/googletest external/googletest -cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd .. -git clone --depth=1 https://github.com/google/effcee external/effcee -git clone --depth=1 https://github.com/google/re2 external/re2 - -:: REM Install Bazel. -wget -q https://github.com/bazelbuild/bazel/releases/download/5.0.0/bazel-5.0.0-windows-x86_64.zip -unzip -q bazel-5.0.0-windows-x86_64.zip - -:: Set up MSVC -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC - -:: ######################################### -:: Start building. -:: ######################################### -echo "Build everything... %DATE% %TIME%" -bazel.exe build :all -if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% -echo "Build Completed %DATE% %TIME%" - -:: ############## -:: Run the tests -:: ############## -echo "Running Tests... %DATE% %TIME%" -bazel.exe test :all -if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% -echo "Tests Completed %DATE% %TIME%" - -exit /b 0 - diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/continuous.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/continuous.cfg deleted file mode 100644 index f2387a6889..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/continuous.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2019 Google LLC. -# -# 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. - -# Continuous build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-release-bazel/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/presubmit.cfg deleted file mode 100644 index 13394b4100..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release-bazel/presubmit.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2019 Google LLC. -# -# 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. - -# Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-release-bazel/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2017-release/build.bat deleted file mode 100644 index 899fcbcfb5..0000000000 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/build.bat +++ /dev/null @@ -1,24 +0,0 @@ -:: Copyright (c) 2018 Google LLC. -:: -:: 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. -:: -:: Windows Build Script. - -@echo on - -:: Find out the directory of the common build script. -set SCRIPT_DIR=%~dp0 - -:: Call with correct parameter -call %SCRIPT_DIR%\..\scripts\windows\build.bat RelWithDebInfo 2017 - diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2013-release/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/build.bat similarity index 95% rename from third_party/spirv-tools/kokoro/windows-msvc-2013-release/build.bat rename to third_party/spirv-tools/kokoro/windows-msvc-2019-release/build.bat index e77172afc9..8212924549 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2013-release/build.bat +++ b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/build.bat @@ -1,4 +1,4 @@ -:: Copyright (c) 2018 Google LLC. +:: Copyright (c) 2023 Google LLC :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. @@ -20,5 +20,5 @@ set SCRIPT_DIR=%~dp0 :: Call with correct parameter -call %SCRIPT_DIR%\..\scripts\windows\build.bat RelWithDebInfo 2013 +call %SCRIPT_DIR%\..\scripts\windows\build.bat RelWithDebInfo 2019 diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/continuous.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/continuous.cfg similarity index 86% rename from third_party/spirv-tools/kokoro/windows-msvc-2017-release/continuous.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2019-release/continuous.cfg index a9ac6eca91..624ccbde6e 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/continuous.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/continuous.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2023 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # limitations under the License. # Continuous build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-release/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2019-release/build.bat" action { define_artifacts { diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/presubmit.cfg similarity index 85% rename from third_party/spirv-tools/kokoro/windows-msvc-2017-release/presubmit.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2019-release/presubmit.cfg index 5efd429274..4c578e0069 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-release/presubmit.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2019-release/presubmit.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2023 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # limitations under the License. # Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-release/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2019-release/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/build.bat similarity index 88% rename from third_party/spirv-tools/kokoro/windows-msvc-2017-debug/build.bat rename to third_party/spirv-tools/kokoro/windows-msvc-2022-debug/build.bat index 25783a9e58..7ad94c19f5 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/build.bat +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/build.bat @@ -1,4 +1,4 @@ -:: Copyright (c) 2018 Google LLC. +:: Copyright (c) 2023 Google LLC :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. @@ -20,4 +20,4 @@ set SCRIPT_DIR=%~dp0 :: Call with correct parameter -call %SCRIPT_DIR%\..\scripts\windows\build.bat Debug 2017 +call %SCRIPT_DIR%\..\scripts\windows\build.bat Debug 2019 diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/continuous.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/continuous.cfg similarity index 86% rename from third_party/spirv-tools/kokoro/windows-msvc-2017-debug/continuous.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2022-debug/continuous.cfg index 25c5e113de..5514fab19f 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/continuous.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/continuous.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # limitations under the License. # Continuous build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-debug/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2022-debug/build.bat" action { define_artifacts { diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/presubmit.cfg similarity index 85% rename from third_party/spirv-tools/kokoro/windows-msvc-2017-debug/presubmit.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2022-debug/presubmit.cfg index a7a553aee9..ced91a3822 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2017-debug/presubmit.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-debug/presubmit.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # limitations under the License. # Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2017-debug/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2022-debug/build.bat" diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/build.bat b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/build.bat similarity index 95% rename from third_party/spirv-tools/kokoro/windows-msvc-2015-release/build.bat rename to third_party/spirv-tools/kokoro/windows-msvc-2022-release/build.bat index c0e4bd317a..5294a9070b 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/build.bat +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/build.bat @@ -1,4 +1,4 @@ -:: Copyright (c) 2018 Google LLC. +:: Copyright (c) 2025 Google LLC :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. @@ -20,5 +20,5 @@ set SCRIPT_DIR=%~dp0 :: Call with correct parameter -call %SCRIPT_DIR%\..\scripts\windows\build.bat RelWithDebInfo 2015 +call %SCRIPT_DIR%\..\scripts\windows\build.bat RelWithDebInfo 2022 diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/continuous.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/continuous.cfg similarity index 78% rename from third_party/spirv-tools/kokoro/windows-msvc-2015-release/continuous.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2022-release/continuous.cfg index 3e47e52688..7c376050ac 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release/continuous.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/continuous.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2025 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,10 @@ # limitations under the License. # Continuous build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2015-release/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2022-release/build.bat" + +action { + define_artifacts { + regex: "install.zip" + } +} diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2013-release/presubmit.cfg b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/presubmit.cfg similarity index 85% rename from third_party/spirv-tools/kokoro/windows-msvc-2013-release/presubmit.cfg rename to third_party/spirv-tools/kokoro/windows-msvc-2022-release/presubmit.cfg index 7d3b238227..94c9144c72 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2013-release/presubmit.cfg +++ b/third_party/spirv-tools/kokoro/windows-msvc-2022-release/presubmit.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Google LLC. +# Copyright (c) 2025 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # limitations under the License. # Presubmit build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2013-release/build.bat" +build_file: "SPIRV-Tools/kokoro/windows-msvc-2022-release/build.bat" diff --git a/third_party/spirv-tools/source/CMakeLists.txt b/third_party/spirv-tools/source/CMakeLists.txt index 26d0583932..b5608f0ef6 100644 --- a/third_party/spirv-tools/source/CMakeLists.txt +++ b/third_party/spirv-tools/source/CMakeLists.txt @@ -13,7 +13,7 @@ # limitations under the License. set(GRAMMAR_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_grammar_tables.py") -set(VIMSYNTAX_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_vim_syntax.py") +set(VIMSYNTAX_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/vim/generate_syntax.py") set(XML_REGISTRY_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_registry_tables.py") set(LANG_HEADER_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_language_headers.py") @@ -31,7 +31,7 @@ macro(spvtools_core_tables CONFIG_VERSION) set(GRAMMAR_INSTS_INC_FILE "${spirv-tools_BINARY_DIR}/core.insts-${CONFIG_VERSION}.inc") set(GRAMMAR_KINDS_INC_FILE "${spirv-tools_BINARY_DIR}/operand.kinds-${CONFIG_VERSION}.inc") add_custom_command(OUTPUT ${GRAMMAR_INSTS_INC_FILE} ${GRAMMAR_KINDS_INC_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT} --spirv-core-grammar=${GRAMMAR_JSON_FILE} --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} --extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE} @@ -53,7 +53,7 @@ macro(spvtools_enum_string_mapping CONFIG_VERSION) set(GRAMMAR_ENUM_STRING_MAPPING_INC_FILE "${spirv-tools_BINARY_DIR}/enum_string_mapping.inc") add_custom_command(OUTPUT ${GRAMMAR_EXTENSION_ENUM_INC_FILE} ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT} --spirv-core-grammar=${GRAMMAR_JSON_FILE} --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} --extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE} @@ -75,7 +75,7 @@ macro(spvtools_vimsyntax CONFIG_VERSION CLVERSION) set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json") set(VIMSYNTAX_FILE "${spirv-tools_BINARY_DIR}/spvasm.vim") add_custom_command(OUTPUT ${VIMSYNTAX_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${VIMSYNTAX_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${VIMSYNTAX_PROCESSING_SCRIPT} --spirv-core-grammar=${GRAMMAR_JSON_FILE} --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} --extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE} @@ -91,7 +91,7 @@ macro(spvtools_glsl_tables CONFIG_VERSION) set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.glsl.std.450.grammar.json") set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc") add_custom_command(OUTPUT ${GRAMMAR_INC_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT} --extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE} --glsl-insts-output=${GRAMMAR_INC_FILE} --output-language=c++ @@ -105,7 +105,7 @@ macro(spvtools_opencl_tables CONFIG_VERSION) set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${CONFIG_VERSION}/extinst.opencl.std.100.grammar.json") set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts.inc") add_custom_command(OUTPUT ${GRAMMAR_INC_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT} --extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE} --opencl-insts-output=${GRAMMAR_INC_FILE} DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${OPENCL_GRAMMAR_JSON_FILE} @@ -120,7 +120,7 @@ macro(spvtools_vendor_tables VENDOR_TABLE SHORT_NAME OPERAND_KIND_PREFIX) set(GRAMMAR_FILE "${spirv-tools_SOURCE_DIR}/source/extinst.${VENDOR_TABLE}.grammar.json") endif() add_custom_command(OUTPUT ${INSTS_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT} --extinst-vendor-grammar=${GRAMMAR_FILE} --vendor-insts-output=${INSTS_FILE} --vendor-operand-kind-prefix=${OPERAND_KIND_PREFIX} @@ -134,7 +134,7 @@ endmacro(spvtools_vendor_tables) macro(spvtools_extinst_lang_headers NAME GRAMMAR_FILE) set(OUT_H ${spirv-tools_BINARY_DIR}/${NAME}.h) add_custom_command(OUTPUT ${OUT_H} - COMMAND ${PYTHON_EXECUTABLE} ${LANG_HEADER_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${LANG_HEADER_PROCESSING_SCRIPT} --extinst-grammar=${GRAMMAR_FILE} --extinst-output-path=${OUT_H} DEPENDS ${LANG_HEADER_PROCESSING_SCRIPT} ${GRAMMAR_FILE} @@ -156,6 +156,7 @@ spvtools_vendor_tables("debuginfo" "debuginfo" "") spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_") spvtools_vendor_tables("nonsemantic.shader.debuginfo.100" "shdi100" "SHDEBUG100_") spvtools_vendor_tables("nonsemantic.clspvreflection" "clspvreflection" "") +spvtools_vendor_tables("nonsemantic.vkspreflection" "vkspreflection" "") spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE}) spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE}) spvtools_extinst_lang_headers("NonSemanticShaderDebugInfo100" ${VKDEBUGINFO100_GRAMMAR_JSON_FILE}) @@ -168,7 +169,7 @@ set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities set(GENERATOR_INC_FILE ${spirv-tools_BINARY_DIR}/generators.inc) set(SPIRV_XML_REGISTRY_FILE ${SPIRV_HEADER_INCLUDE_DIR}/spirv/spir-v.xml) add_custom_command(OUTPUT ${GENERATOR_INC_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${XML_REGISTRY_PROCESSING_SCRIPT} + COMMAND Python3::Interpreter ${XML_REGISTRY_PROCESSING_SCRIPT} --xml=${SPIRV_XML_REGISTRY_FILE} --generator-output=${GENERATOR_INC_FILE} DEPENDS ${XML_REGISTRY_PROCESSING_SCRIPT} ${SPIRV_XML_REGISTRY_FILE} @@ -198,7 +199,7 @@ set(SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR set(SPIRV_TOOLS_CHANGES_FILE ${spirv-tools_SOURCE_DIR}/CHANGES) add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND Python3::Interpreter ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} ${SPIRV_TOOLS_CHANGES_FILE} ${SPIRV_TOOLS_BUILD_VERSION_INC} DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC_GENERATOR} @@ -265,6 +266,7 @@ set(SPIRV_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/table.h ${CMAKE_CURRENT_SOURCE_DIR}/text.h ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.h + ${CMAKE_CURRENT_SOURCE_DIR}/to_string.h ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.h ${CMAKE_CURRENT_SOURCE_DIR}/util/bit_vector.cpp @@ -293,6 +295,7 @@ set(SPIRV_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/table.cpp ${CMAKE_CURRENT_SOURCE_DIR}/text.cpp ${CMAKE_CURRENT_SOURCE_DIR}/text_handler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/to_string.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_adjacency.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_annotation.cpp @@ -331,6 +334,7 @@ set(SPIRV_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_ray_tracing_reorder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_scopes.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_small_type_uses.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_tensor_layout.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/validate_type.cpp ${CMAKE_CURRENT_SOURCE_DIR}/val/decoration.h ${CMAKE_CURRENT_SOURCE_DIR}/val/basic_block.cpp @@ -380,6 +384,13 @@ endfunction() # Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and # unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. +add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) +spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) +set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${SPIRV_TOOLS}-shared + PRIVATE SPIRV_TOOLS_IMPLEMENTATION + PUBLIC SPIRV_TOOLS_SHAREDLIB +) if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) @@ -395,11 +406,11 @@ if(SPIRV_TOOLS_BUILD_STATIC) add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) endif() - set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static) + set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) else() add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) spirv_tools_default_target_options(${SPIRV_TOOLS}) - set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}) + set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared) endif() if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") @@ -411,17 +422,8 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") endif() endif() -if (ANDROID) - foreach(target ${SPIRV_TOOLS_TARGETS}) - target_link_libraries(${target} PRIVATE android log) - endforeach() -endif() - if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets) export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake) spvtools_config_package_dir(${SPIRV_TOOLS} PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/assembly_grammar.cpp b/third_party/spirv-tools/source/assembly_grammar.cpp index 6df823e307..0092d01a50 100644 --- a/third_party/spirv-tools/source/assembly_grammar.cpp +++ b/third_party/spirv-tools/source/assembly_grammar.cpp @@ -21,6 +21,7 @@ #include "source/ext_inst.h" #include "source/opcode.h" #include "source/operand.h" +#include "source/spirv_target_env.h" #include "source/table.h" namespace spvtools { @@ -154,11 +155,12 @@ const SpecConstantOpcodeEntry kOpSpecConstantOpcodes[] = { CASE(InBoundsAccessChain), CASE(PtrAccessChain), CASE(InBoundsPtrAccessChain), - CASE(CooperativeMatrixLengthNV) + CASE(CooperativeMatrixLengthNV), + CASE(CooperativeMatrixLengthKHR) }; // The 60 is determined by counting the opcodes listed in the spec. -static_assert(60 == sizeof(kOpSpecConstantOpcodes)/sizeof(kOpSpecConstantOpcodes[0]), +static_assert(61 == sizeof(kOpSpecConstantOpcodes)/sizeof(kOpSpecConstantOpcodes[0]), "OpSpecConstantOp opcode table is incomplete"); #undef CASE // clang-format on @@ -175,15 +177,18 @@ bool AssemblyGrammar::isValid() const { CapabilitySet AssemblyGrammar::filterCapsAgainstTargetEnv( const spv::Capability* cap_array, uint32_t count) const { CapabilitySet cap_set; + const auto version = spvVersionForTargetEnv(target_env_); for (uint32_t i = 0; i < count; ++i) { - spv_operand_desc cap_desc = {}; + spv_operand_desc entry = {}; if (SPV_SUCCESS == lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, static_cast(cap_array[i]), - &cap_desc)) { - // spvOperandTableValueLookup() filters capabilities internally - // according to the current target environment by itself. So we - // should be safe to add this capability if the lookup succeeds. - cap_set.Add(cap_array[i]); + &entry)) { + // This token is visible in this environment if it's in an appropriate + // core version, or it is enabled by a capability or an extension. + if ((version >= entry->minVersion && version <= entry->lastVersion) || + entry->numExtensions > 0u || entry->numCapabilities > 0u) { + cap_set.insert(cap_array[i]); + } } } return cap_set; diff --git a/third_party/spirv-tools/source/binary.cpp b/third_party/spirv-tools/source/binary.cpp index beb56be7b5..3807441dfe 100644 --- a/third_party/spirv-tools/source/binary.cpp +++ b/third_party/spirv-tools/source/binary.cpp @@ -473,7 +473,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset, if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Id is 0"; parsed_operand.type = SPV_OPERAND_TYPE_ID; - if (opcode == spv::Op::OpExtInst && parsed_operand.offset == 3) { + if (spvIsExtendedInstruction(opcode) && parsed_operand.offset == 3) { // The current word is the extended instruction set Id. // Set the extended instruction set type for the current instruction. auto ext_inst_type_iter = _.import_id_to_ext_inst_type.find(word); @@ -494,7 +494,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset, break; case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: { - assert(spv::Op::OpExtInst == opcode); + assert(spvIsExtendedInstruction(opcode)); assert(inst->ext_inst_type != SPV_EXT_INST_TYPE_NONE); spv_ext_inst_desc ext_inst; if (grammar_.lookupExtInst(inst->ext_inst_type, word, &ext_inst) == @@ -546,6 +546,13 @@ spv_result_t Parser::parseOperand(size_t inst_offset, parsed_operand.number_bit_width = 32; break; + case SPV_OPERAND_TYPE_LITERAL_FLOAT: + // These are regular single-word literal float operands. + parsed_operand.type = SPV_OPERAND_TYPE_LITERAL_FLOAT; + parsed_operand.number_kind = SPV_NUMBER_FLOATING; + parsed_operand.number_bit_width = 32; + break; + case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: case SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER: parsed_operand.type = SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER; @@ -626,7 +633,6 @@ spv_result_t Parser::parseOperand(size_t inst_offset, } break; case SPV_OPERAND_TYPE_CAPABILITY: - case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: case SPV_OPERAND_TYPE_EXECUTION_MODEL: case SPV_OPERAND_TYPE_ADDRESSING_MODEL: case SPV_OPERAND_TYPE_MEMORY_MODEL: @@ -664,7 +670,13 @@ spv_result_t Parser::parseOperand(size_t inst_offset, case SPV_OPERAND_TYPE_QUANTIZATION_MODES: case SPV_OPERAND_TYPE_OVERFLOW_MODES: case SPV_OPERAND_TYPE_PACKED_VECTOR_FORMAT: - case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT: { + case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT: + case SPV_OPERAND_TYPE_FPENCODING: + case SPV_OPERAND_TYPE_OPTIONAL_FPENCODING: + case SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER: + case SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL: + case SPV_OPERAND_TYPE_STORE_CACHE_CONTROL: + case SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS: { // A single word that is a plain enum value. // Map an optional operand type to its corresponding concrete type. @@ -672,6 +684,8 @@ spv_result_t Parser::parseOperand(size_t inst_offset, parsed_operand.type = SPV_OPERAND_TYPE_ACCESS_QUALIFIER; if (type == SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT) parsed_operand.type = SPV_OPERAND_TYPE_PACKED_VECTOR_FORMAT; + if (type == SPV_OPERAND_TYPE_OPTIONAL_FPENCODING) + parsed_operand.type = SPV_OPERAND_TYPE_FPENCODING; spv_operand_desc entry; if (grammar_.lookupOperand(type, word, &entry)) { @@ -683,22 +697,52 @@ spv_result_t Parser::parseOperand(size_t inst_offset, spvPushOperandTypes(entry->operandTypes, expected_operands); } break; + case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: { + spv_operand_desc entry; + if (grammar_.lookupOperand(type, word, &entry)) { + return diagnostic() + << "Invalid " << spvOperandTypeStr(parsed_operand.type) + << " operand: " << word + << ", if you are creating a new source language please use " + "value 0 " + "(Unknown) and when ready, add your source language to " + "SPIRV-Headers"; + } + // Prepare to accept operands to this operand, if needed. + spvPushOperandTypes(entry->operandTypes, expected_operands); + } break; + case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE: case SPV_OPERAND_TYPE_FUNCTION_CONTROL: case SPV_OPERAND_TYPE_LOOP_CONTROL: case SPV_OPERAND_TYPE_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: + case SPV_OPERAND_TYPE_MEMORY_ACCESS: case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: + case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS: case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: - case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: { + case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE: + case SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS: + case SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: { // This operand is a mask. // Map an optional operand type to its corresponding concrete type. if (type == SPV_OPERAND_TYPE_OPTIONAL_IMAGE) parsed_operand.type = SPV_OPERAND_TYPE_IMAGE; - else if (type == SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS) + if (type == SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS) parsed_operand.type = SPV_OPERAND_TYPE_MEMORY_ACCESS; + if (type == SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS) + parsed_operand.type = SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS; + if (type == SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS) + parsed_operand.type = SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS; + if (type == SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS) + parsed_operand.type = + SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS; // Check validity of set mask bits. Also prepare for operands for those // masks if they have any. To get operand order correct, scan from diff --git a/third_party/spirv-tools/source/cfa.h b/third_party/spirv-tools/source/cfa.h index 9ae3e39a19..dc8b9ba0c2 100644 --- a/third_party/spirv-tools/source/cfa.h +++ b/third_party/spirv-tools/source/cfa.h @@ -15,6 +15,8 @@ #ifndef SOURCE_CFA_H_ #define SOURCE_CFA_H_ +#include + #include #include #include diff --git a/third_party/spirv-tools/source/diff/CMakeLists.txt b/third_party/spirv-tools/source/diff/CMakeLists.txt index 1328699ab1..52f18f2d13 100644 --- a/third_party/spirv-tools/source/diff/CMakeLists.txt +++ b/third_party/spirv-tools/source/diff/CMakeLists.txt @@ -39,10 +39,7 @@ set_property(TARGET SPIRV-Tools-diff PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-diff) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-diff EXPORT SPIRV-Tools-diffTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-diff EXPORT SPIRV-Tools-diffTargets) export(EXPORT SPIRV-Tools-diffTargets FILE SPIRV-Tools-diffTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-diff PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/diff/diff.cpp b/third_party/spirv-tools/source/diff/diff.cpp index 6daed321d1..6269af5004 100644 --- a/third_party/spirv-tools/source/diff/diff.cpp +++ b/third_party/spirv-tools/source/diff/diff.cpp @@ -101,9 +101,12 @@ class IdMap { return from < id_map_.size() && id_map_[from] != 0; } - // Map any ids in src and dst that have not been mapped to new ids in dst and - // src respectively. - void MapUnmatchedIds(IdMap& other_way); + bool IsMapped(const opt::Instruction* from_inst) const { + assert(from_inst != nullptr); + assert(!from_inst->HasResultId()); + + return inst_map_.find(from_inst) != inst_map_.end(); + } // Some instructions don't have result ids. Those are mapped by pointer. void MapInsts(const opt::Instruction* from_inst, @@ -117,6 +120,12 @@ class IdMap { uint32_t IdBound() const { return static_cast(id_map_.size()); } + // Generate a fresh id in this mapping's domain. + uint32_t MakeFreshId() { + id_map_.push_back(0); + return static_cast(id_map_.size()) - 1; + } + private: // Given an id, returns the corresponding id in the other module, or 0 if not // matched yet. @@ -150,10 +159,16 @@ class SrcDstIdMap { bool IsSrcMapped(uint32_t src) { return src_to_dst_.IsMapped(src); } bool IsDstMapped(uint32_t dst) { return dst_to_src_.IsMapped(dst); } + bool IsDstMapped(const opt::Instruction* dst_inst) { + return dst_to_src_.IsMapped(dst_inst); + } // Map any ids in src and dst that have not been mapped to new ids in dst and - // src respectively. - void MapUnmatchedIds(); + // src respectively. Use src_insn_defined and dst_insn_defined to ignore ids + // that are simply never defined. (Since we assume the inputs are valid + // SPIR-V, this implies they are also never used.) + void MapUnmatchedIds(std::function src_insn_defined, + std::function dst_insn_defined); // Some instructions don't have result ids. Those are mapped by pointer. void MapInsts(const opt::Instruction* src_inst, @@ -203,6 +218,11 @@ struct IdInstructions { void MapIdToInstruction(uint32_t id, const opt::Instruction* inst); + // Return true if id is mapped to any instruction, false otherwise. + bool IsDefined(uint32_t id) { + return id < inst_map_.size() && inst_map_[id] != nullptr; + } + void MapIdsToInstruction( opt::IteratorRange section); void MapIdsToInfos( @@ -338,6 +358,59 @@ class Differ { std::function match_group); + // Bucket `src_ids` and `dst_ids` by the key ids returned by `get_group`, and + // then call `match_group` on pairs of buckets whose key ids are matched with + // each other. + // + // For example, suppose we want to pair up groups of instructions with the + // same type. Naturally, the source instructions refer to their types by their + // ids in the source, and the destination instructions use destination type + // ids, so simply comparing source and destination type ids as integers, as + // `GroupIdsAndMatch` would do, is meaningless. But if a prior call to + // `MatchTypeIds` has established type matches between the two modules, then + // we can consult those to pair source and destination buckets whose types are + // equivalent. + // + // Suppose our input groups are as follows: + // + // - src_ids: { 1 -> 100, 2 -> 300, 3 -> 100, 4 -> 200 } + // - dst_ids: { 5 -> 10, 6 -> 20, 7 -> 10, 8 -> 300 } + // + // Here, `X -> Y` means that the instruction with SPIR-V id `X` is a member of + // the group, and `Y` is the id of its type. If we use + // `Differ::GroupIdsHelperGetTypeId` for `get_group`, then + // `get_group(X) == Y`. + // + // These instructions are bucketed by type as follows: + // + // - source: [1, 3] -> 100 + // [4] -> 200 + // [2] -> 300 + // + // - destination: [5, 7] -> 10 + // [6] -> 20 + // [8] -> 300 + // + // Now suppose that we have previously matched up src type 100 with dst type + // 10, and src type 200 with dst type 20, but no other types are matched. + // + // Then `match_group` is called twice: + // - Once with ([1,3], [5, 7]), corresponding to 100/10 + // - Once with ([4],[6]), corresponding to 200/20 + // + // The source type 300 isn't matched with anything, so the fact that there's a + // destination type 300 is irrelevant, and thus 2 and 8 are never passed to + // `match_group`. + // + // This function isn't specific to types; it simply buckets by the ids + // returned from `get_group`, and consults existing matches to pair up the + // resulting buckets. + void GroupIdsAndMatchByMappedId( + const IdGroup& src_ids, const IdGroup& dst_ids, + uint32_t (Differ::*get_group)(const IdInstructions&, uint32_t), + std::function + match_group); + // Helper functions that determine if two instructions match bool DoIdsMatch(uint32_t src_id, uint32_t dst_id); bool DoesOperandMatch(const opt::Operand& src_operand, @@ -504,36 +577,27 @@ class Differ { FunctionMap dst_funcs_; }; -void IdMap::MapUnmatchedIds(IdMap& other_way) { - const uint32_t src_id_bound = static_cast(id_map_.size()); - const uint32_t dst_id_bound = static_cast(other_way.id_map_.size()); - - uint32_t next_src_id = src_id_bound; - uint32_t next_dst_id = dst_id_bound; +void SrcDstIdMap::MapUnmatchedIds( + std::function src_insn_defined, + std::function dst_insn_defined) { + const uint32_t src_id_bound = static_cast(src_to_dst_.IdBound()); + const uint32_t dst_id_bound = static_cast(dst_to_src_.IdBound()); for (uint32_t src_id = 1; src_id < src_id_bound; ++src_id) { - if (!IsMapped(src_id)) { - MapIds(src_id, next_dst_id); - - other_way.id_map_.push_back(0); - other_way.MapIds(next_dst_id++, src_id); + if (!src_to_dst_.IsMapped(src_id) && src_insn_defined(src_id)) { + uint32_t fresh_dst_id = dst_to_src_.MakeFreshId(); + MapIds(src_id, fresh_dst_id); } } for (uint32_t dst_id = 1; dst_id < dst_id_bound; ++dst_id) { - if (!other_way.IsMapped(dst_id)) { - id_map_.push_back(0); - MapIds(next_src_id, dst_id); - - other_way.MapIds(dst_id, next_src_id++); + if (!dst_to_src_.IsMapped(dst_id) && dst_insn_defined(dst_id)) { + uint32_t fresh_src_id = src_to_dst_.MakeFreshId(); + MapIds(fresh_src_id, dst_id); } } } -void SrcDstIdMap::MapUnmatchedIds() { - src_to_dst_.MapUnmatchedIds(dst_to_src_); -} - void IdInstructions::MapIdToInstruction(uint32_t id, const opt::Instruction* inst) { assert(id != 0); @@ -889,6 +953,37 @@ void Differ::GroupIdsAndMatch( } } +void Differ::GroupIdsAndMatchByMappedId( + const IdGroup& src_ids, const IdGroup& dst_ids, + uint32_t (Differ::*get_group)(const IdInstructions&, uint32_t), + std::function + match_group) { + // Group the ids based on a key (get_group) + std::map src_groups; + std::map dst_groups; + + GroupIds(src_ids, true, &src_groups, get_group); + GroupIds(dst_ids, false, &dst_groups, get_group); + + // Iterate over pairs of groups whose keys map to each other. + for (const auto& iter : src_groups) { + const uint32_t& src_key = iter.first; + const IdGroup& src_group = iter.second; + + if (src_key == 0) { + continue; + } + + if (id_map_.IsSrcMapped(src_key)) { + const uint32_t& dst_key = id_map_.MappedDstId(src_key); + const IdGroup& dst_group = dst_groups[dst_key]; + + // Let the caller match the groups as appropriate. + match_group(src_group, dst_group); + } + } +} + bool Differ::DoIdsMatch(uint32_t src_id, uint32_t dst_id) { assert(dst_id != 0); return id_map_.MappedDstId(src_id) == dst_id; @@ -1419,7 +1514,6 @@ void Differ::MatchTypeForwardPointersByName(const IdGroup& src, GroupIdsAndMatch( src, dst, "", &Differ::GetSanitizedName, [this](const IdGroup& src_group, const IdGroup& dst_group) { - // Match only if there's a unique forward declaration with this debug // name. if (src_group.size() == 1 && dst_group.size() == 1) { @@ -1574,6 +1668,8 @@ void Differ::BestEffortMatchFunctions(const IdGroup& src_func_ids, id_map_.MapIds(match_result.src_id, match_result.dst_id); + MatchFunctionParamIds(src_funcs_[match_result.src_id], + dst_funcs_[match_result.dst_id]); MatchIdsInFunctionBodies(src_func_insts.at(match_result.src_id), dst_func_insts.at(match_result.dst_id), match_result.src_match, match_result.dst_match, 0); @@ -1598,7 +1694,6 @@ void Differ::MatchFunctionParamIds(const opt::Function* src_func, GroupIdsAndMatch( src_params, dst_params, "", &Differ::GetSanitizedName, [this](const IdGroup& src_group, const IdGroup& dst_group) { - // There shouldn't be two parameters with the same name, so the ids // should match. There is nothing restricting the SPIR-V however to have // two parameters with the same name, so be resilient against that. @@ -1609,17 +1704,17 @@ void Differ::MatchFunctionParamIds(const opt::Function* src_func, // Then match the parameters by their type. If there are multiple of them, // match them by their order. - GroupIdsAndMatch( - src_params, dst_params, 0, &Differ::GroupIdsHelperGetTypeId, + GroupIdsAndMatchByMappedId( + src_params, dst_params, &Differ::GroupIdsHelperGetTypeId, [this](const IdGroup& src_group_by_type_id, const IdGroup& dst_group_by_type_id) { - const size_t shared_param_count = std::min(src_group_by_type_id.size(), dst_group_by_type_id.size()); for (size_t param_index = 0; param_index < shared_param_count; ++param_index) { - id_map_.MapIds(src_group_by_type_id[0], dst_group_by_type_id[0]); + id_map_.MapIds(src_group_by_type_id[param_index], + dst_group_by_type_id[param_index]); } }); } @@ -1943,6 +2038,10 @@ spv_number_kind_t Differ::GetNumberKind(const IdInstructions& id_to, // Always unsigned integers. *number_bit_width = 32; return SPV_NUMBER_UNSIGNED_INT; + case SPV_OPERAND_TYPE_LITERAL_FLOAT: + // Always float. + *number_bit_width = 32; + return SPV_NUMBER_FLOATING; case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: case SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER: switch (inst.opcode()) { @@ -2064,9 +2163,10 @@ void Differ::MatchEntryPointIds() { } // Otherwise match them by name. - bool matched = false; for (const opt::Instruction* src_inst : src_insts) { for (const opt::Instruction* dst_inst : dst_insts) { + if (id_map_.IsDstMapped(dst_inst)) continue; + const opt::Operand& src_name = src_inst->GetOperand(2); const opt::Operand& dst_name = dst_inst->GetOperand(2); @@ -2075,13 +2175,9 @@ void Differ::MatchEntryPointIds() { uint32_t dst_id = dst_inst->GetSingleWordOperand(1); id_map_.MapIds(src_id, dst_id); id_map_.MapInsts(src_inst, dst_inst); - matched = true; break; } } - if (matched) { - break; - } } } } @@ -2126,7 +2222,6 @@ void Differ::MatchTypeForwardPointers() { spv::StorageClass::Max, &Differ::GroupIdsHelperGetTypePointerStorageClass, [this](const IdGroup& src_group_by_storage_class, const IdGroup& dst_group_by_storage_class) { - // Group them further by the type they are pointing to and loop over // them. GroupIdsAndMatch( @@ -2134,7 +2229,6 @@ void Differ::MatchTypeForwardPointers() { spv::Op::Max, &Differ::GroupIdsHelperGetTypePointerTypeOp, [this](const IdGroup& src_group_by_type_op, const IdGroup& dst_group_by_type_op) { - // Group them even further by debug info, if possible and match by // debug name. MatchTypeForwardPointersByName(src_group_by_type_op, @@ -2199,7 +2293,9 @@ void Differ::MatchTypeIds() { case spv::Op::OpTypeVoid: case spv::Op::OpTypeBool: case spv::Op::OpTypeSampler: - // void, bool and sampler are unique, match them. + case spv::Op::OpTypeAccelerationStructureNV: + case spv::Op::OpTypeRayQueryKHR: + // the above types have no operands and are unique, match them. return true; case spv::Op::OpTypeInt: case spv::Op::OpTypeFloat: @@ -2378,7 +2474,6 @@ void Differ::MatchFunctions() { GroupIdsAndMatch( src_func_ids, dst_func_ids, "", &Differ::GetSanitizedName, [this](const IdGroup& src_group, const IdGroup& dst_group) { - // If there is a single function with this name in src and dst, it's a // definite match. if (src_group.size() == 1 && dst_group.size() == 1) { @@ -2392,7 +2487,6 @@ void Differ::MatchFunctions() { &Differ::GroupIdsHelperGetTypeId, [this](const IdGroup& src_group_by_type_id, const IdGroup& dst_group_by_type_id) { - if (src_group_by_type_id.size() == 1 && dst_group_by_type_id.size() == 1) { id_map_.MapIds(src_group_by_type_id[0], @@ -2437,7 +2531,6 @@ void Differ::MatchFunctions() { src_func_ids, dst_func_ids, 0, &Differ::GroupIdsHelperGetTypeId, [this](const IdGroup& src_group_by_type_id, const IdGroup& dst_group_by_type_id) { - BestEffortMatchFunctions(src_group_by_type_id, dst_group_by_type_id, src_func_insts_, dst_func_insts_); }); @@ -2647,7 +2740,9 @@ opt::Instruction Differ::ToMappedSrcIds(const opt::Instruction& dst_inst) { } spv_result_t Differ::Output() { - id_map_.MapUnmatchedIds(); + id_map_.MapUnmatchedIds( + [this](uint32_t src_id) { return src_id_to_.IsDefined(src_id); }, + [this](uint32_t dst_id) { return dst_id_to_.IsDefined(dst_id); }); src_id_to_.inst_map_.resize(id_map_.SrcToDstMap().IdBound(), nullptr); dst_id_to_.inst_map_.resize(id_map_.DstToSrcMap().IdBound(), nullptr); diff --git a/third_party/spirv-tools/source/disassemble.cpp b/third_party/spirv-tools/source/disassemble.cpp index f862efd56b..93791a0ca7 100644 --- a/third_party/spirv-tools/source/disassemble.cpp +++ b/third_party/spirv-tools/source/disassemble.cpp @@ -23,7 +23,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include @@ -43,6 +47,70 @@ namespace spvtools { namespace { +// Indices to ControlFlowGraph's list of blocks from one block to its successors +struct BlockSuccessors { + // Merge block in OpLoopMerge and OpSelectionMerge + uint32_t merge_block_id = 0; + // The continue block in OpLoopMerge + uint32_t continue_block_id = 0; + // The true and false blocks in OpBranchConditional + uint32_t true_block_id = 0; + uint32_t false_block_id = 0; + // The body block of a loop, as specified by OpBranch after a merge + // instruction + uint32_t body_block_id = 0; + // The same-nesting-level block that follows this one, indicated by an + // OpBranch with no merge instruction. + uint32_t next_block_id = 0; + // The cases (including default) of an OpSwitch + std::vector case_block_ids; +}; + +class ParsedInstruction { + public: + ParsedInstruction(const spv_parsed_instruction_t* instruction) { + // Make a copy of the parsed instruction, including stable memory for its + // operands. + instruction_ = *instruction; + operands_ = + std::make_unique(instruction->num_operands); + memcpy(operands_.get(), instruction->operands, + instruction->num_operands * sizeof(*instruction->operands)); + instruction_.operands = operands_.get(); + } + + const spv_parsed_instruction_t* get() const { return &instruction_; } + + private: + spv_parsed_instruction_t instruction_; + std::unique_ptr operands_; +}; + +// One block in the CFG +struct SingleBlock { + // The byte offset in the SPIR-V where the block starts. Used for printing in + // a comment. + size_t byte_offset; + + // Block instructions + std::vector instructions; + + // Successors of this block + BlockSuccessors successors; + + // The nesting level for this block. + uint32_t nest_level = 0; + bool nest_level_assigned = false; + + // Whether the block was reachable + bool reachable = false; +}; + +// CFG for one function +struct ControlFlowGraph { + std::vector blocks; +}; + // A Disassembler instance converts a SPIR-V binary to its assembly // representation. class Disassembler { @@ -50,6 +118,10 @@ class Disassembler { Disassembler(const AssemblyGrammar& grammar, uint32_t options, NameMapper name_mapper) : print_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options)), + nested_indent_( + spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, options)), + reorder_blocks_( + spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS, options)), text_(), out_(print_ ? out_stream() : out_stream(text_)), instruction_disassembler_(grammar, out_.get(), options, name_mapper), @@ -70,7 +142,13 @@ class Disassembler { spv_result_t SaveTextResult(spv_text* text_result) const; private: + void EmitCFG(); + const bool print_; // Should we also print to the standard output stream? + const bool nested_indent_; // Should the blocks be indented according to the + // control flow structure? + const bool + reorder_blocks_; // Should the blocks be reordered for readability? spv_endianness_t endian_; // The detected endianness of the binary. std::stringstream text_; // Captures the text, if not printing. out_stream out_; // The Output stream. Either to text_ or standard output. @@ -80,6 +158,9 @@ class Disassembler { bool inserted_decoration_space_ = false; bool inserted_debug_space_ = false; bool inserted_type_space_ = false; + + // The CFG for the current function + ControlFlowGraph current_function_cfg_; }; spv_result_t Disassembler::HandleHeader(spv_endianness_t endian, @@ -106,13 +187,336 @@ spv_result_t Disassembler::HandleInstruction( inserted_debug_space_, inserted_type_space_); - instruction_disassembler_.EmitInstruction(inst, byte_offset_); + // When nesting needs to be calculated or when the blocks are reordered, we + // have to have the full picture of the CFG first. Defer processing of the + // instructions until the entire function is visited. This is not done + // without those options (even if simpler) to improve debuggability; for + // example to be able to see whatever is parsed so far even if there is a + // parse error. + if (nested_indent_ || reorder_blocks_) { + switch (static_cast(inst.opcode)) { + case spv::Op::OpLabel: { + // Add a new block to the CFG + SingleBlock new_block; + new_block.byte_offset = byte_offset_; + new_block.instructions.emplace_back(&inst); + current_function_cfg_.blocks.push_back(std::move(new_block)); + break; + } + case spv::Op::OpFunctionEnd: + // Process the CFG and output the instructions + EmitCFG(); + // Output OpFunctionEnd itself too + [[fallthrough]]; + default: + if (!current_function_cfg_.blocks.empty()) { + // If in a function, stash the instruction for later. + current_function_cfg_.blocks.back().instructions.emplace_back(&inst); + } else { + // Otherwise emit the instruction right away. + instruction_disassembler_.EmitInstruction(inst, byte_offset_); + } + break; + } + } else { + instruction_disassembler_.EmitInstruction(inst, byte_offset_); + } byte_offset_ += inst.num_words * sizeof(uint32_t); return SPV_SUCCESS; } +// Helper to get the operand of an instruction as an id. +uint32_t GetOperand(const spv_parsed_instruction_t* instruction, + uint32_t operand) { + return instruction->words[instruction->operands[operand].offset]; +} + +std::unordered_map BuildControlFlowGraph( + ControlFlowGraph& cfg) { + std::unordered_map id_to_index; + + for (size_t index = 0; index < cfg.blocks.size(); ++index) { + SingleBlock& block = cfg.blocks[index]; + + // For future use, build the ID->index map + assert(static_cast(block.instructions[0].get()->opcode) == + spv::Op::OpLabel); + const uint32_t id = block.instructions[0].get()->result_id; + + id_to_index[id] = static_cast(index); + + // Look for a merge instruction first. The function of OpBranch depends on + // that. + if (block.instructions.size() >= 3) { + const spv_parsed_instruction_t* maybe_merge = + block.instructions[block.instructions.size() - 2].get(); + + switch (static_cast(maybe_merge->opcode)) { + case spv::Op::OpLoopMerge: + block.successors.merge_block_id = GetOperand(maybe_merge, 0); + block.successors.continue_block_id = GetOperand(maybe_merge, 1); + break; + + case spv::Op::OpSelectionMerge: + block.successors.merge_block_id = GetOperand(maybe_merge, 0); + break; + + default: + break; + } + } + + // Then look at the last instruction; it must be a branch + assert(block.instructions.size() >= 2); + + const spv_parsed_instruction_t* branch = block.instructions.back().get(); + switch (static_cast(branch->opcode)) { + case spv::Op::OpBranch: + if (block.successors.merge_block_id != 0) { + block.successors.body_block_id = GetOperand(branch, 0); + } else { + block.successors.next_block_id = GetOperand(branch, 0); + } + break; + + case spv::Op::OpBranchConditional: + block.successors.true_block_id = GetOperand(branch, 1); + block.successors.false_block_id = GetOperand(branch, 2); + break; + + case spv::Op::OpSwitch: + for (uint32_t case_index = 1; case_index < branch->num_operands; + case_index += 2) { + block.successors.case_block_ids.push_back( + GetOperand(branch, case_index)); + } + break; + + default: + break; + } + } + + return id_to_index; +} + +// Helper to deal with nesting and non-existing ids / previously-assigned +// levels. It assigns a given nesting level `level` to the block identified by +// `id` (unless that block already has a nesting level assigned). +void Nest(ControlFlowGraph& cfg, + const std::unordered_map& id_to_index, + uint32_t id, uint32_t level) { + if (id == 0) { + return; + } + + const uint32_t block_index = id_to_index.at(id); + SingleBlock& block = cfg.blocks[block_index]; + + if (!block.nest_level_assigned) { + block.nest_level = level; + block.nest_level_assigned = true; + } +} + +// For a given block, assign nesting level to its successors. +void NestSuccessors(ControlFlowGraph& cfg, const SingleBlock& block, + const std::unordered_map& id_to_index) { + assert(block.nest_level_assigned); + + // Nest loops as such: + // + // %loop = OpLabel + // OpLoopMerge %merge %cont ... + // OpBranch %body + // %body = OpLabel + // Op... + // %cont = OpLabel + // Op... + // %merge = OpLabel + // Op... + // + // Nest conditional branches as such: + // + // %header = OpLabel + // OpSelectionMerge %merge ... + // OpBranchConditional ... %true %false + // %true = OpLabel + // Op... + // %false = OpLabel + // Op... + // %merge = OpLabel + // Op... + // + // Nest switch/case as such: + // + // %header = OpLabel + // OpSelectionMerge %merge ... + // OpSwitch ... %default ... %case0 ... %case1 ... + // %default = OpLabel + // Op... + // %case0 = OpLabel + // Op... + // %case1 = OpLabel + // Op... + // ... + // %merge = OpLabel + // Op... + // + // The following can be observed: + // + // - In all cases, the merge block has the same nesting as this block + // - The continue block of loops is nested 1 level deeper + // - The body/branches/cases are nested 2 levels deeper + // + // Back branches to the header block, branches to the merge block, etc + // are correctly handled by processing the header block first (that is + // _this_ block, already processed), then following the above rules + // (in the same order) for any block that is not already processed. + Nest(cfg, id_to_index, block.successors.merge_block_id, block.nest_level); + Nest(cfg, id_to_index, block.successors.continue_block_id, + block.nest_level + 1); + Nest(cfg, id_to_index, block.successors.true_block_id, block.nest_level + 2); + Nest(cfg, id_to_index, block.successors.false_block_id, block.nest_level + 2); + Nest(cfg, id_to_index, block.successors.body_block_id, block.nest_level + 2); + Nest(cfg, id_to_index, block.successors.next_block_id, block.nest_level); + for (uint32_t case_block_id : block.successors.case_block_ids) { + Nest(cfg, id_to_index, case_block_id, block.nest_level + 2); + } +} + +struct StackEntry { + // The index of the block (in ControlFlowGraph::blocks) to process. + uint32_t block_index; + // Whether this is the pre or post visit of the block. Because a post-visit + // traversal is needed, the same block is pushed back on the stack on + // pre-visit so it can be visited again on post-visit. + bool post_visit = false; +}; + +// Helper to deal with DFS traversal and non-existing ids +void VisitSuccesor(std::stack* dfs_stack, + const std::unordered_map& id_to_index, + uint32_t id) { + if (id != 0) { + dfs_stack->push({id_to_index.at(id), false}); + } +} + +// Given the control flow graph, calculates and returns the reverse post-order +// ordering of the blocks. The blocks are then disassembled in that order for +// readability. +std::vector OrderBlocks( + ControlFlowGraph& cfg, + const std::unordered_map& id_to_index) { + std::vector post_order; + + // Nest level of a function's first block is 0. + cfg.blocks[0].nest_level = 0; + cfg.blocks[0].nest_level_assigned = true; + + // Stack of block indices as they are visited. + std::stack dfs_stack; + dfs_stack.push({0, false}); + + std::set visited; + + while (!dfs_stack.empty()) { + const uint32_t block_index = dfs_stack.top().block_index; + const bool post_visit = dfs_stack.top().post_visit; + dfs_stack.pop(); + + // If this is the second time the block is visited, that's the post-order + // visit. + if (post_visit) { + post_order.push_back(block_index); + continue; + } + + // If already visited, another path got to it first (like a case + // fallthrough), avoid reprocessing it. + if (visited.count(block_index) > 0) { + continue; + } + visited.insert(block_index); + + // Push it back in the stack for post-order visit + dfs_stack.push({block_index, true}); + + SingleBlock& block = cfg.blocks[block_index]; + + // Assign nest levels of successors right away. The successors are either + // nested under this block, or are back or forward edges to blocks outside + // this nesting level (no farther than the merge block), whose nesting + // levels are already assigned before this block is visited. + NestSuccessors(cfg, block, id_to_index); + block.reachable = true; + + // The post-order visit yields the order in which the blocks are naturally + // ordered _backwards_. So blocks to be ordered last should be visited + // first. In other words, they should be pushed to the DFS stack last. + VisitSuccesor(&dfs_stack, id_to_index, block.successors.true_block_id); + VisitSuccesor(&dfs_stack, id_to_index, block.successors.false_block_id); + VisitSuccesor(&dfs_stack, id_to_index, block.successors.body_block_id); + VisitSuccesor(&dfs_stack, id_to_index, block.successors.next_block_id); + for (uint32_t case_block_id : block.successors.case_block_ids) { + VisitSuccesor(&dfs_stack, id_to_index, case_block_id); + } + VisitSuccesor(&dfs_stack, id_to_index, block.successors.continue_block_id); + VisitSuccesor(&dfs_stack, id_to_index, block.successors.merge_block_id); + } + + std::vector order(post_order.rbegin(), post_order.rend()); + + // Finally, dump all unreachable blocks at the end + for (size_t index = 0; index < cfg.blocks.size(); ++index) { + SingleBlock& block = cfg.blocks[index]; + + if (!block.reachable) { + order.push_back(static_cast(index)); + block.nest_level = 0; + block.nest_level_assigned = true; + } + } + + return order; +} + +void Disassembler::EmitCFG() { + // Build the CFG edges. At the same time, build an ID->block index map to + // simplify building the CFG edges. + const std::unordered_map id_to_index = + BuildControlFlowGraph(current_function_cfg_); + + // Walk the CFG in reverse post-order to find the best ordering of blocks for + // presentation + std::vector block_order = + OrderBlocks(current_function_cfg_, id_to_index); + assert(block_order.size() == current_function_cfg_.blocks.size()); + + // Walk the CFG either in block order or input order based on whether the + // reorder_blocks_ option is given. + for (uint32_t index = 0; index < current_function_cfg_.blocks.size(); + ++index) { + const uint32_t block_index = reorder_blocks_ ? block_order[index] : index; + const SingleBlock& block = current_function_cfg_.blocks[block_index]; + + // Emit instructions for this block + size_t byte_offset = block.byte_offset; + assert(block.nest_level_assigned); + + for (const ParsedInstruction& inst : block.instructions) { + instruction_disassembler_.EmitInstructionInBlock(*inst.get(), byte_offset, + block.nest_level); + byte_offset += inst.get()->num_words * sizeof(uint32_t); + } + } + + current_function_cfg_.blocks.clear(); +} + spv_result_t Disassembler::SaveTextResult(spv_text* text_result) const { if (!print_) { size_t length = text_.str().size(); @@ -194,7 +598,29 @@ spv_result_t DisassembleTargetInstruction( return SPV_SUCCESS; } +uint32_t GetLineLengthWithoutColor(const std::string line) { + // Currently, every added color is in the form \x1b...m, so instead of doing a + // lot of string comparisons with spvtools::clr::* strings, we just ignore + // those ranges. + uint32_t length = 0; + for (size_t i = 0; i < line.size(); ++i) { + if (line[i] == '\x1b') { + do { + ++i; + } while (i < line.size() && line[i] != 'm'); + continue; + } + + ++length; + } + + return length; +} + constexpr int kStandardIndent = 15; +constexpr int kBlockNestIndent = 2; +constexpr int kBlockBodyIndentOffset = 2; +constexpr uint32_t kCommentColumn = 50; } // namespace namespace disassemble { @@ -209,10 +635,13 @@ InstructionDisassembler::InstructionDisassembler(const AssemblyGrammar& grammar, indent_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_INDENT, options) ? kStandardIndent : 0), + nested_indent_( + spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, options)), comment_(spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_COMMENT, options)), show_byte_offset_( spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET, options)), - name_mapper_(std::move(name_mapper)) {} + name_mapper_(std::move(name_mapper)), + last_instruction_comment_alignment_(0) {} void InstructionDisassembler::EmitHeaderSpirv() { stream_ << "; SPIR-V\n"; } @@ -244,55 +673,160 @@ void InstructionDisassembler::EmitHeaderSchema(uint32_t schema) { void InstructionDisassembler::EmitInstruction( const spv_parsed_instruction_t& inst, size_t inst_byte_offset) { + EmitInstructionImpl(inst, inst_byte_offset, 0, false); +} + +void InstructionDisassembler::EmitInstructionInBlock( + const spv_parsed_instruction_t& inst, size_t inst_byte_offset, + uint32_t block_indent) { + EmitInstructionImpl(inst, inst_byte_offset, block_indent, true); +} + +void InstructionDisassembler::EmitInstructionImpl( + const spv_parsed_instruction_t& inst, size_t inst_byte_offset, + uint32_t block_indent, bool is_in_block) { auto opcode = static_cast(inst.opcode); + // To better align the comments (if any), write the instruction to a line + // first so its length can be readily available. + std::ostringstream line; + + if (nested_indent_ && opcode == spv::Op::OpLabel) { + // Separate the blocks by an empty line to make them easier to separate + stream_ << std::endl; + } + if (inst.result_id) { SetBlue(); const std::string id_name = name_mapper_(inst.result_id); if (indent_) - stream_ << std::setw(std::max(0, indent_ - 3 - int(id_name.size()))); - stream_ << "%" << id_name; + line << std::setw(std::max(0, indent_ - 3 - int(id_name.size()))); + line << "%" << id_name; ResetColor(); - stream_ << " = "; + line << " = "; } else { - stream_ << std::string(indent_, ' '); + line << std::string(indent_, ' '); } - stream_ << "Op" << spvOpcodeString(opcode); + if (nested_indent_ && is_in_block) { + // Output OpLabel at the specified nest level, and instructions inside + // blocks nested a little more. + uint32_t indent = block_indent; + bool body_indent = opcode != spv::Op::OpLabel; + + line << std::string( + indent * kBlockNestIndent + (body_indent ? kBlockBodyIndentOffset : 0), + ' '); + } + + line << "Op" << spvOpcodeString(opcode); for (uint16_t i = 0; i < inst.num_operands; i++) { const spv_operand_type_t type = inst.operands[i].type; assert(type != SPV_OPERAND_TYPE_NONE); if (type == SPV_OPERAND_TYPE_RESULT_ID) continue; - stream_ << " "; - EmitOperand(inst, i); + line << " "; + EmitOperand(line, inst, i); + } + + // For the sake of comment generation, store information from some + // instructions for the future. + if (comment_) { + GenerateCommentForDecoratedId(inst); + } + + std::ostringstream comments; + const char* comment_separator = ""; + + if (show_byte_offset_) { + SetGrey(comments); + auto saved_flags = comments.flags(); + auto saved_fill = comments.fill(); + comments << comment_separator << "0x" << std::setw(8) << std::hex + << std::setfill('0') << inst_byte_offset; + comments.flags(saved_flags); + comments.fill(saved_fill); + ResetColor(comments); + comment_separator = ", "; } if (comment_ && opcode == spv::Op::OpName) { const spv_parsed_operand_t& operand = inst.operands[0]; const uint32_t word = inst.words[operand.offset]; - stream_ << " ; id %" << word; + comments << comment_separator << "id %" << word; + comment_separator = ", "; } - if (show_byte_offset_) { - SetGrey(); - auto saved_flags = stream_.flags(); - auto saved_fill = stream_.fill(); - stream_ << " ; 0x" << std::setw(8) << std::hex << std::setfill('0') - << inst_byte_offset; - stream_.flags(saved_flags); - stream_.fill(saved_fill); - ResetColor(); + if (comment_ && inst.result_id && id_comments_.count(inst.result_id) > 0) { + comments << comment_separator << id_comments_[inst.result_id].str(); + comment_separator = ", "; } + + stream_ << line.str(); + + if (!comments.str().empty()) { + // Align the comments + const uint32_t line_length = GetLineLengthWithoutColor(line.str()); + uint32_t align = std::max( + {line_length + 2, last_instruction_comment_alignment_, kCommentColumn}); + // Round up the alignment to a multiple of 4 for more niceness. + align = (align + 3) & ~0x3u; + last_instruction_comment_alignment_ = align; + + stream_ << std::string(align - line_length, ' ') << "; " << comments.str(); + } else { + last_instruction_comment_alignment_ = 0; + } + stream_ << "\n"; } +void InstructionDisassembler::GenerateCommentForDecoratedId( + const spv_parsed_instruction_t& inst) { + assert(comment_); + auto opcode = static_cast(inst.opcode); + + std::ostringstream partial; + uint32_t id = 0; + const char* separator = ""; + + switch (opcode) { + case spv::Op::OpDecorate: + // Take everything after `OpDecorate %id` and associate it with id. + id = inst.words[inst.operands[0].offset]; + for (uint16_t i = 1; i < inst.num_operands; i++) { + partial << separator; + separator = " "; + EmitOperand(partial, inst, i); + } + break; + default: + break; + } + + if (id == 0) { + return; + } + + // Add the new comment to the comments of this id + std::ostringstream& id_comment = id_comments_[id]; + if (!id_comment.str().empty()) { + id_comment << ", "; + } + id_comment << partial.str(); +} + void InstructionDisassembler::EmitSectionComment( const spv_parsed_instruction_t& inst, bool& inserted_decoration_space, bool& inserted_debug_space, bool& inserted_type_space) { auto opcode = static_cast(inst.opcode); if (comment_ && opcode == spv::Op::OpFunction) { stream_ << std::endl; + if (nested_indent_) { + // Double the empty lines between Function sections since nested_indent_ + // also separates blocks by a blank. + stream_ << std::endl; + } stream_ << std::string(indent_, ' '); stream_ << "; Function " << name_mapper_(inst.result_id) << std::endl; } @@ -316,36 +850,37 @@ void InstructionDisassembler::EmitSectionComment( } } -void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst, - const uint16_t operand_index) { +void InstructionDisassembler::EmitOperand(std::ostream& stream, + const spv_parsed_instruction_t& inst, + const uint16_t operand_index) const { assert(operand_index < inst.num_operands); const spv_parsed_operand_t& operand = inst.operands[operand_index]; const uint32_t word = inst.words[operand.offset]; switch (operand.type) { case SPV_OPERAND_TYPE_RESULT_ID: assert(false && " is not supposed to be handled here"); - SetBlue(); - stream_ << "%" << name_mapper_(word); + SetBlue(stream); + stream << "%" << name_mapper_(word); break; case SPV_OPERAND_TYPE_ID: case SPV_OPERAND_TYPE_TYPE_ID: case SPV_OPERAND_TYPE_SCOPE_ID: case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID: - SetYellow(); - stream_ << "%" << name_mapper_(word); + SetYellow(stream); + stream << "%" << name_mapper_(word); break; case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: { spv_ext_inst_desc ext_inst; - SetRed(); + SetRed(stream); if (grammar_.lookupExtInst(inst.ext_inst_type, word, &ext_inst) == SPV_SUCCESS) { - stream_ << ext_inst->name; + stream << ext_inst->name; } else { if (!spvExtInstIsNonSemantic(inst.ext_inst_type)) { assert(false && "should have caught this earlier"); } else { // for non-semantic instruction sets we can just print the number - stream_ << word; + stream << word; } } } break; @@ -353,26 +888,27 @@ void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst, spv_opcode_desc opcode_desc; if (grammar_.lookupOpcode(spv::Op(word), &opcode_desc)) assert(false && "should have caught this earlier"); - SetRed(); - stream_ << opcode_desc->name; + SetRed(stream); + stream << opcode_desc->name; } break; case SPV_OPERAND_TYPE_LITERAL_INTEGER: - case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: { - SetRed(); - EmitNumericLiteral(&stream_, inst, operand); - ResetColor(); + case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: + case SPV_OPERAND_TYPE_LITERAL_FLOAT: { + SetRed(stream); + EmitNumericLiteral(&stream, inst, operand); + ResetColor(stream); } break; case SPV_OPERAND_TYPE_LITERAL_STRING: { - stream_ << "\""; - SetGreen(); + stream << "\""; + SetGreen(stream); std::string str = spvDecodeLiteralStringOperand(inst, operand_index); for (char const& c : str) { - if (c == '"' || c == '\\') stream_ << '\\'; - stream_ << c; + if (c == '"' || c == '\\') stream << '\\'; + stream << c; } - ResetColor(); - stream_ << '"'; + ResetColor(stream); + stream << '"'; } break; case SPV_OPERAND_TYPE_CAPABILITY: case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: @@ -410,11 +946,12 @@ void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst, case SPV_OPERAND_TYPE_FPDENORM_MODE: case SPV_OPERAND_TYPE_FPOPERATION_MODE: case SPV_OPERAND_TYPE_QUANTIZATION_MODES: + case SPV_OPERAND_TYPE_FPENCODING: case SPV_OPERAND_TYPE_OVERFLOW_MODES: { spv_operand_desc entry; if (grammar_.lookupOperand(operand.type, word, &entry)) assert(false && "should have caught this earlier"); - stream_ << entry->name; + stream << entry->name; } break; case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE: case SPV_OPERAND_TYPE_FUNCTION_CONTROL: @@ -424,26 +961,28 @@ void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst, case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: - EmitMaskOperand(operand.type, word); + case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS: + EmitMaskOperand(stream, operand.type, word); break; default: if (spvOperandIsConcreteMask(operand.type)) { - EmitMaskOperand(operand.type, word); + EmitMaskOperand(stream, operand.type, word); } else if (spvOperandIsConcrete(operand.type)) { spv_operand_desc entry; if (grammar_.lookupOperand(operand.type, word, &entry)) assert(false && "should have caught this earlier"); - stream_ << entry->name; + stream << entry->name; } else { assert(false && "unhandled or invalid case"); } break; } - ResetColor(); + ResetColor(stream); } -void InstructionDisassembler::EmitMaskOperand(const spv_operand_type_t type, - const uint32_t word) { +void InstructionDisassembler::EmitMaskOperand(std::ostream& stream, + const spv_operand_type_t type, + const uint32_t word) const { // Scan the mask from least significant bit to most significant bit. For each // set bit, emit the name of that bit. Separate multiple names with '|'. uint32_t remaining_word = word; @@ -455,8 +994,8 @@ void InstructionDisassembler::EmitMaskOperand(const spv_operand_type_t type, spv_operand_desc entry; if (grammar_.lookupOperand(type, mask, &entry)) assert(false && "should have caught this earlier"); - if (num_emitted) stream_ << "|"; - stream_ << entry->name; + if (num_emitted) stream << "|"; + stream << entry->name; num_emitted++; } } @@ -465,28 +1004,35 @@ void InstructionDisassembler::EmitMaskOperand(const spv_operand_type_t type, // of the 0 value. In many cases, that's "None". spv_operand_desc entry; if (SPV_SUCCESS == grammar_.lookupOperand(type, 0, &entry)) - stream_ << entry->name; + stream << entry->name; } } -void InstructionDisassembler::ResetColor() { - if (color_) stream_ << spvtools::clr::reset{print_}; +void InstructionDisassembler::ResetColor(std::ostream& stream) const { + if (color_) stream << spvtools::clr::reset{print_}; } -void InstructionDisassembler::SetGrey() { - if (color_) stream_ << spvtools::clr::grey{print_}; +void InstructionDisassembler::SetGrey(std::ostream& stream) const { + if (color_) stream << spvtools::clr::grey{print_}; } -void InstructionDisassembler::SetBlue() { - if (color_) stream_ << spvtools::clr::blue{print_}; +void InstructionDisassembler::SetBlue(std::ostream& stream) const { + if (color_) stream << spvtools::clr::blue{print_}; } -void InstructionDisassembler::SetYellow() { - if (color_) stream_ << spvtools::clr::yellow{print_}; +void InstructionDisassembler::SetYellow(std::ostream& stream) const { + if (color_) stream << spvtools::clr::yellow{print_}; } -void InstructionDisassembler::SetRed() { - if (color_) stream_ << spvtools::clr::red{print_}; +void InstructionDisassembler::SetRed(std::ostream& stream) const { + if (color_) stream << spvtools::clr::red{print_}; } -void InstructionDisassembler::SetGreen() { - if (color_) stream_ << spvtools::clr::green{print_}; +void InstructionDisassembler::SetGreen(std::ostream& stream) const { + if (color_) stream << spvtools::clr::green{print_}; } + +void InstructionDisassembler::ResetColor() { ResetColor(stream_); } +void InstructionDisassembler::SetGrey() { SetGrey(stream_); } +void InstructionDisassembler::SetBlue() { SetBlue(stream_); } +void InstructionDisassembler::SetYellow() { SetYellow(stream_); } +void InstructionDisassembler::SetRed() { SetRed(stream_); } +void InstructionDisassembler::SetGreen() { SetGreen(stream_); } } // namespace disassemble std::string spvInstructionBinaryToText(const spv_target_env env, diff --git a/third_party/spirv-tools/source/disassemble.h b/third_party/spirv-tools/source/disassemble.h index b520a1ea91..b6d13c647b 100644 --- a/third_party/spirv-tools/source/disassemble.h +++ b/third_party/spirv-tools/source/disassemble.h @@ -15,7 +15,8 @@ #ifndef SOURCE_DISASSEMBLE_H_ #define SOURCE_DISASSEMBLE_H_ -#include +#include +#include #include #include "source/name_mapper.h" @@ -57,6 +58,11 @@ class InstructionDisassembler { // Emits the assembly text for the given instruction. void EmitInstruction(const spv_parsed_instruction_t& inst, size_t inst_byte_offset); + // Same as EmitInstruction, but only for block instructions (including + // OpLabel) and useful for nested indentation. If nested indentation is not + // desired, EmitInstruction can still be used for block instructions. + void EmitInstructionInBlock(const spv_parsed_instruction_t& inst, + size_t inst_byte_offset, uint32_t block_indent); // Emits a comment between different sections of the module. void EmitSectionComment(const spv_parsed_instruction_t& inst, @@ -74,22 +80,46 @@ class InstructionDisassembler { void SetGreen(); private: + void ResetColor(std::ostream& stream) const; + void SetGrey(std::ostream& stream) const; + void SetBlue(std::ostream& stream) const; + void SetYellow(std::ostream& stream) const; + void SetRed(std::ostream& stream) const; + void SetGreen(std::ostream& stream) const; + + void EmitInstructionImpl(const spv_parsed_instruction_t& inst, + size_t inst_byte_offset, uint32_t block_indent, + bool is_in_block); + // Emits an operand for the given instruction, where the instruction // is at offset words from the start of the binary. - void EmitOperand(const spv_parsed_instruction_t& inst, - const uint16_t operand_index); + void EmitOperand(std::ostream& stream, const spv_parsed_instruction_t& inst, + uint16_t operand_index) const; // Emits a mask expression for the given mask word of the specified type. - void EmitMaskOperand(const spv_operand_type_t type, const uint32_t word); + void EmitMaskOperand(std::ostream& stream, spv_operand_type_t type, + uint32_t word) const; + + // Generate part of the instruction as a comment to be added to + // |id_comments_|. + void GenerateCommentForDecoratedId(const spv_parsed_instruction_t& inst); const spvtools::AssemblyGrammar& grammar_; std::ostream& stream_; - const bool print_; // Should we also print to the standard output stream? - const bool color_; // Should we print in colour? - const int indent_; // How much to indent. 0 means don't indent - const int comment_; // Should we comment the source + const bool print_; // Should we also print to the standard output stream? + const bool color_; // Should we print in colour? + const int indent_; // How much to indent. 0 means don't indent + const bool nested_indent_; // Whether indentation should indicate nesting + const int comment_; // Should we comment the source const bool show_byte_offset_; // Should we print byte offset, in hex? spvtools::NameMapper name_mapper_; + + // Some comments are generated as instructions (such as OpDecorate) are + // visited so that when the instruction with that result id is visited, the + // comment can be output. + std::unordered_map id_comments_; + // Align the comments in consecutive lines for more readability. + uint32_t last_instruction_comment_alignment_; }; } // namespace disassemble diff --git a/third_party/spirv-tools/source/enum_set.h b/third_party/spirv-tools/source/enum_set.h index 28ee5fee8d..340f5b9786 100644 --- a/third_party/spirv-tools/source/enum_set.h +++ b/third_party/spirv-tools/source/enum_set.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016 Google Inc. +// Copyright (c) 2023 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,195 +12,459 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + #ifndef SOURCE_ENUM_SET_H_ #define SOURCE_ENUM_SET_H_ -#include -#include -#include -#include -#include - #include "source/latest_version_spirv_header.h" -#include "source/util/make_unique.h" namespace spvtools { -// A set of values of a 32-bit enum type. -// It is fast and compact for the common case, where enum values -// are at most 63. But it can represent enums with larger values, -// as may appear in extensions. -template +// This container is optimized to store and retrieve unsigned enum values. +// The base model for this implementation is an open-addressing hashtable with +// linear probing. For small enums (max index < 64), all operations are O(1). +// +// - Enums are stored in buckets (64 contiguous values max per bucket) +// - Buckets ranges don't overlap, but don't have to be contiguous. +// - Enums are packed into 64-bits buckets, using 1 bit per enum value. +// +// Example: +// - MyEnum { A = 0, B = 1, C = 64, D = 65 } +// - 2 buckets are required: +// - bucket 0, storing values in the range [ 0; 64[ +// - bucket 1, storing values in the range [64; 128[ +// +// - Buckets are stored in a sorted vector (sorted by bucket range). +// - Retrieval is done by computing the theoretical bucket index using the enum +// value, and +// doing a linear scan from this position. +// - Insertion is done by retrieving the bucket and either: +// - inserting a new bucket in the sorted vector when no buckets has a +// compatible range. +// - setting the corresponding bit in the bucket. +// This means insertion in the middle/beginning can cause a memmove when no +// bucket is available. In our case, this happens at most 23 times for the +// largest enum we have (Opcodes). +template class EnumSet { private: - // The ForEach method will call the functor on enum values in - // enum value order (lowest to highest). To make that easier, use - // an ordered set for the overflow values. - using OverflowSetType = std::set; + using BucketType = uint64_t; + using ElementType = std::underlying_type_t; + static_assert(std::is_enum_v, "EnumSets only works with enums."); + static_assert(std::is_signed_v == false, + "EnumSet doesn't supports signed enums."); + + // Each bucket can hold up to `kBucketSize` distinct, contiguous enum values. + // The first value a bucket can hold must be aligned on `kBucketSize`. + struct Bucket { + // bit mask to store `kBucketSize` enums. + BucketType data; + // 1st enum this bucket can represent. + T start; + + friend bool operator==(const Bucket& lhs, const Bucket& rhs) { + return lhs.start == rhs.start && lhs.data == rhs.data; + } + }; + + // How many distinct values can a bucket hold? 1 bit per value. + static constexpr size_t kBucketSize = sizeof(BucketType) * 8ULL; public: - // Construct an empty set. - EnumSet() {} - // Construct an set with just the given enum value. - explicit EnumSet(EnumType c) { Add(c); } - // Construct an set from an initializer list of enum values. - EnumSet(std::initializer_list cs) { - for (auto c : cs) Add(c); - } - EnumSet(uint32_t count, const EnumType* ptr) { - for (uint32_t i = 0; i < count; ++i) Add(ptr[i]); - } - // Copy constructor. - EnumSet(const EnumSet& other) { *this = other; } - // Move constructor. The moved-from set is emptied. - EnumSet(EnumSet&& other) { - mask_ = other.mask_; - overflow_ = std::move(other.overflow_); - other.mask_ = 0; - other.overflow_.reset(nullptr); - } - // Assignment operator. - EnumSet& operator=(const EnumSet& other) { - if (&other != this) { - mask_ = other.mask_; - overflow_.reset(other.overflow_ ? new OverflowSetType(*other.overflow_) - : nullptr); + class Iterator { + public: + typedef Iterator self_type; + typedef T value_type; + typedef T& reference; + typedef T* pointer; + typedef std::forward_iterator_tag iterator_category; + typedef size_t difference_type; + + Iterator(const Iterator& other) + : set_(other.set_), + bucketIndex_(other.bucketIndex_), + bucketOffset_(other.bucketOffset_) {} + + Iterator& operator++() { + do { + if (bucketIndex_ >= set_->buckets_.size()) { + bucketIndex_ = set_->buckets_.size(); + bucketOffset_ = 0; + break; + } + + if (bucketOffset_ + 1 == kBucketSize) { + bucketOffset_ = 0; + ++bucketIndex_; + } else { + ++bucketOffset_; + } + + } while (bucketIndex_ < set_->buckets_.size() && + !set_->HasEnumAt(bucketIndex_, bucketOffset_)); + return *this; } + + Iterator operator++(int) { + Iterator old = *this; + operator++(); + return old; + } + + T operator*() const { + assert(set_->HasEnumAt(bucketIndex_, bucketOffset_) && + "operator*() called on an invalid iterator."); + return GetValueFromBucket(set_->buckets_[bucketIndex_], bucketOffset_); + } + + bool operator!=(const Iterator& other) const { + return set_ != other.set_ || bucketOffset_ != other.bucketOffset_ || + bucketIndex_ != other.bucketIndex_; + } + + bool operator==(const Iterator& other) const { + return !(operator!=(other)); + } + + Iterator& operator=(const Iterator& other) { + set_ = other.set_; + bucketIndex_ = other.bucketIndex_; + bucketOffset_ = other.bucketOffset_; + return *this; + } + + private: + Iterator(const EnumSet* set, size_t bucketIndex, ElementType bucketOffset) + : set_(set), bucketIndex_(bucketIndex), bucketOffset_(bucketOffset) {} + + private: + const EnumSet* set_ = nullptr; + // Index of the bucket in the vector. + size_t bucketIndex_ = 0; + // Offset in bits in the current bucket. + ElementType bucketOffset_ = 0; + + friend class EnumSet; + }; + + // Required to allow the use of std::inserter. + using value_type = T; + using const_iterator = Iterator; + using iterator = Iterator; + + public: + iterator cbegin() const noexcept { + auto it = iterator(this, /* bucketIndex= */ 0, /* bucketOffset= */ 0); + if (buckets_.size() == 0) { + return it; + } + + // The iterator has the logic to find the next valid bit. If the value 0 + // is not stored, use it to find the next valid bit. + if (!HasEnumAt(it.bucketIndex_, it.bucketOffset_)) { + ++it; + } + + return it; + } + + iterator begin() const noexcept { return cbegin(); } + + iterator cend() const noexcept { + return iterator(this, buckets_.size(), /* bucketOffset= */ 0); + } + + iterator end() const noexcept { return cend(); } + + // Creates an empty set. + EnumSet() : buckets_(0), size_(0) {} + + // Creates a set and store `value` in it. + EnumSet(T value) : EnumSet() { insert(value); } + + // Creates a set and stores each `values` in it. + EnumSet(std::initializer_list values) : EnumSet() { + for (auto item : values) { + insert(item); + } + } + + // Creates a set, and insert `count` enum values pointed by `array` in it. + EnumSet(ElementType count, const T* array) : EnumSet() { + for (ElementType i = 0; i < count; i++) { + insert(array[i]); + } + } + + // Creates a set initialized with the content of the range [begin; end[. + template + EnumSet(InputIt begin, InputIt end) : EnumSet() { + for (; begin != end; ++begin) { + insert(*begin); + } + } + + // Copies the EnumSet `other` into a new EnumSet. + EnumSet(const EnumSet& other) + : buckets_(other.buckets_), size_(other.size_) {} + + // Moves the EnumSet `other` into a new EnumSet. + EnumSet(EnumSet&& other) + : buckets_(std::move(other.buckets_)), size_(other.size_) {} + + // Deep-copies the EnumSet `other` into this EnumSet. + EnumSet& operator=(const EnumSet& other) { + buckets_ = other.buckets_; + size_ = other.size_; return *this; } - friend bool operator==(const EnumSet& a, const EnumSet& b) { - if (a.mask_ != b.mask_) { - return false; + // Matches std::unordered_set::insert behavior. + std::pair insert(const T& value) { + const size_t index = FindBucketForValue(value); + const ElementType offset = ComputeBucketOffset(value); + + if (index >= buckets_.size() || + buckets_[index].start != ComputeBucketStart(value)) { + size_ += 1; + InsertBucketFor(index, value); + return std::make_pair(Iterator(this, index, offset), true); } - if (a.overflow_ == nullptr && b.overflow_ == nullptr) { + auto& bucket = buckets_[index]; + const auto mask = ComputeMaskForValue(value); + if (bucket.data & mask) { + return std::make_pair(Iterator(this, index, offset), false); + } + + size_ += 1; + bucket.data |= ComputeMaskForValue(value); + return std::make_pair(Iterator(this, index, offset), true); + } + + // Inserts `value` in the set if possible. + // Similar to `std::unordered_set::insert`, except the hint is ignored. + // Returns an iterator to the inserted element, or the element preventing + // insertion. + iterator insert(const_iterator, const T& value) { + return insert(value).first; + } + + // Inserts `value` in the set if possible. + // Similar to `std::unordered_set::insert`, except the hint is ignored. + // Returns an iterator to the inserted element, or the element preventing + // insertion. + iterator insert(const_iterator, T&& value) { return insert(value).first; } + + // Inserts all the values in the range [`first`; `last[. + // Similar to `std::unordered_set::insert`. + template + void insert(InputIt first, InputIt last) { + for (auto it = first; it != last; ++it) { + insert(*it); + } + } + + // Removes the value `value` into the set. + // Similar to `std::unordered_set::erase`. + // Returns the number of erased elements. + size_t erase(const T& value) { + const size_t index = FindBucketForValue(value); + if (index >= buckets_.size() || + buckets_[index].start != ComputeBucketStart(value)) { + return 0; + } + + auto& bucket = buckets_[index]; + const auto mask = ComputeMaskForValue(value); + if (!(bucket.data & mask)) { + return 0; + } + + size_ -= 1; + bucket.data &= ~mask; + if (bucket.data == 0) { + buckets_.erase(buckets_.cbegin() + index); + } + return 1; + } + + // Returns true if `value` is present in the set. + bool contains(T value) const { + const size_t index = FindBucketForValue(value); + if (index >= buckets_.size() || + buckets_[index].start != ComputeBucketStart(value)) { + return false; + } + auto& bucket = buckets_[index]; + return bucket.data & ComputeMaskForValue(value); + } + + // Returns the 1 if `value` is present in the set, `0` otherwise. + inline size_t count(T value) const { return contains(value) ? 1 : 0; } + + // Returns true if the set is holds no values. + inline bool empty() const { return size_ == 0; } + + // Returns the number of enums stored in this set. + size_t size() const { return size_; } + + // Returns true if this set contains at least one value contained in `in_set`. + // Note: If `in_set` is empty, this function returns true. + bool HasAnyOf(const EnumSet& in_set) const { + if (in_set.empty()) { return true; } - if (a.overflow_ == nullptr || b.overflow_ == nullptr) { - return false; - } + auto lhs = buckets_.cbegin(); + auto rhs = in_set.buckets_.cbegin(); - return *a.overflow_ == *b.overflow_; - } + while (lhs != buckets_.cend() && rhs != in_set.buckets_.cend()) { + if (lhs->start == rhs->start) { + if (lhs->data & rhs->data) { + // At least 1 bit is shared. Early return. + return true; + } - friend bool operator!=(const EnumSet& a, const EnumSet& b) { - return !(a == b); - } + lhs++; + rhs++; + continue; + } - // Adds the given enum value to the set. This has no effect if the - // enum value is already in the set. - void Add(EnumType c) { AddWord(ToWord(c)); } + // LHS bucket is smaller than the current RHS bucket. Catching up on RHS. + if (lhs->start < rhs->start) { + lhs++; + continue; + } - // Removes the given enum value from the set. This has no effect if the - // enum value is not in the set. - void Remove(EnumType c) { RemoveWord(ToWord(c)); } - - // Returns true if this enum value is in the set. - bool Contains(EnumType c) const { return ContainsWord(ToWord(c)); } - - // Applies f to each enum in the set, in order from smallest enum - // value to largest. - void ForEach(std::function f) const { - for (uint32_t i = 0; i < 64; ++i) { - if (mask_ & AsMask(i)) f(static_cast(i)); - } - if (overflow_) { - for (uint32_t c : *overflow_) f(static_cast(c)); - } - } - - // Returns true if the set is empty. - bool IsEmpty() const { - if (mask_) return false; - if (overflow_ && !overflow_->empty()) return false; - return true; - } - - // Returns true if the set contains ANY of the elements of |in_set|, - // or if |in_set| is empty. - bool HasAnyOf(const EnumSet& in_set) const { - if (in_set.IsEmpty()) return true; - - if (mask_ & in_set.mask_) return true; - - if (!overflow_ || !in_set.overflow_) return false; - - for (uint32_t item : *in_set.overflow_) { - if (overflow_->find(item) != overflow_->end()) return true; + // Otherwise, RHS needs to catch up on LHS. + rhs++; } return false; } private: - // Adds the given enum value (as a 32-bit word) to the set. This has no - // effect if the enum value is already in the set. - void AddWord(uint32_t word) { - if (auto new_bits = AsMask(word)) { - mask_ |= new_bits; - } else { - Overflow().insert(word); + // Returns the index of the last bucket in which `value` could be stored. + static constexpr inline size_t ComputeLargestPossibleBucketIndexFor(T value) { + return static_cast(value) / kBucketSize; + } + + // Returns the smallest enum value that could be contained in the same bucket + // as `value`. + static constexpr inline T ComputeBucketStart(T value) { + return static_cast(kBucketSize * + ComputeLargestPossibleBucketIndexFor(value)); + } + + // Returns the index of the bit that corresponds to `value` in the bucket. + static constexpr inline ElementType ComputeBucketOffset(T value) { + return static_cast(value) % kBucketSize; + } + + // Returns the bitmask used to represent the enum `value` in its bucket. + static constexpr inline BucketType ComputeMaskForValue(T value) { + return 1ULL << ComputeBucketOffset(value); + } + + // Returns the `enum` stored in `bucket` at `offset`. + // `offset` is the bit-offset in the bucket storage. + static constexpr inline T GetValueFromBucket(const Bucket& bucket, + BucketType offset) { + return static_cast(static_cast(bucket.start) + offset); + } + + // For a given enum `value`, finds the bucket index that could contain this + // value. If no such bucket is found, the index at which the new bucket should + // be inserted is returned. + size_t FindBucketForValue(T value) const { + // Set is empty, insert at 0. + if (buckets_.size() == 0) { + return 0; } - } - // Removes the given enum value (as a 32-bit word) from the set. This has no - // effect if the enum value is not in the set. - void RemoveWord(uint32_t word) { - if (auto new_bits = AsMask(word)) { - mask_ &= ~new_bits; - } else { - auto itr = Overflow().find(word); - if (itr != Overflow().end()) Overflow().erase(itr); + const T wanted_start = ComputeBucketStart(value); + assert(buckets_.size() > 0 && + "Size must not be 0 here. Has the code above changed?"); + size_t index = std::min(buckets_.size() - 1, + ComputeLargestPossibleBucketIndexFor(value)); + + // This loops behaves like std::upper_bound with a reverse iterator. + // Buckets are sorted. 3 main cases: + // - The bucket matches + // => returns the bucket index. + // - The found bucket is larger + // => scans left until it finds the correct bucket, or insertion point. + // - The found bucket is smaller + // => We are at the end, so we return past-end index for insertion. + for (; buckets_[index].start >= wanted_start; index--) { + if (index == 0) { + return 0; + } } + + return index + 1; } - // Returns true if the enum represented as a 32-bit word is in the set. - bool ContainsWord(uint32_t word) const { - // We shouldn't call Overflow() since this is a const method. - if (auto bits = AsMask(word)) { - return (mask_ & bits) != 0; - } else if (auto overflow = overflow_.get()) { - return overflow->find(word) != overflow->end(); + // Creates a new bucket to store `value` and inserts it at `index`. + // If the `index` is past the end, the bucket is inserted at the end of the + // vector. + void InsertBucketFor(size_t index, T value) { + const T bucket_start = ComputeBucketStart(value); + Bucket bucket = {1ULL << ComputeBucketOffset(value), bucket_start}; + auto it = buckets_.emplace(buckets_.begin() + index, std::move(bucket)); +#if defined(NDEBUG) + (void)it; // Silencing unused variable warning. +#else + assert(std::next(it) == buckets_.end() || + std::next(it)->start > bucket_start); + assert(it == buckets_.begin() || std::prev(it)->start < bucket_start); +#endif + } + + // Returns true if the bucket at `bucketIndex/ stores the enum at + // `bucketOffset`, false otherwise. + bool HasEnumAt(size_t bucketIndex, BucketType bucketOffset) const { + assert(bucketIndex < buckets_.size()); + assert(bucketOffset < kBucketSize); + return buckets_[bucketIndex].data & (1ULL << bucketOffset); + } + + // Returns true if `lhs` and `rhs` hold the exact same values. + friend bool operator==(const EnumSet& lhs, const EnumSet& rhs) { + if (lhs.size_ != rhs.size_) { + return false; } - // The word is large, but the set doesn't have large members, so - // it doesn't have an overflow set. - return false; - } - // Returns the enum value as a uint32_t. - uint32_t ToWord(EnumType value) const { - static_assert(sizeof(EnumType) <= sizeof(uint32_t), - "EnumType must statically castable to uint32_t"); - return static_cast(value); - } - - // Determines whether the given enum value can be represented - // as a bit in a uint64_t mask. If so, then returns that mask bit. - // Otherwise, returns 0. - uint64_t AsMask(uint32_t word) const { - if (word > 63) return 0; - return uint64_t(1) << word; - } - - // Ensures that overflow_set_ references a set. A new empty set is - // allocated if one doesn't exist yet. Returns overflow_set_. - OverflowSetType& Overflow() { - if (overflow_.get() == nullptr) { - overflow_ = MakeUnique(); + if (lhs.buckets_.size() != rhs.buckets_.size()) { + return false; } - return *overflow_; + return lhs.buckets_ == rhs.buckets_; } - // Enums with values up to 63 are stored as bits in this mask. - uint64_t mask_ = 0; - // Enums with values larger than 63 are stored in this set. - // This set should normally be empty or very small. - std::unique_ptr overflow_ = {}; + // Returns true if `lhs` and `rhs` hold at least 1 different value. + friend bool operator!=(const EnumSet& lhs, const EnumSet& rhs) { + return !(lhs == rhs); + } + + // Storage for the buckets. + std::vector buckets_; + // How many enums is this set storing. + size_t size_ = 0; }; -// A set of spv::Capability, optimized for small capability values. +// A set of spv::Capability. using CapabilitySet = EnumSet; } // namespace spvtools diff --git a/third_party/spirv-tools/source/ext_inst.cpp b/third_party/spirv-tools/source/ext_inst.cpp index 4e2795453f..f2ff63fc20 100644 --- a/third_party/spirv-tools/source/ext_inst.cpp +++ b/third_party/spirv-tools/source/ext_inst.cpp @@ -30,6 +30,7 @@ #include "glsl.std.450.insts.inc" #include "nonsemantic.clspvreflection.insts.inc" #include "nonsemantic.shader.debuginfo.100.insts.inc" +#include "nonsemantic.vkspreflection.insts.inc" #include "opencl.debuginfo.100.insts.inc" #include "opencl.std.insts.inc" @@ -62,6 +63,9 @@ static const spv_ext_inst_group_t kGroups_1_0[] = { {SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION, ARRAY_SIZE(nonsemantic_clspvreflection_entries), nonsemantic_clspvreflection_entries}, + {SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION, + ARRAY_SIZE(nonsemantic_vkspreflection_entries), + nonsemantic_vkspreflection_entries}, }; static const spv_ext_inst_table_t kTable_1_0 = {ARRAY_SIZE(kGroups_1_0), @@ -98,6 +102,7 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable, case SPV_ENV_VULKAN_1_2: case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: *pExtInstTable = &kTable_1_0; return SPV_SUCCESS; default: @@ -138,6 +143,9 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) { if (!strncmp("NonSemantic.ClspvReflection.", name, 28)) { return SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION; } + if (!strncmp("NonSemantic.VkspReflection.", name, 27)) { + return SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION; + } // ensure to add any known non-semantic extended instruction sets // above this point, and update spvExtInstIsNonSemantic() if (!strncmp("NonSemantic.", name, 12)) { @@ -149,7 +157,8 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) { bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) { if (type == SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN || type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 || - type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION) { + type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION || + type == SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION) { return true; } return false; diff --git a/third_party/spirv-tools/source/extensions.cpp b/third_party/spirv-tools/source/extensions.cpp index ebf6bec061..ac987fcc0e 100644 --- a/third_party/spirv-tools/source/extensions.cpp +++ b/third_party/spirv-tools/source/extensions.cpp @@ -40,8 +40,9 @@ std::string GetExtensionString(const spv_parsed_instruction_t* inst) { std::string ExtensionSetToString(const ExtensionSet& extensions) { std::stringstream ss; - extensions.ForEach( - [&ss](Extension ext) { ss << ExtensionToString(ext) << " "; }); + for (auto extension : extensions) { + ss << ExtensionToString(extension) << " "; + } return ss.str(); } diff --git a/third_party/spirv-tools/source/extensions.h b/third_party/spirv-tools/source/extensions.h index 8023444c31..cda4924a47 100644 --- a/third_party/spirv-tools/source/extensions.h +++ b/third_party/spirv-tools/source/extensions.h @@ -15,6 +15,7 @@ #ifndef SOURCE_EXTENSIONS_H_ #define SOURCE_EXTENSIONS_H_ +#include #include #include "source/enum_set.h" @@ -23,7 +24,7 @@ namespace spvtools { // The known SPIR-V extensions. -enum Extension { +enum Extension : uint32_t { #include "extension_enum.inc" }; diff --git a/third_party/spirv-tools/source/fuzz/CMakeLists.txt b/third_party/spirv-tools/source/fuzz/CMakeLists.txt index dd674dd04c..86ee657a1c 100644 --- a/third_party/spirv-tools/source/fuzz/CMakeLists.txt +++ b/third_party/spirv-tools/source/fuzz/CMakeLists.txt @@ -470,10 +470,7 @@ if(SPIRV_BUILD_FUZZER) spvtools_check_symbol_exports(SPIRV-Tools-fuzz) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets) export(EXPORT SPIRV-Tools-fuzzTargets FILE SPIRV-Tools-fuzzTarget.cmake) spvtools_config_package_dir(SPIRV-Tools-fuzz PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/fuzz/protobufs/spirvfuzz_protobufs.h b/third_party/spirv-tools/source/fuzz/protobufs/spirvfuzz_protobufs.h index 46c218814e..44aecfd62f 100644 --- a/third_party/spirv-tools/source/fuzz/protobufs/spirvfuzz_protobufs.h +++ b/third_party/spirv-tools/source/fuzz/protobufs/spirvfuzz_protobufs.h @@ -21,6 +21,10 @@ // of these header files without having to compromise on freedom from warnings // in the rest of the project. +#ifndef GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE +#define GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE 1 +#endif + #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-warning-option" // Must come first @@ -28,6 +32,8 @@ #pragma clang diagnostic ignored "-Wshadow" #pragma clang diagnostic ignored "-Wsuggest-destructor-override" #pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi" +#pragma clang diagnostic ignored "-Wshorten-64-to-32" #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" diff --git a/third_party/spirv-tools/source/fuzz/transformation_add_no_contraction_decoration.cpp b/third_party/spirv-tools/source/fuzz/transformation_add_no_contraction_decoration.cpp index 07a31e5cb5..87393e95b0 100644 --- a/third_party/spirv-tools/source/fuzz/transformation_add_no_contraction_decoration.cpp +++ b/third_party/spirv-tools/source/fuzz/transformation_add_no_contraction_decoration.cpp @@ -36,6 +36,11 @@ bool TransformationAddNoContractionDecoration::IsApplicable( if (!instr) { return false; } + // |instr| must not be decorated with NoContraction. + if (ir_context->get_decoration_mgr()->HasDecoration( + message_.result_id(), spv::Decoration::NoContraction)) { + return false; + } // The instruction must be arithmetic. return IsArithmetic(instr->opcode()); } diff --git a/third_party/spirv-tools/source/fuzz/transformation_add_relaxed_decoration.cpp b/third_party/spirv-tools/source/fuzz/transformation_add_relaxed_decoration.cpp index 6cd4ecbb3f..601546c978 100644 --- a/third_party/spirv-tools/source/fuzz/transformation_add_relaxed_decoration.cpp +++ b/third_party/spirv-tools/source/fuzz/transformation_add_relaxed_decoration.cpp @@ -36,6 +36,11 @@ bool TransformationAddRelaxedDecoration::IsApplicable( if (!instr) { return false; } + // |instr| must not be decorated with RelaxedPrecision. + if (ir_context->get_decoration_mgr()->HasDecoration( + message_.result_id(), spv::Decoration::RelaxedPrecision)) { + return false; + } opt::BasicBlock* cur_block = ir_context->get_instr_block(instr); // The instruction must have a block. if (cur_block == nullptr) { @@ -46,6 +51,7 @@ bool TransformationAddRelaxedDecoration::IsApplicable( cur_block->id()))) { return false; } + // The instruction must be numeric. return IsNumeric(instr->opcode()); } diff --git a/third_party/spirv-tools/source/libspirv.cpp b/third_party/spirv-tools/source/libspirv.cpp index be76caaa8b..83e8629b70 100644 --- a/third_party/spirv-tools/source/libspirv.cpp +++ b/third_party/spirv-tools/source/libspirv.cpp @@ -108,6 +108,40 @@ bool SpirvTools::Disassemble(const uint32_t* binary, const size_t binary_size, return status == SPV_SUCCESS; } +struct CxxParserContext { + const HeaderParser& header_parser; + const InstructionParser& instruction_parser; +}; + +bool SpirvTools::Parse(const std::vector& binary, + const HeaderParser& header_parser, + const InstructionParser& instruction_parser, + spv_diagnostic* diagnostic) { + CxxParserContext parser_context = {header_parser, instruction_parser}; + + spv_parsed_header_fn_t header_fn_wrapper = + [](void* user_data, spv_endianness_t endianness, uint32_t magic, + uint32_t version, uint32_t generator, uint32_t id_bound, + uint32_t reserved) { + CxxParserContext* ctx = reinterpret_cast(user_data); + spv_parsed_header_t header = {magic, version, generator, id_bound, + reserved}; + + return ctx->header_parser(endianness, header); + }; + + spv_parsed_instruction_fn_t instruction_fn_wrapper = + [](void* user_data, const spv_parsed_instruction_t* instruction) { + CxxParserContext* ctx = reinterpret_cast(user_data); + return ctx->instruction_parser(*instruction); + }; + + spv_result_t status = spvBinaryParse( + impl_->context, &parser_context, binary.data(), binary.size(), + header_fn_wrapper, instruction_fn_wrapper, diagnostic); + return status == SPV_SUCCESS; +} + bool SpirvTools::Validate(const std::vector& binary) const { return Validate(binary.data(), binary.size()); } diff --git a/third_party/spirv-tools/source/link/CMakeLists.txt b/third_party/spirv-tools/source/link/CMakeLists.txt index a452a107df..a35b9a58fd 100644 --- a/third_party/spirv-tools/source/link/CMakeLists.txt +++ b/third_party/spirv-tools/source/link/CMakeLists.txt @@ -31,10 +31,7 @@ set_property(TARGET SPIRV-Tools-link PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-link) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-link EXPORT SPIRV-Tools-linkTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-link EXPORT SPIRV-Tools-linkTargets) export(EXPORT SPIRV-Tools-linkTargets FILE SPIRV-Tools-linkTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-link PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/link/linker.cpp b/third_party/spirv-tools/source/link/linker.cpp index e50391a1b3..d030e2afbc 100644 --- a/third_party/spirv-tools/source/link/linker.cpp +++ b/third_party/spirv-tools/source/link/linker.cpp @@ -31,6 +31,7 @@ #include "source/opt/build_module.h" #include "source/opt/compact_ids_pass.h" #include "source/opt/decoration_manager.h" +#include "source/opt/ir_builder.h" #include "source/opt/ir_loader.h" #include "source/opt/pass_manager.h" #include "source/opt/remove_duplicates_pass.h" @@ -46,12 +47,14 @@ namespace spvtools { namespace { using opt::Instruction; +using opt::InstructionBuilder; using opt::IRContext; using opt::Module; using opt::PassManager; using opt::RemoveDuplicatesPass; using opt::analysis::DecorationManager; using opt::analysis::DefUseManager; +using opt::analysis::Function; using opt::analysis::Type; using opt::analysis::TypeManager; @@ -91,7 +94,8 @@ spv_result_t ShiftIdsInModules(const MessageConsumer& consumer, // should be non-null. |max_id_bound| should be strictly greater than 0. spv_result_t GenerateHeader(const MessageConsumer& consumer, const std::vector& modules, - uint32_t max_id_bound, opt::ModuleHeader* header); + uint32_t max_id_bound, opt::ModuleHeader* header, + const LinkerOptions& options); // Merge all the modules from |in_modules| into a single module owned by // |linked_context|. @@ -125,6 +129,7 @@ spv_result_t GetImportExportPairs(const MessageConsumer& consumer, // checked. spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer, const LinkageTable& linkings_to_do, + bool allow_ptr_type_mismatch, opt::IRContext* context); // Remove linkage specific instructions, such as prototypes of imported @@ -202,7 +207,8 @@ spv_result_t ShiftIdsInModules(const MessageConsumer& consumer, spv_result_t GenerateHeader(const MessageConsumer& consumer, const std::vector& modules, - uint32_t max_id_bound, opt::ModuleHeader* header) { + uint32_t max_id_bound, opt::ModuleHeader* header, + const LinkerOptions& options) { spv_position_t position = {}; if (modules.empty()) @@ -212,10 +218,12 @@ spv_result_t GenerateHeader(const MessageConsumer& consumer, return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_DATA) << "|max_id_bound| of GenerateHeader should not be null."; - const uint32_t linked_version = modules.front()->version(); + uint32_t linked_version = modules.front()->version(); for (std::size_t i = 1; i < modules.size(); ++i) { const uint32_t module_version = modules[i]->version(); - if (module_version != linked_version) + if (options.GetUseHighestVersion()) { + linked_version = std::max(linked_version, module_version); + } else if (module_version != linked_version) { return DiagnosticStream({0, 0, 1}, consumer, "", SPV_ERROR_INTERNAL) << "Conflicting SPIR-V versions: " << SPV_SPIRV_VERSION_MAJOR_PART(linked_version) << "." @@ -224,6 +232,7 @@ spv_result_t GenerateHeader(const MessageConsumer& consumer, << SPV_SPIRV_VERSION_MAJOR_PART(module_version) << "." << SPV_SPIRV_VERSION_MINOR_PART(module_version) << " (input module " << (i + 1) << ")."; + } } header->magic_number = spv::MagicNumber; @@ -411,6 +420,7 @@ spv_result_t GetImportExportPairs(const MessageConsumer& consumer, std::vector imports; std::unordered_map> exports; + std::unordered_map linkonce; // Figure out the imports and exports for (const auto& decoration : linked_context.annotations()) { @@ -469,10 +479,24 @@ spv_result_t GetImportExportPairs(const MessageConsumer& consumer, << " LinkageAttributes; " << id << " is neither of them.\n"; } - if (spv::LinkageType(type) == spv::LinkageType::Import) + if (spv::LinkageType(type) == spv::LinkageType::Import) { imports.push_back(symbol_info); - else if (spv::LinkageType(type) == spv::LinkageType::Export) + } else if (spv::LinkageType(type) == spv::LinkageType::Export) { exports[symbol_info.name].push_back(symbol_info); + } else if (spv::LinkageType(type) == spv::LinkageType::LinkOnceODR) { + if (linkonce.find(symbol_info.name) == linkonce.end()) + linkonce[symbol_info.name] = symbol_info; + } + } + + for (const auto& possible_export : linkonce) { + if (exports.find(possible_export.first) == exports.end()) + exports[possible_export.first].push_back(possible_export.second); + else + return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_BINARY) + << "Combination of Export and LinkOnceODR is not allowed, found " + "for \"" + << possible_export.second.name << "\"."; } // Find the import/export pairs @@ -497,6 +521,7 @@ spv_result_t GetImportExportPairs(const MessageConsumer& consumer, spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer, const LinkageTable& linkings_to_do, + bool allow_ptr_type_mismatch, opt::IRContext* context) { spv_position_t position = {}; @@ -508,7 +533,34 @@ spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer, type_manager.GetType(linking_entry.imported_symbol.type_id); Type* exported_symbol_type = type_manager.GetType(linking_entry.exported_symbol.type_id); - if (!(*imported_symbol_type == *exported_symbol_type)) + if (!(*imported_symbol_type == *exported_symbol_type)) { + Function* imported_symbol_type_func = imported_symbol_type->AsFunction(); + Function* exported_symbol_type_func = exported_symbol_type->AsFunction(); + + if (imported_symbol_type_func && exported_symbol_type_func) { + const auto& imported_params = imported_symbol_type_func->param_types(); + const auto& exported_params = exported_symbol_type_func->param_types(); + // allow_ptr_type_mismatch allows linking functions where the pointer + // type of arguments doesn't match. Everything else still needs to be + // equal. This is to workaround LLVM-17+ not having typed pointers and + // generated SPIR-Vs not knowing the actual pointer types in some cases. + if (allow_ptr_type_mismatch && + imported_params.size() == exported_params.size()) { + bool correct = true; + for (size_t i = 0; i < imported_params.size(); i++) { + const auto& imported_param = imported_params[i]; + const auto& exported_param = exported_params[i]; + + if (!imported_param->IsSame(exported_param) && + (imported_param->kind() != Type::kPointer || + exported_param->kind() != Type::kPointer)) { + correct = false; + break; + } + } + if (correct) continue; + } + } return DiagnosticStream(position, consumer, "", SPV_ERROR_INVALID_BINARY) << "Type mismatch on symbol \"" << linking_entry.imported_symbol.name @@ -516,6 +568,7 @@ spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer, << linking_entry.imported_symbol.id << " and exported variable/function %" << linking_entry.exported_symbol.id << "."; + } } // Ensure the import and export decorations are similar @@ -691,6 +744,57 @@ spv_result_t VerifyLimits(const MessageConsumer& consumer, return SPV_SUCCESS; } +spv_result_t FixFunctionCallTypes(opt::IRContext& context, + const LinkageTable& linkings) { + auto mod = context.module(); + const auto type_manager = context.get_type_mgr(); + const auto def_use_mgr = context.get_def_use_mgr(); + + for (auto& func : *mod) { + func.ForEachInst([&](Instruction* inst) { + if (inst->opcode() != spv::Op::OpFunctionCall) return; + opt::Operand& target = inst->GetInOperand(0); + + // only fix calls to imported functions + auto linking = std::find_if( + linkings.begin(), linkings.end(), [&](const auto& entry) { + return entry.exported_symbol.id == target.AsId(); + }); + if (linking == linkings.end()) return; + + auto builder = InstructionBuilder(&context, inst); + for (uint32_t i = 1; i < inst->NumInOperands(); ++i) { + auto exported_func_param = + def_use_mgr->GetDef(linking->exported_symbol.parameter_ids[i - 1]); + const Type* target_type = + type_manager->GetType(exported_func_param->type_id()); + if (target_type->kind() != Type::kPointer) continue; + + opt::Operand& arg = inst->GetInOperand(i); + const Type* param_type = + type_manager->GetType(def_use_mgr->GetDef(arg.AsId())->type_id()); + + // No need to cast if it already matches + if (*param_type == *target_type) continue; + + auto new_id = context.TakeNextId(); + + // cast to the expected pointer type + builder.AddInstruction(MakeUnique( + &context, spv::Op::OpBitcast, exported_func_param->type_id(), + new_id, + opt::Instruction::OperandList( + {{SPV_OPERAND_TYPE_ID, {arg.AsId()}}}))); + + inst->SetInOperand(i, {new_id}); + } + }); + } + context.InvalidateAnalyses(opt::IRContext::kAnalysisDefUse | + opt::IRContext::kAnalysisInstrToBlockMapping); + return SPV_SUCCESS; +} + } // namespace spv_result_t Link(const Context& context, @@ -753,7 +857,7 @@ spv_result_t Link(const Context& context, const uint32_t* const* binaries, // Phase 2: Generate the header opt::ModuleHeader header; - res = GenerateHeader(consumer, modules, max_id_bound, &header); + res = GenerateHeader(consumer, modules, max_id_bound, &header, options); if (res != SPV_SUCCESS) return res; IRContext linked_context(c_context->target_env, consumer); linked_context.module()->SetHeader(header); @@ -768,7 +872,14 @@ spv_result_t Link(const Context& context, const uint32_t* const* binaries, if (res != SPV_SUCCESS) return res; } - // Phase 4: Find the import/export pairs + // Phase 4: Remove duplicates + PassManager manager; + manager.SetMessageConsumer(consumer); + manager.AddPass(); + opt::Pass::Status pass_res = manager.Run(&linked_context); + if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; + + // Phase 5: Find the import/export pairs LinkageTable linkings_to_do; res = GetImportExportPairs(consumer, linked_context, *linked_context.get_def_use_mgr(), @@ -776,18 +887,12 @@ spv_result_t Link(const Context& context, const uint32_t* const* binaries, options.GetAllowPartialLinkage(), &linkings_to_do); if (res != SPV_SUCCESS) return res; - // Phase 5: Ensure the import and export have the same types and decorations. - res = - CheckImportExportCompatibility(consumer, linkings_to_do, &linked_context); + // Phase 6: Ensure the import and export have the same types and decorations. + res = CheckImportExportCompatibility(consumer, linkings_to_do, + options.GetAllowPtrTypeMismatch(), + &linked_context); if (res != SPV_SUCCESS) return res; - // Phase 6: Remove duplicates - PassManager manager; - manager.SetMessageConsumer(consumer); - manager.AddPass(); - opt::Pass::Status pass_res = manager.Run(&linked_context); - if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; - // Phase 7: Remove all names and decorations of import variables/functions for (const auto& linking_entry : linkings_to_do) { linked_context.KillNamesAndDecorates(linking_entry.imported_symbol.id); @@ -810,21 +915,27 @@ spv_result_t Link(const Context& context, const uint32_t* const* binaries, &linked_context); if (res != SPV_SUCCESS) return res; - // Phase 10: Compact the IDs used in the module + // Phase 10: Optionally fix function call types + if (options.GetAllowPtrTypeMismatch()) { + res = FixFunctionCallTypes(linked_context, linkings_to_do); + if (res != SPV_SUCCESS) return res; + } + + // Phase 11: Compact the IDs used in the module manager.AddPass(); pass_res = manager.Run(&linked_context); if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; - // Phase 11: Recompute EntryPoint variables + // Phase 12: Recompute EntryPoint variables manager.AddPass(); pass_res = manager.Run(&linked_context); if (pass_res == opt::Pass::Status::Failure) return SPV_ERROR_INVALID_DATA; - // Phase 12: Warn if SPIR-V limits were exceeded + // Phase 13: Warn if SPIR-V limits were exceeded res = VerifyLimits(consumer, linked_context); if (res != SPV_SUCCESS) return res; - // Phase 13: Output the module + // Phase 14: Output the module linked_context.module()->ToBinary(linked_binary, true); return SPV_SUCCESS; diff --git a/third_party/spirv-tools/source/lint/CMakeLists.txt b/third_party/spirv-tools/source/lint/CMakeLists.txt index 1feae3f94d..4704beb1fc 100644 --- a/third_party/spirv-tools/source/lint/CMakeLists.txt +++ b/third_party/spirv-tools/source/lint/CMakeLists.txt @@ -46,10 +46,7 @@ set_property(TARGET SPIRV-Tools-lint PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-lint) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-lint EXPORT SPIRV-Tools-lintTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-lint EXPORT SPIRV-Tools-lintTargets) export(EXPORT SPIRV-Tools-lintTargets FILE SPIRV-Tools-lintTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-lint PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/name_mapper.cpp b/third_party/spirv-tools/source/name_mapper.cpp index b2d0f44525..24c24e2c73 100644 --- a/third_party/spirv-tools/source/name_mapper.cpp +++ b/third_party/spirv-tools/source/name_mapper.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2016 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,24 +27,15 @@ #include "source/binary.h" #include "source/latest_version_spirv_header.h" #include "source/parsed_operand.h" +#include "source/to_string.h" #include "spirv-tools/libspirv.h" namespace spvtools { -namespace { -// Converts a uint32_t to its string decimal representation. -std::string to_string(uint32_t id) { - // Use stringstream, since some versions of Android compilers lack - // std::to_string. - std::stringstream os; - os << id; - return os.str(); +NameMapper GetTrivialNameMapper() { + return [](uint32_t i) { return spvtools::to_string(i); }; } -} // anonymous namespace - -NameMapper GetTrivialNameMapper() { return to_string; } - FriendlyNameMapper::FriendlyNameMapper(const spv_const_context context, const uint32_t* code, const size_t wordCount) @@ -218,6 +211,7 @@ spv_result_t FriendlyNameMapper::ParseInstruction( } break; case spv::Op::OpTypeFloat: { const auto bit_width = inst.words[2]; + // TODO: Handle optional fpencoding enum once actually used. switch (bit_width) { case 16: SaveName(result_id, "half"); @@ -249,12 +243,21 @@ spv_result_t FriendlyNameMapper::ParseInstruction( SaveName(result_id, std::string("_runtimearr_") + NameForId(inst.words[2])); break; + case spv::Op::OpTypeNodePayloadArrayAMDX: + SaveName(result_id, + std::string("_payloadarr_") + NameForId(inst.words[2])); + break; case spv::Op::OpTypePointer: SaveName(result_id, std::string("_ptr_") + NameForEnumOperand(SPV_OPERAND_TYPE_STORAGE_CLASS, inst.words[2]) + "_" + NameForId(inst.words[3])); break; + case spv::Op::OpTypeUntypedPointerKHR: + SaveName(result_id, std::string("_ptr_") + + NameForEnumOperand(SPV_OPERAND_TYPE_STORAGE_CLASS, + inst.words[2])); + break; case spv::Op::OpTypePipe: SaveName(result_id, std::string("Pipe") + diff --git a/third_party/spirv-tools/source/opcode.cpp b/third_party/spirv-tools/source/opcode.cpp index b1785cccce..985c91c365 100644 --- a/third_party/spirv-tools/source/opcode.cpp +++ b/third_party/spirv-tools/source/opcode.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015-2022 The Khronos Group Inc. -// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights -// reserved. +// Modifications Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All +// rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env, const auto version = spvVersionForTargetEnv(env); for (uint64_t opcodeIndex = 0; opcodeIndex < table->count; ++opcodeIndex) { const spv_opcode_desc_t& entry = table->entries[opcodeIndex]; - // We considers the current opcode as available as long as + // We consider the current opcode as available as long as // 1. The target environment satisfies the minimal requirement of the // opcode; or // 2. There is at least one extension enabling this opcode. @@ -110,13 +110,34 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env, // Note that the second rule assumes the extension enabling this instruction // is indeed requested in the SPIR-V code; checking that should be // validator's work. - if (((version >= entry.minVersion && version <= entry.lastVersion) || - entry.numExtensions > 0u || entry.numCapabilities > 0u) && - nameLength == strlen(entry.name) && - !strncmp(name, entry.name, nameLength)) { - // NOTE: Found out Opcode! - *pEntry = &entry; - return SPV_SUCCESS; + if ((version >= entry.minVersion && version <= entry.lastVersion) || + entry.numExtensions > 0u || entry.numCapabilities > 0u) { + // Exact match case. + if (nameLength == strlen(entry.name) && + !strncmp(name, entry.name, nameLength)) { + *pEntry = &entry; + return SPV_SUCCESS; + } + // Lack of binary search really hurts here. There isn't an easy filter to + // apply before checking aliases since we need to handle promotion from + // vendor to KHR/EXT and KHR/EXT to core. It would require a sure-fire way + // of dropping suffices. Fortunately, most lookup are based on token + // value. + // + // If this was a binary search we could iterate between the lower and + // upper bounds. + if (entry.numAliases > 0) { + for (uint32_t aliasIndex = 0; aliasIndex < entry.numAliases; + aliasIndex++) { + // Skip Op prefix. Should this be encoded in the table instead? + const auto alias = entry.aliases[aliasIndex] + 2; + const size_t aliasLength = strlen(alias); + if (nameLength == aliasLength && !strncmp(name, alias, nameLength)) { + *pEntry = &entry; + return SPV_SUCCESS; + } + } + } } } @@ -133,8 +154,8 @@ spv_result_t spvOpcodeTableValueLookup(spv_target_env env, const auto beg = table->entries; const auto end = table->entries + table->count; - spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {}, - false, false, 0, nullptr, ~0u, ~0u}; + spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {}, 0, + {}, false, false, 0, nullptr, ~0u, ~0u}; auto comp = [](const spv_opcode_desc_t& lhs, const spv_opcode_desc_t& rhs) { return lhs.opcode < rhs.opcode; @@ -189,6 +210,7 @@ const char* spvOpcodeString(const uint32_t opcode) { spv_opcode_desc_t needle = {"", static_cast(opcode), 0, nullptr, 0, {}, + 0, {}, false, false, 0, nullptr, ~0u, ~0u}; @@ -225,6 +247,7 @@ int32_t spvOpcodeIsSpecConstant(const spv::Op opcode) { case spv::Op::OpSpecConstantFalse: case spv::Op::OpSpecConstant: case spv::Op::OpSpecConstantComposite: + case spv::Op::OpSpecConstantCompositeReplicateEXT: case spv::Op::OpSpecConstantOp: return true; default: @@ -238,13 +261,18 @@ int32_t spvOpcodeIsConstant(const spv::Op opcode) { case spv::Op::OpConstantFalse: case spv::Op::OpConstant: case spv::Op::OpConstantComposite: + case spv::Op::OpConstantCompositeReplicateEXT: case spv::Op::OpConstantSampler: case spv::Op::OpConstantNull: + case spv::Op::OpConstantFunctionPointerINTEL: + case spv::Op::OpConstantStringAMDX: case spv::Op::OpSpecConstantTrue: case spv::Op::OpSpecConstantFalse: case spv::Op::OpSpecConstant: case spv::Op::OpSpecConstantComposite: + case spv::Op::OpSpecConstantCompositeReplicateEXT: case spv::Op::OpSpecConstantOp: + case spv::Op::OpSpecConstantStringAMDX: return true; default: return false; @@ -272,7 +300,10 @@ int32_t spvOpcodeIsComposite(const spv::Op opcode) { case spv::Op::OpTypeMatrix: case spv::Op::OpTypeArray: case spv::Op::OpTypeStruct: + case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: return true; default: return false; @@ -282,17 +313,23 @@ int32_t spvOpcodeIsComposite(const spv::Op opcode) { bool spvOpcodeReturnsLogicalVariablePointer(const spv::Op opcode) { switch (opcode) { case spv::Op::OpVariable: + case spv::Op::OpUntypedVariableKHR: case spv::Op::OpAccessChain: case spv::Op::OpInBoundsAccessChain: + case spv::Op::OpUntypedAccessChainKHR: + case spv::Op::OpUntypedInBoundsAccessChainKHR: case spv::Op::OpFunctionParameter: case spv::Op::OpImageTexelPointer: case spv::Op::OpCopyObject: + case spv::Op::OpAllocateNodePayloadsAMDX: case spv::Op::OpSelect: case spv::Op::OpPhi: case spv::Op::OpFunctionCall: case spv::Op::OpPtrAccessChain: + case spv::Op::OpUntypedPtrAccessChainKHR: case spv::Op::OpLoad: case spv::Op::OpConstantNull: + case spv::Op::OpRawAccessChainNV: return true; default: return false; @@ -302,11 +339,16 @@ bool spvOpcodeReturnsLogicalVariablePointer(const spv::Op opcode) { int32_t spvOpcodeReturnsLogicalPointer(const spv::Op opcode) { switch (opcode) { case spv::Op::OpVariable: + case spv::Op::OpUntypedVariableKHR: case spv::Op::OpAccessChain: case spv::Op::OpInBoundsAccessChain: + case spv::Op::OpUntypedAccessChainKHR: + case spv::Op::OpUntypedInBoundsAccessChainKHR: case spv::Op::OpFunctionParameter: case spv::Op::OpImageTexelPointer: case spv::Op::OpCopyObject: + case spv::Op::OpRawAccessChainNV: + case spv::Op::OpAllocateNodePayloadsAMDX: return true; default: return false; @@ -339,10 +381,16 @@ int32_t spvOpcodeGeneratesType(spv::Op op) { case spv::Op::OpTypeNamedBarrier: case spv::Op::OpTypeAccelerationStructureNV: case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: // case spv::Op::OpTypeAccelerationStructureKHR: covered by // spv::Op::OpTypeAccelerationStructureNV case spv::Op::OpTypeRayQueryKHR: case spv::Op::OpTypeHitObjectNV: + case spv::Op::OpTypeUntypedPointerKHR: + case spv::Op::OpTypeNodePayloadArrayAMDX: + case spv::Op::OpTypeTensorLayoutNV: + case spv::Op::OpTypeTensorViewNV: return true; default: // In particular, OpTypeForwardPointer does not generate a type, @@ -380,6 +428,7 @@ bool spvOpcodeIsLoad(const spv::Op opcode) { case spv::Op::OpImageSampleProjExplicitLod: case spv::Op::OpImageSampleProjDrefImplicitLod: case spv::Op::OpImageSampleProjDrefExplicitLod: + case spv::Op::OpImageSampleFootprintNV: case spv::Op::OpImageFetch: case spv::Op::OpImageGather: case spv::Op::OpImageDrefGather: @@ -531,6 +580,8 @@ bool spvOpcodeIsNonUniformGroupOperation(spv::Op opcode) { case spv::Op::OpGroupNonUniformQuadBroadcast: case spv::Op::OpGroupNonUniformQuadSwap: case spv::Op::OpGroupNonUniformRotateKHR: + case spv::Op::OpGroupNonUniformQuadAllKHR: + case spv::Op::OpGroupNonUniformQuadAnyKHR: return true; default: return false; @@ -704,6 +755,17 @@ bool spvOpcodeIsImageSample(const spv::Op opcode) { case spv::Op::OpImageSparseSampleExplicitLod: case spv::Op::OpImageSparseSampleDrefImplicitLod: case spv::Op::OpImageSparseSampleDrefExplicitLod: + case spv::Op::OpImageSampleFootprintNV: + return true; + default: + return false; + } +} + +bool spvIsExtendedInstruction(const spv::Op opcode) { + switch (opcode) { + case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: return true; default: return false; @@ -749,6 +811,7 @@ bool spvOpcodeIsAccessChain(spv::Op opcode) { case spv::Op::OpInBoundsAccessChain: case spv::Op::OpPtrAccessChain: case spv::Op::OpInBoundsPtrAccessChain: + case spv::Op::OpRawAccessChainNV: return true; default: return false; @@ -771,3 +834,16 @@ bool spvOpcodeIsBit(spv::Op opcode) { return false; } } + +bool spvOpcodeGeneratesUntypedPointer(spv::Op opcode) { + switch (opcode) { + case spv::Op::OpUntypedVariableKHR: + case spv::Op::OpUntypedAccessChainKHR: + case spv::Op::OpUntypedInBoundsAccessChainKHR: + case spv::Op::OpUntypedPtrAccessChainKHR: + case spv::Op::OpUntypedInBoundsPtrAccessChainKHR: + return true; + default: + return false; + } +} diff --git a/third_party/spirv-tools/source/opcode.h b/third_party/spirv-tools/source/opcode.h index 217aeb2b6f..08fc56d8a0 100644 --- a/third_party/spirv-tools/source/opcode.h +++ b/third_party/spirv-tools/source/opcode.h @@ -146,6 +146,9 @@ bool spvOpcodeIsLinearAlgebra(spv::Op opcode); // Returns true for opcodes that represent image sample instructions. bool spvOpcodeIsImageSample(spv::Op opcode); +// Returns true if the opcode is either OpExtInst or OpExtInstWithForwardRefsKHR +bool spvIsExtendedInstruction(spv::Op opcode); + // Returns a vector containing the indices of the memory semantics // operands for |opcode|. std::vector spvOpcodeMemorySemanticsOperandIndices(spv::Op opcode); @@ -159,4 +162,7 @@ bool spvOpcodeIsBit(spv::Op opcode); // Gets the name of an instruction, without the "Op" prefix. const char* spvOpcodeString(const spv::Op opcode); +// Returns true for opcodes that generate an untyped pointer result. +bool spvOpcodeGeneratesUntypedPointer(spv::Op opcode); + #endif // SOURCE_OPCODE_H_ diff --git a/third_party/spirv-tools/source/operand.cpp b/third_party/spirv-tools/source/operand.cpp index 31a6c5965d..869a7ca137 100644 --- a/third_party/spirv-tools/source/operand.cpp +++ b/third_party/spirv-tools/source/operand.cpp @@ -26,7 +26,6 @@ #include "source/macro.h" #include "source/opcode.h" #include "source/spirv_constant.h" -#include "source/spirv_target_env.h" // For now, assume unified1 contains up to SPIR-V 1.3 and no later // SPIR-V version. @@ -48,7 +47,7 @@ spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable, return SPV_SUCCESS; } -spv_result_t spvOperandTableNameLookup(spv_target_env env, +spv_result_t spvOperandTableNameLookup(spv_target_env, const spv_operand_table table, const spv_operand_type_t type, const char* name, @@ -57,30 +56,35 @@ spv_result_t spvOperandTableNameLookup(spv_target_env env, if (!table) return SPV_ERROR_INVALID_TABLE; if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER; - const auto version = spvVersionForTargetEnv(env); for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) { const auto& group = table->types[typeIndex]; if (type != group.type) continue; for (uint64_t index = 0; index < group.count; ++index) { const auto& entry = group.entries[index]; // We consider the current operand as available as long as - // 1. The target environment satisfies the minimal requirement of the - // operand; or - // 2. There is at least one extension enabling this operand; or - // 3. There is at least one capability enabling this operand. + // it is in the grammar. It might not be *valid* to use, + // but that should be checked by the validator, not by parsing. // - // Note that the second rule assumes the extension enabling this operand - // is indeed requested in the SPIR-V code; checking that should be - // validator's work. + // Exact match case if (nameLength == strlen(entry.name) && !strncmp(entry.name, name, nameLength)) { - if ((version >= entry.minVersion && version <= entry.lastVersion) || - entry.numExtensions > 0u || entry.numCapabilities > 0u) { - *pEntry = &entry; - return SPV_SUCCESS; - } else { - // if there is no extension/capability then the version is wrong - return SPV_ERROR_WRONG_VERSION; + *pEntry = &entry; + return SPV_SUCCESS; + } + + // Check the aliases. Ideally we would have a version of the table sorted + // by name and then we could iterate between the lower and upper bounds to + // restrict the amount comparisons. Fortunately, name-based lookups are + // mostly restricted to the assembler. + if (entry.numAliases > 0) { + for (uint32_t aliasIndex = 0; aliasIndex < entry.numAliases; + aliasIndex++) { + const auto alias = entry.aliases[aliasIndex]; + const size_t aliasLength = strlen(alias); + if (nameLength == aliasLength && !strncmp(name, alias, nameLength)) { + *pEntry = &entry; + return SPV_SUCCESS; + } } } } @@ -89,7 +93,7 @@ spv_result_t spvOperandTableNameLookup(spv_target_env env, return SPV_ERROR_INVALID_LOOKUP; } -spv_result_t spvOperandTableValueLookup(spv_target_env env, +spv_result_t spvOperandTableValueLookup(spv_target_env, const spv_operand_table table, const spv_operand_type_t type, const uint32_t value, @@ -97,7 +101,8 @@ spv_result_t spvOperandTableValueLookup(spv_target_env env, if (!table) return SPV_ERROR_INVALID_TABLE; if (!pEntry) return SPV_ERROR_INVALID_POINTER; - spv_operand_desc_t needle = {"", value, 0, nullptr, 0, nullptr, {}, ~0u, ~0u}; + spv_operand_desc_t needle = {"", value, 0, nullptr, 0, nullptr, + 0, nullptr, {}, ~0u, ~0u}; auto comp = [](const spv_operand_desc_t& lhs, const spv_operand_desc_t& rhs) { return lhs.value < rhs.value; @@ -110,33 +115,15 @@ spv_result_t spvOperandTableValueLookup(spv_target_env env, const auto beg = group.entries; const auto end = group.entries + group.count; - // We need to loop here because there can exist multiple symbols for the - // same operand value, and they can be introduced in different target - // environments, which means they can have different minimal version - // requirements. For example, SubgroupEqMaskKHR can exist in any SPIR-V - // version as long as the SPV_KHR_shader_ballot extension is there; but - // starting from SPIR-V 1.3, SubgroupEqMask, which has the same numeric - // value as SubgroupEqMaskKHR, is available in core SPIR-V without extension - // requirements. // Assumes the underlying table is already sorted ascendingly according to // opcode value. - const auto version = spvVersionForTargetEnv(env); - for (auto it = std::lower_bound(beg, end, needle, comp); - it != end && it->value == value; ++it) { - // We consider the current operand as available as long as - // 1. The target environment satisfies the minimal requirement of the - // operand; or - // 2. There is at least one extension enabling this operand; or - // 3. There is at least one capability enabling this operand. - // - // Note that the second rule assumes the extension enabling this operand - // is indeed requested in the SPIR-V code; checking that should be - // validator's work. - if ((version >= it->minVersion && version <= it->lastVersion) || - it->numExtensions > 0u || it->numCapabilities > 0u) { - *pEntry = it; - return SPV_SUCCESS; - } + auto it = std::lower_bound(beg, end, needle, comp); + if (it != end && it->value == value) { + // The current operand is considered available as long as + // it is in the grammar. It might not be *valid* to use, + // but that should be checked by the validator, not by parsing. + *pEntry = it; + return SPV_SUCCESS; } } @@ -155,6 +142,7 @@ const char* spvOperandTypeStr(spv_operand_type_t type) { case SPV_OPERAND_TYPE_LITERAL_INTEGER: case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER: case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER: + case SPV_OPERAND_TYPE_LITERAL_FLOAT: return "literal number"; case SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER: return "possibly multi-word literal integer"; @@ -236,6 +224,35 @@ const char* spvOperandTypeStr(spv_operand_type_t type) { case SPV_OPERAND_TYPE_PACKED_VECTOR_FORMAT: case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT: return "packed vector format"; + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS: + return "cooperative matrix operands"; + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_LAYOUT: + return "cooperative matrix layout"; + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_USE: + return "cooperative matrix use"; + case SPV_OPERAND_TYPE_TENSOR_CLAMP_MODE: + return "tensor clamp mode"; + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE: + return "cooperative matrix reduce"; + case SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS: + return "tensor addressing operands"; + case SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: + return "matrix multiply accumulate operands"; + case SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER: + return "initialization mode qualifier"; + case SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER: + return "host access qualifier"; + case SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL: + return "load cache control"; + case SPV_OPERAND_TYPE_STORE_CACHE_CONTROL: + return "store cache control"; + case SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS: + return "named maximum number of registers"; + case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS: + return "raw access chain operands"; case SPV_OPERAND_TYPE_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: return "image"; @@ -263,6 +280,9 @@ const char* spvOperandTypeStr(spv_operand_type_t type) { return "OpenCL.DebugInfo.100 debug operation"; case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY: return "OpenCL.DebugInfo.100 debug imported entity"; + case SPV_OPERAND_TYPE_FPENCODING: + case SPV_OPERAND_TYPE_OPTIONAL_FPENCODING: + return "FP encoding"; // The next values are for values returned from an instruction, not actually // an operand. So the specific strings don't matter. But let's add them @@ -280,6 +300,10 @@ const char* spvOperandTypeStr(spv_operand_type_t type) { return "quantization mode"; case SPV_OPERAND_TYPE_OVERFLOW_MODES: return "overflow mode"; + case SPV_OPERAND_TYPE_COOPERATIVE_VECTOR_MATRIX_LAYOUT: + return "cooperative vector matrix layout"; + case SPV_OPERAND_TYPE_COMPONENT_TYPE: + return "component type"; case SPV_OPERAND_TYPE_NONE: return "NONE"; @@ -325,6 +349,7 @@ bool spvOperandIsConcrete(spv_operand_type_t type) { } switch (type) { case SPV_OPERAND_TYPE_LITERAL_INTEGER: + case SPV_OPERAND_TYPE_LITERAL_FLOAT: case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: case SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER: case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: @@ -369,6 +394,17 @@ bool spvOperandIsConcrete(spv_operand_type_t type) { case SPV_OPERAND_TYPE_QUANTIZATION_MODES: case SPV_OPERAND_TYPE_OVERFLOW_MODES: case SPV_OPERAND_TYPE_PACKED_VECTOR_FORMAT: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_LAYOUT: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_USE: + case SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER: + case SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER: + case SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL: + case SPV_OPERAND_TYPE_STORE_CACHE_CONTROL: + case SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS: + case SPV_OPERAND_TYPE_FPENCODING: + case SPV_OPERAND_TYPE_TENSOR_CLAMP_MODE: + case SPV_OPERAND_TYPE_COOPERATIVE_VECTOR_MATRIX_LAYOUT: + case SPV_OPERAND_TYPE_COMPONENT_TYPE: return true; default: break; @@ -387,6 +423,11 @@ bool spvOperandIsConcreteMask(spv_operand_type_t type) { case SPV_OPERAND_TYPE_FRAGMENT_SHADING_RATE: case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: + case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE: + case SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS: return true; default: break; @@ -405,7 +446,11 @@ bool spvOperandIsOptional(spv_operand_type_t type) { case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING: case SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER: case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT: + case SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: case SPV_OPERAND_TYPE_OPTIONAL_CIV: + case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS: + case SPV_OPERAND_TYPE_OPTIONAL_FPENCODING: return true; default: break; @@ -573,6 +618,16 @@ std::function spvOperandCanBeForwardDeclaredFunction( case spv::Op::OpTypeArray: out = [](unsigned index) { return index == 1; }; break; + case spv::Op::OpCooperativeMatrixPerElementOpNV: + out = [](unsigned index) { return index == 3; }; + break; + case spv::Op::OpCooperativeMatrixReduceNV: + out = [](unsigned index) { return index == 4; }; + break; + case spv::Op::OpCooperativeMatrixLoadTensorNV: + // approximate, due to variable operands + out = [](unsigned index) { return index > 6; }; + break; default: out = [](unsigned) { return false; }; break; @@ -581,11 +636,13 @@ std::function spvOperandCanBeForwardDeclaredFunction( } std::function spvDbgInfoExtOperandCanBeForwardDeclaredFunction( - spv_ext_inst_type_t ext_type, uint32_t key) { + spv::Op opcode, spv_ext_inst_type_t ext_type, uint32_t key) { // The Vulkan debug info extended instruction set is non-semantic so allows no - // forward references ever + // forward references except if used through OpExtInstWithForwardRefsKHR. if (ext_type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) { - return [](unsigned) { return false; }; + return [opcode](unsigned) { + return opcode == spv::Op::OpExtInstWithForwardRefsKHR; + }; } // TODO(https://gitlab.khronos.org/spirv/SPIR-V/issues/532): Forward diff --git a/third_party/spirv-tools/source/operand.h b/third_party/spirv-tools/source/operand.h index a3010d9341..3d42a0594d 100644 --- a/third_party/spirv-tools/source/operand.h +++ b/third_party/spirv-tools/source/operand.h @@ -57,12 +57,6 @@ spv_result_t spvOperandTableValueLookup(spv_target_env, // Gets the name string of the non-variable operand type. const char* spvOperandTypeStr(spv_operand_type_t type); -// Returns true if the given type is concrete. -bool spvOperandIsConcrete(spv_operand_type_t type); - -// Returns true if the given type is concrete and also a mask. -bool spvOperandIsConcreteMask(spv_operand_type_t type); - // Returns true if an operand of the given type is optional. bool spvOperandIsOptional(spv_operand_type_t type); @@ -146,6 +140,6 @@ std::function spvOperandCanBeForwardDeclaredFunction( // of the operand can be forward declared. This function will // used in the SSA validation stage of the pipeline std::function spvDbgInfoExtOperandCanBeForwardDeclaredFunction( - spv_ext_inst_type_t ext_type, uint32_t key); + spv::Op opcode, spv_ext_inst_type_t ext_type, uint32_t key); #endif // SOURCE_OPERAND_H_ diff --git a/third_party/spirv-tools/source/opt/CMakeLists.txt b/third_party/spirv-tools/source/opt/CMakeLists.txt index c34c38d0b8..4a12e6ef5f 100644 --- a/third_party/spirv-tools/source/opt/CMakeLists.txt +++ b/third_party/spirv-tools/source/opt/CMakeLists.txt @@ -64,14 +64,12 @@ set(SPIRV_TOOLS_OPT_SOURCES inline_exhaustive_pass.h inline_opaque_pass.h inline_pass.h - inst_bindless_check_pass.h - inst_buff_addr_check_pass.h - inst_debug_printf_pass.h instruction.h instruction_list.h - instrument_pass.h interface_var_sroa.h + invocation_interlock_placement_pass.h interp_fixup_pass.h + opextinst_forward_ref_fixup_pass.h ir_builder.h ir_context.h ir_loader.h @@ -93,6 +91,7 @@ set(SPIRV_TOOLS_OPT_SOURCES loop_unswitch_pass.h mem_pass.h merge_return_pass.h + modify_maximal_reconvergence.h module.h null_pass.h passes.h @@ -121,7 +120,9 @@ set(SPIRV_TOOLS_OPT_SOURCES strip_debug_info_pass.h strip_nonsemantic_info_pass.h struct_cfg_analysis.h + switch_descriptorset_pass.h tree_iterator.h + trim_capabilities_pass.h type_manager.h types.h unify_const_pass.h @@ -182,14 +183,12 @@ set(SPIRV_TOOLS_OPT_SOURCES inline_exhaustive_pass.cpp inline_opaque_pass.cpp inline_pass.cpp - inst_bindless_check_pass.cpp - inst_buff_addr_check_pass.cpp - inst_debug_printf_pass.cpp instruction.cpp instruction_list.cpp - instrument_pass.cpp interface_var_sroa.cpp + invocation_interlock_placement_pass.cpp interp_fixup_pass.cpp + opextinst_forward_ref_fixup_pass.cpp ir_context.cpp ir_loader.cpp licm_pass.cpp @@ -210,6 +209,7 @@ set(SPIRV_TOOLS_OPT_SOURCES loop_unswitch_pass.cpp mem_pass.cpp merge_return_pass.cpp + modify_maximal_reconvergence.cpp module.cpp optimizer.cpp pass.cpp @@ -236,6 +236,9 @@ set(SPIRV_TOOLS_OPT_SOURCES strip_debug_info_pass.cpp strip_nonsemantic_info_pass.cpp struct_cfg_analysis.cpp + struct_packing_pass.cpp + switch_descriptorset_pass.cpp + trim_capabilities_pass.cpp type_manager.cpp types.cpp unify_const_pass.cpp @@ -271,10 +274,7 @@ set_property(TARGET SPIRV-Tools-opt PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-opt) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-opt EXPORT SPIRV-Tools-optTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-opt EXPORT SPIRV-Tools-optTargets) export(EXPORT SPIRV-Tools-optTargets FILE SPIRV-Tools-optTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-opt PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp b/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp index 53d13f18bf..333ef7bdca 100644 --- a/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp @@ -21,10 +21,8 @@ #include #include "source/cfa.h" -#include "source/latest_version_glsl_std_450_header.h" #include "source/opt/eliminate_dead_functions_util.h" #include "source/opt/ir_builder.h" -#include "source/opt/iterator.h" #include "source/opt/reflect.h" #include "source/spirv_constant.h" #include "source/util/string_utils.h" @@ -42,6 +40,10 @@ constexpr uint32_t kCopyMemorySourceAddrInIdx = 1; constexpr uint32_t kLoadSourceAddrInIdx = 0; constexpr uint32_t kDebugDeclareOperandVariableIndex = 5; constexpr uint32_t kGlobalVariableVariableIndex = 12; +constexpr uint32_t kExtInstSetInIdx = 0; +constexpr uint32_t kExtInstOpInIdx = 1; +constexpr uint32_t kInterpolantInIdx = 2; +constexpr uint32_t kCooperativeMatrixLoadSourceAddrInIdx = 0; // Sorting functor to present annotation instructions in an easy-to-process // order. The functor orders by opcode first and falls back on unique id @@ -136,7 +138,12 @@ void AggressiveDCEPass::AddStores(Function* func, uint32_t ptrId) { } break; // If default, assume it stores e.g. frexp, modf, function call - case spv::Op::OpStore: + case spv::Op::OpStore: { + const uint32_t kStoreTargetAddrInIdx = 0; + if (user->GetSingleWordInOperand(kStoreTargetAddrInIdx) == ptrId) + AddToWorklist(user); + break; + } default: AddToWorklist(user); break; @@ -158,7 +165,8 @@ bool AggressiveDCEPass::AllExtensionsSupported() const { "Expecting an import of an extension's instruction set."); const std::string extension_name = inst.GetInOperand(0).AsString(); if (spvtools::utils::starts_with(extension_name, "NonSemantic.") && - extension_name != "NonSemantic.Shader.DebugInfo.100") { + (extension_name != "NonSemantic.Shader.DebugInfo.100") && + (extension_name != "NonSemantic.DebugPrintf")) { return false; } } @@ -263,6 +271,7 @@ void AggressiveDCEPass::AddBreaksAndContinuesToWorklist( } bool AggressiveDCEPass::AggressiveDCE(Function* func) { + if (func->IsDeclaration()) return false; std::list structured_order; cfg()->ComputeStructuredOrder(func, &*func->begin(), &structured_order); live_local_vars_.clear(); @@ -417,6 +426,24 @@ uint32_t AggressiveDCEPass::GetLoadedVariableFromNonFunctionCalls( case spv::Op::OpCopyMemorySized: return GetVariableId( inst->GetSingleWordInOperand(kCopyMemorySourceAddrInIdx)); + case spv::Op::OpExtInst: { + if (inst->GetSingleWordInOperand(kExtInstSetInIdx) == + context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450()) { + auto ext_inst = inst->GetSingleWordInOperand(kExtInstOpInIdx); + switch (ext_inst) { + case GLSLstd450InterpolateAtCentroid: + case GLSLstd450InterpolateAtOffset: + case GLSLstd450InterpolateAtSample: + return inst->GetSingleWordInOperand(kInterpolantInIdx); + } + } + break; + } + case spv::Op::OpCooperativeMatrixLoadNV: + case spv::Op::OpCooperativeMatrixLoadKHR: + case spv::Op::OpCooperativeMatrixLoadTensorNV: + return GetVariableId( + inst->GetSingleWordInOperand(kCooperativeMatrixLoadSourceAddrInIdx)); default: break; } @@ -439,6 +466,9 @@ std::vector AggressiveDCEPass::GetLoadedVariablesFromFunctionCall( const Instruction* inst) { assert(inst->opcode() == spv::Op::OpFunctionCall); std::vector live_variables; + // NOTE: we should only be checking function call parameters here, not the + // function itself, however, `IsPtr` will trivially return false for + // OpFunction inst->ForEachInId([this, &live_variables](const uint32_t* operand_id) { if (!IsPtr(*operand_id)) return; uint32_t var_id = GetVariableId(*operand_id); @@ -646,6 +676,7 @@ void AggressiveDCEPass::InitializeModuleScopeLiveInstructions() { auto op = dbg.GetShader100DebugOpcode(); if (op == NonSemanticShaderDebugInfo100DebugCompilationUnit || op == NonSemanticShaderDebugInfo100DebugEntryPoint || + op == NonSemanticShaderDebugInfo100DebugSource || op == NonSemanticShaderDebugInfo100DebugSourceContinued) { AddToWorklist(&dbg); } @@ -939,6 +970,8 @@ Pass::Status AggressiveDCEPass::Process() { void AggressiveDCEPass::InitExtensions() { extensions_allowlist_.clear(); + + // clang-format off extensions_allowlist_.insert({ "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_trinary_minmax", @@ -981,11 +1014,13 @@ void AggressiveDCEPass::InitExtensions() { "SPV_NV_shader_image_footprint", "SPV_NV_shading_rate", "SPV_NV_mesh_shader", + "SPV_EXT_mesh_shader", "SPV_NV_ray_tracing", "SPV_KHR_ray_tracing", "SPV_KHR_ray_query", "SPV_EXT_fragment_invocation_density", "SPV_EXT_physical_storage_buffer", + "SPV_KHR_physical_storage_buffer", "SPV_KHR_terminate_invocation", "SPV_KHR_shader_clock", "SPV_KHR_vulkan_memory_model", @@ -995,7 +1030,16 @@ void AggressiveDCEPass::InitExtensions() { "SPV_KHR_non_semantic_info", "SPV_KHR_uniform_group_instructions", "SPV_KHR_fragment_shader_barycentric", + "SPV_NV_bindless_texture", + "SPV_EXT_shader_atomic_float_add", + "SPV_EXT_fragment_shader_interlock", + "SPV_KHR_compute_shader_derivatives", + "SPV_NV_cooperative_matrix", + "SPV_KHR_cooperative_matrix", + "SPV_KHR_ray_tracing_position_fetch", + "SPV_KHR_fragment_shading_rate" }); + // clang-format on } Instruction* AggressiveDCEPass::GetHeaderBranch(BasicBlock* blk) { diff --git a/third_party/spirv-tools/source/opt/basic_block.cpp b/third_party/spirv-tools/source/opt/basic_block.cpp index d12178ebe3..a9fc8e2f7b 100644 --- a/third_party/spirv-tools/source/opt/basic_block.cpp +++ b/third_party/spirv-tools/source/opt/basic_block.cpp @@ -16,9 +16,7 @@ #include -#include "source/opt/function.h" #include "source/opt/ir_context.h" -#include "source/opt/module.h" #include "source/opt/reflect.h" #include "source/util/make_unique.h" diff --git a/third_party/spirv-tools/source/opt/block_merge_pass.cpp b/third_party/spirv-tools/source/opt/block_merge_pass.cpp index ef7f31fe0b..d6c33e52b5 100644 --- a/third_party/spirv-tools/source/opt/block_merge_pass.cpp +++ b/third_party/spirv-tools/source/opt/block_merge_pass.cpp @@ -16,11 +16,8 @@ #include "source/opt/block_merge_pass.h" -#include - #include "source/opt/block_merge_util.h" #include "source/opt/ir_context.h" -#include "source/opt/iterator.h" namespace spvtools { namespace opt { diff --git a/third_party/spirv-tools/source/opt/block_merge_util.cpp b/third_party/spirv-tools/source/opt/block_merge_util.cpp index fe23e36f90..42f695f235 100644 --- a/third_party/spirv-tools/source/opt/block_merge_util.cpp +++ b/third_party/spirv-tools/source/opt/block_merge_util.cpp @@ -98,6 +98,17 @@ bool CanMergeWithSuccessor(IRContext* context, BasicBlock* block) { return false; } + // Note: This means that the instructions in a break block will execute as if + // they were still diverged according to the loop iteration. This restricts + // potential transformations an implementation may perform on the IR to match + // shader author expectations. Similarly, instructions in the loop construct + // cannot be moved into the continue construct unless it can be proven that + // invocations are always converged. + if (succ_is_merge && context->get_feature_mgr()->HasExtension( + kSPV_KHR_maximal_reconvergence)) { + return false; + } + if (pred_is_merge && IsContinue(context, lab_id)) { // Cannot merge a continue target with a merge block. return false; diff --git a/third_party/spirv-tools/source/opt/build_module.h b/third_party/spirv-tools/source/opt/build_module.h index 29eaf66139..0f906c88bf 100644 --- a/third_party/spirv-tools/source/opt/build_module.h +++ b/third_party/spirv-tools/source/opt/build_module.h @@ -24,7 +24,7 @@ namespace spvtools { -// Builds an Module returns the owning IRContext from the given SPIR-V +// Builds a Module and returns the owning IRContext from the given SPIR-V // |binary|. |size| specifies number of words in |binary|. The |binary| will be // decoded according to the given target |env|. Returns nullptr if errors occur // and sends the errors to |consumer|. When |extra_line_tracking| is true, @@ -41,7 +41,7 @@ std::unique_ptr BuildModule(spv_target_env env, const uint32_t* binary, size_t size); -// Builds an Module and returns the owning IRContext from the given +// Builds a Module and returns the owning IRContext from the given // SPIR-V assembly |text|. The |text| will be encoded according to the given // target |env|. Returns nullptr if errors occur and sends the errors to // |consumer|. diff --git a/third_party/spirv-tools/source/opt/ccp_pass.cpp b/third_party/spirv-tools/source/opt/ccp_pass.cpp index 63627a2f73..46bfc907de 100644 --- a/third_party/spirv-tools/source/opt/ccp_pass.cpp +++ b/third_party/spirv-tools/source/opt/ccp_pass.cpp @@ -24,7 +24,6 @@ #include "source/opt/fold.h" #include "source/opt/function.h" -#include "source/opt/module.h" #include "source/opt/propagator.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/cfg_cleanup_pass.cpp b/third_party/spirv-tools/source/opt/cfg_cleanup_pass.cpp index 6d48637a45..26fed89fb1 100644 --- a/third_party/spirv-tools/source/opt/cfg_cleanup_pass.cpp +++ b/third_party/spirv-tools/source/opt/cfg_cleanup_pass.cpp @@ -16,13 +16,9 @@ // constructs (e.g., unreachable basic blocks, empty control flow structures, // etc) -#include -#include - #include "source/opt/cfg_cleanup_pass.h" #include "source/opt/function.h" -#include "source/opt/module.h" namespace spvtools { namespace opt { diff --git a/third_party/spirv-tools/source/opt/code_sink.cpp b/third_party/spirv-tools/source/opt/code_sink.cpp index 35a8df23b9..90231791e7 100644 --- a/third_party/spirv-tools/source/opt/code_sink.cpp +++ b/third_party/spirv-tools/source/opt/code_sink.cpp @@ -14,11 +14,9 @@ #include "code_sink.h" -#include #include #include "source/opt/instruction.h" -#include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" #include "source/util/bit_vector.h" diff --git a/third_party/spirv-tools/source/opt/const_folding_rules.cpp b/third_party/spirv-tools/source/opt/const_folding_rules.cpp index 14f22089b4..a5d4cbe755 100644 --- a/third_party/spirv-tools/source/opt/const_folding_rules.cpp +++ b/third_party/spirv-tools/source/opt/const_folding_rules.cpp @@ -88,6 +88,22 @@ const analysis::Constant* NegateFPConst(const analysis::Type* result_type, return nullptr; } +// Returns a constants with the value |-val| of the given type. +const analysis::Constant* NegateIntConst(const analysis::Type* result_type, + const analysis::Constant* val, + analysis::ConstantManager* const_mgr) { + const analysis::Integer* int_type = result_type->AsInteger(); + assert(int_type != nullptr); + + if (val->AsNullConstant()) { + return val; + } + + uint64_t new_value = static_cast(-val->GetSignExtendedValue()); + return const_mgr->GetIntConst(new_value, int_type->width(), + int_type->IsSigned()); +} + // Folds an OpcompositeExtract where input is a composite constant. ConstantFoldingRule FoldExtractWithConstants() { return [](IRContext* context, Instruction* inst, @@ -145,12 +161,17 @@ ConstantFoldingRule FoldInsertWithConstants() { if (composite->AsNullConstant()) { // Make new composite so it can be inserted in the index with the // non-null value - const auto new_composite = const_mgr->GetNullCompositeConstant(type); - // Keep track of any indexes along the way to last index - if (i != final_index) { - chain.push_back(new_composite); + if (const auto new_composite = + const_mgr->GetNullCompositeConstant(type)) { + // Keep track of any indexes along the way to last index + if (i != final_index) { + chain.push_back(new_composite); + } + components = new_composite->AsCompositeConstant()->GetComponents(); + } else { + // Unsupported input type (such as structs) + return nullptr; } - components = new_composite->AsCompositeConstant()->GetComponents(); } else { // Keep track of any indexes along the way to last index if (i != final_index) { @@ -336,6 +357,69 @@ ConstantFoldingRule FoldVectorTimesScalar() { }; } +// Returns to the constant that results from tranposing |matrix|. The result +// will have type |result_type|, and |matrix| must exist in |context|. The +// result constant will also exist in |context|. +const analysis::Constant* TransposeMatrix(const analysis::Constant* matrix, + analysis::Matrix* result_type, + IRContext* context) { + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); + if (matrix->AsNullConstant() != nullptr) { + return const_mgr->GetNullCompositeConstant(result_type); + } + + const auto& columns = matrix->AsMatrixConstant()->GetComponents(); + uint32_t number_of_rows = columns[0]->type()->AsVector()->element_count(); + + // Collect the ids of the elements in their new positions. + std::vector> result_elements(number_of_rows); + for (const analysis::Constant* column : columns) { + if (column->AsNullConstant()) { + column = const_mgr->GetNullCompositeConstant(column->type()); + } + const auto& column_components = column->AsVectorConstant()->GetComponents(); + + for (uint32_t row = 0; row < number_of_rows; ++row) { + result_elements[row].push_back( + const_mgr->GetDefiningInstruction(column_components[row]) + ->result_id()); + } + } + + // Create the constant for each row in the result, and collect the ids. + std::vector result_columns(number_of_rows); + for (uint32_t col = 0; col < number_of_rows; ++col) { + auto* element = const_mgr->GetConstant(result_type->element_type(), + result_elements[col]); + result_columns[col] = + const_mgr->GetDefiningInstruction(element)->result_id(); + } + + // Create the matrix constant from the row ids, and return it. + return const_mgr->GetConstant(result_type, result_columns); +} + +const analysis::Constant* FoldTranspose( + IRContext* context, Instruction* inst, + const std::vector& constants) { + assert(inst->opcode() == spv::Op::OpTranspose); + + analysis::TypeManager* type_mgr = context->get_type_mgr(); + if (!inst->IsFloatingPointFoldingAllowed()) { + if (HasFloatingPoint(type_mgr->GetType(inst->type_id()))) { + return nullptr; + } + } + + const analysis::Constant* matrix = constants[0]; + if (matrix == nullptr) { + return nullptr; + } + + auto* result_type = type_mgr->GetType(inst->type_id()); + return TransposeMatrix(matrix, result_type->AsMatrix(), context); +} + ConstantFoldingRule FoldVectorTimesMatrix() { return [](IRContext* context, Instruction* inst, const std::vector& constants) @@ -371,13 +455,7 @@ ConstantFoldingRule FoldVectorTimesMatrix() { assert(c1->type()->AsVector()->element_type() == element_type && c2->type()->AsMatrix()->element_type() == vector_type); - // Get a float vector that is the result of vector-times-matrix. - std::vector c1_components = - c1->GetVectorComponents(const_mgr); - std::vector c2_components = - c2->AsMatrixConstant()->GetComponents(); uint32_t resultVectorSize = result_type->AsVector()->element_count(); - std::vector ids; if ((c1 && c1->IsZero()) || (c2 && c2->IsZero())) { @@ -390,15 +468,23 @@ ConstantFoldingRule FoldVectorTimesMatrix() { return const_mgr->GetConstant(vector_type, ids); } + // Get a float vector that is the result of vector-times-matrix. + std::vector c1_components = + c1->GetVectorComponents(const_mgr); + std::vector c2_components = + c2->AsMatrixConstant()->GetComponents(); + if (float_type->width() == 32) { for (uint32_t i = 0; i < resultVectorSize; ++i) { float result_scalar = 0.0f; - const analysis::VectorConstant* c2_vec = - c2_components[i]->AsVectorConstant(); - for (uint32_t j = 0; j < c2_vec->GetComponents().size(); ++j) { - float c1_scalar = c1_components[j]->GetFloat(); - float c2_scalar = c2_vec->GetComponents()[j]->GetFloat(); - result_scalar += c1_scalar * c2_scalar; + if (!c2_components[i]->AsNullConstant()) { + const analysis::VectorConstant* c2_vec = + c2_components[i]->AsVectorConstant(); + for (uint32_t j = 0; j < c2_vec->GetComponents().size(); ++j) { + float c1_scalar = c1_components[j]->GetFloat(); + float c2_scalar = c2_vec->GetComponents()[j]->GetFloat(); + result_scalar += c1_scalar * c2_scalar; + } } utils::FloatProxy result(result_scalar); std::vector words = result.GetWords(); @@ -410,12 +496,14 @@ ConstantFoldingRule FoldVectorTimesMatrix() { } else if (float_type->width() == 64) { for (uint32_t i = 0; i < c2_components.size(); ++i) { double result_scalar = 0.0; - const analysis::VectorConstant* c2_vec = - c2_components[i]->AsVectorConstant(); - for (uint32_t j = 0; j < c2_vec->GetComponents().size(); ++j) { - double c1_scalar = c1_components[j]->GetDouble(); - double c2_scalar = c2_vec->GetComponents()[j]->GetDouble(); - result_scalar += c1_scalar * c2_scalar; + if (!c2_components[i]->AsNullConstant()) { + const analysis::VectorConstant* c2_vec = + c2_components[i]->AsVectorConstant(); + for (uint32_t j = 0; j < c2_vec->GetComponents().size(); ++j) { + double c1_scalar = c1_components[j]->GetDouble(); + double c2_scalar = c2_vec->GetComponents()[j]->GetDouble(); + result_scalar += c1_scalar * c2_scalar; + } } utils::FloatProxy result(result_scalar); std::vector words = result.GetWords(); @@ -463,13 +551,7 @@ ConstantFoldingRule FoldMatrixTimesVector() { assert(c1->type()->AsMatrix()->element_type() == vector_type); assert(c2->type()->AsVector()->element_type() == element_type); - // Get a float vector that is the result of matrix-times-vector. - std::vector c1_components = - c1->AsMatrixConstant()->GetComponents(); - std::vector c2_components = - c2->GetVectorComponents(const_mgr); uint32_t resultVectorSize = result_type->AsVector()->element_count(); - std::vector ids; if ((c1 && c1->IsZero()) || (c2 && c2->IsZero())) { @@ -482,16 +564,24 @@ ConstantFoldingRule FoldMatrixTimesVector() { return const_mgr->GetConstant(vector_type, ids); } + // Get a float vector that is the result of matrix-times-vector. + std::vector c1_components = + c1->AsMatrixConstant()->GetComponents(); + std::vector c2_components = + c2->GetVectorComponents(const_mgr); + if (float_type->width() == 32) { for (uint32_t i = 0; i < resultVectorSize; ++i) { float result_scalar = 0.0f; for (uint32_t j = 0; j < c1_components.size(); ++j) { - float c1_scalar = c1_components[j] - ->AsVectorConstant() - ->GetComponents()[i] - ->GetFloat(); - float c2_scalar = c2_components[j]->GetFloat(); - result_scalar += c1_scalar * c2_scalar; + if (!c1_components[j]->AsNullConstant()) { + float c1_scalar = c1_components[j] + ->AsVectorConstant() + ->GetComponents()[i] + ->GetFloat(); + float c2_scalar = c2_components[j]->GetFloat(); + result_scalar += c1_scalar * c2_scalar; + } } utils::FloatProxy result(result_scalar); std::vector words = result.GetWords(); @@ -504,12 +594,14 @@ ConstantFoldingRule FoldMatrixTimesVector() { for (uint32_t i = 0; i < resultVectorSize; ++i) { double result_scalar = 0.0; for (uint32_t j = 0; j < c1_components.size(); ++j) { - double c1_scalar = c1_components[j] - ->AsVectorConstant() - ->GetComponents()[i] - ->GetDouble(); - double c2_scalar = c2_components[j]->GetDouble(); - result_scalar += c1_scalar * c2_scalar; + if (!c1_components[j]->AsNullConstant()) { + double c1_scalar = c1_components[j] + ->AsVectorConstant() + ->GetComponents()[i] + ->GetDouble(); + double c2_scalar = c2_components[j]->GetDouble(); + result_scalar += c1_scalar * c2_scalar; + } } utils::FloatProxy result(result_scalar); std::vector words = result.GetWords(); @@ -574,13 +666,13 @@ using BinaryScalarFoldingRule = std::function; -// Returns a |ConstantFoldingRule| that folds unary floating point scalar ops -// using |scalar_rule| and unary float point vectors ops by applying +// Returns a |ConstantFoldingRule| that folds unary scalar ops +// using |scalar_rule| and unary vectors ops by applying // |scalar_rule| to the elements of the vector. The |ConstantFoldingRule| // that is returned assumes that |constants| contains 1 entry. If they are // not |nullptr|, then their type is either |Float| or |Integer| or a |Vector| // whose element type is |Float| or |Integer|. -ConstantFoldingRule FoldFPUnaryOp(UnaryScalarFoldingRule scalar_rule) { +ConstantFoldingRule FoldUnaryOp(UnaryScalarFoldingRule scalar_rule) { return [scalar_rule](IRContext* context, Instruction* inst, const std::vector& constants) -> const analysis::Constant* { @@ -589,10 +681,6 @@ ConstantFoldingRule FoldFPUnaryOp(UnaryScalarFoldingRule scalar_rule) { const analysis::Type* result_type = type_mgr->GetType(inst->type_id()); const analysis::Vector* vector_type = result_type->AsVector(); - if (!inst->IsFloatingPointFoldingAllowed()) { - return nullptr; - } - const analysis::Constant* arg = (inst->opcode() == spv::Op::OpExtInst) ? constants[1] : constants[0]; @@ -627,6 +715,83 @@ ConstantFoldingRule FoldFPUnaryOp(UnaryScalarFoldingRule scalar_rule) { }; } +// Returns a |ConstantFoldingRule| that folds binary scalar ops +// using |scalar_rule| and binary vectors ops by applying +// |scalar_rule| to the elements of the vector. The folding rule assumes that op +// has two inputs. For regular instruction, those are in operands 0 and 1. For +// extended instruction, they are in operands 1 and 2. If an element in +// |constants| is not nullprt, then the constant's type is |Float|, |Integer|, +// or |Vector| whose element type is |Float| or |Integer|. +ConstantFoldingRule FoldBinaryOp(BinaryScalarFoldingRule scalar_rule) { + return [scalar_rule](IRContext* context, Instruction* inst, + const std::vector& constants) + -> const analysis::Constant* { + assert(constants.size() == inst->NumInOperands()); + assert(constants.size() == (inst->opcode() == spv::Op::OpExtInst ? 3 : 2)); + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); + analysis::TypeManager* type_mgr = context->get_type_mgr(); + const analysis::Type* result_type = type_mgr->GetType(inst->type_id()); + const analysis::Vector* vector_type = result_type->AsVector(); + + const analysis::Constant* arg1 = + (inst->opcode() == spv::Op::OpExtInst) ? constants[1] : constants[0]; + const analysis::Constant* arg2 = + (inst->opcode() == spv::Op::OpExtInst) ? constants[2] : constants[1]; + + if (arg1 == nullptr || arg2 == nullptr) { + return nullptr; + } + + if (vector_type == nullptr) { + return scalar_rule(result_type, arg1, arg2, const_mgr); + } + + std::vector a_components; + std::vector b_components; + std::vector results_components; + + a_components = arg1->GetVectorComponents(const_mgr); + b_components = arg2->GetVectorComponents(const_mgr); + assert(a_components.size() == b_components.size()); + + // Fold each component of the vector. + for (uint32_t i = 0; i < a_components.size(); ++i) { + results_components.push_back(scalar_rule(vector_type->element_type(), + a_components[i], b_components[i], + const_mgr)); + if (results_components[i] == nullptr) { + return nullptr; + } + } + + // Build the constant object and return it. + std::vector ids; + for (const analysis::Constant* member : results_components) { + ids.push_back(const_mgr->GetDefiningInstruction(member)->result_id()); + } + return const_mgr->GetConstant(vector_type, ids); + }; +} + +// Returns a |ConstantFoldingRule| that folds unary floating point scalar ops +// using |scalar_rule| and unary float point vectors ops by applying +// |scalar_rule| to the elements of the vector. The |ConstantFoldingRule| +// that is returned assumes that |constants| contains 1 entry. If they are +// not |nullptr|, then their type is either |Float| or |Integer| or a |Vector| +// whose element type is |Float| or |Integer|. +ConstantFoldingRule FoldFPUnaryOp(UnaryScalarFoldingRule scalar_rule) { + auto folding_rule = FoldUnaryOp(scalar_rule); + return [folding_rule](IRContext* context, Instruction* inst, + const std::vector& constants) + -> const analysis::Constant* { + if (!inst->IsFloatingPointFoldingAllowed()) { + return nullptr; + } + + return folding_rule(context, inst, constants); + }; +} + // Returns the result of folding the constants in |constants| according the // |scalar_rule|. If |result_type| is a vector, then |scalar_rule| is applied // per component. @@ -859,6 +1024,11 @@ const analysis::Constant* FoldScalarFPDivide( return FoldFPScalarDivideByZero(result_type, numerator, const_mgr); } + uint32_t width = denominator->type()->AsFloat()->width(); + if (width != 32 && width != 64) { + return nullptr; + } + const analysis::FloatConstant* denominator_float = denominator->AsFloatConstant(); if (denominator_float && denominator->GetValueAsDouble() == -0.0) { @@ -1029,18 +1199,8 @@ ConstantFoldingRule FoldOpDotWithConstants() { }; } -// This function defines a |UnaryScalarFoldingRule| that subtracts the constant -// from zero. -UnaryScalarFoldingRule FoldFNegateOp() { - return [](const analysis::Type* result_type, const analysis::Constant* a, - analysis::ConstantManager* const_mgr) -> const analysis::Constant* { - assert(result_type != nullptr && a != nullptr); - assert(result_type == a->type()); - return NegateFPConst(result_type, a, const_mgr); - }; -} - -ConstantFoldingRule FoldFNegate() { return FoldFPUnaryOp(FoldFNegateOp()); } +ConstantFoldingRule FoldFNegate() { return FoldFPUnaryOp(NegateFPConst); } +ConstantFoldingRule FoldSNegate() { return FoldUnaryOp(NegateIntConst); } ConstantFoldingRule FoldFClampFeedingCompare(spv::Op cmp_opcode) { return [cmp_opcode](IRContext* context, Instruction* inst, @@ -1484,6 +1644,74 @@ BinaryScalarFoldingRule FoldFTranscendentalBinary(double (*fp)(double, return nullptr; }; } + +enum Sign { Signed, Unsigned }; + +// Returns a BinaryScalarFoldingRule that applies `op` to the scalars. +// The `signedness` is used to determine if the operands should be interpreted +// as signed or unsigned. If the operands are signed, the value will be sign +// extended before the value is passed to `op`. Otherwise the values will be +// zero extended. +template +BinaryScalarFoldingRule FoldBinaryIntegerOperation(uint64_t (*op)(uint64_t, + uint64_t)) { + return + [op](const analysis::Type* result_type, const analysis::Constant* a, + const analysis::Constant* b, + analysis::ConstantManager* const_mgr) -> const analysis::Constant* { + assert(result_type != nullptr && a != nullptr && b != nullptr); + const analysis::Integer* integer_type = result_type->AsInteger(); + assert(integer_type != nullptr); + assert(a->type()->kind() == analysis::Type::kInteger); + assert(b->type()->kind() == analysis::Type::kInteger); + assert(integer_type->width() == a->type()->AsInteger()->width()); + assert(integer_type->width() == b->type()->AsInteger()->width()); + + // In SPIR-V, all operations support unsigned types, but the way they + // are interpreted depends on the opcode. This is why we use the + // template argument to determine how to interpret the operands. + uint64_t ia = (signedness == Signed ? a->GetSignExtendedValue() + : a->GetZeroExtendedValue()); + uint64_t ib = (signedness == Signed ? b->GetSignExtendedValue() + : b->GetZeroExtendedValue()); + uint64_t result = op(ia, ib); + + const analysis::Constant* result_constant = + const_mgr->GenerateIntegerConstant(integer_type, result); + return result_constant; + }; +} + +// A scalar folding rule that folds OpSConvert. +const analysis::Constant* FoldScalarSConvert( + const analysis::Type* result_type, const analysis::Constant* a, + analysis::ConstantManager* const_mgr) { + assert(result_type != nullptr); + assert(a != nullptr); + assert(const_mgr != nullptr); + const analysis::Integer* integer_type = result_type->AsInteger(); + assert(integer_type && "The result type of an SConvert"); + int64_t value = a->GetSignExtendedValue(); + return const_mgr->GenerateIntegerConstant(integer_type, value); +} + +// A scalar folding rule that folds OpUConvert. +const analysis::Constant* FoldScalarUConvert( + const analysis::Type* result_type, const analysis::Constant* a, + analysis::ConstantManager* const_mgr) { + assert(result_type != nullptr); + assert(a != nullptr); + assert(const_mgr != nullptr); + const analysis::Integer* integer_type = result_type->AsInteger(); + assert(integer_type && "The result type of an UConvert"); + uint64_t value = a->GetZeroExtendedValue(); + + // If the operand was an unsigned value with less than 32-bit, it would have + // been sign extended earlier, and we need to clear those bits. + auto* operand_type = a->type()->AsInteger(); + value = utils::ClearHighBits(value, 64 - operand_type->width()); + return const_mgr->GenerateIntegerConstant(integer_type, value); +} } // namespace void ConstantFoldingRules::AddFoldingRules() { @@ -1501,6 +1729,8 @@ void ConstantFoldingRules::AddFoldingRules() { rules_[spv::Op::OpConvertFToU].push_back(FoldFToI()); rules_[spv::Op::OpConvertSToF].push_back(FoldIToF()); rules_[spv::Op::OpConvertUToF].push_back(FoldIToF()); + rules_[spv::Op::OpSConvert].push_back(FoldUnaryOp(FoldScalarSConvert)); + rules_[spv::Op::OpUConvert].push_back(FoldUnaryOp(FoldScalarUConvert)); rules_[spv::Op::OpDot].push_back(FoldOpDotWithConstants()); rules_[spv::Op::OpFAdd].push_back(FoldFAdd()); @@ -1553,10 +1783,52 @@ void ConstantFoldingRules::AddFoldingRules() { rules_[spv::Op::OpVectorTimesScalar].push_back(FoldVectorTimesScalar()); rules_[spv::Op::OpVectorTimesMatrix].push_back(FoldVectorTimesMatrix()); rules_[spv::Op::OpMatrixTimesVector].push_back(FoldMatrixTimesVector()); + rules_[spv::Op::OpTranspose].push_back(FoldTranspose); rules_[spv::Op::OpFNegate].push_back(FoldFNegate()); + rules_[spv::Op::OpSNegate].push_back(FoldSNegate()); rules_[spv::Op::OpQuantizeToF16].push_back(FoldQuantizeToF16()); + rules_[spv::Op::OpIAdd].push_back( + FoldBinaryOp(FoldBinaryIntegerOperation( + [](uint64_t a, uint64_t b) { return a + b; }))); + rules_[spv::Op::OpISub].push_back( + FoldBinaryOp(FoldBinaryIntegerOperation( + [](uint64_t a, uint64_t b) { return a - b; }))); + rules_[spv::Op::OpIMul].push_back( + FoldBinaryOp(FoldBinaryIntegerOperation( + [](uint64_t a, uint64_t b) { return a * b; }))); + rules_[spv::Op::OpUDiv].push_back( + FoldBinaryOp(FoldBinaryIntegerOperation( + [](uint64_t a, uint64_t b) { return (b != 0 ? a / b : 0); }))); + rules_[spv::Op::OpSDiv].push_back(FoldBinaryOp( + FoldBinaryIntegerOperation([](uint64_t a, uint64_t b) { + return (b != 0 ? static_cast(static_cast(a) / + static_cast(b)) + : 0); + }))); + rules_[spv::Op::OpUMod].push_back( + FoldBinaryOp(FoldBinaryIntegerOperation( + [](uint64_t a, uint64_t b) { return (b != 0 ? a % b : 0); }))); + + rules_[spv::Op::OpSRem].push_back(FoldBinaryOp( + FoldBinaryIntegerOperation([](uint64_t a, uint64_t b) { + return (b != 0 ? static_cast(static_cast(a) % + static_cast(b)) + : 0); + }))); + + rules_[spv::Op::OpSMod].push_back(FoldBinaryOp( + FoldBinaryIntegerOperation([](uint64_t a, uint64_t b) { + if (b == 0) return static_cast(0ull); + + int64_t signed_a = static_cast(a); + int64_t signed_b = static_cast(b); + int64_t result = signed_a % signed_b; + if ((signed_b < 0) != (result < 0)) result += signed_b; + return static_cast(result); + }))); + // Add rules for GLSLstd450 FeatureManager* feature_manager = context_->get_feature_mgr(); uint32_t ext_inst_glslstd450_id = diff --git a/third_party/spirv-tools/source/opt/constants.cpp b/third_party/spirv-tools/source/opt/constants.cpp index d70e27bb29..7dc02deaa4 100644 --- a/third_party/spirv-tools/source/opt/constants.cpp +++ b/third_party/spirv-tools/source/opt/constants.cpp @@ -14,7 +14,6 @@ #include "source/opt/constants.h" -#include #include #include "source/opt/ir_context.h" @@ -436,6 +435,8 @@ const Constant* ConstantManager::GetNumericVectorConstantWithWords( words_per_element = float_type->width() / 32; else if (const auto* int_type = element_type->AsInteger()) words_per_element = int_type->width() / 32; + else if (element_type->AsBool() != nullptr) + words_per_element = 1; if (words_per_element != 1 && words_per_element != 2) return nullptr; @@ -488,6 +489,31 @@ uint32_t ConstantManager::GetSIntConstId(int32_t val) { return GetDefiningInstruction(c)->result_id(); } +const Constant* ConstantManager::GetIntConst(uint64_t val, int32_t bitWidth, + bool isSigned) { + Type* int_type = context()->get_type_mgr()->GetIntType(bitWidth, isSigned); + + if (isSigned) { + // Sign extend the value. + int32_t num_of_bit_to_ignore = 64 - bitWidth; + val = static_cast(val << num_of_bit_to_ignore) >> + num_of_bit_to_ignore; + } else if (bitWidth < 64) { + // Clear the upper bit that are not used. + uint64_t mask = ((1ull << bitWidth) - 1); + val &= mask; + } + + if (bitWidth <= 32) { + return GetConstant(int_type, {static_cast(val)}); + } + + // If the value is more than 32-bit, we need to split the operands into two + // 32-bit integers. + return GetConstant( + int_type, {static_cast(val), static_cast(val >> 32)}); +} + uint32_t ConstantManager::GetUIntConstId(uint32_t val) { Type* uint_type = context()->get_type_mgr()->GetUIntType(); const Constant* c = GetConstant(uint_type, {val}); @@ -499,6 +525,28 @@ uint32_t ConstantManager::GetNullConstId(const Type* type) { return GetDefiningInstruction(c)->result_id(); } +const Constant* ConstantManager::GenerateIntegerConstant( + const analysis::Integer* integer_type, uint64_t result) { + assert(integer_type != nullptr); + + std::vector words; + if (integer_type->width() == 64) { + // In the 64-bit case, two words are needed to represent the value. + words = {static_cast(result), + static_cast(result >> 32)}; + } else { + // In all other cases, only a single word is needed. + assert(integer_type->width() <= 32); + if (integer_type->IsSigned()) { + result = utils::SignExtendValue(result, integer_type->width()); + } else { + result = utils::ZeroExtendValue(result, integer_type->width()); + } + words = {static_cast(result)}; + } + return GetConstant(integer_type, words); +} + std::vector Constant::GetVectorComponents( analysis::ConstantManager* const_mgr) const { std::vector components; diff --git a/third_party/spirv-tools/source/opt/constants.h b/third_party/spirv-tools/source/opt/constants.h index 410304eaee..534afa6f53 100644 --- a/third_party/spirv-tools/source/opt/constants.h +++ b/third_party/spirv-tools/source/opt/constants.h @@ -659,12 +659,23 @@ class ConstantManager { // Returns the id of a 32-bit signed integer constant with value |val|. uint32_t GetSIntConstId(int32_t val); + // Returns an integer constant with `bitWidth` and value |val|. If `isSigned` + // is true, the constant will be a signed integer. Otherwise it will be + // unsigned. Only the `bitWidth` lower order bits of |val| will be used. The + // rest will be ignored. + const Constant* GetIntConst(uint64_t val, int32_t bitWidth, bool isSigned); + // Returns the id of a 32-bit unsigned integer constant with value |val|. uint32_t GetUIntConstId(uint32_t val); // Returns the id of a OpConstantNull with type of |type|. uint32_t GetNullConstId(const Type* type); + // Returns a constant whose value is `value` and type is `type`. This constant + // will be generated by `const_mgr`. The type must be a scalar integer type. + const Constant* GenerateIntegerConstant(const analysis::Integer* integer_type, + uint64_t result); + private: // Creates a Constant instance with the given type and a vector of constant // defining words. Returns a unique pointer to the created Constant instance diff --git a/third_party/spirv-tools/source/opt/control_dependence.cpp b/third_party/spirv-tools/source/opt/control_dependence.cpp index a153cabfc6..3d48139636 100644 --- a/third_party/spirv-tools/source/opt/control_dependence.cpp +++ b/third_party/spirv-tools/source/opt/control_dependence.cpp @@ -16,8 +16,6 @@ #include #include -#include -#include #include "source/opt/basic_block.h" #include "source/opt/cfg.h" diff --git a/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp b/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp index 7a4c1f4097..e243bedf0c 100644 --- a/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp +++ b/third_party/spirv-tools/source/opt/convert_to_half_pass.cpp @@ -39,6 +39,13 @@ bool ConvertToHalfPass::IsFloat(Instruction* inst, uint32_t width) { return Pass::IsFloat(ty_id, width); } +bool ConvertToHalfPass::IsStruct(Instruction* inst) { + uint32_t ty_id = inst->type_id(); + if (ty_id == 0) return false; + Instruction* ty_inst = Pass::GetBaseType(ty_id); + return (ty_inst->opcode() == spv::Op::OpTypeStruct); +} + bool ConvertToHalfPass::IsDecoratedRelaxed(Instruction* inst) { uint32_t r_id = inst->result_id(); for (auto r_inst : get_decoration_mgr()->GetDecorationsFor(r_id, false)) @@ -56,6 +63,10 @@ bool ConvertToHalfPass::IsRelaxed(uint32_t id) { void ConvertToHalfPass::AddRelaxed(uint32_t id) { relaxed_ids_set_.insert(id); } +bool ConvertToHalfPass::CanRelaxOpOperands(Instruction* inst) { + return image_ops_.count(inst->opcode()) == 0; +} + analysis::Type* ConvertToHalfPass::FloatScalarType(uint32_t width) { analysis::Float float_ty(width); return context()->get_type_mgr()->GetRegisteredType(&float_ty); @@ -160,6 +171,19 @@ bool ConvertToHalfPass::RemoveRelaxedDecoration(uint32_t id) { bool ConvertToHalfPass::GenHalfArith(Instruction* inst) { bool modified = false; + // If this is a OpCompositeExtract instruction and has a struct operand, we + // should not relax this instruction. Doing so could cause a mismatch between + // the result type and the struct member type. + bool hasStructOperand = false; + if (inst->opcode() == spv::Op::OpCompositeExtract) { + inst->ForEachInId([&hasStructOperand, this](uint32_t* idp) { + Instruction* op_inst = get_def_use_mgr()->GetDef(*idp); + if (IsStruct(op_inst)) hasStructOperand = true; + }); + if (hasStructOperand) { + return false; + } + } // Convert all float32 based operands to float16 equivalent and change // instruction type to float16 equivalent. inst->ForEachInId([&inst, &modified, this](uint32_t* idp) { @@ -292,11 +316,19 @@ bool ConvertToHalfPass::CloseRelaxInst(Instruction* inst) { if (closure_ops_.count(inst->opcode()) == 0) return false; // Can relax if all float operands are relaxed bool relax = true; - inst->ForEachInId([&relax, this](uint32_t* idp) { + bool hasStructOperand = false; + inst->ForEachInId([&relax, &hasStructOperand, this](uint32_t* idp) { Instruction* op_inst = get_def_use_mgr()->GetDef(*idp); + if (IsStruct(op_inst)) hasStructOperand = true; if (!IsFloat(op_inst, 32)) return; if (!IsRelaxed(*idp)) relax = false; }); + // If the instruction has a struct operand, we should not relax it, even if + // all its uses are relaxed. Doing so could cause a mismatch between the + // result type and the struct member type. + if (hasStructOperand) { + return false; + } if (relax) { AddRelaxed(inst->result_id()); return true; @@ -305,7 +337,8 @@ bool ConvertToHalfPass::CloseRelaxInst(Instruction* inst) { relax = true; get_def_use_mgr()->ForEachUser(inst, [&relax, this](Instruction* uinst) { if (uinst->result_id() == 0 || !IsFloat(uinst, 32) || - (!IsDecoratedRelaxed(uinst) && !IsRelaxed(uinst->result_id()))) { + (!IsDecoratedRelaxed(uinst) && !IsRelaxed(uinst->result_id())) || + !CanRelaxOpOperands(uinst)) { relax = false; return; } diff --git a/third_party/spirv-tools/source/opt/convert_to_half_pass.h b/third_party/spirv-tools/source/opt/convert_to_half_pass.h index feabfba3e1..8e10c4fb95 100644 --- a/third_party/spirv-tools/source/opt/convert_to_half_pass.h +++ b/third_party/spirv-tools/source/opt/convert_to_half_pass.h @@ -45,6 +45,7 @@ class ConvertToHalfPass : public Pass { // Return true if |inst| returns scalar, vector or matrix type with base // float and |width| bool IsFloat(Instruction* inst, uint32_t width); + bool IsStruct(Instruction* inst); // Return true if |inst| is decorated with RelaxedPrecision bool IsDecoratedRelaxed(Instruction* inst); @@ -55,6 +56,9 @@ class ConvertToHalfPass : public Pass { // Add |id| to the relaxed id set void AddRelaxed(uint32_t id); + // Return true if the instruction's operands can be relaxed + bool CanRelaxOpOperands(Instruction* inst); + // Return type id for float with |width| analysis::Type* FloatScalarType(uint32_t width); @@ -132,13 +136,13 @@ class ConvertToHalfPass : public Pass { // Set of 450 extension operations to be processed std::unordered_set target_ops_450_; - // Set of sample operations + // Set of all sample operations, including dref and non-dref operations std::unordered_set image_ops_; - // Set of dref sample operations + // Set of only dref sample operations std::unordered_set dref_image_ops_; - // Set of dref sample operations + // Set of operations that can be marked as relaxed std::unordered_set closure_ops_; // Set of ids of all relaxed instructions diff --git a/third_party/spirv-tools/source/opt/convert_to_sampled_image_pass.cpp b/third_party/spirv-tools/source/opt/convert_to_sampled_image_pass.cpp index 2effc3e4c7..d2da4d1e0b 100644 --- a/third_party/spirv-tools/source/opt/convert_to_sampled_image_pass.cpp +++ b/third_party/spirv-tools/source/opt/convert_to_sampled_image_pass.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "source/opt/ir_builder.h" #include "source/util/make_unique.h" @@ -330,12 +329,10 @@ bool ConvertToSampledImagePass::ConvertImageVariableToSampledImage( if (sampled_image_type == nullptr) return false; auto storage_class = GetStorageClass(*image_variable); if (storage_class == spv::StorageClass::Max) return false; - analysis::Pointer sampled_image_pointer(sampled_image_type, storage_class); - // Make sure |image_variable| is behind its type i.e., avoid the forward // reference. - uint32_t type_id = - context()->get_type_mgr()->GetTypeInstruction(&sampled_image_pointer); + uint32_t type_id = context()->get_type_mgr()->FindPointerToType( + sampled_image_type_id, storage_class); MoveInstructionNextToType(image_variable, type_id); return true; } diff --git a/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp b/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp index 66a268fbaa..0a42074405 100644 --- a/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp +++ b/third_party/spirv-tools/source/opt/copy_prop_arrays.cpp @@ -28,6 +28,9 @@ constexpr uint32_t kStoreObjectInOperand = 1; constexpr uint32_t kCompositeExtractObjectInOperand = 0; constexpr uint32_t kTypePointerStorageClassInIdx = 0; constexpr uint32_t kTypePointerPointeeInIdx = 1; +constexpr uint32_t kExtInstSetInIdx = 0; +constexpr uint32_t kExtInstOpInIdx = 1; +constexpr uint32_t kInterpolantInIdx = 2; bool IsDebugDeclareOrValue(Instruction* di) { auto dbg_opcode = di->GetCommonDebugOpcode(); @@ -35,6 +38,32 @@ bool IsDebugDeclareOrValue(Instruction* di) { dbg_opcode == CommonDebugInfoDebugValue; } +// Returns the number of members in |type|. If |type| is not a composite type +// or the number of components is not known at compile time, the return value +// will be 0. +uint32_t GetNumberOfMembers(const analysis::Type* type, IRContext* context) { + if (const analysis::Struct* struct_type = type->AsStruct()) { + return static_cast(struct_type->element_types().size()); + } else if (const analysis::Array* array_type = type->AsArray()) { + const analysis::Constant* length_const = + context->get_constant_mgr()->FindDeclaredConstant( + array_type->LengthId()); + + if (length_const == nullptr) { + // This can happen if the length is an OpSpecConstant. + return 0; + } + assert(length_const->type()->AsInteger()); + return length_const->GetU32(); + } else if (const analysis::Vector* vector_type = type->AsVector()) { + return vector_type->element_count(); + } else if (const analysis::Matrix* matrix_type = type->AsMatrix()) { + return matrix_type->element_count(); + } else { + return 0; + } +} + } // namespace Pass::Status CopyPropagateArrays::Process() { @@ -48,28 +77,38 @@ Pass::Status CopyPropagateArrays::Process() { for (auto var_inst = entry_bb->begin(); var_inst->opcode() == spv::Op::OpVariable; ++var_inst) { - if (!IsPointerToArrayType(var_inst->type_id())) { + worklist_.push(&*var_inst); + } + } + + while (!worklist_.empty()) { + Instruction* var_inst = worklist_.front(); + worklist_.pop(); + + // Find the only store to the entire memory location, if it exists. + Instruction* store_inst = FindStoreInstruction(&*var_inst); + + if (!store_inst) { + continue; + } + + std::unique_ptr source_object = + FindSourceObjectIfPossible(&*var_inst, store_inst); + + if (source_object != nullptr) { + if (!IsPointerToArrayType(var_inst->type_id()) && + source_object->GetStorageClass() != spv::StorageClass::Input) { continue; } - // Find the only store to the entire memory location, if it exists. - Instruction* store_inst = FindStoreInstruction(&*var_inst); + if (CanUpdateUses(&*var_inst, source_object->GetPointerTypeId(this))) { + modified = true; - if (!store_inst) { - continue; - } - - std::unique_ptr source_object = - FindSourceObjectIfPossible(&*var_inst, store_inst); - - if (source_object != nullptr) { - if (CanUpdateUses(&*var_inst, source_object->GetPointerTypeId(this))) { - modified = true; - PropagateObject(&*var_inst, source_object.get(), store_inst); - } + PropagateObject(&*var_inst, source_object.get(), store_inst); } } } + return (modified ? Status::SuccessWithChange : Status::SuccessWithoutChange); } @@ -178,6 +217,8 @@ bool CopyPropagateArrays::HasNoStores(Instruction* ptr_inst) { return true; } else if (use->opcode() == spv::Op::OpEntryPoint) { return true; + } else if (IsInterpolationInstruction(use)) { + return true; } // Some other instruction. Be conservative. return false; @@ -199,6 +240,13 @@ bool CopyPropagateArrays::HasValidReferencesOnly(Instruction* ptr_inst, // time to do the multiple traverses can add up. Consider collecting // those loads and doing a single traversal. return dominator_analysis->Dominates(store_inst, use); + } else if (IsInterpolationInstruction(use)) { + // GLSL InterpolateAt* instructions work similarly to loads + uint32_t interpolant = use->GetSingleWordInOperand(kInterpolantInIdx); + if (interpolant != + store_inst->GetSingleWordInOperand(kStorePointerInOperand)) + return false; + return dominator_analysis->Dominates(store_inst, use); } else if (use->opcode() == spv::Op::OpAccessChain) { return HasValidReferencesOnly(use, store_inst); } else if (use->IsDecoration() || use->opcode() == spv::Op::OpName) { @@ -357,22 +405,9 @@ CopyPropagateArrays::BuildMemoryObjectFromInsert(Instruction* insert_inst) { analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::ConstantManager* const_mgr = context()->get_constant_mgr(); const analysis::Type* result_type = type_mgr->GetType(insert_inst->type_id()); - uint32_t number_of_elements = 0; - if (const analysis::Struct* struct_type = result_type->AsStruct()) { - number_of_elements = - static_cast(struct_type->element_types().size()); - } else if (const analysis::Array* array_type = result_type->AsArray()) { - const analysis::Constant* length_const = - const_mgr->FindDeclaredConstant(array_type->LengthId()); - number_of_elements = length_const->GetU32(); - } else if (const analysis::Vector* vector_type = result_type->AsVector()) { - number_of_elements = vector_type->element_count(); - } else if (const analysis::Matrix* matrix_type = result_type->AsMatrix()) { - number_of_elements = matrix_type->element_count(); - } + uint32_t number_of_elements = GetNumberOfMembers(result_type, context()); if (number_of_elements == 0) { return nullptr; @@ -476,6 +511,21 @@ bool CopyPropagateArrays::IsPointerToArrayType(uint32_t type_id) { return false; } +bool CopyPropagateArrays::IsInterpolationInstruction(Instruction* inst) { + if (inst->opcode() == spv::Op::OpExtInst && + inst->GetSingleWordInOperand(kExtInstSetInIdx) == + context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450()) { + uint32_t ext_inst = inst->GetSingleWordInOperand(kExtInstOpInIdx); + switch (ext_inst) { + case GLSLstd450InterpolateAtCentroid: + case GLSLstd450InterpolateAtOffset: + case GLSLstd450InterpolateAtSample: + return true; + } + } + return false; +} + bool CopyPropagateArrays::CanUpdateUses(Instruction* original_ptr_inst, uint32_t type_id) { analysis::TypeManager* type_mgr = context()->get_type_mgr(); @@ -509,6 +559,11 @@ bool CopyPropagateArrays::CanUpdateUses(Instruction* original_ptr_inst, } return true; } + case spv::Op::OpExtInst: + if (IsInterpolationInstruction(use)) { + return true; + } + return false; case spv::Op::OpAccessChain: { analysis::Pointer* pointer_type = type->AsPointer(); const analysis::Type* pointee_type = pointer_type->pointee_type(); @@ -657,6 +712,18 @@ void CopyPropagateArrays::UpdateUses(Instruction* original_ptr_inst, } else { context()->AnalyzeUses(use); } + + AddUsesToWorklist(use); + } break; + case spv::Op::OpExtInst: { + if (IsInterpolationInstruction(use)) { + // Replace the actual use. + context()->ForgetUses(use); + use->SetOperand(index, {new_ptr_inst->result_id()}); + context()->AnalyzeUses(use); + } else { + assert(false && "Don't know how to rewrite instruction"); + } } break; case spv::Op::OpAccessChain: { // Update the actual use. @@ -738,6 +805,8 @@ void CopyPropagateArrays::UpdateUses(Instruction* original_ptr_inst, uint32_t pointee_type_id = pointer_type->GetSingleWordInOperand(kTypePointerPointeeInIdx); uint32_t copy = GenerateCopy(original_ptr_inst, pointee_type_id, use); + assert(copy != 0 && + "Should not be updating uses unless we know it can be done."); context()->ForgetUses(use); use->SetInOperand(index, {copy}); @@ -784,6 +853,22 @@ uint32_t CopyPropagateArrays::GetMemberTypeId( return id; } +void CopyPropagateArrays::AddUsesToWorklist(Instruction* inst) { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + + def_use_mgr->ForEachUse(inst, [this](Instruction* use, uint32_t) { + if (use->opcode() == spv::Op::OpStore) { + uint32_t var_id; + Instruction* target_pointer = GetPtr(use, &var_id); + if (target_pointer->opcode() != spv::Op::OpVariable) { + return; + } + + worklist_.push(target_pointer); + } + }); +} + void CopyPropagateArrays::MemoryObject::PushIndirection( const std::vector& access_chain) { access_chain_.insert(access_chain_.end(), access_chain.begin(), @@ -800,23 +885,8 @@ uint32_t CopyPropagateArrays::MemoryObject::GetNumberOfMembers() { std::vector access_indices = GetAccessIds(); type = type_mgr->GetMemberType(type, access_indices); - if (const analysis::Struct* struct_type = type->AsStruct()) { - return static_cast(struct_type->element_types().size()); - } else if (const analysis::Array* array_type = type->AsArray()) { - const analysis::Constant* length_const = - context->get_constant_mgr()->FindDeclaredConstant( - array_type->LengthId()); - assert(length_const->type()->AsInteger()); - return length_const->GetU32(); - } else if (const analysis::Vector* vector_type = type->AsVector()) { - return vector_type->element_count(); - } else if (const analysis::Matrix* matrix_type = type->AsMatrix()) { - return matrix_type->element_count(); - } else { - return 0; - } + return opt::GetNumberOfMembers(type, context); } - template CopyPropagateArrays::MemoryObject::MemoryObject(Instruction* var_inst, iterator begin, iterator end) diff --git a/third_party/spirv-tools/source/opt/copy_prop_arrays.h b/third_party/spirv-tools/source/opt/copy_prop_arrays.h index 7486f8086e..bf4bfb5c54 100644 --- a/third_party/spirv-tools/source/opt/copy_prop_arrays.h +++ b/third_party/spirv-tools/source/opt/copy_prop_arrays.h @@ -101,7 +101,8 @@ class CopyPropagateArrays : public MemPass { bool IsMember() const { return !access_chain_.empty(); } // Returns the number of members in the object represented by |this|. If - // |this| does not represent a composite type, the return value will be 0. + // |this| does not represent a composite type or the number of components is + // not known at compile time, the return value will be 0. uint32_t GetNumberOfMembers(); // Returns the owning variable that the memory object is contained in. @@ -207,7 +208,7 @@ class CopyPropagateArrays : public MemPass { // Returns the memory object that at some point was equivalent to the result // of |insert_inst|. If a memory object cannot be identified, the return - // value is |nullptr\. The opcode of |insert_inst| must be + // value is |nullptr|. The opcode of |insert_inst| must be // |OpCompositeInsert|. This function looks for a series of // |OpCompositeInsert| instructions that insert the elements one at a time in // order from beginning to end. @@ -221,6 +222,10 @@ class CopyPropagateArrays : public MemPass { // Return true if |type_id| is a pointer type whose pointee type is an array. bool IsPointerToArrayType(uint32_t type_id); + // Return true if |inst| is one of the InterpolateAt* GLSL.std.450 extended + // instructions. + bool IsInterpolationInstruction(Instruction* inst); + // Returns true if there are not stores using |ptr_inst| or something derived // from it. bool HasNoStores(Instruction* ptr_inst); @@ -253,6 +258,14 @@ class CopyPropagateArrays : public MemPass { // same way the indexes are used in an |OpCompositeExtract| instruction. uint32_t GetMemberTypeId(uint32_t id, const std::vector& access_chain) const; + + // If the result of inst is stored to a variable, add that variable to the + // worklist. + void AddUsesToWorklist(Instruction* inst); + + // OpVariable worklist. An instruction is added to this list if we would like + // to run copy propagation on it. + std::queue worklist_; }; } // namespace opt diff --git a/third_party/spirv-tools/source/opt/dataflow.cpp b/third_party/spirv-tools/source/opt/dataflow.cpp index 8d74e41373..63737f1984 100644 --- a/third_party/spirv-tools/source/opt/dataflow.cpp +++ b/third_party/spirv-tools/source/opt/dataflow.cpp @@ -14,7 +14,6 @@ #include "source/opt/dataflow.h" -#include #include namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp index 319b8d161c..1526b9e05e 100644 --- a/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/dead_branch_elim_pass.cpp @@ -23,7 +23,6 @@ #include "source/cfa.h" #include "source/opt/ir_context.h" -#include "source/opt/iterator.h" #include "source/opt/struct_cfg_analysis.h" #include "source/util/make_unique.h" diff --git a/third_party/spirv-tools/source/opt/dead_insert_elim_pass.cpp b/third_party/spirv-tools/source/opt/dead_insert_elim_pass.cpp index a48690374e..f985e4c268 100644 --- a/third_party/spirv-tools/source/opt/dead_insert_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/dead_insert_elim_pass.cpp @@ -213,7 +213,8 @@ bool DeadInsertElimPass::EliminateDeadInsertsOnePass(Function* func) { } break; default: { // Mark inserts in chain for all components - MarkInsertChain(&*ii, nullptr, 0, nullptr); + std::unordered_set visited_phis; + MarkInsertChain(&*ii, nullptr, 0, &visited_phis); } break; } }); diff --git a/third_party/spirv-tools/source/opt/debug_info_manager.cpp b/third_party/spirv-tools/source/opt/debug_info_manager.cpp index 1e614c6ff3..24094b36ef 100644 --- a/third_party/spirv-tools/source/opt/debug_info_manager.cpp +++ b/third_party/spirv-tools/source/opt/debug_info_manager.cpp @@ -768,15 +768,29 @@ void DebugInfoManager::ConvertDebugGlobalToLocalVariable( local_var->opcode() == spv::Op::OpFunctionParameter); // Convert |dbg_global_var| to DebugLocalVariable + // All of the operands up to the scope operand are the same for the type + // instructions. The flag operand needs to move from operand + // kDebugGlobalVariableOperandFlagsIndex to + // kDebugLocalVariableOperandFlagsIndex. No other operands are needed to + // define the DebugLocalVariable. + + // Modify the opcode. dbg_global_var->SetInOperand(kExtInstInstructionInIdx, {CommonDebugInfoDebugLocalVariable}); + + // Move the flags operand. auto flags = dbg_global_var->GetSingleWordOperand( kDebugGlobalVariableOperandFlagsIndex); - for (uint32_t i = dbg_global_var->NumInOperands() - 1; - i >= kDebugLocalVariableOperandFlagsIndex; --i) { + dbg_global_var->SetOperand(kDebugLocalVariableOperandFlagsIndex, {flags}); + + // Remove the extra operands. Starting at the end to avoid copying too much + // data. + for (uint32_t i = dbg_global_var->NumOperands() - 1; + i > kDebugLocalVariableOperandFlagsIndex; --i) { dbg_global_var->RemoveOperand(i); } - dbg_global_var->SetOperand(kDebugLocalVariableOperandFlagsIndex, {flags}); + + // Update the def-use manager. context()->ForgetUses(dbg_global_var); context()->AnalyzeUses(dbg_global_var); diff --git a/third_party/spirv-tools/source/opt/decoration_manager.cpp b/third_party/spirv-tools/source/opt/decoration_manager.cpp index 1393d480e6..3e95dbc352 100644 --- a/third_party/spirv-tools/source/opt/decoration_manager.cpp +++ b/third_party/spirv-tools/source/opt/decoration_manager.cpp @@ -461,7 +461,7 @@ std::vector DecorationManager::InternalGetDecorationsFor( bool DecorationManager::WhileEachDecoration( uint32_t id, uint32_t decoration, - std::function f) { + std::function f) const { for (const Instruction* inst : GetDecorationsFor(id, true)) { switch (inst->opcode()) { case spv::Op::OpMemberDecorate: @@ -485,14 +485,19 @@ bool DecorationManager::WhileEachDecoration( void DecorationManager::ForEachDecoration( uint32_t id, uint32_t decoration, - std::function f) { + std::function f) const { WhileEachDecoration(id, decoration, [&f](const Instruction& inst) { f(inst); return true; }); } -bool DecorationManager::HasDecoration(uint32_t id, uint32_t decoration) { +bool DecorationManager::HasDecoration(uint32_t id, + spv::Decoration decoration) const { + return HasDecoration(id, static_cast(decoration)); +} + +bool DecorationManager::HasDecoration(uint32_t id, uint32_t decoration) const { bool has_decoration = false; ForEachDecoration(id, decoration, [&has_decoration](const Instruction&) { has_decoration = true; diff --git a/third_party/spirv-tools/source/opt/decoration_manager.h b/third_party/spirv-tools/source/opt/decoration_manager.h index 1a0d1b1838..2be016a71a 100644 --- a/third_party/spirv-tools/source/opt/decoration_manager.h +++ b/third_party/spirv-tools/source/opt/decoration_manager.h @@ -92,20 +92,21 @@ class DecorationManager { // Returns whether a decoration instruction for |id| with decoration // |decoration| exists or not. - bool HasDecoration(uint32_t id, uint32_t decoration); + bool HasDecoration(uint32_t id, uint32_t decoration) const; + bool HasDecoration(uint32_t id, spv::Decoration decoration) const; // |f| is run on each decoration instruction for |id| with decoration // |decoration|. Processed are all decorations which target |id| either // directly or indirectly by Decoration Groups. void ForEachDecoration(uint32_t id, uint32_t decoration, - std::function f); + std::function f) const; // |f| is run on each decoration instruction for |id| with decoration // |decoration|. Processes all decoration which target |id| either directly or // indirectly through decoration groups. If |f| returns false, iteration is // terminated and this function returns false. bool WhileEachDecoration(uint32_t id, uint32_t decoration, - std::function f); + std::function f) const; // |f| is run on each decoration instruction for |id| with decoration // |decoration|. Processes all decoration which target |id| either directly or @@ -141,7 +142,7 @@ class DecorationManager { uint32_t decoration_value); // Add |decoration, decoration_value| of |inst_id, member| to module. - void AddMemberDecoration(uint32_t member, uint32_t inst_id, + void AddMemberDecoration(uint32_t inst_id, uint32_t member, uint32_t decoration, uint32_t decoration_value); friend bool operator==(const DecorationManager&, const DecorationManager&); diff --git a/third_party/spirv-tools/source/opt/def_use_manager.h b/third_party/spirv-tools/source/opt/def_use_manager.h index a8dbbc60b6..13cf9bd3ed 100644 --- a/third_party/spirv-tools/source/opt/def_use_manager.h +++ b/third_party/spirv-tools/source/opt/def_use_manager.h @@ -27,28 +27,6 @@ namespace spvtools { namespace opt { namespace analysis { -// Class for representing a use of id. Note that: -// * Result type id is a use. -// * Ids referenced in OpSectionMerge & OpLoopMerge are considered as use. -// * Ids referenced in OpPhi's in operands are considered as use. -struct Use { - Instruction* inst; // Instruction using the id. - uint32_t operand_index; // logical operand index of the id use. This can be - // the index of result type id. -}; - -inline bool operator==(const Use& lhs, const Use& rhs) { - return lhs.inst == rhs.inst && lhs.operand_index == rhs.operand_index; -} - -inline bool operator!=(const Use& lhs, const Use& rhs) { return !(lhs == rhs); } - -inline bool operator<(const Use& lhs, const Use& rhs) { - if (lhs.inst < rhs.inst) return true; - if (lhs.inst > rhs.inst) return false; - return lhs.operand_index < rhs.operand_index; -} - // Definition should never be null. User can be null, however, such an entry // should be used only for searching (e.g. all users of a particular definition) // and never stored in a container. diff --git a/third_party/spirv-tools/source/opt/desc_sroa.cpp b/third_party/spirv-tools/source/opt/desc_sroa.cpp index 8da0c864fe..124a3d3a8e 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa.cpp +++ b/third_party/spirv-tools/source/opt/desc_sroa.cpp @@ -31,11 +31,14 @@ bool IsDecorationBinding(Instruction* inst) { Pass::Status DescriptorScalarReplacement::Process() { bool modified = false; - std::vector vars_to_kill; for (Instruction& var : context()->types_values()) { - if (descsroautil::IsDescriptorArray(context(), &var)) { + bool is_candidate = + flatten_arrays_ && descsroautil::IsDescriptorArray(context(), &var); + is_candidate |= flatten_composites_ && + descsroautil::IsDescriptorStruct(context(), &var); + if (is_candidate) { modified = true; if (!ReplaceCandidate(&var)) { return Status::Failure; @@ -54,9 +57,10 @@ Pass::Status DescriptorScalarReplacement::Process() { bool DescriptorScalarReplacement::ReplaceCandidate(Instruction* var) { std::vector access_chain_work_list; std::vector load_work_list; + std::vector entry_point_work_list; bool failed = !get_def_use_mgr()->WhileEachUser( - var->result_id(), - [this, &access_chain_work_list, &load_work_list](Instruction* use) { + var->result_id(), [this, &access_chain_work_list, &load_work_list, + &entry_point_work_list](Instruction* use) { if (use->opcode() == spv::Op::OpName) { return true; } @@ -73,6 +77,9 @@ bool DescriptorScalarReplacement::ReplaceCandidate(Instruction* var) { case spv::Op::OpLoad: load_work_list.push_back(use); return true; + case spv::Op::OpEntryPoint: + entry_point_work_list.push_back(use); + return true; default: context()->EmitErrorMessage( "Variable cannot be replaced: invalid instruction", use); @@ -95,6 +102,11 @@ bool DescriptorScalarReplacement::ReplaceCandidate(Instruction* var) { return false; } } + for (Instruction* use : entry_point_work_list) { + if (!ReplaceEntryPoint(var, use)) { + return false; + } + } return true; } @@ -147,6 +159,42 @@ bool DescriptorScalarReplacement::ReplaceAccessChain(Instruction* var, return true; } +bool DescriptorScalarReplacement::ReplaceEntryPoint(Instruction* var, + Instruction* use) { + // Build a new |OperandList| for |use| that removes |var| and adds its + // replacement variables. + Instruction::OperandList new_operands; + + // Copy all operands except |var|. + bool found = false; + for (uint32_t idx = 0; idx < use->NumOperands(); idx++) { + Operand& op = use->GetOperand(idx); + if (op.type == SPV_OPERAND_TYPE_ID && op.words[0] == var->result_id()) { + found = true; + } else { + new_operands.emplace_back(op); + } + } + + if (!found) { + context()->EmitErrorMessage( + "Variable cannot be replaced: invalid instruction", use); + return false; + } + + // Add all new replacement variables. + uint32_t num_replacement_vars = + descsroautil::GetNumberOfElementsForArrayOrStruct(context(), var); + for (uint32_t i = 0; i < num_replacement_vars; i++) { + new_operands.push_back( + {SPV_OPERAND_TYPE_ID, {GetReplacementVariable(var, i)}}); + } + + use->ReplaceOperands(new_operands); + context()->UpdateDefUse(use); + return true; +} + uint32_t DescriptorScalarReplacement::GetReplacementVariable(Instruction* var, uint32_t idx) { auto replacement_vars = replacement_variables_.find(var); diff --git a/third_party/spirv-tools/source/opt/desc_sroa.h b/third_party/spirv-tools/source/opt/desc_sroa.h index 6a24fd8714..d6af4df597 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa.h +++ b/third_party/spirv-tools/source/opt/desc_sroa.h @@ -32,9 +32,16 @@ namespace opt { // Documented in optimizer.hpp class DescriptorScalarReplacement : public Pass { public: - DescriptorScalarReplacement() {} + DescriptorScalarReplacement(bool flatten_composites, bool flatten_arrays) + : flatten_composites_(flatten_composites), + flatten_arrays_(flatten_arrays) {} - const char* name() const override { return "descriptor-scalar-replacement"; } + const char* name() const override { + if (flatten_composites_ && flatten_arrays_) + return "descriptor-scalar-replacement"; + if (flatten_composites_) return "descriptor-compososite-scalar-replacement"; + return "descriptor-array-scalar-replacement"; + } Status Process() override; @@ -64,6 +71,11 @@ class DescriptorScalarReplacement : public Pass { // otherwise. bool ReplaceLoadedValue(Instruction* var, Instruction* value); + // Replaces the given composite variable |var| in the OpEntryPoint with the + // new replacement variables, one for each element of the array |var|. Returns + // |true| if successful, and |false| otherwise. + bool ReplaceEntryPoint(Instruction* var, Instruction* use); + // Replaces the given OpCompositeExtract |extract| and all of its references // with an OpLoad of a replacement variable. |var| is the variable with // composite type whose value is being used by |extract|. Assumes that @@ -136,6 +148,9 @@ class DescriptorScalarReplacement : public Pass { // array |var|. If the entry is |0|, then the variable has not been // created yet. std::map> replacement_variables_; + + bool flatten_composites_; + bool flatten_arrays_; }; } // namespace opt diff --git a/third_party/spirv-tools/source/opt/desc_sroa_util.cpp b/third_party/spirv-tools/source/opt/desc_sroa_util.cpp index dba3de9c05..62d9476467 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa_util.cpp +++ b/third_party/spirv-tools/source/opt/desc_sroa_util.cpp @@ -29,41 +29,58 @@ uint32_t GetLengthOfArrayType(IRContext* context, Instruction* type) { return length_const->GetU32(); } -} // namespace +bool HasDescriptorDecorations(IRContext* context, Instruction* var) { + const auto& decoration_mgr = context->get_decoration_mgr(); + return decoration_mgr->HasDecoration( + var->result_id(), uint32_t(spv::Decoration::DescriptorSet)) && + decoration_mgr->HasDecoration(var->result_id(), + uint32_t(spv::Decoration::Binding)); +} -namespace descsroautil { - -bool IsDescriptorArray(IRContext* context, Instruction* var) { +Instruction* GetVariableType(IRContext* context, Instruction* var) { if (var->opcode() != spv::Op::OpVariable) { - return false; + return nullptr; } uint32_t ptr_type_id = var->type_id(); Instruction* ptr_type_inst = context->get_def_use_mgr()->GetDef(ptr_type_id); if (ptr_type_inst->opcode() != spv::Op::OpTypePointer) { - return false; + return nullptr; } uint32_t var_type_id = ptr_type_inst->GetSingleWordInOperand(1); - Instruction* var_type_inst = context->get_def_use_mgr()->GetDef(var_type_id); - if (var_type_inst->opcode() != spv::Op::OpTypeArray && - var_type_inst->opcode() != spv::Op::OpTypeStruct) { - return false; + return context->get_def_use_mgr()->GetDef(var_type_id); +} + +} // namespace + +namespace descsroautil { + +bool IsDescriptorArray(IRContext* context, Instruction* var) { + Instruction* var_type_inst = GetVariableType(context, var); + if (var_type_inst == nullptr) return false; + return var_type_inst->opcode() == spv::Op::OpTypeArray && + HasDescriptorDecorations(context, var); +} + +bool IsDescriptorStruct(IRContext* context, Instruction* var) { + Instruction* var_type_inst = GetVariableType(context, var); + if (var_type_inst == nullptr) return false; + + while (var_type_inst->opcode() == spv::Op::OpTypeArray) { + var_type_inst = context->get_def_use_mgr()->GetDef( + var_type_inst->GetInOperand(0).AsId()); } + if (var_type_inst->opcode() != spv::Op::OpTypeStruct) return false; + // All structures with descriptor assignments must be replaced by variables, // one for each of their members - with the exceptions of buffers. if (IsTypeOfStructuredBuffer(context, var_type_inst)) { return false; } - if (!context->get_decoration_mgr()->HasDecoration( - var->result_id(), uint32_t(spv::Decoration::DescriptorSet))) { - return false; - } - - return context->get_decoration_mgr()->HasDecoration( - var->result_id(), uint32_t(spv::Decoration::Binding)); + return HasDescriptorDecorations(context, var); } bool IsTypeOfStructuredBuffer(IRContext* context, const Instruction* type) { diff --git a/third_party/spirv-tools/source/opt/desc_sroa_util.h b/third_party/spirv-tools/source/opt/desc_sroa_util.h index 2f45c0c2f4..04233565b1 100644 --- a/third_party/spirv-tools/source/opt/desc_sroa_util.h +++ b/third_party/spirv-tools/source/opt/desc_sroa_util.h @@ -27,6 +27,10 @@ namespace descsroautil { // descriptor array. bool IsDescriptorArray(IRContext* context, Instruction* var); +// Returns true if |var| is an OpVariable instruction that represents a +// struct containing descriptors. +bool IsDescriptorStruct(IRContext* context, Instruction* var); + // Returns true if |type| is a type that could be used for a structured buffer // as opposed to a type that would be used for a structure of resource // descriptors. diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_constant_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_constant_pass.cpp index d021515600..500fd8af9a 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_constant_pass.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_constant_pass.cpp @@ -20,7 +20,6 @@ #include #include "source/opt/def_use_manager.h" -#include "source/opt/ir_context.h" #include "source/opt/log.h" #include "source/opt/reflect.h" diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_functions_util.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_functions_util.cpp index cf7f92f550..e95b7f6a86 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_functions_util.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_functions_util.cpp @@ -37,7 +37,9 @@ Module::iterator EliminateFunction(IRContext* context, assert(inst->IsNonSemanticInstruction()); if (to_kill.find(inst) != to_kill.end()) return; std::unique_ptr clone(inst->Clone(context)); - context->ForgetUses(inst); + // Clear uses of "inst" to in case this moves a dependent chain of + // instructions. + context->get_def_use_mgr()->ClearInst(inst); context->AnalyzeDefUse(clone.get()); if (first_func) { context->AddGlobalValue(std::move(clone)); diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_io_components_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_io_components_pass.cpp index 916fc27a3c..5553a3362f 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_io_components_pass.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_io_components_pass.cpp @@ -15,11 +15,9 @@ #include "source/opt/eliminate_dead_io_components_pass.h" -#include #include #include "source/opt/instruction.h" -#include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" #include "source/util/bit_vector.h" diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp index 1c98502e22..170f27068b 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_members_pass.cpp @@ -70,6 +70,11 @@ void EliminateDeadMembersPass::FindLiveMembers() { MarkPointeeTypeAsFullUsed(inst.type_id()); break; } + } else if (inst.opcode() == spv::Op::OpTypePointer) { + uint32_t storage_class = inst.GetSingleWordInOperand(0); + if (storage_class == uint32_t(spv::StorageClass::PhysicalStorageBuffer)) { + MarkTypeAsFullyUsed(inst.GetSingleWordInOperand(1)); + } } } @@ -200,6 +205,9 @@ void EliminateDeadMembersPass::MarkMembersAsLiveForExtract( case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeVector: case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: type_id = type_inst->GetSingleWordInOperand(0); break; default: @@ -246,6 +254,9 @@ void EliminateDeadMembersPass::MarkMembersAsLiveForAccessChain( case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeVector: case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: type_id = type_inst->GetSingleWordInOperand(0); break; default: @@ -505,6 +516,9 @@ bool EliminateDeadMembersPass::UpdateAccessChain(Instruction* inst) { case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeVector: case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: new_operands.emplace_back(inst->GetInOperand(i)); type_id = type_inst->GetSingleWordInOperand(0); break; @@ -578,6 +592,9 @@ bool EliminateDeadMembersPass::UpdateCompsiteExtract(Instruction* inst) { case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeVector: case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: type_id = type_inst->GetSingleWordInOperand(0); break; default: @@ -639,6 +656,9 @@ bool EliminateDeadMembersPass::UpdateCompositeInsert(Instruction* inst) { case spv::Op::OpTypeRuntimeArray: case spv::Op::OpTypeVector: case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: type_id = type_inst->GetSingleWordInOperand(0); break; default: diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.cpp b/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.cpp index f2f64f812a..e71032d439 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.cpp +++ b/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.cpp @@ -92,16 +92,19 @@ void EliminateDeadOutputStoresPass::KillAllDeadStoresOfLocRef( }); // Compute offset and final type of reference. If no location found // or any stored locations are live, return without removing stores. - auto ptr_type = type_mgr->GetType(var->type_id())->AsPointer(); + + Instruction* ptr_type = get_def_use_mgr()->GetDef(var->type_id()); assert(ptr_type && "unexpected var type"); - auto var_type = ptr_type->pointee_type(); + const uint32_t kPointerTypePointeeIdx = 1; + uint32_t var_type_id = + ptr_type->GetSingleWordInOperand(kPointerTypePointeeIdx); uint32_t ref_loc = start_loc; - auto curr_type = var_type; if (ref->opcode() == spv::Op::OpAccessChain || ref->opcode() == spv::Op::OpInBoundsAccessChain) { - live_mgr->AnalyzeAccessChainLoc(ref, &curr_type, &ref_loc, &no_loc, - is_patch, /* input */ false); + var_type_id = live_mgr->AnalyzeAccessChainLoc( + ref, var_type_id, &ref_loc, &no_loc, is_patch, /* input */ false); } + const analysis::Type* curr_type = type_mgr->GetType(var_type_id); if (no_loc || AnyLocsAreLive(ref_loc, live_mgr->GetLocSize(curr_type))) return; // Kill all stores based on this reference @@ -219,7 +222,7 @@ Pass::Status EliminateDeadOutputStoresPass::DoDeadOutputStoreElimination() { var_id, [this, &var, is_builtin](Instruction* user) { auto op = user->opcode(); if (op == spv::Op::OpEntryPoint || op == spv::Op::OpName || - op == spv::Op::OpDecorate) + op == spv::Op::OpDecorate || user->IsNonSemanticInstruction()) return; if (is_builtin) KillAllDeadStoresOfBuiltinRef(user, &var); diff --git a/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.h b/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.h index 13785f3493..676d4f4f00 100644 --- a/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.h +++ b/third_party/spirv-tools/source/opt/eliminate_dead_output_stores_pass.h @@ -50,15 +50,9 @@ class EliminateDeadOutputStoresPass : public Pass { // Initialize elimination void InitializeElimination(); - // Do dead output store analysis - Status DoDeadOutputStoreAnalysis(); - // Do dead output store analysis Status DoDeadOutputStoreElimination(); - // Mark all locations live - void MarkAllLocsLive(); - // Kill all stores resulting from |ref|. void KillAllStoresOfRef(Instruction* ref); diff --git a/third_party/spirv-tools/source/opt/feature_manager.cpp b/third_party/spirv-tools/source/opt/feature_manager.cpp index 2a1c00664a..51883706aa 100644 --- a/third_party/spirv-tools/source/opt/feature_manager.cpp +++ b/third_party/spirv-tools/source/opt/feature_manager.cpp @@ -14,8 +14,6 @@ #include "source/opt/feature_manager.h" -#include -#include #include #include "source/enum_string_mapping.h" @@ -42,31 +40,33 @@ void FeatureManager::AddExtension(Instruction* ext) { const std::string name = ext->GetInOperand(0u).AsString(); Extension extension; if (GetExtensionFromString(name.c_str(), &extension)) { - extensions_.Add(extension); + extensions_.insert(extension); } } void FeatureManager::RemoveExtension(Extension ext) { - if (!extensions_.Contains(ext)) return; - extensions_.Remove(ext); + if (!extensions_.contains(ext)) return; + extensions_.erase(ext); } void FeatureManager::AddCapability(spv::Capability cap) { - if (capabilities_.Contains(cap)) return; + if (capabilities_.contains(cap)) return; - capabilities_.Add(cap); + capabilities_.insert(cap); spv_operand_desc desc = {}; if (SPV_SUCCESS == grammar_.lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, uint32_t(cap), &desc)) { - CapabilitySet(desc->numCapabilities, desc->capabilities) - .ForEach([this](spv::Capability c) { AddCapability(c); }); + for (auto capability : + CapabilitySet(desc->numCapabilities, desc->capabilities)) { + AddCapability(capability); + } } } void FeatureManager::RemoveCapability(spv::Capability cap) { - if (!capabilities_.Contains(cap)) return; - capabilities_.Remove(cap); + if (!capabilities_.contains(cap)) return; + capabilities_.erase(cap); } void FeatureManager::AddCapabilities(Module* module) { diff --git a/third_party/spirv-tools/source/opt/feature_manager.h b/third_party/spirv-tools/source/opt/feature_manager.h index b96988de47..d150a2fa2b 100644 --- a/third_party/spirv-tools/source/opt/feature_manager.h +++ b/third_party/spirv-tools/source/opt/feature_manager.h @@ -25,27 +25,19 @@ namespace opt { // Tracks features enabled by a module. The IRContext has a FeatureManager. class FeatureManager { public: - explicit FeatureManager(const AssemblyGrammar& grammar) : grammar_(grammar) {} - // Returns true if |ext| is an enabled extension in the module. - bool HasExtension(Extension ext) const { return extensions_.Contains(ext); } - - // Removes the given |extension| from the current FeatureManager. - void RemoveExtension(Extension extension); + bool HasExtension(Extension ext) const { return extensions_.contains(ext); } // Returns true if |cap| is an enabled capability in the module. bool HasCapability(spv::Capability cap) const { - return capabilities_.Contains(cap); + return capabilities_.contains(cap); } - // Removes the given |capability| from the current FeatureManager. - void RemoveCapability(spv::Capability capability); + // Returns the capabilities the module declares. + inline const CapabilitySet& GetCapabilities() const { return capabilities_; } - // Analyzes |module| and records enabled extensions and capabilities. - void Analyze(Module* module); - - CapabilitySet* GetCapabilities() { return &capabilities_; } - const CapabilitySet* GetCapabilities() const { return &capabilities_; } + // Returns the extensions the module imports. + inline const ExtensionSet& GetExtensions() const { return extensions_; } uint32_t GetExtInstImportId_GLSLstd450() const { return extinst_importid_GLSLstd450_; @@ -64,23 +56,34 @@ class FeatureManager { return !(a == b); } - // Adds the given |capability| and all implied capabilities into the current - // FeatureManager. - void AddCapability(spv::Capability capability); + private: + explicit FeatureManager(const AssemblyGrammar& grammar) : grammar_(grammar) {} + + // Analyzes |module| and records enabled extensions and capabilities. + void Analyze(Module* module); // Add the extension |ext| to the feature manager. void AddExtension(Instruction* ext); - // Analyzes |module| and records imported external instruction sets. - void AddExtInstImportIds(Module* module); - - private: // Analyzes |module| and records enabled extensions. void AddExtensions(Module* module); + // Removes the given |extension| from the current FeatureManager. + void RemoveExtension(Extension extension); + + // Adds the given |capability| and all implied capabilities into the current + // FeatureManager. + void AddCapability(spv::Capability capability); + // Analyzes |module| and records enabled capabilities. void AddCapabilities(Module* module); + // Removes the given |capability| from the current FeatureManager. + void RemoveCapability(spv::Capability capability); + + // Analyzes |module| and records imported external instruction sets. + void AddExtInstImportIds(Module* module); + // Auxiliary object for querying SPIR-V grammar facts. const AssemblyGrammar& grammar_; @@ -100,6 +103,8 @@ class FeatureManager { // Common NonSemanticShader100DebugInfo external instruction import ids, // cached for performance. uint32_t extinst_importid_Shader100DebugInfo_ = 0; + + friend class IRContext; }; } // namespace opt diff --git a/third_party/spirv-tools/source/opt/fix_storage_class.cpp b/third_party/spirv-tools/source/opt/fix_storage_class.cpp index 5597e825b2..608285e663 100644 --- a/third_party/spirv-tools/source/opt/fix_storage_class.cpp +++ b/third_party/spirv-tools/source/opt/fix_storage_class.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2019 Google LLC +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -99,6 +101,7 @@ bool FixStorageClass::PropagateStorageClass(Instruction* inst, case spv::Op::OpCopyMemorySized: case spv::Op::OpVariable: case spv::Op::OpBitcast: + case spv::Op::OpAllocateNodePayloadsAMDX: // Nothing to change for these opcode. The result type is the same // regardless of the storage class of the operand. return false; @@ -141,22 +144,26 @@ bool FixStorageClass::IsPointerResultType(Instruction* inst) { if (inst->type_id() == 0) { return false; } - const analysis::Type* ret_type = - context()->get_type_mgr()->GetType(inst->type_id()); - return ret_type->AsPointer() != nullptr; + + Instruction* type_def = get_def_use_mgr()->GetDef(inst->type_id()); + return type_def->opcode() == spv::Op::OpTypePointer; } bool FixStorageClass::IsPointerToStorageClass(Instruction* inst, spv::StorageClass storage_class) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Type* pType = type_mgr->GetType(inst->type_id()); - const analysis::Pointer* result_type = pType->AsPointer(); - - if (result_type == nullptr) { + if (inst->type_id() == 0) { return false; } - return (result_type->storage_class() == storage_class); + Instruction* type_def = get_def_use_mgr()->GetDef(inst->type_id()); + if (type_def->opcode() != spv::Op::OpTypePointer) { + return false; + } + + const uint32_t kPointerTypeStorageClassIndex = 0; + spv::StorageClass pointer_storage_class = static_cast( + type_def->GetSingleWordInOperand(kPointerTypeStorageClassIndex)); + return pointer_storage_class == storage_class; } bool FixStorageClass::ChangeResultType(Instruction* inst, @@ -233,6 +240,9 @@ bool FixStorageClass::PropagateType(Instruction* inst, uint32_t type_id, } uint32_t copy_id = GenerateCopy(obj_inst, pointee_type_id, inst); + if (copy_id == 0) { + return false; + } inst->SetInOperand(1, {copy_id}); context()->UpdateDefUse(inst); } @@ -301,24 +311,34 @@ uint32_t FixStorageClass::WalkAccessChainType(Instruction* inst, uint32_t id) { break; } - Instruction* orig_type_inst = get_def_use_mgr()->GetDef(id); - assert(orig_type_inst->opcode() == spv::Op::OpTypePointer); - id = orig_type_inst->GetSingleWordInOperand(1); + Instruction* id_type_inst = get_def_use_mgr()->GetDef(id); + assert(id_type_inst->opcode() == spv::Op::OpTypePointer); + id = id_type_inst->GetSingleWordInOperand(1); + spv::StorageClass input_storage_class = + static_cast(id_type_inst->GetSingleWordInOperand(0)); for (uint32_t i = start_idx; i < inst->NumInOperands(); ++i) { Instruction* type_inst = get_def_use_mgr()->GetDef(id); switch (type_inst->opcode()) { case spv::Op::OpTypeArray: case spv::Op::OpTypeRuntimeArray: + case spv::Op::OpTypeNodePayloadArrayAMDX: case spv::Op::OpTypeMatrix: case spv::Op::OpTypeVector: + case spv::Op::OpTypeCooperativeMatrixKHR: id = type_inst->GetSingleWordInOperand(0); break; case spv::Op::OpTypeStruct: { const analysis::Constant* index_const = context()->get_constant_mgr()->FindDeclaredConstant( inst->GetSingleWordInOperand(i)); - uint32_t index = index_const->GetU32(); + // It is highly unlikely that any type would have more fields than could + // be indexed by a 32-bit integer, and GetSingleWordInOperand only takes + // a 32-bit value, so we would not be able to handle it anyway. But the + // specification does allow any scalar integer type, treated as signed, + // so we simply downcast the index to 32-bits. + uint32_t index = + static_cast(index_const->GetSignExtendedValue()); id = type_inst->GetSingleWordInOperand(index); break; } @@ -329,9 +349,19 @@ uint32_t FixStorageClass::WalkAccessChainType(Instruction* inst, uint32_t id) { "Tried to extract from an object where it cannot be done."); } - return context()->get_type_mgr()->FindPointerToType( - id, static_cast( - orig_type_inst->GetSingleWordInOperand(0))); + Instruction* orig_type_inst = get_def_use_mgr()->GetDef(inst->type_id()); + spv::StorageClass orig_storage_class = + static_cast(orig_type_inst->GetSingleWordInOperand(0)); + assert(orig_type_inst->opcode() == spv::Op::OpTypePointer); + if (orig_type_inst->GetSingleWordInOperand(1) == id && + input_storage_class == orig_storage_class) { + // The existing type is correct. Avoid the search for the type. Note that if + // there is a duplicate type, the search below could return a different type + // forcing more changes to the code than necessary. + return inst->type_id(); + } + + return context()->get_type_mgr()->FindPointerToType(id, input_storage_class); } // namespace opt diff --git a/third_party/spirv-tools/source/opt/fold.cpp b/third_party/spirv-tools/source/opt/fold.cpp index 3c234c4e35..942da6835f 100644 --- a/third_party/spirv-tools/source/opt/fold.cpp +++ b/third_party/spirv-tools/source/opt/fold.cpp @@ -21,7 +21,6 @@ #include "source/opt/const_folding_rules.h" #include "source/opt/def_use_manager.h" #include "source/opt/folding_rules.h" -#include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" namespace spvtools { @@ -71,58 +70,6 @@ uint32_t InstructionFolder::UnaryOperate(spv::Op opcode, uint32_t InstructionFolder::BinaryOperate(spv::Op opcode, uint32_t a, uint32_t b) const { switch (opcode) { - // Arthimetics - case spv::Op::OpIAdd: - return a + b; - case spv::Op::OpISub: - return a - b; - case spv::Op::OpIMul: - return a * b; - case spv::Op::OpUDiv: - if (b != 0) { - return a / b; - } else { - // Dividing by 0 is undefined, so we will just pick 0. - return 0; - } - case spv::Op::OpSDiv: - if (b != 0u) { - return (static_cast(a)) / (static_cast(b)); - } else { - // Dividing by 0 is undefined, so we will just pick 0. - return 0; - } - case spv::Op::OpSRem: { - // The sign of non-zero result comes from the first operand: a. This is - // guaranteed by C++11 rules for integer division operator. The division - // result is rounded toward zero, so the result of '%' has the sign of - // the first operand. - if (b != 0u) { - return static_cast(a) % static_cast(b); - } else { - // Remainder when dividing with 0 is undefined, so we will just pick 0. - return 0; - } - } - case spv::Op::OpSMod: { - // The sign of non-zero result comes from the second operand: b - if (b != 0u) { - int32_t rem = BinaryOperate(spv::Op::OpSRem, a, b); - int32_t b_prim = static_cast(b); - return (rem + b_prim) % b_prim; - } else { - // Mod with 0 is undefined, so we will just pick 0. - return 0; - } - } - case spv::Op::OpUMod: - if (b != 0u) { - return (a % b); - } else { - // Mod with 0 is undefined, so we will just pick 0. - return 0; - } - // Shifting case spv::Op::OpShiftRightLogical: if (b >= 32) { @@ -628,7 +575,8 @@ Instruction* InstructionFolder::FoldInstructionToConstant( Instruction* inst, std::function id_map) const { analysis::ConstantManager* const_mgr = context_->get_constant_mgr(); - if (!inst->IsFoldableByFoldScalar() && !HasConstFoldingRule(inst)) { + if (!inst->IsFoldableByFoldScalar() && !inst->IsFoldableByFoldVector() && + !GetConstantFoldingRules().HasFoldingRule(inst)) { return nullptr; } // Collect the values of the constant parameters. @@ -662,29 +610,58 @@ Instruction* InstructionFolder::FoldInstructionToConstant( } } - uint32_t result_val = 0; bool successful = false; + // If all parameters are constant, fold the instruction to a constant. - if (!missing_constants && inst->IsFoldableByFoldScalar()) { - result_val = FoldScalars(inst->opcode(), constants); - successful = true; + if (inst->IsFoldableByFoldScalar()) { + uint32_t result_val = 0; + + if (!missing_constants) { + result_val = FoldScalars(inst->opcode(), constants); + successful = true; + } + + if (!successful) { + successful = FoldIntegerOpToConstant(inst, id_map, &result_val); + } + + if (successful) { + const analysis::Constant* result_const = + const_mgr->GetConstant(const_mgr->GetType(inst), {result_val}); + Instruction* folded_inst = + const_mgr->GetDefiningInstruction(result_const, inst->type_id()); + return folded_inst; + } + } else if (inst->IsFoldableByFoldVector()) { + std::vector result_val; + + if (!missing_constants) { + if (Instruction* inst_type = + context_->get_def_use_mgr()->GetDef(inst->type_id())) { + result_val = FoldVectors( + inst->opcode(), inst_type->GetSingleWordInOperand(1), constants); + successful = true; + } + } + + if (successful) { + const analysis::Constant* result_const = + const_mgr->GetNumericVectorConstantWithWords( + const_mgr->GetType(inst)->AsVector(), result_val); + Instruction* folded_inst = + const_mgr->GetDefiningInstruction(result_const, inst->type_id()); + return folded_inst; + } } - if (!successful && inst->IsFoldableByFoldScalar()) { - successful = FoldIntegerOpToConstant(inst, id_map, &result_val); - } - - if (successful) { - const analysis::Constant* result_const = - const_mgr->GetConstant(const_mgr->GetType(inst), {result_val}); - Instruction* folded_inst = - const_mgr->GetDefiningInstruction(result_const, inst->type_id()); - return folded_inst; - } return nullptr; } bool InstructionFolder::IsFoldableType(Instruction* type_inst) const { + return IsFoldableScalarType(type_inst) || IsFoldableVectorType(type_inst); +} + +bool InstructionFolder::IsFoldableScalarType(Instruction* type_inst) const { // Support 32-bit integers. if (type_inst->opcode() == spv::Op::OpTypeInt) { return type_inst->GetSingleWordInOperand(0) == 32; @@ -697,6 +674,19 @@ bool InstructionFolder::IsFoldableType(Instruction* type_inst) const { return false; } +bool InstructionFolder::IsFoldableVectorType(Instruction* type_inst) const { + // Support vectors with foldable components + if (type_inst->opcode() == spv::Op::OpTypeVector) { + uint32_t component_type_id = type_inst->GetSingleWordInOperand(0); + Instruction* def_component_type = + context_->get_def_use_mgr()->GetDef(component_type_id); + return def_component_type != nullptr && + IsFoldableScalarType(def_component_type); + } + // Nothing else yet. + return false; +} + bool InstructionFolder::FoldInstruction(Instruction* inst) const { bool modified = false; Instruction* folded_inst(inst); diff --git a/third_party/spirv-tools/source/opt/fold.h b/third_party/spirv-tools/source/opt/fold.h index 9a131d0df5..42da65e4d2 100644 --- a/third_party/spirv-tools/source/opt/fold.h +++ b/third_party/spirv-tools/source/opt/fold.h @@ -86,6 +86,14 @@ class InstructionFolder { // result type is |type_inst|. bool IsFoldableType(Instruction* type_inst) const; + // Returns true if |FoldInstructionToConstant| could fold an instruction whose + // result type is |type_inst|. + bool IsFoldableScalarType(Instruction* type_inst) const; + + // Returns true if |FoldInstructionToConstant| could fold an instruction whose + // result type is |type_inst|. + bool IsFoldableVectorType(Instruction* type_inst) const; + // Tries to fold |inst| to a single constant, when the input ids to |inst| // have been substituted using |id_map|. Returns a pointer to the OpConstant* // instruction if successful. If necessary, a new constant instruction is diff --git a/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp b/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp index 132be0c4b1..ddfe59f752 100644 --- a/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp +++ b/third_party/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp @@ -15,12 +15,9 @@ #include "source/opt/fold_spec_constant_op_and_composite_pass.h" #include -#include #include #include "source/opt/constants.h" -#include "source/opt/fold.h" -#include "source/opt/ir_context.h" #include "source/util/make_unique.h" namespace spvtools { @@ -118,20 +115,9 @@ bool FoldSpecConstantOpAndCompositePass::ProcessOpSpecConstantOp( "The first in-operand of OpSpecConstantOp instruction must be of " "SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER type"); - switch (static_cast(inst->GetSingleWordInOperand(0))) { - case spv::Op::OpCompositeExtract: - case spv::Op::OpVectorShuffle: - case spv::Op::OpCompositeInsert: - case spv::Op::OpQuantizeToF16: - folded_inst = FoldWithInstructionFolder(pos); - break; - default: - // TODO: This should use the instruction folder as well, but some folding - // rules are missing. - - // Component-wise operations. - folded_inst = DoComponentWiseOperation(pos); - break; + folded_inst = FoldWithInstructionFolder(pos); + if (!folded_inst) { + folded_inst = DoComponentWiseOperation(pos); } if (!folded_inst) return false; @@ -179,8 +165,9 @@ Instruction* FoldSpecConstantOpAndCompositePass::FoldWithInstructionFolder( Instruction* new_const_inst = context()->get_instruction_folder().FoldInstructionToConstant( inst.get(), identity_map); - assert(new_const_inst != nullptr && - "Failed to fold instruction that must be folded."); + + // new_const_inst == null indicates we cannot fold this spec constant + if (!new_const_inst) return nullptr; // Get the instruction before |pos| to insert after. |pos| cannot be the // first instruction in the list because its type has to come first. @@ -260,18 +247,7 @@ utils::SmallVector EncodeIntegerAsWords(const analysis::Type& type, // Truncate first_word if the |type| has width less than uint32. if (bit_width < bits_per_word) { - const uint32_t num_high_bits_to_mask = bits_per_word - bit_width; - const bool is_negative_after_truncation = - result_type_signed && - utils::IsBitAtPositionSet(first_word, bit_width - 1); - - if (is_negative_after_truncation) { - // Truncate and sign-extend |first_word|. No padding words will be - // added and |pad_value| can be left as-is. - first_word = utils::SetHighBits(first_word, num_high_bits_to_mask); - } else { - first_word = utils::ClearHighBits(first_word, num_high_bits_to_mask); - } + first_word = utils::SignExtendValue(first_word, bit_width); } utils::SmallVector words = {first_word}; diff --git a/third_party/spirv-tools/source/opt/folding_rules.cpp b/third_party/spirv-tools/source/opt/folding_rules.cpp index 1a4c03d7e3..e5ac2a1cb2 100644 --- a/third_party/spirv-tools/source/opt/folding_rules.cpp +++ b/third_party/spirv-tools/source/opt/folding_rules.cpp @@ -14,7 +14,6 @@ #include "source/opt/folding_rules.h" -#include #include #include #include @@ -78,7 +77,10 @@ int32_t ImageOperandsMaskInOperandIndex(Instruction* inst) { // Returns the element width of |type|. uint32_t ElementWidth(const analysis::Type* type) { - if (const analysis::Vector* vec_type = type->AsVector()) { + if (const analysis::CooperativeVectorNV* coopvec_type = + type->AsCooperativeVectorNV()) { + return ElementWidth(coopvec_type->component_type()); + } else if (const analysis::Vector* vec_type = type->AsVector()) { return ElementWidth(vec_type->element_type()); } else if (const analysis::Float* float_type = type->AsFloat()) { return float_type->width(); @@ -113,6 +115,12 @@ bool IsValidResult(T val) { } } +// Returns true if `type` is a cooperative matrix. +bool IsCooperativeMatrix(const analysis::Type* type) { + return type->kind() == analysis::Type::kCooperativeMatrixKHR || + type->kind() == analysis::Type::kCooperativeMatrixNV; +} + const analysis::Constant* ConstInput( const std::vector& constants) { return constants[0] ? constants[0] : constants[1]; @@ -181,8 +189,14 @@ std::vector GetWordsFromNumericScalarOrVectorConstant( const analysis::Constant* ConvertWordsToNumericScalarOrVectorConstant( analysis::ConstantManager* const_mgr, const std::vector& words, const analysis::Type* type) { - if (type->AsInteger() || type->AsFloat()) - return const_mgr->GetConstant(type, words); + const spvtools::opt::analysis::Integer* int_type = type->AsInteger(); + + if (int_type && int_type->width() <= 32) { + assert(words.size() == 1); + return const_mgr->GenerateIntegerConstant(int_type, words[0]); + } + + if (int_type || type->AsFloat()) return const_mgr->GetConstant(type, words); if (const auto* vec_type = type->AsVector()) return const_mgr->GetNumericVectorConstantWithWords(vec_type, words); return nullptr; @@ -308,6 +322,11 @@ FoldingRule ReciprocalFDiv() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (!inst->IsFloatingPointFoldingAllowed()) return false; uint32_t width = ElementWidth(type); @@ -389,6 +408,11 @@ FoldingRule MergeNegateMulDivArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (HasFloatingPoint(type) && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -401,36 +425,37 @@ FoldingRule MergeNegateMulDivArithmetic() { if (width != 32 && width != 64) return false; spv::Op opcode = op_inst->opcode(); - if (opcode == spv::Op::OpFMul || opcode == spv::Op::OpFDiv || - opcode == spv::Op::OpIMul || opcode == spv::Op::OpSDiv || - opcode == spv::Op::OpUDiv) { - std::vector op_constants = - const_mgr->GetOperandConstants(op_inst); - // Merge negate into mul or div if one operand is constant. - if (op_constants[0] || op_constants[1]) { - bool zero_is_variable = op_constants[0] == nullptr; - const analysis::Constant* c = ConstInput(op_constants); - uint32_t neg_id = NegateConstant(const_mgr, c); - uint32_t non_const_id = zero_is_variable - ? op_inst->GetSingleWordInOperand(0u) - : op_inst->GetSingleWordInOperand(1u); - // Change this instruction to a mul/div. - inst->SetOpcode(op_inst->opcode()); - if (opcode == spv::Op::OpFDiv || opcode == spv::Op::OpUDiv || - opcode == spv::Op::OpSDiv) { - uint32_t op0 = zero_is_variable ? non_const_id : neg_id; - uint32_t op1 = zero_is_variable ? neg_id : non_const_id; - inst->SetInOperands( - {{SPV_OPERAND_TYPE_ID, {op0}}, {SPV_OPERAND_TYPE_ID, {op1}}}); - } else { - inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {non_const_id}}, - {SPV_OPERAND_TYPE_ID, {neg_id}}}); - } - return true; - } + if (opcode != spv::Op::OpFMul && opcode != spv::Op::OpFDiv && + opcode != spv::Op::OpIMul && opcode != spv::Op::OpSDiv) { + return false; } - return false; + std::vector op_constants = + const_mgr->GetOperandConstants(op_inst); + // Merge negate into mul or div if one operand is constant. + if (op_constants[0] == nullptr && op_constants[1] == nullptr) { + return false; + } + + bool zero_is_variable = op_constants[0] == nullptr; + const analysis::Constant* c = ConstInput(op_constants); + uint32_t neg_id = NegateConstant(const_mgr, c); + uint32_t non_const_id = zero_is_variable + ? op_inst->GetSingleWordInOperand(0u) + : op_inst->GetSingleWordInOperand(1u); + // Change this instruction to a mul/div. + inst->SetOpcode(op_inst->opcode()); + if (opcode == spv::Op::OpFDiv || opcode == spv::Op::OpUDiv || + opcode == spv::Op::OpSDiv) { + uint32_t op0 = zero_is_variable ? non_const_id : neg_id; + uint32_t op1 = zero_is_variable ? neg_id : non_const_id; + inst->SetInOperands( + {{SPV_OPERAND_TYPE_ID, {op0}}, {SPV_OPERAND_TYPE_ID, {op1}}}); + } else { + inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {non_const_id}}, + {SPV_OPERAND_TYPE_ID, {neg_id}}}); + } + return true; }; } @@ -450,6 +475,11 @@ FoldingRule MergeNegateAddSubArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (HasFloatingPoint(type) && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -681,6 +711,11 @@ FoldingRule MergeMulMulArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (HasFloatingPoint(type) && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -735,6 +770,11 @@ FoldingRule MergeMulDivArithmetic() { const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (!inst->IsFloatingPointFoldingAllowed()) return false; uint32_t width = ElementWidth(type); @@ -808,6 +848,11 @@ FoldingRule MergeMulNegateArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -848,6 +893,11 @@ FoldingRule MergeDivDivArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (!inst->IsFloatingPointFoldingAllowed()) return false; uint32_t width = ElementWidth(type); @@ -921,6 +971,11 @@ FoldingRule MergeDivMulArithmetic() { const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + if (!inst->IsFloatingPointFoldingAllowed()) return false; uint32_t width = ElementWidth(type); @@ -1063,6 +1118,11 @@ FoldingRule MergeSubNegateArithmetic() { analysis::ConstantManager* const_mgr = context->get_constant_mgr(); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1111,6 +1171,11 @@ FoldingRule MergeAddAddArithmetic() { inst->opcode() == spv::Op::OpIAdd); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1159,6 +1224,11 @@ FoldingRule MergeAddSubArithmetic() { inst->opcode() == spv::Op::OpIAdd); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1219,6 +1289,11 @@ FoldingRule MergeSubAddArithmetic() { inst->opcode() == spv::Op::OpISub); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1285,6 +1360,11 @@ FoldingRule MergeSubSubArithmetic() { inst->opcode() == spv::Op::OpISub); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1378,6 +1458,11 @@ FoldingRule MergeGenericAddSubArithmetic() { inst->opcode() == spv::Op::OpIAdd); const analysis::Type* type = context->get_type_mgr()->GetType(inst->type_id()); + + if (IsCooperativeMatrix(type)) { + return false; + } + bool uses_float = HasFloatingPoint(type); if (uses_float && !inst->IsFloatingPointFoldingAllowed()) return false; @@ -1460,132 +1545,6 @@ FoldingRule FactorAddMuls() { }; } -// Replaces |inst| inplace with an FMA instruction |(x*y)+a|. -void ReplaceWithFma(Instruction* inst, uint32_t x, uint32_t y, uint32_t a) { - uint32_t ext = - inst->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); - - if (ext == 0) { - inst->context()->AddExtInstImport("GLSL.std.450"); - ext = inst->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); - assert(ext != 0 && - "Could not add the GLSL.std.450 extended instruction set"); - } - - std::vector operands; - operands.push_back({SPV_OPERAND_TYPE_ID, {ext}}); - operands.push_back({SPV_OPERAND_TYPE_LITERAL_INTEGER, {GLSLstd450Fma}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {x}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {y}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {a}}); - - inst->SetOpcode(spv::Op::OpExtInst); - inst->SetInOperands(std::move(operands)); -} - -// Folds a multiple and add into an Fma. -// -// Cases: -// (x * y) + a = Fma x y a -// a + (x * y) = Fma x y a -bool MergeMulAddArithmetic(IRContext* context, Instruction* inst, - const std::vector&) { - assert(inst->opcode() == spv::Op::OpFAdd); - - if (!inst->IsFloatingPointFoldingAllowed()) { - return false; - } - - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - for (int i = 0; i < 2; i++) { - uint32_t op_id = inst->GetSingleWordInOperand(i); - Instruction* op_inst = def_use_mgr->GetDef(op_id); - - if (op_inst->opcode() != spv::Op::OpFMul) { - continue; - } - - if (!op_inst->IsFloatingPointFoldingAllowed()) { - continue; - } - - uint32_t x = op_inst->GetSingleWordInOperand(0); - uint32_t y = op_inst->GetSingleWordInOperand(1); - uint32_t a = inst->GetSingleWordInOperand((i + 1) % 2); - ReplaceWithFma(inst, x, y, a); - return true; - } - return false; -} - -// Replaces |sub| inplace with an FMA instruction |(x*y)+a| where |a| first gets -// negated if |negate_addition| is true, otherwise |x| gets negated. -void ReplaceWithFmaAndNegate(Instruction* sub, uint32_t x, uint32_t y, - uint32_t a, bool negate_addition) { - uint32_t ext = - sub->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); - - if (ext == 0) { - sub->context()->AddExtInstImport("GLSL.std.450"); - ext = sub->context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450(); - assert(ext != 0 && - "Could not add the GLSL.std.450 extended instruction set"); - } - - InstructionBuilder ir_builder( - sub->context(), sub, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - - Instruction* neg = ir_builder.AddUnaryOp(sub->type_id(), spv::Op::OpFNegate, - negate_addition ? a : x); - uint32_t neg_op = neg->result_id(); // -a : -x - - std::vector operands; - operands.push_back({SPV_OPERAND_TYPE_ID, {ext}}); - operands.push_back({SPV_OPERAND_TYPE_LITERAL_INTEGER, {GLSLstd450Fma}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {negate_addition ? x : neg_op}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {y}}); - operands.push_back({SPV_OPERAND_TYPE_ID, {negate_addition ? neg_op : a}}); - - sub->SetOpcode(spv::Op::OpExtInst); - sub->SetInOperands(std::move(operands)); -} - -// Folds a multiply and subtract into an Fma and negation. -// -// Cases: -// (x * y) - a = Fma x y -a -// a - (x * y) = Fma -x y a -bool MergeMulSubArithmetic(IRContext* context, Instruction* sub, - const std::vector&) { - assert(sub->opcode() == spv::Op::OpFSub); - - if (!sub->IsFloatingPointFoldingAllowed()) { - return false; - } - - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - for (int i = 0; i < 2; i++) { - uint32_t op_id = sub->GetSingleWordInOperand(i); - Instruction* mul = def_use_mgr->GetDef(op_id); - - if (mul->opcode() != spv::Op::OpFMul) { - continue; - } - - if (!mul->IsFloatingPointFoldingAllowed()) { - continue; - } - - uint32_t x = mul->GetSingleWordInOperand(0); - uint32_t y = mul->GetSingleWordInOperand(1); - uint32_t a = sub->GetSingleWordInOperand((i + 1) % 2); - ReplaceWithFmaAndNegate(sub, x, y, a, i == 0); - return true; - } - return false; -} - FoldingRule IntMultipleBy1() { return [](IRContext*, Instruction* inst, const std::vector& constants) { @@ -1656,8 +1615,11 @@ std::vector GetExtractOperandsForElementOfCompositeConstruct( analysis::Type* result_type = type_mgr->GetType(inst->type_id()); if (result_type->AsVector() == nullptr) { - uint32_t id = inst->GetSingleWordInOperand(result_index); - return {Operand(SPV_OPERAND_TYPE_ID, {id})}; + if (result_index < inst->NumInOperands()) { + uint32_t id = inst->GetSingleWordInOperand(result_index); + return {Operand(SPV_OPERAND_TYPE_ID, {id})}; + } + return {}; } // If the result type is a vector, then vector operands are concatenated. @@ -1731,27 +1693,26 @@ bool CompositeConstructFeedingExtract( } // Walks the indexes chain from |start| to |end| of an OpCompositeInsert or -// OpCompositeExtract instruction, and returns the type of the final element -// being accessed. -const analysis::Type* GetElementType(uint32_t type_id, - Instruction::iterator start, - Instruction::iterator end, - const analysis::TypeManager* type_mgr) { - const analysis::Type* type = type_mgr->GetType(type_id); +// OpCompositeExtract instruction, and returns the type id of the final element +// being accessed. Returns 0 if a valid type could not be found. +uint32_t GetElementType(uint32_t type_id, Instruction::iterator start, + Instruction::iterator end, + const analysis::DefUseManager* def_use_manager) { for (auto index : make_range(std::move(start), std::move(end))) { + const Instruction* type_inst = def_use_manager->GetDef(type_id); assert(index.type == SPV_OPERAND_TYPE_LITERAL_INTEGER && index.words.size() == 1); - if (auto* array_type = type->AsArray()) { - type = array_type->element_type(); - } else if (auto* matrix_type = type->AsMatrix()) { - type = matrix_type->element_type(); - } else if (auto* struct_type = type->AsStruct()) { - type = struct_type->element_types()[index.words[0]]; + if (type_inst->opcode() == spv::Op::OpTypeArray) { + type_id = type_inst->GetSingleWordInOperand(0); + } else if (type_inst->opcode() == spv::Op::OpTypeMatrix) { + type_id = type_inst->GetSingleWordInOperand(0); + } else if (type_inst->opcode() == spv::Op::OpTypeStruct) { + type_id = type_inst->GetSingleWordInOperand(index.words[0]); } else { - type = nullptr; + return 0; } } - return type; + return type_id; } // Returns true of |inst_1| and |inst_2| have the same indexes that will be used @@ -1832,20 +1793,16 @@ bool CompositeExtractFeedingConstruct( return false; } } + assert(first_element_inst != nullptr); // The last check it to see that the object being extracted from is the // correct type. Instruction* original_inst = def_use_mgr->GetDef(original_id); - analysis::TypeManager* type_mgr = context->get_type_mgr(); - const analysis::Type* original_type = + uint32_t original_type_id = GetElementType(original_inst->type_id(), first_element_inst->begin() + 3, - first_element_inst->end() - 1, type_mgr); + first_element_inst->end() - 1, def_use_mgr); - if (original_type == nullptr) { - return false; - } - - if (inst->type_id() != type_mgr->GetId(original_type)) { + if (inst->type_id() != original_type_id) { return false; } @@ -2065,7 +2022,8 @@ FoldingRule FMixFeedingExtract() { } // Returns the number of elements in the composite type |type|. Returns 0 if -// |type| is a scalar value. +// |type| is a scalar value. Return UINT32_MAX when the size is unknown at +// compile time. uint32_t GetNumberOfElements(const analysis::Type* type) { if (auto* vector_type = type->AsVector()) { return vector_type->element_count(); @@ -2077,21 +2035,27 @@ uint32_t GetNumberOfElements(const analysis::Type* type) { return static_cast(struct_type->element_types().size()); } if (auto* array_type = type->AsArray()) { - return array_type->length_info().words[0]; + if (array_type->length_info().words[0] == + analysis::Array::LengthInfo::kConstant && + array_type->length_info().words.size() == 2) { + return array_type->length_info().words[1]; + } + return UINT32_MAX; } return 0; } // Returns a map with the set of values that were inserted into an object by // the chain of OpCompositeInsertInstruction starting with |inst|. -// The map will map the index to the value inserted at that index. +// The map will map the index to the value inserted at that index. An empty map +// will be returned if the map could not be properly generated. std::map GetInsertedValues(Instruction* inst) { analysis::DefUseManager* def_use_mgr = inst->context()->get_def_use_mgr(); std::map values_inserted; Instruction* current_inst = inst; while (current_inst->opcode() == spv::Op::OpCompositeInsert) { if (current_inst->NumInOperands() > inst->NumInOperands()) { - // This is the catch the case + // This is to catch the case // %2 = OpCompositeInsert %m2x2int %v2int_1_0 %m2x2int_undef 0 // %3 = OpCompositeInsert %m2x2int %int_4 %2 0 0 // %4 = OpCompositeInsert %m2x2int %v2int_2_3 %3 1 @@ -2128,13 +2092,15 @@ bool DoInsertedValuesCoverEntireObject( return true; } -// Returns the type of the element that immediately contains the element being -// inserted by the OpCompositeInsert instruction |inst|. -const analysis::Type* GetContainerType(Instruction* inst) { +// Returns id of the type of the element that immediately contains the element +// being inserted by the OpCompositeInsert instruction |inst|. Returns 0 if it +// could not be found. +uint32_t GetContainerTypeId(Instruction* inst) { assert(inst->opcode() == spv::Op::OpCompositeInsert); - analysis::TypeManager* type_mgr = inst->context()->get_type_mgr(); - return GetElementType(inst->type_id(), inst->begin() + 4, inst->end() - 1, - type_mgr); + analysis::DefUseManager* def_use_manager = inst->context()->get_def_use_mgr(); + uint32_t container_type_id = GetElementType( + inst->type_id(), inst->begin() + 4, inst->end() - 1, def_use_manager); + return container_type_id; } // Returns an OpCompositeConstruct instruction that build an object with @@ -2181,18 +2147,20 @@ bool CompositeInsertToCompositeConstruct( if (inst->NumInOperands() < 3) return false; std::map values_inserted = GetInsertedValues(inst); - const analysis::Type* container_type = GetContainerType(inst); - if (container_type == nullptr) { - return false; - } - - if (!DoInsertedValuesCoverEntireObject(container_type, values_inserted)) { + uint32_t container_type_id = GetContainerTypeId(inst); + if (container_type_id == 0) { return false; } analysis::TypeManager* type_mgr = context->get_type_mgr(); - Instruction* construct = BuildCompositeConstruct( - type_mgr->GetId(container_type), values_inserted, inst); + const analysis::Type* container_type = type_mgr->GetType(container_type_id); + assert(container_type && "GetContainerTypeId returned a bad id."); + if (!DoInsertedValuesCoverEntireObject(container_type, values_inserted)) { + return false; + } + + Instruction* construct = + BuildCompositeConstruct(container_type_id, values_inserted, inst); InsertConstructedObject(inst, construct); return true; } @@ -2882,8 +2850,12 @@ FoldingRule UpdateImageOperands() { "Offset and ConstOffset may not be used together"); if (offset_operand_index < inst->NumOperands()) { if (constants[offset_operand_index]) { - image_operands = - image_operands | uint32_t(spv::ImageOperandsMask::ConstOffset); + if (constants[offset_operand_index]->IsZero()) { + inst->RemoveInOperand(offset_operand_index); + } else { + image_operands = image_operands | + uint32_t(spv::ImageOperandsMask::ConstOffset); + } image_operands = image_operands & ~uint32_t(spv::ImageOperandsMask::Offset); inst->SetInOperand(operand_index, {image_operands}); @@ -2928,7 +2900,6 @@ void FoldingRules::AddFoldingRules() { rules_[spv::Op::OpFAdd].push_back(MergeAddSubArithmetic()); rules_[spv::Op::OpFAdd].push_back(MergeGenericAddSubArithmetic()); rules_[spv::Op::OpFAdd].push_back(FactorAddMuls()); - rules_[spv::Op::OpFAdd].push_back(MergeMulAddArithmetic); rules_[spv::Op::OpFDiv].push_back(RedundantFDiv()); rules_[spv::Op::OpFDiv].push_back(ReciprocalFDiv()); @@ -2949,7 +2920,6 @@ void FoldingRules::AddFoldingRules() { rules_[spv::Op::OpFSub].push_back(MergeSubNegateArithmetic()); rules_[spv::Op::OpFSub].push_back(MergeSubAddArithmetic()); rules_[spv::Op::OpFSub].push_back(MergeSubSubArithmetic()); - rules_[spv::Op::OpFSub].push_back(MergeMulSubArithmetic); rules_[spv::Op::OpIAdd].push_back(RedundantIAdd()); rules_[spv::Op::OpIAdd].push_back(MergeAddNegateArithmetic()); diff --git a/third_party/spirv-tools/source/opt/function.cpp b/third_party/spirv-tools/source/opt/function.cpp index 6c7c949fd3..2ee88eca8e 100644 --- a/third_party/spirv-tools/source/opt/function.cpp +++ b/third_party/spirv-tools/source/opt/function.cpp @@ -15,9 +15,7 @@ #include "source/opt/function.h" #include -#include -#include "function.h" #include "ir_context.h" #include "source/util/bit_vector.h" diff --git a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp index da2764fc83..e765c39760 100644 --- a/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp +++ b/third_party/spirv-tools/source/opt/graphics_robust_access_pass.cpp @@ -141,18 +141,12 @@ #include "graphics_robust_access_pass.h" -#include -#include #include #include -#include #include -#include "constants.h" -#include "def_use_manager.h" #include "function.h" #include "ir_context.h" -#include "module.h" #include "pass.h" #include "source/diagnostic.h" #include "source/util/make_unique.h" @@ -579,9 +573,9 @@ uint32_t GraphicsRobustAccessPass::GetGlslInsts() { context()->module()->AddExtInstImport(std::move(import_inst)); module_status_.modified = true; context()->AnalyzeDefUse(inst); - // Reanalyze the feature list, since we added an extended instruction - // set improt. - context()->get_feature_mgr()->Analyze(context()->module()); + // Invalidates the feature manager, since we added an extended instruction + // set import. + context()->ResetFeatureManager(); } } return module_status_.glsl_insts_id; diff --git a/third_party/spirv-tools/source/opt/inline_pass.cpp b/third_party/spirv-tools/source/opt/inline_pass.cpp index 3f160b24cd..318643341a 100644 --- a/third_party/spirv-tools/source/opt/inline_pass.cpp +++ b/third_party/spirv-tools/source/opt/inline_pass.cpp @@ -213,6 +213,19 @@ uint32_t InlinePass::CreateReturnVar( {(uint32_t)spv::StorageClass::Function}}})); new_vars->push_back(std::move(var_inst)); get_decoration_mgr()->CloneDecorations(calleeFn->result_id(), returnVarId); + + // Decorate the return var with AliasedPointer if the storage class of the + // pointee type is PhysicalStorageBuffer. + auto const pointee_type = + type_mgr->GetType(returnVarTypeId)->AsPointer()->pointee_type(); + if (pointee_type->AsPointer() != nullptr) { + if (pointee_type->AsPointer()->storage_class() == + spv::StorageClass::PhysicalStorageBuffer) { + get_decoration_mgr()->AddDecoration( + returnVarId, uint32_t(spv::Decoration::AliasedPointer)); + } + } + return returnVarId; } diff --git a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp deleted file mode 100644 index ca36dd6062..0000000000 --- a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.cpp +++ /dev/null @@ -1,845 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// Copyright (c) 2018 Valve Corporation -// Copyright (c) 2018 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "inst_bindless_check_pass.h" - -namespace spvtools { -namespace opt { -namespace { -// Input Operand Indices -constexpr int kSpvImageSampleImageIdInIdx = 0; -constexpr int kSpvSampledImageImageIdInIdx = 0; -constexpr int kSpvSampledImageSamplerIdInIdx = 1; -constexpr int kSpvImageSampledImageIdInIdx = 0; -constexpr int kSpvCopyObjectOperandIdInIdx = 0; -constexpr int kSpvLoadPtrIdInIdx = 0; -constexpr int kSpvAccessChainBaseIdInIdx = 0; -constexpr int kSpvAccessChainIndex0IdInIdx = 1; -constexpr int kSpvTypeArrayTypeIdInIdx = 0; -constexpr int kSpvTypeArrayLengthIdInIdx = 1; -constexpr int kSpvConstantValueInIdx = 0; -constexpr int kSpvVariableStorageClassInIdx = 0; -constexpr int kSpvTypePtrTypeIdInIdx = 1; -constexpr int kSpvTypeImageDim = 1; -constexpr int kSpvTypeImageDepth = 2; -constexpr int kSpvTypeImageArrayed = 3; -constexpr int kSpvTypeImageMS = 4; -constexpr int kSpvTypeImageSampled = 5; -} // namespace - -uint32_t InstBindlessCheckPass::GenDebugReadLength( - uint32_t var_id, InstructionBuilder* builder) { - uint32_t desc_set_idx = - var2desc_set_[var_id] + kDebugInputBindlessOffsetLengths; - uint32_t desc_set_idx_id = builder->GetUintConstantId(desc_set_idx); - uint32_t binding_idx_id = builder->GetUintConstantId(var2binding_[var_id]); - return GenDebugDirectRead({desc_set_idx_id, binding_idx_id}, builder); -} - -uint32_t InstBindlessCheckPass::GenDebugReadInit(uint32_t var_id, - uint32_t desc_idx_id, - InstructionBuilder* builder) { - uint32_t binding_idx_id = builder->GetUintConstantId(var2binding_[var_id]); - uint32_t u_desc_idx_id = GenUintCastCode(desc_idx_id, builder); - // If desc index checking is not enabled, we know the offset of initialization - // entries is 1, so we can avoid loading this value and just add 1 to the - // descriptor set. - if (!desc_idx_enabled_) { - uint32_t desc_set_idx_id = - builder->GetUintConstantId(var2desc_set_[var_id] + 1); - return GenDebugDirectRead({desc_set_idx_id, binding_idx_id, u_desc_idx_id}, - builder); - } else { - uint32_t desc_set_base_id = - builder->GetUintConstantId(kDebugInputBindlessInitOffset); - uint32_t desc_set_idx_id = - builder->GetUintConstantId(var2desc_set_[var_id]); - return GenDebugDirectRead( - {desc_set_base_id, desc_set_idx_id, binding_idx_id, u_desc_idx_id}, - builder); - } -} - -uint32_t InstBindlessCheckPass::CloneOriginalImage( - uint32_t old_image_id, InstructionBuilder* builder) { - Instruction* new_image_inst; - Instruction* old_image_inst = get_def_use_mgr()->GetDef(old_image_id); - if (old_image_inst->opcode() == spv::Op::OpLoad) { - new_image_inst = builder->AddLoad( - old_image_inst->type_id(), - old_image_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx)); - } else if (old_image_inst->opcode() == spv::Op::OpSampledImage) { - uint32_t clone_id = CloneOriginalImage( - old_image_inst->GetSingleWordInOperand(kSpvSampledImageImageIdInIdx), - builder); - new_image_inst = builder->AddBinaryOp( - old_image_inst->type_id(), spv::Op::OpSampledImage, clone_id, - old_image_inst->GetSingleWordInOperand(kSpvSampledImageSamplerIdInIdx)); - } else if (old_image_inst->opcode() == spv::Op::OpImage) { - uint32_t clone_id = CloneOriginalImage( - old_image_inst->GetSingleWordInOperand(kSpvImageSampledImageIdInIdx), - builder); - new_image_inst = builder->AddUnaryOp(old_image_inst->type_id(), - spv::Op::OpImage, clone_id); - } else { - assert(old_image_inst->opcode() == spv::Op::OpCopyObject && - "expecting OpCopyObject"); - uint32_t clone_id = CloneOriginalImage( - old_image_inst->GetSingleWordInOperand(kSpvCopyObjectOperandIdInIdx), - builder); - // Since we are cloning, no need to create new copy - new_image_inst = get_def_use_mgr()->GetDef(clone_id); - } - uid2offset_[new_image_inst->unique_id()] = - uid2offset_[old_image_inst->unique_id()]; - uint32_t new_image_id = new_image_inst->result_id(); - get_decoration_mgr()->CloneDecorations(old_image_id, new_image_id); - return new_image_id; -} - -uint32_t InstBindlessCheckPass::CloneOriginalReference( - RefAnalysis* ref, InstructionBuilder* builder) { - // If original is image based, start by cloning descriptor load - uint32_t new_image_id = 0; - if (ref->desc_load_id != 0) { - uint32_t old_image_id = - ref->ref_inst->GetSingleWordInOperand(kSpvImageSampleImageIdInIdx); - new_image_id = CloneOriginalImage(old_image_id, builder); - } - // Clone original reference - std::unique_ptr new_ref_inst(ref->ref_inst->Clone(context())); - uint32_t ref_result_id = ref->ref_inst->result_id(); - uint32_t new_ref_id = 0; - if (ref_result_id != 0) { - new_ref_id = TakeNextId(); - new_ref_inst->SetResultId(new_ref_id); - } - // Update new ref with new image if created - if (new_image_id != 0) - new_ref_inst->SetInOperand(kSpvImageSampleImageIdInIdx, {new_image_id}); - // Register new reference and add to new block - Instruction* added_inst = builder->AddInstruction(std::move(new_ref_inst)); - uid2offset_[added_inst->unique_id()] = - uid2offset_[ref->ref_inst->unique_id()]; - if (new_ref_id != 0) - get_decoration_mgr()->CloneDecorations(ref_result_id, new_ref_id); - return new_ref_id; -} - -uint32_t InstBindlessCheckPass::GetImageId(Instruction* inst) { - switch (inst->opcode()) { - case spv::Op::OpImageSampleImplicitLod: - case spv::Op::OpImageSampleExplicitLod: - case spv::Op::OpImageSampleDrefImplicitLod: - case spv::Op::OpImageSampleDrefExplicitLod: - case spv::Op::OpImageSampleProjImplicitLod: - case spv::Op::OpImageSampleProjExplicitLod: - case spv::Op::OpImageSampleProjDrefImplicitLod: - case spv::Op::OpImageSampleProjDrefExplicitLod: - case spv::Op::OpImageGather: - case spv::Op::OpImageDrefGather: - case spv::Op::OpImageQueryLod: - case spv::Op::OpImageSparseSampleImplicitLod: - case spv::Op::OpImageSparseSampleExplicitLod: - case spv::Op::OpImageSparseSampleDrefImplicitLod: - case spv::Op::OpImageSparseSampleDrefExplicitLod: - case spv::Op::OpImageSparseSampleProjImplicitLod: - case spv::Op::OpImageSparseSampleProjExplicitLod: - case spv::Op::OpImageSparseSampleProjDrefImplicitLod: - case spv::Op::OpImageSparseSampleProjDrefExplicitLod: - case spv::Op::OpImageSparseGather: - case spv::Op::OpImageSparseDrefGather: - case spv::Op::OpImageFetch: - case spv::Op::OpImageRead: - case spv::Op::OpImageQueryFormat: - case spv::Op::OpImageQueryOrder: - case spv::Op::OpImageQuerySizeLod: - case spv::Op::OpImageQuerySize: - case spv::Op::OpImageQueryLevels: - case spv::Op::OpImageQuerySamples: - case spv::Op::OpImageSparseFetch: - case spv::Op::OpImageSparseRead: - case spv::Op::OpImageWrite: - return inst->GetSingleWordInOperand(kSpvImageSampleImageIdInIdx); - default: - break; - } - return 0; -} - -Instruction* InstBindlessCheckPass::GetPointeeTypeInst(Instruction* ptr_inst) { - uint32_t pte_ty_id = GetPointeeTypeId(ptr_inst); - return get_def_use_mgr()->GetDef(pte_ty_id); -} - -bool InstBindlessCheckPass::AnalyzeDescriptorReference(Instruction* ref_inst, - RefAnalysis* ref) { - ref->ref_inst = ref_inst; - if (ref_inst->opcode() == spv::Op::OpLoad || - ref_inst->opcode() == spv::Op::OpStore) { - ref->desc_load_id = 0; - ref->ptr_id = ref_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx); - Instruction* ptr_inst = get_def_use_mgr()->GetDef(ref->ptr_id); - if (ptr_inst->opcode() != spv::Op::OpAccessChain) return false; - ref->var_id = ptr_inst->GetSingleWordInOperand(kSpvAccessChainBaseIdInIdx); - Instruction* var_inst = get_def_use_mgr()->GetDef(ref->var_id); - if (var_inst->opcode() != spv::Op::OpVariable) return false; - spv::StorageClass storage_class = spv::StorageClass( - var_inst->GetSingleWordInOperand(kSpvVariableStorageClassInIdx)); - switch (storage_class) { - case spv::StorageClass::Uniform: - case spv::StorageClass::StorageBuffer: - break; - default: - return false; - break; - } - // Check for deprecated storage block form - if (storage_class == spv::StorageClass::Uniform) { - uint32_t var_ty_id = var_inst->type_id(); - Instruction* var_ty_inst = get_def_use_mgr()->GetDef(var_ty_id); - uint32_t ptr_ty_id = - var_ty_inst->GetSingleWordInOperand(kSpvTypePtrTypeIdInIdx); - Instruction* ptr_ty_inst = get_def_use_mgr()->GetDef(ptr_ty_id); - spv::Op ptr_ty_op = ptr_ty_inst->opcode(); - uint32_t block_ty_id = - (ptr_ty_op == spv::Op::OpTypeArray || - ptr_ty_op == spv::Op::OpTypeRuntimeArray) - ? ptr_ty_inst->GetSingleWordInOperand(kSpvTypeArrayTypeIdInIdx) - : ptr_ty_id; - assert(get_def_use_mgr()->GetDef(block_ty_id)->opcode() == - spv::Op::OpTypeStruct && - "unexpected block type"); - bool block_found = get_decoration_mgr()->FindDecoration( - block_ty_id, uint32_t(spv::Decoration::Block), - [](const Instruction&) { return true; }); - if (!block_found) { - // If block decoration not found, verify deprecated form of SSBO - bool buffer_block_found = get_decoration_mgr()->FindDecoration( - block_ty_id, uint32_t(spv::Decoration::BufferBlock), - [](const Instruction&) { return true; }); - USE_ASSERT(buffer_block_found && "block decoration not found"); - storage_class = spv::StorageClass::StorageBuffer; - } - } - ref->strg_class = uint32_t(storage_class); - Instruction* desc_type_inst = GetPointeeTypeInst(var_inst); - switch (desc_type_inst->opcode()) { - case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: - // A load through a descriptor array will have at least 3 operands. We - // do not want to instrument loads of descriptors here which are part of - // an image-based reference. - if (ptr_inst->NumInOperands() < 3) return false; - ref->desc_idx_id = - ptr_inst->GetSingleWordInOperand(kSpvAccessChainIndex0IdInIdx); - break; - default: - ref->desc_idx_id = 0; - break; - } - return true; - } - // Reference is not load or store. If not an image-based reference, return. - ref->image_id = GetImageId(ref_inst); - if (ref->image_id == 0) return false; - // Search for descriptor load - uint32_t desc_load_id = ref->image_id; - Instruction* desc_load_inst; - for (;;) { - desc_load_inst = get_def_use_mgr()->GetDef(desc_load_id); - if (desc_load_inst->opcode() == spv::Op::OpSampledImage) - desc_load_id = - desc_load_inst->GetSingleWordInOperand(kSpvSampledImageImageIdInIdx); - else if (desc_load_inst->opcode() == spv::Op::OpImage) - desc_load_id = - desc_load_inst->GetSingleWordInOperand(kSpvImageSampledImageIdInIdx); - else if (desc_load_inst->opcode() == spv::Op::OpCopyObject) - desc_load_id = - desc_load_inst->GetSingleWordInOperand(kSpvCopyObjectOperandIdInIdx); - else - break; - } - if (desc_load_inst->opcode() != spv::Op::OpLoad) { - // TODO(greg-lunarg): Handle additional possibilities? - return false; - } - ref->desc_load_id = desc_load_id; - ref->ptr_id = desc_load_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx); - Instruction* ptr_inst = get_def_use_mgr()->GetDef(ref->ptr_id); - if (ptr_inst->opcode() == spv::Op::OpVariable) { - ref->desc_idx_id = 0; - ref->var_id = ref->ptr_id; - } else if (ptr_inst->opcode() == spv::Op::OpAccessChain) { - if (ptr_inst->NumInOperands() != 2) { - assert(false && "unexpected bindless index number"); - return false; - } - ref->desc_idx_id = - ptr_inst->GetSingleWordInOperand(kSpvAccessChainIndex0IdInIdx); - ref->var_id = ptr_inst->GetSingleWordInOperand(kSpvAccessChainBaseIdInIdx); - Instruction* var_inst = get_def_use_mgr()->GetDef(ref->var_id); - if (var_inst->opcode() != spv::Op::OpVariable) { - assert(false && "unexpected bindless base"); - return false; - } - } else { - // TODO(greg-lunarg): Handle additional possibilities? - return false; - } - return true; -} - -uint32_t InstBindlessCheckPass::FindStride(uint32_t ty_id, - uint32_t stride_deco) { - uint32_t stride = 0xdeadbeef; - bool found = get_decoration_mgr()->FindDecoration( - ty_id, stride_deco, [&stride](const Instruction& deco_inst) { - stride = deco_inst.GetSingleWordInOperand(2u); - return true; - }); - USE_ASSERT(found && "stride not found"); - return stride; -} - -uint32_t InstBindlessCheckPass::ByteSize(uint32_t ty_id, uint32_t matrix_stride, - bool col_major, bool in_matrix) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - const analysis::Type* sz_ty = type_mgr->GetType(ty_id); - if (sz_ty->kind() == analysis::Type::kPointer) { - // Assuming PhysicalStorageBuffer pointer - return 8; - } - if (sz_ty->kind() == analysis::Type::kMatrix) { - assert(matrix_stride != 0 && "missing matrix stride"); - const analysis::Matrix* m_ty = sz_ty->AsMatrix(); - if (col_major) { - return m_ty->element_count() * matrix_stride; - } else { - const analysis::Vector* v_ty = m_ty->element_type()->AsVector(); - return v_ty->element_count() * matrix_stride; - } - } - uint32_t size = 1; - if (sz_ty->kind() == analysis::Type::kVector) { - const analysis::Vector* v_ty = sz_ty->AsVector(); - size = v_ty->element_count(); - const analysis::Type* comp_ty = v_ty->element_type(); - // if vector in row major matrix, the vector is strided so return the - // number of bytes spanned by the vector - if (in_matrix && !col_major && matrix_stride > 0) { - uint32_t comp_ty_id = type_mgr->GetId(comp_ty); - return (size - 1) * matrix_stride + ByteSize(comp_ty_id, 0, false, false); - } - sz_ty = comp_ty; - } - switch (sz_ty->kind()) { - case analysis::Type::kFloat: { - const analysis::Float* f_ty = sz_ty->AsFloat(); - size *= f_ty->width(); - } break; - case analysis::Type::kInteger: { - const analysis::Integer* i_ty = sz_ty->AsInteger(); - size *= i_ty->width(); - } break; - default: { assert(false && "unexpected type"); } break; - } - size /= 8; - return size; -} - -uint32_t InstBindlessCheckPass::GenLastByteIdx(RefAnalysis* ref, - InstructionBuilder* builder) { - // Find outermost buffer type and its access chain index - Instruction* var_inst = get_def_use_mgr()->GetDef(ref->var_id); - Instruction* desc_ty_inst = GetPointeeTypeInst(var_inst); - uint32_t buff_ty_id; - uint32_t ac_in_idx = 1; - switch (desc_ty_inst->opcode()) { - case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: - buff_ty_id = desc_ty_inst->GetSingleWordInOperand(0); - ++ac_in_idx; - break; - default: - assert(desc_ty_inst->opcode() == spv::Op::OpTypeStruct && - "unexpected descriptor type"); - buff_ty_id = desc_ty_inst->result_id(); - break; - } - // Process remaining access chain indices - Instruction* ac_inst = get_def_use_mgr()->GetDef(ref->ptr_id); - uint32_t curr_ty_id = buff_ty_id; - uint32_t sum_id = 0u; - uint32_t matrix_stride = 0u; - bool col_major = false; - uint32_t matrix_stride_id = 0u; - bool in_matrix = false; - while (ac_in_idx < ac_inst->NumInOperands()) { - uint32_t curr_idx_id = ac_inst->GetSingleWordInOperand(ac_in_idx); - Instruction* curr_ty_inst = get_def_use_mgr()->GetDef(curr_ty_id); - uint32_t curr_offset_id = 0; - switch (curr_ty_inst->opcode()) { - case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: { - // Get array stride and multiply by current index - uint32_t arr_stride = - FindStride(curr_ty_id, uint32_t(spv::Decoration::ArrayStride)); - uint32_t arr_stride_id = builder->GetUintConstantId(arr_stride); - uint32_t curr_idx_32b_id = Gen32BitCvtCode(curr_idx_id, builder); - Instruction* curr_offset_inst = builder->AddBinaryOp( - GetUintId(), spv::Op::OpIMul, arr_stride_id, curr_idx_32b_id); - curr_offset_id = curr_offset_inst->result_id(); - // Get element type for next step - curr_ty_id = curr_ty_inst->GetSingleWordInOperand(0); - } break; - case spv::Op::OpTypeMatrix: { - assert(matrix_stride != 0 && "missing matrix stride"); - matrix_stride_id = builder->GetUintConstantId(matrix_stride); - uint32_t vec_ty_id = curr_ty_inst->GetSingleWordInOperand(0); - // If column major, multiply column index by matrix stride, otherwise - // by vector component size and save matrix stride for vector (row) - // index - uint32_t col_stride_id; - if (col_major) { - col_stride_id = matrix_stride_id; - } else { - Instruction* vec_ty_inst = get_def_use_mgr()->GetDef(vec_ty_id); - uint32_t comp_ty_id = vec_ty_inst->GetSingleWordInOperand(0u); - uint32_t col_stride = ByteSize(comp_ty_id, 0u, false, false); - col_stride_id = builder->GetUintConstantId(col_stride); - } - uint32_t curr_idx_32b_id = Gen32BitCvtCode(curr_idx_id, builder); - Instruction* curr_offset_inst = builder->AddBinaryOp( - GetUintId(), spv::Op::OpIMul, col_stride_id, curr_idx_32b_id); - curr_offset_id = curr_offset_inst->result_id(); - // Get element type for next step - curr_ty_id = vec_ty_id; - in_matrix = true; - } break; - case spv::Op::OpTypeVector: { - // If inside a row major matrix type, multiply index by matrix stride, - // else multiply by component size - uint32_t comp_ty_id = curr_ty_inst->GetSingleWordInOperand(0u); - uint32_t curr_idx_32b_id = Gen32BitCvtCode(curr_idx_id, builder); - if (in_matrix && !col_major) { - Instruction* curr_offset_inst = builder->AddBinaryOp( - GetUintId(), spv::Op::OpIMul, matrix_stride_id, curr_idx_32b_id); - curr_offset_id = curr_offset_inst->result_id(); - } else { - uint32_t comp_ty_sz = ByteSize(comp_ty_id, 0u, false, false); - uint32_t comp_ty_sz_id = builder->GetUintConstantId(comp_ty_sz); - Instruction* curr_offset_inst = builder->AddBinaryOp( - GetUintId(), spv::Op::OpIMul, comp_ty_sz_id, curr_idx_32b_id); - curr_offset_id = curr_offset_inst->result_id(); - } - // Get element type for next step - curr_ty_id = comp_ty_id; - } break; - case spv::Op::OpTypeStruct: { - // Get buffer byte offset for the referenced member - Instruction* curr_idx_inst = get_def_use_mgr()->GetDef(curr_idx_id); - assert(curr_idx_inst->opcode() == spv::Op::OpConstant && - "unexpected struct index"); - uint32_t member_idx = curr_idx_inst->GetSingleWordInOperand(0); - uint32_t member_offset = 0xdeadbeef; - bool found = get_decoration_mgr()->FindDecoration( - curr_ty_id, uint32_t(spv::Decoration::Offset), - [&member_idx, &member_offset](const Instruction& deco_inst) { - if (deco_inst.GetSingleWordInOperand(1u) != member_idx) - return false; - member_offset = deco_inst.GetSingleWordInOperand(3u); - return true; - }); - USE_ASSERT(found && "member offset not found"); - curr_offset_id = builder->GetUintConstantId(member_offset); - // Look for matrix stride for this member if there is one. The matrix - // stride is not on the matrix type, but in a OpMemberDecorate on the - // enclosing struct type at the member index. If none found, reset - // stride to 0. - found = get_decoration_mgr()->FindDecoration( - curr_ty_id, uint32_t(spv::Decoration::MatrixStride), - [&member_idx, &matrix_stride](const Instruction& deco_inst) { - if (deco_inst.GetSingleWordInOperand(1u) != member_idx) - return false; - matrix_stride = deco_inst.GetSingleWordInOperand(3u); - return true; - }); - if (!found) matrix_stride = 0; - // Look for column major decoration - found = get_decoration_mgr()->FindDecoration( - curr_ty_id, uint32_t(spv::Decoration::ColMajor), - [&member_idx, &col_major](const Instruction& deco_inst) { - if (deco_inst.GetSingleWordInOperand(1u) != member_idx) - return false; - col_major = true; - return true; - }); - if (!found) col_major = false; - // Get element type for next step - curr_ty_id = curr_ty_inst->GetSingleWordInOperand(member_idx); - } break; - default: { assert(false && "unexpected non-composite type"); } break; - } - if (sum_id == 0) - sum_id = curr_offset_id; - else { - Instruction* sum_inst = builder->AddBinaryOp(GetUintId(), spv::Op::OpIAdd, - sum_id, curr_offset_id); - sum_id = sum_inst->result_id(); - } - ++ac_in_idx; - } - // Add in offset of last byte of referenced object - uint32_t bsize = ByteSize(curr_ty_id, matrix_stride, col_major, in_matrix); - uint32_t last = bsize - 1; - uint32_t last_id = builder->GetUintConstantId(last); - Instruction* sum_inst = - builder->AddBinaryOp(GetUintId(), spv::Op::OpIAdd, sum_id, last_id); - return sum_inst->result_id(); -} - -void InstBindlessCheckPass::GenCheckCode( - uint32_t check_id, uint32_t error_id, uint32_t offset_id, - uint32_t length_id, uint32_t stage_idx, RefAnalysis* ref, - std::vector>* new_blocks) { - BasicBlock* back_blk_ptr = &*new_blocks->back(); - InstructionBuilder builder( - context(), back_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - // Gen conditional branch on check_id. Valid branch generates original - // reference. Invalid generates debug output and zero result (if needed). - uint32_t merge_blk_id = TakeNextId(); - uint32_t valid_blk_id = TakeNextId(); - uint32_t invalid_blk_id = TakeNextId(); - std::unique_ptr merge_label(NewLabel(merge_blk_id)); - std::unique_ptr valid_label(NewLabel(valid_blk_id)); - std::unique_ptr invalid_label(NewLabel(invalid_blk_id)); - (void)builder.AddConditionalBranch( - check_id, valid_blk_id, invalid_blk_id, merge_blk_id, - uint32_t(spv::SelectionControlMask::MaskNone)); - // Gen valid bounds branch - std::unique_ptr new_blk_ptr( - new BasicBlock(std::move(valid_label))); - builder.SetInsertPoint(&*new_blk_ptr); - uint32_t new_ref_id = CloneOriginalReference(ref, &builder); - (void)builder.AddBranch(merge_blk_id); - new_blocks->push_back(std::move(new_blk_ptr)); - // Gen invalid block - new_blk_ptr.reset(new BasicBlock(std::move(invalid_label))); - builder.SetInsertPoint(&*new_blk_ptr); - uint32_t u_index_id = GenUintCastCode(ref->desc_idx_id, &builder); - if (offset_id != 0) { - // Buffer OOB - uint32_t u_offset_id = GenUintCastCode(offset_id, &builder); - uint32_t u_length_id = GenUintCastCode(length_id, &builder); - GenDebugStreamWrite(uid2offset_[ref->ref_inst->unique_id()], stage_idx, - {error_id, u_index_id, u_offset_id, u_length_id}, - &builder); - } else if (buffer_bounds_enabled_ || texel_buffer_enabled_) { - // Uninitialized Descriptor - Return additional unused zero so all error - // modes will use same debug stream write function - uint32_t u_length_id = GenUintCastCode(length_id, &builder); - GenDebugStreamWrite( - uid2offset_[ref->ref_inst->unique_id()], stage_idx, - {error_id, u_index_id, u_length_id, builder.GetUintConstantId(0)}, - &builder); - } else { - // Uninitialized Descriptor - Normal error return - uint32_t u_length_id = GenUintCastCode(length_id, &builder); - GenDebugStreamWrite(uid2offset_[ref->ref_inst->unique_id()], stage_idx, - {error_id, u_index_id, u_length_id}, &builder); - } - // Remember last invalid block id - uint32_t last_invalid_blk_id = new_blk_ptr->GetLabelInst()->result_id(); - // Gen zero for invalid reference - uint32_t ref_type_id = ref->ref_inst->type_id(); - (void)builder.AddBranch(merge_blk_id); - new_blocks->push_back(std::move(new_blk_ptr)); - // Gen merge block - new_blk_ptr.reset(new BasicBlock(std::move(merge_label))); - builder.SetInsertPoint(&*new_blk_ptr); - // Gen phi of new reference and zero, if necessary, and replace the - // result id of the original reference with that of the Phi. Kill original - // reference. - if (new_ref_id != 0) { - Instruction* phi_inst = builder.AddPhi( - ref_type_id, {new_ref_id, valid_blk_id, GetNullId(ref_type_id), - last_invalid_blk_id}); - context()->ReplaceAllUsesWith(ref->ref_inst->result_id(), - phi_inst->result_id()); - } - new_blocks->push_back(std::move(new_blk_ptr)); - context()->KillInst(ref->ref_inst); -} - -void InstBindlessCheckPass::GenDescIdxCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - // Look for reference through indexed descriptor. If found, analyze and - // save components. If not, return. - RefAnalysis ref; - if (!AnalyzeDescriptorReference(&*ref_inst_itr, &ref)) return; - Instruction* ptr_inst = get_def_use_mgr()->GetDef(ref.ptr_id); - if (ptr_inst->opcode() != spv::Op::OpAccessChain) return; - // If index and bound both compile-time constants and index < bound, - // return without changing - Instruction* var_inst = get_def_use_mgr()->GetDef(ref.var_id); - Instruction* desc_type_inst = GetPointeeTypeInst(var_inst); - uint32_t length_id = 0; - if (desc_type_inst->opcode() == spv::Op::OpTypeArray) { - length_id = - desc_type_inst->GetSingleWordInOperand(kSpvTypeArrayLengthIdInIdx); - Instruction* index_inst = get_def_use_mgr()->GetDef(ref.desc_idx_id); - Instruction* length_inst = get_def_use_mgr()->GetDef(length_id); - if (index_inst->opcode() == spv::Op::OpConstant && - length_inst->opcode() == spv::Op::OpConstant && - index_inst->GetSingleWordInOperand(kSpvConstantValueInIdx) < - length_inst->GetSingleWordInOperand(kSpvConstantValueInIdx)) - return; - } else if (!desc_idx_enabled_ || - desc_type_inst->opcode() != spv::Op::OpTypeRuntimeArray) { - return; - } - // Move original block's preceding instructions into first new block - std::unique_ptr new_blk_ptr; - MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - new_blocks->push_back(std::move(new_blk_ptr)); - uint32_t error_id = builder.GetUintConstantId(kInstErrorBindlessBounds); - // If length id not yet set, descriptor array is runtime size so - // generate load of length from stage's debug input buffer. - if (length_id == 0) { - assert(desc_type_inst->opcode() == spv::Op::OpTypeRuntimeArray && - "unexpected bindless type"); - length_id = GenDebugReadLength(ref.var_id, &builder); - } - // Generate full runtime bounds test code with true branch - // being full reference and false branch being debug output and zero - // for the referenced value. - uint32_t desc_idx_32b_id = Gen32BitCvtCode(ref.desc_idx_id, &builder); - uint32_t length_32b_id = Gen32BitCvtCode(length_id, &builder); - Instruction* ult_inst = builder.AddBinaryOp(GetBoolId(), spv::Op::OpULessThan, - desc_idx_32b_id, length_32b_id); - ref.desc_idx_id = desc_idx_32b_id; - GenCheckCode(ult_inst->result_id(), error_id, 0u, length_id, stage_idx, &ref, - new_blocks); - // Move original block's remaining code into remainder/merge block and add - // to new blocks - BasicBlock* back_blk_ptr = &*new_blocks->back(); - MovePostludeCode(ref_block_itr, back_blk_ptr); -} - -void InstBindlessCheckPass::GenDescInitCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - // Look for reference through descriptor. If not, return. - RefAnalysis ref; - if (!AnalyzeDescriptorReference(&*ref_inst_itr, &ref)) return; - // Determine if we can only do initialization check - bool init_check = false; - if (ref.desc_load_id != 0 || !buffer_bounds_enabled_) { - init_check = true; - } else { - // For now, only do bounds check for non-aggregate types. Otherwise - // just do descriptor initialization check. - // TODO(greg-lunarg): Do bounds check for aggregate loads and stores - Instruction* ref_ptr_inst = get_def_use_mgr()->GetDef(ref.ptr_id); - Instruction* pte_type_inst = GetPointeeTypeInst(ref_ptr_inst); - spv::Op pte_type_op = pte_type_inst->opcode(); - if (pte_type_op == spv::Op::OpTypeArray || - pte_type_op == spv::Op::OpTypeRuntimeArray || - pte_type_op == spv::Op::OpTypeStruct) - init_check = true; - } - // If initialization check and not enabled, return - if (init_check && !desc_init_enabled_) return; - // Move original block's preceding instructions into first new block - std::unique_ptr new_blk_ptr; - MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - new_blocks->push_back(std::move(new_blk_ptr)); - // If initialization check, use reference value of zero. - // Else use the index of the last byte referenced. - uint32_t ref_id = init_check ? builder.GetUintConstantId(0u) - : GenLastByteIdx(&ref, &builder); - // Read initialization/bounds from debug input buffer. If index id not yet - // set, binding is single descriptor, so set index to constant 0. - if (ref.desc_idx_id == 0) ref.desc_idx_id = builder.GetUintConstantId(0u); - uint32_t init_id = GenDebugReadInit(ref.var_id, ref.desc_idx_id, &builder); - // Generate runtime initialization/bounds test code with true branch - // being full reference and false branch being debug output and zero - // for the referenced value. - Instruction* ult_inst = - builder.AddBinaryOp(GetBoolId(), spv::Op::OpULessThan, ref_id, init_id); - uint32_t error = - init_check - ? kInstErrorBindlessUninit - : (spv::StorageClass(ref.strg_class) == spv::StorageClass::Uniform - ? kInstErrorBuffOOBUniform - : kInstErrorBuffOOBStorage); - uint32_t error_id = builder.GetUintConstantId(error); - GenCheckCode(ult_inst->result_id(), error_id, init_check ? 0 : ref_id, - init_check ? builder.GetUintConstantId(0u) : init_id, stage_idx, - &ref, new_blocks); - // Move original block's remaining code into remainder/merge block and add - // to new blocks - BasicBlock* back_blk_ptr = &*new_blocks->back(); - MovePostludeCode(ref_block_itr, back_blk_ptr); -} - -void InstBindlessCheckPass::GenTexBuffCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - // Only process OpImageRead and OpImageWrite with no optional operands - Instruction* ref_inst = &*ref_inst_itr; - spv::Op op = ref_inst->opcode(); - uint32_t num_in_oprnds = ref_inst->NumInOperands(); - if (!((op == spv::Op::OpImageRead && num_in_oprnds == 2) || - (op == spv::Op::OpImageFetch && num_in_oprnds == 2) || - (op == spv::Op::OpImageWrite && num_in_oprnds == 3))) - return; - // Pull components from descriptor reference - RefAnalysis ref; - if (!AnalyzeDescriptorReference(ref_inst, &ref)) return; - // Only process if image is texel buffer - Instruction* image_inst = get_def_use_mgr()->GetDef(ref.image_id); - uint32_t image_ty_id = image_inst->type_id(); - Instruction* image_ty_inst = get_def_use_mgr()->GetDef(image_ty_id); - if (spv::Dim(image_ty_inst->GetSingleWordInOperand(kSpvTypeImageDim)) != - spv::Dim::Buffer) { - return; - } - if (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageDepth) != 0) return; - if (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageArrayed) != 0) return; - if (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageMS) != 0) return; - // Enable ImageQuery Capability if not yet enabled - if (!get_feature_mgr()->HasCapability(spv::Capability::ImageQuery)) { - std::unique_ptr cap_image_query_inst( - new Instruction(context(), spv::Op::OpCapability, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_CAPABILITY, - {uint32_t(spv::Capability::ImageQuery)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*cap_image_query_inst); - context()->AddCapability(std::move(cap_image_query_inst)); - } - // Move original block's preceding instructions into first new block - std::unique_ptr new_blk_ptr; - MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - new_blocks->push_back(std::move(new_blk_ptr)); - // Get texel coordinate - uint32_t coord_id = - GenUintCastCode(ref_inst->GetSingleWordInOperand(1), &builder); - // If index id not yet set, binding is single descriptor, so set index to - // constant 0. - if (ref.desc_idx_id == 0) ref.desc_idx_id = builder.GetUintConstantId(0u); - // Get texel buffer size. - Instruction* size_inst = - builder.AddUnaryOp(GetUintId(), spv::Op::OpImageQuerySize, ref.image_id); - uint32_t size_id = size_inst->result_id(); - // Generate runtime initialization/bounds test code with true branch - // being full reference and false branch being debug output and zero - // for the referenced value. - Instruction* ult_inst = - builder.AddBinaryOp(GetBoolId(), spv::Op::OpULessThan, coord_id, size_id); - uint32_t error = - (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageSampled) == 2) - ? kInstErrorBuffOOBStorageTexel - : kInstErrorBuffOOBUniformTexel; - uint32_t error_id = builder.GetUintConstantId(error); - GenCheckCode(ult_inst->result_id(), error_id, coord_id, size_id, stage_idx, - &ref, new_blocks); - // Move original block's remaining code into remainder/merge block and add - // to new blocks - BasicBlock* back_blk_ptr = &*new_blocks->back(); - MovePostludeCode(ref_block_itr, back_blk_ptr); -} - -void InstBindlessCheckPass::InitializeInstBindlessCheck() { - // Initialize base class - InitializeInstrument(); - // If runtime array length support or buffer bounds checking are enabled, - // create variable mappings. Length support is always enabled if descriptor - // init check is enabled. - if (desc_idx_enabled_ || buffer_bounds_enabled_ || texel_buffer_enabled_) - for (auto& anno : get_module()->annotations()) - if (anno.opcode() == spv::Op::OpDecorate) { - if (spv::Decoration(anno.GetSingleWordInOperand(1u)) == - spv::Decoration::DescriptorSet) { - var2desc_set_[anno.GetSingleWordInOperand(0u)] = - anno.GetSingleWordInOperand(2u); - } else if (spv::Decoration(anno.GetSingleWordInOperand(1u)) == - spv::Decoration::Binding) { - var2binding_[anno.GetSingleWordInOperand(0u)] = - anno.GetSingleWordInOperand(2u); - } - } -} - -Pass::Status InstBindlessCheckPass::ProcessImpl() { - // Perform bindless bounds check on each entry point function in module - InstProcessFunction pfn = - [this](BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - return GenDescIdxCheckCode(ref_inst_itr, ref_block_itr, stage_idx, - new_blocks); - }; - bool modified = InstProcessEntryPointCallTree(pfn); - if (desc_init_enabled_ || buffer_bounds_enabled_) { - // Perform descriptor initialization and/or buffer bounds check on each - // entry point function in module - pfn = [this](BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, - uint32_t stage_idx, - std::vector>* new_blocks) { - return GenDescInitCheckCode(ref_inst_itr, ref_block_itr, stage_idx, - new_blocks); - }; - modified |= InstProcessEntryPointCallTree(pfn); - } - if (texel_buffer_enabled_) { - // Perform texel buffer bounds check on each entry point function in - // module. Generate after descriptor bounds and initialization checks. - pfn = [this](BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, - uint32_t stage_idx, - std::vector>* new_blocks) { - return GenTexBuffCheckCode(ref_inst_itr, ref_block_itr, stage_idx, - new_blocks); - }; - modified |= InstProcessEntryPointCallTree(pfn); - } - return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; -} - -Pass::Status InstBindlessCheckPass::Process() { - InitializeInstBindlessCheck(); - return ProcessImpl(); -} - -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h b/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h deleted file mode 100644 index e6e6ef4f98..0000000000 --- a/third_party/spirv-tools/source/opt/inst_bindless_check_pass.h +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// Copyright (c) 2018 Valve Corporation -// Copyright (c) 2018 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef LIBSPIRV_OPT_INST_BINDLESS_CHECK_PASS_H_ -#define LIBSPIRV_OPT_INST_BINDLESS_CHECK_PASS_H_ - -#include "instrument_pass.h" - -namespace spvtools { -namespace opt { - -// This class/pass is designed to support the bindless (descriptor indexing) -// GPU-assisted validation layer of -// https://github.com/KhronosGroup/Vulkan-ValidationLayers. Its internal and -// external design may change as the layer evolves. -class InstBindlessCheckPass : public InstrumentPass { - public: - InstBindlessCheckPass(uint32_t desc_set, uint32_t shader_id, - bool desc_idx_enable, bool desc_init_enable, - bool buffer_bounds_enable, bool texel_buffer_enable, - bool opt_direct_reads) - : InstrumentPass(desc_set, shader_id, kInstValidationIdBindless, - opt_direct_reads), - desc_idx_enabled_(desc_idx_enable), - desc_init_enabled_(desc_init_enable), - buffer_bounds_enabled_(buffer_bounds_enable), - texel_buffer_enabled_(texel_buffer_enable) {} - - ~InstBindlessCheckPass() override = default; - - // See optimizer.hpp for pass user documentation. - Status Process() override; - - const char* name() const override { return "inst-bindless-check-pass"; } - - private: - // These functions do bindless checking instrumentation on a single - // instruction which references through a descriptor (ie references into an - // image or buffer). Refer to Vulkan API for further information on - // descriptors. GenDescIdxCheckCode checks that an index into a descriptor - // array (array of images or buffers) is in-bounds. GenDescInitCheckCode - // checks that the referenced descriptor has been initialized, if the - // SPV_EXT_descriptor_indexing extension is enabled, and initialized large - // enough to handle the reference, if RobustBufferAccess is disabled. - // GenDescInitCheckCode checks for uniform and storage buffer overrun. - // GenTexBuffCheckCode checks for texel buffer overrun and should be - // run after GenDescInitCheckCode to first make sure that the descriptor - // is initialized because it uses OpImageQuerySize on the descriptor. - // - // The functions are designed to be passed to - // InstrumentPass::InstProcessEntryPointCallTree(), which applies the - // function to each instruction in a module and replaces the instruction - // if warranted. - // - // If |ref_inst_itr| is a bindless reference, return in |new_blocks| the - // result of instrumenting it with validation code within its block at - // |ref_block_itr|. The validation code first executes a check for the - // specific condition called for. If the check passes, it executes - // the remainder of the reference, otherwise writes a record to the debug - // output buffer stream including |function_idx, instruction_idx, stage_idx| - // and replaces the reference with the null value of the original type. The - // block at |ref_block_itr| can just be replaced with the blocks in - // |new_blocks|, which will contain at least two blocks. The last block will - // comprise all instructions following |ref_inst_itr|, - // preceded by a phi instruction. - // - // These instrumentation functions utilize GenDebugDirectRead() to read data - // from the debug input buffer, specifically the lengths of variable length - // descriptor arrays, and the initialization status of each descriptor. - // The format of the debug input buffer is documented in instrument.hpp. - // - // These instrumentation functions utilize GenDebugStreamWrite() to write its - // error records. The validation-specific part of the error record will - // have the format: - // - // Validation Error Code (=kInstErrorBindlessBounds) - // Descriptor Index - // Descriptor Array Size - // - // The Descriptor Index is the index which has been determined to be - // out-of-bounds. - // - // The Descriptor Array Size is the size of the descriptor array which was - // indexed. - void GenDescIdxCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks); - - void GenDescInitCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks); - - void GenTexBuffCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks); - - // Generate instructions into |builder| to read length of runtime descriptor - // array |var_id| from debug input buffer and return id of value. - uint32_t GenDebugReadLength(uint32_t var_id, InstructionBuilder* builder); - - // Generate instructions into |builder| to read initialization status of - // descriptor array |image_id| at |index_id| from debug input buffer and - // return id of value. - uint32_t GenDebugReadInit(uint32_t image_id, uint32_t index_id, - InstructionBuilder* builder); - - // Analysis data for descriptor reference components, generated by - // AnalyzeDescriptorReference. It is necessary and sufficient for further - // analysis and regeneration of the reference. - typedef struct RefAnalysis { - uint32_t desc_load_id; - uint32_t image_id; - uint32_t load_id; - uint32_t ptr_id; - uint32_t var_id; - uint32_t desc_idx_id; - uint32_t strg_class; - Instruction* ref_inst; - } RefAnalysis; - - // Return size of type |ty_id| in bytes. Use |matrix_stride| and |col_major| - // for matrix type, or for vector type if vector is |in_matrix|. - uint32_t ByteSize(uint32_t ty_id, uint32_t matrix_stride, bool col_major, - bool in_matrix); - - // Return stride of type |ty_id| with decoration |stride_deco|. Return 0 - // if not found - uint32_t FindStride(uint32_t ty_id, uint32_t stride_deco); - - // Generate index of last byte referenced by buffer reference |ref| - uint32_t GenLastByteIdx(RefAnalysis* ref, InstructionBuilder* builder); - - // Clone original image computation starting at |image_id| into |builder|. - // This may generate more than one instruction if necessary. - uint32_t CloneOriginalImage(uint32_t image_id, InstructionBuilder* builder); - - // Clone original original reference encapsulated by |ref| into |builder|. - // This may generate more than one instruction if necessary. - uint32_t CloneOriginalReference(RefAnalysis* ref, - InstructionBuilder* builder); - - // If |inst| references through an image, return the id of the image it - // references through. Else return 0. - uint32_t GetImageId(Instruction* inst); - - // Get pointee type inst of pointer value |ptr_inst|. - Instruction* GetPointeeTypeInst(Instruction* ptr_inst); - - // Analyze descriptor reference |ref_inst| and save components into |ref|. - // Return true if |ref_inst| is a descriptor reference, false otherwise. - bool AnalyzeDescriptorReference(Instruction* ref_inst, RefAnalysis* ref); - - // Generate instrumentation code for generic test result |check_id|, starting - // with |builder| of block |new_blk_ptr|, adding new blocks to |new_blocks|. - // Generate conditional branch to a valid or invalid branch. Generate valid - // block which does original reference |ref|. Generate invalid block which - // writes debug error output utilizing |ref|, |error_id|, |length_id| and - // |stage_idx|. Generate merge block for valid and invalid branches. Kill - // original reference. - void GenCheckCode(uint32_t check_id, uint32_t error_id, uint32_t offset_id, - uint32_t length_id, uint32_t stage_idx, RefAnalysis* ref, - std::vector>* new_blocks); - - // Initialize state for instrumenting bindless checking - void InitializeInstBindlessCheck(); - - // Apply GenDescIdxCheckCode to every instruction in module. Then apply - // GenDescInitCheckCode to every instruction in module. - Pass::Status ProcessImpl(); - - // Enable instrumentation of runtime array length checking - bool desc_idx_enabled_; - - // Enable instrumentation of descriptor initialization checking - bool desc_init_enabled_; - - // Enable instrumentation of uniform and storage buffer overrun checking - bool buffer_bounds_enabled_; - - // Enable instrumentation of texel buffer overrun checking - bool texel_buffer_enabled_; - - // Mapping from variable to descriptor set - std::unordered_map var2desc_set_; - - // Mapping from variable to binding - std::unordered_map var2binding_; -}; - -} // namespace opt -} // namespace spvtools - -#endif // LIBSPIRV_OPT_INST_BINDLESS_CHECK_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.cpp b/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.cpp deleted file mode 100644 index be361e69be..0000000000 --- a/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.cpp +++ /dev/null @@ -1,500 +0,0 @@ -// Copyright (c) 2019 The Khronos Group Inc. -// Copyright (c) 2019 Valve Corporation -// Copyright (c) 2019 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "inst_buff_addr_check_pass.h" - -namespace spvtools { -namespace opt { - -uint32_t InstBuffAddrCheckPass::CloneOriginalReference( - Instruction* ref_inst, InstructionBuilder* builder) { - // Clone original ref with new result id (if load) - assert((ref_inst->opcode() == spv::Op::OpLoad || - ref_inst->opcode() == spv::Op::OpStore) && - "unexpected ref"); - std::unique_ptr new_ref_inst(ref_inst->Clone(context())); - uint32_t ref_result_id = ref_inst->result_id(); - uint32_t new_ref_id = 0; - if (ref_result_id != 0) { - new_ref_id = TakeNextId(); - new_ref_inst->SetResultId(new_ref_id); - } - // Register new reference and add to new block - Instruction* added_inst = builder->AddInstruction(std::move(new_ref_inst)); - uid2offset_[added_inst->unique_id()] = uid2offset_[ref_inst->unique_id()]; - if (new_ref_id != 0) - get_decoration_mgr()->CloneDecorations(ref_result_id, new_ref_id); - return new_ref_id; -} - -bool InstBuffAddrCheckPass::IsPhysicalBuffAddrReference(Instruction* ref_inst) { - if (ref_inst->opcode() != spv::Op::OpLoad && - ref_inst->opcode() != spv::Op::OpStore) - return false; - uint32_t ptr_id = ref_inst->GetSingleWordInOperand(0); - analysis::DefUseManager* du_mgr = get_def_use_mgr(); - Instruction* ptr_inst = du_mgr->GetDef(ptr_id); - if (ptr_inst->opcode() != spv::Op::OpAccessChain) return false; - uint32_t ptr_ty_id = ptr_inst->type_id(); - Instruction* ptr_ty_inst = du_mgr->GetDef(ptr_ty_id); - if (spv::StorageClass(ptr_ty_inst->GetSingleWordInOperand(0)) != - spv::StorageClass::PhysicalStorageBufferEXT) - return false; - return true; -} - -// TODO(greg-lunarg): Refactor with InstBindlessCheckPass::GenCheckCode() ?? -void InstBuffAddrCheckPass::GenCheckCode( - uint32_t check_id, uint32_t error_id, uint32_t ref_uptr_id, - uint32_t stage_idx, Instruction* ref_inst, - std::vector>* new_blocks) { - BasicBlock* back_blk_ptr = &*new_blocks->back(); - InstructionBuilder builder( - context(), back_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - // Gen conditional branch on check_id. Valid branch generates original - // reference. Invalid generates debug output and zero result (if needed). - uint32_t merge_blk_id = TakeNextId(); - uint32_t valid_blk_id = TakeNextId(); - uint32_t invalid_blk_id = TakeNextId(); - std::unique_ptr merge_label(NewLabel(merge_blk_id)); - std::unique_ptr valid_label(NewLabel(valid_blk_id)); - std::unique_ptr invalid_label(NewLabel(invalid_blk_id)); - (void)builder.AddConditionalBranch( - check_id, valid_blk_id, invalid_blk_id, merge_blk_id, - uint32_t(spv::SelectionControlMask::MaskNone)); - // Gen valid branch - std::unique_ptr new_blk_ptr( - new BasicBlock(std::move(valid_label))); - builder.SetInsertPoint(&*new_blk_ptr); - uint32_t new_ref_id = CloneOriginalReference(ref_inst, &builder); - (void)builder.AddBranch(merge_blk_id); - new_blocks->push_back(std::move(new_blk_ptr)); - // Gen invalid block - new_blk_ptr.reset(new BasicBlock(std::move(invalid_label))); - builder.SetInsertPoint(&*new_blk_ptr); - // Convert uptr from uint64 to 2 uint32 - Instruction* lo_uptr_inst = - builder.AddUnaryOp(GetUintId(), spv::Op::OpUConvert, ref_uptr_id); - Instruction* rshift_uptr_inst = - builder.AddBinaryOp(GetUint64Id(), spv::Op::OpShiftRightLogical, - ref_uptr_id, builder.GetUintConstantId(32)); - Instruction* hi_uptr_inst = builder.AddUnaryOp( - GetUintId(), spv::Op::OpUConvert, rshift_uptr_inst->result_id()); - GenDebugStreamWrite( - uid2offset_[ref_inst->unique_id()], stage_idx, - {error_id, lo_uptr_inst->result_id(), hi_uptr_inst->result_id()}, - &builder); - // Gen zero for invalid load. If pointer type, need to convert uint64 - // zero to pointer; cannot create ConstantNull of pointer type. - uint32_t null_id = 0; - if (new_ref_id != 0) { - uint32_t ref_type_id = ref_inst->type_id(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Type* ref_type = type_mgr->GetType(ref_type_id); - if (ref_type->AsPointer() != nullptr) { - uint32_t null_u64_id = GetNullId(GetUint64Id()); - Instruction* null_ptr_inst = builder.AddUnaryOp( - ref_type_id, spv::Op::OpConvertUToPtr, null_u64_id); - null_id = null_ptr_inst->result_id(); - } else { - null_id = GetNullId(ref_type_id); - } - } - (void)builder.AddBranch(merge_blk_id); - new_blocks->push_back(std::move(new_blk_ptr)); - // Gen merge block - new_blk_ptr.reset(new BasicBlock(std::move(merge_label))); - builder.SetInsertPoint(&*new_blk_ptr); - // Gen phi of new reference and zero, if necessary, and replace the - // result id of the original reference with that of the Phi. Kill original - // reference. - if (new_ref_id != 0) { - Instruction* phi_inst = - builder.AddPhi(ref_inst->type_id(), - {new_ref_id, valid_blk_id, null_id, invalid_blk_id}); - context()->ReplaceAllUsesWith(ref_inst->result_id(), phi_inst->result_id()); - } - new_blocks->push_back(std::move(new_blk_ptr)); - context()->KillInst(ref_inst); -} - -uint32_t InstBuffAddrCheckPass::GetTypeAlignment(uint32_t type_id) { - Instruction* type_inst = get_def_use_mgr()->GetDef(type_id); - switch (type_inst->opcode()) { - case spv::Op::OpTypeFloat: - case spv::Op::OpTypeInt: - case spv::Op::OpTypeVector: - return GetTypeLength(type_id); - case spv::Op::OpTypeMatrix: - return GetTypeAlignment(type_inst->GetSingleWordInOperand(0)); - case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: - return GetTypeAlignment(type_inst->GetSingleWordInOperand(0)); - case spv::Op::OpTypeStruct: { - uint32_t max = 0; - type_inst->ForEachInId([&max, this](const uint32_t* iid) { - uint32_t alignment = GetTypeAlignment(*iid); - max = (alignment > max) ? alignment : max; - }); - return max; - } - case spv::Op::OpTypePointer: - assert(spv::StorageClass(type_inst->GetSingleWordInOperand(0)) == - spv::StorageClass::PhysicalStorageBufferEXT && - "unexpected pointer type"); - return 8u; - default: - assert(false && "unexpected type"); - return 0; - } -} - -uint32_t InstBuffAddrCheckPass::GetTypeLength(uint32_t type_id) { - Instruction* type_inst = get_def_use_mgr()->GetDef(type_id); - switch (type_inst->opcode()) { - case spv::Op::OpTypeFloat: - case spv::Op::OpTypeInt: - return type_inst->GetSingleWordInOperand(0) / 8u; - case spv::Op::OpTypeVector: { - uint32_t raw_cnt = type_inst->GetSingleWordInOperand(1); - uint32_t adj_cnt = (raw_cnt == 3u) ? 4u : raw_cnt; - return adj_cnt * GetTypeLength(type_inst->GetSingleWordInOperand(0)); - } - case spv::Op::OpTypeMatrix: - return type_inst->GetSingleWordInOperand(1) * - GetTypeLength(type_inst->GetSingleWordInOperand(0)); - case spv::Op::OpTypePointer: - assert(spv::StorageClass(type_inst->GetSingleWordInOperand(0)) == - spv::StorageClass::PhysicalStorageBufferEXT && - "unexpected pointer type"); - return 8u; - case spv::Op::OpTypeArray: { - uint32_t const_id = type_inst->GetSingleWordInOperand(1); - Instruction* const_inst = get_def_use_mgr()->GetDef(const_id); - uint32_t cnt = const_inst->GetSingleWordInOperand(0); - return cnt * GetTypeLength(type_inst->GetSingleWordInOperand(0)); - } - case spv::Op::OpTypeStruct: { - uint32_t len = 0; - type_inst->ForEachInId([&len, this](const uint32_t* iid) { - // Align struct length - uint32_t alignment = GetTypeAlignment(*iid); - uint32_t mod = len % alignment; - uint32_t diff = (mod != 0) ? alignment - mod : 0; - len += diff; - // Increment struct length by component length - uint32_t comp_len = GetTypeLength(*iid); - len += comp_len; - }); - return len; - } - case spv::Op::OpTypeRuntimeArray: - default: - assert(false && "unexpected type"); - return 0; - } -} - -void InstBuffAddrCheckPass::AddParam(uint32_t type_id, - std::vector* param_vec, - std::unique_ptr* input_func) { - uint32_t pid = TakeNextId(); - param_vec->push_back(pid); - std::unique_ptr param_inst(new Instruction( - get_module()->context(), spv::Op::OpFunctionParameter, type_id, pid, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*param_inst); - (*input_func)->AddParameter(std::move(param_inst)); -} - -uint32_t InstBuffAddrCheckPass::GetSearchAndTestFuncId() { - if (search_test_func_id_ == 0) { - // Generate function "bool search_and_test(uint64_t ref_ptr, uint32_t len)" - // which searches input buffer for buffer which most likely contains the - // pointer value |ref_ptr| and verifies that the entire reference of - // length |len| bytes is contained in the buffer. - search_test_func_id_ = TakeNextId(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - std::vector param_types = { - type_mgr->GetType(GetUint64Id()), type_mgr->GetType(GetUintId())}; - analysis::Function func_ty(type_mgr->GetType(GetBoolId()), param_types); - analysis::Type* reg_func_ty = type_mgr->GetRegisteredType(&func_ty); - std::unique_ptr func_inst( - new Instruction(get_module()->context(), spv::Op::OpFunction, - GetBoolId(), search_test_func_id_, - {{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::FunctionControlMask::MaskNone)}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, - {type_mgr->GetTypeInstruction(reg_func_ty)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_inst); - std::unique_ptr input_func = - MakeUnique(std::move(func_inst)); - std::vector param_vec; - // Add ref_ptr and length parameters - AddParam(GetUint64Id(), ¶m_vec, &input_func); - AddParam(GetUintId(), ¶m_vec, &input_func); - // Empty first block. - uint32_t first_blk_id = TakeNextId(); - std::unique_ptr first_blk_label(NewLabel(first_blk_id)); - std::unique_ptr first_blk_ptr = - MakeUnique(std::move(first_blk_label)); - InstructionBuilder builder( - context(), &*first_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - uint32_t hdr_blk_id = TakeNextId(); - // Branch to search loop header - std::unique_ptr hdr_blk_label(NewLabel(hdr_blk_id)); - (void)builder.AddInstruction(MakeUnique( - context(), spv::Op::OpBranch, 0, 0, - std::initializer_list{{SPV_OPERAND_TYPE_ID, {hdr_blk_id}}})); - input_func->AddBasicBlock(std::move(first_blk_ptr)); - // Linear search loop header block - // TODO(greg-lunarg): Implement binary search - std::unique_ptr hdr_blk_ptr = - MakeUnique(std::move(hdr_blk_label)); - builder.SetInsertPoint(&*hdr_blk_ptr); - // Phi for search index. Starts with 1. - uint32_t cont_blk_id = TakeNextId(); - std::unique_ptr cont_blk_label(NewLabel(cont_blk_id)); - // Deal with def-use cycle caused by search loop index computation. - // Create Add and Phi instructions first, then do Def analysis on Add. - // Add Phi and Add instructions and do Use analysis later. - uint32_t idx_phi_id = TakeNextId(); - uint32_t idx_inc_id = TakeNextId(); - std::unique_ptr idx_inc_inst(new Instruction( - context(), spv::Op::OpIAdd, GetUintId(), idx_inc_id, - {{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {idx_phi_id}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, - {builder.GetUintConstantId(1u)}}})); - std::unique_ptr idx_phi_inst(new Instruction( - context(), spv::Op::OpPhi, GetUintId(), idx_phi_id, - {{spv_operand_type_t::SPV_OPERAND_TYPE_ID, - {builder.GetUintConstantId(1u)}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {first_blk_id}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {idx_inc_id}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {cont_blk_id}}})); - get_def_use_mgr()->AnalyzeInstDef(&*idx_inc_inst); - // Add (previously created) search index phi - (void)builder.AddInstruction(std::move(idx_phi_inst)); - // LoopMerge - uint32_t bound_test_blk_id = TakeNextId(); - std::unique_ptr bound_test_blk_label( - NewLabel(bound_test_blk_id)); - (void)builder.AddInstruction(MakeUnique( - context(), spv::Op::OpLoopMerge, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_ID, {bound_test_blk_id}}, - {SPV_OPERAND_TYPE_ID, {cont_blk_id}}, - {SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::LoopControlMask::MaskNone)}}})); - // Branch to continue/work block - (void)builder.AddInstruction(MakeUnique( - context(), spv::Op::OpBranch, 0, 0, - std::initializer_list{{SPV_OPERAND_TYPE_ID, {cont_blk_id}}})); - input_func->AddBasicBlock(std::move(hdr_blk_ptr)); - // Continue/Work Block. Read next buffer pointer and break if greater - // than ref_ptr arg. - std::unique_ptr cont_blk_ptr = - MakeUnique(std::move(cont_blk_label)); - builder.SetInsertPoint(&*cont_blk_ptr); - // Add (previously created) search index increment now. - (void)builder.AddInstruction(std::move(idx_inc_inst)); - // Load next buffer address from debug input buffer - uint32_t ibuf_id = GetInputBufferId(); - uint32_t ibuf_ptr_id = GetInputBufferPtrId(); - Instruction* uptr_ac_inst = builder.AddTernaryOp( - ibuf_ptr_id, spv::Op::OpAccessChain, ibuf_id, - builder.GetUintConstantId(kDebugInputDataOffset), idx_inc_id); - uint32_t ibuf_type_id = GetInputBufferTypeId(); - Instruction* uptr_load_inst = builder.AddUnaryOp( - ibuf_type_id, spv::Op::OpLoad, uptr_ac_inst->result_id()); - // If loaded address greater than ref_ptr arg, break, else branch back to - // loop header - Instruction* uptr_test_inst = - builder.AddBinaryOp(GetBoolId(), spv::Op::OpUGreaterThan, - uptr_load_inst->result_id(), param_vec[0]); - (void)builder.AddConditionalBranch( - uptr_test_inst->result_id(), bound_test_blk_id, hdr_blk_id, kInvalidId, - uint32_t(spv::SelectionControlMask::MaskNone)); - input_func->AddBasicBlock(std::move(cont_blk_ptr)); - // Bounds test block. Read length of selected buffer and test that - // all len arg bytes are in buffer. - std::unique_ptr bound_test_blk_ptr = - MakeUnique(std::move(bound_test_blk_label)); - builder.SetInsertPoint(&*bound_test_blk_ptr); - // Decrement index to point to previous/candidate buffer address - Instruction* cand_idx_inst = - builder.AddBinaryOp(GetUintId(), spv::Op::OpISub, idx_inc_id, - builder.GetUintConstantId(1u)); - // Load candidate buffer address - Instruction* cand_ac_inst = - builder.AddTernaryOp(ibuf_ptr_id, spv::Op::OpAccessChain, ibuf_id, - builder.GetUintConstantId(kDebugInputDataOffset), - cand_idx_inst->result_id()); - Instruction* cand_load_inst = builder.AddUnaryOp( - ibuf_type_id, spv::Op::OpLoad, cand_ac_inst->result_id()); - // Compute offset of ref_ptr from candidate buffer address - Instruction* offset_inst = - builder.AddBinaryOp(ibuf_type_id, spv::Op::OpISub, param_vec[0], - cand_load_inst->result_id()); - // Convert ref length to uint64 - Instruction* ref_len_64_inst = - builder.AddUnaryOp(ibuf_type_id, spv::Op::OpUConvert, param_vec[1]); - // Add ref length to ref offset to compute end of reference - Instruction* ref_end_inst = builder.AddBinaryOp( - ibuf_type_id, spv::Op::OpIAdd, offset_inst->result_id(), - ref_len_64_inst->result_id()); - // Load starting index of lengths in input buffer and convert to uint32 - Instruction* len_start_ac_inst = - builder.AddTernaryOp(ibuf_ptr_id, spv::Op::OpAccessChain, ibuf_id, - builder.GetUintConstantId(kDebugInputDataOffset), - builder.GetUintConstantId(0u)); - Instruction* len_start_load_inst = builder.AddUnaryOp( - ibuf_type_id, spv::Op::OpLoad, len_start_ac_inst->result_id()); - Instruction* len_start_32_inst = builder.AddUnaryOp( - GetUintId(), spv::Op::OpUConvert, len_start_load_inst->result_id()); - // Decrement search index to get candidate buffer length index - Instruction* cand_len_idx_inst = builder.AddBinaryOp( - GetUintId(), spv::Op::OpISub, cand_idx_inst->result_id(), - builder.GetUintConstantId(1u)); - // Add candidate length index to start index - Instruction* len_idx_inst = builder.AddBinaryOp( - GetUintId(), spv::Op::OpIAdd, cand_len_idx_inst->result_id(), - len_start_32_inst->result_id()); - // Load candidate buffer length - Instruction* len_ac_inst = - builder.AddTernaryOp(ibuf_ptr_id, spv::Op::OpAccessChain, ibuf_id, - builder.GetUintConstantId(kDebugInputDataOffset), - len_idx_inst->result_id()); - Instruction* len_load_inst = builder.AddUnaryOp( - ibuf_type_id, spv::Op::OpLoad, len_ac_inst->result_id()); - // Test if reference end within candidate buffer length - Instruction* len_test_inst = builder.AddBinaryOp( - GetBoolId(), spv::Op::OpULessThanEqual, ref_end_inst->result_id(), - len_load_inst->result_id()); - // Return test result - (void)builder.AddInstruction(MakeUnique( - context(), spv::Op::OpReturnValue, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_ID, {len_test_inst->result_id()}}})); - // Close block - input_func->AddBasicBlock(std::move(bound_test_blk_ptr)); - // Close function and add function to module - std::unique_ptr func_end_inst(new Instruction( - get_module()->context(), spv::Op::OpFunctionEnd, 0, 0, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_end_inst); - input_func->SetFunctionEnd(std::move(func_end_inst)); - context()->AddFunction(std::move(input_func)); - context()->AddDebug2Inst( - NewGlobalName(search_test_func_id_, "search_and_test")); - } - return search_test_func_id_; -} - -uint32_t InstBuffAddrCheckPass::GenSearchAndTest(Instruction* ref_inst, - InstructionBuilder* builder, - uint32_t* ref_uptr_id) { - // Enable Int64 if necessary - if (!get_feature_mgr()->HasCapability(spv::Capability::Int64)) { - std::unique_ptr cap_int64_inst(new Instruction( - context(), spv::Op::OpCapability, 0, 0, - std::initializer_list{{SPV_OPERAND_TYPE_CAPABILITY, - {uint32_t(spv::Capability::Int64)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*cap_int64_inst); - context()->AddCapability(std::move(cap_int64_inst)); - } - // Convert reference pointer to uint64 - uint32_t ref_ptr_id = ref_inst->GetSingleWordInOperand(0); - Instruction* ref_uptr_inst = - builder->AddUnaryOp(GetUint64Id(), spv::Op::OpConvertPtrToU, ref_ptr_id); - *ref_uptr_id = ref_uptr_inst->result_id(); - // Compute reference length in bytes - analysis::DefUseManager* du_mgr = get_def_use_mgr(); - Instruction* ref_ptr_inst = du_mgr->GetDef(ref_ptr_id); - uint32_t ref_ptr_ty_id = ref_ptr_inst->type_id(); - Instruction* ref_ptr_ty_inst = du_mgr->GetDef(ref_ptr_ty_id); - uint32_t ref_len = GetTypeLength(ref_ptr_ty_inst->GetSingleWordInOperand(1)); - uint32_t ref_len_id = builder->GetUintConstantId(ref_len); - // Gen call to search and test function - const std::vector args = {GetSearchAndTestFuncId(), *ref_uptr_id, - ref_len_id}; - Instruction* call_inst = - builder->AddNaryOp(GetBoolId(), spv::Op::OpFunctionCall, args); - uint32_t retval = call_inst->result_id(); - return retval; -} - -void InstBuffAddrCheckPass::GenBuffAddrCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - // Look for reference through indexed descriptor. If found, analyze and - // save components. If not, return. - Instruction* ref_inst = &*ref_inst_itr; - if (!IsPhysicalBuffAddrReference(ref_inst)) return; - // Move original block's preceding instructions into first new block - std::unique_ptr new_blk_ptr; - MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - new_blocks->push_back(std::move(new_blk_ptr)); - uint32_t error_id = builder.GetUintConstantId(kInstErrorBuffAddrUnallocRef); - // Generate code to do search and test if all bytes of reference - // are within a listed buffer. Return reference pointer converted to uint64. - uint32_t ref_uptr_id; - uint32_t valid_id = GenSearchAndTest(ref_inst, &builder, &ref_uptr_id); - // Generate test of search results with true branch - // being full reference and false branch being debug output and zero - // for the referenced value. - GenCheckCode(valid_id, error_id, ref_uptr_id, stage_idx, ref_inst, - new_blocks); - // Move original block's remaining code into remainder/merge block and add - // to new blocks - BasicBlock* back_blk_ptr = &*new_blocks->back(); - MovePostludeCode(ref_block_itr, back_blk_ptr); -} - -void InstBuffAddrCheckPass::InitInstBuffAddrCheck() { - // Initialize base class - InitializeInstrument(); - // Initialize class - search_test_func_id_ = 0; -} - -Pass::Status InstBuffAddrCheckPass::ProcessImpl() { - // Perform bindless bounds check on each entry point function in module - InstProcessFunction pfn = - [this](BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - return GenBuffAddrCheckCode(ref_inst_itr, ref_block_itr, stage_idx, - new_blocks); - }; - bool modified = InstProcessEntryPointCallTree(pfn); - return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; -} - -Pass::Status InstBuffAddrCheckPass::Process() { - if (!get_feature_mgr()->HasCapability( - spv::Capability::PhysicalStorageBufferAddressesEXT)) - return Status::SuccessWithoutChange; - InitInstBuffAddrCheck(); - return ProcessImpl(); -} - -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.h b/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.h deleted file mode 100644 index fb43c397a5..0000000000 --- a/third_party/spirv-tools/source/opt/inst_buff_addr_check_pass.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2019 The Khronos Group Inc. -// Copyright (c) 2019 Valve Corporation -// Copyright (c) 2019 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef LIBSPIRV_OPT_INST_BUFFER_ADDRESS_PASS_H_ -#define LIBSPIRV_OPT_INST_BUFFER_ADDRESS_PASS_H_ - -#include "instrument_pass.h" - -namespace spvtools { -namespace opt { - -// This class/pass is designed to support the GPU-assisted validation layer of -// the Buffer Device Address (BDA) extension in -// https://github.com/KhronosGroup/Vulkan-ValidationLayers. The internal and -// external design of this class may change as the layer evolves. -class InstBuffAddrCheckPass : public InstrumentPass { - public: - // For test harness only - InstBuffAddrCheckPass() : InstrumentPass(7, 23, kInstValidationIdBuffAddr) {} - // For all other interfaces - InstBuffAddrCheckPass(uint32_t desc_set, uint32_t shader_id) - : InstrumentPass(desc_set, shader_id, kInstValidationIdBuffAddr) {} - - ~InstBuffAddrCheckPass() override = default; - - // See optimizer.hpp for pass user documentation. - Status Process() override; - - const char* name() const override { return "inst-buff-addr-check-pass"; } - - private: - // Return byte alignment of type |type_id|. Must be int, float, vector, - // matrix, struct, array or physical pointer. Uses std430 alignment. - uint32_t GetTypeAlignment(uint32_t type_id); - - // Return byte length of type |type_id|. Must be int, float, vector, matrix, - // struct, array or physical pointer. Uses std430 alignment and sizes. - uint32_t GetTypeLength(uint32_t type_id); - - // Add |type_id| param to |input_func| and add id to |param_vec|. - void AddParam(uint32_t type_id, std::vector* param_vec, - std::unique_ptr* input_func); - - // Return id for search and test function. Generate it if not already gen'd. - uint32_t GetSearchAndTestFuncId(); - - // Generate code into |builder| to do search of the BDA debug input buffer - // for the buffer used by |ref_inst| and test that all bytes of reference - // are within the buffer. Returns id of boolean value which is true if - // search and test is successful, false otherwise. - uint32_t GenSearchAndTest(Instruction* ref_inst, InstructionBuilder* builder, - uint32_t* ref_uptr_id); - - // This function does checking instrumentation on a single - // instruction which references through a physical storage buffer address. - // GenBuffAddrCheckCode generates code that checks that all bytes that - // are referenced fall within a buffer that was queried via - // the Vulkan API call vkGetBufferDeviceAddressEXT(). - // - // The function is designed to be passed to - // InstrumentPass::InstProcessEntryPointCallTree(), which applies the - // function to each instruction in a module and replaces the instruction - // with instrumented code if warranted. - // - // If |ref_inst_itr| is a physical storage buffer reference, return in - // |new_blocks| the result of instrumenting it with validation code within - // its block at |ref_block_itr|. The validation code first executes a check - // for the specific condition called for. If the check passes, it executes - // the remainder of the reference, otherwise writes a record to the debug - // output buffer stream including |function_idx, instruction_idx, stage_idx| - // and replaces the reference with the null value of the original type. The - // block at |ref_block_itr| can just be replaced with the blocks in - // |new_blocks|, which will contain at least two blocks. The last block will - // comprise all instructions following |ref_inst_itr|, - // preceded by a phi instruction if needed. - // - // This instrumentation function utilizes GenDebugStreamWrite() to write its - // error records. The validation-specific part of the error record will - // have the format: - // - // Validation Error Code (=kInstErrorBuffAddr) - // Buffer Address (lowest 32 bits) - // Buffer Address (highest 32 bits) - // - void GenBuffAddrCheckCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks); - - // Return true if |ref_inst| is a physical buffer address reference, false - // otherwise. - bool IsPhysicalBuffAddrReference(Instruction* ref_inst); - - // Clone original reference |ref_inst| into |builder| and return id of result - uint32_t CloneOriginalReference(Instruction* ref_inst, - InstructionBuilder* builder); - - // Generate instrumentation code for boolean test result |check_id|, - // adding new blocks to |new_blocks|. Generate conditional branch to valid - // or invalid reference blocks. Generate valid reference block which does - // original reference |ref_inst|. Then generate invalid reference block which - // writes debug error output utilizing |ref_inst|, |error_id| and - // |stage_idx|. Generate merge block for valid and invalid reference blocks. - // Kill original reference. - void GenCheckCode(uint32_t check_id, uint32_t error_id, uint32_t length_id, - uint32_t stage_idx, Instruction* ref_inst, - std::vector>* new_blocks); - - // Initialize state for instrumenting physical buffer address checking - void InitInstBuffAddrCheck(); - - // Apply GenBuffAddrCheckCode to every instruction in module. - Pass::Status ProcessImpl(); - - // Id of search and test function, if already gen'd, else zero. - uint32_t search_test_func_id_; -}; - -} // namespace opt -} // namespace spvtools - -#endif // LIBSPIRV_OPT_INST_BUFFER_ADDRESS_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp b/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp deleted file mode 100644 index 151b94c73e..0000000000 --- a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) 2020 The Khronos Group Inc. -// Copyright (c) 2020 Valve Corporation -// Copyright (c) 2020 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "inst_debug_printf_pass.h" - -#include "source/util/string_utils.h" -#include "spirv/unified1/NonSemanticDebugPrintf.h" - -namespace spvtools { -namespace opt { - -void InstDebugPrintfPass::GenOutputValues(Instruction* val_inst, - std::vector* val_ids, - InstructionBuilder* builder) { - uint32_t val_ty_id = val_inst->type_id(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Type* val_ty = type_mgr->GetType(val_ty_id); - switch (val_ty->kind()) { - case analysis::Type::kVector: { - analysis::Vector* v_ty = val_ty->AsVector(); - const analysis::Type* c_ty = v_ty->element_type(); - uint32_t c_ty_id = type_mgr->GetId(c_ty); - for (uint32_t c = 0; c < v_ty->element_count(); ++c) { - Instruction* c_inst = builder->AddIdLiteralOp( - c_ty_id, spv::Op::OpCompositeExtract, val_inst->result_id(), c); - GenOutputValues(c_inst, val_ids, builder); - } - return; - } - case analysis::Type::kBool: { - // Select between uint32 zero or one - uint32_t zero_id = builder->GetUintConstantId(0); - uint32_t one_id = builder->GetUintConstantId(1); - Instruction* sel_inst = - builder->AddTernaryOp(GetUintId(), spv::Op::OpSelect, - val_inst->result_id(), one_id, zero_id); - val_ids->push_back(sel_inst->result_id()); - return; - } - case analysis::Type::kFloat: { - analysis::Float* f_ty = val_ty->AsFloat(); - switch (f_ty->width()) { - case 16: { - // Convert float16 to float32 and recurse - Instruction* f32_inst = builder->AddUnaryOp( - GetFloatId(), spv::Op::OpFConvert, val_inst->result_id()); - GenOutputValues(f32_inst, val_ids, builder); - return; - } - case 64: { - // Bitcast float64 to uint64 and recurse - Instruction* ui64_inst = builder->AddUnaryOp( - GetUint64Id(), spv::Op::OpBitcast, val_inst->result_id()); - GenOutputValues(ui64_inst, val_ids, builder); - return; - } - case 32: { - // Bitcase float32 to uint32 - Instruction* bc_inst = builder->AddUnaryOp( - GetUintId(), spv::Op::OpBitcast, val_inst->result_id()); - val_ids->push_back(bc_inst->result_id()); - return; - } - default: - assert(false && "unsupported float width"); - return; - } - } - case analysis::Type::kInteger: { - analysis::Integer* i_ty = val_ty->AsInteger(); - switch (i_ty->width()) { - case 64: { - Instruction* ui64_inst = val_inst; - if (i_ty->IsSigned()) { - // Bitcast sint64 to uint64 - ui64_inst = builder->AddUnaryOp(GetUint64Id(), spv::Op::OpBitcast, - val_inst->result_id()); - } - // Break uint64 into 2x uint32 - Instruction* lo_ui64_inst = builder->AddUnaryOp( - GetUintId(), spv::Op::OpUConvert, ui64_inst->result_id()); - Instruction* rshift_ui64_inst = builder->AddBinaryOp( - GetUint64Id(), spv::Op::OpShiftRightLogical, - ui64_inst->result_id(), builder->GetUintConstantId(32)); - Instruction* hi_ui64_inst = builder->AddUnaryOp( - GetUintId(), spv::Op::OpUConvert, rshift_ui64_inst->result_id()); - val_ids->push_back(lo_ui64_inst->result_id()); - val_ids->push_back(hi_ui64_inst->result_id()); - return; - } - case 8: { - Instruction* ui8_inst = val_inst; - if (i_ty->IsSigned()) { - // Bitcast sint8 to uint8 - ui8_inst = builder->AddUnaryOp(GetUint8Id(), spv::Op::OpBitcast, - val_inst->result_id()); - } - // Convert uint8 to uint32 - Instruction* ui32_inst = builder->AddUnaryOp( - GetUintId(), spv::Op::OpUConvert, ui8_inst->result_id()); - val_ids->push_back(ui32_inst->result_id()); - return; - } - case 32: { - Instruction* ui32_inst = val_inst; - if (i_ty->IsSigned()) { - // Bitcast sint32 to uint32 - ui32_inst = builder->AddUnaryOp(GetUintId(), spv::Op::OpBitcast, - val_inst->result_id()); - } - // uint32 needs no further processing - val_ids->push_back(ui32_inst->result_id()); - return; - } - default: - // TODO(greg-lunarg): Support non-32-bit int - assert(false && "unsupported int width"); - return; - } - } - default: - assert(false && "unsupported type"); - return; - } -} - -void InstDebugPrintfPass::GenOutputCode( - Instruction* printf_inst, uint32_t stage_idx, - std::vector>* new_blocks) { - BasicBlock* back_blk_ptr = &*new_blocks->back(); - InstructionBuilder builder( - context(), back_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - // Gen debug printf record validation-specific values. The format string - // will have its id written. Vectors will need to be broken down into - // component values. float16 will need to be converted to float32. Pointer - // and uint64 will need to be converted to two uint32 values. float32 will - // need to be bitcast to uint32. int32 will need to be bitcast to uint32. - std::vector val_ids; - bool is_first_operand = false; - printf_inst->ForEachInId( - [&is_first_operand, &val_ids, &builder, this](const uint32_t* iid) { - // skip set operand - if (!is_first_operand) { - is_first_operand = true; - return; - } - Instruction* opnd_inst = get_def_use_mgr()->GetDef(*iid); - if (opnd_inst->opcode() == spv::Op::OpString) { - uint32_t string_id_id = builder.GetUintConstantId(*iid); - val_ids.push_back(string_id_id); - } else { - GenOutputValues(opnd_inst, &val_ids, &builder); - } - }); - GenDebugStreamWrite(uid2offset_[printf_inst->unique_id()], stage_idx, val_ids, - &builder); - context()->KillInst(printf_inst); -} - -void InstDebugPrintfPass::GenDebugPrintfCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - // If not DebugPrintf OpExtInst, return. - Instruction* printf_inst = &*ref_inst_itr; - if (printf_inst->opcode() != spv::Op::OpExtInst) return; - if (printf_inst->GetSingleWordInOperand(0) != ext_inst_printf_id_) return; - if (printf_inst->GetSingleWordInOperand(1) != - NonSemanticDebugPrintfDebugPrintf) - return; - // Initialize DefUse manager before dismantling module - (void)get_def_use_mgr(); - // Move original block's preceding instructions into first new block - std::unique_ptr new_blk_ptr; - MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); - new_blocks->push_back(std::move(new_blk_ptr)); - // Generate instructions to output printf args to printf buffer - GenOutputCode(printf_inst, stage_idx, new_blocks); - // Caller expects at least two blocks with last block containing remaining - // code, so end block after instrumentation, create remainder block, and - // branch to it - uint32_t rem_blk_id = TakeNextId(); - std::unique_ptr rem_label(NewLabel(rem_blk_id)); - BasicBlock* back_blk_ptr = &*new_blocks->back(); - InstructionBuilder builder( - context(), back_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - (void)builder.AddBranch(rem_blk_id); - // Gen remainder block - new_blk_ptr.reset(new BasicBlock(std::move(rem_label))); - builder.SetInsertPoint(&*new_blk_ptr); - // Move original block's remaining code into remainder block and add - // to new blocks - MovePostludeCode(ref_block_itr, &*new_blk_ptr); - new_blocks->push_back(std::move(new_blk_ptr)); -} - -void InstDebugPrintfPass::InitializeInstDebugPrintf() { - // Initialize base class - InitializeInstrument(); -} - -Pass::Status InstDebugPrintfPass::ProcessImpl() { - // Perform printf instrumentation on each entry point function in module - InstProcessFunction pfn = - [this](BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, uint32_t stage_idx, - std::vector>* new_blocks) { - return GenDebugPrintfCode(ref_inst_itr, ref_block_itr, stage_idx, - new_blocks); - }; - (void)InstProcessEntryPointCallTree(pfn); - // Remove DebugPrintf OpExtInstImport instruction - Instruction* ext_inst_import_inst = - get_def_use_mgr()->GetDef(ext_inst_printf_id_); - context()->KillInst(ext_inst_import_inst); - // If no remaining non-semantic instruction sets, remove non-semantic debug - // info extension from module and feature manager - bool non_sem_set_seen = false; - for (auto c_itr = context()->module()->ext_inst_import_begin(); - c_itr != context()->module()->ext_inst_import_end(); ++c_itr) { - const std::string set_name = c_itr->GetInOperand(0).AsString(); - if (spvtools::utils::starts_with(set_name, "NonSemantic.")) { - non_sem_set_seen = true; - break; - } - } - if (!non_sem_set_seen) { - for (auto c_itr = context()->module()->extension_begin(); - c_itr != context()->module()->extension_end(); ++c_itr) { - const std::string ext_name = c_itr->GetInOperand(0).AsString(); - if (ext_name == "SPV_KHR_non_semantic_info") { - context()->KillInst(&*c_itr); - break; - } - } - context()->get_feature_mgr()->RemoveExtension(kSPV_KHR_non_semantic_info); - } - return Status::SuccessWithChange; -} - -Pass::Status InstDebugPrintfPass::Process() { - ext_inst_printf_id_ = - get_module()->GetExtInstImportId("NonSemantic.DebugPrintf"); - if (ext_inst_printf_id_ == 0) return Status::SuccessWithoutChange; - InitializeInstDebugPrintf(); - return ProcessImpl(); -} - -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.h b/third_party/spirv-tools/source/opt/inst_debug_printf_pass.h deleted file mode 100644 index 70b0a72bd7..0000000000 --- a/third_party/spirv-tools/source/opt/inst_debug_printf_pass.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2020 The Khronos Group Inc. -// Copyright (c) 2020 Valve Corporation -// Copyright (c) 2020 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef LIBSPIRV_OPT_INST_DEBUG_PRINTF_PASS_H_ -#define LIBSPIRV_OPT_INST_DEBUG_PRINTF_PASS_H_ - -#include "instrument_pass.h" - -namespace spvtools { -namespace opt { - -// This class/pass is designed to support the debug printf GPU-assisted layer -// of https://github.com/KhronosGroup/Vulkan-ValidationLayers. Its internal and -// external design may change as the layer evolves. -class InstDebugPrintfPass : public InstrumentPass { - public: - // For test harness only - InstDebugPrintfPass() : InstrumentPass(7, 23, kInstValidationIdDebugPrintf) {} - // For all other interfaces - InstDebugPrintfPass(uint32_t desc_set, uint32_t shader_id) - : InstrumentPass(desc_set, shader_id, kInstValidationIdDebugPrintf) {} - - ~InstDebugPrintfPass() override = default; - - // See optimizer.hpp for pass user documentation. - Status Process() override; - - const char* name() const override { return "inst-printf-pass"; } - - private: - // Generate instructions for OpDebugPrintf. - // - // If |ref_inst_itr| is an OpDebugPrintf, return in |new_blocks| the result - // of replacing it with buffer write instructions within its block at - // |ref_block_itr|. The instructions write a record to the printf - // output buffer stream including |function_idx, instruction_idx, stage_idx| - // and removes the OpDebugPrintf. The block at |ref_block_itr| can just be - // replaced with the block in |new_blocks|. Besides the buffer writes, this - // block will comprise all instructions preceding and following - // |ref_inst_itr|. - // - // This function is designed to be passed to - // InstrumentPass::InstProcessEntryPointCallTree(), which applies the - // function to each instruction in a module and replaces the instruction - // if warranted. - // - // This instrumentation function utilizes GenDebugStreamWrite() to write its - // error records. The validation-specific part of the error record will - // consist of a uint32 which is the id of the format string plus a sequence - // of uint32s representing the values of the remaining operands of the - // DebugPrintf. - void GenDebugPrintfCode(BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, - uint32_t stage_idx, - std::vector>* new_blocks); - - // Generate a sequence of uint32 instructions in |builder| (if necessary) - // representing the value of |val_inst|, which must be a buffer pointer, a - // uint64, or a scalar or vector of type uint32, float32 or float16. Append - // the ids of all values to the end of |val_ids|. - void GenOutputValues(Instruction* val_inst, std::vector* val_ids, - InstructionBuilder* builder); - - // Generate instructions to write a record containing the operands of - // |printf_inst| arguments to printf buffer, adding new code to the end of - // the last block in |new_blocks|. Kill OpDebugPrintf instruction. - void GenOutputCode(Instruction* printf_inst, uint32_t stage_idx, - std::vector>* new_blocks); - - // Initialize state for instrumenting bindless checking - void InitializeInstDebugPrintf(); - - // Apply GenDebugPrintfCode to every instruction in module. - Pass::Status ProcessImpl(); - - uint32_t ext_inst_printf_id_; -}; - -} // namespace opt -} // namespace spvtools - -#endif // LIBSPIRV_OPT_INST_DEBUG_PRINTF_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/instruction.cpp b/third_party/spirv-tools/source/opt/instruction.cpp index ece6baf92f..aa4ae26b64 100644 --- a/third_party/spirv-tools/source/opt/instruction.cpp +++ b/third_party/spirv-tools/source/opt/instruction.cpp @@ -751,7 +751,7 @@ bool Instruction::IsOpaqueType() const { } bool Instruction::IsFoldable() const { - return IsFoldableByFoldScalar() || + return IsFoldableByFoldScalar() || IsFoldableByFoldVector() || context()->get_instruction_folder().HasConstFoldingRule(this); } @@ -762,7 +762,7 @@ bool Instruction::IsFoldableByFoldScalar() const { } Instruction* type = context()->get_def_use_mgr()->GetDef(type_id()); - if (!folder.IsFoldableType(type)) { + if (!folder.IsFoldableScalarType(type)) { return false; } @@ -773,7 +773,29 @@ bool Instruction::IsFoldableByFoldScalar() const { Instruction* def_inst = context()->get_def_use_mgr()->GetDef(*op_id); Instruction* def_inst_type = context()->get_def_use_mgr()->GetDef(def_inst->type_id()); - return folder.IsFoldableType(def_inst_type); + return folder.IsFoldableScalarType(def_inst_type); + }); +} + +bool Instruction::IsFoldableByFoldVector() const { + const InstructionFolder& folder = context()->get_instruction_folder(); + if (!folder.IsFoldableOpcode(opcode())) { + return false; + } + + Instruction* type = context()->get_def_use_mgr()->GetDef(type_id()); + if (!folder.IsFoldableVectorType(type)) { + return false; + } + + // Even if the type of the instruction is foldable, its operands may not be + // foldable (e.g., comparisons of 64bit types). Check that all operand types + // are foldable before accepting the instruction. + return WhileEachInOperand([&folder, this](const uint32_t* op_id) { + Instruction* def_inst = context()->get_def_use_mgr()->GetDef(*op_id); + Instruction* def_inst_type = + context()->get_def_use_mgr()->GetDef(def_inst->type_id()); + return folder.IsFoldableVectorType(def_inst_type); }); } diff --git a/third_party/spirv-tools/source/opt/instruction.h b/third_party/spirv-tools/source/opt/instruction.h index 22736bff89..c2617fba54 100644 --- a/third_party/spirv-tools/source/opt/instruction.h +++ b/third_party/spirv-tools/source/opt/instruction.h @@ -294,6 +294,8 @@ class Instruction : public utils::IntrusiveNodeBase { // It is the responsibility of the caller to make sure // that the instruction remains valid. inline void AddOperand(Operand&& operand); + // Adds a copy of |operand| to the list of operands of this instruction. + inline void AddOperand(const Operand& operand); // Gets the |index|-th logical operand as a single SPIR-V word. This method is // not expected to be used with logical operands consisting of multiple SPIR-V // words. @@ -522,6 +524,10 @@ class Instruction : public utils::IntrusiveNodeBase { // constant value by |FoldScalar|. bool IsFoldableByFoldScalar() const; + // Returns true if |this| is an instruction which could be folded into a + // constant value by |FoldVector|. + bool IsFoldableByFoldVector() const; + // Returns true if we are allowed to fold or otherwise manipulate the // instruction that defines |id| in the given context. This includes not // handling NaN values. @@ -676,6 +682,10 @@ inline void Instruction::AddOperand(Operand&& operand) { operands_.push_back(std::move(operand)); } +inline void Instruction::AddOperand(const Operand& operand) { + operands_.push_back(operand); +} + inline void Instruction::SetInOperand(uint32_t index, Operand::OperandData&& data) { SetOperand(index + TypeResultIdCount(), std::move(data)); @@ -906,7 +916,7 @@ bool Instruction::IsAtomicWithLoad() const { bool Instruction::IsAtomicOp() const { return spvOpcodeIsAtomicOp(opcode()); } bool Instruction::IsConstant() const { - return IsCompileTimeConstantInst(opcode()); + return IsConstantInst(opcode()) && !IsSpecConstantInst(opcode()); } } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/instrument_pass.cpp b/third_party/spirv-tools/source/opt/instrument_pass.cpp deleted file mode 100644 index 441d943f70..0000000000 --- a/third_party/spirv-tools/source/opt/instrument_pass.cpp +++ /dev/null @@ -1,1191 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// Copyright (c) 2018 Valve Corporation -// Copyright (c) 2018 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "instrument_pass.h" - -#include "source/cfa.h" -#include "source/spirv_constant.h" - -namespace spvtools { -namespace opt { -namespace { -// Common Parameter Positions -constexpr int kInstCommonParamInstIdx = 0; -constexpr int kInstCommonParamCnt = 1; -// Indices of operands in SPIR-V instructions -constexpr int kEntryPointFunctionIdInIdx = 1; -} // namespace - -void InstrumentPass::MovePreludeCode( - BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, - std::unique_ptr* new_blk_ptr) { - same_block_pre_.clear(); - same_block_post_.clear(); - // Initialize new block. Reuse label from original block. - new_blk_ptr->reset(new BasicBlock(std::move(ref_block_itr->GetLabel()))); - // Move contents of original ref block up to ref instruction. - for (auto cii = ref_block_itr->begin(); cii != ref_inst_itr; - cii = ref_block_itr->begin()) { - Instruction* inst = &*cii; - inst->RemoveFromList(); - std::unique_ptr mv_ptr(inst); - // Remember same-block ops for possible regeneration. - if (IsSameBlockOp(&*mv_ptr)) { - auto* sb_inst_ptr = mv_ptr.get(); - same_block_pre_[mv_ptr->result_id()] = sb_inst_ptr; - } - (*new_blk_ptr)->AddInstruction(std::move(mv_ptr)); - } -} - -void InstrumentPass::MovePostludeCode( - UptrVectorIterator ref_block_itr, BasicBlock* new_blk_ptr) { - // new_blk_ptr->reset(new BasicBlock(NewLabel(ref_block_itr->id()))); - // Move contents of original ref block. - for (auto cii = ref_block_itr->begin(); cii != ref_block_itr->end(); - cii = ref_block_itr->begin()) { - Instruction* inst = &*cii; - inst->RemoveFromList(); - std::unique_ptr mv_inst(inst); - // Regenerate any same-block instruction that has not been seen in the - // current block. - if (same_block_pre_.size() > 0) { - CloneSameBlockOps(&mv_inst, &same_block_post_, &same_block_pre_, - new_blk_ptr); - // Remember same-block ops in this block. - if (IsSameBlockOp(&*mv_inst)) { - const uint32_t rid = mv_inst->result_id(); - same_block_post_[rid] = rid; - } - } - new_blk_ptr->AddInstruction(std::move(mv_inst)); - } -} - -std::unique_ptr InstrumentPass::NewLabel(uint32_t label_id) { - std::unique_ptr newLabel( - new Instruction(context(), spv::Op::OpLabel, 0, label_id, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*newLabel); - return newLabel; -} - -std::unique_ptr InstrumentPass::NewName( - uint32_t id, const std::string& name_str) { - std::unique_ptr new_name(new Instruction( - context(), spv::Op::OpName, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_ID, {id}}, - {SPV_OPERAND_TYPE_LITERAL_STRING, utils::MakeVector(name_str)}})); - - return new_name; -} - -std::unique_ptr InstrumentPass::NewGlobalName( - uint32_t id, const std::string& name_str) { - std::string prefixed_name; - switch (validation_id_) { - case kInstValidationIdBindless: - prefixed_name = "inst_bindless_"; - break; - case kInstValidationIdBuffAddr: - prefixed_name = "inst_buff_addr_"; - break; - case kInstValidationIdDebugPrintf: - prefixed_name = "inst_printf_"; - break; - default: - assert(false); // add new instrumentation pass here - prefixed_name = "inst_pass_"; - break; - } - prefixed_name += name_str; - return NewName(id, prefixed_name); -} - -std::unique_ptr InstrumentPass::NewMemberName( - uint32_t id, uint32_t member_index, const std::string& name_str) { - std::unique_ptr new_name(new Instruction( - context(), spv::Op::OpMemberName, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_ID, {id}}, - {SPV_OPERAND_TYPE_LITERAL_INTEGER, {member_index}}, - {SPV_OPERAND_TYPE_LITERAL_STRING, utils::MakeVector(name_str)}})); - - return new_name; -} - -uint32_t InstrumentPass::Gen32BitCvtCode(uint32_t val_id, - InstructionBuilder* builder) { - // Convert integer value to 32-bit if necessary - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - uint32_t val_ty_id = get_def_use_mgr()->GetDef(val_id)->type_id(); - analysis::Integer* val_ty = type_mgr->GetType(val_ty_id)->AsInteger(); - if (val_ty->width() == 32) return val_id; - bool is_signed = val_ty->IsSigned(); - analysis::Integer val_32b_ty(32, is_signed); - analysis::Type* val_32b_reg_ty = type_mgr->GetRegisteredType(&val_32b_ty); - uint32_t val_32b_reg_ty_id = type_mgr->GetId(val_32b_reg_ty); - if (is_signed) - return builder->AddUnaryOp(val_32b_reg_ty_id, spv::Op::OpSConvert, val_id) - ->result_id(); - else - return builder->AddUnaryOp(val_32b_reg_ty_id, spv::Op::OpUConvert, val_id) - ->result_id(); -} - -uint32_t InstrumentPass::GenUintCastCode(uint32_t val_id, - InstructionBuilder* builder) { - // Convert value to 32-bit if necessary - uint32_t val_32b_id = Gen32BitCvtCode(val_id, builder); - // Cast value to unsigned if necessary - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - uint32_t val_ty_id = get_def_use_mgr()->GetDef(val_32b_id)->type_id(); - analysis::Integer* val_ty = type_mgr->GetType(val_ty_id)->AsInteger(); - if (!val_ty->IsSigned()) return val_32b_id; - return builder->AddUnaryOp(GetUintId(), spv::Op::OpBitcast, val_32b_id) - ->result_id(); -} - -void InstrumentPass::GenDebugOutputFieldCode(uint32_t base_offset_id, - uint32_t field_offset, - uint32_t field_value_id, - InstructionBuilder* builder) { - // Cast value to 32-bit unsigned if necessary - uint32_t val_id = GenUintCastCode(field_value_id, builder); - // Store value - Instruction* data_idx_inst = - builder->AddBinaryOp(GetUintId(), spv::Op::OpIAdd, base_offset_id, - builder->GetUintConstantId(field_offset)); - uint32_t buf_id = GetOutputBufferId(); - uint32_t buf_uint_ptr_id = GetOutputBufferPtrId(); - Instruction* achain_inst = - builder->AddTernaryOp(buf_uint_ptr_id, spv::Op::OpAccessChain, buf_id, - builder->GetUintConstantId(kDebugOutputDataOffset), - data_idx_inst->result_id()); - (void)builder->AddBinaryOp(0, spv::Op::OpStore, achain_inst->result_id(), - val_id); -} - -void InstrumentPass::GenCommonStreamWriteCode(uint32_t record_sz, - uint32_t inst_id, - uint32_t stage_idx, - uint32_t base_offset_id, - InstructionBuilder* builder) { - // Store record size - GenDebugOutputFieldCode(base_offset_id, kInstCommonOutSize, - builder->GetUintConstantId(record_sz), builder); - // Store Shader Id - GenDebugOutputFieldCode(base_offset_id, kInstCommonOutShaderId, - builder->GetUintConstantId(shader_id_), builder); - // Store Instruction Idx - GenDebugOutputFieldCode(base_offset_id, kInstCommonOutInstructionIdx, inst_id, - builder); - // Store Stage Idx - GenDebugOutputFieldCode(base_offset_id, kInstCommonOutStageIdx, - builder->GetUintConstantId(stage_idx), builder); -} - -void InstrumentPass::GenFragCoordEltDebugOutputCode( - uint32_t base_offset_id, uint32_t uint_frag_coord_id, uint32_t element, - InstructionBuilder* builder) { - Instruction* element_val_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, uint_frag_coord_id, element); - GenDebugOutputFieldCode(base_offset_id, kInstFragOutFragCoordX + element, - element_val_inst->result_id(), builder); -} - -uint32_t InstrumentPass::GenVarLoad(uint32_t var_id, - InstructionBuilder* builder) { - Instruction* var_inst = get_def_use_mgr()->GetDef(var_id); - uint32_t type_id = GetPointeeTypeId(var_inst); - Instruction* load_inst = - builder->AddUnaryOp(type_id, spv::Op::OpLoad, var_id); - return load_inst->result_id(); -} - -void InstrumentPass::GenBuiltinOutputCode(uint32_t builtin_id, - uint32_t builtin_off, - uint32_t base_offset_id, - InstructionBuilder* builder) { - // Load and store builtin - uint32_t load_id = GenVarLoad(builtin_id, builder); - GenDebugOutputFieldCode(base_offset_id, builtin_off, load_id, builder); -} - -void InstrumentPass::GenStageStreamWriteCode(uint32_t stage_idx, - uint32_t base_offset_id, - InstructionBuilder* builder) { - // TODO(greg-lunarg): Add support for all stages - switch (spv::ExecutionModel(stage_idx)) { - case spv::ExecutionModel::Vertex: { - // Load and store VertexId and InstanceId - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::VertexIndex)), - kInstVertOutVertexIndex, base_offset_id, builder); - GenBuiltinOutputCode(context()->GetBuiltinInputVarId( - uint32_t(spv::BuiltIn::InstanceIndex)), - kInstVertOutInstanceIndex, base_offset_id, builder); - } break; - case spv::ExecutionModel::GLCompute: - case spv::ExecutionModel::TaskNV: - case spv::ExecutionModel::MeshNV: - case spv::ExecutionModel::TaskEXT: - case spv::ExecutionModel::MeshEXT: { - // Load and store GlobalInvocationId. - uint32_t load_id = GenVarLoad(context()->GetBuiltinInputVarId(uint32_t( - spv::BuiltIn::GlobalInvocationId)), - builder); - Instruction* x_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, load_id, 0); - Instruction* y_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, load_id, 1); - Instruction* z_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, load_id, 2); - GenDebugOutputFieldCode(base_offset_id, kInstCompOutGlobalInvocationIdX, - x_inst->result_id(), builder); - GenDebugOutputFieldCode(base_offset_id, kInstCompOutGlobalInvocationIdY, - y_inst->result_id(), builder); - GenDebugOutputFieldCode(base_offset_id, kInstCompOutGlobalInvocationIdZ, - z_inst->result_id(), builder); - } break; - case spv::ExecutionModel::Geometry: { - // Load and store PrimitiveId and InvocationId. - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::PrimitiveId)), - kInstGeomOutPrimitiveId, base_offset_id, builder); - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::InvocationId)), - kInstGeomOutInvocationId, base_offset_id, builder); - } break; - case spv::ExecutionModel::TessellationControl: { - // Load and store InvocationId and PrimitiveId - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::InvocationId)), - kInstTessCtlOutInvocationId, base_offset_id, builder); - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::PrimitiveId)), - kInstTessCtlOutPrimitiveId, base_offset_id, builder); - } break; - case spv::ExecutionModel::TessellationEvaluation: { - // Load and store PrimitiveId and TessCoord.uv - GenBuiltinOutputCode( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::PrimitiveId)), - kInstTessEvalOutPrimitiveId, base_offset_id, builder); - uint32_t load_id = GenVarLoad( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::TessCoord)), - builder); - Instruction* uvec3_cast_inst = - builder->AddUnaryOp(GetVec3UintId(), spv::Op::OpBitcast, load_id); - uint32_t uvec3_cast_id = uvec3_cast_inst->result_id(); - Instruction* u_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, uvec3_cast_id, 0); - Instruction* v_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, uvec3_cast_id, 1); - GenDebugOutputFieldCode(base_offset_id, kInstTessEvalOutTessCoordU, - u_inst->result_id(), builder); - GenDebugOutputFieldCode(base_offset_id, kInstTessEvalOutTessCoordV, - v_inst->result_id(), builder); - } break; - case spv::ExecutionModel::Fragment: { - // Load FragCoord and convert to Uint - Instruction* frag_coord_inst = builder->AddUnaryOp( - GetVec4FloatId(), spv::Op::OpLoad, - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::FragCoord))); - Instruction* uint_frag_coord_inst = builder->AddUnaryOp( - GetVec4UintId(), spv::Op::OpBitcast, frag_coord_inst->result_id()); - for (uint32_t u = 0; u < 2u; ++u) - GenFragCoordEltDebugOutputCode( - base_offset_id, uint_frag_coord_inst->result_id(), u, builder); - } break; - case spv::ExecutionModel::RayGenerationNV: - case spv::ExecutionModel::IntersectionNV: - case spv::ExecutionModel::AnyHitNV: - case spv::ExecutionModel::ClosestHitNV: - case spv::ExecutionModel::MissNV: - case spv::ExecutionModel::CallableNV: { - // Load and store LaunchIdNV. - uint32_t launch_id = GenVarLoad( - context()->GetBuiltinInputVarId(uint32_t(spv::BuiltIn::LaunchIdNV)), - builder); - Instruction* x_launch_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, launch_id, 0); - Instruction* y_launch_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, launch_id, 1); - Instruction* z_launch_inst = builder->AddIdLiteralOp( - GetUintId(), spv::Op::OpCompositeExtract, launch_id, 2); - GenDebugOutputFieldCode(base_offset_id, kInstRayTracingOutLaunchIdX, - x_launch_inst->result_id(), builder); - GenDebugOutputFieldCode(base_offset_id, kInstRayTracingOutLaunchIdY, - y_launch_inst->result_id(), builder); - GenDebugOutputFieldCode(base_offset_id, kInstRayTracingOutLaunchIdZ, - z_launch_inst->result_id(), builder); - } break; - default: { assert(false && "unsupported stage"); } break; - } -} - -void InstrumentPass::GenDebugStreamWrite( - uint32_t instruction_idx, uint32_t stage_idx, - const std::vector& validation_ids, InstructionBuilder* builder) { - // Call debug output function. Pass func_idx, instruction_idx and - // validation ids as args. - uint32_t val_id_cnt = static_cast(validation_ids.size()); - uint32_t output_func_id = GetStreamWriteFunctionId(stage_idx, val_id_cnt); - std::vector args = {output_func_id, - builder->GetUintConstantId(instruction_idx)}; - (void)args.insert(args.end(), validation_ids.begin(), validation_ids.end()); - (void)builder->AddNaryOp(GetVoidId(), spv::Op::OpFunctionCall, args); -} - -bool InstrumentPass::AllConstant(const std::vector& ids) { - for (auto& id : ids) { - Instruction* id_inst = context()->get_def_use_mgr()->GetDef(id); - if (!spvOpcodeIsConstant(id_inst->opcode())) return false; - } - return true; -} - -uint32_t InstrumentPass::GenDebugDirectRead( - const std::vector& offset_ids, InstructionBuilder* ref_builder) { - // Call debug input function. Pass func_idx and offset ids as args. - uint32_t off_id_cnt = static_cast(offset_ids.size()); - uint32_t input_func_id = GetDirectReadFunctionId(off_id_cnt); - std::vector args = {input_func_id}; - (void)args.insert(args.end(), offset_ids.begin(), offset_ids.end()); - // If optimizing direct reads and the call has already been generated, - // use its result - if (opt_direct_reads_) { - uint32_t res_id = call2id_[args]; - if (res_id != 0) return res_id; - } - // If the offsets are all constants, the call can be moved to the first block - // of the function where its result can be reused. One example where this is - // profitable is for uniform buffer references, of which there are often many. - InstructionBuilder builder(ref_builder->GetContext(), - &*ref_builder->GetInsertPoint(), - ref_builder->GetPreservedAnalysis()); - bool insert_in_first_block = opt_direct_reads_ && AllConstant(offset_ids); - if (insert_in_first_block) { - Instruction* insert_before = &*curr_func_->begin()->tail(); - builder.SetInsertPoint(insert_before); - } - uint32_t res_id = - builder.AddNaryOp(GetUintId(), spv::Op::OpFunctionCall, args) - ->result_id(); - if (insert_in_first_block) call2id_[args] = res_id; - return res_id; -} - -bool InstrumentPass::IsSameBlockOp(const Instruction* inst) const { - return inst->opcode() == spv::Op::OpSampledImage || - inst->opcode() == spv::Op::OpImage; -} - -void InstrumentPass::CloneSameBlockOps( - std::unique_ptr* inst, - std::unordered_map* same_blk_post, - std::unordered_map* same_blk_pre, - BasicBlock* block_ptr) { - bool changed = false; - (*inst)->ForEachInId([&same_blk_post, &same_blk_pre, &block_ptr, &changed, - this](uint32_t* iid) { - const auto map_itr = (*same_blk_post).find(*iid); - if (map_itr == (*same_blk_post).end()) { - const auto map_itr2 = (*same_blk_pre).find(*iid); - if (map_itr2 != (*same_blk_pre).end()) { - // Clone pre-call same-block ops, map result id. - const Instruction* in_inst = map_itr2->second; - std::unique_ptr sb_inst(in_inst->Clone(context())); - const uint32_t rid = sb_inst->result_id(); - const uint32_t nid = this->TakeNextId(); - get_decoration_mgr()->CloneDecorations(rid, nid); - sb_inst->SetResultId(nid); - get_def_use_mgr()->AnalyzeInstDefUse(&*sb_inst); - (*same_blk_post)[rid] = nid; - *iid = nid; - changed = true; - CloneSameBlockOps(&sb_inst, same_blk_post, same_blk_pre, block_ptr); - block_ptr->AddInstruction(std::move(sb_inst)); - } - } else { - // Reset same-block op operand if necessary - if (*iid != map_itr->second) { - *iid = map_itr->second; - changed = true; - } - } - }); - if (changed) get_def_use_mgr()->AnalyzeInstUse(&**inst); -} - -void InstrumentPass::UpdateSucceedingPhis( - std::vector>& new_blocks) { - const auto first_blk = new_blocks.begin(); - const auto last_blk = new_blocks.end() - 1; - const uint32_t first_id = (*first_blk)->id(); - const uint32_t last_id = (*last_blk)->id(); - const BasicBlock& const_last_block = *last_blk->get(); - const_last_block.ForEachSuccessorLabel( - [&first_id, &last_id, this](const uint32_t succ) { - BasicBlock* sbp = this->id2block_[succ]; - sbp->ForEachPhiInst([&first_id, &last_id, this](Instruction* phi) { - bool changed = false; - phi->ForEachInId([&first_id, &last_id, &changed](uint32_t* id) { - if (*id == first_id) { - *id = last_id; - changed = true; - } - }); - if (changed) get_def_use_mgr()->AnalyzeInstUse(phi); - }); - }); -} - -uint32_t InstrumentPass::GetOutputBufferPtrId() { - if (output_buffer_ptr_id_ == 0) { - output_buffer_ptr_id_ = context()->get_type_mgr()->FindPointerToType( - GetUintId(), spv::StorageClass::StorageBuffer); - } - return output_buffer_ptr_id_; -} - -uint32_t InstrumentPass::GetInputBufferTypeId() { - return (validation_id_ == kInstValidationIdBuffAddr) ? GetUint64Id() - : GetUintId(); -} - -uint32_t InstrumentPass::GetInputBufferPtrId() { - if (input_buffer_ptr_id_ == 0) { - input_buffer_ptr_id_ = context()->get_type_mgr()->FindPointerToType( - GetInputBufferTypeId(), spv::StorageClass::StorageBuffer); - } - return input_buffer_ptr_id_; -} - -uint32_t InstrumentPass::GetOutputBufferBinding() { - switch (validation_id_) { - case kInstValidationIdBindless: - return kDebugOutputBindingStream; - case kInstValidationIdBuffAddr: - return kDebugOutputBindingStream; - case kInstValidationIdDebugPrintf: - return kDebugOutputPrintfStream; - default: - assert(false && "unexpected validation id"); - } - return 0; -} - -uint32_t InstrumentPass::GetInputBufferBinding() { - switch (validation_id_) { - case kInstValidationIdBindless: - return kDebugInputBindingBindless; - case kInstValidationIdBuffAddr: - return kDebugInputBindingBuffAddr; - default: - assert(false && "unexpected validation id"); - } - return 0; -} - -analysis::Type* InstrumentPass::GetUintXRuntimeArrayType( - uint32_t width, analysis::Type** rarr_ty) { - if (*rarr_ty == nullptr) { - analysis::DecorationManager* deco_mgr = get_decoration_mgr(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Integer uint_ty(width, false); - analysis::Type* reg_uint_ty = type_mgr->GetRegisteredType(&uint_ty); - analysis::RuntimeArray uint_rarr_ty_tmp(reg_uint_ty); - *rarr_ty = type_mgr->GetRegisteredType(&uint_rarr_ty_tmp); - uint32_t uint_arr_ty_id = type_mgr->GetTypeInstruction(*rarr_ty); - // By the Vulkan spec, a pre-existing RuntimeArray of uint must be part of - // a block, and will therefore be decorated with an ArrayStride. Therefore - // the undecorated type returned here will not be pre-existing and can - // safely be decorated. Since this type is now decorated, it is out of - // sync with the TypeManager and therefore the TypeManager must be - // invalidated after this pass. - assert(context()->get_def_use_mgr()->NumUses(uint_arr_ty_id) == 0 && - "used RuntimeArray type returned"); - deco_mgr->AddDecorationVal( - uint_arr_ty_id, uint32_t(spv::Decoration::ArrayStride), width / 8u); - } - return *rarr_ty; -} - -analysis::Type* InstrumentPass::GetUintRuntimeArrayType(uint32_t width) { - analysis::Type** rarr_ty = - (width == 64) ? &uint64_rarr_ty_ : &uint32_rarr_ty_; - return GetUintXRuntimeArrayType(width, rarr_ty); -} - -void InstrumentPass::AddStorageBufferExt() { - if (storage_buffer_ext_defined_) return; - if (!get_feature_mgr()->HasExtension(kSPV_KHR_storage_buffer_storage_class)) { - context()->AddExtension("SPV_KHR_storage_buffer_storage_class"); - } - storage_buffer_ext_defined_ = true; -} - -// Return id for output buffer -uint32_t InstrumentPass::GetOutputBufferId() { - if (output_buffer_id_ == 0) { - // If not created yet, create one - analysis::DecorationManager* deco_mgr = get_decoration_mgr(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Type* reg_uint_rarr_ty = GetUintRuntimeArrayType(32); - analysis::Integer uint_ty(32, false); - analysis::Type* reg_uint_ty = type_mgr->GetRegisteredType(&uint_ty); - analysis::Struct buf_ty({reg_uint_ty, reg_uint_ty, reg_uint_rarr_ty}); - analysis::Type* reg_buf_ty = type_mgr->GetRegisteredType(&buf_ty); - uint32_t obufTyId = type_mgr->GetTypeInstruction(reg_buf_ty); - // By the Vulkan spec, a pre-existing struct containing a RuntimeArray - // must be a block, and will therefore be decorated with Block. Therefore - // the undecorated type returned here will not be pre-existing and can - // safely be decorated. Since this type is now decorated, it is out of - // sync with the TypeManager and therefore the TypeManager must be - // invalidated after this pass. - assert(context()->get_def_use_mgr()->NumUses(obufTyId) == 0 && - "used struct type returned"); - deco_mgr->AddDecoration(obufTyId, uint32_t(spv::Decoration::Block)); - deco_mgr->AddMemberDecoration(obufTyId, kDebugOutputFlagsOffset, - uint32_t(spv::Decoration::Offset), 0); - deco_mgr->AddMemberDecoration(obufTyId, kDebugOutputSizeOffset, - uint32_t(spv::Decoration::Offset), 4); - deco_mgr->AddMemberDecoration(obufTyId, kDebugOutputDataOffset, - uint32_t(spv::Decoration::Offset), 8); - uint32_t obufTyPtrId_ = - type_mgr->FindPointerToType(obufTyId, spv::StorageClass::StorageBuffer); - output_buffer_id_ = TakeNextId(); - std::unique_ptr newVarOp(new Instruction( - context(), spv::Op::OpVariable, obufTyPtrId_, output_buffer_id_, - {{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::StorageClass::StorageBuffer)}}})); - context()->AddGlobalValue(std::move(newVarOp)); - context()->AddDebug2Inst(NewGlobalName(obufTyId, "OutputBuffer")); - context()->AddDebug2Inst(NewMemberName(obufTyId, 0, "flags")); - context()->AddDebug2Inst(NewMemberName(obufTyId, 1, "written_count")); - context()->AddDebug2Inst(NewMemberName(obufTyId, 2, "data")); - context()->AddDebug2Inst(NewGlobalName(output_buffer_id_, "output_buffer")); - deco_mgr->AddDecorationVal( - output_buffer_id_, uint32_t(spv::Decoration::DescriptorSet), desc_set_); - deco_mgr->AddDecorationVal(output_buffer_id_, - uint32_t(spv::Decoration::Binding), - GetOutputBufferBinding()); - AddStorageBufferExt(); - if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4)) { - // Add the new buffer to all entry points. - for (auto& entry : get_module()->entry_points()) { - entry.AddOperand({SPV_OPERAND_TYPE_ID, {output_buffer_id_}}); - context()->AnalyzeUses(&entry); - } - } - } - return output_buffer_id_; -} - -uint32_t InstrumentPass::GetInputBufferId() { - if (input_buffer_id_ == 0) { - // If not created yet, create one - analysis::DecorationManager* deco_mgr = get_decoration_mgr(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - uint32_t width = (validation_id_ == kInstValidationIdBuffAddr) ? 64u : 32u; - analysis::Type* reg_uint_rarr_ty = GetUintRuntimeArrayType(width); - analysis::Struct buf_ty({reg_uint_rarr_ty}); - analysis::Type* reg_buf_ty = type_mgr->GetRegisteredType(&buf_ty); - uint32_t ibufTyId = type_mgr->GetTypeInstruction(reg_buf_ty); - // By the Vulkan spec, a pre-existing struct containing a RuntimeArray - // must be a block, and will therefore be decorated with Block. Therefore - // the undecorated type returned here will not be pre-existing and can - // safely be decorated. Since this type is now decorated, it is out of - // sync with the TypeManager and therefore the TypeManager must be - // invalidated after this pass. - assert(context()->get_def_use_mgr()->NumUses(ibufTyId) == 0 && - "used struct type returned"); - deco_mgr->AddDecoration(ibufTyId, uint32_t(spv::Decoration::Block)); - deco_mgr->AddMemberDecoration(ibufTyId, 0, - uint32_t(spv::Decoration::Offset), 0); - uint32_t ibufTyPtrId_ = - type_mgr->FindPointerToType(ibufTyId, spv::StorageClass::StorageBuffer); - input_buffer_id_ = TakeNextId(); - std::unique_ptr newVarOp(new Instruction( - context(), spv::Op::OpVariable, ibufTyPtrId_, input_buffer_id_, - {{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::StorageClass::StorageBuffer)}}})); - context()->AddGlobalValue(std::move(newVarOp)); - context()->AddDebug2Inst(NewGlobalName(ibufTyId, "InputBuffer")); - context()->AddDebug2Inst(NewMemberName(ibufTyId, 0, "data")); - context()->AddDebug2Inst(NewGlobalName(input_buffer_id_, "input_buffer")); - deco_mgr->AddDecorationVal( - input_buffer_id_, uint32_t(spv::Decoration::DescriptorSet), desc_set_); - deco_mgr->AddDecorationVal(input_buffer_id_, - uint32_t(spv::Decoration::Binding), - GetInputBufferBinding()); - AddStorageBufferExt(); - if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4)) { - // Add the new buffer to all entry points. - for (auto& entry : get_module()->entry_points()) { - entry.AddOperand({SPV_OPERAND_TYPE_ID, {input_buffer_id_}}); - context()->AnalyzeUses(&entry); - } - } - } - return input_buffer_id_; -} - -uint32_t InstrumentPass::GetFloatId() { - if (float_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Float float_ty(32); - analysis::Type* reg_float_ty = type_mgr->GetRegisteredType(&float_ty); - float_id_ = type_mgr->GetTypeInstruction(reg_float_ty); - } - return float_id_; -} - -uint32_t InstrumentPass::GetVec4FloatId() { - if (v4float_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Float float_ty(32); - analysis::Type* reg_float_ty = type_mgr->GetRegisteredType(&float_ty); - analysis::Vector v4float_ty(reg_float_ty, 4); - analysis::Type* reg_v4float_ty = type_mgr->GetRegisteredType(&v4float_ty); - v4float_id_ = type_mgr->GetTypeInstruction(reg_v4float_ty); - } - return v4float_id_; -} - -uint32_t InstrumentPass::GetUintId() { - if (uint_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Integer uint_ty(32, false); - analysis::Type* reg_uint_ty = type_mgr->GetRegisteredType(&uint_ty); - uint_id_ = type_mgr->GetTypeInstruction(reg_uint_ty); - } - return uint_id_; -} - -uint32_t InstrumentPass::GetUint64Id() { - if (uint64_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Integer uint64_ty(64, false); - analysis::Type* reg_uint64_ty = type_mgr->GetRegisteredType(&uint64_ty); - uint64_id_ = type_mgr->GetTypeInstruction(reg_uint64_ty); - } - return uint64_id_; -} - -uint32_t InstrumentPass::GetUint8Id() { - if (uint8_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Integer uint8_ty(8, false); - analysis::Type* reg_uint8_ty = type_mgr->GetRegisteredType(&uint8_ty); - uint8_id_ = type_mgr->GetTypeInstruction(reg_uint8_ty); - } - return uint8_id_; -} - -uint32_t InstrumentPass::GetVecUintId(uint32_t len) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Integer uint_ty(32, false); - analysis::Type* reg_uint_ty = type_mgr->GetRegisteredType(&uint_ty); - analysis::Vector v_uint_ty(reg_uint_ty, len); - analysis::Type* reg_v_uint_ty = type_mgr->GetRegisteredType(&v_uint_ty); - uint32_t v_uint_id = type_mgr->GetTypeInstruction(reg_v_uint_ty); - return v_uint_id; -} - -uint32_t InstrumentPass::GetVec4UintId() { - if (v4uint_id_ == 0) v4uint_id_ = GetVecUintId(4u); - return v4uint_id_; -} - -uint32_t InstrumentPass::GetVec3UintId() { - if (v3uint_id_ == 0) v3uint_id_ = GetVecUintId(3u); - return v3uint_id_; -} - -uint32_t InstrumentPass::GetBoolId() { - if (bool_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Bool bool_ty; - analysis::Type* reg_bool_ty = type_mgr->GetRegisteredType(&bool_ty); - bool_id_ = type_mgr->GetTypeInstruction(reg_bool_ty); - } - return bool_id_; -} - -uint32_t InstrumentPass::GetVoidId() { - if (void_id_ == 0) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - analysis::Void void_ty; - analysis::Type* reg_void_ty = type_mgr->GetRegisteredType(&void_ty); - void_id_ = type_mgr->GetTypeInstruction(reg_void_ty); - } - return void_id_; -} - -uint32_t InstrumentPass::GetStreamWriteFunctionId(uint32_t stage_idx, - uint32_t val_spec_param_cnt) { - // Total param count is common params plus validation-specific - // params - uint32_t param_cnt = kInstCommonParamCnt + val_spec_param_cnt; - if (param2output_func_id_[param_cnt] == 0) { - // Create function - param2output_func_id_[param_cnt] = TakeNextId(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - std::vector param_types; - for (uint32_t c = 0; c < param_cnt; ++c) - param_types.push_back(type_mgr->GetType(GetUintId())); - analysis::Function func_ty(type_mgr->GetType(GetVoidId()), param_types); - analysis::Type* reg_func_ty = type_mgr->GetRegisteredType(&func_ty); - std::unique_ptr func_inst( - new Instruction(get_module()->context(), spv::Op::OpFunction, - GetVoidId(), param2output_func_id_[param_cnt], - {{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::FunctionControlMask::MaskNone)}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, - {type_mgr->GetTypeInstruction(reg_func_ty)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_inst); - std::unique_ptr output_func = - MakeUnique(std::move(func_inst)); - // Add parameters - std::vector param_vec; - for (uint32_t c = 0; c < param_cnt; ++c) { - uint32_t pid = TakeNextId(); - param_vec.push_back(pid); - std::unique_ptr param_inst( - new Instruction(get_module()->context(), spv::Op::OpFunctionParameter, - GetUintId(), pid, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*param_inst); - output_func->AddParameter(std::move(param_inst)); - } - // Create first block - uint32_t test_blk_id = TakeNextId(); - std::unique_ptr test_label(NewLabel(test_blk_id)); - std::unique_ptr new_blk_ptr = - MakeUnique(std::move(test_label)); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - // Gen test if debug output buffer size will not be exceeded. - uint32_t val_spec_offset = kInstStageOutCnt; - uint32_t obuf_record_sz = val_spec_offset + val_spec_param_cnt; - uint32_t buf_id = GetOutputBufferId(); - uint32_t buf_uint_ptr_id = GetOutputBufferPtrId(); - Instruction* obuf_curr_sz_ac_inst = - builder.AddBinaryOp(buf_uint_ptr_id, spv::Op::OpAccessChain, buf_id, - builder.GetUintConstantId(kDebugOutputSizeOffset)); - // Fetch the current debug buffer written size atomically, adding the - // size of the record to be written. - uint32_t obuf_record_sz_id = builder.GetUintConstantId(obuf_record_sz); - uint32_t mask_none_id = - builder.GetUintConstantId(uint32_t(spv::MemoryAccessMask::MaskNone)); - uint32_t scope_invok_id = - builder.GetUintConstantId(uint32_t(spv::Scope::Invocation)); - Instruction* obuf_curr_sz_inst = builder.AddQuadOp( - GetUintId(), spv::Op::OpAtomicIAdd, obuf_curr_sz_ac_inst->result_id(), - scope_invok_id, mask_none_id, obuf_record_sz_id); - uint32_t obuf_curr_sz_id = obuf_curr_sz_inst->result_id(); - // Compute new written size - Instruction* obuf_new_sz_inst = - builder.AddBinaryOp(GetUintId(), spv::Op::OpIAdd, obuf_curr_sz_id, - builder.GetUintConstantId(obuf_record_sz)); - // Fetch the data bound - Instruction* obuf_bnd_inst = - builder.AddIdLiteralOp(GetUintId(), spv::Op::OpArrayLength, - GetOutputBufferId(), kDebugOutputDataOffset); - // Test that new written size is less than or equal to debug output - // data bound - Instruction* obuf_safe_inst = builder.AddBinaryOp( - GetBoolId(), spv::Op::OpULessThanEqual, obuf_new_sz_inst->result_id(), - obuf_bnd_inst->result_id()); - uint32_t merge_blk_id = TakeNextId(); - uint32_t write_blk_id = TakeNextId(); - std::unique_ptr merge_label(NewLabel(merge_blk_id)); - std::unique_ptr write_label(NewLabel(write_blk_id)); - (void)builder.AddConditionalBranch( - obuf_safe_inst->result_id(), write_blk_id, merge_blk_id, merge_blk_id, - uint32_t(spv::SelectionControlMask::MaskNone)); - // Close safety test block and gen write block - output_func->AddBasicBlock(std::move(new_blk_ptr)); - new_blk_ptr = MakeUnique(std::move(write_label)); - builder.SetInsertPoint(&*new_blk_ptr); - // Generate common and stage-specific debug record members - GenCommonStreamWriteCode(obuf_record_sz, param_vec[kInstCommonParamInstIdx], - stage_idx, obuf_curr_sz_id, &builder); - GenStageStreamWriteCode(stage_idx, obuf_curr_sz_id, &builder); - // Gen writes of validation specific data - for (uint32_t i = 0; i < val_spec_param_cnt; ++i) { - GenDebugOutputFieldCode(obuf_curr_sz_id, val_spec_offset + i, - param_vec[kInstCommonParamCnt + i], &builder); - } - // Close write block and gen merge block - (void)builder.AddBranch(merge_blk_id); - output_func->AddBasicBlock(std::move(new_blk_ptr)); - new_blk_ptr = MakeUnique(std::move(merge_label)); - builder.SetInsertPoint(&*new_blk_ptr); - // Close merge block and function and add function to module - (void)builder.AddNullaryOp(0, spv::Op::OpReturn); - output_func->AddBasicBlock(std::move(new_blk_ptr)); - std::unique_ptr func_end_inst(new Instruction( - get_module()->context(), spv::Op::OpFunctionEnd, 0, 0, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_end_inst); - output_func->SetFunctionEnd(std::move(func_end_inst)); - context()->AddFunction(std::move(output_func)); - - std::string name("stream_write_"); - name += std::to_string(param_cnt); - - context()->AddDebug2Inst( - NewGlobalName(param2output_func_id_[param_cnt], name)); - } - return param2output_func_id_[param_cnt]; -} - -uint32_t InstrumentPass::GetDirectReadFunctionId(uint32_t param_cnt) { - uint32_t func_id = param2input_func_id_[param_cnt]; - if (func_id != 0) return func_id; - // Create input function for param_cnt. - func_id = TakeNextId(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); - std::vector param_types; - for (uint32_t c = 0; c < param_cnt; ++c) - param_types.push_back(type_mgr->GetType(GetUintId())); - uint32_t ibuf_type_id = GetInputBufferTypeId(); - analysis::Function func_ty(type_mgr->GetType(ibuf_type_id), param_types); - analysis::Type* reg_func_ty = type_mgr->GetRegisteredType(&func_ty); - std::unique_ptr func_inst(new Instruction( - get_module()->context(), spv::Op::OpFunction, ibuf_type_id, func_id, - {{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, - {uint32_t(spv::FunctionControlMask::MaskNone)}}, - {spv_operand_type_t::SPV_OPERAND_TYPE_ID, - {type_mgr->GetTypeInstruction(reg_func_ty)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_inst); - std::unique_ptr input_func = - MakeUnique(std::move(func_inst)); - // Add parameters - std::vector param_vec; - for (uint32_t c = 0; c < param_cnt; ++c) { - uint32_t pid = TakeNextId(); - param_vec.push_back(pid); - std::unique_ptr param_inst( - new Instruction(get_module()->context(), spv::Op::OpFunctionParameter, - GetUintId(), pid, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*param_inst); - input_func->AddParameter(std::move(param_inst)); - } - // Create block - uint32_t blk_id = TakeNextId(); - std::unique_ptr blk_label(NewLabel(blk_id)); - std::unique_ptr new_blk_ptr = - MakeUnique(std::move(blk_label)); - InstructionBuilder builder( - context(), &*new_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - // For each offset parameter, generate new offset with parameter, adding last - // loaded value if it exists, and load value from input buffer at new offset. - // Return last loaded value. - uint32_t buf_id = GetInputBufferId(); - uint32_t buf_ptr_id = GetInputBufferPtrId(); - uint32_t last_value_id = 0; - for (uint32_t p = 0; p < param_cnt; ++p) { - uint32_t offset_id; - if (p == 0) { - offset_id = param_vec[0]; - } else { - if (ibuf_type_id != GetUintId()) { - Instruction* ucvt_inst = - builder.AddUnaryOp(GetUintId(), spv::Op::OpUConvert, last_value_id); - last_value_id = ucvt_inst->result_id(); - } - Instruction* offset_inst = builder.AddBinaryOp( - GetUintId(), spv::Op::OpIAdd, last_value_id, param_vec[p]); - offset_id = offset_inst->result_id(); - } - Instruction* ac_inst = builder.AddTernaryOp( - buf_ptr_id, spv::Op::OpAccessChain, buf_id, - builder.GetUintConstantId(kDebugInputDataOffset), offset_id); - Instruction* load_inst = - builder.AddUnaryOp(ibuf_type_id, spv::Op::OpLoad, ac_inst->result_id()); - last_value_id = load_inst->result_id(); - } - (void)builder.AddInstruction(MakeUnique( - context(), spv::Op::OpReturnValue, 0, 0, - std::initializer_list{{SPV_OPERAND_TYPE_ID, {last_value_id}}})); - // Close block and function and add function to module - input_func->AddBasicBlock(std::move(new_blk_ptr)); - std::unique_ptr func_end_inst(new Instruction( - get_module()->context(), spv::Op::OpFunctionEnd, 0, 0, {})); - get_def_use_mgr()->AnalyzeInstDefUse(&*func_end_inst); - input_func->SetFunctionEnd(std::move(func_end_inst)); - context()->AddFunction(std::move(input_func)); - - std::string name("direct_read_"); - name += std::to_string(param_cnt); - context()->AddDebug2Inst(NewGlobalName(func_id, name)); - - param2input_func_id_[param_cnt] = func_id; - return func_id; -} - -void InstrumentPass::SplitBlock( - BasicBlock::iterator inst_itr, UptrVectorIterator block_itr, - std::vector>* new_blocks) { - // Make sure def/use analysis is done before we start moving instructions - // out of function - (void)get_def_use_mgr(); - // Move original block's preceding instructions into first new block - std::unique_ptr first_blk_ptr; - MovePreludeCode(inst_itr, block_itr, &first_blk_ptr); - InstructionBuilder builder( - context(), &*first_blk_ptr, - IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); - uint32_t split_blk_id = TakeNextId(); - std::unique_ptr split_label(NewLabel(split_blk_id)); - (void)builder.AddBranch(split_blk_id); - new_blocks->push_back(std::move(first_blk_ptr)); - // Move remaining instructions into split block and add to new blocks - std::unique_ptr split_blk_ptr( - new BasicBlock(std::move(split_label))); - MovePostludeCode(block_itr, &*split_blk_ptr); - new_blocks->push_back(std::move(split_blk_ptr)); -} - -bool InstrumentPass::InstrumentFunction(Function* func, uint32_t stage_idx, - InstProcessFunction& pfn) { - curr_func_ = func; - call2id_.clear(); - bool first_block_split = false; - bool modified = false; - // Apply instrumentation function to each instruction. - // Using block iterators here because of block erasures and insertions. - std::vector> new_blks; - for (auto bi = func->begin(); bi != func->end(); ++bi) { - for (auto ii = bi->begin(); ii != bi->end();) { - // Split all executable instructions out of first block into a following - // block. This will allow function calls to be inserted into the first - // block without interfering with the instrumentation algorithm. - if (opt_direct_reads_ && !first_block_split) { - if (ii->opcode() != spv::Op::OpVariable) { - SplitBlock(ii, bi, &new_blks); - first_block_split = true; - } - } else { - pfn(ii, bi, stage_idx, &new_blks); - } - // If no new code, continue - if (new_blks.size() == 0) { - ++ii; - continue; - } - // Add new blocks to label id map - for (auto& blk : new_blks) id2block_[blk->id()] = &*blk; - // If there are new blocks we know there will always be two or - // more, so update succeeding phis with label of new last block. - size_t newBlocksSize = new_blks.size(); - assert(newBlocksSize > 1); - UpdateSucceedingPhis(new_blks); - // Replace original block with new block(s) - bi = bi.Erase(); - for (auto& bb : new_blks) { - bb->SetParent(func); - } - bi = bi.InsertBefore(&new_blks); - // Reset block iterator to last new block - for (size_t i = 0; i < newBlocksSize - 1; i++) ++bi; - modified = true; - // Restart instrumenting at beginning of last new block, - // but skip over any new phi or copy instruction. - ii = bi->begin(); - if (ii->opcode() == spv::Op::OpPhi || - ii->opcode() == spv::Op::OpCopyObject) - ++ii; - new_blks.clear(); - } - } - return modified; -} - -bool InstrumentPass::InstProcessCallTreeFromRoots(InstProcessFunction& pfn, - std::queue* roots, - uint32_t stage_idx) { - bool modified = false; - std::unordered_set done; - // Don't process input and output functions - for (auto& ifn : param2input_func_id_) done.insert(ifn.second); - for (auto& ofn : param2output_func_id_) done.insert(ofn.second); - // Process all functions from roots - while (!roots->empty()) { - const uint32_t fi = roots->front(); - roots->pop(); - if (done.insert(fi).second) { - Function* fn = id2function_.at(fi); - // Add calls first so we don't add new output function - context()->AddCalls(fn, roots); - modified = InstrumentFunction(fn, stage_idx, pfn) || modified; - } - } - return modified; -} - -bool InstrumentPass::InstProcessEntryPointCallTree(InstProcessFunction& pfn) { - // Make sure all entry points have the same execution model. Do not - // instrument if they do not. - // TODO(greg-lunarg): Handle mixed stages. Technically, a shader module - // can contain entry points with different execution models, although - // such modules will likely be rare as GLSL and HLSL are geared toward - // one model per module. In such cases we will need - // to clone any functions which are in the call trees of entrypoints - // with differing execution models. - spv::ExecutionModel stage = context()->GetStage(); - // Check for supported stages - if (stage != spv::ExecutionModel::Vertex && - stage != spv::ExecutionModel::Fragment && - stage != spv::ExecutionModel::Geometry && - stage != spv::ExecutionModel::GLCompute && - stage != spv::ExecutionModel::TessellationControl && - stage != spv::ExecutionModel::TessellationEvaluation && - stage != spv::ExecutionModel::TaskNV && - stage != spv::ExecutionModel::MeshNV && - stage != spv::ExecutionModel::RayGenerationNV && - stage != spv::ExecutionModel::IntersectionNV && - stage != spv::ExecutionModel::AnyHitNV && - stage != spv::ExecutionModel::ClosestHitNV && - stage != spv::ExecutionModel::MissNV && - stage != spv::ExecutionModel::CallableNV && - stage != spv::ExecutionModel::TaskEXT && - stage != spv::ExecutionModel::MeshEXT) { - if (consumer()) { - std::string message = "Stage not supported by instrumentation"; - consumer()(SPV_MSG_ERROR, 0, {0, 0, 0}, message.c_str()); - } - return false; - } - // Add together the roots of all entry points - std::queue roots; - for (auto& e : get_module()->entry_points()) { - roots.push(e.GetSingleWordInOperand(kEntryPointFunctionIdInIdx)); - } - bool modified = InstProcessCallTreeFromRoots(pfn, &roots, uint32_t(stage)); - return modified; -} - -void InstrumentPass::InitializeInstrument() { - output_buffer_id_ = 0; - output_buffer_ptr_id_ = 0; - input_buffer_ptr_id_ = 0; - input_buffer_id_ = 0; - float_id_ = 0; - v4float_id_ = 0; - uint_id_ = 0; - uint64_id_ = 0; - uint8_id_ = 0; - v4uint_id_ = 0; - v3uint_id_ = 0; - bool_id_ = 0; - void_id_ = 0; - storage_buffer_ext_defined_ = false; - uint32_rarr_ty_ = nullptr; - uint64_rarr_ty_ = nullptr; - - // clear collections - id2function_.clear(); - id2block_.clear(); - - // clear maps - param2input_func_id_.clear(); - param2output_func_id_.clear(); - - // Initialize function and block maps. - for (auto& fn : *get_module()) { - id2function_[fn.result_id()] = &fn; - for (auto& blk : fn) { - id2block_[blk.id()] = &blk; - } - } - - // Remember original instruction offsets - uint32_t module_offset = 0; - Module* module = get_module(); - for (auto& i : context()->capabilities()) { - (void)i; - ++module_offset; - } - for (auto& i : module->extensions()) { - (void)i; - ++module_offset; - } - for (auto& i : module->ext_inst_imports()) { - (void)i; - ++module_offset; - } - ++module_offset; // memory_model - for (auto& i : module->entry_points()) { - (void)i; - ++module_offset; - } - for (auto& i : module->execution_modes()) { - (void)i; - ++module_offset; - } - for (auto& i : module->debugs1()) { - (void)i; - ++module_offset; - } - for (auto& i : module->debugs2()) { - (void)i; - ++module_offset; - } - for (auto& i : module->debugs3()) { - (void)i; - ++module_offset; - } - for (auto& i : module->ext_inst_debuginfo()) { - (void)i; - ++module_offset; - } - for (auto& i : module->annotations()) { - (void)i; - ++module_offset; - } - for (auto& i : module->types_values()) { - module_offset += 1; - module_offset += static_cast(i.dbg_line_insts().size()); - } - - auto curr_fn = get_module()->begin(); - for (; curr_fn != get_module()->end(); ++curr_fn) { - // Count function instruction - module_offset += 1; - curr_fn->ForEachParam( - [&module_offset](const Instruction*) { module_offset += 1; }, true); - for (auto& blk : *curr_fn) { - // Count label - module_offset += 1; - for (auto& inst : blk) { - module_offset += static_cast(inst.dbg_line_insts().size()); - uid2offset_[inst.unique_id()] = module_offset; - module_offset += 1; - } - } - // Count function end instruction - module_offset += 1; - } -} - -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/instrument_pass.h b/third_party/spirv-tools/source/opt/instrument_pass.h deleted file mode 100644 index e98ba88e42..0000000000 --- a/third_party/spirv-tools/source/opt/instrument_pass.h +++ /dev/null @@ -1,489 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// Copyright (c) 2018 Valve Corporation -// Copyright (c) 2018 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef LIBSPIRV_OPT_INSTRUMENT_PASS_H_ -#define LIBSPIRV_OPT_INSTRUMENT_PASS_H_ - -#include -#include -#include - -#include "source/opt/ir_builder.h" -#include "source/opt/pass.h" -#include "spirv-tools/instrument.hpp" - -// This is a base class to assist in the creation of passes which instrument -// shader modules. More specifically, passes which replace instructions with a -// larger and more capable set of instructions. Commonly, these new -// instructions will add testing of operands and execute different -// instructions depending on the outcome, including outputting of debug -// information into a buffer created especially for that purpose. -// -// This class contains helper functions to create an InstProcessFunction, -// which is the heart of any derived class implementing a specific -// instrumentation pass. It takes an instruction as an argument, decides -// if it should be instrumented, and generates code to replace it. This class -// also supplies function InstProcessEntryPointCallTree which applies the -// InstProcessFunction to every reachable instruction in a module and replaces -// the instruction with new instructions if generated. -// -// Chief among the helper functions are output code generation functions, -// used to generate code in the shader which writes data to output buffers -// associated with that validation. Currently one such function, -// GenDebugStreamWrite, exists. Other such functions may be added in the -// future. Each is accompanied by documentation describing the format of -// its output buffer. -// -// A validation pass may read or write multiple buffers. All such buffers -// are located in a single debug descriptor set whose index is passed at the -// creation of the instrumentation pass. The bindings of the buffers used by -// a validation pass are permanently assigned and fixed and documented by -// the kDebugOutput* static consts. - -namespace spvtools { -namespace opt { -namespace { -// Validation Ids -// These are used to identify the general validation being done and map to -// its output buffers. -constexpr uint32_t kInstValidationIdBindless = 0; -constexpr uint32_t kInstValidationIdBuffAddr = 1; -constexpr uint32_t kInstValidationIdDebugPrintf = 2; -} // namespace - -class InstrumentPass : public Pass { - using cbb_ptr = const BasicBlock*; - - public: - using InstProcessFunction = - std::function, - uint32_t, std::vector>*)>; - - ~InstrumentPass() override = default; - - IRContext::Analysis GetPreservedAnalyses() override { - return IRContext::kAnalysisDefUse | IRContext::kAnalysisDecorations | - IRContext::kAnalysisCombinators | IRContext::kAnalysisNameMap | - IRContext::kAnalysisBuiltinVarId | IRContext::kAnalysisConstants; - } - - protected: - // Create instrumentation pass for |validation_id| which utilizes descriptor - // set |desc_set| for debug input and output buffers and writes |shader_id| - // into debug output records. |opt_direct_reads| indicates that the pass - // will see direct input buffer reads and should prepare to optimize them. - InstrumentPass(uint32_t desc_set, uint32_t shader_id, uint32_t validation_id, - bool opt_direct_reads = false) - : Pass(), - desc_set_(desc_set), - shader_id_(shader_id), - validation_id_(validation_id), - opt_direct_reads_(opt_direct_reads) {} - - // Initialize state for instrumentation of module. - void InitializeInstrument(); - - // Call |pfn| on all instructions in all functions in the call tree of the - // entry points in |module|. If code is generated for an instruction, replace - // the instruction's block with the new blocks that are generated. Continue - // processing at the top of the last new block. - bool InstProcessEntryPointCallTree(InstProcessFunction& pfn); - - // Move all code in |ref_block_itr| preceding the instruction |ref_inst_itr| - // to be instrumented into block |new_blk_ptr|. - void MovePreludeCode(BasicBlock::iterator ref_inst_itr, - UptrVectorIterator ref_block_itr, - std::unique_ptr* new_blk_ptr); - - // Move all code in |ref_block_itr| succeeding the instruction |ref_inst_itr| - // to be instrumented into block |new_blk_ptr|. - void MovePostludeCode(UptrVectorIterator ref_block_itr, - BasicBlock* new_blk_ptr); - - // Generate instructions in |builder| which will atomically fetch and - // increment the size of the debug output buffer stream of the current - // validation and write a record to the end of the stream, if enough space - // in the buffer remains. The record will contain the index of the function - // and instruction within that function |func_idx, instruction_idx| which - // generated the record. It will also contain additional information to - // identify the instance of the shader, depending on the stage |stage_idx| - // of the shader. Finally, the record will contain validation-specific - // data contained in |validation_ids| which will identify the validation - // error as well as the values involved in the error. - // - // The output buffer binding written to by the code generated by the function - // is determined by the validation id specified when each specific - // instrumentation pass is created. - // - // The output buffer is a sequence of 32-bit values with the following - // format (where all elements are unsigned 32-bit unless otherwise noted): - // - // Size - // Record0 - // Record1 - // Record2 - // ... - // - // Size is the number of 32-bit values that have been written or - // attempted to be written to the output buffer, excluding the Size. It is - // initialized to 0. If the size of attempts to write the buffer exceeds - // the actual size of the buffer, it is possible that this field can exceed - // the actual size of the buffer. - // - // Each Record* is a variable-length sequence of 32-bit values with the - // following format defined using static const offsets in the .cpp file: - // - // Record Size - // Shader ID - // Instruction Index - // Stage - // Stage-specific Word 0 - // Stage-specific Word 1 - // ... - // Validation Error Code - // Validation-specific Word 0 - // Validation-specific Word 1 - // Validation-specific Word 2 - // ... - // - // Each record consists of three subsections: members common across all - // validation, members specific to the stage, and members specific to a - // validation. - // - // The Record Size is the number of 32-bit words in the record, including - // the Record Size word. - // - // Shader ID is a value that identifies which shader has generated the - // validation error. It is passed when the instrumentation pass is created. - // - // The Instruction Index is the position of the instruction within the - // SPIR-V file which is in error. - // - // The Stage is the pipeline stage which has generated the error as defined - // by the SpvExecutionModel_ enumeration. This is used to interpret the - // following Stage-specific words. - // - // The Stage-specific Words identify which invocation of the shader generated - // the error. Every stage will write a fixed number of words. Vertex shaders - // will write the Vertex and Instance ID. Fragment shaders will write - // FragCoord.xy. Compute shaders will write the GlobalInvocation ID. - // The tessellation eval shader will write the Primitive ID and TessCoords.uv. - // The tessellation control shader and geometry shader will write the - // Primitive ID and Invocation ID. - // - // The Validation Error Code specifies the exact error which has occurred. - // These are enumerated with the kInstError* static consts. This allows - // multiple validation layers to use the same, single output buffer. - // - // The Validation-specific Words are a validation-specific number of 32-bit - // words which give further information on the validation error that - // occurred. These are documented further in each file containing the - // validation-specific class which derives from this base class. - // - // Because the code that is generated checks against the size of the buffer - // before writing, the size of the debug out buffer can be used by the - // validation layer to control the number of error records that are written. - void GenDebugStreamWrite(uint32_t instruction_idx, uint32_t stage_idx, - const std::vector& validation_ids, - InstructionBuilder* builder); - - // Return true if all instructions in |ids| are constants or spec constants. - bool AllConstant(const std::vector& ids); - - // Generate in |builder| instructions to read the unsigned integer from the - // input buffer specified by the offsets in |offset_ids|. Given offsets - // o0, o1, ... oN, and input buffer ibuf, return the id for the value: - // - // ibuf[...ibuf[ibuf[o0]+o1]...+oN] - // - // The binding and the format of the input buffer is determined by each - // specific validation, which is specified at the creation of the pass. - uint32_t GenDebugDirectRead(const std::vector& offset_ids, - InstructionBuilder* builder); - - // Generate code to convert integer |value_id| to 32bit, if needed. Return - // an id to the 32bit equivalent. - uint32_t Gen32BitCvtCode(uint32_t value_id, InstructionBuilder* builder); - - // Generate code to cast integer |value_id| to 32bit unsigned, if needed. - // Return an id to the Uint equivalent. - uint32_t GenUintCastCode(uint32_t value_id, InstructionBuilder* builder); - - // Return new label. - std::unique_ptr NewLabel(uint32_t label_id); - - // Set the name function parameter or local variable - std::unique_ptr NewName(uint32_t id, - const std::string& name_str); - - // Set the name for a function or global variable, names will be - // prefixed to identify which instrumentation pass generated them. - std::unique_ptr NewGlobalName(uint32_t id, - const std::string& name_str); - - // Set the name for a structure member - std::unique_ptr NewMemberName(uint32_t id, uint32_t member_index, - const std::string& name_str); - - // Return id for 32-bit unsigned type - uint32_t GetUintId(); - - // Return id for 64-bit unsigned type - uint32_t GetUint64Id(); - - // Return id for 8-bit unsigned type - uint32_t GetUint8Id(); - - // Return id for 32-bit unsigned type - uint32_t GetBoolId(); - - // Return id for void type - uint32_t GetVoidId(); - - // Return pointer to type for runtime array of uint - analysis::Type* GetUintXRuntimeArrayType(uint32_t width, - analysis::Type** rarr_ty); - - // Return pointer to type for runtime array of uint - analysis::Type* GetUintRuntimeArrayType(uint32_t width); - - // Return id for buffer uint type - uint32_t GetOutputBufferPtrId(); - - // Return id for buffer uint type - uint32_t GetInputBufferTypeId(); - - // Return id for buffer uint type - uint32_t GetInputBufferPtrId(); - - // Return binding for output buffer for current validation. - uint32_t GetOutputBufferBinding(); - - // Return binding for input buffer for current validation. - uint32_t GetInputBufferBinding(); - - // Add storage buffer extension if needed - void AddStorageBufferExt(); - - // Return id for debug output buffer - uint32_t GetOutputBufferId(); - - // Return id for debug input buffer - uint32_t GetInputBufferId(); - - // Return id for 32-bit float type - uint32_t GetFloatId(); - - // Return id for v4float type - uint32_t GetVec4FloatId(); - - // Return id for uint vector type of |length| - uint32_t GetVecUintId(uint32_t length); - - // Return id for v4uint type - uint32_t GetVec4UintId(); - - // Return id for v3uint type - uint32_t GetVec3UintId(); - - // Return id for output function. Define if it doesn't exist with - // |val_spec_param_cnt| validation-specific uint32 parameters. - uint32_t GetStreamWriteFunctionId(uint32_t stage_idx, - uint32_t val_spec_param_cnt); - - // Return id for input function taking |param_cnt| uint32 parameters. Define - // if it doesn't exist. - uint32_t GetDirectReadFunctionId(uint32_t param_cnt); - - // Split block |block_itr| into two new blocks where the second block - // contains |inst_itr| and place in |new_blocks|. - void SplitBlock(BasicBlock::iterator inst_itr, - UptrVectorIterator block_itr, - std::vector>* new_blocks); - - // Apply instrumentation function |pfn| to every instruction in |func|. - // If code is generated for an instruction, replace the instruction's - // block with the new blocks that are generated. Continue processing at the - // top of the last new block. - bool InstrumentFunction(Function* func, uint32_t stage_idx, - InstProcessFunction& pfn); - - // Call |pfn| on all functions in the call tree of the function - // ids in |roots|. - bool InstProcessCallTreeFromRoots(InstProcessFunction& pfn, - std::queue* roots, - uint32_t stage_idx); - - // Gen code into |builder| to write |field_value_id| into debug output - // buffer at |base_offset_id| + |field_offset|. - void GenDebugOutputFieldCode(uint32_t base_offset_id, uint32_t field_offset, - uint32_t field_value_id, - InstructionBuilder* builder); - - // Generate instructions into |builder| which will write the members - // of the debug output record common for all stages and validations at - // |base_off|. - void GenCommonStreamWriteCode(uint32_t record_sz, uint32_t instruction_idx, - uint32_t stage_idx, uint32_t base_off, - InstructionBuilder* builder); - - // Generate instructions into |builder| which will write - // |uint_frag_coord_id| at |component| of the record at |base_offset_id| of - // the debug output buffer . - void GenFragCoordEltDebugOutputCode(uint32_t base_offset_id, - uint32_t uint_frag_coord_id, - uint32_t component, - InstructionBuilder* builder); - - // Generate instructions into |builder| which will load |var_id| and return - // its result id. - uint32_t GenVarLoad(uint32_t var_id, InstructionBuilder* builder); - - // Generate instructions into |builder| which will load the uint |builtin_id| - // and write it into the debug output buffer at |base_off| + |builtin_off|. - void GenBuiltinOutputCode(uint32_t builtin_id, uint32_t builtin_off, - uint32_t base_off, InstructionBuilder* builder); - - // Generate instructions into |builder| which will write the |stage_idx|- - // specific members of the debug output stream at |base_off|. - void GenStageStreamWriteCode(uint32_t stage_idx, uint32_t base_off, - InstructionBuilder* builder); - - // Return true if instruction must be in the same block that its result - // is used. - bool IsSameBlockOp(const Instruction* inst) const; - - // Clone operands which must be in same block as consumer instructions. - // Look in same_blk_pre for instructions that need cloning. Look in - // same_blk_post for instructions already cloned. Add cloned instruction - // to same_blk_post. - void CloneSameBlockOps( - std::unique_ptr* inst, - std::unordered_map* same_blk_post, - std::unordered_map* same_blk_pre, - BasicBlock* block_ptr); - - // Update phis in succeeding blocks to point to new last block - void UpdateSucceedingPhis( - std::vector>& new_blocks); - - // Debug descriptor set index - uint32_t desc_set_; - - // Shader module ID written into output record - uint32_t shader_id_; - - // Map from function id to function pointer. - std::unordered_map id2function_; - - // Map from block's label id to block. TODO(dnovillo): This is superfluous wrt - // CFG. It has functionality not present in CFG. Consolidate. - std::unordered_map id2block_; - - // Map from instruction's unique id to offset in original file. - std::unordered_map uid2offset_; - - // result id for OpConstantFalse - uint32_t validation_id_; - - // id for output buffer variable - uint32_t output_buffer_id_; - - // ptr type id for output buffer element - uint32_t output_buffer_ptr_id_; - - // ptr type id for input buffer element - uint32_t input_buffer_ptr_id_; - - // id for debug output function - std::unordered_map param2output_func_id_; - - // ids for debug input functions - std::unordered_map param2input_func_id_; - - // id for input buffer variable - uint32_t input_buffer_id_; - - // id for 32-bit float type - uint32_t float_id_; - - // id for v4float type - uint32_t v4float_id_; - - // id for v4uint type - uint32_t v4uint_id_; - - // id for v3uint type - uint32_t v3uint_id_; - - // id for 32-bit unsigned type - uint32_t uint_id_; - - // id for 64-bit unsigned type - uint32_t uint64_id_; - - // id for 8-bit unsigned type - uint32_t uint8_id_; - - // id for bool type - uint32_t bool_id_; - - // id for void type - uint32_t void_id_; - - // boolean to remember storage buffer extension - bool storage_buffer_ext_defined_; - - // runtime array of uint type - analysis::Type* uint64_rarr_ty_; - - // runtime array of uint type - analysis::Type* uint32_rarr_ty_; - - // Pre-instrumentation same-block insts - std::unordered_map same_block_pre_; - - // Post-instrumentation same-block op ids - std::unordered_map same_block_post_; - - // Map function calls to result id. Clear for every function. - // This is for debug input reads with constant arguments that - // have been generated into the first block of the function. - // This mechanism is used to avoid multiple identical debug - // input buffer reads. - struct vector_hash_ { - std::size_t operator()(const std::vector& v) const { - std::size_t hash = v.size(); - for (auto& u : v) { - hash ^= u + 0x9e3779b9 + (hash << 11) + (hash >> 21); - } - return hash; - } - }; - std::unordered_map, uint32_t, vector_hash_> call2id_; - - // Function currently being instrumented - Function* curr_func_; - - // Optimize direct debug input buffer reads. Specifically, move all such - // reads with constant args to first block and reuse them. - bool opt_direct_reads_; -}; - -} // namespace opt -} // namespace spvtools - -#endif // LIBSPIRV_OPT_INSTRUMENT_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/interface_var_sroa.h b/third_party/spirv-tools/source/opt/interface_var_sroa.h index df7511bf3a..45ed3717ad 100644 --- a/third_party/spirv-tools/source/opt/interface_var_sroa.h +++ b/third_party/spirv-tools/source/opt/interface_var_sroa.h @@ -90,10 +90,6 @@ class InterfaceVariableScalarReplacement : public Pass { // |component|. Returns true whether the component exists or not. bool GetVariableComponent(Instruction* var, uint32_t* component); - // Returns the interface variable instruction whose result id is - // |interface_var_id|. - Instruction* GetInterfaceVariable(uint32_t interface_var_id); - // Returns the type of |var| as an instruction. Instruction* GetTypeOfVariable(Instruction* var); diff --git a/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp b/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp index bb6f6108cf..2ec2147d60 100644 --- a/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp +++ b/third_party/spirv-tools/source/opt/interp_fixup_pass.cpp @@ -19,7 +19,6 @@ #include #include -#include "ir_builder.h" #include "source/opt/ir_context.h" #include "type_manager.h" diff --git a/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.cpp b/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.cpp new file mode 100644 index 0000000000..642e2d23a5 --- /dev/null +++ b/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.cpp @@ -0,0 +1,493 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/invocation_interlock_placement_pass.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "source/enum_set.h" +#include "source/enum_string_mapping.h" +#include "source/opt/ir_context.h" +#include "source/opt/reflect.h" +#include "source/spirv_target_env.h" +#include "source/util/string_utils.h" + +namespace spvtools { +namespace opt { + +namespace { +constexpr uint32_t kEntryPointExecutionModelInIdx = 0; +constexpr uint32_t kEntryPointFunctionIdInIdx = 1; +constexpr uint32_t kFunctionCallFunctionIdInIdx = 0; +} // namespace + +bool InvocationInterlockPlacementPass::hasSingleNextBlock(uint32_t block_id, + bool reverse_cfg) { + if (reverse_cfg) { + // We are traversing forward, so check whether there is a single successor. + BasicBlock* block = cfg()->block(block_id); + + switch (block->tail()->opcode()) { + case spv::Op::OpBranchConditional: + return false; + case spv::Op::OpSwitch: + return block->tail()->NumInOperandWords() == 1; + default: + return !block->tail()->IsReturnOrAbort(); + } + } else { + // We are traversing backward, so check whether there is a single + // predecessor. + return cfg()->preds(block_id).size() == 1; + } +} + +void InvocationInterlockPlacementPass::forEachNext( + uint32_t block_id, bool reverse_cfg, std::function f) { + if (reverse_cfg) { + BasicBlock* block = cfg()->block(block_id); + + block->ForEachSuccessorLabel([f](uint32_t succ_id) { f(succ_id); }); + } else { + for (uint32_t pred_id : cfg()->preds(block_id)) { + f(pred_id); + } + } +} + +void InvocationInterlockPlacementPass::addInstructionAtBlockBoundary( + BasicBlock* block, spv::Op opcode, bool at_end) { + if (at_end) { + assert(block->begin()->opcode() != spv::Op::OpPhi && + "addInstructionAtBlockBoundary expects to be called with at_end == " + "true only if there is a single successor to block"); + // Insert a begin instruction at the end of the block. + Instruction* begin_inst = new Instruction(context(), opcode); + begin_inst->InsertAfter(&*--block->tail()); + } else { + assert(block->begin()->opcode() != spv::Op::OpPhi && + "addInstructionAtBlockBoundary expects to be called with at_end == " + "false only if there is a single predecessor to block"); + // Insert an end instruction at the beginning of the block. + Instruction* end_inst = new Instruction(context(), opcode); + end_inst->InsertBefore(&*block->begin()); + } +} + +bool InvocationInterlockPlacementPass::killDuplicateBegin(BasicBlock* block) { + bool found = false; + + return context()->KillInstructionIf( + block->begin(), block->end(), [&found](Instruction* inst) { + if (inst->opcode() == spv::Op::OpBeginInvocationInterlockEXT) { + if (found) { + return true; + } + found = true; + } + return false; + }); +} + +bool InvocationInterlockPlacementPass::killDuplicateEnd(BasicBlock* block) { + std::vector to_kill; + block->ForEachInst([&to_kill](Instruction* inst) { + if (inst->opcode() == spv::Op::OpEndInvocationInterlockEXT) { + to_kill.push_back(inst); + } + }); + + if (to_kill.size() <= 1) { + return false; + } + + to_kill.pop_back(); + + for (Instruction* inst : to_kill) { + context()->KillInst(inst); + } + + return true; +} + +void InvocationInterlockPlacementPass::recordBeginOrEndInFunction( + Function* func) { + if (extracted_functions_.count(func)) { + return; + } + + bool had_begin = false; + bool had_end = false; + + func->ForEachInst([this, &had_begin, &had_end](Instruction* inst) { + switch (inst->opcode()) { + case spv::Op::OpBeginInvocationInterlockEXT: + had_begin = true; + break; + case spv::Op::OpEndInvocationInterlockEXT: + had_end = true; + break; + case spv::Op::OpFunctionCall: { + uint32_t function_id = + inst->GetSingleWordInOperand(kFunctionCallFunctionIdInIdx); + Function* inner_func = context()->GetFunction(function_id); + recordBeginOrEndInFunction(inner_func); + ExtractionResult result = extracted_functions_[inner_func]; + had_begin = had_begin || result.had_begin; + had_end = had_end || result.had_end; + break; + } + default: + break; + } + }); + + ExtractionResult result = {had_begin, had_end}; + extracted_functions_[func] = result; +} + +bool InvocationInterlockPlacementPass:: + removeBeginAndEndInstructionsFromFunction(Function* func) { + bool modified = false; + func->ForEachInst([this, &modified](Instruction* inst) { + switch (inst->opcode()) { + case spv::Op::OpBeginInvocationInterlockEXT: + context()->KillInst(inst); + modified = true; + break; + case spv::Op::OpEndInvocationInterlockEXT: + context()->KillInst(inst); + modified = true; + break; + default: + break; + } + }); + return modified; +} + +bool InvocationInterlockPlacementPass::extractInstructionsFromCalls( + std::vector blocks) { + bool modified = false; + + for (BasicBlock* block : blocks) { + block->ForEachInst([this, &modified](Instruction* inst) { + if (inst->opcode() == spv::Op::OpFunctionCall) { + uint32_t function_id = + inst->GetSingleWordInOperand(kFunctionCallFunctionIdInIdx); + Function* func = context()->GetFunction(function_id); + ExtractionResult result = extracted_functions_[func]; + + if (result.had_begin) { + Instruction* new_inst = new Instruction( + context(), spv::Op::OpBeginInvocationInterlockEXT); + new_inst->InsertBefore(inst); + modified = true; + } + if (result.had_end) { + Instruction* new_inst = + new Instruction(context(), spv::Op::OpEndInvocationInterlockEXT); + new_inst->InsertAfter(inst); + modified = true; + } + } + }); + } + return modified; +} + +void InvocationInterlockPlacementPass::recordExistingBeginAndEndBlock( + std::vector blocks) { + for (BasicBlock* block : blocks) { + block->ForEachInst([this, block](Instruction* inst) { + switch (inst->opcode()) { + case spv::Op::OpBeginInvocationInterlockEXT: + begin_.insert(block->id()); + break; + case spv::Op::OpEndInvocationInterlockEXT: + end_.insert(block->id()); + break; + default: + break; + } + }); + } +} + +InvocationInterlockPlacementPass::BlockSet +InvocationInterlockPlacementPass::computeReachableBlocks( + BlockSet& previous_inside, const BlockSet& starting_nodes, + bool reverse_cfg) { + BlockSet inside = starting_nodes; + + std::deque worklist; + worklist.insert(worklist.begin(), starting_nodes.begin(), + starting_nodes.end()); + + while (!worklist.empty()) { + uint32_t block_id = worklist.front(); + worklist.pop_front(); + + forEachNext(block_id, reverse_cfg, + [&inside, &previous_inside, &worklist](uint32_t next_id) { + previous_inside.insert(next_id); + if (inside.insert(next_id).second) { + worklist.push_back(next_id); + } + }); + } + + return inside; +} + +bool InvocationInterlockPlacementPass::removeUnneededInstructions( + BasicBlock* block) { + bool modified = false; + if (!predecessors_after_begin_.count(block->id()) && + after_begin_.count(block->id())) { + // None of the previous blocks are in the critical section, but this block + // is. This can only happen if this block already has at least one begin + // instruction. Leave the first begin instruction, and remove any others. + modified |= killDuplicateBegin(block); + } else if (predecessors_after_begin_.count(block->id())) { + // At least one previous block is in the critical section; remove all + // begin instructions in this block. + modified |= context()->KillInstructionIf( + block->begin(), block->end(), [](Instruction* inst) { + return inst->opcode() == spv::Op::OpBeginInvocationInterlockEXT; + }); + } + + if (!successors_before_end_.count(block->id()) && + before_end_.count(block->id())) { + // Same as above + modified |= killDuplicateEnd(block); + } else if (successors_before_end_.count(block->id())) { + modified |= context()->KillInstructionIf( + block->begin(), block->end(), [](Instruction* inst) { + return inst->opcode() == spv::Op::OpEndInvocationInterlockEXT; + }); + } + return modified; +} + +BasicBlock* InvocationInterlockPlacementPass::splitEdge(BasicBlock* block, + uint32_t succ_id) { + // Create a new block to replace the critical edge. + auto new_succ_temp = MakeUnique( + MakeUnique(context(), spv::Op::OpLabel, 0, TakeNextId(), + std::initializer_list{})); + auto* new_succ = new_succ_temp.get(); + + // Insert the new block into the function. + block->GetParent()->InsertBasicBlockAfter(std::move(new_succ_temp), block); + + new_succ->AddInstruction(MakeUnique( + context(), spv::Op::OpBranch, 0, 0, + std::initializer_list{ + Operand(spv_operand_type_t::SPV_OPERAND_TYPE_ID, {succ_id})})); + + assert(block->tail()->opcode() == spv::Op::OpBranchConditional || + block->tail()->opcode() == spv::Op::OpSwitch); + + // Update the first branch to successor to instead branch to + // the new successor. If there are multiple edges, we arbitrarily choose the + // first time it appears in the list. The other edges to `succ_id` will have + // to be split by another call to `splitEdge`. + block->tail()->WhileEachInId([new_succ, succ_id](uint32_t* branch_id) { + if (*branch_id == succ_id) { + *branch_id = new_succ->id(); + return false; + } + return true; + }); + + return new_succ; +} + +bool InvocationInterlockPlacementPass::placeInstructionsForEdge( + BasicBlock* block, uint32_t next_id, BlockSet& inside, + BlockSet& previous_inside, spv::Op opcode, bool reverse_cfg) { + bool modified = false; + + if (previous_inside.count(next_id) && !inside.count(block->id())) { + // This block is not in the critical section but the next has at least one + // other previous block that is, so this block should be enter it as well. + // We need to add begin or end instructions to the edge. + + modified = true; + + if (hasSingleNextBlock(block->id(), reverse_cfg)) { + // This is the only next block. + + // Additionally, because `next_id` is in `previous_inside`, we know that + // `next_id` has at least one previous block in `inside`. And because + // 'block` is not in `inside`, that means the `next_id` has to have at + // least one other previous block in `inside`. + + // This is solely for a debug assertion. It is essentially recomputing the + // value of `previous_inside` to verify that it was computed correctly + // such that the above statement is true. + bool next_has_previous_inside = false; + // By passing !reverse_cfg to forEachNext, we are actually iterating over + // the previous blocks. + forEachNext(next_id, !reverse_cfg, + [&next_has_previous_inside, inside](uint32_t previous_id) { + if (inside.count(previous_id)) { + next_has_previous_inside = true; + } + }); + assert(next_has_previous_inside && + "`previous_inside` must be the set of blocks with at least one " + "previous block in `inside`"); + + addInstructionAtBlockBoundary(block, opcode, reverse_cfg); + } else { + // This block has multiple next blocks. Split the edge and insert the + // instruction in the new next block. + BasicBlock* new_branch; + if (reverse_cfg) { + new_branch = splitEdge(block, next_id); + } else { + new_branch = splitEdge(cfg()->block(next_id), block->id()); + } + + auto inst = new Instruction(context(), opcode); + inst->InsertBefore(&*new_branch->tail()); + } + } + + return modified; +} + +bool InvocationInterlockPlacementPass::placeInstructions(BasicBlock* block) { + bool modified = false; + + block->ForEachSuccessorLabel([this, block, &modified](uint32_t succ_id) { + modified |= placeInstructionsForEdge( + block, succ_id, after_begin_, predecessors_after_begin_, + spv::Op::OpBeginInvocationInterlockEXT, /* reverse_cfg= */ true); + modified |= placeInstructionsForEdge(cfg()->block(succ_id), block->id(), + before_end_, successors_before_end_, + spv::Op::OpEndInvocationInterlockEXT, + /* reverse_cfg= */ false); + }); + + return modified; +} + +bool InvocationInterlockPlacementPass::processFragmentShaderEntry( + Function* entry_func) { + bool modified = false; + + // Save the original order of blocks in the function, so we don't iterate over + // newly-added blocks. + std::vector original_blocks; + for (auto bi = entry_func->begin(); bi != entry_func->end(); ++bi) { + original_blocks.push_back(&*bi); + } + + modified |= extractInstructionsFromCalls(original_blocks); + recordExistingBeginAndEndBlock(original_blocks); + + after_begin_ = computeReachableBlocks(predecessors_after_begin_, begin_, + /* reverse_cfg= */ true); + before_end_ = computeReachableBlocks(successors_before_end_, end_, + /* reverse_cfg= */ false); + + for (BasicBlock* block : original_blocks) { + modified |= removeUnneededInstructions(block); + modified |= placeInstructions(block); + } + return modified; +} + +bool InvocationInterlockPlacementPass::isFragmentShaderInterlockEnabled() { + if (!context()->get_feature_mgr()->HasExtension( + kSPV_EXT_fragment_shader_interlock)) { + return false; + } + + if (context()->get_feature_mgr()->HasCapability( + spv::Capability::FragmentShaderSampleInterlockEXT)) { + return true; + } + + if (context()->get_feature_mgr()->HasCapability( + spv::Capability::FragmentShaderPixelInterlockEXT)) { + return true; + } + + if (context()->get_feature_mgr()->HasCapability( + spv::Capability::FragmentShaderShadingRateInterlockEXT)) { + return true; + } + + return false; +} + +Pass::Status InvocationInterlockPlacementPass::Process() { + // Skip this pass if the necessary extension or capability is missing + if (!isFragmentShaderInterlockEnabled()) { + return Status::SuccessWithoutChange; + } + + bool modified = false; + + std::unordered_set entry_points; + for (Instruction& entry_inst : context()->module()->entry_points()) { + uint32_t entry_id = + entry_inst.GetSingleWordInOperand(kEntryPointFunctionIdInIdx); + entry_points.insert(context()->GetFunction(entry_id)); + } + + for (auto fi = context()->module()->begin(); fi != context()->module()->end(); + ++fi) { + Function* func = &*fi; + recordBeginOrEndInFunction(func); + if (!entry_points.count(func) && extracted_functions_.count(func)) { + modified |= removeBeginAndEndInstructionsFromFunction(func); + } + } + + for (Instruction& entry_inst : context()->module()->entry_points()) { + uint32_t entry_id = + entry_inst.GetSingleWordInOperand(kEntryPointFunctionIdInIdx); + Function* entry_func = context()->GetFunction(entry_id); + + auto execution_model = spv::ExecutionModel( + entry_inst.GetSingleWordInOperand(kEntryPointExecutionModelInIdx)); + + if (execution_model != spv::ExecutionModel::Fragment) { + continue; + } + + modified |= processFragmentShaderEntry(entry_func); + } + + return modified ? Pass::Status::SuccessWithChange + : Pass::Status::SuccessWithoutChange; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.h b/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.h new file mode 100644 index 0000000000..4e85be8586 --- /dev/null +++ b/third_party/spirv-tools/source/opt/invocation_interlock_placement_pass.h @@ -0,0 +1,158 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_DEDUPE_INTERLOCK_INVOCATION_PASS_H_ +#define SOURCE_OPT_DEDUPE_INTERLOCK_INVOCATION_PASS_H_ + +#include +#include +#include +#include +#include +#include + +#include "source/enum_set.h" +#include "source/extensions.h" +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "source/opt/pass.h" +#include "source/spirv_target_env.h" + +namespace spvtools { +namespace opt { + +// This pass will ensure that an entry point will only have at most one +// OpBeginInterlockInvocationEXT and one OpEndInterlockInvocationEXT, in that +// order +class InvocationInterlockPlacementPass : public Pass { + public: + InvocationInterlockPlacementPass() {} + InvocationInterlockPlacementPass(const InvocationInterlockPlacementPass&) = + delete; + InvocationInterlockPlacementPass(InvocationInterlockPlacementPass&&) = delete; + + const char* name() const override { return "dedupe-interlock-invocation"; } + Status Process() override; + + private: + using BlockSet = std::unordered_set; + + // Specifies whether a function originally had a begin or end instruction. + struct ExtractionResult { + bool had_begin : 1; + bool had_end : 2; + }; + + // Check if a block has only a single next block, depending on the directing + // that we are traversing the CFG. If reverse_cfg is true, we are walking + // forward through the CFG, and will return if the block has only one + // successor. Otherwise, we are walking backward through the CFG, and will + // return if the block has only one predecessor. + bool hasSingleNextBlock(uint32_t block_id, bool reverse_cfg); + + // Iterate over each of a block's predecessors or successors, depending on + // direction. If reverse_cfg is true, we are walking forward through the CFG, + // and need to iterate over the successors. Otherwise, we are walking backward + // through the CFG, and need to iterate over the predecessors. + void forEachNext(uint32_t block_id, bool reverse_cfg, + std::function f); + + // Add either a begin or end instruction to the edge of the basic block. If + // at_end is true, add the instruction to the end of the block; otherwise add + // the instruction to the beginning of the basic block. + void addInstructionAtBlockBoundary(BasicBlock* block, spv::Op opcode, + bool at_end); + + // Remove every OpBeginInvocationInterlockEXT instruction in block after the + // first. Returns whether any instructions were removed. + bool killDuplicateBegin(BasicBlock* block); + // Remove every OpBeginInvocationInterlockEXT instruction in block before the + // last. Returns whether any instructions were removed. + bool killDuplicateEnd(BasicBlock* block); + + // Records whether a function will potentially execute a begin or end + // instruction. + void recordBeginOrEndInFunction(Function* func); + + // Recursively removes any begin or end instructions from func and any + // function func calls. Returns whether any instructions were removed. + bool removeBeginAndEndInstructionsFromFunction(Function* func); + + // For every function call in any of the passed blocks, move any begin or end + // instructions outside of the function call. Returns whether any extractions + // occurred. + bool extractInstructionsFromCalls(std::vector blocks); + + // Finds the sets of blocks that contain OpBeginInvocationInterlockEXT and + // OpEndInvocationInterlockEXT, storing them in the member variables begin_ + // and end_ respectively. + void recordExistingBeginAndEndBlock(std::vector blocks); + + // Compute the set of blocks including or after the barrier instruction, and + // the set of blocks with any previous blocks inside the barrier instruction. + // If reverse_cfg is true, move forward through the CFG, computing + // after_begin_ and predecessors_after_begin_computing after_begin_ and + // predecessors_after_begin_, otherwise, move backward through the CFG, + // computing before_end_ and successors_before_end_. + BlockSet computeReachableBlocks(BlockSet& in_set, + const BlockSet& starting_nodes, + bool reverse_cfg); + + // Remove unneeded begin and end instructions in block. + bool removeUnneededInstructions(BasicBlock* block); + + // Given a block which branches to multiple successors, and a specific + // successor, creates a new empty block, and update the branch instruction to + // branch to the new block instead. + BasicBlock* splitEdge(BasicBlock* block, uint32_t succ_id); + + // For the edge from block to next_id, places a begin or end instruction on + // the edge, based on the direction we are walking the CFG, specified in + // reverse_cfg. + bool placeInstructionsForEdge(BasicBlock* block, uint32_t next_id, + BlockSet& inside, BlockSet& previous_inside, + spv::Op opcode, bool reverse_cfg); + // Calls placeInstructionsForEdge for each edge in block. + bool placeInstructions(BasicBlock* block); + + // Processes a single fragment shader entry function. + bool processFragmentShaderEntry(Function* entry_func); + + // Returns whether the module has the SPV_EXT_fragment_shader_interlock + // extension and one of the FragmentShader*InterlockEXT capabilities. + bool isFragmentShaderInterlockEnabled(); + + // Maps a function to whether that function originally held a begin or end + // instruction. + std::unordered_map extracted_functions_; + + // The set of blocks which have an OpBeginInvocationInterlockEXT instruction. + BlockSet begin_; + // The set of blocks which have an OpEndInvocationInterlockEXT instruction. + BlockSet end_; + // The set of blocks which either have a begin instruction, or have a + // predecessor which has a begin instruction. + BlockSet after_begin_; + // The set of blocks which either have an end instruction, or have a successor + // which have an end instruction. + BlockSet before_end_; + // The set of blocks which have a predecessor in after_begin_. + BlockSet predecessors_after_begin_; + // The set of blocks which have a successor in before_end_. + BlockSet successors_before_end_; +}; + +} // namespace opt +} // namespace spvtools +#endif // SOURCE_OPT_DEDUPE_INTERLOCK_INVOCATION_PASS_H_ diff --git a/third_party/spirv-tools/source/opt/ir_builder.h b/third_party/spirv-tools/source/opt/ir_builder.h index 93289a61a7..f3e0afceae 100644 --- a/third_party/spirv-tools/source/opt/ir_builder.h +++ b/third_party/spirv-tools/source/opt/ir_builder.h @@ -440,6 +440,22 @@ class InstructionBuilder { return GetContext()->get_constant_mgr()->GetDefiningInstruction(constant); } + Instruction* GetBoolConstant(bool value) { + analysis::Bool type; + uint32_t type_id = GetContext()->get_type_mgr()->GetTypeInstruction(&type); + analysis::Type* rebuilt_type = + GetContext()->get_type_mgr()->GetType(type_id); + uint32_t word = value; + const analysis::Constant* constant = + GetContext()->get_constant_mgr()->GetConstant(rebuilt_type, {word}); + return GetContext()->get_constant_mgr()->GetDefiningInstruction(constant); + } + + uint32_t GetBoolConstantId(bool value) { + Instruction* inst = GetBoolConstant(value); + return (inst != nullptr ? inst->result_id() : 0); + } + Instruction* AddCompositeExtract(uint32_t type, uint32_t id_of_composite, const std::vector& index_list) { std::vector operands; @@ -480,9 +496,16 @@ class InstructionBuilder { return AddInstruction(std::move(new_inst)); } - Instruction* AddLoad(uint32_t type_id, uint32_t base_ptr_id) { + Instruction* AddLoad(uint32_t type_id, uint32_t base_ptr_id, + uint32_t alignment = 0) { std::vector operands; operands.push_back({SPV_OPERAND_TYPE_ID, {base_ptr_id}}); + if (alignment != 0) { + operands.push_back( + {SPV_OPERAND_TYPE_MEMORY_ACCESS, + {static_cast(spv::MemoryAccessMask::Aligned)}}); + operands.push_back({SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER, {alignment}}); + } // TODO(1841): Handle id overflow. std::unique_ptr new_inst( diff --git a/third_party/spirv-tools/source/opt/ir_context.cpp b/third_party/spirv-tools/source/opt/ir_context.cpp index 889a671d07..6be7b05669 100644 --- a/third_party/spirv-tools/source/opt/ir_context.cpp +++ b/third_party/spirv-tools/source/opt/ir_context.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2017 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +21,6 @@ #include "OpenCLDebugInfo100.h" #include "source/latest_version_glsl_std_450_header.h" #include "source/opt/log.h" -#include "source/opt/mem_pass.h" #include "source/opt/reflect.h" namespace spvtools { @@ -89,6 +90,9 @@ void IRContext::BuildInvalidAnalyses(IRContext::Analysis set) { if (set & kAnalysisDebugInfo) { BuildDebugInfoManager(); } + if (set & kAnalysisLiveness) { + BuildLivenessManager(); + } } void IRContext::InvalidateAnalysesExceptFor( @@ -221,6 +225,28 @@ Instruction* IRContext::KillInst(Instruction* inst) { return next_instruction; } +bool IRContext::KillInstructionIf(Module::inst_iterator begin, + Module::inst_iterator end, + std::function condition) { + bool removed = false; + for (auto it = begin; it != end;) { + if (!condition(&*it)) { + ++it; + continue; + } + + removed = true; + // `it` is an iterator on an intrusive list. Next is invalidated on the + // current node when an instruction is killed. The iterator must be moved + // forward before deleting the node. + auto instruction = &*it; + ++it; + KillInst(instruction); + } + + return removed; +} + void IRContext::CollectNonSemanticTree( Instruction* inst, std::unordered_set* to_kill) { if (!inst->HasResultId()) return; @@ -252,6 +278,36 @@ bool IRContext::KillDef(uint32_t id) { return false; } +bool IRContext::RemoveCapability(spv::Capability capability) { + const bool removed = KillInstructionIf( + module()->capability_begin(), module()->capability_end(), + [capability](Instruction* inst) { + return static_cast(inst->GetSingleWordOperand(0)) == + capability; + }); + + if (removed && feature_mgr_ != nullptr) { + feature_mgr_->RemoveCapability(capability); + } + + return removed; +} + +bool IRContext::RemoveExtension(Extension extension) { + const std::string_view extensionName = ExtensionToString(extension); + const bool removed = KillInstructionIf( + module()->extension_begin(), module()->extension_end(), + [&extensionName](Instruction* inst) { + return inst->GetOperand(0).AsString() == extensionName; + }); + + if (removed && feature_mgr_ != nullptr) { + feature_mgr_->RemoveExtension(extension); + } + + return removed; +} + bool IRContext::ReplaceAllUsesWith(uint32_t before, uint32_t after) { return ReplaceAllUsesWithPredicate(before, after, [](Instruction*) { return true; }); @@ -485,6 +541,7 @@ void IRContext::AddCombinatorsForCapability(uint32_t capability) { (uint32_t)spv::Op::OpTypeHitObjectNV, (uint32_t)spv::Op::OpTypeArray, (uint32_t)spv::Op::OpTypeRuntimeArray, + (uint32_t)spv::Op::OpTypeNodePayloadArrayAMDX, (uint32_t)spv::Op::OpTypeStruct, (uint32_t)spv::Op::OpTypeOpaque, (uint32_t)spv::Op::OpTypePointer, @@ -719,9 +776,9 @@ void IRContext::AddCombinatorsForExtension(Instruction* extension) { } void IRContext::InitializeCombinators() { - get_feature_mgr()->GetCapabilities()->ForEach([this](spv::Capability cap) { - AddCombinatorsForCapability(uint32_t(cap)); - }); + for (auto capability : get_feature_mgr()->GetCapabilities()) { + AddCombinatorsForCapability(uint32_t(capability)); + } for (auto& extension : module()->ext_inst_imports()) { AddCombinatorsForExtension(&extension); @@ -872,9 +929,35 @@ uint32_t IRContext::GetBuiltinInputVarId(uint32_t builtin) { void IRContext::AddCalls(const Function* func, std::queue* todo) { for (auto bi = func->begin(); bi != func->end(); ++bi) - for (auto ii = bi->begin(); ii != bi->end(); ++ii) + for (auto ii = bi->begin(); ii != bi->end(); ++ii) { if (ii->opcode() == spv::Op::OpFunctionCall) todo->push(ii->GetSingleWordInOperand(0)); + if (ii->opcode() == spv::Op::OpCooperativeMatrixPerElementOpNV) + todo->push(ii->GetSingleWordInOperand(1)); + if (ii->opcode() == spv::Op::OpCooperativeMatrixReduceNV) + todo->push(ii->GetSingleWordInOperand(2)); + if (ii->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) { + const auto memory_operands_index = 3; + auto mask = ii->GetSingleWordInOperand(memory_operands_index); + + uint32_t count = 1; + if (mask & uint32_t(spv::MemoryAccessMask::Aligned)) ++count; + if (mask & uint32_t(spv::MemoryAccessMask::MakePointerAvailableKHR)) + ++count; + if (mask & uint32_t(spv::MemoryAccessMask::MakePointerVisibleKHR)) + ++count; + + const auto tensor_operands_index = memory_operands_index + count; + mask = ii->GetSingleWordInOperand(tensor_operands_index); + count = 1; + if (mask & uint32_t(spv::TensorAddressingOperandsMask::TensorView)) + ++count; + + if (mask & uint32_t(spv::TensorAddressingOperandsMask::DecodeFunc)) { + todo->push(ii->GetSingleWordInOperand(tensor_operands_index + count)); + } + } + } } bool IRContext::ProcessEntryPointCallTree(ProcessFunction& pfn) { diff --git a/third_party/spirv-tools/source/opt/ir_context.h b/third_party/spirv-tools/source/opt/ir_context.h index 35075de171..3857696618 100644 --- a/third_party/spirv-tools/source/opt/ir_context.h +++ b/third_party/spirv-tools/source/opt/ir_context.h @@ -27,6 +27,7 @@ #include #include "source/assembly_grammar.h" +#include "source/enum_string_mapping.h" #include "source/opt/cfg.h" #include "source/opt/constants.h" #include "source/opt/debug_info_manager.h" @@ -83,7 +84,7 @@ class IRContext { kAnalysisTypes = 1 << 15, kAnalysisDebugInfo = 1 << 16, kAnalysisLiveness = 1 << 17, - kAnalysisEnd = 1 << 17 + kAnalysisEnd = 1 << 18 }; using ProcessFunction = std::function; @@ -153,13 +154,19 @@ class IRContext { inline IteratorRange capabilities(); inline IteratorRange capabilities() const; + // Iterators for extensions instructions contained in this module. + inline Module::inst_iterator extension_begin(); + inline Module::inst_iterator extension_end(); + inline IteratorRange extensions(); + inline IteratorRange extensions() const; + // Iterators for types, constants and global variables instructions. inline Module::inst_iterator types_values_begin(); inline Module::inst_iterator types_values_end(); inline IteratorRange types_values(); inline IteratorRange types_values() const; - // Iterators for extension instructions contained in this module. + // Iterators for ext_inst import instructions contained in this module. inline Module::inst_iterator ext_inst_import_begin(); inline Module::inst_iterator ext_inst_import_end(); inline IteratorRange ext_inst_imports(); @@ -195,8 +202,9 @@ class IRContext { inline IteratorRange debugs3() const; // Iterators for debug info instructions (excluding OpLine & OpNoLine) - // contained in this module. These are OpExtInst for DebugInfo extension - // placed between section 9 and 10. + // contained in this module. These are OpExtInst & + // OpExtInstWithForwardRefsKHR for DebugInfo extension placed between section + // 9 and 10. inline Module::inst_iterator ext_inst_debuginfo_begin(); inline Module::inst_iterator ext_inst_debuginfo_end(); inline IteratorRange ext_inst_debuginfo(); @@ -204,17 +212,26 @@ class IRContext { // Add |capability| to the module, if it is not already enabled. inline void AddCapability(spv::Capability capability); - // Appends a capability instruction to this module. inline void AddCapability(std::unique_ptr&& c); + // Removes instruction declaring `capability` from this module. + // Returns true if the capability was removed, false otherwise. + bool RemoveCapability(spv::Capability capability); + // Appends an extension instruction to this module. inline void AddExtension(const std::string& ext_name); inline void AddExtension(std::unique_ptr&& e); + // Removes instruction declaring `extension` from this module. + // Returns true if the extension was removed, false otherwise. + bool RemoveExtension(Extension extension); + // Appends an extended instruction set instruction to this module. inline void AddExtInstImport(const std::string& name); inline void AddExtInstImport(std::unique_ptr&& e); // Set the memory model for this module. inline void SetMemoryModel(std::unique_ptr&& m); + // Get the memory model for this module. + inline const Instruction* GetMemoryModel() const; // Appends an entry point instruction to this module. inline void AddEntryPoint(std::unique_ptr&& e); // Appends an execution mode instruction to this module. @@ -238,6 +255,8 @@ class IRContext { inline void AddType(std::unique_ptr&& t); // Appends a constant, global variable, or OpUndef instruction to this module. inline void AddGlobalValue(std::unique_ptr&& v); + // Prepends a function declaration to this module. + inline void AddFunctionDeclaration(std::unique_ptr&& f); // Appends a function to this module. inline void AddFunction(std::unique_ptr&& f); @@ -422,6 +441,15 @@ class IRContext { // instruction exists. Instruction* KillInst(Instruction* inst); + // Deletes all the instruction in the range [`begin`; `end`[, for which the + // unary predicate `condition` returned true. + // Returns true if at least one instruction was removed, false otherwise. + // + // Pointer and iterator pointing to the deleted instructions become invalid. + // However other pointers and iterators are still valid. + bool KillInstructionIf(Module::inst_iterator begin, Module::inst_iterator end, + std::function condition); + // Collects the non-semantic instruction tree that uses |inst|'s result id // to be killed later. void CollectNonSemanticTree(Instruction* inst, @@ -645,6 +673,17 @@ class IRContext { // all have the same stage. spv::ExecutionModel GetStage(); + // Returns true of the current target environment is at least that of the + // given environment. + bool IsTargetEnvAtLeast(spv_target_env env) { + // A bit of a hack. We assume that the target environments are appended to + // the enum, so that there is an appropriate order. + return syntax_context_->target_env >= env; + } + + // Return the target environment for the current context. + spv_target_env GetTargetEnv() const { return syntax_context_->target_env; } + private: // Builds the def-use manager from scratch, even if it was already valid. void BuildDefUseManager() { @@ -761,7 +800,8 @@ class IRContext { // Analyzes the features in the owned module. Builds the manager if required. void AnalyzeFeatures() { - feature_mgr_ = MakeUnique(grammar_); + feature_mgr_ = + std::unique_ptr(new FeatureManager(grammar_)); feature_mgr_->Analyze(module()); } @@ -953,6 +993,22 @@ IteratorRange IRContext::capabilities() const { return ((const Module*)module())->capabilities(); } +Module::inst_iterator IRContext::extension_begin() { + return module()->extension_begin(); +} + +Module::inst_iterator IRContext::extension_end() { + return module()->extension_end(); +} + +IteratorRange IRContext::extensions() { + return module()->extensions(); +} + +IteratorRange IRContext::extensions() const { + return ((const Module*)module())->extensions(); +} + Module::inst_iterator IRContext::types_values_begin() { return module()->types_values_begin(); } @@ -1103,6 +1159,10 @@ void IRContext::SetMemoryModel(std::unique_ptr&& m) { module()->SetMemoryModel(std::move(m)); } +const Instruction* IRContext::GetMemoryModel() const { + return module()->GetMemoryModel(); +} + void IRContext::AddEntryPoint(std::unique_ptr&& e) { module()->AddEntryPoint(std::move(e)); } @@ -1162,6 +1222,10 @@ void IRContext::AddGlobalValue(std::unique_ptr&& v) { module()->AddGlobalValue(std::move(v)); } +void IRContext::AddFunctionDeclaration(std::unique_ptr&& f) { + module()->AddFunctionDeclaration(std::move(f)); +} + void IRContext::AddFunction(std::unique_ptr&& f) { module()->AddFunction(std::move(f)); } diff --git a/third_party/spirv-tools/source/opt/ir_loader.cpp b/third_party/spirv-tools/source/opt/ir_loader.cpp index e9b7bbfc2b..a78504880f 100644 --- a/third_party/spirv-tools/source/opt/ir_loader.cpp +++ b/third_party/spirv-tools/source/opt/ir_loader.cpp @@ -42,7 +42,7 @@ IrLoader::IrLoader(const MessageConsumer& consumer, Module* m) bool IsLineInst(const spv_parsed_instruction_t* inst) { const auto opcode = static_cast(inst->opcode); if (IsOpLineInst(opcode)) return true; - if (opcode != spv::Op::OpExtInst) return false; + if (!spvIsExtendedInstruction(opcode)) return false; if (inst->ext_inst_type != SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) return false; const uint32_t ext_inst_index = inst->words[kExtInstSetIndex]; @@ -65,7 +65,7 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) { // create a new instruction, but simply keep the information in // struct DebugScope. const auto opcode = static_cast(inst->opcode); - if (opcode == spv::Op::OpExtInst && + if (spvIsExtendedInstruction(opcode) && spvExtInstIsDebugInfo(inst->ext_inst_type)) { const uint32_t ext_inst_index = inst->words[kExtInstSetIndex]; if (inst->ext_inst_type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 || @@ -209,10 +209,10 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) { } else if (IsConstantInst(opcode) || opcode == spv::Op::OpVariable || opcode == spv::Op::OpUndef) { module_->AddGlobalValue(std::move(spv_inst)); - } else if (opcode == spv::Op::OpExtInst && + } else if (spvIsExtendedInstruction(opcode) && spvExtInstIsDebugInfo(inst->ext_inst_type)) { module_->AddExtInstDebugInfo(std::move(spv_inst)); - } else if (opcode == spv::Op::OpExtInst && + } else if (spvIsExtendedInstruction(opcode) && spvExtInstIsNonSemantic(inst->ext_inst_type)) { // If there are no functions, add the non-semantic instructions to the // global values. Otherwise append it to the list of the last function. @@ -235,7 +235,7 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) { last_dbg_scope_ = DebugScope(kNoDebugScope, kNoInlinedAt); if (last_dbg_scope_.GetLexicalScope() != kNoDebugScope) spv_inst->SetDebugScope(last_dbg_scope_); - if (opcode == spv::Op::OpExtInst && + if (spvIsExtendedInstruction(opcode) && spvExtInstIsDebugInfo(inst->ext_inst_type)) { const uint32_t ext_inst_index = inst->words[kExtInstSetIndex]; if (inst->ext_inst_type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100) { diff --git a/third_party/spirv-tools/source/opt/licm_pass.cpp b/third_party/spirv-tools/source/opt/licm_pass.cpp index 514518b467..f2a6e4df56 100644 --- a/third_party/spirv-tools/source/opt/licm_pass.cpp +++ b/third_party/spirv-tools/source/opt/licm_pass.cpp @@ -15,7 +15,6 @@ #include "source/opt/licm_pass.h" #include -#include #include "source/opt/module.h" #include "source/opt/pass.h" @@ -85,7 +84,7 @@ Pass::Status LICMPass::AnalyseAndHoistFromBB( bool modified = false; std::function hoist_inst = [this, &loop, &modified](Instruction* inst) { - if (loop->ShouldHoistInstruction(this->context(), inst)) { + if (loop->ShouldHoistInstruction(*inst)) { if (!HoistInstruction(loop, inst)) { return false; } diff --git a/third_party/spirv-tools/source/opt/liveness.cpp b/third_party/spirv-tools/source/opt/liveness.cpp index fdf3f4e110..dae705dc5b 100644 --- a/third_party/spirv-tools/source/opt/liveness.cpp +++ b/third_party/spirv-tools/source/opt/liveness.cpp @@ -123,21 +123,29 @@ uint32_t LivenessManager::GetLocSize(const analysis::Type* type) const { return 1; } -const analysis::Type* LivenessManager::GetComponentType( - uint32_t index, const analysis::Type* agg_type) const { - auto arr_type = agg_type->AsArray(); - if (arr_type) return arr_type->element_type(); - auto struct_type = agg_type->AsStruct(); - if (struct_type) return struct_type->element_types()[index]; - auto mat_type = agg_type->AsMatrix(); - if (mat_type) return mat_type->element_type(); - auto vec_type = agg_type->AsVector(); - assert(vec_type && "unexpected non-aggregate type"); - return vec_type->element_type(); +uint32_t LivenessManager::GetComponentType(uint32_t index, + uint32_t agg_type_id) const { + analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); + Instruction* agg_type_inst = def_use_mgr->GetDef(agg_type_id); + + const uint32_t kArrayElementInIdx = 0; + switch (agg_type_inst->opcode()) { + case spv::Op::OpTypeArray: + case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeVector: + return agg_type_inst->GetSingleWordInOperand(kArrayElementInIdx); + case spv::Op::OpTypeStruct: + return agg_type_inst->GetSingleWordInOperand(index); + default: + assert(false && "unexpected aggregate type"); + return 0; + } } uint32_t LivenessManager::GetLocOffset(uint32_t index, - const analysis::Type* agg_type) const { + uint32_t agg_type_id) const { + analysis::TypeManager* type_mgr = context()->get_type_mgr(); + const analysis::Type* agg_type = type_mgr->GetType(agg_type_id); auto arr_type = agg_type->AsArray(); if (arr_type) return index * GetLocSize(arr_type->element_type()); auto struct_type = agg_type->AsStruct(); @@ -161,12 +169,11 @@ uint32_t LivenessManager::GetLocOffset(uint32_t index, return 0; } -void LivenessManager::AnalyzeAccessChainLoc(const Instruction* ac, - const analysis::Type** curr_type, - uint32_t* offset, bool* no_loc, - bool is_patch, bool input) { +uint32_t LivenessManager::AnalyzeAccessChainLoc(const Instruction* ac, + uint32_t curr_type_id, + uint32_t* offset, bool* no_loc, + bool is_patch, bool input) { analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); analysis::DecorationManager* deco_mgr = context()->get_decoration_mgr(); // For tesc, tese and geom input variables, and tesc output variables, // first array index does not contribute to offset. @@ -178,15 +185,18 @@ void LivenessManager::AnalyzeAccessChainLoc(const Instruction* ac, (!input && stage == spv::ExecutionModel::TessellationControl)) skip_first_index = !is_patch; uint32_t ocnt = 0; - ac->WhileEachInOperand([this, &ocnt, def_use_mgr, type_mgr, deco_mgr, - curr_type, offset, no_loc, + ac->WhileEachInOperand([this, &ocnt, def_use_mgr, deco_mgr, &curr_type_id, + offset, no_loc, skip_first_index](const uint32_t* opnd) { if (ocnt >= 1) { // Skip first index's contribution to offset if indicated + Instruction* curr_type_inst = def_use_mgr->GetDef(curr_type_id); if (ocnt == 1 && skip_first_index) { - auto arr_type = (*curr_type)->AsArray(); - assert(arr_type && "unexpected wrapper type"); - *curr_type = arr_type->element_type(); + assert(curr_type_inst->opcode() == spv::Op::OpTypeArray && + "unexpected wrapper type"); + const uint32_t kArrayElementTypeInIdx = 0; + curr_type_id = + curr_type_inst->GetSingleWordInOperand(kArrayElementTypeInIdx); ocnt++; return true; } @@ -196,12 +206,10 @@ void LivenessManager::AnalyzeAccessChainLoc(const Instruction* ac, // If current type is struct, look for location decoration on member and // reset offset if found. auto index = idx_inst->GetSingleWordInOperand(0); - auto str_type = (*curr_type)->AsStruct(); - if (str_type) { + if (curr_type_inst->opcode() == spv::Op::OpTypeStruct) { uint32_t loc = 0; - auto str_type_id = type_mgr->GetId(str_type); bool no_mem_loc = deco_mgr->WhileEachDecoration( - str_type_id, uint32_t(spv::Decoration::Location), + curr_type_id, uint32_t(spv::Decoration::Location), [&loc, index, no_loc](const Instruction& deco) { assert(deco.opcode() == spv::Op::OpMemberDecorate && "unexpected decoration"); @@ -216,19 +224,20 @@ void LivenessManager::AnalyzeAccessChainLoc(const Instruction* ac, }); if (!no_mem_loc) { *offset = loc; - *curr_type = GetComponentType(index, *curr_type); + curr_type_id = curr_type_inst->GetSingleWordInOperand(index); ocnt++; return true; } } // Update offset and current type based on constant index. - *offset += GetLocOffset(index, *curr_type); - *curr_type = GetComponentType(index, *curr_type); + *offset += GetLocOffset(index, curr_type_id); + curr_type_id = GetComponentType(index, curr_type_id); } ocnt++; return true; }); + return curr_type_id; } void LivenessManager::MarkRefLive(const Instruction* ref, Instruction* var) { @@ -268,8 +277,15 @@ void LivenessManager::MarkRefLive(const Instruction* ref, Instruction* var) { // through constant indices and mark those locs live. Assert if no location // found. uint32_t offset = loc; - auto curr_type = var_type; - AnalyzeAccessChainLoc(ref, &curr_type, &offset, &no_loc, is_patch); + Instruction* ptr_type_inst = + context()->get_def_use_mgr()->GetDef(var->type_id()); + assert(ptr_type && "unexpected var type"); + const uint32_t kPointerTypePointeeIdx = 1; + uint32_t var_type_id = + ptr_type_inst->GetSingleWordInOperand(kPointerTypePointeeIdx); + uint32_t curr_type_id = + AnalyzeAccessChainLoc(ref, var_type_id, &offset, &no_loc, is_patch); + auto curr_type = type_mgr->GetType(curr_type_id); assert(!no_loc && "missing input variable location"); MarkLocsLive(offset, GetLocSize(curr_type)); } @@ -277,15 +293,18 @@ void LivenessManager::MarkRefLive(const Instruction* ref, Instruction* var) { void LivenessManager::ComputeLiveness() { InitializeAnalysis(); analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); - analysis::TypeManager* type_mgr = context()->get_type_mgr(); // Process all input variables for (auto& var : context()->types_values()) { if (var.opcode() != spv::Op::OpVariable) { continue; } - analysis::Type* var_type = type_mgr->GetType(var.type_id()); - analysis::Pointer* ptr_type = var_type->AsPointer(); - if (ptr_type->storage_class() != spv::StorageClass::Input) { + Instruction* var_type_inst = def_use_mgr->GetDef(var.type_id()); + assert(var_type_inst->opcode() == spv::Op::OpTypePointer && + "Expected a pointer type"); + const uint32_t kPointerTypeStorageClassInIdx = 0; + spv::StorageClass sc = static_cast( + var_type_inst->GetSingleWordInOperand(kPointerTypeStorageClassInIdx)); + if (sc != spv::StorageClass::Input) { continue; } // If var is builtin, mark live if analyzed and continue to next variable @@ -295,21 +314,22 @@ void LivenessManager::ComputeLiveness() { // continue to next variable. Input interface blocks will only appear // in tesc, tese and geom shaders. Will need to strip off one level of // arrayness to get to block type. - auto pte_type = ptr_type->pointee_type(); - auto arr_type = pte_type->AsArray(); - if (arr_type) { - auto elt_type = arr_type->element_type(); - auto str_type = elt_type->AsStruct(); - if (str_type) { - auto str_type_id = type_mgr->GetId(str_type); - if (AnalyzeBuiltIn(str_type_id)) continue; + const uint32_t kPointerTypePointeeTypeInIdx = 1; + uint32_t pte_type_id = + var_type_inst->GetSingleWordInOperand(kPointerTypePointeeTypeInIdx); + Instruction* pte_type_inst = def_use_mgr->GetDef(pte_type_id); + if (pte_type_inst->opcode() == spv::Op::OpTypeArray) { + uint32_t array_elt_type_id = pte_type_inst->GetSingleWordInOperand(0); + Instruction* arr_elt_type = def_use_mgr->GetDef(array_elt_type_id); + if (arr_elt_type->opcode() == spv::Op::OpTypeStruct) { + if (AnalyzeBuiltIn(array_elt_type_id)) continue; } } // Mark all used locations of var live def_use_mgr->ForEachUser(var_id, [this, &var](Instruction* user) { auto op = user->opcode(); if (op == spv::Op::OpEntryPoint || op == spv::Op::OpName || - op == spv::Op::OpDecorate) { + op == spv::Op::OpDecorate || user->IsNonSemanticInstruction()) { return; } MarkRefLive(user, &var); diff --git a/third_party/spirv-tools/source/opt/liveness.h b/third_party/spirv-tools/source/opt/liveness.h index 7d8a9fb408..70500059a2 100644 --- a/third_party/spirv-tools/source/opt/liveness.h +++ b/third_party/spirv-tools/source/opt/liveness.h @@ -41,13 +41,13 @@ class LivenessManager { // Return true if builtin |bi| is being analyzed. bool IsAnalyzedBuiltin(uint32_t bi); - // Determine starting loc |offset| and the type |cur_type| of - // access chain |ac|. Set |no_loc| to true if no loc found. - // |is_patch| indicates if patch variable. |input| is true - // if input variable, otherwise output variable. - void AnalyzeAccessChainLoc(const Instruction* ac, - const analysis::Type** curr_type, uint32_t* offset, - bool* no_loc, bool is_patch, bool input = true); + // Return the result type of |ac| when applied to |cur_type_id|. Set + // |no_loc| to true if no loc found. Set |is_patch| indicates if the variable + // is a patch variable. Set |input| if the variable is an input variable. + // Otherwise it is assumed that the variable is an output variable. + uint32_t AnalyzeAccessChainLoc(const Instruction* ac, uint32_t curr_type_id, + uint32_t* offset, bool* no_loc, bool is_patch, + bool input = true); // Return size of |type_id| in units of locations uint32_t GetLocSize(const analysis::Type* type) const; @@ -68,13 +68,12 @@ class LivenessManager { // Mark |count| locations starting at location |start|. void MarkLocsLive(uint32_t start, uint32_t count); - // Return type of component of aggregate type |agg_type| at |index| - const analysis::Type* GetComponentType(uint32_t index, - const analysis::Type* agg_type) const; + // Return type of the member |index| in the aggregate type |agg_type_id|. + uint32_t GetComponentType(uint32_t index, uint32_t agg_type_id) const; - // Return offset of |index| into aggregate type |agg_type| in units of - // input locations - uint32_t GetLocOffset(uint32_t index, const analysis::Type* agg_type) const; + // Return offset of member |index| in the aggregate type |agg_type_id| in + // units of input locations. + uint32_t GetLocOffset(uint32_t index, uint32_t agg_type_id) const; // Populate live_locs_ and live_builtins_ void ComputeLiveness(); diff --git a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp index 66e8813365..2bfc7816ec 100644 --- a/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_access_chain_convert_pass.cpp @@ -1,6 +1,8 @@ // Copyright (c) 2017 The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +18,6 @@ #include "source/opt/local_access_chain_convert_pass.h" -#include "ir_builder.h" #include "ir_context.h" #include "iterator.h" #include "source/util/string_utils.h" @@ -398,60 +399,41 @@ Pass::Status LocalAccessChainConvertPass::Process() { void LocalAccessChainConvertPass::InitExtensions() { extensions_allowlist_.clear(); - extensions_allowlist_.insert({ - "SPV_AMD_shader_explicit_vertex_parameter", - "SPV_AMD_shader_trinary_minmax", - "SPV_AMD_gcn_shader", - "SPV_KHR_shader_ballot", - "SPV_AMD_shader_ballot", - "SPV_AMD_gpu_shader_half_float", - "SPV_KHR_shader_draw_parameters", - "SPV_KHR_subgroup_vote", - "SPV_KHR_8bit_storage", - "SPV_KHR_16bit_storage", - "SPV_KHR_device_group", - "SPV_KHR_multiview", - "SPV_NVX_multiview_per_view_attributes", - "SPV_NV_viewport_array2", - "SPV_NV_stereo_view_rendering", - "SPV_NV_sample_mask_override_coverage", - "SPV_NV_geometry_shader_passthrough", - "SPV_AMD_texture_gather_bias_lod", - "SPV_KHR_storage_buffer_storage_class", - // SPV_KHR_variable_pointers - // Currently do not support extended pointer expressions - "SPV_AMD_gpu_shader_int16", - "SPV_KHR_post_depth_coverage", - "SPV_KHR_shader_atomic_counter_ops", - "SPV_EXT_shader_stencil_export", - "SPV_EXT_shader_viewport_index_layer", - "SPV_AMD_shader_image_load_store_lod", - "SPV_AMD_shader_fragment_mask", - "SPV_EXT_fragment_fully_covered", - "SPV_AMD_gpu_shader_half_float_fetch", - "SPV_GOOGLE_decorate_string", - "SPV_GOOGLE_hlsl_functionality1", - "SPV_GOOGLE_user_type", - "SPV_NV_shader_subgroup_partitioned", - "SPV_EXT_demote_to_helper_invocation", - "SPV_EXT_descriptor_indexing", - "SPV_NV_fragment_shader_barycentric", - "SPV_NV_compute_shader_derivatives", - "SPV_NV_shader_image_footprint", - "SPV_NV_shading_rate", - "SPV_NV_mesh_shader", - "SPV_NV_ray_tracing", - "SPV_KHR_ray_tracing", - "SPV_KHR_ray_query", - "SPV_EXT_fragment_invocation_density", - "SPV_KHR_terminate_invocation", - "SPV_KHR_subgroup_uniform_control_flow", - "SPV_KHR_integer_dot_product", - "SPV_EXT_shader_image_int64", - "SPV_KHR_non_semantic_info", - "SPV_KHR_uniform_group_instructions", - "SPV_KHR_fragment_shader_barycentric", - }); + extensions_allowlist_.insert( + {"SPV_AMD_shader_explicit_vertex_parameter", + "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader", + "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot", + "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters", + "SPV_KHR_subgroup_vote", "SPV_KHR_8bit_storage", "SPV_KHR_16bit_storage", + "SPV_KHR_device_group", "SPV_KHR_multiview", + "SPV_NVX_multiview_per_view_attributes", "SPV_NV_viewport_array2", + "SPV_NV_stereo_view_rendering", "SPV_NV_sample_mask_override_coverage", + "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod", + "SPV_KHR_storage_buffer_storage_class", + // SPV_KHR_variable_pointers + // Currently do not support extended pointer expressions + "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage", + "SPV_KHR_shader_atomic_counter_ops", "SPV_EXT_shader_stencil_export", + "SPV_EXT_shader_viewport_index_layer", + "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_fragment_mask", + "SPV_EXT_fragment_fully_covered", "SPV_AMD_gpu_shader_half_float_fetch", + "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", + "SPV_GOOGLE_user_type", "SPV_NV_shader_subgroup_partitioned", + "SPV_EXT_demote_to_helper_invocation", "SPV_EXT_descriptor_indexing", + "SPV_NV_fragment_shader_barycentric", + "SPV_NV_compute_shader_derivatives", "SPV_NV_shader_image_footprint", + "SPV_NV_shading_rate", "SPV_NV_mesh_shader", "SPV_EXT_mesh_shader", + "SPV_NV_ray_tracing", "SPV_KHR_ray_tracing", "SPV_KHR_ray_query", + "SPV_EXT_fragment_invocation_density", "SPV_KHR_terminate_invocation", + "SPV_KHR_subgroup_uniform_control_flow", "SPV_KHR_integer_dot_product", + "SPV_EXT_shader_image_int64", "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", "SPV_KHR_vulkan_memory_model", + "SPV_NV_bindless_texture", "SPV_EXT_shader_atomic_float_add", + "SPV_EXT_fragment_shader_interlock", + "SPV_KHR_compute_shader_derivatives", "SPV_NV_cooperative_matrix", + "SPV_KHR_cooperative_matrix", "SPV_KHR_ray_tracing_position_fetch", + "SPV_AMDX_shader_enqueue", "SPV_KHR_fragment_shading_rate"}); } bool LocalAccessChainConvertPass::AnyIndexIsOutOfBounds( diff --git a/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp b/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp index c1789c8851..86ad952758 100644 --- a/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_single_block_elim_pass.cpp @@ -1,6 +1,8 @@ // Copyright (c) 2017 The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +20,6 @@ #include -#include "source/opt/iterator.h" #include "source/util/string_utils.h" namespace spvtools { @@ -234,60 +235,70 @@ Pass::Status LocalSingleBlockLoadStoreElimPass::Process() { void LocalSingleBlockLoadStoreElimPass::InitExtensions() { extensions_allowlist_.clear(); - extensions_allowlist_.insert({ - "SPV_AMD_shader_explicit_vertex_parameter", - "SPV_AMD_shader_trinary_minmax", - "SPV_AMD_gcn_shader", - "SPV_KHR_shader_ballot", - "SPV_AMD_shader_ballot", - "SPV_AMD_gpu_shader_half_float", - "SPV_KHR_shader_draw_parameters", - "SPV_KHR_subgroup_vote", - "SPV_KHR_8bit_storage", - "SPV_KHR_16bit_storage", - "SPV_KHR_device_group", - "SPV_KHR_multiview", - "SPV_NVX_multiview_per_view_attributes", - "SPV_NV_viewport_array2", - "SPV_NV_stereo_view_rendering", - "SPV_NV_sample_mask_override_coverage", - "SPV_NV_geometry_shader_passthrough", - "SPV_AMD_texture_gather_bias_lod", - "SPV_KHR_storage_buffer_storage_class", - "SPV_KHR_variable_pointers", - "SPV_AMD_gpu_shader_int16", - "SPV_KHR_post_depth_coverage", - "SPV_KHR_shader_atomic_counter_ops", - "SPV_EXT_shader_stencil_export", - "SPV_EXT_shader_viewport_index_layer", - "SPV_AMD_shader_image_load_store_lod", - "SPV_AMD_shader_fragment_mask", - "SPV_EXT_fragment_fully_covered", - "SPV_AMD_gpu_shader_half_float_fetch", - "SPV_GOOGLE_decorate_string", - "SPV_GOOGLE_hlsl_functionality1", - "SPV_GOOGLE_user_type", - "SPV_NV_shader_subgroup_partitioned", - "SPV_EXT_demote_to_helper_invocation", - "SPV_EXT_descriptor_indexing", - "SPV_NV_fragment_shader_barycentric", - "SPV_NV_compute_shader_derivatives", - "SPV_NV_shader_image_footprint", - "SPV_NV_shading_rate", - "SPV_NV_mesh_shader", - "SPV_NV_ray_tracing", - "SPV_KHR_ray_tracing", - "SPV_KHR_ray_query", - "SPV_EXT_fragment_invocation_density", - "SPV_EXT_physical_storage_buffer", - "SPV_KHR_terminate_invocation", - "SPV_KHR_subgroup_uniform_control_flow", - "SPV_KHR_integer_dot_product", - "SPV_EXT_shader_image_int64", - "SPV_KHR_non_semantic_info", - "SPV_KHR_uniform_group_instructions", - "SPV_KHR_fragment_shader_barycentric", - }); + extensions_allowlist_.insert({"SPV_AMD_shader_explicit_vertex_parameter", + "SPV_AMD_shader_trinary_minmax", + "SPV_AMD_gcn_shader", + "SPV_KHR_shader_ballot", + "SPV_AMD_shader_ballot", + "SPV_AMDX_shader_enqueue", + "SPV_AMD_gpu_shader_half_float", + "SPV_KHR_shader_draw_parameters", + "SPV_KHR_subgroup_vote", + "SPV_KHR_8bit_storage", + "SPV_KHR_16bit_storage", + "SPV_KHR_device_group", + "SPV_KHR_multiview", + "SPV_NVX_multiview_per_view_attributes", + "SPV_NV_viewport_array2", + "SPV_NV_stereo_view_rendering", + "SPV_NV_sample_mask_override_coverage", + "SPV_NV_geometry_shader_passthrough", + "SPV_AMD_texture_gather_bias_lod", + "SPV_KHR_storage_buffer_storage_class", + "SPV_KHR_variable_pointers", + "SPV_AMD_gpu_shader_int16", + "SPV_KHR_post_depth_coverage", + "SPV_KHR_shader_atomic_counter_ops", + "SPV_EXT_shader_stencil_export", + "SPV_EXT_shader_viewport_index_layer", + "SPV_AMD_shader_image_load_store_lod", + "SPV_AMD_shader_fragment_mask", + "SPV_EXT_fragment_fully_covered", + "SPV_AMD_gpu_shader_half_float_fetch", + "SPV_GOOGLE_decorate_string", + "SPV_GOOGLE_hlsl_functionality1", + "SPV_GOOGLE_user_type", + "SPV_NV_shader_subgroup_partitioned", + "SPV_EXT_demote_to_helper_invocation", + "SPV_EXT_descriptor_indexing", + "SPV_NV_fragment_shader_barycentric", + "SPV_NV_compute_shader_derivatives", + "SPV_NV_shader_image_footprint", + "SPV_NV_shading_rate", + "SPV_NV_mesh_shader", + "SPV_EXT_mesh_shader", + "SPV_NV_ray_tracing", + "SPV_KHR_ray_tracing", + "SPV_KHR_ray_query", + "SPV_EXT_fragment_invocation_density", + "SPV_EXT_physical_storage_buffer", + "SPV_KHR_physical_storage_buffer", + "SPV_KHR_terminate_invocation", + "SPV_KHR_subgroup_uniform_control_flow", + "SPV_KHR_integer_dot_product", + "SPV_EXT_shader_image_int64", + "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", + "SPV_KHR_vulkan_memory_model", + "SPV_NV_bindless_texture", + "SPV_EXT_shader_atomic_float_add", + "SPV_EXT_fragment_shader_interlock", + "SPV_KHR_compute_shader_derivatives", + "SPV_NV_cooperative_matrix", + "SPV_KHR_cooperative_matrix", + "SPV_KHR_ray_tracing_position_fetch", + "SPV_KHR_fragment_shading_rate"}); } } // namespace opt diff --git a/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp b/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp index e494689fa6..6dc89be5c0 100644 --- a/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp +++ b/third_party/spirv-tools/source/opt/local_single_store_elim_pass.cpp @@ -1,6 +1,8 @@ // Copyright (c) 2017 The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,8 +19,6 @@ #include "source/opt/local_single_store_elim_pass.h" #include "source/cfa.h" -#include "source/latest_version_glsl_std_450_header.h" -#include "source/opt/iterator.h" #include "source/util/string_utils.h" namespace spvtools { @@ -88,57 +88,68 @@ Pass::Status LocalSingleStoreElimPass::Process() { } void LocalSingleStoreElimPass::InitExtensionAllowList() { - extensions_allowlist_.insert({ - "SPV_AMD_shader_explicit_vertex_parameter", - "SPV_AMD_shader_trinary_minmax", - "SPV_AMD_gcn_shader", - "SPV_KHR_shader_ballot", - "SPV_AMD_shader_ballot", - "SPV_AMD_gpu_shader_half_float", - "SPV_KHR_shader_draw_parameters", - "SPV_KHR_subgroup_vote", - "SPV_KHR_8bit_storage", - "SPV_KHR_16bit_storage", - "SPV_KHR_device_group", - "SPV_KHR_multiview", - "SPV_NVX_multiview_per_view_attributes", - "SPV_NV_viewport_array2", - "SPV_NV_stereo_view_rendering", - "SPV_NV_sample_mask_override_coverage", - "SPV_NV_geometry_shader_passthrough", - "SPV_AMD_texture_gather_bias_lod", - "SPV_KHR_storage_buffer_storage_class", - "SPV_KHR_variable_pointers", - "SPV_AMD_gpu_shader_int16", - "SPV_KHR_post_depth_coverage", - "SPV_KHR_shader_atomic_counter_ops", - "SPV_EXT_shader_stencil_export", - "SPV_EXT_shader_viewport_index_layer", - "SPV_AMD_shader_image_load_store_lod", - "SPV_AMD_shader_fragment_mask", - "SPV_EXT_fragment_fully_covered", - "SPV_AMD_gpu_shader_half_float_fetch", - "SPV_GOOGLE_decorate_string", - "SPV_GOOGLE_hlsl_functionality1", - "SPV_NV_shader_subgroup_partitioned", - "SPV_EXT_descriptor_indexing", - "SPV_NV_fragment_shader_barycentric", - "SPV_NV_compute_shader_derivatives", - "SPV_NV_shader_image_footprint", - "SPV_NV_shading_rate", - "SPV_NV_mesh_shader", - "SPV_NV_ray_tracing", - "SPV_KHR_ray_query", - "SPV_EXT_fragment_invocation_density", - "SPV_EXT_physical_storage_buffer", - "SPV_KHR_terminate_invocation", - "SPV_KHR_subgroup_uniform_control_flow", - "SPV_KHR_integer_dot_product", - "SPV_EXT_shader_image_int64", - "SPV_KHR_non_semantic_info", - "SPV_KHR_uniform_group_instructions", - "SPV_KHR_fragment_shader_barycentric", - }); + extensions_allowlist_.insert({"SPV_AMD_shader_explicit_vertex_parameter", + "SPV_AMD_shader_trinary_minmax", + "SPV_AMD_gcn_shader", + "SPV_KHR_shader_ballot", + "SPV_AMD_shader_ballot", + "SPV_AMD_gpu_shader_half_float", + "SPV_KHR_shader_draw_parameters", + "SPV_KHR_subgroup_vote", + "SPV_KHR_8bit_storage", + "SPV_KHR_16bit_storage", + "SPV_KHR_device_group", + "SPV_KHR_multiview", + "SPV_NVX_multiview_per_view_attributes", + "SPV_NV_viewport_array2", + "SPV_NV_stereo_view_rendering", + "SPV_NV_sample_mask_override_coverage", + "SPV_NV_geometry_shader_passthrough", + "SPV_AMD_texture_gather_bias_lod", + "SPV_KHR_storage_buffer_storage_class", + "SPV_KHR_variable_pointers", + "SPV_AMD_gpu_shader_int16", + "SPV_KHR_post_depth_coverage", + "SPV_KHR_shader_atomic_counter_ops", + "SPV_EXT_shader_stencil_export", + "SPV_EXT_shader_viewport_index_layer", + "SPV_AMD_shader_image_load_store_lod", + "SPV_AMD_shader_fragment_mask", + "SPV_EXT_fragment_fully_covered", + "SPV_AMD_gpu_shader_half_float_fetch", + "SPV_GOOGLE_decorate_string", + "SPV_GOOGLE_hlsl_functionality1", + "SPV_NV_shader_subgroup_partitioned", + "SPV_EXT_descriptor_indexing", + "SPV_NV_fragment_shader_barycentric", + "SPV_NV_compute_shader_derivatives", + "SPV_NV_shader_image_footprint", + "SPV_NV_shading_rate", + "SPV_NV_mesh_shader", + "SPV_EXT_mesh_shader", + "SPV_NV_ray_tracing", + "SPV_KHR_ray_query", + "SPV_EXT_fragment_invocation_density", + "SPV_EXT_physical_storage_buffer", + "SPV_KHR_physical_storage_buffer", + "SPV_KHR_terminate_invocation", + "SPV_KHR_subgroup_uniform_control_flow", + "SPV_KHR_integer_dot_product", + "SPV_EXT_shader_image_int64", + "SPV_KHR_non_semantic_info", + "SPV_KHR_uniform_group_instructions", + "SPV_KHR_fragment_shader_barycentric", + "SPV_KHR_vulkan_memory_model", + "SPV_NV_bindless_texture", + "SPV_EXT_shader_atomic_float_add", + "SPV_EXT_fragment_shader_interlock", + "SPV_KHR_compute_shader_derivatives", + "SPV_NV_cooperative_matrix", + "SPV_KHR_cooperative_matrix", + "SPV_KHR_ray_tracing_position_fetch", + "SPV_AMDX_shader_enqueue", + "SPV_KHR_fragment_shading_rate", + "SPV_KHR_ray_tracing"}); } bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) { std::vector users; diff --git a/third_party/spirv-tools/source/opt/log.h b/third_party/spirv-tools/source/opt/log.h index 68051002e2..4fb66fd455 100644 --- a/third_party/spirv-tools/source/opt/log.h +++ b/third_party/spirv-tools/source/opt/log.h @@ -23,7 +23,7 @@ #include "spirv-tools/libspirv.hpp" // Asserts the given condition is true. Otherwise, sends a message to the -// consumer and exits the problem with failure code. Accepts the following +// consumer and exits the program with failure code. Accepts the following // formats: // // SPIRV_ASSERT(, ); @@ -36,7 +36,9 @@ #if !defined(NDEBUG) #define SPIRV_ASSERT(consumer, ...) SPIRV_ASSERT_IMPL(consumer, __VA_ARGS__) #else -#define SPIRV_ASSERT(consumer, ...) +// Adding a use to avoid errors in the release build related to unused +// consumers. +#define SPIRV_ASSERT(consumer, ...) (void)(consumer) #endif // Logs a debug message to the consumer. Accepts the following formats: @@ -49,26 +51,11 @@ #if !defined(NDEBUG) && defined(SPIRV_LOG_DEBUG) #define SPIRV_DEBUG(consumer, ...) SPIRV_DEBUG_IMPL(consumer, __VA_ARGS__) #else -#define SPIRV_DEBUG(consumer, ...) +// Adding a use to avoid errors in the release build related to unused +// consumers. +#define SPIRV_DEBUG(consumer, ...) (void)(consumer) #endif -// Logs an error message to the consumer saying the given feature is -// unimplemented. -#define SPIRV_UNIMPLEMENTED(consumer, feature) \ - do { \ - spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \ - {static_cast(__LINE__), 0, 0}, \ - "unimplemented: " feature); \ - } while (0) - -// Logs an error message to the consumer saying the code location -// should be unreachable. -#define SPIRV_UNREACHABLE(consumer) \ - do { \ - spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \ - {static_cast(__LINE__), 0, 0}, "unreachable"); \ - } while (0) - // Helper macros for concatenating arguments. #define SPIRV_CONCATENATE(a, b) SPIRV_CONCATENATE_(a, b) #define SPIRV_CONCATENATE_(a, b) a##b diff --git a/third_party/spirv-tools/source/opt/loop_dependence.cpp b/third_party/spirv-tools/source/opt/loop_dependence.cpp index d7256bf840..e41c044afd 100644 --- a/third_party/spirv-tools/source/opt/loop_dependence.cpp +++ b/third_party/spirv-tools/source/opt/loop_dependence.cpp @@ -15,14 +15,12 @@ #include "source/opt/loop_dependence.h" #include -#include #include #include #include #include #include "source/opt/instruction.h" -#include "source/opt/scalar_analysis.h" #include "source/opt/scalar_analysis_nodes.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/loop_dependence_helpers.cpp b/third_party/spirv-tools/source/opt/loop_dependence_helpers.cpp index 929c9404ba..5d7d994035 100644 --- a/third_party/spirv-tools/source/opt/loop_dependence_helpers.cpp +++ b/third_party/spirv-tools/source/opt/loop_dependence_helpers.cpp @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/opt/loop_dependence.h" - #include #include #include @@ -23,7 +21,7 @@ #include "source/opt/basic_block.h" #include "source/opt/instruction.h" -#include "source/opt/scalar_analysis.h" +#include "source/opt/loop_dependence.h" #include "source/opt/scalar_analysis_nodes.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/loop_descriptor.cpp b/third_party/spirv-tools/source/opt/loop_descriptor.cpp index 172b978150..cbfc2e7599 100644 --- a/third_party/spirv-tools/source/opt/loop_descriptor.cpp +++ b/third_party/spirv-tools/source/opt/loop_descriptor.cpp @@ -15,17 +15,14 @@ #include "source/opt/loop_descriptor.h" #include -#include #include #include -#include #include #include #include "source/opt/cfg.h" #include "source/opt/constants.h" #include "source/opt/dominator_tree.h" -#include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" #include "source/opt/iterator.h" #include "source/opt/tree_iterator.h" @@ -453,25 +450,20 @@ bool Loop::IsLCSSA() const { return true; } -bool Loop::ShouldHoistInstruction(IRContext* context, Instruction* inst) { - return AreAllOperandsOutsideLoop(context, inst) && - inst->IsOpcodeCodeMotionSafe(); +bool Loop::ShouldHoistInstruction(const Instruction& inst) const { + return inst.IsOpcodeCodeMotionSafe() && AreAllOperandsOutsideLoop(inst) && + (!inst.IsLoad() || inst.IsReadOnlyLoad()); } -bool Loop::AreAllOperandsOutsideLoop(IRContext* context, Instruction* inst) { - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - bool all_outside_loop = true; +bool Loop::AreAllOperandsOutsideLoop(const Instruction& inst) const { + analysis::DefUseManager* def_use_mgr = GetContext()->get_def_use_mgr(); - const std::function operand_outside_loop = - [this, &def_use_mgr, &all_outside_loop](uint32_t* id) { - if (this->IsInsideLoop(def_use_mgr->GetDef(*id))) { - all_outside_loop = false; - return; - } + const std::function operand_outside_loop = + [this, &def_use_mgr](const uint32_t* id) { + return !this->IsInsideLoop(def_use_mgr->GetDef(*id)); }; - inst->ForEachInId(operand_outside_loop); - return all_outside_loop; + return inst.WhileEachInId(operand_outside_loop); } void Loop::ComputeLoopStructuredOrder( diff --git a/third_party/spirv-tools/source/opt/loop_descriptor.h b/third_party/spirv-tools/source/opt/loop_descriptor.h index 35256bc3fe..d451496e77 100644 --- a/third_party/spirv-tools/source/opt/loop_descriptor.h +++ b/third_party/spirv-tools/source/opt/loop_descriptor.h @@ -296,12 +296,12 @@ class Loop { // as a nested child loop. inline void SetParent(Loop* parent) { parent_ = parent; } - // Returns true is the instruction is invariant and safe to move wrt loop - bool ShouldHoistInstruction(IRContext* context, Instruction* inst); + // Returns true is the instruction is invariant and safe to move wrt loop. + bool ShouldHoistInstruction(const Instruction& inst) const; // Returns true if all operands of inst are in basic blocks not contained in - // loop - bool AreAllOperandsOutsideLoop(IRContext* context, Instruction* inst); + // loop. + bool AreAllOperandsOutsideLoop(const Instruction& inst) const; // Extract the initial value from the |induction| variable and store it in // |value|. If the function couldn't find the initial value of |induction| diff --git a/third_party/spirv-tools/source/opt/loop_fission.cpp b/third_party/spirv-tools/source/opt/loop_fission.cpp index 2ae05c3c3f..1bbe4baa34 100644 --- a/third_party/spirv-tools/source/opt/loop_fission.cpp +++ b/third_party/spirv-tools/source/opt/loop_fission.cpp @@ -499,6 +499,7 @@ Pass::Status LoopFissionPass::Process() { // next iteration. if (split_multiple_times_) { inner_most_loops = std::move(new_loops_to_split); + new_loops_to_split = {}; } else { break; } diff --git a/third_party/spirv-tools/source/opt/loop_fusion_pass.cpp b/third_party/spirv-tools/source/opt/loop_fusion_pass.cpp index bd8444ae56..097430fcf1 100644 --- a/third_party/spirv-tools/source/opt/loop_fusion_pass.cpp +++ b/third_party/spirv-tools/source/opt/loop_fusion_pass.cpp @@ -14,7 +14,6 @@ #include "source/opt/loop_fusion_pass.h" -#include "source/opt/ir_context.h" #include "source/opt/loop_descriptor.h" #include "source/opt/loop_fusion.h" #include "source/opt/register_pressure.h" diff --git a/third_party/spirv-tools/source/opt/loop_peeling.cpp b/third_party/spirv-tools/source/opt/loop_peeling.cpp index d512273035..25c6db1207 100644 --- a/third_party/spirv-tools/source/opt/loop_peeling.cpp +++ b/third_party/spirv-tools/source/opt/loop_peeling.cpp @@ -12,17 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "source/opt/loop_peeling.h" + #include #include -#include #include #include #include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" #include "source/opt/loop_descriptor.h" -#include "source/opt/loop_peeling.h" #include "source/opt/loop_utils.h" #include "source/opt/scalar_analysis.h" #include "source/opt/scalar_analysis_nodes.h" diff --git a/third_party/spirv-tools/source/opt/loop_unroller.cpp b/third_party/spirv-tools/source/opt/loop_unroller.cpp index 07b529d494..d9e34f2423 100644 --- a/third_party/spirv-tools/source/opt/loop_unroller.cpp +++ b/third_party/spirv-tools/source/opt/loop_unroller.cpp @@ -15,7 +15,6 @@ #include "source/opt/loop_unroller.h" #include -#include #include #include #include diff --git a/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp b/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp index b00d66de82..41f1a804bf 100644 --- a/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp +++ b/third_party/spirv-tools/source/opt/loop_unswitch_pass.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -31,7 +30,6 @@ #include "source/opt/ir_builder.h" #include "source/opt/ir_context.h" #include "source/opt/loop_descriptor.h" - #include "source/opt/loop_utils.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/mem_pass.cpp b/third_party/spirv-tools/source/opt/mem_pass.cpp index 5f59291865..65f45ec3b8 100644 --- a/third_party/spirv-tools/source/opt/mem_pass.cpp +++ b/third_party/spirv-tools/source/opt/mem_pass.cpp @@ -22,9 +22,7 @@ #include "source/cfa.h" #include "source/opt/basic_block.h" -#include "source/opt/dominator_analysis.h" #include "source/opt/ir_context.h" -#include "source/opt/iterator.h" namespace spvtools { namespace opt { @@ -45,6 +43,8 @@ bool MemPass::IsBaseTargetType(const Instruction* typeInst) const { case spv::Op::OpTypeSampler: case spv::Op::OpTypeSampledImage: case spv::Op::OpTypePointer: + case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: return true; default: break; @@ -78,6 +78,11 @@ bool MemPass::IsNonPtrAccessChain(const spv::Op opcode) const { bool MemPass::IsPtr(uint32_t ptrId) { uint32_t varId = ptrId; Instruction* ptrInst = get_def_use_mgr()->GetDef(varId); + if (ptrInst->opcode() == spv::Op::OpFunction) { + // A function is not a pointer, but it's return type could be, which will + // erroneously lead to this function returning true later on + return false; + } while (ptrInst->opcode() == spv::Op::OpCopyObject) { varId = ptrInst->GetSingleWordInOperand(kCopyObjectOperandInIdx); ptrInst = get_def_use_mgr()->GetDef(varId); @@ -410,6 +415,7 @@ void MemPass::RemoveBlock(Function::iterator* bi) { } bool MemPass::RemoveUnreachableBlocks(Function* func) { + if (func->IsDeclaration()) return false; bool modified = false; // Mark reachable all blocks reachable from the function's entry block. diff --git a/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.cpp b/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.cpp new file mode 100644 index 0000000000..dd79b6283f --- /dev/null +++ b/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.cpp @@ -0,0 +1,103 @@ +// Copyright (c) 2024 Google LLC +// +// 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 "modify_maximal_reconvergence.h" + +#include "source/opt/ir_context.h" +#include "source/util/make_unique.h" + +namespace spvtools { +namespace opt { + +Pass::Status ModifyMaximalReconvergence::Process() { + bool changed = false; + if (add_) { + changed = AddMaximalReconvergence(); + } else { + changed = RemoveMaximalReconvergence(); + } + return changed ? Pass::Status::SuccessWithChange + : Pass::Status::SuccessWithoutChange; +} + +bool ModifyMaximalReconvergence::AddMaximalReconvergence() { + bool changed = false; + bool has_extension = false; + bool has_shader = + context()->get_feature_mgr()->HasCapability(spv::Capability::Shader); + for (auto extension : context()->extensions()) { + if (extension.GetOperand(0).AsString() == "SPV_KHR_maximal_reconvergence") { + has_extension = true; + break; + } + } + + std::unordered_set entry_points_with_mode; + for (auto mode : get_module()->execution_modes()) { + if (spv::ExecutionMode(mode.GetSingleWordInOperand(1)) == + spv::ExecutionMode::MaximallyReconvergesKHR) { + entry_points_with_mode.insert(mode.GetSingleWordInOperand(0)); + } + } + + for (auto entry_point : get_module()->entry_points()) { + const uint32_t id = entry_point.GetSingleWordInOperand(1); + if (!entry_points_with_mode.count(id)) { + changed = true; + if (!has_extension) { + context()->AddExtension("SPV_KHR_maximal_reconvergence"); + has_extension = true; + } + if (!has_shader) { + context()->AddCapability(spv::Capability::Shader); + has_shader = true; + } + context()->AddExecutionMode(MakeUnique( + context(), spv::Op::OpExecutionMode, 0, 0, + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {id}}, + {SPV_OPERAND_TYPE_EXECUTION_MODE, + {static_cast( + spv::ExecutionMode::MaximallyReconvergesKHR)}}})); + entry_points_with_mode.insert(id); + } + } + + return changed; +} + +bool ModifyMaximalReconvergence::RemoveMaximalReconvergence() { + bool changed = false; + std::vector to_remove; + Instruction* mode = &*get_module()->execution_mode_begin(); + while (mode) { + if (mode->opcode() != spv::Op::OpExecutionMode && + mode->opcode() != spv::Op::OpExecutionModeId) { + break; + } + if (spv::ExecutionMode(mode->GetSingleWordInOperand(1)) == + spv::ExecutionMode::MaximallyReconvergesKHR) { + mode = context()->KillInst(mode); + changed = true; + } else { + mode = mode->NextNode(); + } + } + + changed |= + context()->RemoveExtension(Extension::kSPV_KHR_maximal_reconvergence); + return changed; +} +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.h b/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.h new file mode 100644 index 0000000000..8d9a698e9e --- /dev/null +++ b/third_party/spirv-tools/source/opt/modify_maximal_reconvergence.h @@ -0,0 +1,53 @@ +// Copyright (c) 2024 Google LLC +// +// 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 LIBSPIRV_OPT_MODIFY_MAXIMAL_RECONVERGENCE_H_ +#define LIBSPIRV_OPT_MODIFY_MAXIMAL_RECONVERGENCE_H_ + +#include "pass.h" + +namespace spvtools { +namespace opt { + +// Modifies entry points to either add or remove MaximallyReconvergesKHR +// +// This pass will either add or remove MaximallyReconvergesKHR to all entry +// points in the module. When adding the execution mode, it does not attempt to +// determine whether any ray tracing invocation repack instructions might be +// executed because it is a runtime restriction. That is left to the user. +class ModifyMaximalReconvergence : public Pass { + public: + const char* name() const override { return "modify-maximal-reconvergence"; } + Status Process() override; + + explicit ModifyMaximalReconvergence(bool add = true) : Pass(), add_(add) {} + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisDefUse | + IRContext::kAnalysisInstrToBlockMapping | + IRContext::kAnalysisDecorations | IRContext::kAnalysisCombinators | + IRContext::kAnalysisCFG | IRContext::kAnalysisNameMap | + IRContext::kAnalysisConstants | IRContext::kAnalysisTypes; + } + + private: + bool AddMaximalReconvergence(); + bool RemoveMaximalReconvergence(); + + bool add_; +}; +} // namespace opt +} // namespace spvtools + +#endif // LIBSPIRV_OPT_MODIFY_MAXIMAL_RECONVERGENCE_H_ diff --git a/third_party/spirv-tools/source/opt/module.h b/third_party/spirv-tools/source/opt/module.h index ed2f3454e1..98c16dc4c9 100644 --- a/third_party/spirv-tools/source/opt/module.h +++ b/third_party/spirv-tools/source/opt/module.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -119,6 +120,9 @@ class Module { // Appends a constant, global variable, or OpUndef instruction to this module. inline void AddGlobalValue(std::unique_ptr v); + // Prepends a function declaration to this module. + inline void AddFunctionDeclaration(std::unique_ptr f); + // Appends a function to this module. inline void AddFunction(std::unique_ptr f); @@ -379,6 +383,11 @@ inline void Module::AddGlobalValue(std::unique_ptr v) { types_values_.push_back(std::move(v)); } +inline void Module::AddFunctionDeclaration(std::unique_ptr f) { + // function declarations must come before function definitions. + functions_.emplace(functions_.begin(), std::move(f)); +} + inline void Module::AddFunction(std::unique_ptr f) { functions_.emplace_back(std::move(f)); } diff --git a/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.cpp b/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.cpp new file mode 100644 index 0000000000..8684feb4e0 --- /dev/null +++ b/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.cpp @@ -0,0 +1,112 @@ +// Copyright (c) 2024 Google LLC +// +// 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 "source/opt/opextinst_forward_ref_fixup_pass.h" + +#include +#include + +#include "source/extensions.h" +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "type_manager.h" + +namespace spvtools { +namespace opt { +namespace { + +// Returns true if the instruction |inst| has a forward reference to another +// debug instruction. +// |debug_ids| contains the list of IDs belonging to debug instructions. +// |seen_ids| contains the list of IDs already seen. +bool HasForwardReference(const Instruction& inst, + const std::unordered_set& debug_ids, + const std::unordered_set& seen_ids) { + const uint32_t num_in_operands = inst.NumInOperands(); + for (uint32_t i = 0; i < num_in_operands; ++i) { + const Operand& op = inst.GetInOperand(i); + if (!spvIsIdType(op.type)) continue; + + if (debug_ids.count(op.AsId()) == 0) continue; + + if (seen_ids.count(op.AsId()) == 0) return true; + } + + return false; +} + +// Replace |inst| opcode with OpExtInstWithForwardRefsKHR or OpExtInst +// if required to comply with forward references. +bool ReplaceOpcodeIfRequired(Instruction& inst, bool hasForwardReferences) { + if (hasForwardReferences && + inst.opcode() != spv::Op::OpExtInstWithForwardRefsKHR) + inst.SetOpcode(spv::Op::OpExtInstWithForwardRefsKHR); + else if (!hasForwardReferences && inst.opcode() != spv::Op::OpExtInst) + inst.SetOpcode(spv::Op::OpExtInst); + else + return false; + return true; +} + +// Returns all the result IDs of the instructions in |range|. +std::unordered_set gatherResultIds( + const IteratorRange& range) { + std::unordered_set output; + for (const auto& it : range) output.insert(it.result_id()); + return output; +} + +} // namespace + +Pass::Status OpExtInstWithForwardReferenceFixupPass::Process() { + std::unordered_set seen_ids = + gatherResultIds(get_module()->ext_inst_imports()); + std::unordered_set debug_ids = + gatherResultIds(get_module()->ext_inst_debuginfo()); + for (uint32_t id : seen_ids) debug_ids.insert(id); + + bool moduleChanged = false; + bool hasAtLeastOneForwardReference = false; + IRContext* ctx = context(); + for (Instruction& inst : get_module()->ext_inst_debuginfo()) { + if (inst.opcode() != spv::Op::OpExtInst && + inst.opcode() != spv::Op::OpExtInstWithForwardRefsKHR) + continue; + + seen_ids.insert(inst.result_id()); + bool hasForwardReferences = HasForwardReference(inst, debug_ids, seen_ids); + hasAtLeastOneForwardReference |= hasForwardReferences; + + if (ReplaceOpcodeIfRequired(inst, hasForwardReferences)) { + moduleChanged = true; + ctx->AnalyzeUses(&inst); + } + } + + if (hasAtLeastOneForwardReference != + ctx->get_feature_mgr()->HasExtension( + kSPV_KHR_relaxed_extended_instruction)) { + if (hasAtLeastOneForwardReference) + ctx->AddExtension("SPV_KHR_relaxed_extended_instruction"); + else + ctx->RemoveExtension(Extension::kSPV_KHR_relaxed_extended_instruction); + moduleChanged = true; + } + + return moduleChanged ? Status::SuccessWithChange + : Status::SuccessWithoutChange; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.h b/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.h new file mode 100644 index 0000000000..26e5b81cb4 --- /dev/null +++ b/third_party/spirv-tools/source/opt/opextinst_forward_ref_fixup_pass.h @@ -0,0 +1,48 @@ +// Copyright (c) 2024 Google LLC +// +// 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 SOURCE_OPT_OPEXTINST_FORWARD_REF_FIXUP_H +#define SOURCE_OPT_OPEXTINST_FORWARD_REF_FIXUP_H + +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +class OpExtInstWithForwardReferenceFixupPass : public Pass { + public: + const char* name() const override { return "fix-opextinst-opcodes"; } + Status Process() override; + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisInstrToBlockMapping | + IRContext::kAnalysisDecorations | IRContext::kAnalysisCombinators | + IRContext::kAnalysisCFG | IRContext::kAnalysisDominatorAnalysis | + IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap | + IRContext::kAnalysisScalarEvolution | + IRContext::kAnalysisRegisterPressure | + IRContext::kAnalysisValueNumberTable | + IRContext::kAnalysisStructuredCFG | + IRContext::kAnalysisBuiltinVarId | + IRContext::kAnalysisIdToFuncMapping | IRContext::kAnalysisTypes | + IRContext::kAnalysisDefUse | IRContext::kAnalysisConstants; + } +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_OPEXTINST_FORWARD_REF_FIXUP_H diff --git a/third_party/spirv-tools/source/opt/optimizer.cpp b/third_party/spirv-tools/source/opt/optimizer.cpp index be0daebda8..a41885c0e6 100644 --- a/third_party/spirv-tools/source/opt/optimizer.cpp +++ b/third_party/spirv-tools/source/opt/optimizer.cpp @@ -15,8 +15,10 @@ #include "spirv-tools/optimizer.hpp" #include +#include #include #include +#include #include #include #include @@ -32,6 +34,15 @@ namespace spvtools { +std::vector GetVectorOfStrings(const char** strings, + const size_t string_count) { + std::vector result; + for (uint32_t i = 0; i < string_count; i++) { + result.emplace_back(strings[i]); + } + return result; +} + struct Optimizer::PassToken::Impl { Impl(std::unique_ptr p) : pass(std::move(p)) {} @@ -109,7 +120,7 @@ Optimizer& Optimizer::RegisterPass(PassToken&& p) { // The legalization problem is essentially a very general copy propagation // problem. The optimization we use are all used to either do copy propagation // or enable more copy propagation. -Optimizer& Optimizer::RegisterLegalizationPasses() { +Optimizer& Optimizer::RegisterLegalizationPasses(bool preserve_interface) { return // Wrap OpKill instructions so all other code can be inlined. RegisterPass(CreateWrapOpKillPass()) @@ -129,16 +140,16 @@ Optimizer& Optimizer::RegisterLegalizationPasses() { // Propagate the value stored to the loads in very simple cases. .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) // Split up aggregates so they are easier to deal with. .RegisterPass(CreateScalarReplacementPass(0)) // Remove loads and stores so everything is in intermediate values. // Takes care of copy propagation of non-members. .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateLocalMultiStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) // Propagate constants to get as many constant conditions on branches // as possible. .RegisterPass(CreateCCPPass()) @@ -147,7 +158,7 @@ Optimizer& Optimizer::RegisterLegalizationPasses() { // Copy propagate members. Cleans up code sequences generated by // scalar replacement. Also important for removing OpPhi nodes. .RegisterPass(CreateSimplificationPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateCopyPropagateArraysPass()) // May need loop unrolling here see // https://github.com/Microsoft/DirectXShaderCompiler/pull/930 @@ -156,30 +167,37 @@ Optimizer& Optimizer::RegisterLegalizationPasses() { .RegisterPass(CreateVectorDCEPass()) .RegisterPass(CreateDeadInsertElimPass()) .RegisterPass(CreateReduceLoadSizePass()) - .RegisterPass(CreateAggressiveDCEPass()) - .RegisterPass(CreateInterpolateFixupPass()); + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) + .RegisterPass(CreateRemoveUnusedInterfaceVariablesPass()) + .RegisterPass(CreateInterpolateFixupPass()) + .RegisterPass(CreateInvocationInterlockPlacementPass()) + .RegisterPass(CreateOpExtInstWithForwardReferenceFixupPass()); } -Optimizer& Optimizer::RegisterPerformancePasses() { +Optimizer& Optimizer::RegisterLegalizationPasses() { + return RegisterLegalizationPasses(false); +} + +Optimizer& Optimizer::RegisterPerformancePasses(bool preserve_interface) { return RegisterPass(CreateWrapOpKillPass()) .RegisterPass(CreateDeadBranchElimPass()) .RegisterPass(CreateMergeReturnPass()) .RegisterPass(CreateInlineExhaustivePass()) .RegisterPass(CreateEliminateDeadFunctionsPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreatePrivateToLocalPass()) .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateScalarReplacementPass()) .RegisterPass(CreateLocalAccessChainConvertPass()) .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateLocalMultiStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateCCPPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateLoopUnrollPass(true)) .RegisterPass(CreateDeadBranchElimPass()) .RegisterPass(CreateRedundancyEliminationPass()) @@ -189,9 +207,9 @@ Optimizer& Optimizer::RegisterPerformancePasses() { .RegisterPass(CreateLocalAccessChainConvertPass()) .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateSSARewritePass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateVectorDCEPass()) .RegisterPass(CreateDeadInsertElimPass()) .RegisterPass(CreateDeadBranchElimPass()) @@ -199,7 +217,7 @@ Optimizer& Optimizer::RegisterPerformancePasses() { .RegisterPass(CreateIfConversionPass()) .RegisterPass(CreateCopyPropagateArraysPass()) .RegisterPass(CreateReduceLoadSizePass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateBlockMergePass()) .RegisterPass(CreateRedundancyEliminationPass()) .RegisterPass(CreateDeadBranchElimPass()) @@ -207,7 +225,11 @@ Optimizer& Optimizer::RegisterPerformancePasses() { .RegisterPass(CreateSimplificationPass()); } -Optimizer& Optimizer::RegisterSizePasses() { +Optimizer& Optimizer::RegisterPerformancePasses() { + return RegisterPerformancePasses(false); +} + +Optimizer& Optimizer::RegisterSizePasses(bool preserve_interface) { return RegisterPass(CreateWrapOpKillPass()) .RegisterPass(CreateDeadBranchElimPass()) .RegisterPass(CreateMergeReturnPass()) @@ -224,12 +246,12 @@ Optimizer& Optimizer::RegisterSizePasses() { .RegisterPass(CreateLocalSingleStoreElimPass()) .RegisterPass(CreateIfConversionPass()) .RegisterPass(CreateSimplificationPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateDeadBranchElimPass()) .RegisterPass(CreateBlockMergePass()) .RegisterPass(CreateLocalAccessChainConvertPass()) .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateCopyPropagateArraysPass()) .RegisterPass(CreateVectorDCEPass()) .RegisterPass(CreateDeadInsertElimPass()) @@ -239,13 +261,20 @@ Optimizer& Optimizer::RegisterSizePasses() { .RegisterPass(CreateLocalMultiStoreElimPass()) .RegisterPass(CreateRedundancyEliminationPass()) .RegisterPass(CreateSimplificationPass()) - .RegisterPass(CreateAggressiveDCEPass()) + .RegisterPass(CreateAggressiveDCEPass(preserve_interface)) .RegisterPass(CreateCFGCleanupPass()); } +Optimizer& Optimizer::RegisterSizePasses() { return RegisterSizePasses(false); } + bool Optimizer::RegisterPassesFromFlags(const std::vector& flags) { + return RegisterPassesFromFlags(flags, false); +} + +bool Optimizer::RegisterPassesFromFlags(const std::vector& flags, + bool preserve_interface) { for (const auto& flag : flags) { - if (!RegisterPassFromFlag(flag)) { + if (!RegisterPassFromFlag(flag, preserve_interface)) { return false; } } @@ -269,6 +298,11 @@ bool Optimizer::FlagHasValidForm(const std::string& flag) const { } bool Optimizer::RegisterPassFromFlag(const std::string& flag) { + return RegisterPassFromFlag(flag, false); +} + +bool Optimizer::RegisterPassFromFlag(const std::string& flag, + bool preserve_interface) { if (!FlagHasValidForm(flag)) { return false; } @@ -291,6 +325,8 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateStripReflectInfoPass()); } else if (pass_name == "strip-nonsemantic") { RegisterPass(CreateStripNonSemanticInfoPass()); + } else if (pass_name == "fix-opextinst-opcodes") { + RegisterPass(CreateOpExtInstWithForwardReferenceFixupPass()); } else if (pass_name == "set-spec-const-default-value") { if (pass_args.size() > 0) { auto spec_ids_vals = @@ -329,8 +365,12 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateSpreadVolatileSemanticsPass()); } else if (pass_name == "descriptor-scalar-replacement") { RegisterPass(CreateDescriptorScalarReplacementPass()); + } else if (pass_name == "descriptor-composite-scalar-replacement") { + RegisterPass(CreateDescriptorCompositeScalarReplacementPass()); + } else if (pass_name == "descriptor-array-scalar-replacement") { + RegisterPass(CreateDescriptorArrayScalarReplacementPass()); } else if (pass_name == "eliminate-dead-code-aggressive") { - RegisterPass(CreateAggressiveDCEPass()); + RegisterPass(CreateAggressiveDCEPass(preserve_interface)); } else if (pass_name == "eliminate-insert-extract") { RegisterPass(CreateInsertExtractElimPass()); } else if (pass_name == "eliminate-local-single-block") { @@ -419,33 +459,10 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { RegisterPass(CreateWorkaround1209Pass()); } else if (pass_name == "replace-invalid-opcode") { RegisterPass(CreateReplaceInvalidOpcodePass()); - } else if (pass_name == "inst-bindless-check") { - RegisterPass(CreateInstBindlessCheckPass(7, 23, false, false)); - RegisterPass(CreateSimplificationPass()); - RegisterPass(CreateDeadBranchElimPass()); - RegisterPass(CreateBlockMergePass()); - RegisterPass(CreateAggressiveDCEPass(true)); - } else if (pass_name == "inst-desc-idx-check") { - RegisterPass(CreateInstBindlessCheckPass(7, 23, true, true)); - RegisterPass(CreateSimplificationPass()); - RegisterPass(CreateDeadBranchElimPass()); - RegisterPass(CreateBlockMergePass()); - RegisterPass(CreateAggressiveDCEPass(true)); - } else if (pass_name == "inst-buff-oob-check") { - RegisterPass(CreateInstBindlessCheckPass(7, 23, false, false, true, true)); - RegisterPass(CreateSimplificationPass()); - RegisterPass(CreateDeadBranchElimPass()); - RegisterPass(CreateBlockMergePass()); - RegisterPass(CreateAggressiveDCEPass(true)); - } else if (pass_name == "inst-buff-addr-check") { - RegisterPass(CreateInstBuffAddrCheckPass(7, 23)); - RegisterPass(CreateAggressiveDCEPass(true)); } else if (pass_name == "convert-relaxed-to-half") { RegisterPass(CreateConvertRelaxedToHalfPass()); } else if (pass_name == "relax-float-ops") { RegisterPass(CreateRelaxFloatOpsPass()); - } else if (pass_name == "inst-debug-printf") { - RegisterPass(CreateInstDebugPrintfPass(7, 23)); } else if (pass_name == "simplify-instructions") { RegisterPass(CreateSimplificationPass()); } else if (pass_name == "ssa-rewrite") { @@ -507,11 +524,11 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { } else if (pass_name == "fix-storage-class") { RegisterPass(CreateFixStorageClassPass()); } else if (pass_name == "O") { - RegisterPerformancePasses(); + RegisterPerformancePasses(preserve_interface); } else if (pass_name == "Os") { - RegisterSizePasses(); + RegisterSizePasses(preserve_interface); } else if (pass_name == "legalize-hlsl") { - RegisterLegalizationPasses(); + RegisterLegalizationPasses(preserve_interface); } else if (pass_name == "remove-unused-interface-variables") { RegisterPass(CreateRemoveUnusedInterfaceVariablesPass()); } else if (pass_name == "graphics-robust-access") { @@ -548,6 +565,78 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) { pass_args.c_str()); return false; } + } else if (pass_name == "struct-packing") { + if (pass_args.size() == 0) { + Error(consumer(), nullptr, {}, + "--struct-packing requires a name:rule argument."); + return false; + } + + auto separator_pos = pass_args.find(':'); + if (separator_pos == std::string::npos || separator_pos == 0 || + separator_pos + 1 == pass_args.size()) { + Errorf(consumer(), nullptr, {}, + "Invalid argument for --struct-packing: %s", pass_args.c_str()); + return false; + } + + const std::string struct_name = pass_args.substr(0, separator_pos); + const std::string rule_name = pass_args.substr(separator_pos + 1); + + RegisterPass( + CreateStructPackingPass(struct_name.c_str(), rule_name.c_str())); + } else if (pass_name == "switch-descriptorset") { + if (pass_args.size() == 0) { + Error(consumer(), nullptr, {}, + "--switch-descriptorset requires a from:to argument."); + return false; + } + uint32_t from_set = 0, to_set = 0; + const char* start = pass_args.data(); + const char* end = pass_args.data() + pass_args.size(); + + auto result = std::from_chars(start, end, from_set); + if (result.ec != std::errc()) { + Errorf(consumer(), nullptr, {}, + "Invalid argument for --switch-descriptorset: %s", + pass_args.c_str()); + return false; + } + start = result.ptr; + if (start[0] != ':') { + Errorf(consumer(), nullptr, {}, + "Invalid argument for --switch-descriptorset: %s", + pass_args.c_str()); + return false; + } + start++; + result = std::from_chars(start, end, to_set); + if (result.ec != std::errc() || result.ptr != end) { + Errorf(consumer(), nullptr, {}, + "Invalid argument for --switch-descriptorset: %s", + pass_args.c_str()); + return false; + } + RegisterPass(CreateSwitchDescriptorSetPass(from_set, to_set)); + } else if (pass_name == "modify-maximal-reconvergence") { + if (pass_args.size() == 0) { + Error(consumer(), nullptr, {}, + "--modify-maximal-reconvergence requires an argument"); + return false; + } + if (pass_args == "add") { + RegisterPass(CreateModifyMaximalReconvergencePass(true)); + } else if (pass_args == "remove") { + RegisterPass(CreateModifyMaximalReconvergencePass(false)); + } else { + Errorf(consumer(), nullptr, {}, + "Invalid argument for --modify-maximal-reconvergence: %s (must be " + "'add' or 'remove')", + pass_args.c_str()); + return false; + } + } else if (pass_name == "trim-capabilities") { + RegisterPass(CreateTrimCapabilitiesPass()); } else { Errorf(consumer(), nullptr, {}, "Unknown flag '--%s'. Use --help for a list of valid flags", @@ -785,6 +874,16 @@ Optimizer::PassToken CreateLocalMultiStoreElimPass() { MakeUnique()); } +Optimizer::PassToken CreateAggressiveDCEPass() { + return MakeUnique( + MakeUnique(false, false)); +} + +Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface) { + return MakeUnique( + MakeUnique(preserve_interface, false)); +} + Optimizer::PassToken CreateAggressiveDCEPass(bool preserve_interface, bool remove_outputs) { return MakeUnique( @@ -935,28 +1034,6 @@ Optimizer::PassToken CreateUpgradeMemoryModelPass() { MakeUnique()); } -Optimizer::PassToken CreateInstBindlessCheckPass( - uint32_t desc_set, uint32_t shader_id, bool desc_length_enable, - bool desc_init_enable, bool buff_oob_enable, bool texbuff_oob_enable) { - return MakeUnique( - MakeUnique( - desc_set, shader_id, desc_length_enable, desc_init_enable, - buff_oob_enable, texbuff_oob_enable, - desc_length_enable || desc_init_enable || buff_oob_enable)); -} - -Optimizer::PassToken CreateInstDebugPrintfPass(uint32_t desc_set, - uint32_t shader_id) { - return MakeUnique( - MakeUnique(desc_set, shader_id)); -} - -Optimizer::PassToken CreateInstBuffAddrCheckPass(uint32_t desc_set, - uint32_t shader_id) { - return MakeUnique( - MakeUnique(desc_set, shader_id)); -} - Optimizer::PassToken CreateConvertRelaxedToHalfPass() { return MakeUnique( MakeUnique()); @@ -994,7 +1071,20 @@ Optimizer::PassToken CreateSpreadVolatileSemanticsPass() { Optimizer::PassToken CreateDescriptorScalarReplacementPass() { return MakeUnique( - MakeUnique()); + MakeUnique( + /* flatten_composites= */ true, /* flatten_arrays= */ true)); +} + +Optimizer::PassToken CreateDescriptorCompositeScalarReplacementPass() { + return MakeUnique( + MakeUnique( + /* flatten_composites= */ true, /* flatten_arrays= */ false)); +} + +Optimizer::PassToken CreateDescriptorArrayScalarReplacementPass() { + return MakeUnique( + MakeUnique( + /* flatten_composites= */ false, /* flatten_arrays= */ true)); } Optimizer::PassToken CreateWrapOpKillPass() { @@ -1064,4 +1154,136 @@ Optimizer::PassToken CreateFixFuncCallArgumentsPass() { return MakeUnique( MakeUnique()); } + +Optimizer::PassToken CreateTrimCapabilitiesPass() { + return MakeUnique( + MakeUnique()); +} + +Optimizer::PassToken CreateStructPackingPass(const char* structToPack, + const char* packingRule) { + return MakeUnique( + MakeUnique( + structToPack, + opt::StructPackingPass::ParsePackingRuleFromString(packingRule))); +} + +Optimizer::PassToken CreateSwitchDescriptorSetPass(uint32_t from, uint32_t to) { + return MakeUnique( + MakeUnique(from, to)); +} + +Optimizer::PassToken CreateInvocationInterlockPlacementPass() { + return MakeUnique( + MakeUnique()); +} + +Optimizer::PassToken CreateModifyMaximalReconvergencePass(bool add) { + return MakeUnique( + MakeUnique(add)); +} + +Optimizer::PassToken CreateOpExtInstWithForwardReferenceFixupPass() { + return MakeUnique( + MakeUnique()); +} + } // namespace spvtools + +extern "C" { + +SPIRV_TOOLS_EXPORT spv_optimizer_t* spvOptimizerCreate(spv_target_env env) { + return reinterpret_cast(new spvtools::Optimizer(env)); +} + +SPIRV_TOOLS_EXPORT void spvOptimizerDestroy(spv_optimizer_t* optimizer) { + delete reinterpret_cast(optimizer); +} + +SPIRV_TOOLS_EXPORT void spvOptimizerSetMessageConsumer( + spv_optimizer_t* optimizer, spv_message_consumer consumer) { + reinterpret_cast(optimizer)-> + SetMessageConsumer( + [consumer](spv_message_level_t level, const char* source, + const spv_position_t& position, const char* message) { + return consumer(level, source, &position, message); + }); +} + +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterLegalizationPasses( + spv_optimizer_t* optimizer) { + reinterpret_cast(optimizer)-> + RegisterLegalizationPasses(); +} + +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterPerformancePasses( + spv_optimizer_t* optimizer) { + reinterpret_cast(optimizer)-> + RegisterPerformancePasses(); +} + +SPIRV_TOOLS_EXPORT void spvOptimizerRegisterSizePasses( + spv_optimizer_t* optimizer) { + reinterpret_cast(optimizer)->RegisterSizePasses(); +} + +SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassFromFlag( + spv_optimizer_t* optimizer, const char* flag) +{ + return reinterpret_cast(optimizer)-> + RegisterPassFromFlag(flag); +} + +SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassesFromFlags( + spv_optimizer_t* optimizer, const char** flags, const size_t flag_count) { + std::vector opt_flags = + spvtools::GetVectorOfStrings(flags, flag_count); + return reinterpret_cast(optimizer) + ->RegisterPassesFromFlags(opt_flags, false); +} + +SPIRV_TOOLS_EXPORT bool +spvOptimizerRegisterPassesFromFlagsWhilePreservingTheInterface( + spv_optimizer_t* optimizer, const char** flags, const size_t flag_count) { + std::vector opt_flags = + spvtools::GetVectorOfStrings(flags, flag_count); + return reinterpret_cast(optimizer) + ->RegisterPassesFromFlags(opt_flags, true); +} + +SPIRV_TOOLS_EXPORT +spv_result_t spvOptimizerRun(spv_optimizer_t* optimizer, + const uint32_t* binary, + const size_t word_count, + spv_binary* optimized_binary, + const spv_optimizer_options options) { + std::vector optimized; + + if (!reinterpret_cast(optimizer)-> + Run(binary, word_count, &optimized, options)) { + return SPV_ERROR_INTERNAL; + } + + auto result_binary = new spv_binary_t(); + if (!result_binary) { + *optimized_binary = nullptr; + return SPV_ERROR_OUT_OF_MEMORY; + } + + result_binary->code = new uint32_t[optimized.size()]; + if (!result_binary->code) { + delete result_binary; + *optimized_binary = nullptr; + return SPV_ERROR_OUT_OF_MEMORY; + } + result_binary->wordCount = optimized.size(); + + memcpy(result_binary->code, optimized.data(), + optimized.size() * sizeof(uint32_t)); + + *optimized_binary = result_binary; + + return SPV_SUCCESS; +} + +} // extern "C" diff --git a/third_party/spirv-tools/source/opt/pass.cpp b/third_party/spirv-tools/source/opt/pass.cpp index 75c37407fd..0f260e2efe 100644 --- a/third_party/spirv-tools/source/opt/pass.cpp +++ b/third_party/spirv-tools/source/opt/pass.cpp @@ -83,7 +83,6 @@ uint32_t Pass::GetNullId(uint32_t type_id) { uint32_t Pass::GenerateCopy(Instruction* object_to_copy, uint32_t new_type_id, Instruction* insertion_position) { - analysis::TypeManager* type_mgr = context()->get_type_mgr(); analysis::ConstantManager* const_mgr = context()->get_constant_mgr(); uint32_t original_type_id = object_to_copy->type_id(); @@ -95,57 +94,63 @@ uint32_t Pass::GenerateCopy(Instruction* object_to_copy, uint32_t new_type_id, context(), insertion_position, IRContext::kAnalysisInstrToBlockMapping | IRContext::kAnalysisDefUse); - analysis::Type* original_type = type_mgr->GetType(original_type_id); - analysis::Type* new_type = type_mgr->GetType(new_type_id); + Instruction* original_type = get_def_use_mgr()->GetDef(original_type_id); + Instruction* new_type = get_def_use_mgr()->GetDef(new_type_id); - if (const analysis::Array* original_array_type = original_type->AsArray()) { - uint32_t original_element_type_id = - type_mgr->GetId(original_array_type->element_type()); - - analysis::Array* new_array_type = new_type->AsArray(); - assert(new_array_type != nullptr && "Can't copy an array to a non-array."); - uint32_t new_element_type_id = - type_mgr->GetId(new_array_type->element_type()); - - std::vector element_ids; - const analysis::Constant* length_const = - const_mgr->FindDeclaredConstant(original_array_type->LengthId()); - assert(length_const->AsIntConstant()); - uint32_t array_length = length_const->AsIntConstant()->GetU32(); - for (uint32_t i = 0; i < array_length; i++) { - Instruction* extract = ir_builder.AddCompositeExtract( - original_element_type_id, object_to_copy->result_id(), {i}); - element_ids.push_back( - GenerateCopy(extract, new_element_type_id, insertion_position)); - } - - return ir_builder.AddCompositeConstruct(new_type_id, element_ids) - ->result_id(); - } else if (const analysis::Struct* original_struct_type = - original_type->AsStruct()) { - analysis::Struct* new_struct_type = new_type->AsStruct(); - - const std::vector& original_types = - original_struct_type->element_types(); - const std::vector& new_types = - new_struct_type->element_types(); - std::vector element_ids; - for (uint32_t i = 0; i < original_types.size(); i++) { - Instruction* extract = ir_builder.AddCompositeExtract( - type_mgr->GetId(original_types[i]), object_to_copy->result_id(), {i}); - element_ids.push_back(GenerateCopy(extract, type_mgr->GetId(new_types[i]), - insertion_position)); - } - return ir_builder.AddCompositeConstruct(new_type_id, element_ids) - ->result_id(); - } else { - // If we do not have an aggregate type, then we have a problem. Either we - // found multiple instances of the same type, or we are copying to an - // incompatible type. Either way the code is illegal. - assert(false && - "Don't know how to copy this type. Code is likely illegal."); + if (new_type->opcode() != original_type->opcode()) { + return 0; + } + + switch (original_type->opcode()) { + case spv::Op::OpTypeArray: { + uint32_t original_element_type_id = + original_type->GetSingleWordInOperand(0); + uint32_t new_element_type_id = new_type->GetSingleWordInOperand(0); + + std::vector element_ids; + uint32_t length_id = original_type->GetSingleWordInOperand(1); + const analysis::Constant* length_const = + const_mgr->FindDeclaredConstant(length_id); + assert(length_const->AsIntConstant()); + uint32_t array_length = length_const->AsIntConstant()->GetU32(); + for (uint32_t i = 0; i < array_length; i++) { + Instruction* extract = ir_builder.AddCompositeExtract( + original_element_type_id, object_to_copy->result_id(), {i}); + uint32_t new_id = + GenerateCopy(extract, new_element_type_id, insertion_position); + if (new_id == 0) { + return 0; + } + element_ids.push_back(new_id); + } + + return ir_builder.AddCompositeConstruct(new_type_id, element_ids) + ->result_id(); + } + case spv::Op::OpTypeStruct: { + std::vector element_ids; + for (uint32_t i = 0; i < original_type->NumInOperands(); i++) { + uint32_t orig_member_type_id = original_type->GetSingleWordInOperand(i); + uint32_t new_member_type_id = new_type->GetSingleWordInOperand(i); + Instruction* extract = ir_builder.AddCompositeExtract( + orig_member_type_id, object_to_copy->result_id(), {i}); + uint32_t new_id = + GenerateCopy(extract, new_member_type_id, insertion_position); + if (new_id == 0) { + return 0; + } + element_ids.push_back(new_id); + } + return ir_builder.AddCompositeConstruct(new_type_id, element_ids) + ->result_id(); + } + default: + // If we do not have an aggregate type, then we have a problem. Either we + // found multiple instances of the same type, or we are copying to an + // incompatible type. Either way the code is illegal. Leave the code as + // is and let the caller deal with it. + return 0; } - return 0; } } // namespace opt diff --git a/third_party/spirv-tools/source/opt/pass.h b/third_party/spirv-tools/source/opt/pass.h index b2303e2316..3e6c4d0763 100644 --- a/third_party/spirv-tools/source/opt/pass.h +++ b/third_party/spirv-tools/source/opt/pass.h @@ -145,7 +145,8 @@ class Pass { // Returns the id whose value is the same as |object_to_copy| except its type // is |new_type_id|. Any instructions needed to generate this value will be - // inserted before |insertion_position|. + // inserted before |insertion_position|. Returns 0 if a copy could not be + // done. uint32_t GenerateCopy(Instruction* object_to_copy, uint32_t new_type_id, Instruction* insertion_position); diff --git a/third_party/spirv-tools/source/opt/passes.h b/third_party/spirv-tools/source/opt/passes.h index eb3b1e5d31..3311529aaa 100644 --- a/third_party/spirv-tools/source/opt/passes.h +++ b/third_party/spirv-tools/source/opt/passes.h @@ -48,11 +48,9 @@ #include "source/opt/if_conversion.h" #include "source/opt/inline_exhaustive_pass.h" #include "source/opt/inline_opaque_pass.h" -#include "source/opt/inst_bindless_check_pass.h" -#include "source/opt/inst_buff_addr_check_pass.h" -#include "source/opt/inst_debug_printf_pass.h" #include "source/opt/interface_var_sroa.h" #include "source/opt/interp_fixup_pass.h" +#include "source/opt/invocation_interlock_placement_pass.h" #include "source/opt/licm_pass.h" #include "source/opt/local_access_chain_convert_pass.h" #include "source/opt/local_redundancy_elimination.h" @@ -64,7 +62,9 @@ #include "source/opt/loop_unroller.h" #include "source/opt/loop_unswitch_pass.h" #include "source/opt/merge_return_pass.h" +#include "source/opt/modify_maximal_reconvergence.h" #include "source/opt/null_pass.h" +#include "source/opt/opextinst_forward_ref_fixup_pass.h" #include "source/opt/private_to_local_pass.h" #include "source/opt/reduce_load_size.h" #include "source/opt/redundancy_elimination.h" @@ -82,6 +82,9 @@ #include "source/opt/strength_reduction_pass.h" #include "source/opt/strip_debug_info_pass.h" #include "source/opt/strip_nonsemantic_info_pass.h" +#include "source/opt/struct_packing_pass.h" +#include "source/opt/switch_descriptorset_pass.h" +#include "source/opt/trim_capabilities_pass.h" #include "source/opt/unify_const_pass.h" #include "source/opt/upgrade_memory_model.h" #include "source/opt/vector_dce.h" diff --git a/third_party/spirv-tools/source/opt/reflect.h b/third_party/spirv-tools/source/opt/reflect.h index 45bb5c57c0..ec7c2dd075 100644 --- a/third_party/spirv-tools/source/opt/reflect.h +++ b/third_party/spirv-tools/source/opt/reflect.h @@ -16,6 +16,7 @@ #define SOURCE_OPT_REFLECT_H_ #include "source/latest_version_spirv_header.h" +#include "source/opcode.h" namespace spvtools { namespace opt { @@ -46,27 +47,14 @@ inline bool IsAnnotationInst(spv::Op opcode) { opcode == spv::Op::OpMemberDecorateStringGOOGLE; } inline bool IsTypeInst(spv::Op opcode) { - return (opcode >= spv::Op::OpTypeVoid && - opcode <= spv::Op::OpTypeForwardPointer) || - opcode == spv::Op::OpTypePipeStorage || - opcode == spv::Op::OpTypeNamedBarrier || - opcode == spv::Op::OpTypeAccelerationStructureNV || - opcode == spv::Op::OpTypeAccelerationStructureKHR || - opcode == spv::Op::OpTypeRayQueryKHR || - opcode == spv::Op::OpTypeCooperativeMatrixNV || - opcode == spv::Op::OpTypeHitObjectNV; + return spvOpcodeGeneratesType(opcode) || + opcode == spv::Op::OpTypeForwardPointer; } inline bool IsConstantInst(spv::Op opcode) { - return (opcode >= spv::Op::OpConstantTrue && - opcode <= spv::Op::OpSpecConstantOp) || - opcode == spv::Op::OpConstantFunctionPointerINTEL; -} -inline bool IsCompileTimeConstantInst(spv::Op opcode) { - return opcode >= spv::Op::OpConstantTrue && opcode <= spv::Op::OpConstantNull; + return spvOpcodeIsConstant(opcode); } inline bool IsSpecConstantInst(spv::Op opcode) { - return opcode >= spv::Op::OpSpecConstantTrue && - opcode <= spv::Op::OpSpecConstantOp; + return spvOpcodeIsSpecConstant(opcode); } } // namespace opt diff --git a/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp b/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp index 90c3acff2c..0df559b345 100644 --- a/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp +++ b/third_party/spirv-tools/source/opt/remove_duplicates_pass.cpp @@ -15,8 +15,6 @@ #include "source/opt/remove_duplicates_pass.h" #include -#include -#include #include #include #include @@ -25,7 +23,6 @@ #include "source/opcode.h" #include "source/opt/decoration_manager.h" #include "source/opt/ir_context.h" -#include "source/opt/reflect.h" namespace spvtools { namespace opt { diff --git a/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.cpp b/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.cpp index d4df1b2efd..c3a4b775a1 100644 --- a/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.cpp +++ b/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.cpp @@ -21,6 +21,8 @@ class RemoveUnusedInterfaceVariablesContext { RemoveUnusedInterfaceVariablesPass& parent_; Instruction& entry_; std::unordered_set used_variables_; + std::vector operands_to_add_; + IRContext::ProcessFunction pfn_ = std::bind(&RemoveUnusedInterfaceVariablesContext::processFunction, this, std::placeholders::_1); @@ -38,8 +40,10 @@ class RemoveUnusedInterfaceVariablesContext { (parent_.get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4) || storage_class == spv::StorageClass::Input || - storage_class == spv::StorageClass::Output)) + storage_class == spv::StorageClass::Output)) { used_variables_.insert(*id); + operands_to_add_.push_back(*id); + } }); return false; } @@ -71,7 +75,7 @@ class RemoveUnusedInterfaceVariablesContext { void Modify() { for (int i = entry_.NumInOperands() - 1; i >= 3; --i) entry_.RemoveInOperand(i); - for (auto id : used_variables_) { + for (auto id : operands_to_add_) { entry_.AddOperand(Operand(SPV_OPERAND_TYPE_ID, {id})); } } diff --git a/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.h b/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.h index 7f11187cac..a4cb1085ab 100644 --- a/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.h +++ b/third_party/spirv-tools/source/opt/remove_unused_interface_variables_pass.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef SOURCE_OPT_REMOVE_UNUSED_INTERFACE_VARIABLES_PASS_H_ +#define SOURCE_OPT_REMOVE_UNUSED_INTERFACE_VARIABLES_PASS_H_ + #include "source/opt/pass.h" namespace spvtools { namespace opt { @@ -23,4 +26,6 @@ class RemoveUnusedInterfaceVariablesPass : public Pass { Status Process() override; }; } // namespace opt -} // namespace spvtools \ No newline at end of file +} // namespace spvtools + +#endif // SOURCE_OPT_REMOVE_UNUSED_INTERFACE_VARIABLES_PASS_H_ \ No newline at end of file diff --git a/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp b/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp index 214097398d..1b97c0e84f 100644 --- a/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp +++ b/third_party/spirv-tools/source/opt/replace_invalid_opc.cpp @@ -86,7 +86,8 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function, } if (model != spv::ExecutionModel::TessellationControl && - model != spv::ExecutionModel::GLCompute) { + model != spv::ExecutionModel::GLCompute && + !context()->IsTargetEnvAtLeast(SPV_ENV_UNIVERSAL_1_3)) { if (inst->opcode() == spv::Op::OpControlBarrier) { assert(model != spv::ExecutionModel::Kernel && "Expecting to be working on a shader module."); diff --git a/third_party/spirv-tools/source/opt/scalar_analysis.cpp b/third_party/spirv-tools/source/opt/scalar_analysis.cpp index 0c8babe8ae..26cc8b303a 100644 --- a/third_party/spirv-tools/source/opt/scalar_analysis.cpp +++ b/third_party/spirv-tools/source/opt/scalar_analysis.cpp @@ -14,7 +14,6 @@ #include "source/opt/scalar_analysis.h" -#include #include #include #include diff --git a/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp b/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp index 3c1ecc082a..3c0947cdae 100644 --- a/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp +++ b/third_party/spirv-tools/source/opt/scalar_analysis_simplification.cpp @@ -12,16 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/opt/scalar_analysis.h" - #include #include #include #include -#include #include #include +#include "source/opt/scalar_analysis.h" + // Simplifies scalar analysis DAGs. // // 1. Given a node passed to SimplifyExpression we first simplify the graph by diff --git a/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp b/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp index bfebb01c87..ff81fae3ff 100644 --- a/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp +++ b/third_party/spirv-tools/source/opt/scalar_replacement_pass.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2017 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,12 +21,10 @@ #include #include -#include "source/enum_string_mapping.h" #include "source/extensions.h" #include "source/opt/reflect.h" #include "source/opt/types.h" #include "source/util/make_unique.h" -#include "types.h" namespace spvtools { namespace opt { @@ -468,9 +468,9 @@ void ScalarReplacementPass::TransferAnnotations( } void ScalarReplacementPass::CreateVariable( - uint32_t typeId, Instruction* varInst, uint32_t index, + uint32_t type_id, Instruction* var_inst, uint32_t index, std::vector* replacements) { - uint32_t ptrId = GetOrCreatePointerType(typeId); + uint32_t ptr_id = GetOrCreatePointerType(type_id); uint32_t id = TakeNextId(); if (id == 0) { @@ -478,51 +478,22 @@ void ScalarReplacementPass::CreateVariable( } std::unique_ptr variable( - new Instruction(context(), spv::Op::OpVariable, ptrId, id, + new Instruction(context(), spv::Op::OpVariable, ptr_id, id, std::initializer_list{ {SPV_OPERAND_TYPE_STORAGE_CLASS, {uint32_t(spv::StorageClass::Function)}}})); - BasicBlock* block = context()->get_instr_block(varInst); + BasicBlock* block = context()->get_instr_block(var_inst); block->begin().InsertBefore(std::move(variable)); Instruction* inst = &*block->begin(); // If varInst was initialized, make sure to initialize its replacement. - GetOrCreateInitialValue(varInst, index, inst); + GetOrCreateInitialValue(var_inst, index, inst); get_def_use_mgr()->AnalyzeInstDefUse(inst); context()->set_instr_block(inst, block); - // Copy decorations from the member to the new variable. - Instruction* typeInst = GetStorageType(varInst); - for (auto dec_inst : - get_decoration_mgr()->GetDecorationsFor(typeInst->result_id(), false)) { - uint32_t decoration; - if (dec_inst->opcode() != spv::Op::OpMemberDecorate) { - continue; - } - - if (dec_inst->GetSingleWordInOperand(1) != index) { - continue; - } - - decoration = dec_inst->GetSingleWordInOperand(2u); - switch (spv::Decoration(decoration)) { - case spv::Decoration::RelaxedPrecision: { - std::unique_ptr new_dec_inst( - new Instruction(context(), spv::Op::OpDecorate, 0, 0, {})); - new_dec_inst->AddOperand(Operand(SPV_OPERAND_TYPE_ID, {id})); - for (uint32_t i = 2; i < dec_inst->NumInOperandWords(); ++i) { - new_dec_inst->AddOperand(Operand(dec_inst->GetInOperand(i))); - } - context()->AddAnnotationInst(std::move(new_dec_inst)); - } break; - default: - break; - } - } - - // Update the DebugInfo debug information. - inst->UpdateDebugInfoFrom(varInst); + CopyDecorationsToVariable(var_inst, inst, index); + inst->UpdateDebugInfoFrom(var_inst); replacements->push_back(inst); } @@ -531,52 +502,11 @@ uint32_t ScalarReplacementPass::GetOrCreatePointerType(uint32_t id) { auto iter = pointee_to_pointer_.find(id); if (iter != pointee_to_pointer_.end()) return iter->second; - analysis::Type* pointeeTy; - std::unique_ptr pointerTy; - std::tie(pointeeTy, pointerTy) = - context()->get_type_mgr()->GetTypeAndPointerType( - id, spv::StorageClass::Function); - uint32_t ptrId = 0; - if (pointeeTy->IsUniqueType()) { - // Non-ambiguous type, just ask the type manager for an id. - ptrId = context()->get_type_mgr()->GetTypeInstruction(pointerTy.get()); - pointee_to_pointer_[id] = ptrId; - return ptrId; - } - - // Ambiguous type. We must perform a linear search to try and find the right - // type. - for (auto global : context()->types_values()) { - if (global.opcode() == spv::Op::OpTypePointer && - spv::StorageClass(global.GetSingleWordInOperand(0u)) == - spv::StorageClass::Function && - global.GetSingleWordInOperand(1u) == id) { - if (get_decoration_mgr()->GetDecorationsFor(id, false).empty()) { - // Only reuse a decoration-less pointer of the correct type. - ptrId = global.result_id(); - break; - } - } - } - - if (ptrId != 0) { - pointee_to_pointer_[id] = ptrId; - return ptrId; - } - - ptrId = TakeNextId(); - context()->AddType(MakeUnique( - context(), spv::Op::OpTypePointer, 0, ptrId, - std::initializer_list{{SPV_OPERAND_TYPE_STORAGE_CLASS, - {uint32_t(spv::StorageClass::Function)}}, - {SPV_OPERAND_TYPE_ID, {id}}})); - Instruction* ptr = &*--context()->types_values_end(); - get_def_use_mgr()->AnalyzeInstDefUse(ptr); - pointee_to_pointer_[id] = ptrId; - // Register with the type manager if necessary. - context()->get_type_mgr()->RegisterType(ptrId, *pointerTy); - - return ptrId; + analysis::TypeManager* type_mgr = context()->get_type_mgr(); + uint32_t ptr_type_id = + type_mgr->FindPointerToType(id, spv::StorageClass::Function); + pointee_to_pointer_[id] = ptr_type_id; + return ptr_type_id; } void ScalarReplacementPass::GetOrCreateInitialValue(Instruction* source, @@ -743,7 +673,8 @@ bool ScalarReplacementPass::CheckTypeAnnotations( for (auto inst : get_decoration_mgr()->GetDecorationsFor(typeInst->result_id(), false)) { uint32_t decoration; - if (inst->opcode() == spv::Op::OpDecorate) { + if (inst->opcode() == spv::Op::OpDecorate || + inst->opcode() == spv::Op::OpDecorateId) { decoration = inst->GetSingleWordInOperand(1u); } else { assert(inst->opcode() == spv::Op::OpMemberDecorate); @@ -763,6 +694,8 @@ bool ScalarReplacementPass::CheckTypeAnnotations( case spv::Decoration::AlignmentId: case spv::Decoration::MaxByteOffset: case spv::Decoration::RelaxedPrecision: + case spv::Decoration::AliasedPointer: + case spv::Decoration::RestrictPointer: break; default: return false; @@ -783,6 +716,8 @@ bool ScalarReplacementPass::CheckAnnotations(const Instruction* varInst) const { case spv::Decoration::Alignment: case spv::Decoration::AlignmentId: case spv::Decoration::MaxByteOffset: + case spv::Decoration::AliasedPointer: + case spv::Decoration::RestrictPointer: break; default: return false; @@ -1013,5 +948,69 @@ uint64_t ScalarReplacementPass::GetMaxLegalIndex( return 0; } +void ScalarReplacementPass::CopyDecorationsToVariable(Instruction* from, + Instruction* to, + uint32_t member_index) { + CopyPointerDecorationsToVariable(from, to); + CopyNecessaryMemberDecorationsToVariable(from, to, member_index); +} + +void ScalarReplacementPass::CopyPointerDecorationsToVariable(Instruction* from, + Instruction* to) { + // The RestrictPointer and AliasedPointer decorations are copied to all + // members even if the new variable does not contain a pointer. It does + // not hurt to do so. + for (auto dec_inst : + get_decoration_mgr()->GetDecorationsFor(from->result_id(), false)) { + uint32_t decoration; + decoration = dec_inst->GetSingleWordInOperand(1u); + switch (spv::Decoration(decoration)) { + case spv::Decoration::AliasedPointer: + case spv::Decoration::RestrictPointer: { + std::unique_ptr new_dec_inst(dec_inst->Clone(context())); + new_dec_inst->SetInOperand(0, {to->result_id()}); + context()->AddAnnotationInst(std::move(new_dec_inst)); + } break; + default: + break; + } + } +} + +void ScalarReplacementPass::CopyNecessaryMemberDecorationsToVariable( + Instruction* from, Instruction* to, uint32_t member_index) { + Instruction* type_inst = GetStorageType(from); + for (auto dec_inst : + get_decoration_mgr()->GetDecorationsFor(type_inst->result_id(), false)) { + uint32_t decoration; + if (dec_inst->opcode() == spv::Op::OpMemberDecorate) { + if (dec_inst->GetSingleWordInOperand(1) != member_index) { + continue; + } + + decoration = dec_inst->GetSingleWordInOperand(2u); + switch (spv::Decoration(decoration)) { + case spv::Decoration::ArrayStride: + case spv::Decoration::Alignment: + case spv::Decoration::AlignmentId: + case spv::Decoration::MaxByteOffset: + case spv::Decoration::MaxByteOffsetId: + case spv::Decoration::RelaxedPrecision: { + std::unique_ptr new_dec_inst( + new Instruction(context(), spv::Op::OpDecorate, 0, 0, {})); + new_dec_inst->AddOperand( + Operand(SPV_OPERAND_TYPE_ID, {to->result_id()})); + for (uint32_t i = 2; i < dec_inst->NumInOperandWords(); ++i) { + new_dec_inst->AddOperand(Operand(dec_inst->GetInOperand(i))); + } + context()->AddAnnotationInst(std::move(new_dec_inst)); + } break; + default: + break; + } + } + } +} + } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/scalar_replacement_pass.h b/third_party/spirv-tools/source/opt/scalar_replacement_pass.h index 0bcd2a4e40..c73ecfd98b 100644 --- a/third_party/spirv-tools/source/opt/scalar_replacement_pass.h +++ b/third_party/spirv-tools/source/opt/scalar_replacement_pass.h @@ -262,9 +262,26 @@ class ScalarReplacementPass : public MemPass { // that we will be willing to split. bool IsLargerThanSizeLimit(uint64_t length) const; + // Copies all relevant decorations from `from` to `to`. This includes + // decorations applied to the variable, and to the members of the type. + // It is assumed that `to` is a variable that is intended to replace the + // `member_index`th member of `from`. + void CopyDecorationsToVariable(Instruction* from, Instruction* to, + uint32_t member_index); + + // Copies pointer related decoration from `from` to `to` if they exist. + void CopyPointerDecorationsToVariable(Instruction* from, Instruction* to); + + // Copies decorations that are needed from the `member_index` of `from` to + // `to, if there was one. + void CopyNecessaryMemberDecorationsToVariable(Instruction* from, + Instruction* to, + uint32_t member_index); + // Limit on the number of members in an object that will be replaced. // 0 means there is no limit. uint32_t max_num_elements_; + // This has to be big enough to fit "scalar-replacement=" followed by a // uint32_t number written in decimal (so 10 digits), and then a // terminating nul. diff --git a/third_party/spirv-tools/source/opt/set_spec_constant_default_value_pass.cpp b/third_party/spirv-tools/source/opt/set_spec_constant_default_value_pass.cpp index 5125bd153b..d2aa9b1da2 100644 --- a/third_party/spirv-tools/source/opt/set_spec_constant_default_value_pass.cpp +++ b/third_party/spirv-tools/source/opt/set_spec_constant_default_value_pass.cpp @@ -21,8 +21,6 @@ #include #include "source/opt/def_use_manager.h" -#include "source/opt/ir_context.h" -#include "source/opt/type_manager.h" #include "source/opt/types.h" #include "source/util/make_unique.h" #include "source/util/parse_number.h" diff --git a/third_party/spirv-tools/source/opt/simplification_pass.cpp b/third_party/spirv-tools/source/opt/simplification_pass.cpp index dbda397285..f8ffc03c20 100644 --- a/third_party/spirv-tools/source/opt/simplification_pass.cpp +++ b/third_party/spirv-tools/source/opt/simplification_pass.cpp @@ -14,7 +14,6 @@ #include "source/opt/simplification_pass.h" -#include #include #include diff --git a/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp b/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp index 3037274d38..e552ba5e76 100644 --- a/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp +++ b/third_party/spirv-tools/source/opt/spread_volatile_semantics.cpp @@ -15,7 +15,6 @@ #include "source/opt/spread_volatile_semantics.h" #include "source/opt/decoration_manager.h" -#include "source/opt/ir_builder.h" #include "source/spirv_constant.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/opt/ssa_rewrite_pass.cpp b/third_party/spirv-tools/source/opt/ssa_rewrite_pass.cpp index b8e22908df..3eb4ec3f8e 100644 --- a/third_party/spirv-tools/source/opt/ssa_rewrite_pass.cpp +++ b/third_party/spirv-tools/source/opt/ssa_rewrite_pass.cpp @@ -48,7 +48,6 @@ #include "source/opt/cfg.h" #include "source/opt/mem_pass.h" #include "source/opt/types.h" -#include "source/util/make_unique.h" // Debug logging (0: Off, 1-N: Verbosity level). Replace this with the // implementation done for diff --git a/third_party/spirv-tools/source/opt/strength_reduction_pass.cpp b/third_party/spirv-tools/source/opt/strength_reduction_pass.cpp index f2e849871d..16a7869ec5 100644 --- a/third_party/spirv-tools/source/opt/strength_reduction_pass.cpp +++ b/third_party/spirv-tools/source/opt/strength_reduction_pass.cpp @@ -14,12 +14,8 @@ #include "source/opt/strength_reduction_pass.h" -#include -#include #include #include -#include -#include #include #include diff --git a/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp b/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp index f81bced52c..118d84656b 100644 --- a/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp +++ b/third_party/spirv-tools/source/opt/strip_debug_info_pass.cpp @@ -43,7 +43,7 @@ Pass::Status StripDebugInfoPass::Process() { // see if this string is used anywhere by a non-semantic instruction bool no_nonsemantic_use = def_use->WhileEachUser(&inst, [def_use](Instruction* use) { - if (use->opcode() == spv::Op::OpExtInst) { + if (spvIsExtendedInstruction(use->opcode())) { auto ext_inst_set = def_use->GetDef(use->GetSingleWordInOperand(0u)); const std::string extension_name = diff --git a/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp index 889969007a..659849efd2 100644 --- a/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp +++ b/third_party/spirv-tools/source/opt/strip_nonsemantic_info_pass.cpp @@ -14,7 +14,6 @@ #include "source/opt/strip_nonsemantic_info_pass.h" -#include #include #include "source/opt/instruction.h" @@ -97,7 +96,7 @@ Pass::Status StripNonSemanticInfoPass::Process() { if (!non_semantic_sets.empty()) { context()->module()->ForEachInst( [&non_semantic_sets, &to_remove](Instruction* inst) { - if (inst->opcode() == spv::Op::OpExtInst) { + if (spvIsExtendedInstruction(inst->opcode())) { if (non_semantic_sets.find(inst->GetSingleWordInOperand(0)) != non_semantic_sets.end()) { to_remove.push_back(inst); diff --git a/third_party/spirv-tools/source/opt/struct_packing_pass.cpp b/third_party/spirv-tools/source/opt/struct_packing_pass.cpp new file mode 100644 index 0000000000..3bf2b2ab41 --- /dev/null +++ b/third_party/spirv-tools/source/opt/struct_packing_pass.cpp @@ -0,0 +1,482 @@ +// Copyright (c) 2024 Epic Games, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "struct_packing_pass.h" + +#include + +#include "source/opt/instruction.h" +#include "source/opt/ir_context.h" + +namespace spvtools { +namespace opt { + +/* +Std140 packing rules from the original GLSL 140 specification (see +https://registry.khronos.org/OpenGL/extensions/ARB/ARB_uniform_buffer_object.txt) + +When using the "std140" storage layout, structures will be laid out in +buffer storage with its members stored in monotonically increasing order +based on their location in the declaration. A structure and each +structure member have a base offset and a base alignment, from which an +aligned offset is computed by rounding the base offset up to a multiple of +the base alignment. The base offset of the first member of a structure is +taken from the aligned offset of the structure itself. The base offset of +all other structure members is derived by taking the offset of the last +basic machine unit consumed by the previous member and adding one. Each +structure member is stored in memory at its aligned offset. The members +of a top-level uniform block are laid out in buffer storage by treating +the uniform block as a structure with a base offset of zero. + +(1) If the member is a scalar consuming basic machine units, the + base alignment is . + +(2) If the member is a two- or four-component vector with components + consuming basic machine units, the base alignment is 2 or + 4, respectively. + +(3) If the member is a three-component vector with components consuming + basic machine units, the base alignment is 4. + +(4) If the member is an array of scalars or vectors, the base alignment + and array stride are set to match the base alignment of a single + array element, according to rules (1), (2), and (3), and rounded up + to the base alignment of a vec4. The array may have padding at the + end; the base offset of the member following the array is rounded up + to the next multiple of the base alignment. + +(5) If the member is a column-major matrix with columns and + rows, the matrix is stored identically to an array of column + vectors with components each, according to rule (4). + +(6) If the member is an array of column-major matrices with + columns and rows, the matrix is stored identically to a row of + * column vectors with components each, according to rule + (4). + +(7) If the member is a row-major matrix with columns and rows, + the matrix is stored identically to an array of row vectors + with components each, according to rule (4). + +(8) If the member is an array of row-major matrices with columns + and rows, the matrix is stored identically to a row of * + row vectors with components each, according to rule (4). + +(9) If the member is a structure, the base alignment of the structure is + , where is the largest base alignment value of any of its + members, and rounded up to the base alignment of a vec4. The + individual members of this sub-structure are then assigned offsets + by applying this set of rules recursively, where the base offset of + the first member of the sub-structure is equal to the aligned offset + of the structure. The structure may have padding at the end; the + base offset of the member following the sub-structure is rounded up + to the next multiple of the base alignment of the structure. + +(10) If the member is an array of structures, the elements of + the array are laid out in order, according to rule (9). +*/ + +static bool isPackingVec4Padded(StructPackingPass::PackingRules rules) { + switch (rules) { + case StructPackingPass::PackingRules::Std140: + case StructPackingPass::PackingRules::Std140EnhancedLayout: + case StructPackingPass::PackingRules::HlslCbuffer: + case StructPackingPass::PackingRules::HlslCbufferPackOffset: + return true; + default: + return false; + } +} + +static bool isPackingScalar(StructPackingPass::PackingRules rules) { + switch (rules) { + case StructPackingPass::PackingRules::Scalar: + case StructPackingPass::PackingRules::ScalarEnhancedLayout: + return true; + default: + return false; + } +} + +static bool isPackingHlsl(StructPackingPass::PackingRules rules) { + switch (rules) { + case StructPackingPass::PackingRules::HlslCbuffer: + case StructPackingPass::PackingRules::HlslCbufferPackOffset: + return true; + default: + return false; + } +} + +static uint32_t getPackedBaseSize(const analysis::Type& type) { + switch (type.kind()) { + case analysis::Type::kBool: + return 1; + case analysis::Type::kInteger: + return type.AsInteger()->width() / 8; + case analysis::Type::kFloat: + return type.AsFloat()->width() / 8; + case analysis::Type::kVector: + return getPackedBaseSize(*type.AsVector()->element_type()); + case analysis::Type::kMatrix: + return getPackedBaseSize(*type.AsMatrix()->element_type()); + default: + break; // we only expect bool, int, float, vec, and mat here + } + assert(0 && "Unrecognized type to get base size"); + return 0; +} + +static uint32_t getScalarElementCount(const analysis::Type& type) { + switch (type.kind()) { + case analysis::Type::kVector: + return type.AsVector()->element_count(); + case analysis::Type::kMatrix: + return getScalarElementCount(*type.AsMatrix()->element_type()); + case analysis::Type::kStruct: + assert(0 && "getScalarElementCount() does not recognized struct types"); + return 0; + default: + return 1; + } +} + +// Aligns the specified value to a multiple of alignment, whereas the +// alignment must be a power-of-two. +static uint32_t alignPow2(uint32_t value, uint32_t alignment) { + return (value + alignment - 1) & ~(alignment - 1); +} + +void StructPackingPass::buildConstantsMap() { + constantsMap_.clear(); + for (Instruction* instr : context()->module()->GetConstants()) { + constantsMap_[instr->result_id()] = instr; + } +} + +uint32_t StructPackingPass::getPackedAlignment( + const analysis::Type& type) const { + switch (type.kind()) { + case analysis::Type::kArray: { + // Get alignment of base type and round up to minimum alignment + const uint32_t minAlignment = isPackingVec4Padded(packingRules_) ? 16 : 1; + return std::max( + minAlignment, getPackedAlignment(*type.AsArray()->element_type())); + } + case analysis::Type::kStruct: { + // Rule 9. Struct alignment is maximum alignmnet of its members + uint32_t alignment = 1; + + for (const analysis::Type* elementType : + type.AsStruct()->element_types()) { + alignment = + std::max(alignment, getPackedAlignment(*elementType)); + } + + if (isPackingVec4Padded(packingRules_)) + alignment = std::max(alignment, 16u); + + return alignment; + } + default: { + const uint32_t baseAlignment = getPackedBaseSize(type); + + // Scalar block layout always uses alignment for the most basic component + if (isPackingScalar(packingRules_)) return baseAlignment; + + if (const analysis::Matrix* matrixType = type.AsMatrix()) { + // Rule 5/7 + if (isPackingVec4Padded(packingRules_) || + matrixType->element_count() == 3) + return baseAlignment * 4; + else + return baseAlignment * matrixType->element_count(); + } else if (const analysis::Vector* vectorType = type.AsVector()) { + // Rule 1 + if (vectorType->element_count() == 1) return baseAlignment; + + // Rule 2 + if (vectorType->element_count() == 2 || + vectorType->element_count() == 4) + return baseAlignment * vectorType->element_count(); + + // Rule 3 + if (vectorType->element_count() == 3) return baseAlignment * 4; + } else { + // Rule 1 + return baseAlignment; + } + } + } + assert(0 && "Unrecognized type to get packed alignment"); + return 0; +} + +static uint32_t getPadAlignment(const analysis::Type& type, + uint32_t packedAlignment) { + // The next member following a struct member is aligned to the base alignment + // of a previous struct member. + return type.kind() == analysis::Type::kStruct ? packedAlignment : 1; +} + +uint32_t StructPackingPass::getPackedSize(const analysis::Type& type) const { + switch (type.kind()) { + case analysis::Type::kArray: { + if (const analysis::Array* arrayType = type.AsArray()) { + uint32_t size = + getPackedArrayStride(*arrayType) * getArrayLength(*arrayType); + + // For arrays of vector and matrices in HLSL, the last element has a + // size depending on its vector/matrix size to allow packing other + // vectors in the last element. + const analysis::Type* arraySubType = arrayType->element_type(); + if (isPackingHlsl(packingRules_) && + arraySubType->kind() != analysis::Type::kStruct) { + size -= (4 - getScalarElementCount(*arraySubType)) * + getPackedBaseSize(*arraySubType); + } + return size; + } + break; + } + case analysis::Type::kStruct: { + uint32_t size = 0; + uint32_t padAlignment = 1; + for (const analysis::Type* memberType : + type.AsStruct()->element_types()) { + const uint32_t packedAlignment = getPackedAlignment(*memberType); + const uint32_t alignment = + std::max(packedAlignment, padAlignment); + padAlignment = getPadAlignment(*memberType, packedAlignment); + size = alignPow2(size, alignment); + size += getPackedSize(*memberType); + } + return size; + } + default: { + const uint32_t baseAlignment = getPackedBaseSize(type); + if (isPackingScalar(packingRules_)) { + return getScalarElementCount(type) * baseAlignment; + } else { + uint32_t size = 0; + if (const analysis::Matrix* matrixType = type.AsMatrix()) { + const analysis::Vector* matrixSubType = + matrixType->element_type()->AsVector(); + assert(matrixSubType != nullptr && + "Matrix sub-type is expected to be a vector type"); + if (isPackingVec4Padded(packingRules_) || + matrixType->element_count() == 3) + size = matrixSubType->element_count() * baseAlignment * 4; + else + size = matrixSubType->element_count() * baseAlignment * + matrixType->element_count(); + + // For matrices in HLSL, the last element has a size depending on its + // vector size to allow packing other vectors in the last element. + if (isPackingHlsl(packingRules_)) { + size -= (4 - matrixSubType->element_count()) * + getPackedBaseSize(*matrixSubType); + } + } else if (const analysis::Vector* vectorType = type.AsVector()) { + size = vectorType->element_count() * baseAlignment; + } else { + size = baseAlignment; + } + return size; + } + } + } + assert(0 && "Unrecognized type to get packed size"); + return 0; +} + +uint32_t StructPackingPass::getPackedArrayStride( + const analysis::Array& arrayType) const { + // Array stride is equal to aligned size of element type + const uint32_t elementSize = getPackedSize(*arrayType.element_type()); + const uint32_t alignment = getPackedAlignment(arrayType); + return alignPow2(elementSize, alignment); +} + +uint32_t StructPackingPass::getArrayLength( + const analysis::Array& arrayType) const { + return getConstantInt(arrayType.LengthId()); +} + +uint32_t StructPackingPass::getConstantInt(spv::Id id) const { + auto it = constantsMap_.find(id); + assert(it != constantsMap_.end() && + "Failed to map SPIR-V instruction ID to constant value"); + [[maybe_unused]] const analysis::Type* constType = + context()->get_type_mgr()->GetType(it->second->type_id()); + assert(constType != nullptr && + "Failed to map SPIR-V instruction result type to definition"); + assert(constType->kind() == analysis::Type::kInteger && + "Failed to map SPIR-V instruction result type to integer type"); + return it->second->GetOperand(2).words[0]; +} + +StructPackingPass::PackingRules StructPackingPass::ParsePackingRuleFromString( + const std::string& s) { + if (s == "std140") return PackingRules::Std140; + if (s == "std140EnhancedLayout") return PackingRules::Std140EnhancedLayout; + if (s == "std430") return PackingRules::Std430; + if (s == "std430EnhancedLayout") return PackingRules::Std430EnhancedLayout; + if (s == "hlslCbuffer") return PackingRules::HlslCbuffer; + if (s == "hlslCbufferPackOffset") return PackingRules::HlslCbufferPackOffset; + if (s == "scalar") return PackingRules::Scalar; + if (s == "scalarEnhancedLayout") return PackingRules::ScalarEnhancedLayout; + return PackingRules::Undefined; +} + +StructPackingPass::StructPackingPass(const char* structToPack, + PackingRules rules) + : structToPack_{structToPack != nullptr ? structToPack : ""}, + packingRules_{rules} {} + +Pass::Status StructPackingPass::Process() { + if (packingRules_ == PackingRules::Undefined) { + if (consumer()) { + consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, + "Cannot pack struct with undefined rule"); + } + return Status::Failure; + } + + // Build Id-to-instruction map for easier access + buildConstantsMap(); + + // Find structure of interest + const uint32_t structIdToPack = findStructIdByName(structToPack_.c_str()); + + const Instruction* structDef = + context()->get_def_use_mgr()->GetDef(structIdToPack); + if (structDef == nullptr || structDef->opcode() != spv::Op::OpTypeStruct) { + if (consumer()) { + const std::string message = + "Failed to find struct with name " + structToPack_; + consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); + } + return Status::Failure; + } + + // Find all struct member types + std::vector structMemberTypes = + findStructMemberTypes(*structDef); + + return assignStructMemberOffsets(structIdToPack, structMemberTypes); +} + +uint32_t StructPackingPass::findStructIdByName(const char* structName) const { + for (Instruction& instr : context()->module()->debugs2()) { + if (instr.opcode() == spv::Op::OpName && + instr.GetOperand(1).AsString() == structName) { + return instr.GetOperand(0).AsId(); + } + } + return 0; +} + +std::vector StructPackingPass::findStructMemberTypes( + const Instruction& structDef) const { + // Found struct type to pack, now collect all types of its members + assert(structDef.NumOperands() > 0 && + "Number of operands in OpTypeStruct instruction must not be zero"); + const uint32_t numMembers = structDef.NumOperands() - 1; + std::vector structMemberTypes; + structMemberTypes.resize(numMembers); + for (uint32_t i = 0; i < numMembers; ++i) { + const spv::Id memberTypeId = structDef.GetOperand(1 + i).AsId(); + if (const analysis::Type* memberType = + context()->get_type_mgr()->GetType(memberTypeId)) { + structMemberTypes[i] = memberType; + } + } + return structMemberTypes; +} + +Pass::Status StructPackingPass::assignStructMemberOffsets( + uint32_t structIdToPack, + const std::vector& structMemberTypes) { + // Returns true if the specified instruction is a OpMemberDecorate for the + // struct we're looking for with an offset decoration + auto isMemberOffsetDecoration = + [structIdToPack](const Instruction& instr) -> bool { + return instr.opcode() == spv::Op::OpMemberDecorate && + instr.GetOperand(0).AsId() == structIdToPack && + static_cast(instr.GetOperand(2).words[0]) == + spv::Decoration::Offset; + }; + + bool modified = false; + + // Find and re-assign all member offset decorations + for (auto it = context()->module()->annotation_begin(), + itEnd = context()->module()->annotation_end(); + it != itEnd; ++it) { + if (isMemberOffsetDecoration(*it)) { + // Found first member decoration with offset, we expect all other + // offsets right after the first one + uint32_t prevMemberIndex = 0; + uint32_t currentOffset = 0; + uint32_t padAlignment = 1; + do { + const uint32_t memberIndex = it->GetOperand(1).words[0]; + if (memberIndex < prevMemberIndex) { + // Failure: we expect all members to appear in consecutive order + return Status::Failure; + } + + // Apply alignment rules to current offset + const analysis::Type& memberType = *structMemberTypes[memberIndex]; + uint32_t packedAlignment = getPackedAlignment(memberType); + uint32_t packedSize = getPackedSize(memberType); + + if (isPackingHlsl(packingRules_)) { + // If a member crosses vec4 boundaries, alignment is size of vec4 + if (currentOffset / 16 != (currentOffset + packedSize - 1) / 16) + packedAlignment = std::max(packedAlignment, 16u); + } + + const uint32_t alignment = + std::max(packedAlignment, padAlignment); + currentOffset = alignPow2(currentOffset, alignment); + padAlignment = getPadAlignment(memberType, packedAlignment); + + // Override packed offset in instruction + if (it->GetOperand(3).words[0] < currentOffset) { + // Failure: packing resulted in higher offset for member than + // previously generated + return Status::Failure; + } + + it->GetOperand(3).words[0] = currentOffset; + modified = true; + + // Move to next member + ++it; + prevMemberIndex = memberIndex; + currentOffset += packedSize; + } while (it != itEnd && isMemberOffsetDecoration(*it)); + + // We're done with all decorations for the struct of interest + break; + } + } + + return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/struct_packing_pass.h b/third_party/spirv-tools/source/opt/struct_packing_pass.h new file mode 100644 index 0000000000..3f30f98a5d --- /dev/null +++ b/third_party/spirv-tools/source/opt/struct_packing_pass.h @@ -0,0 +1,81 @@ +// Copyright (c) 2024 Epic Games, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_STRUCT_PACKING_PASS_ +#define SOURCE_OPT_STRUCT_PACKING_PASS_ + +#include + +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// This pass re-assigns all field offsets under the specified packing rules. +class StructPackingPass final : public Pass { + public: + enum class PackingRules { + Undefined, + Std140, + Std140EnhancedLayout, + Std430, + Std430EnhancedLayout, + HlslCbuffer, + HlslCbufferPackOffset, + Scalar, + ScalarEnhancedLayout, + }; + + static PackingRules ParsePackingRuleFromString(const std::string& s); + + StructPackingPass(const char* structToPack, PackingRules rules); + const char* name() const override { return "struct-packing"; } + Status Process() override; + + IRContext::Analysis GetPreservedAnalyses() override { + return IRContext::kAnalysisCombinators | IRContext::kAnalysisCFG | + IRContext::kAnalysisDominatorAnalysis | + IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap | + IRContext::kAnalysisScalarEvolution | + IRContext::kAnalysisStructuredCFG | IRContext::kAnalysisConstants | + IRContext::kAnalysisDebugInfo | IRContext::kAnalysisLiveness; + } + + private: + void buildConstantsMap(); + uint32_t findStructIdByName(const char* structName) const; + std::vector findStructMemberTypes( + const Instruction& structDef) const; + Status assignStructMemberOffsets( + uint32_t structIdToPack, + const std::vector& structMemberTypes); + + uint32_t getPackedAlignment(const analysis::Type& type) const; + uint32_t getPackedSize(const analysis::Type& type) const; + uint32_t getPackedArrayStride(const analysis::Array& arrayType) const; + uint32_t getArrayLength(const analysis::Array& arrayType) const; + uint32_t getConstantInt(spv::Id id) const; + + private: + std::string structToPack_; + PackingRules packingRules_ = PackingRules::Undefined; + std::unordered_map constantsMap_; +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_STRUCT_PACKING_PASS_ diff --git a/third_party/spirv-tools/source/opt/switch_descriptorset_pass.cpp b/third_party/spirv-tools/source/opt/switch_descriptorset_pass.cpp new file mode 100644 index 0000000000..f07c917579 --- /dev/null +++ b/third_party/spirv-tools/source/opt/switch_descriptorset_pass.cpp @@ -0,0 +1,46 @@ +// Copyright (c) 2023 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/switch_descriptorset_pass.h" + +#include "source/opt/ir_builder.h" +#include "source/util/string_utils.h" + +namespace spvtools { +namespace opt { + +Pass::Status SwitchDescriptorSetPass::Process() { + Status status = Status::SuccessWithoutChange; + auto* deco_mgr = context()->get_decoration_mgr(); + + for (Instruction& var : context()->types_values()) { + if (var.opcode() != spv::Op::OpVariable) { + continue; + } + auto decos = deco_mgr->GetDecorationsFor(var.result_id(), false); + for (const auto& deco : decos) { + spv::Decoration d = spv::Decoration(deco->GetSingleWordInOperand(1u)); + if (d == spv::Decoration::DescriptorSet && + deco->GetSingleWordInOperand(2u) == ds_from_) { + deco->SetInOperand(2u, {ds_to_}); + status = Status::SuccessWithChange; + break; + } + } + } + return status; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/switch_descriptorset_pass.h b/third_party/spirv-tools/source/opt/switch_descriptorset_pass.h new file mode 100644 index 0000000000..2084e9cda1 --- /dev/null +++ b/third_party/spirv-tools/source/opt/switch_descriptorset_pass.h @@ -0,0 +1,52 @@ +// Copyright (c) 2023 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// See optimizer.hpp for documentation. +class SwitchDescriptorSetPass : public Pass { + public: + SwitchDescriptorSetPass(uint32_t ds_from, uint32_t ds_to) + : ds_from_(ds_from), ds_to_(ds_to) {} + + const char* name() const override { return "switch-descriptorset"; } + + Status Process() override; + + IRContext::Analysis GetPreservedAnalyses() override { + // this pass preserves everything except decorations + uint32_t mask = ((IRContext::kAnalysisEnd << 1) - 1); + mask &= ~static_cast(IRContext::kAnalysisDecorations); + return static_cast(mask); + } + + private: + uint32_t ds_from_; + uint32_t ds_to_; +}; + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/trim_capabilities_pass.cpp b/third_party/spirv-tools/source/opt/trim_capabilities_pass.cpp new file mode 100644 index 0000000000..34fbc4496b --- /dev/null +++ b/third_party/spirv-tools/source/opt/trim_capabilities_pass.cpp @@ -0,0 +1,734 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "source/opt/trim_capabilities_pass.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "source/enum_set.h" +#include "source/enum_string_mapping.h" +#include "source/ext_inst.h" +#include "source/opt/ir_context.h" +#include "source/opt/reflect.h" +#include "source/spirv_target_env.h" +#include "source/util/string_utils.h" + +namespace spvtools { +namespace opt { + +namespace { +constexpr uint32_t kOpTypeFloatSizeIndex = 0; +constexpr uint32_t kOpTypePointerStorageClassIndex = 0; +constexpr uint32_t kTypeArrayTypeIndex = 0; +constexpr uint32_t kOpTypeScalarBitWidthIndex = 0; +constexpr uint32_t kTypePointerTypeIdInIndex = 1; +constexpr uint32_t kOpTypeIntSizeIndex = 0; +constexpr uint32_t kOpTypeImageDimIndex = 1; +constexpr uint32_t kOpTypeImageArrayedIndex = kOpTypeImageDimIndex + 2; +constexpr uint32_t kOpTypeImageMSIndex = kOpTypeImageArrayedIndex + 1; +constexpr uint32_t kOpTypeImageSampledIndex = kOpTypeImageMSIndex + 1; +constexpr uint32_t kOpTypeImageFormatIndex = kOpTypeImageSampledIndex + 1; +constexpr uint32_t kOpImageReadImageIndex = 0; +constexpr uint32_t kOpImageWriteImageIndex = 0; +constexpr uint32_t kOpImageSparseReadImageIndex = 0; +constexpr uint32_t kOpExtInstSetInIndex = 0; +constexpr uint32_t kOpExtInstInstructionInIndex = 1; +constexpr uint32_t kOpExtInstImportNameInIndex = 0; + +// DFS visit of the type defined by `instruction`. +// If `condition` is true, children of the current node are visited. +// If `condition` is false, the children of the current node are ignored. +template +static void DFSWhile(const Instruction* instruction, UnaryPredicate condition) { + std::stack instructions_to_visit; + instructions_to_visit.push(instruction->result_id()); + const auto* def_use_mgr = instruction->context()->get_def_use_mgr(); + + while (!instructions_to_visit.empty()) { + const Instruction* item = def_use_mgr->GetDef(instructions_to_visit.top()); + instructions_to_visit.pop(); + + if (!condition(item)) { + continue; + } + + if (item->opcode() == spv::Op::OpTypePointer) { + instructions_to_visit.push( + item->GetSingleWordInOperand(kTypePointerTypeIdInIndex)); + continue; + } + + if (item->opcode() == spv::Op::OpTypeMatrix || + item->opcode() == spv::Op::OpTypeVector || + item->opcode() == spv::Op::OpTypeArray || + item->opcode() == spv::Op::OpTypeRuntimeArray) { + instructions_to_visit.push( + item->GetSingleWordInOperand(kTypeArrayTypeIndex)); + continue; + } + + if (item->opcode() == spv::Op::OpTypeStruct) { + item->ForEachInOperand([&instructions_to_visit](const uint32_t* op_id) { + instructions_to_visit.push(*op_id); + }); + continue; + } + } +} + +// Walks the type defined by `instruction` (OpType* only). +// Returns `true` if any call to `predicate` with the type/subtype returns true. +template +static bool AnyTypeOf(const Instruction* instruction, + UnaryPredicate predicate) { + assert(IsTypeInst(instruction->opcode()) && + "AnyTypeOf called with a non-type instruction."); + + bool found_one = false; + DFSWhile(instruction, [&found_one, predicate](const Instruction* node) { + if (found_one || predicate(node)) { + found_one = true; + return false; + } + + return true; + }); + return found_one; +} + +static bool is16bitType(const Instruction* instruction) { + if (instruction->opcode() != spv::Op::OpTypeInt && + instruction->opcode() != spv::Op::OpTypeFloat) { + return false; + } + + return instruction->GetSingleWordInOperand(kOpTypeScalarBitWidthIndex) == 16; +} + +static bool Has16BitCapability(const FeatureManager* feature_manager) { + const CapabilitySet& capabilities = feature_manager->GetCapabilities(); + return capabilities.contains(spv::Capability::Float16) || + capabilities.contains(spv::Capability::Int16); +} + +} // namespace + +// ============== Begin opcode handler implementations. ======================= +// +// Adding support for a new capability should only require adding a new handler, +// and updating the +// kSupportedCapabilities/kUntouchableCapabilities/kFordiddenCapabilities lists. +// +// Handler names follow the following convention: +// Handler__() + +static std::optional Handler_OpTypeFloat_Float16( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypeFloat && + "This handler only support OpTypeFloat opcodes."); + + const uint32_t size = + instruction->GetSingleWordInOperand(kOpTypeFloatSizeIndex); + return size == 16 ? std::optional(spv::Capability::Float16) : std::nullopt; +} + +static std::optional Handler_OpTypeFloat_Float64( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypeFloat && + "This handler only support OpTypeFloat opcodes."); + + const uint32_t size = + instruction->GetSingleWordInOperand(kOpTypeFloatSizeIndex); + return size == 64 ? std::optional(spv::Capability::Float64) : std::nullopt; +} + +static std::optional +Handler_OpTypePointer_StorageInputOutput16(const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypePointer && + "This handler only support OpTypePointer opcodes."); + + // This capability is only required if the variable has an Input/Output + // storage class. + spv::StorageClass storage_class = spv::StorageClass( + instruction->GetSingleWordInOperand(kOpTypePointerStorageClassIndex)); + if (storage_class != spv::StorageClass::Input && + storage_class != spv::StorageClass::Output) { + return std::nullopt; + } + + if (!Has16BitCapability(instruction->context()->get_feature_mgr())) { + return std::nullopt; + } + + return AnyTypeOf(instruction, is16bitType) + ? std::optional(spv::Capability::StorageInputOutput16) + : std::nullopt; +} + +static std::optional +Handler_OpTypePointer_StoragePushConstant16(const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypePointer && + "This handler only support OpTypePointer opcodes."); + + // This capability is only required if the variable has a PushConstant storage + // class. + spv::StorageClass storage_class = spv::StorageClass( + instruction->GetSingleWordInOperand(kOpTypePointerStorageClassIndex)); + if (storage_class != spv::StorageClass::PushConstant) { + return std::nullopt; + } + + if (!Has16BitCapability(instruction->context()->get_feature_mgr())) { + return std::nullopt; + } + + return AnyTypeOf(instruction, is16bitType) + ? std::optional(spv::Capability::StoragePushConstant16) + : std::nullopt; +} + +static std::optional +Handler_OpTypePointer_StorageUniformBufferBlock16( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypePointer && + "This handler only support OpTypePointer opcodes."); + + // This capability is only required if the variable has a Uniform storage + // class. + spv::StorageClass storage_class = spv::StorageClass( + instruction->GetSingleWordInOperand(kOpTypePointerStorageClassIndex)); + if (storage_class != spv::StorageClass::Uniform) { + return std::nullopt; + } + + if (!Has16BitCapability(instruction->context()->get_feature_mgr())) { + return std::nullopt; + } + + const auto* decoration_mgr = instruction->context()->get_decoration_mgr(); + const bool matchesCondition = + AnyTypeOf(instruction, [decoration_mgr](const Instruction* item) { + if (!decoration_mgr->HasDecoration(item->result_id(), + spv::Decoration::BufferBlock)) { + return false; + } + + return AnyTypeOf(item, is16bitType); + }); + + return matchesCondition + ? std::optional(spv::Capability::StorageUniformBufferBlock16) + : std::nullopt; +} + +static std::optional Handler_OpTypePointer_StorageUniform16( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypePointer && + "This handler only support OpTypePointer opcodes."); + + // This capability is only required if the variable has a Uniform storage + // class. + spv::StorageClass storage_class = spv::StorageClass( + instruction->GetSingleWordInOperand(kOpTypePointerStorageClassIndex)); + if (storage_class != spv::StorageClass::Uniform) { + return std::nullopt; + } + + const auto* feature_manager = instruction->context()->get_feature_mgr(); + if (!Has16BitCapability(feature_manager)) { + return std::nullopt; + } + + const bool hasBufferBlockCapability = + feature_manager->GetCapabilities().contains( + spv::Capability::StorageUniformBufferBlock16); + const auto* decoration_mgr = instruction->context()->get_decoration_mgr(); + bool found16bitType = false; + + DFSWhile(instruction, [decoration_mgr, hasBufferBlockCapability, + &found16bitType](const Instruction* item) { + if (found16bitType) { + return false; + } + + if (hasBufferBlockCapability && + decoration_mgr->HasDecoration(item->result_id(), + spv::Decoration::BufferBlock)) { + return false; + } + + if (is16bitType(item)) { + found16bitType = true; + return false; + } + + return true; + }); + + return found16bitType ? std::optional(spv::Capability::StorageUniform16) + : std::nullopt; +} + +static std::optional Handler_OpTypeInt_Int16( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypeInt && + "This handler only support OpTypeInt opcodes."); + + const uint32_t size = + instruction->GetSingleWordInOperand(kOpTypeIntSizeIndex); + return size == 16 ? std::optional(spv::Capability::Int16) : std::nullopt; +} + +static std::optional Handler_OpTypeInt_Int64( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypeInt && + "This handler only support OpTypeInt opcodes."); + + const uint32_t size = + instruction->GetSingleWordInOperand(kOpTypeIntSizeIndex); + return size == 64 ? std::optional(spv::Capability::Int64) : std::nullopt; +} + +static std::optional Handler_OpTypeImage_ImageMSArray( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpTypeImage && + "This handler only support OpTypeImage opcodes."); + + const uint32_t arrayed = + instruction->GetSingleWordInOperand(kOpTypeImageArrayedIndex); + const uint32_t ms = instruction->GetSingleWordInOperand(kOpTypeImageMSIndex); + const uint32_t sampled = + instruction->GetSingleWordInOperand(kOpTypeImageSampledIndex); + + return arrayed == 1 && sampled == 2 && ms == 1 + ? std::optional(spv::Capability::ImageMSArray) + : std::nullopt; +} + +static std::optional +Handler_OpImageRead_StorageImageReadWithoutFormat( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpImageRead && + "This handler only support OpImageRead opcodes."); + const auto* def_use_mgr = instruction->context()->get_def_use_mgr(); + + const uint32_t image_index = + instruction->GetSingleWordInOperand(kOpImageReadImageIndex); + const uint32_t type_index = def_use_mgr->GetDef(image_index)->type_id(); + const Instruction* type = def_use_mgr->GetDef(type_index); + const uint32_t dim = type->GetSingleWordInOperand(kOpTypeImageDimIndex); + const uint32_t format = type->GetSingleWordInOperand(kOpTypeImageFormatIndex); + + // If the Image Format is Unknown and Dim is SubpassData, + // StorageImageReadWithoutFormat is required. + const bool is_unknown = spv::ImageFormat(format) == spv::ImageFormat::Unknown; + const bool requires_capability_for_unknown = + spv::Dim(dim) != spv::Dim::SubpassData; + return is_unknown && requires_capability_for_unknown + ? std::optional(spv::Capability::StorageImageReadWithoutFormat) + : std::nullopt; +} + +static std::optional +Handler_OpImageWrite_StorageImageWriteWithoutFormat( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpImageWrite && + "This handler only support OpImageWrite opcodes."); + const auto* def_use_mgr = instruction->context()->get_def_use_mgr(); + + const uint32_t image_index = + instruction->GetSingleWordInOperand(kOpImageWriteImageIndex); + const uint32_t type_index = def_use_mgr->GetDef(image_index)->type_id(); + + // If the Image Format is Unknown, StorageImageWriteWithoutFormat is required. + const Instruction* type = def_use_mgr->GetDef(type_index); + const uint32_t format = type->GetSingleWordInOperand(kOpTypeImageFormatIndex); + const bool is_unknown = spv::ImageFormat(format) == spv::ImageFormat::Unknown; + return is_unknown + ? std::optional(spv::Capability::StorageImageWriteWithoutFormat) + : std::nullopt; +} + +static std::optional +Handler_OpImageSparseRead_StorageImageReadWithoutFormat( + const Instruction* instruction) { + assert(instruction->opcode() == spv::Op::OpImageSparseRead && + "This handler only support OpImageSparseRead opcodes."); + const auto* def_use_mgr = instruction->context()->get_def_use_mgr(); + + const uint32_t image_index = + instruction->GetSingleWordInOperand(kOpImageSparseReadImageIndex); + const uint32_t type_index = def_use_mgr->GetDef(image_index)->type_id(); + const Instruction* type = def_use_mgr->GetDef(type_index); + const uint32_t format = type->GetSingleWordInOperand(kOpTypeImageFormatIndex); + + return spv::ImageFormat(format) == spv::ImageFormat::Unknown + ? std::optional(spv::Capability::StorageImageReadWithoutFormat) + : std::nullopt; +} + +// Opcode of interest to determine capabilities requirements. +constexpr std::array, 13> kOpcodeHandlers{{ + // clang-format off + {spv::Op::OpImageRead, Handler_OpImageRead_StorageImageReadWithoutFormat}, + {spv::Op::OpImageWrite, Handler_OpImageWrite_StorageImageWriteWithoutFormat}, + {spv::Op::OpImageSparseRead, Handler_OpImageSparseRead_StorageImageReadWithoutFormat}, + {spv::Op::OpTypeFloat, Handler_OpTypeFloat_Float16 }, + {spv::Op::OpTypeFloat, Handler_OpTypeFloat_Float64 }, + {spv::Op::OpTypeImage, Handler_OpTypeImage_ImageMSArray}, + {spv::Op::OpTypeInt, Handler_OpTypeInt_Int16 }, + {spv::Op::OpTypeInt, Handler_OpTypeInt_Int64 }, + {spv::Op::OpTypePointer, Handler_OpTypePointer_StorageInputOutput16}, + {spv::Op::OpTypePointer, Handler_OpTypePointer_StoragePushConstant16}, + {spv::Op::OpTypePointer, Handler_OpTypePointer_StorageUniform16}, + {spv::Op::OpTypePointer, Handler_OpTypePointer_StorageUniform16}, + {spv::Op::OpTypePointer, Handler_OpTypePointer_StorageUniformBufferBlock16}, + // clang-format on +}}; + +// ============== End opcode handler implementations. ======================= + +namespace { +ExtensionSet getExtensionsRelatedTo(const CapabilitySet& capabilities, + const AssemblyGrammar& grammar) { + ExtensionSet output; + const spv_operand_desc_t* desc = nullptr; + for (auto capability : capabilities) { + if (SPV_SUCCESS != grammar.lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, + static_cast(capability), + &desc)) { + continue; + } + + for (uint32_t i = 0; i < desc->numExtensions; ++i) { + output.insert(desc->extensions[i]); + } + } + + return output; +} + +bool hasOpcodeConflictingCapabilities(spv::Op opcode) { + switch (opcode) { + case spv::Op::OpBeginInvocationInterlockEXT: + case spv::Op::OpEndInvocationInterlockEXT: + case spv::Op::OpGroupNonUniformIAdd: + case spv::Op::OpGroupNonUniformFAdd: + case spv::Op::OpGroupNonUniformIMul: + case spv::Op::OpGroupNonUniformFMul: + case spv::Op::OpGroupNonUniformSMin: + case spv::Op::OpGroupNonUniformUMin: + case spv::Op::OpGroupNonUniformFMin: + case spv::Op::OpGroupNonUniformSMax: + case spv::Op::OpGroupNonUniformUMax: + case spv::Op::OpGroupNonUniformFMax: + case spv::Op::OpGroupNonUniformBitwiseAnd: + case spv::Op::OpGroupNonUniformBitwiseOr: + case spv::Op::OpGroupNonUniformBitwiseXor: + case spv::Op::OpGroupNonUniformLogicalAnd: + case spv::Op::OpGroupNonUniformLogicalOr: + case spv::Op::OpGroupNonUniformLogicalXor: + return true; + default: + return false; + } +} + +} // namespace + +TrimCapabilitiesPass::TrimCapabilitiesPass() + : supportedCapabilities_( + TrimCapabilitiesPass::kSupportedCapabilities.cbegin(), + TrimCapabilitiesPass::kSupportedCapabilities.cend()), + forbiddenCapabilities_( + TrimCapabilitiesPass::kForbiddenCapabilities.cbegin(), + TrimCapabilitiesPass::kForbiddenCapabilities.cend()), + untouchableCapabilities_( + TrimCapabilitiesPass::kUntouchableCapabilities.cbegin(), + TrimCapabilitiesPass::kUntouchableCapabilities.cend()), + opcodeHandlers_(kOpcodeHandlers.cbegin(), kOpcodeHandlers.cend()) {} + +void TrimCapabilitiesPass::addInstructionRequirementsForOpcode( + spv::Op opcode, CapabilitySet* capabilities, + ExtensionSet* extensions) const { + if (hasOpcodeConflictingCapabilities(opcode)) { + return; + } + + const spv_opcode_desc_t* desc = {}; + auto result = context()->grammar().lookupOpcode(opcode, &desc); + if (result != SPV_SUCCESS) { + return; + } + + addSupportedCapabilitiesToSet(desc, capabilities); + addSupportedExtensionsToSet(desc, extensions); +} + +void TrimCapabilitiesPass::addInstructionRequirementsForOperand( + const Operand& operand, CapabilitySet* capabilities, + ExtensionSet* extensions) const { + // No supported capability relies on a 2+-word operand. + if (operand.words.size() != 1) { + return; + } + + // No supported capability relies on a literal string operand or an ID. + if (operand.type == SPV_OPERAND_TYPE_LITERAL_STRING || + operand.type == SPV_OPERAND_TYPE_ID || + operand.type == SPV_OPERAND_TYPE_RESULT_ID) { + return; + } + + // If the Vulkan memory model is declared and any instruction uses Device + // scope, the VulkanMemoryModelDeviceScope capability must be declared. This + // rule cannot be covered by the grammar, so must be checked explicitly. + if (operand.type == SPV_OPERAND_TYPE_SCOPE_ID) { + const Instruction* memory_model = context()->GetMemoryModel(); + if (memory_model && memory_model->GetSingleWordInOperand(1u) == + uint32_t(spv::MemoryModel::Vulkan)) { + capabilities->insert(spv::Capability::VulkanMemoryModelDeviceScope); + } + } + + // case 1: Operand is a single value, can directly lookup. + if (!spvOperandIsConcreteMask(operand.type)) { + const spv_operand_desc_t* desc = {}; + auto result = context()->grammar().lookupOperand(operand.type, + operand.words[0], &desc); + if (result != SPV_SUCCESS) { + return; + } + addSupportedCapabilitiesToSet(desc, capabilities); + addSupportedExtensionsToSet(desc, extensions); + return; + } + + // case 2: operand can be a bitmask, we need to decompose the lookup. + for (uint32_t i = 0; i < 32; i++) { + const uint32_t mask = (1 << i) & operand.words[0]; + if (!mask) { + continue; + } + + const spv_operand_desc_t* desc = {}; + auto result = context()->grammar().lookupOperand(operand.type, mask, &desc); + if (result != SPV_SUCCESS) { + continue; + } + + addSupportedCapabilitiesToSet(desc, capabilities); + addSupportedExtensionsToSet(desc, extensions); + } +} + +void TrimCapabilitiesPass::addInstructionRequirementsForExtInst( + Instruction* instruction, CapabilitySet* capabilities) const { + assert(instruction->opcode() == spv::Op::OpExtInst && + "addInstructionRequirementsForExtInst must be passed an OpExtInst " + "instruction"); + + const auto* def_use_mgr = context()->get_def_use_mgr(); + + const Instruction* extInstImport = def_use_mgr->GetDef( + instruction->GetSingleWordInOperand(kOpExtInstSetInIndex)); + uint32_t extInstruction = + instruction->GetSingleWordInOperand(kOpExtInstInstructionInIndex); + + const Operand& extInstSet = + extInstImport->GetInOperand(kOpExtInstImportNameInIndex); + + spv_ext_inst_type_t instructionSet = + spvExtInstImportTypeGet(extInstSet.AsString().c_str()); + + spv_ext_inst_desc desc = {}; + auto result = + context()->grammar().lookupExtInst(instructionSet, extInstruction, &desc); + if (result != SPV_SUCCESS) { + return; + } + + addSupportedCapabilitiesToSet(desc, capabilities); +} + +void TrimCapabilitiesPass::addInstructionRequirements( + Instruction* instruction, CapabilitySet* capabilities, + ExtensionSet* extensions) const { + // Ignoring OpCapability and OpExtension instructions. + if (instruction->opcode() == spv::Op::OpCapability || + instruction->opcode() == spv::Op::OpExtension) { + return; + } + + if (instruction->opcode() == spv::Op::OpExtInst) { + addInstructionRequirementsForExtInst(instruction, capabilities); + } else { + addInstructionRequirementsForOpcode(instruction->opcode(), capabilities, + extensions); + } + + // Second case: one of the opcode operand is gated by a capability. + const uint32_t operandCount = instruction->NumOperands(); + for (uint32_t i = 0; i < operandCount; i++) { + addInstructionRequirementsForOperand(instruction->GetOperand(i), + capabilities, extensions); + } + + // Last case: some complex logic needs to be run to determine capabilities. + auto[begin, end] = opcodeHandlers_.equal_range(instruction->opcode()); + for (auto it = begin; it != end; it++) { + const OpcodeHandler handler = it->second; + auto result = handler(instruction); + if (!result.has_value()) { + continue; + } + + capabilities->insert(*result); + } +} + +void TrimCapabilitiesPass::AddExtensionsForOperand( + const spv_operand_type_t type, const uint32_t value, + ExtensionSet* extensions) const { + const spv_operand_desc_t* desc = nullptr; + spv_result_t result = context()->grammar().lookupOperand(type, value, &desc); + if (result != SPV_SUCCESS) { + return; + } + addSupportedExtensionsToSet(desc, extensions); +} + +std::pair +TrimCapabilitiesPass::DetermineRequiredCapabilitiesAndExtensions() const { + CapabilitySet required_capabilities; + ExtensionSet required_extensions; + + get_module()->ForEachInst([&](Instruction* instruction) { + addInstructionRequirements(instruction, &required_capabilities, + &required_extensions); + }); + + for (auto capability : required_capabilities) { + AddExtensionsForOperand(SPV_OPERAND_TYPE_CAPABILITY, + static_cast(capability), + &required_extensions); + } + +#if !defined(NDEBUG) + // Debug only. We check the outputted required capabilities against the + // supported capabilities list. The supported capabilities list is useful for + // API users to quickly determine if they can use the pass or not. But this + // list has to remain up-to-date with the pass code. If we can detect a + // capability as required, but it's not listed, it means the list is + // out-of-sync. This method is not ideal, but should cover most cases. + { + for (auto capability : required_capabilities) { + assert(supportedCapabilities_.contains(capability) && + "Module is using a capability that is not listed as supported."); + } + } +#endif + + return std::make_pair(std::move(required_capabilities), + std::move(required_extensions)); +} + +Pass::Status TrimCapabilitiesPass::TrimUnrequiredCapabilities( + const CapabilitySet& required_capabilities) const { + const FeatureManager* feature_manager = context()->get_feature_mgr(); + CapabilitySet capabilities_to_trim; + for (auto capability : feature_manager->GetCapabilities()) { + // Some capabilities cannot be safely removed. Leaving them untouched. + if (untouchableCapabilities_.contains(capability)) { + continue; + } + + // If the capability is unsupported, don't trim it. + if (!supportedCapabilities_.contains(capability)) { + continue; + } + + if (required_capabilities.contains(capability)) { + continue; + } + + capabilities_to_trim.insert(capability); + } + + for (auto capability : capabilities_to_trim) { + context()->RemoveCapability(capability); + } + + return capabilities_to_trim.size() == 0 ? Pass::Status::SuccessWithoutChange + : Pass::Status::SuccessWithChange; +} + +Pass::Status TrimCapabilitiesPass::TrimUnrequiredExtensions( + const ExtensionSet& required_extensions) const { + const auto supported_extensions = + getExtensionsRelatedTo(supportedCapabilities_, context()->grammar()); + + bool modified_module = false; + for (auto extension : supported_extensions) { + if (required_extensions.contains(extension)) { + continue; + } + + if (context()->RemoveExtension(extension)) { + modified_module = true; + } + } + + return modified_module ? Pass::Status::SuccessWithChange + : Pass::Status::SuccessWithoutChange; +} + +bool TrimCapabilitiesPass::HasForbiddenCapabilities() const { + // EnumSet.HasAnyOf returns `true` if the given set is empty. + if (forbiddenCapabilities_.size() == 0) { + return false; + } + + const auto& capabilities = context()->get_feature_mgr()->GetCapabilities(); + return capabilities.HasAnyOf(forbiddenCapabilities_); +} + +Pass::Status TrimCapabilitiesPass::Process() { + if (HasForbiddenCapabilities()) { + return Status::SuccessWithoutChange; + } + + auto[required_capabilities, required_extensions] = + DetermineRequiredCapabilitiesAndExtensions(); + + Pass::Status capStatus = TrimUnrequiredCapabilities(required_capabilities); + Pass::Status extStatus = TrimUnrequiredExtensions(required_extensions); + + return capStatus == Pass::Status::SuccessWithChange || + extStatus == Pass::Status::SuccessWithChange + ? Pass::Status::SuccessWithChange + : Pass::Status::SuccessWithoutChange; +} + +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/trim_capabilities_pass.h b/third_party/spirv-tools/source/opt/trim_capabilities_pass.h new file mode 100644 index 0000000000..1d1183ab23 --- /dev/null +++ b/third_party/spirv-tools/source/opt/trim_capabilities_pass.h @@ -0,0 +1,214 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_TRIM_CAPABILITIES_PASS_H_ +#define SOURCE_OPT_TRIM_CAPABILITIES_PASS_H_ + +#include +#include +#include +#include +#include +#include + +#include "source/enum_set.h" +#include "source/extensions.h" +#include "source/opt/ir_context.h" +#include "source/opt/module.h" +#include "source/opt/pass.h" +#include "source/spirv_target_env.h" + +namespace spvtools { +namespace opt { + +// This is required for NDK build. The unordered_set/unordered_map +// implementation don't work with class enums. +struct ClassEnumHash { + std::size_t operator()(spv::Capability value) const { + using StoringType = typename std::underlying_type_t; + return std::hash{}(static_cast(value)); + } + + std::size_t operator()(spv::Op value) const { + using StoringType = typename std::underlying_type_t; + return std::hash{}(static_cast(value)); + } +}; + +// An opcode handler is a function which, given an instruction, returns either +// the required capability, or nothing. +// Each handler checks one case for a capability requirement. +// +// Example: +// - `OpTypeImage` can have operand `A` operand which requires capability 1 +// - `OpTypeImage` can also have operand `B` which requires capability 2. +// -> We have 2 handlers: `Handler_OpTypeImage_1` and +// `Handler_OpTypeImage_2`. +using OpcodeHandler = + std::optional (*)(const Instruction* instruction); + +// This pass tried to remove superfluous capabilities declared in the module. +// - If all the capabilities listed by an extension are removed, the extension +// is also trimmed. +// - If the module countains any capability listed in `kForbiddenCapabilities`, +// the module is left untouched. +// - No capabilities listed in `kUntouchableCapabilities` are trimmed, even when +// not used. +// - Only capabilitied listed in `kSupportedCapabilities` are supported. +// - If the module contains unsupported capabilities, results might be +// incorrect. +class TrimCapabilitiesPass : public Pass { + private: + // All the capabilities supported by this optimization pass. If your module + // contains unsupported instruction, the pass could yield bad results. + static constexpr std::array kSupportedCapabilities{ + // clang-format off + spv::Capability::ComputeDerivativeGroupLinearKHR, + spv::Capability::ComputeDerivativeGroupQuadsKHR, + spv::Capability::Float16, + spv::Capability::Float64, + spv::Capability::FragmentShaderPixelInterlockEXT, + spv::Capability::FragmentShaderSampleInterlockEXT, + spv::Capability::FragmentShaderShadingRateInterlockEXT, + spv::Capability::GroupNonUniform, + spv::Capability::GroupNonUniformArithmetic, + spv::Capability::GroupNonUniformClustered, + spv::Capability::GroupNonUniformPartitionedNV, + spv::Capability::GroupNonUniformVote, + spv::Capability::Groups, + spv::Capability::ImageMSArray, + spv::Capability::Int16, + spv::Capability::Int64, + spv::Capability::InterpolationFunction, + spv::Capability::Linkage, + spv::Capability::MinLod, + spv::Capability::PhysicalStorageBufferAddresses, + spv::Capability::RayQueryKHR, + spv::Capability::RayTracingKHR, + spv::Capability::RayTraversalPrimitiveCullingKHR, + spv::Capability::Shader, + spv::Capability::ShaderClockKHR, + spv::Capability::StorageImageReadWithoutFormat, + spv::Capability::StorageImageWriteWithoutFormat, + spv::Capability::StorageInputOutput16, + spv::Capability::StoragePushConstant16, + spv::Capability::StorageUniform16, + spv::Capability::StorageUniformBufferBlock16, + spv::Capability::VulkanMemoryModelDeviceScope, + // clang-format on + }; + + // Those capabilities disable all transformation of the module. + static constexpr std::array kForbiddenCapabilities{ + spv::Capability::Linkage, + }; + + // Those capabilities are never removed from a module because we cannot + // guess from the SPIR-V only if they are required or not. + static constexpr std::array kUntouchableCapabilities{ + spv::Capability::Shader, + }; + + public: + TrimCapabilitiesPass(); + TrimCapabilitiesPass(const TrimCapabilitiesPass&) = delete; + TrimCapabilitiesPass(TrimCapabilitiesPass&&) = delete; + + private: + // Inserts every capability listed by `descriptor` this pass supports into + // `output`. Expects a Descriptor like `spv_opcode_desc_t` or + // `spv_operand_desc_t`. + template + inline void addSupportedCapabilitiesToSet(const Descriptor* const descriptor, + CapabilitySet* output) const { + const uint32_t capabilityCount = descriptor->numCapabilities; + for (uint32_t i = 0; i < capabilityCount; ++i) { + const auto capability = descriptor->capabilities[i]; + if (supportedCapabilities_.contains(capability)) { + output->insert(capability); + } + } + } + + // Inserts every extension listed by `descriptor` required by the module into + // `output`. Expects a Descriptor like `spv_opcode_desc_t` or + // `spv_operand_desc_t`. + template + inline void addSupportedExtensionsToSet(const Descriptor* const descriptor, + ExtensionSet* output) const { + if (descriptor->minVersion <= + spvVersionForTargetEnv(context()->GetTargetEnv())) { + return; + } + output->insert(descriptor->extensions, + descriptor->extensions + descriptor->numExtensions); + } + + void addInstructionRequirementsForOpcode(spv::Op opcode, + CapabilitySet* capabilities, + ExtensionSet* extensions) const; + void addInstructionRequirementsForOperand(const Operand& operand, + CapabilitySet* capabilities, + ExtensionSet* extensions) const; + + void addInstructionRequirementsForExtInst(Instruction* instruction, + CapabilitySet* capabilities) const; + + // Given an `instruction`, determines the capabilities it requires, and output + // them in `capabilities`. The returned capabilities form a subset of + // kSupportedCapabilities. + void addInstructionRequirements(Instruction* instruction, + CapabilitySet* capabilities, + ExtensionSet* extensions) const; + + // Given an operand `type` and `value`, adds the extensions it would require + // to `extensions`. + void AddExtensionsForOperand(const spv_operand_type_t type, + const uint32_t value, + ExtensionSet* extensions) const; + + // Returns the list of required capabilities and extensions for the module. + // The returned capabilities form a subset of kSupportedCapabilities. + std::pair + DetermineRequiredCapabilitiesAndExtensions() const; + + // Trims capabilities not listed in `required_capabilities` if possible. + // Returns whether or not the module was modified. + Pass::Status TrimUnrequiredCapabilities( + const CapabilitySet& required_capabilities) const; + + // Trims extensions not listed in `required_extensions` if supported by this + // pass. An extensions is considered supported as soon as one capability this + // pass support requires it. + Pass::Status TrimUnrequiredExtensions( + const ExtensionSet& required_extensions) const; + + // Returns if the analyzed module contains any forbidden capability. + bool HasForbiddenCapabilities() const; + + public: + const char* name() const override { return "trim-capabilities"; } + Status Process() override; + + private: + const CapabilitySet supportedCapabilities_; + const CapabilitySet forbiddenCapabilities_; + const CapabilitySet untouchableCapabilities_; + const std::unordered_multimap + opcodeHandlers_; +}; + +} // namespace opt +} // namespace spvtools +#endif // SOURCE_OPT_TRIM_CAPABILITIES_H_ diff --git a/third_party/spirv-tools/source/opt/type_manager.cpp b/third_party/spirv-tools/source/opt/type_manager.cpp index 6e4c054ef4..45d14af531 100644 --- a/third_party/spirv-tools/source/opt/type_manager.cpp +++ b/third_party/spirv-tools/source/opt/type_manager.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2016 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -178,7 +180,7 @@ void TypeManager::RemoveId(uint32_t id) { if (iter == id_to_type_.end()) return; auto& type = iter->second; - if (!type->IsUniqueType(true)) { + if (!type->IsUniqueType()) { auto tIter = type_to_id_.find(type); if (tIter != type_to_id_.end() && tIter->second == id) { // |type| currently maps to |id|. @@ -245,6 +247,7 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { {(type->AsInteger()->IsSigned() ? 1u : 0u)}}}); break; case Type::kFloat: + // TODO: Handle FP encoding enums once actually used. typeInst = MakeUnique( context(), spv::Op::OpTypeFloat, 0, id, std::initializer_list{ @@ -334,6 +337,17 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { std::initializer_list{{SPV_OPERAND_TYPE_ID, {subtype}}}); break; } + case Type::kNodePayloadArrayAMDX: { + uint32_t subtype = + GetTypeInstruction(type->AsNodePayloadArrayAMDX()->element_type()); + if (subtype == 0) { + return 0; + } + typeInst = MakeUnique( + context(), spv::Op::OpTypeNodePayloadArrayAMDX, 0, id, + std::initializer_list{{SPV_OPERAND_TYPE_ID, {subtype}}}); + break; + } case Type::kStruct: { std::vector ops; const Struct* structTy = type->AsStruct(); @@ -423,6 +437,59 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { {SPV_OPERAND_TYPE_ID, {coop_mat->columns_id()}}}); break; } + case Type::kCooperativeMatrixKHR: { + auto coop_mat = type->AsCooperativeMatrixKHR(); + uint32_t const component_type = + GetTypeInstruction(coop_mat->component_type()); + if (component_type == 0) { + return 0; + } + typeInst = MakeUnique( + context(), spv::Op::OpTypeCooperativeMatrixKHR, 0, id, + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {component_type}}, + {SPV_OPERAND_TYPE_SCOPE_ID, {coop_mat->scope_id()}}, + {SPV_OPERAND_TYPE_ID, {coop_mat->rows_id()}}, + {SPV_OPERAND_TYPE_ID, {coop_mat->columns_id()}}, + {SPV_OPERAND_TYPE_ID, {coop_mat->use_id()}}}); + break; + } + case Type::kTensorLayoutNV: { + auto tensor_layout = type->AsTensorLayoutNV(); + typeInst = MakeUnique( + context(), spv::Op::OpTypeTensorLayoutNV, 0, id, + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {tensor_layout->dim_id()}}, + {SPV_OPERAND_TYPE_ID, {tensor_layout->clamp_mode_id()}}}); + break; + } + case Type::kTensorViewNV: { + auto tensor_view = type->AsTensorViewNV(); + std::vector operands; + operands.push_back(Operand{SPV_OPERAND_TYPE_ID, {tensor_view->dim_id()}}); + operands.push_back( + Operand{SPV_OPERAND_TYPE_ID, {tensor_view->has_dimensions_id()}}); + for (auto p : tensor_view->perm()) { + operands.push_back(Operand{SPV_OPERAND_TYPE_ID, {p}}); + } + typeInst = MakeUnique(context(), spv::Op::OpTypeTensorViewNV, + 0, id, operands); + break; + } + case Type::kCooperativeVectorNV: { + auto coop_vec = type->AsCooperativeVectorNV(); + uint32_t const component_type = + GetTypeInstruction(coop_vec->component_type()); + if (component_type == 0) { + return 0; + } + typeInst = MakeUnique( + context(), spv::Op::OpTypeCooperativeVectorNV, 0, id, + std::initializer_list{ + {SPV_OPERAND_TYPE_ID, {component_type}}, + {SPV_OPERAND_TYPE_ID, {coop_vec->components()}}}); + break; + } default: assert(false && "Unexpected type"); break; @@ -437,12 +504,7 @@ uint32_t TypeManager::FindPointerToType(uint32_t type_id, spv::StorageClass storage_class) { Type* pointeeTy = GetType(type_id); Pointer pointerTy(pointeeTy, storage_class); - if (pointeeTy->IsUniqueType(true)) { - // Non-ambiguous type. Get the pointer type through the type manager. - return GetTypeInstruction(&pointerTy); - } - // Ambiguous type, do a linear search. Module::inst_iterator type_itr = context()->module()->types_values_begin(); for (; type_itr != context()->module()->types_values_end(); ++type_itr) { const Instruction* type_inst = &*type_itr; @@ -455,8 +517,10 @@ uint32_t TypeManager::FindPointerToType(uint32_t type_id, } // Must create the pointer type. - // TODO(1841): Handle id overflow. uint32_t resultId = context()->TakeNextId(); + if (resultId == 0) { + return 0; + } std::unique_ptr type_inst( new Instruction(context(), spv::Op::OpTypePointer, 0, resultId, {{spv_operand_type_t::SPV_OPERAND_TYPE_STORAGE_CLASS, @@ -500,13 +564,24 @@ void TypeManager::CreateDecoration(uint32_t target, context()->get_def_use_mgr()->AnalyzeInstUse(inst); } -Type* TypeManager::RebuildType(const Type& type) { +Type* TypeManager::RebuildType(uint32_t type_id, const Type& type) { + assert(type_id != 0); + // The comparison and hash on the type pool will avoid inserting the rebuilt // type if an equivalent type already exists. The rebuilt type will be deleted // when it goes out of scope at the end of the function in that case. Repeated // insertions of the same Type will, at most, keep one corresponding object in // the type pool. std::unique_ptr rebuilt_ty; + + // If |type_id| is already present in the type pool, return the existing type. + // This saves extra work in the type builder and prevents running into + // circular issues (https://github.com/KhronosGroup/SPIRV-Tools/issues/5623). + Type* pool_ty = GetType(type_id); + if (pool_ty != nullptr) { + return pool_ty; + } + switch (type.kind()) { #define DefineNoSubtypeCase(kind) \ case Type::k##kind: \ @@ -533,43 +608,53 @@ Type* TypeManager::RebuildType(const Type& type) { case Type::kVector: { const Vector* vec_ty = type.AsVector(); const Type* ele_ty = vec_ty->element_type(); - rebuilt_ty = - MakeUnique(RebuildType(*ele_ty), vec_ty->element_count()); + rebuilt_ty = MakeUnique(RebuildType(GetId(ele_ty), *ele_ty), + vec_ty->element_count()); break; } case Type::kMatrix: { const Matrix* mat_ty = type.AsMatrix(); const Type* ele_ty = mat_ty->element_type(); - rebuilt_ty = - MakeUnique(RebuildType(*ele_ty), mat_ty->element_count()); + rebuilt_ty = MakeUnique(RebuildType(GetId(ele_ty), *ele_ty), + mat_ty->element_count()); break; } case Type::kImage: { const Image* image_ty = type.AsImage(); const Type* ele_ty = image_ty->sampled_type(); - rebuilt_ty = - MakeUnique(RebuildType(*ele_ty), image_ty->dim(), - image_ty->depth(), image_ty->is_arrayed(), - image_ty->is_multisampled(), image_ty->sampled(), - image_ty->format(), image_ty->access_qualifier()); + rebuilt_ty = MakeUnique( + RebuildType(GetId(ele_ty), *ele_ty), image_ty->dim(), + image_ty->depth(), image_ty->is_arrayed(), + image_ty->is_multisampled(), image_ty->sampled(), image_ty->format(), + image_ty->access_qualifier()); break; } case Type::kSampledImage: { const SampledImage* image_ty = type.AsSampledImage(); const Type* ele_ty = image_ty->image_type(); - rebuilt_ty = MakeUnique(RebuildType(*ele_ty)); + rebuilt_ty = + MakeUnique(RebuildType(GetId(ele_ty), *ele_ty)); break; } case Type::kArray: { const Array* array_ty = type.AsArray(); - rebuilt_ty = - MakeUnique(array_ty->element_type(), array_ty->length_info()); + const Type* ele_ty = array_ty->element_type(); + rebuilt_ty = MakeUnique(RebuildType(GetId(ele_ty), *ele_ty), + array_ty->length_info()); break; } case Type::kRuntimeArray: { const RuntimeArray* array_ty = type.AsRuntimeArray(); const Type* ele_ty = array_ty->element_type(); - rebuilt_ty = MakeUnique(RebuildType(*ele_ty)); + rebuilt_ty = + MakeUnique(RebuildType(GetId(ele_ty), *ele_ty)); + break; + } + case Type::kNodePayloadArrayAMDX: { + const NodePayloadArrayAMDX* array_ty = type.AsNodePayloadArrayAMDX(); + const Type* ele_ty = array_ty->element_type(); + rebuilt_ty = + MakeUnique(RebuildType(GetId(ele_ty), *ele_ty)); break; } case Type::kStruct: { @@ -577,7 +662,7 @@ Type* TypeManager::RebuildType(const Type& type) { std::vector subtypes; subtypes.reserve(struct_ty->element_types().size()); for (const auto* ele_ty : struct_ty->element_types()) { - subtypes.push_back(RebuildType(*ele_ty)); + subtypes.push_back(RebuildType(GetId(ele_ty), *ele_ty)); } rebuilt_ty = MakeUnique(subtypes); Struct* rebuilt_struct = rebuilt_ty->AsStruct(); @@ -594,7 +679,7 @@ Type* TypeManager::RebuildType(const Type& type) { case Type::kPointer: { const Pointer* pointer_ty = type.AsPointer(); const Type* ele_ty = pointer_ty->pointee_type(); - rebuilt_ty = MakeUnique(RebuildType(*ele_ty), + rebuilt_ty = MakeUnique(RebuildType(GetId(ele_ty), *ele_ty), pointer_ty->storage_class()); break; } @@ -604,9 +689,10 @@ Type* TypeManager::RebuildType(const Type& type) { std::vector param_types; param_types.reserve(function_ty->param_types().size()); for (const auto* param_ty : function_ty->param_types()) { - param_types.push_back(RebuildType(*param_ty)); + param_types.push_back(RebuildType(GetId(param_ty), *param_ty)); } - rebuilt_ty = MakeUnique(RebuildType(*ret_ty), param_types); + rebuilt_ty = MakeUnique(RebuildType(GetId(ret_ty), *ret_ty), + param_types); break; } case Type::kForwardPointer: { @@ -616,7 +702,7 @@ Type* TypeManager::RebuildType(const Type& type) { const Pointer* target_ptr = forward_ptr_ty->target_pointer(); if (target_ptr) { rebuilt_ty->AsForwardPointer()->SetTargetPointer( - RebuildType(*target_ptr)->AsPointer()); + RebuildType(GetId(target_ptr), *target_ptr)->AsPointer()); } break; } @@ -624,8 +710,37 @@ Type* TypeManager::RebuildType(const Type& type) { const CooperativeMatrixNV* cm_type = type.AsCooperativeMatrixNV(); const Type* component_type = cm_type->component_type(); rebuilt_ty = MakeUnique( - RebuildType(*component_type), cm_type->scope_id(), cm_type->rows_id(), - cm_type->columns_id()); + RebuildType(GetId(component_type), *component_type), + cm_type->scope_id(), cm_type->rows_id(), cm_type->columns_id()); + break; + } + case Type::kCooperativeMatrixKHR: { + const CooperativeMatrixKHR* cm_type = type.AsCooperativeMatrixKHR(); + const Type* component_type = cm_type->component_type(); + rebuilt_ty = MakeUnique( + RebuildType(GetId(component_type), *component_type), + cm_type->scope_id(), cm_type->rows_id(), cm_type->columns_id(), + cm_type->use_id()); + break; + } + case Type::kTensorLayoutNV: { + const TensorLayoutNV* tl_type = type.AsTensorLayoutNV(); + rebuilt_ty = MakeUnique(tl_type->dim_id(), + tl_type->clamp_mode_id()); + break; + } + case Type::kTensorViewNV: { + const TensorViewNV* tv_type = type.AsTensorViewNV(); + rebuilt_ty = MakeUnique( + tv_type->dim_id(), tv_type->has_dimensions_id(), tv_type->perm()); + break; + } + case Type::kCooperativeVectorNV: { + const CooperativeVectorNV* cv_type = type.AsCooperativeVectorNV(); + const Type* component_type = cv_type->component_type(); + rebuilt_ty = MakeUnique( + RebuildType(GetId(component_type), *component_type), + cv_type->components()); break; } default: @@ -644,7 +759,7 @@ Type* TypeManager::RebuildType(const Type& type) { void TypeManager::RegisterType(uint32_t id, const Type& type) { // Rebuild |type| so it and all its constituent types are owned by the type // pool. - Type* rebuilt = RebuildType(type); + Type* rebuilt = RebuildType(id, type); assert(rebuilt->IsSame(&type)); id_to_type_[id] = rebuilt; if (GetId(rebuilt) == 0) { @@ -764,6 +879,14 @@ Type* TypeManager::RecordIfTypeDefinition(const Instruction& inst) { return type; } break; + case spv::Op::OpTypeNodePayloadArrayAMDX: + type = new NodePayloadArrayAMDX(GetType(inst.GetSingleWordInOperand(0))); + if (id_to_incomplete_type_.count(inst.GetSingleWordInOperand(0))) { + incomplete_types_.emplace_back(inst.result_id(), type); + id_to_incomplete_type_[inst.result_id()] = type; + return type; + } + break; case spv::Op::OpTypeStruct: { std::vector element_types; bool incomplete_type = false; @@ -863,14 +986,38 @@ Type* TypeManager::RecordIfTypeDefinition(const Instruction& inst) { inst.GetSingleWordInOperand(2), inst.GetSingleWordInOperand(3)); break; + case spv::Op::OpTypeCooperativeMatrixKHR: + type = new CooperativeMatrixKHR( + GetType(inst.GetSingleWordInOperand(0)), + inst.GetSingleWordInOperand(1), inst.GetSingleWordInOperand(2), + inst.GetSingleWordInOperand(3), inst.GetSingleWordInOperand(4)); + break; + case spv::Op::OpTypeCooperativeVectorNV: + type = new CooperativeVectorNV(GetType(inst.GetSingleWordInOperand(0)), + inst.GetSingleWordInOperand(1)); + break; case spv::Op::OpTypeRayQueryKHR: type = new RayQueryKHR(); break; case spv::Op::OpTypeHitObjectNV: type = new HitObjectNV(); break; + case spv::Op::OpTypeTensorLayoutNV: + type = new TensorLayoutNV(inst.GetSingleWordInOperand(0), + inst.GetSingleWordInOperand(1)); + break; + case spv::Op::OpTypeTensorViewNV: { + const auto count = inst.NumOperands(); + std::vector perm; + for (uint32_t i = 2; i < count; ++i) { + perm.push_back(inst.GetSingleWordOperand(i)); + } + type = new TensorViewNV(inst.GetSingleWordInOperand(0), + inst.GetSingleWordInOperand(1), perm); + break; + } default: - SPIRV_UNIMPLEMENTED(consumer_, "unhandled type"); + assert(false && "Type not handled by the type manager."); break; } @@ -895,7 +1042,8 @@ void TypeManager::AttachDecoration(const Instruction& inst, Type* type) { if (!IsAnnotationInst(opcode)) return; switch (opcode) { - case spv::Op::OpDecorate: { + case spv::Op::OpDecorate: + case spv::Op::OpDecorateId: { const auto count = inst.NumOperands(); std::vector data; for (uint32_t i = 1; i < count; ++i) { @@ -912,12 +1060,10 @@ void TypeManager::AttachDecoration(const Instruction& inst, Type* type) { } if (Struct* st = type->AsStruct()) { st->AddMemberDecoration(index, std::move(data)); - } else { - SPIRV_UNIMPLEMENTED(consumer_, "OpMemberDecorate non-struct type"); } } break; default: - SPIRV_UNREACHABLE(consumer_); + assert(false && "Unexpected opcode for a decoration instruction."); break; } } diff --git a/third_party/spirv-tools/source/opt/type_manager.h b/third_party/spirv-tools/source/opt/type_manager.h index c49e193227..948b691bac 100644 --- a/third_party/spirv-tools/source/opt/type_manager.h +++ b/third_party/spirv-tools/source/opt/type_manager.h @@ -144,18 +144,17 @@ class TypeManager { // |type| (e.g. should be called in loop of |type|'s decorations). void AttachDecoration(const Instruction& inst, Type* type); - Type* GetUIntType() { - Integer int_type(32, false); - return GetRegisteredType(&int_type); - } + Type* GetUIntType() { return GetIntType(32, false); } uint32_t GetUIntTypeId() { return GetTypeInstruction(GetUIntType()); } - Type* GetSIntType() { - Integer int_type(32, true); + Type* GetIntType(int32_t bitWidth, bool isSigned) { + Integer int_type(bitWidth, isSigned); return GetRegisteredType(&int_type); } + Type* GetSIntType() { return GetIntType(32, true); } + uint32_t GetSIntTypeId() { return GetTypeInstruction(GetSIntType()); } Type* GetFloatType() { @@ -261,7 +260,9 @@ class TypeManager { // Returns an equivalent pointer to |type| built in terms of pointers owned by // |type_pool_|. For example, if |type| is a vec3 of bool, it will be rebuilt // replacing the bool subtype with one owned by |type_pool_|. - Type* RebuildType(const Type& type); + // + // The re-built type will have ID |type_id|. + Type* RebuildType(uint32_t type_id, const Type& type); // Completes the incomplete type |type|, by replaces all references to // ForwardPointer by the defining Pointer. diff --git a/third_party/spirv-tools/source/opt/types.cpp b/third_party/spirv-tools/source/opt/types.cpp index ab95906b6d..2023719c86 100644 --- a/third_party/spirv-tools/source/opt/types.cpp +++ b/third_party/spirv-tools/source/opt/types.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2016 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +18,6 @@ #include #include -#include #include #include #include @@ -85,13 +86,13 @@ bool Type::HasSameDecorations(const Type* that) const { return CompareTwoVectors(decorations_, that->decorations_); } -bool Type::IsUniqueType(bool allowVariablePointers) const { +bool Type::IsUniqueType() const { switch (kind_) { case kPointer: - return !allowVariablePointers; case kStruct: case kArray: case kRuntimeArray: + case kNodePayloadArrayAMDX: return false; default: return true; @@ -130,6 +131,8 @@ std::unique_ptr Type::Clone() const { DeclareKindCase(NamedBarrier); DeclareKindCase(AccelerationStructureNV); DeclareKindCase(CooperativeMatrixNV); + DeclareKindCase(CooperativeMatrixKHR); + DeclareKindCase(CooperativeVectorNV); DeclareKindCase(RayQueryKHR); DeclareKindCase(HitObjectNV); #undef DeclareKindCase @@ -163,6 +166,7 @@ bool Type::operator==(const Type& other) const { DeclareKindCase(SampledImage); DeclareKindCase(Array); DeclareKindCase(RuntimeArray); + DeclareKindCase(NodePayloadArrayAMDX); DeclareKindCase(Struct); DeclareKindCase(Opaque); DeclareKindCase(Pointer); @@ -177,8 +181,12 @@ bool Type::operator==(const Type& other) const { DeclareKindCase(NamedBarrier); DeclareKindCase(AccelerationStructureNV); DeclareKindCase(CooperativeMatrixNV); + DeclareKindCase(CooperativeMatrixKHR); + DeclareKindCase(CooperativeVectorNV); DeclareKindCase(RayQueryKHR); DeclareKindCase(HitObjectNV); + DeclareKindCase(TensorLayoutNV); + DeclareKindCase(TensorViewNV); #undef DeclareKindCase default: assert(false && "Unhandled type"); @@ -218,6 +226,7 @@ size_t Type::ComputeHashValue(size_t hash, SeenTypes* seen) const { DeclareKindCase(SampledImage); DeclareKindCase(Array); DeclareKindCase(RuntimeArray); + DeclareKindCase(NodePayloadArrayAMDX); DeclareKindCase(Struct); DeclareKindCase(Opaque); DeclareKindCase(Pointer); @@ -232,8 +241,12 @@ size_t Type::ComputeHashValue(size_t hash, SeenTypes* seen) const { DeclareKindCase(NamedBarrier); DeclareKindCase(AccelerationStructureNV); DeclareKindCase(CooperativeMatrixNV); + DeclareKindCase(CooperativeMatrixKHR); + DeclareKindCase(CooperativeVectorNV); DeclareKindCase(RayQueryKHR); DeclareKindCase(HitObjectNV); + DeclareKindCase(TensorLayoutNV); + DeclareKindCase(TensorViewNV); #undef DeclareKindCase default: assert(false && "Unhandled type"); @@ -484,6 +497,34 @@ void RuntimeArray::ReplaceElementType(const Type* type) { element_type_ = type; } +NodePayloadArrayAMDX::NodePayloadArrayAMDX(const Type* type) + : Type(kNodePayloadArrayAMDX), element_type_(type) { + assert(!type->AsVoid()); +} + +bool NodePayloadArrayAMDX::IsSameImpl(const Type* that, + IsSameCache* seen) const { + const NodePayloadArrayAMDX* rat = that->AsNodePayloadArrayAMDX(); + if (!rat) return false; + return element_type_->IsSameImpl(rat->element_type_, seen) && + HasSameDecorations(that); +} + +std::string NodePayloadArrayAMDX::str() const { + std::ostringstream oss; + oss << "[" << element_type_->str() << "]"; + return oss.str(); +} + +size_t NodePayloadArrayAMDX::ComputeExtraStateHash(size_t hash, + SeenTypes* seen) const { + return element_type_->ComputeHashValue(hash, seen); +} + +void NodePayloadArrayAMDX::ReplaceElementType(const Type* type) { + element_type_ = type; +} + Struct::Struct(const std::vector& types) : Type(kStruct), element_types_(types) { for (const auto* t : types) { @@ -710,6 +751,122 @@ bool CooperativeMatrixNV::IsSameImpl(const Type* that, columns_id_ == mt->columns_id_ && HasSameDecorations(that); } +CooperativeMatrixKHR::CooperativeMatrixKHR(const Type* type, + const uint32_t scope, + const uint32_t rows, + const uint32_t columns, + const uint32_t use) + : Type(kCooperativeMatrixKHR), + component_type_(type), + scope_id_(scope), + rows_id_(rows), + columns_id_(columns), + use_id_(use) { + assert(type != nullptr); + assert(scope != 0); + assert(rows != 0); + assert(columns != 0); +} + +std::string CooperativeMatrixKHR::str() const { + std::ostringstream oss; + oss << "<" << component_type_->str() << ", " << scope_id_ << ", " << rows_id_ + << ", " << columns_id_ << ", " << use_id_ << ">"; + return oss.str(); +} + +size_t CooperativeMatrixKHR::ComputeExtraStateHash(size_t hash, + SeenTypes* seen) const { + hash = hash_combine(hash, scope_id_, rows_id_, columns_id_, use_id_); + return component_type_->ComputeHashValue(hash, seen); +} + +bool CooperativeMatrixKHR::IsSameImpl(const Type* that, + IsSameCache* seen) const { + const CooperativeMatrixKHR* mt = that->AsCooperativeMatrixKHR(); + if (!mt) return false; + return component_type_->IsSameImpl(mt->component_type_, seen) && + scope_id_ == mt->scope_id_ && rows_id_ == mt->rows_id_ && + columns_id_ == mt->columns_id_ && use_id_ == mt->use_id_ && + HasSameDecorations(that); +} + +TensorLayoutNV::TensorLayoutNV(const uint32_t dim, const uint32_t clamp_mode) + : Type(kTensorLayoutNV), dim_id_(dim), clamp_mode_id_(clamp_mode) {} + +std::string TensorLayoutNV::str() const { + std::ostringstream oss; + oss << "<" << dim_id_ << ", " << clamp_mode_id_ << ">"; + return oss.str(); +} + +size_t TensorLayoutNV::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, dim_id_, clamp_mode_id_); +} + +bool TensorLayoutNV::IsSameImpl(const Type* that, IsSameCache*) const { + const TensorLayoutNV* tl = that->AsTensorLayoutNV(); + if (!tl) return false; + return dim_id_ == tl->dim_id_ && clamp_mode_id_ == tl->clamp_mode_id_; +} + +TensorViewNV::TensorViewNV(const uint32_t dim, const uint32_t clamp_mode, + const std::vector& perm) + : Type(kTensorViewNV), + dim_id_(dim), + has_dimensions_id_(clamp_mode), + perm_(perm) {} + +std::string TensorViewNV::str() const { + std::ostringstream oss; + oss << "<" << dim_id_ << ", " << has_dimensions_id_; + for (auto p : perm_) { + oss << ", " << p; + } + oss << ">"; + return oss.str(); +} + +size_t TensorViewNV::ComputeExtraStateHash(size_t hash, SeenTypes*) const { + return hash_combine(hash, dim_id_, has_dimensions_id_, perm_); +} + +bool TensorViewNV::IsSameImpl(const Type* that, IsSameCache*) const { + const TensorViewNV* tv = that->AsTensorViewNV(); + if (!tv) return false; + return dim_id_ == tv->dim_id_ && + has_dimensions_id_ == tv->has_dimensions_id_ && perm_ == tv->perm_; +} + +CooperativeVectorNV::CooperativeVectorNV(const Type* type, + const uint32_t components) + : Type(kCooperativeVectorNV), + component_type_(type), + components_(components) { + assert(type != nullptr); + assert(components != 0); +} + +std::string CooperativeVectorNV::str() const { + std::ostringstream oss; + oss << "<" << component_type_->str() << ", " << components_ << ">"; + return oss.str(); +} + +size_t CooperativeVectorNV::ComputeExtraStateHash(size_t hash, + SeenTypes* seen) const { + hash = hash_combine(hash, components_); + return component_type_->ComputeHashValue(hash, seen); +} + +bool CooperativeVectorNV::IsSameImpl(const Type* that, + IsSameCache* seen) const { + const CooperativeVectorNV* mt = that->AsCooperativeVectorNV(); + if (!mt) return false; + return component_type_->IsSameImpl(mt->component_type_, seen) && + components_ == mt->components_ && HasSameDecorations(that); +} + } // namespace analysis } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/source/opt/types.h b/third_party/spirv-tools/source/opt/types.h index 1f329373b1..1418331369 100644 --- a/third_party/spirv-tools/source/opt/types.h +++ b/third_party/spirv-tools/source/opt/types.h @@ -1,4 +1,6 @@ // Copyright (c) 2016 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,6 +48,7 @@ class Sampler; class SampledImage; class Array; class RuntimeArray; +class NodePayloadArrayAMDX; class Struct; class Opaque; class Pointer; @@ -60,8 +63,12 @@ class PipeStorage; class NamedBarrier; class AccelerationStructureNV; class CooperativeMatrixNV; +class CooperativeMatrixKHR; +class CooperativeVectorNV; class RayQueryKHR; class HitObjectNV; +class TensorLayoutNV; +class TensorViewNV; // Abstract class for a SPIR-V type. It has a bunch of As() methods, // which is used as a way to probe the actual . @@ -86,6 +93,7 @@ class Type { kSampledImage, kArray, kRuntimeArray, + kNodePayloadArrayAMDX, kStruct, kOpaque, kPointer, @@ -100,8 +108,12 @@ class Type { kNamedBarrier, kAccelerationStructureNV, kCooperativeMatrixNV, + kCooperativeMatrixKHR, + kCooperativeVectorNV, kRayQueryKHR, kHitObjectNV, + kTensorLayoutNV, + kTensorViewNV, kLast }; @@ -148,12 +160,16 @@ class Type { // Returns a clone of |this| minus any decorations. std::unique_ptr RemoveDecorations() const; - // Returns true if this type must be unique. + // Returns true if this cannot hash to the same value as another type in the + // module. For example, structs are not unique types because the module could + // have two types // - // If variable pointers are allowed, then pointers are not required to be - // unique. - // TODO(alanbaker): Update this if variable pointers become a core feature. - bool IsUniqueType(bool allowVariablePointers = false) const; + // %1 = OpTypeStruct %int + // %2 = OpTypeStruct %int + // + // The only way to distinguish these types is the result id. The type manager + // will hash them to the same value. + bool IsUniqueType() const; bool operator==(const Type& other) const; @@ -183,6 +199,7 @@ class Type { DeclareCastMethod(SampledImage) DeclareCastMethod(Array) DeclareCastMethod(RuntimeArray) + DeclareCastMethod(NodePayloadArrayAMDX) DeclareCastMethod(Struct) DeclareCastMethod(Opaque) DeclareCastMethod(Pointer) @@ -197,8 +214,12 @@ class Type { DeclareCastMethod(NamedBarrier) DeclareCastMethod(AccelerationStructureNV) DeclareCastMethod(CooperativeMatrixNV) + DeclareCastMethod(CooperativeMatrixKHR) + DeclareCastMethod(CooperativeVectorNV) DeclareCastMethod(RayQueryKHR) DeclareCastMethod(HitObjectNV) + DeclareCastMethod(TensorLayoutNV) + DeclareCastMethod(TensorViewNV) #undef DeclareCastMethod protected: @@ -208,7 +229,9 @@ protected: protected: // Decorations attached to this type. Each decoration is encoded as a vector // of uint32_t numbers. The first uint32_t number is the decoration value, - // and the rest are the parameters to the decoration (if exists). + // and the rest are the parameters to the decoration (if any exist). + // The parameters can be either all literals or all ids depending on the + // decoration value. std::vector> decorations_; private: @@ -427,6 +450,29 @@ class RuntimeArray : public Type { const Type* element_type_; }; +class NodePayloadArrayAMDX : public Type { + public: + NodePayloadArrayAMDX(const Type* element_type); + NodePayloadArrayAMDX(const NodePayloadArrayAMDX&) = default; + + std::string str() const override; + const Type* element_type() const { return element_type_; } + + NodePayloadArrayAMDX* AsNodePayloadArrayAMDX() override { return this; } + const NodePayloadArrayAMDX* AsNodePayloadArrayAMDX() const override { + return this; + } + + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; + + void ReplaceElementType(const Type* element_type); + + private: + bool IsSameImpl(const Type* that, IsSameCache*) const override; + + const Type* element_type_; +}; + class Struct : public Type { public: Struct(const std::vector& element_types); @@ -620,6 +666,109 @@ class CooperativeMatrixNV : public Type { const uint32_t columns_id_; }; +class CooperativeMatrixKHR : public Type { + public: + CooperativeMatrixKHR(const Type* type, const uint32_t scope, + const uint32_t rows, const uint32_t columns, + const uint32_t use); + CooperativeMatrixKHR(const CooperativeMatrixKHR&) = default; + + std::string str() const override; + + CooperativeMatrixKHR* AsCooperativeMatrixKHR() override { return this; } + const CooperativeMatrixKHR* AsCooperativeMatrixKHR() const override { + return this; + } + + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; + + const Type* component_type() const { return component_type_; } + uint32_t scope_id() const { return scope_id_; } + uint32_t rows_id() const { return rows_id_; } + uint32_t columns_id() const { return columns_id_; } + uint32_t use_id() const { return use_id_; } + + private: + bool IsSameImpl(const Type* that, IsSameCache*) const override; + + const Type* component_type_; + const uint32_t scope_id_; + const uint32_t rows_id_; + const uint32_t columns_id_; + const uint32_t use_id_; +}; + +class TensorLayoutNV : public Type { + public: + TensorLayoutNV(const uint32_t dim, const uint32_t clamp_mode); + TensorLayoutNV(const TensorLayoutNV&) = default; + + std::string str() const override; + + TensorLayoutNV* AsTensorLayoutNV() override { return this; } + const TensorLayoutNV* AsTensorLayoutNV() const override { return this; } + + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; + + uint32_t dim_id() const { return dim_id_; } + uint32_t clamp_mode_id() const { return clamp_mode_id_; } + + private: + bool IsSameImpl(const Type* that, IsSameCache*) const override; + + const uint32_t dim_id_; + const uint32_t clamp_mode_id_; +}; + +class TensorViewNV : public Type { + public: + TensorViewNV(const uint32_t dim, const uint32_t clamp_mode, + const std::vector& perm); + TensorViewNV(const TensorViewNV&) = default; + + std::string str() const override; + + TensorViewNV* AsTensorViewNV() override { return this; } + const TensorViewNV* AsTensorViewNV() const override { return this; } + + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; + + uint32_t dim_id() const { return dim_id_; } + uint32_t has_dimensions_id() const { return has_dimensions_id_; } + const std::vector& perm() const { return perm_; } + + private: + bool IsSameImpl(const Type* that, IsSameCache*) const override; + + const uint32_t dim_id_; + const uint32_t has_dimensions_id_; + std::vector perm_; +}; + +class CooperativeVectorNV : public Type { + public: + CooperativeVectorNV(const Type* type, const uint32_t components); + CooperativeVectorNV(const CooperativeVectorNV&) = default; + + std::string str() const override; + + CooperativeVectorNV* AsCooperativeVectorNV() override { return this; } + const CooperativeVectorNV* AsCooperativeVectorNV() const override { + return this; + } + + size_t ComputeExtraStateHash(size_t hash, SeenTypes* seen) const override; + + const Type* component_type() const { return component_type_; } + uint32_t components() const { return components_; } + + private: + bool IsSameImpl(const Type* that, IsSameCache*) const override; + + const Type* component_type_; + const uint32_t components_; +}; + #define DefineParameterlessType(type, name) \ class type : public Type { \ public: \ diff --git a/third_party/spirv-tools/source/opt/unify_const_pass.cpp b/third_party/spirv-tools/source/opt/unify_const_pass.cpp index f774aa6b61..83dd438b63 100644 --- a/third_party/spirv-tools/source/opt/unify_const_pass.cpp +++ b/third_party/spirv-tools/source/opt/unify_const_pass.cpp @@ -20,7 +20,6 @@ #include #include "source/opt/def_use_manager.h" -#include "source/opt/ir_context.h" #include "source/util/make_unique.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/parsed_operand.cpp b/third_party/spirv-tools/source/parsed_operand.cpp index 5f8e94db84..cc33f8ba2c 100644 --- a/third_party/spirv-tools/source/parsed_operand.cpp +++ b/third_party/spirv-tools/source/parsed_operand.cpp @@ -24,6 +24,7 @@ namespace spvtools { void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst, const spv_parsed_operand_t& operand) { if (operand.type != SPV_OPERAND_TYPE_LITERAL_INTEGER && + operand.type != SPV_OPERAND_TYPE_LITERAL_FLOAT && operand.type != SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER && operand.type != SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER && operand.type != SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER) diff --git a/third_party/spirv-tools/source/print.cpp b/third_party/spirv-tools/source/print.cpp index 6c94e2b7fc..3143db1781 100644 --- a/third_party/spirv-tools/source/print.cpp +++ b/third_party/spirv-tools/source/print.cpp @@ -14,26 +14,7 @@ #include "source/print.h" -#if defined(SPIRV_ANDROID) || defined(SPIRV_LINUX) || defined(SPIRV_MAC) || \ - defined(SPIRV_IOS) || defined(SPIRV_TVOS) || defined(SPIRV_FREEBSD) || \ - defined(SPIRV_OPENBSD) || defined(SPIRV_EMSCRIPTEN) || \ - defined(SPIRV_FUCHSIA) || defined(SPIRV_GNU) -namespace spvtools { - -clr::reset::operator const char*() { return "\x1b[0m"; } - -clr::grey::operator const char*() { return "\x1b[1;30m"; } - -clr::red::operator const char*() { return "\x1b[31m"; } - -clr::green::operator const char*() { return "\x1b[32m"; } - -clr::yellow::operator const char*() { return "\x1b[33m"; } - -clr::blue::operator const char*() { return "\x1b[34m"; } - -} // namespace spvtools -#elif defined(SPIRV_WINDOWS) +#if defined(SPIRV_WINDOWS) #include namespace spvtools { @@ -111,17 +92,17 @@ clr::blue::operator const char*() { #else namespace spvtools { -clr::reset::operator const char*() { return ""; } +clr::reset::operator const char*() { return "\x1b[0m"; } -clr::grey::operator const char*() { return ""; } +clr::grey::operator const char*() { return "\x1b[1;30m"; } -clr::red::operator const char*() { return ""; } +clr::red::operator const char*() { return "\x1b[31m"; } -clr::green::operator const char*() { return ""; } +clr::green::operator const char*() { return "\x1b[32m"; } -clr::yellow::operator const char*() { return ""; } +clr::yellow::operator const char*() { return "\x1b[33m"; } -clr::blue::operator const char*() { return ""; } +clr::blue::operator const char*() { return "\x1b[34m"; } } // namespace spvtools #endif diff --git a/third_party/spirv-tools/source/reduce/CMakeLists.txt b/third_party/spirv-tools/source/reduce/CMakeLists.txt index 6fd8409f69..9ebe4183ef 100644 --- a/third_party/spirv-tools/source/reduce/CMakeLists.txt +++ b/third_party/spirv-tools/source/reduce/CMakeLists.txt @@ -101,10 +101,7 @@ set_property(TARGET SPIRV-Tools-reduce PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-reduce) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-reduce EXPORT SPIRV-Tools-reduceTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-reduce EXPORT SPIRV-Tools-reduceTargets) export(EXPORT SPIRV-Tools-reduceTargets FILE SPIRV-Tools-reduceTarget.cmake) spvtools_config_package_dir(SPIRV-Tools-reduce PACKAGE_DIR) diff --git a/third_party/spirv-tools/source/spirv_target_env.cpp b/third_party/spirv-tools/source/spirv_target_env.cpp index 9a03817426..fe23fa6451 100644 --- a/third_party/spirv-tools/source/spirv_target_env.cpp +++ b/third_party/spirv-tools/source/spirv_target_env.cpp @@ -14,10 +14,13 @@ #include "source/spirv_target_env.h" +#include #include +#include #include #include +#include "source/latest_version_spirv_header.h" #include "source/spirv_constant.h" #include "spirv-tools/libspirv.h" @@ -76,6 +79,8 @@ const char* spvTargetEnvDescription(spv_target_env env) { return "SPIR-V 1.6"; case SPV_ENV_VULKAN_1_3: return "SPIR-V 1.6 (under Vulkan 1.3 semantics)"; + case SPV_ENV_VULKAN_1_4: + return "SPIR-V 1.6 (under Vulkan 1.4 semantics)"; case SPV_ENV_MAX: assert(false && "Invalid target environment value."); break; @@ -119,6 +124,7 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) { return SPV_SPIRV_VERSION_WORD(1, 5); case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: return SPV_SPIRV_VERSION_WORD(1, 6); case SPV_ENV_MAX: assert(false && "Invalid target environment value."); @@ -127,32 +133,53 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) { return SPV_SPIRV_VERSION_WORD(0, 0); } -static const std::pair spvTargetEnvNameMap[] = { - {"vulkan1.1spv1.4", SPV_ENV_VULKAN_1_1_SPIRV_1_4}, - {"vulkan1.0", SPV_ENV_VULKAN_1_0}, - {"vulkan1.1", SPV_ENV_VULKAN_1_1}, - {"vulkan1.2", SPV_ENV_VULKAN_1_2}, - {"vulkan1.3", SPV_ENV_VULKAN_1_3}, - {"spv1.0", SPV_ENV_UNIVERSAL_1_0}, - {"spv1.1", SPV_ENV_UNIVERSAL_1_1}, - {"spv1.2", SPV_ENV_UNIVERSAL_1_2}, - {"spv1.3", SPV_ENV_UNIVERSAL_1_3}, - {"spv1.4", SPV_ENV_UNIVERSAL_1_4}, - {"spv1.5", SPV_ENV_UNIVERSAL_1_5}, - {"spv1.6", SPV_ENV_UNIVERSAL_1_6}, - {"opencl1.2embedded", SPV_ENV_OPENCL_EMBEDDED_1_2}, - {"opencl1.2", SPV_ENV_OPENCL_1_2}, - {"opencl2.0embedded", SPV_ENV_OPENCL_EMBEDDED_2_0}, - {"opencl2.0", SPV_ENV_OPENCL_2_0}, - {"opencl2.1embedded", SPV_ENV_OPENCL_EMBEDDED_2_1}, - {"opencl2.1", SPV_ENV_OPENCL_2_1}, - {"opencl2.2embedded", SPV_ENV_OPENCL_EMBEDDED_2_2}, - {"opencl2.2", SPV_ENV_OPENCL_2_2}, - {"opengl4.0", SPV_ENV_OPENGL_4_0}, - {"opengl4.1", SPV_ENV_OPENGL_4_1}, - {"opengl4.2", SPV_ENV_OPENGL_4_2}, - {"opengl4.3", SPV_ENV_OPENGL_4_3}, - {"opengl4.5", SPV_ENV_OPENGL_4_5}, +// When a new SPIR-V version is released, update this table. +static_assert(spv::Version == 0x10600); +constexpr auto ordered_universal_envs = std::array{ + SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2, + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_5, + SPV_ENV_UNIVERSAL_1_6, +}; + +// When a new SPIR-V version is released, update this table. +// Users see this ordered list when running 'spirv-val --help'. Order +// matters for readability. +static_assert(spv::Version == 0x10600); +inline constexpr std::pair spvTargetEnvNameMap[] = + { + // Do not reorder blindly. The algorithm to find the target looks for + // the first entry where the key is a prefix of the string provided by + // the user. For example, if the user provides `vulkan1.2spv1.5`, it + // will match `vulkan1.2`. If this feature is to work correctly, the + // keys must be ordered so that a string is before its prefix. For + // example, `vulkan1.1spv1.4` must be before `vulkan1.1`. Otherwise, + // `vulkan1.1` will be returned when looking for `vulkan1.1spv1.4`. + {"vulkan1.0", SPV_ENV_VULKAN_1_0}, + {"vulkan1.1spv1.4", SPV_ENV_VULKAN_1_1_SPIRV_1_4}, + {"vulkan1.1", SPV_ENV_VULKAN_1_1}, + {"vulkan1.2", SPV_ENV_VULKAN_1_2}, + {"vulkan1.3", SPV_ENV_VULKAN_1_3}, + {"vulkan1.4", SPV_ENV_VULKAN_1_4}, + {"spv1.0", SPV_ENV_UNIVERSAL_1_0}, + {"spv1.1", SPV_ENV_UNIVERSAL_1_1}, + {"spv1.2", SPV_ENV_UNIVERSAL_1_2}, + {"spv1.3", SPV_ENV_UNIVERSAL_1_3}, + {"spv1.4", SPV_ENV_UNIVERSAL_1_4}, + {"spv1.5", SPV_ENV_UNIVERSAL_1_5}, + {"spv1.6", SPV_ENV_UNIVERSAL_1_6}, + {"opencl1.2embedded", SPV_ENV_OPENCL_EMBEDDED_1_2}, + {"opencl1.2", SPV_ENV_OPENCL_1_2}, + {"opencl2.0embedded", SPV_ENV_OPENCL_EMBEDDED_2_0}, + {"opencl2.0", SPV_ENV_OPENCL_2_0}, + {"opencl2.1embedded", SPV_ENV_OPENCL_EMBEDDED_2_1}, + {"opencl2.1", SPV_ENV_OPENCL_2_1}, + {"opencl2.2embedded", SPV_ENV_OPENCL_EMBEDDED_2_2}, + {"opencl2.2", SPV_ENV_OPENCL_2_2}, + {"opengl4.0", SPV_ENV_OPENGL_4_0}, + {"opengl4.1", SPV_ENV_OPENGL_4_1}, + {"opengl4.2", SPV_ENV_OPENGL_4_2}, + {"opengl4.3", SPV_ENV_OPENGL_4_3}, + {"opengl4.5", SPV_ENV_OPENGL_4_5}, }; bool spvParseTargetEnv(const char* s, spv_target_env* env) { @@ -171,6 +198,59 @@ bool spvParseTargetEnv(const char* s, spv_target_env* env) { return false; } +bool spvReadEnvironmentFromText(const std::vector& text, + spv_target_env* env) { + // Version is expected to match "; Version: 1.X" + // Version string must occur in header, that is, initial lines of comments + // Once a non-comment line occurs, the header has ended + for (std::size_t i = 0; i < text.size(); ++i) { + char c = text[i]; + + if (c == ';') { + // Try to match against the expected version string + constexpr const char* kVersionPrefix = "; Version: 1."; + constexpr const auto kPrefixLength = 13; + // 'minor_digit_pos' is the expected position of the version digit. + const auto minor_digit_pos = i + kPrefixLength; + if (minor_digit_pos >= text.size()) return false; + + // Match the prefix. + auto j = 1; + for (; j < kPrefixLength; ++j) { + if (kVersionPrefix[j] != text[i + j]) break; + } + // j will match the prefix length if all characters before matched + if (j == kPrefixLength) { + // This expects only one digit in the minor number. + static_assert(((spv::Version >> 8) & 0xff) < 10); + char minor = text[minor_digit_pos]; + char next_char = + minor_digit_pos + 1 < text.size() ? text[minor_digit_pos + 1] : 0; + if (std::isdigit(minor) && !std::isdigit(next_char)) { + const auto index = minor - '0'; + assert(index >= 0); + if (static_cast(index) < ordered_universal_envs.size()) { + *env = ordered_universal_envs[index]; + return true; + } + } + } + + // If no match, determine whether the header has ended (in which case, + // assumption has failed.) + // Skip until the next line. + i += j; + for (; i < text.size(); ++i) { + if (text[i] == '\n') break; + } + } else if (!std::isspace(c)) { + // Allow blanks, but end the search if we find something else. + break; + } + } + return false; +} + #define VULKAN_VER(MAJOR, MINOR) ((MAJOR << 22) | (MINOR << 12)) #define SPIRV_VER(MAJOR, MINOR) ((MAJOR << 16) | (MINOR << 8)) @@ -187,7 +267,8 @@ static const VulkanEnv ordered_vulkan_envs[] = { {SPV_ENV_VULKAN_1_1, VULKAN_VER(1, 1), SPIRV_VER(1, 3)}, {SPV_ENV_VULKAN_1_1_SPIRV_1_4, VULKAN_VER(1, 1), SPIRV_VER(1, 4)}, {SPV_ENV_VULKAN_1_2, VULKAN_VER(1, 2), SPIRV_VER(1, 5)}, - {SPV_ENV_VULKAN_1_3, VULKAN_VER(1, 3), SPIRV_VER(1, 6)}}; + {SPV_ENV_VULKAN_1_3, VULKAN_VER(1, 3), SPIRV_VER(1, 6)}, + {SPV_ENV_VULKAN_1_4, VULKAN_VER(1, 4), SPIRV_VER(1, 6)}}; bool spvParseVulkanEnv(uint32_t vulkan_ver, uint32_t spirv_ver, spv_target_env* env) { @@ -228,6 +309,7 @@ bool spvIsVulkanEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_VULKAN_1_2: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: return true; case SPV_ENV_WEBGPU_0: assert(false && "Deprecated target environment value."); @@ -258,6 +340,7 @@ bool spvIsOpenCLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_2: case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: return false; case SPV_ENV_OPENCL_1_2: case SPV_ENV_OPENCL_EMBEDDED_1_2: @@ -300,6 +383,7 @@ bool spvIsOpenGLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_2: case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: return false; case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: @@ -339,6 +423,7 @@ bool spvIsValidEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_2: case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: case SPV_ENV_OPENGL_4_2: @@ -375,7 +460,8 @@ std::string spvLogStringForEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1: case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_VULKAN_1_2: - case SPV_ENV_VULKAN_1_3: { + case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: { return "Vulkan"; } case SPV_ENV_UNIVERSAL_1_0: diff --git a/third_party/spirv-tools/source/spirv_target_env.h b/third_party/spirv-tools/source/spirv_target_env.h index f3b0c2f6f2..4378f06fa4 100644 --- a/third_party/spirv-tools/source/spirv_target_env.h +++ b/third_party/spirv-tools/source/spirv_target_env.h @@ -16,6 +16,8 @@ #define SOURCE_SPIRV_TARGET_ENV_H_ #include +#include +#include #include "spirv-tools/libspirv.h" @@ -46,4 +48,9 @@ std::string spvLogStringForEnv(spv_target_env env); // occur to satisfy this limit. std::string spvTargetEnvList(const int pad, const int wrap); +// Reads the target environment from the header comments of disassembly. Returns +// true if valid name found, false otherwise. +bool spvReadEnvironmentFromText(const std::vector& text, + spv_target_env* env); + #endif // SOURCE_SPIRV_TARGET_ENV_H_ diff --git a/third_party/spirv-tools/source/spirv_validator_options.cpp b/third_party/spirv-tools/source/spirv_validator_options.cpp index b72a64460d..fb09d5cf10 100644 --- a/third_party/spirv-tools/source/spirv_validator_options.cpp +++ b/third_party/spirv-tools/source/spirv_validator_options.cpp @@ -126,6 +126,11 @@ void spvValidatorOptionsSetAllowLocalSizeId(spv_validator_options options, options->allow_localsizeid = val; } +void spvValidatorOptionsSetAllowOffsetTextureOperand( + spv_validator_options options, bool val) { + options->allow_offset_texture_operand = val; +} + void spvValidatorOptionsSetFriendlyNames(spv_validator_options options, bool val) { options->use_friendly_names = val; diff --git a/third_party/spirv-tools/source/spirv_validator_options.h b/third_party/spirv-tools/source/spirv_validator_options.h index 01450480c9..b794981b2e 100644 --- a/third_party/spirv-tools/source/spirv_validator_options.h +++ b/third_party/spirv-tools/source/spirv_validator_options.h @@ -48,6 +48,7 @@ struct spv_validator_options_t { workgroup_scalar_block_layout(false), skip_block_layout(false), allow_localsizeid(false), + allow_offset_texture_operand(false), before_hlsl_legalization(false), use_friendly_names(true) {} @@ -60,6 +61,7 @@ struct spv_validator_options_t { bool workgroup_scalar_block_layout; bool skip_block_layout; bool allow_localsizeid; + bool allow_offset_texture_operand; bool before_hlsl_legalization; bool use_friendly_names; }; diff --git a/third_party/spirv-tools/source/table.cpp b/third_party/spirv-tools/source/table.cpp index 822cefebd7..01df1bc0d8 100644 --- a/third_party/spirv-tools/source/table.cpp +++ b/third_party/spirv-tools/source/table.cpp @@ -43,6 +43,7 @@ spv_context spvContextCreate(spv_target_env env) { case SPV_ENV_VULKAN_1_2: case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: break; default: return nullptr; diff --git a/third_party/spirv-tools/source/table.h b/third_party/spirv-tools/source/table.h index 8097f13f77..47625c5fbd 100644 --- a/third_party/spirv-tools/source/table.h +++ b/third_party/spirv-tools/source/table.h @@ -22,6 +22,8 @@ typedef struct spv_opcode_desc_t { const char* name; const spv::Op opcode; + const uint32_t numAliases; + const char** aliases; const uint32_t numCapabilities; const spv::Capability* capabilities; // operandTypes[0..numTypes-1] describe logical operands for the instruction. @@ -47,6 +49,8 @@ typedef struct spv_opcode_desc_t { typedef struct spv_operand_desc_t { const char* name; const uint32_t value; + const uint32_t numAliases; + const char** aliases; const uint32_t numCapabilities; const spv::Capability* capabilities; // A set of extensions that enable this feature. If empty then this operand @@ -74,7 +78,7 @@ typedef struct spv_ext_inst_desc_t { const uint32_t ext_inst; const uint32_t numCapabilities; const spv::Capability* capabilities; - const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? + const spv_operand_type_t operandTypes[40]; // vksp needs at least 40 } spv_ext_inst_desc_t; typedef struct spv_ext_inst_group_t { diff --git a/third_party/spirv-tools/source/text.cpp b/third_party/spirv-tools/source/text.cpp index 8f77d624ab..36518bef20 100644 --- a/third_party/spirv-tools/source/text.cpp +++ b/third_party/spirv-tools/source/text.cpp @@ -201,7 +201,7 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, } // Optional literal operands can fail to parse. In that case use - // SPV_FAILED_MATCH to avoid emitting a diagostic. Use the following + // SPV_FAILED_MATCH to avoid emitting a diagnostic. Use the following // for those situations. spv_result_t error_code_for_literals = spvOperandIsOptional(type) ? SPV_FAILED_MATCH : SPV_ERROR_INVALID_TEXT; @@ -227,8 +227,7 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, // Set the extended instruction type. // The import set id is the 3rd operand of OpExtInst. - if (spv::Op(pInst->opcode) == spv::Op::OpExtInst && - pInst->words.size() == 4) { + if (spvIsExtendedInstruction(pInst->opcode) && pInst->words.size() == 4) { auto ext_inst_type = context->getExtInstTypeForId(pInst->words[3]); if (ext_inst_type == SPV_EXT_INST_TYPE_NONE) { return context->diagnostic() @@ -312,6 +311,17 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, } } break; + case SPV_OPERAND_TYPE_LITERAL_FLOAT: { + // The current operand is a 32-bit float. + // That's just how the grammar works. + spvtools::IdType expected_type = { + 32, false, spvtools::IdTypeClass::kScalarFloatType}; + if (auto error = context->binaryEncodeNumericLiteral( + textValue, error_code_for_literals, expected_type, pInst)) { + return error; + } + } break; + case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER: // This is a context-independent literal number which can be a 32-bit // number of floating point value. @@ -400,9 +410,14 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, case SPV_OPERAND_TYPE_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: + case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS: case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: - case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: { + case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: + case SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS: + case SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS: + case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE: + case SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS: { uint32_t value; if (auto error = grammar.parseMaskOperand(type, textValue, &value)) { return context->diagnostic(error) @@ -544,7 +559,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, std::string equal_sign; error = context->getWord(&equal_sign, &nextPosition); if ("=" != equal_sign) - return context->diagnostic() << "'=' expected after result id."; + return context->diagnostic() << "'=' expected after result id but found '" + << equal_sign << "'."; // The after the '=' sign. context->setPosition(nextPosition); diff --git a/third_party/spirv-tools/source/text_handler.cpp b/third_party/spirv-tools/source/text_handler.cpp index 35c4b83c10..a778c2c143 100644 --- a/third_party/spirv-tools/source/text_handler.cpp +++ b/third_party/spirv-tools/source/text_handler.cpp @@ -329,8 +329,9 @@ spv_result_t AssemblyContext::recordTypeDefinition( types_[value] = {pInst->words[2], pInst->words[3] != 0, IdTypeClass::kScalarIntegerType}; } else if (pInst->opcode == spv::Op::OpTypeFloat) { - if (pInst->words.size() != 3) + if ((pInst->words.size() != 3) && (pInst->words.size() != 4)) return diagnostic() << "Invalid OpTypeFloat instruction"; + // TODO(kpet) Do we need to record the FP Encoding here? types_[value] = {pInst->words[2], false, IdTypeClass::kScalarFloatType}; } else { types_[value] = {0, false, IdTypeClass::kOtherType}; diff --git a/third_party/spirv-tools/source/to_string.cpp b/third_party/spirv-tools/source/to_string.cpp new file mode 100644 index 0000000000..b707070b3f --- /dev/null +++ b/third_party/spirv-tools/source/to_string.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2024 Google LLC +// +// 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 "source/to_string.h" + +#include + +namespace spvtools { + +std::string to_string(uint32_t n) { + // This implementation avoids using standard library features that access + // the locale. Using the locale requires taking a mutex which causes + // annoying serialization. + + constexpr int max_digits = 10; // max uint has 10 digits + // Contains the resulting digits, with least significant digit in the last + // entry. + char buf[max_digits]; + int write_index = max_digits - 1; + if (n == 0) { + buf[write_index] = '0'; + } else { + while (n > 0) { + int units = n % 10; + buf[write_index--] = "0123456789"[units]; + n = (n - units) / 10; + } + write_index++; + } + assert(write_index >= 0); + return std::string(buf + write_index, max_digits - write_index); +} +} // namespace spvtools diff --git a/third_party/spirv-tools/source/to_string.h b/third_party/spirv-tools/source/to_string.h new file mode 100644 index 0000000000..83702f92ad --- /dev/null +++ b/third_party/spirv-tools/source/to_string.h @@ -0,0 +1,29 @@ +// Copyright (c) 2024 Google LLC +// +// 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 SOURCE_TO_STRING_H_ +#define SOURCE_TO_STRING_H_ + +#include +#include + +namespace spvtools { + +// Returns the decimal representation of a number as a string, +// without using the locale. +std::string to_string(uint32_t n); + +} // namespace spvtools + +#endif // SOURCE_TO_STRING_H_ diff --git a/third_party/spirv-tools/source/util/bitutils.h b/third_party/spirv-tools/source/util/bitutils.h index 9ced2f9621..2763bc273b 100644 --- a/third_party/spirv-tools/source/util/bitutils.h +++ b/third_party/spirv-tools/source/util/bitutils.h @@ -97,7 +97,7 @@ template size_t CountSetBits(T word) { static_assert(std::is_integral::value, "CountSetBits requires integer type"); - size_t count = 0; + uint32_t count = 0; while (word) { word &= word - 1; ++count; @@ -181,6 +181,31 @@ T ClearHighBits(T word, size_t num_bits_to_set) { false); } +// Returns the value obtained by extracting the |number_of_bits| least +// significant bits from |value|, and sign-extending it to 64-bits. +template +T SignExtendValue(T value, uint32_t number_of_bits) { + const uint32_t bit_width = sizeof(value) * 8; + if (number_of_bits == bit_width) return value; + + bool is_negative = utils::IsBitAtPositionSet(value, number_of_bits - 1); + if (is_negative) { + value = utils::SetHighBits(value, bit_width - number_of_bits); + } else { + value = utils::ClearHighBits(value, bit_width - number_of_bits); + } + return value; +} + +// Returns the value obtained by extracting the |number_of_bits| least +// significant bits from |value|, and zero-extending it to 64-bits. +template +T ZeroExtendValue(T value, uint32_t number_of_bits) { + const uint32_t bit_width = sizeof(value) * 8; + if (number_of_bits == bit_width) return value; + return utils::ClearHighBits(value, bit_width - number_of_bits); +} + } // namespace utils } // namespace spvtools diff --git a/third_party/spirv-tools/source/util/hex_float.h b/third_party/spirv-tools/source/util/hex_float.h index 06e3c57572..98353a4ad2 100644 --- a/third_party/spirv-tools/source/util/hex_float.h +++ b/third_party/spirv-tools/source/util/hex_float.h @@ -896,6 +896,47 @@ ParseNormalFloat, HexFloatTraits>>( return is; } +namespace detail { + +// Returns a new value formed from 'value' by setting 'bit' that is the +// 'n'th most significant bit (where 0 is the most significant bit). +// If 'bit' is zero or 'n' is more than the number of bits in the integer +// type, then return the original value. +template +UINT_TYPE set_nth_most_significant_bit(UINT_TYPE value, UINT_TYPE bit, + UINT_TYPE n) { + constexpr UINT_TYPE max_position = std::numeric_limits::digits - 1; + if ((bit != 0) && (n <= max_position)) { + return static_cast(value | (bit << (max_position - n))); + } + return value; +} + +// Attempts to increment the argument. +// If it does not overflow, then increments the argument and returns true. +// If it would overflow, returns false. +template +bool saturated_inc(INT_TYPE& value) { + if (value == std::numeric_limits::max()) { + return false; + } + value++; + return true; +} + +// Attempts to decrement the argument. +// If it does not underflow, then decrements the argument and returns true. +// If it would overflow, returns false. +template +bool saturated_dec(INT_TYPE& value) { + if (value == std::numeric_limits::min()) { + return false; + } + value--; + return true; +} +} // namespace detail + // Reads a HexFloat from the given stream. // If the float is not encoded as a hex-float then it will be parsed // as a regular float. @@ -997,13 +1038,16 @@ std::istream& operator>>(std::istream& is, HexFloat& value) { if (bits_written) { // If we are here the bits represented belong in the fractional // part of the float, and we have to adjust the exponent accordingly. - fraction = static_cast( - fraction | - static_cast( - write_bit << (HF::top_bit_left_shift - fraction_index++))); - // TODO(dneto): Avoid overflow. Testing would require - // parameterization. - exponent = static_cast(exponent + 1); + fraction = detail::set_nth_most_significant_bit(fraction, write_bit, + fraction_index); + // Increment the fraction index. If the input has bizarrely many + // significant digits, then silently drop them. + detail::saturated_inc(fraction_index); + if (!detail::saturated_inc(exponent)) { + // Overflow failure + is.setstate(std::ios::failbit); + return is; + } } // Since this updated after setting fraction bits, this effectively // drops the leading 1 bit. @@ -1034,14 +1078,17 @@ std::istream& operator>>(std::istream& is, HexFloat& value) { // Handle modifying the exponent here this way we can handle // an arbitrary number of hex values without overflowing our // integer. - // TODO(dneto): Handle underflow. Testing would require extra - // parameterization. - exponent = static_cast(exponent - 1); + if (!detail::saturated_dec(exponent)) { + // Overflow failure + is.setstate(std::ios::failbit); + return is; + } } else { - fraction = static_cast( - fraction | - static_cast( - write_bit << (HF::top_bit_left_shift - fraction_index++))); + fraction = detail::set_nth_most_significant_bit(fraction, write_bit, + fraction_index); + // Increment the fraction index. If the input has bizarrely many + // significant digits, then silently drop them. + detail::saturated_inc(fraction_index); } } } else { diff --git a/third_party/spirv-tools/source/util/small_vector.h b/third_party/spirv-tools/source/util/small_vector.h index 648a34824f..1351475bd8 100644 --- a/third_party/spirv-tools/source/util/small_vector.h +++ b/third_party/spirv-tools/source/util/small_vector.h @@ -15,7 +15,9 @@ #ifndef SOURCE_UTIL_SMALL_VECTOR_H_ #define SOURCE_UTIL_SMALL_VECTOR_H_ +#include #include +#include #include #include #include @@ -461,14 +463,18 @@ class SmallVector { // The number of elements in |small_data_| that have been constructed. size_t size_; - // The pointed used to access the array of elements when the number of - // elements is small. - T* small_data_; + // A type with the same alignment and size as T, but will is POD. + struct alignas(T) PodType { + std::array data; + }; // The actual data used to store the array elements. It must never be used // directly, but must only be accessed through |small_data_|. - typename std::aligned_storage::value>::type - buffer[small_size]; + PodType buffer[small_size]; + + // The pointed used to access the array of elements when the number of + // elements is small. + T* small_data_; // A pointer to a vector that is used to store the elements of the vector when // this size exceeds |small_size|. If |large_data_| is nullptr, then the data diff --git a/third_party/spirv-tools/source/val/basic_block.cpp b/third_party/spirv-tools/source/val/basic_block.cpp index da05db3a81..9a358fcb97 100644 --- a/third_party/spirv-tools/source/val/basic_block.cpp +++ b/third_party/spirv-tools/source/val/basic_block.cpp @@ -15,7 +15,6 @@ #include "source/val/basic_block.h" #include -#include #include namespace spvtools { diff --git a/third_party/spirv-tools/source/val/construct.cpp b/third_party/spirv-tools/source/val/construct.cpp index 1ca81d4161..10af155da2 100644 --- a/third_party/spirv-tools/source/val/construct.cpp +++ b/third_party/spirv-tools/source/val/construct.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "source/val/function.h" #include "source/val/validation_state.h" diff --git a/third_party/spirv-tools/source/val/decoration.h b/third_party/spirv-tools/source/val/decoration.h index 384cc5755e..77e0f615e1 100644 --- a/third_party/spirv-tools/source/val/decoration.h +++ b/third_party/spirv-tools/source/val/decoration.h @@ -15,6 +15,7 @@ #ifndef SOURCE_VAL_DECORATION_H_ #define SOURCE_VAL_DECORATION_H_ +#include #include #include #include @@ -55,6 +56,12 @@ namespace val { // params_ = vector { 2 } // struct_member_index_ = 2 // +// Example 4: Decoration for a Builtin: +// OpDecorate %var BuiltIn FragDepth +// dec_type_ = spv::Decoration::BuiltIn +// params_ = vector { FragDepth } +// struct_member_index_ = kInvalidMember +// class Decoration { public: enum { kInvalidMember = -1 }; @@ -68,6 +75,10 @@ class Decoration { spv::Decoration dec_type() const { return dec_type_; } std::vector& params() { return params_; } const std::vector& params() const { return params_; } + spv::BuiltIn builtin() const { + assert(dec_type_ == spv::Decoration::BuiltIn); + return spv::BuiltIn(params_[0]); + } inline bool operator<(const Decoration& rhs) const { // Note: Sort by struct_member_index_ first, then type, so look up can be diff --git a/third_party/spirv-tools/source/val/function.cpp b/third_party/spirv-tools/source/val/function.cpp index 8b4423a1f9..290574b859 100644 --- a/third_party/spirv-tools/source/val/function.cpp +++ b/third_party/spirv-tools/source/val/function.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "source/cfa.h" diff --git a/third_party/spirv-tools/source/val/function.h b/third_party/spirv-tools/source/val/function.h index 481179442e..d3dd63966d 100644 --- a/third_party/spirv-tools/source/val/function.h +++ b/third_party/spirv-tools/source/val/function.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -278,7 +279,7 @@ class Function { Construct& FindConstructForEntryBlock(const BasicBlock* entry_block, ConstructType t); - /// The result id of the OpLabel that defined this block + /// The result id of OpFunction uint32_t id_; /// The type of the function diff --git a/third_party/spirv-tools/source/val/instruction.h b/third_party/spirv-tools/source/val/instruction.h index c524bd3750..59e8af13b1 100644 --- a/third_party/spirv-tools/source/val/instruction.h +++ b/third_party/spirv-tools/source/val/instruction.h @@ -22,6 +22,7 @@ #include #include "source/ext_inst.h" +#include "source/opcode.h" #include "source/table.h" #include "spirv-tools/libspirv.h" @@ -87,13 +88,13 @@ class Instruction { } bool IsNonSemantic() const { - return opcode() == spv::Op::OpExtInst && + return spvIsExtendedInstruction(opcode()) && spvExtInstIsNonSemantic(inst_.ext_inst_type); } /// True if this is an OpExtInst for debug info extension. bool IsDebugInfo() const { - return opcode() == spv::Op::OpExtInst && + return spvIsExtendedInstruction(opcode()) && spvExtInstIsDebugInfo(inst_.ext_inst_type); } diff --git a/third_party/spirv-tools/source/val/validate.cpp b/third_party/spirv-tools/source/val/validate.cpp index 52cb0d8bb8..2d10347d80 100644 --- a/third_party/spirv-tools/source/val/validate.cpp +++ b/third_party/spirv-tools/source/val/validate.cpp @@ -14,13 +14,9 @@ #include "source/val/validate.h" -#include -#include -#include #include #include #include -#include #include #include @@ -28,15 +24,11 @@ #include "source/diagnostic.h" #include "source/enum_string_mapping.h" #include "source/extensions.h" -#include "source/instruction.h" #include "source/opcode.h" -#include "source/operand.h" #include "source/spirv_constant.h" #include "source/spirv_endian.h" #include "source/spirv_target_env.h" -#include "source/spirv_validator_options.h" #include "source/val/construct.h" -#include "source/val/function.h" #include "source/val/instruction.h" #include "source/val/validation_state.h" #include "spirv-tools/libspirv.h" @@ -149,6 +141,13 @@ spv_result_t ValidateEntryPoints(ValidationState_t& _) { } } + if (auto error = ValidateFloatControls2(_)) { + return error; + } + if (auto error = ValidateDuplicateExecutionModes(_)) { + return error; + } + return SPV_SUCCESS; } @@ -367,6 +366,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( if (auto error = RayTracingPass(*vstate, &instruction)) return error; if (auto error = RayReorderNVPass(*vstate, &instruction)) return error; if (auto error = MeshShadingPass(*vstate, &instruction)) return error; + if (auto error = TensorLayoutPass(*vstate, &instruction)) return error; } // Validate the preconditions involving adjacent instructions. e.g. @@ -389,6 +389,8 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( for (const auto& inst : vstate->ordered_instructions()) { if (auto error = ValidateExecutionLimitations(*vstate, &inst)) return error; if (auto error = ValidateSmallTypeUses(*vstate, &inst)) return error; + if (auto error = ValidateQCOMImageProcessingTextureUsages(*vstate, &inst)) + return error; } return SPV_SUCCESS; diff --git a/third_party/spirv-tools/source/val/validate.h b/third_party/spirv-tools/source/val/validate.h index 898743859e..5514ff738e 100644 --- a/third_party/spirv-tools/source/val/validate.h +++ b/third_party/spirv-tools/source/val/validate.h @@ -31,11 +31,6 @@ class ValidationState_t; class BasicBlock; class Instruction; -/// A function that returns a vector of BasicBlocks given a BasicBlock. Used to -/// get the successor and predecessor nodes of a CFG block -using get_blocks_func = - std::function*(const BasicBlock*)>; - /// @brief Performs the Control Flow Graph checks /// /// @param[in] _ the validation state of the module @@ -87,6 +82,25 @@ spv_result_t ValidateAdjacency(ValidationState_t& _); /// @return SPV_SUCCESS if no errors are found. spv_result_t ValidateInterfaces(ValidationState_t& _); +/// @brief Validates entry point call tree requirements of +/// SPV_KHR_float_controls2 +/// +/// Checks that no entry point using FPFastMathDefault uses: +/// * FPFastMathMode Fast +/// * NoContraction +/// +/// @param[in] _ the validation state of the module +/// +/// @return SPV_SUCCESS if no errors are found. +spv_result_t ValidateFloatControls2(ValidationState_t& _); + +/// @brief Validates duplicated execution modes for each entry point. +/// +/// @param[in] _ the validation state of the module +/// +/// @return SPV_SUCCESS if no errors are found. +spv_result_t ValidateDuplicateExecutionModes(ValidationState_t& _); + /// @brief Validates memory instructions /// /// @param[in] _ the validation state of the module @@ -212,6 +226,9 @@ spv_result_t MeshShadingPass(ValidationState_t& _, const Instruction* inst); /// Calculates the reachability of basic blocks. void ReachabilityPass(ValidationState_t& _); +/// Validates tensor layout and view instructions. +spv_result_t TensorLayoutPass(ValidationState_t& _, const Instruction* inst); + /// Validates execution limitations. /// /// Verifies execution models are allowed for all functionality they contain. @@ -225,6 +242,14 @@ spv_result_t ValidateExecutionLimitations(ValidationState_t& _, spv_result_t ValidateSmallTypeUses(ValidationState_t& _, const Instruction* inst); +/// Validates restricted uses of QCOM decorated textures +/// +/// The textures that are decorated with some of QCOM image processing +/// decorations must be used in the specified QCOM image processing built-in +/// functions and not used in any other image functions. +spv_result_t ValidateQCOMImageProcessingTextureUsages(ValidationState_t& _, + const Instruction* inst); + /// @brief Validate the ID's within a SPIR-V binary /// /// @param[in] pInstructions array of instructions diff --git a/third_party/spirv-tools/source/val/validate_adjacency.cpp b/third_party/spirv-tools/source/val/validate_adjacency.cpp index 50c2e92aec..52519bfa9f 100644 --- a/third_party/spirv-tools/source/val/validate_adjacency.cpp +++ b/third_party/spirv-tools/source/val/validate_adjacency.cpp @@ -15,13 +15,10 @@ // Validates correctness of the intra-block preconditions of SPIR-V // instructions. -#include "source/val/validate.h" - #include -#include "source/diagnostic.h" -#include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { @@ -55,6 +52,7 @@ spv_result_t ValidateAdjacency(ValidationState_t& _) { adjacency_status == IN_NEW_FUNCTION ? IN_ENTRY_BLOCK : PHI_VALID; break; case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: // If it is a debug info instruction, we do not change the status to // allow debug info instructions before OpVariable in a function. // TODO(https://gitlab.khronos.org/spirv/SPIR-V/issues/533): We need @@ -119,6 +117,15 @@ spv_result_t ValidateAdjacency(ValidationState_t& _) { "first instructions in the first block."; } break; + case spv::Op::OpUntypedVariableKHR: + if (inst.GetOperandAs(2) == + spv::StorageClass::Function && + adjacency_status != IN_ENTRY_BLOCK) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << "All OpUntypedVariableKHR instructions in a function must " + "be the first instructions in the first block."; + } + break; default: adjacency_status = PHI_AND_VAR_INVALID; break; diff --git a/third_party/spirv-tools/source/val/validate_annotation.cpp b/third_party/spirv-tools/source/val/validate_annotation.cpp index bef753d9c8..031229241c 100644 --- a/third_party/spirv-tools/source/val/validate_annotation.cpp +++ b/third_party/spirv-tools/source/val/validate_annotation.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2018 Google LLC. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,6 +32,11 @@ bool DecorationTakesIdParameters(spv::Decoration type) { case spv::Decoration::AlignmentId: case spv::Decoration::MaxByteOffsetId: case spv::Decoration::HlslCounterBufferGOOGLE: + case spv::Decoration::NodeMaxPayloadsAMDX: + case spv::Decoration::NodeSharesPayloadLimitsWithAMDX: + case spv::Decoration::PayloadNodeArraySizeAMDX: + case spv::Decoration::PayloadNodeNameAMDX: + case spv::Decoration::PayloadNodeBaseIndexAMDX: return true; default: break; @@ -123,12 +130,14 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, case spv::Decoration::ArrayStride: if (target->opcode() != spv::Op::OpTypeArray && target->opcode() != spv::Op::OpTypeRuntimeArray && - target->opcode() != spv::Op::OpTypePointer) { + target->opcode() != spv::Op::OpTypePointer && + target->opcode() != spv::Op::OpTypeUntypedPointerKHR) { return fail(0) << "must be an array or pointer type"; } break; case spv::Decoration::BuiltIn: if (target->opcode() != spv::Op::OpVariable && + target->opcode() != spv::Op::OpUntypedVariableKHR && !spvOpcodeIsConstant(target->opcode())) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "BuiltIns can only target variables, structure members or " @@ -139,7 +148,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, if (!spvOpcodeIsConstant(target->opcode())) { return fail(0) << "must be a constant for WorkgroupSize"; } - } else if (target->opcode() != spv::Op::OpVariable) { + } else if (target->opcode() != spv::Op::OpVariable && + target->opcode() != spv::Op::OpUntypedVariableKHR) { return fail(0) << "must be a variable"; } break; @@ -160,11 +170,14 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, case spv::Decoration::Stream: case spv::Decoration::RestrictPointer: case spv::Decoration::AliasedPointer: + case spv::Decoration::PerPrimitiveEXT: if (target->opcode() != spv::Op::OpVariable && - target->opcode() != spv::Op::OpFunctionParameter) { + target->opcode() != spv::Op::OpUntypedVariableKHR && + target->opcode() != spv::Op::OpFunctionParameter && + target->opcode() != spv::Op::OpRawAccessChainNV) { return fail(0) << "must be a memory object declaration"; } - if (_.GetIdOpcode(target->type_id()) != spv::Op::OpTypePointer) { + if (!_.IsPointerType(target->type_id())) { return fail(0) << "must be a pointer type"; } break; @@ -175,7 +188,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, case spv::Decoration::Binding: case spv::Decoration::DescriptorSet: case spv::Decoration::InputAttachmentIndex: - if (target->opcode() != spv::Op::OpVariable) { + if (target->opcode() != spv::Op::OpVariable && + target->opcode() != spv::Op::OpUntypedVariableKHR) { return fail(0) << "must be a variable"; } break; @@ -193,7 +207,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, switch (dec) { case spv::Decoration::Location: case spv::Decoration::Component: - // Location is used for input, output and ray tracing stages. + // Location is used for input, output, tile image, and ray tracing + // stages. if (sc != spv::StorageClass::Input && sc != spv::StorageClass::Output && sc != spv::StorageClass::RayPayloadKHR && sc != spv::StorageClass::IncomingRayPayloadKHR && @@ -201,7 +216,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec, sc != spv::StorageClass::CallableDataKHR && sc != spv::StorageClass::IncomingCallableDataKHR && sc != spv::StorageClass::ShaderRecordBufferKHR && - sc != spv::StorageClass::HitObjectAttributeNV) { + sc != spv::StorageClass::HitObjectAttributeNV && + sc != spv::StorageClass::TileImageEXT) { return _.diag(SPV_ERROR_INVALID_ID, target) << _.VkErrorID(6672) << _.SpvDecorationString(dec) << " decoration must not be applied to this storage class"; @@ -265,6 +281,34 @@ spv_result_t ValidateDecorate(ValidationState_t& _, const Instruction* inst) { } } + if (decoration == spv::Decoration::FPFastMathMode) { + if (_.HasDecoration(target_id, spv::Decoration::NoContraction)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "FPFastMathMode and NoContraction cannot decorate the same " + "target"; + } + auto mask = inst->GetOperandAs(2); + if ((mask & spv::FPFastMathModeMask::AllowTransform) != + spv::FPFastMathModeMask::MaskNone && + ((mask & (spv::FPFastMathModeMask::AllowContract | + spv::FPFastMathModeMask::AllowReassoc)) != + (spv::FPFastMathModeMask::AllowContract | + spv::FPFastMathModeMask::AllowReassoc))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "AllowReassoc and AllowContract must be specified when " + "AllowTransform is specified"; + } + } + + // This is checked from both sides since we register decorations as we go. + if (decoration == spv::Decoration::NoContraction) { + if (_.HasDecoration(target_id, spv::Decoration::FPFastMathMode)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "FPFastMathMode and NoContraction cannot decorate the same " + "target"; + } + } + if (DecorationTakesIdParameters(decoration)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Decorations taking ID parameters may not be used with " diff --git a/third_party/spirv-tools/source/val/validate_arithmetics.cpp b/third_party/spirv-tools/source/val/validate_arithmetics.cpp index a082eebc9f..d252ec92b4 100644 --- a/third_party/spirv-tools/source/val/validate_arithmetics.cpp +++ b/third_party/spirv-tools/source/val/validate_arithmetics.cpp @@ -14,13 +14,11 @@ // Performs validation of arithmetic instructions. -#include "source/val/validate.h" - #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { @@ -42,16 +40,46 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { bool supportsCoopMat = (opcode != spv::Op::OpFMul && opcode != spv::Op::OpFRem && opcode != spv::Op::OpFMod); + bool supportsCoopVec = + (opcode != spv::Op::OpFRem && opcode != spv::Op::OpFMod); if (!_.IsFloatScalarType(result_type) && !_.IsFloatVectorType(result_type) && - !(supportsCoopMat && _.IsFloatCooperativeMatrixType(result_type))) + !(supportsCoopMat && _.IsFloatCooperativeMatrixType(result_type)) && + !(opcode == spv::Op::OpFMul && + _.IsCooperativeMatrixKHRType(result_type) && + _.IsFloatCooperativeMatrixType(result_type)) && + !(supportsCoopVec && _.IsFloatCooperativeVectorNVType(result_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected floating scalar or vector type as Result Type: " << spvOpcodeString(opcode); for (size_t operand_index = 2; operand_index < inst->operands().size(); ++operand_index) { - if (_.GetOperandTypeId(inst, operand_index) != result_type) + if (supportsCoopVec && _.IsCooperativeVectorNVType(result_type)) { + const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); + if (!_.IsCooperativeVectorNVType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeVectorDimensionsMatch(inst, type_id, result_type); + if (ret != SPV_SUCCESS) return ret; + } else if (supportsCoopMat && + _.IsCooperativeMatrixKHRType(result_type)) { + const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); + if (!_.IsCooperativeMatrixKHRType(type_id) || + !_.IsFloatCooperativeMatrixType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, type_id, false); + if (ret != SPV_SUCCESS) return ret; + } else if (_.GetOperandTypeId(inst, operand_index) != result_type) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected arithmetic operands to be of Result Type: " << spvOpcodeString(opcode) << " operand index " @@ -63,17 +91,44 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpUDiv: case spv::Op::OpUMod: { bool supportsCoopMat = (opcode == spv::Op::OpUDiv); + bool supportsCoopVec = (opcode == spv::Op::OpUDiv); if (!_.IsUnsignedIntScalarType(result_type) && !_.IsUnsignedIntVectorType(result_type) && !(supportsCoopMat && - _.IsUnsignedIntCooperativeMatrixType(result_type))) + _.IsUnsignedIntCooperativeMatrixType(result_type)) && + !(supportsCoopVec && + _.IsUnsignedIntCooperativeVectorNVType(result_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected unsigned int scalar or vector type as Result Type: " << spvOpcodeString(opcode); for (size_t operand_index = 2; operand_index < inst->operands().size(); ++operand_index) { - if (_.GetOperandTypeId(inst, operand_index) != result_type) + if (supportsCoopVec && _.IsCooperativeVectorNVType(result_type)) { + const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); + if (!_.IsCooperativeVectorNVType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeVectorDimensionsMatch(inst, type_id, result_type); + if (ret != SPV_SUCCESS) return ret; + } else if (supportsCoopMat && + _.IsCooperativeMatrixKHRType(result_type)) { + const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); + if (!_.IsCooperativeMatrixKHRType(type_id) || + !_.IsUnsignedIntCooperativeMatrixType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, type_id, false); + if (ret != SPV_SUCCESS) return ret; + } else if (_.GetOperandTypeId(inst, operand_index) != result_type) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected arithmetic operands to be of Result Type: " << spvOpcodeString(opcode) << " operand index " @@ -92,8 +147,14 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { bool supportsCoopMat = (opcode != spv::Op::OpIMul && opcode != spv::Op::OpSRem && opcode != spv::Op::OpSMod); + bool supportsCoopVec = + (opcode != spv::Op::OpSRem && opcode != spv::Op::OpSMod); if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && - !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type))) + !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type)) && + !(opcode == spv::Op::OpIMul && + _.IsCooperativeMatrixKHRType(result_type) && + _.IsIntCooperativeMatrixType(result_type)) && + !(supportsCoopVec && _.IsIntCooperativeVectorNVType(result_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -104,9 +165,39 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { for (size_t operand_index = 2; operand_index < inst->operands().size(); ++operand_index) { const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); + + if (supportsCoopVec && _.IsCooperativeVectorNVType(result_type)) { + if (!_.IsCooperativeVectorNVType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeVectorDimensionsMatch(inst, type_id, result_type); + if (ret != SPV_SUCCESS) return ret; + } + + if (supportsCoopMat && _.IsCooperativeMatrixKHRType(result_type)) { + if (!_.IsCooperativeMatrixKHRType(type_id) || + !_.IsIntCooperativeMatrixType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected arithmetic operands to be of Result Type: " + << spvOpcodeString(opcode) << " operand index " + << operand_index; + } + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, type_id, false); + if (ret != SPV_SUCCESS) return ret; + } + if (!type_id || (!_.IsIntScalarType(type_id) && !_.IsIntVectorType(type_id) && - !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type)))) + !(supportsCoopMat && _.IsIntCooperativeMatrixType(result_type)) && + !(opcode == spv::Op::OpIMul && + _.IsCooperativeMatrixKHRType(result_type) && + _.IsIntCooperativeMatrixType(result_type)) && + !(supportsCoopVec && _.IsIntCooperativeVectorNVType(result_type)))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as operand: " << spvOpcodeString(opcode) << " operand index " @@ -165,7 +256,8 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { } case spv::Op::OpVectorTimesScalar: { - if (!_.IsFloatVectorType(result_type)) + if (!_.IsFloatVectorType(result_type) && + !_.IsFloatCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected float vector type as Result Type: " << spvOpcodeString(opcode); @@ -189,7 +281,7 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpMatrixTimesScalar: { if (!_.IsFloatMatrixType(result_type) && - !_.IsCooperativeMatrixType(result_type)) + !(_.IsCooperativeMatrixType(result_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected float matrix type as Result Type: " << spvOpcodeString(opcode); @@ -461,22 +553,22 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { const uint32_t B_type_id = _.GetOperandTypeId(inst, 3); const uint32_t C_type_id = _.GetOperandTypeId(inst, 4); - if (!_.IsCooperativeMatrixType(A_type_id)) { + if (!_.IsCooperativeMatrixNVType(A_type_id)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected cooperative matrix type as A Type: " << spvOpcodeString(opcode); } - if (!_.IsCooperativeMatrixType(B_type_id)) { + if (!_.IsCooperativeMatrixNVType(B_type_id)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected cooperative matrix type as B Type: " << spvOpcodeString(opcode); } - if (!_.IsCooperativeMatrixType(C_type_id)) { + if (!_.IsCooperativeMatrixNVType(C_type_id)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected cooperative matrix type as C Type: " << spvOpcodeString(opcode); } - if (!_.IsCooperativeMatrixType(D_type_id)) { + if (!_.IsCooperativeMatrixNVType(D_type_id)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected cooperative matrix type as Result Type: " << spvOpcodeString(opcode); @@ -541,6 +633,214 @@ spv_result_t ArithmeticsPass(ValidationState_t& _, const Instruction* inst) { break; } + case spv::Op::OpCooperativeMatrixMulAddKHR: { + const uint32_t D_type_id = _.GetOperandTypeId(inst, 1); + const uint32_t A_type_id = _.GetOperandTypeId(inst, 2); + const uint32_t B_type_id = _.GetOperandTypeId(inst, 3); + const uint32_t C_type_id = _.GetOperandTypeId(inst, 4); + + if (!_.IsCooperativeMatrixAType(A_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix type must be A Type: " + << spvOpcodeString(opcode); + } + if (!_.IsCooperativeMatrixBType(B_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix type must be B Type: " + << spvOpcodeString(opcode); + } + if (!_.IsCooperativeMatrixAccType(C_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix type must be Accumulator Type: " + << spvOpcodeString(opcode); + } + if (!_.IsCooperativeMatrixKHRType(D_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected cooperative matrix type as Result Type: " + << spvOpcodeString(opcode); + } + + const auto A = _.FindDef(A_type_id); + const auto B = _.FindDef(B_type_id); + const auto C = _.FindDef(C_type_id); + const auto D = _.FindDef(D_type_id); + + std::tuple A_scope, B_scope, C_scope, D_scope, + A_rows, B_rows, C_rows, D_rows, A_cols, B_cols, C_cols, D_cols; + + A_scope = _.EvalInt32IfConst(A->GetOperandAs(2)); + B_scope = _.EvalInt32IfConst(B->GetOperandAs(2)); + C_scope = _.EvalInt32IfConst(C->GetOperandAs(2)); + D_scope = _.EvalInt32IfConst(D->GetOperandAs(2)); + + A_rows = _.EvalInt32IfConst(A->GetOperandAs(3)); + B_rows = _.EvalInt32IfConst(B->GetOperandAs(3)); + C_rows = _.EvalInt32IfConst(C->GetOperandAs(3)); + D_rows = _.EvalInt32IfConst(D->GetOperandAs(3)); + + A_cols = _.EvalInt32IfConst(A->GetOperandAs(4)); + B_cols = _.EvalInt32IfConst(B->GetOperandAs(4)); + C_cols = _.EvalInt32IfConst(C->GetOperandAs(4)); + D_cols = _.EvalInt32IfConst(D->GetOperandAs(4)); + + const auto notEqual = [](std::tuple X, + std::tuple Y) { + return (std::get<1>(X) && std::get<1>(Y) && + std::get<2>(X) != std::get<2>(Y)); + }; + + if (notEqual(A_scope, B_scope) || notEqual(A_scope, C_scope) || + notEqual(A_scope, D_scope) || notEqual(B_scope, C_scope) || + notEqual(B_scope, D_scope) || notEqual(C_scope, D_scope)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix scopes must match: " + << spvOpcodeString(opcode); + } + + if (notEqual(A_rows, C_rows) || notEqual(A_rows, D_rows) || + notEqual(C_rows, D_rows)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix 'M' mismatch: " + << spvOpcodeString(opcode); + } + + if (notEqual(B_cols, C_cols) || notEqual(B_cols, D_cols) || + notEqual(C_cols, D_cols)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix 'N' mismatch: " + << spvOpcodeString(opcode); + } + + if (notEqual(A_cols, B_rows)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix 'K' mismatch: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpCooperativeMatrixReduceNV: { + if (!_.IsCooperativeMatrixKHRType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type must be a cooperative matrix type: " + << spvOpcodeString(opcode); + } + + const auto result_comp_type_id = + _.FindDef(result_type)->GetOperandAs(1); + + const auto matrix_id = inst->GetOperandAs(2); + const auto matrix = _.FindDef(matrix_id); + const auto matrix_type_id = matrix->type_id(); + if (!_.IsCooperativeMatrixKHRType(matrix_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Matrix must have a cooperative matrix type: " + << spvOpcodeString(opcode); + } + const auto matrix_type = _.FindDef(matrix_type_id); + const auto matrix_comp_type_id = matrix_type->GetOperandAs(1); + if (matrix_comp_type_id != result_comp_type_id) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type and Matrix type must have the same component " + "type: " + << spvOpcodeString(opcode); + } + if (_.FindDef(result_type)->GetOperandAs(2) != + matrix_type->GetOperandAs(2)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type and Matrix type must have the same scope: " + << spvOpcodeString(opcode); + } + + if (!_.IsCooperativeMatrixAccType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type must have UseAccumulator: " + << spvOpcodeString(opcode); + } + if (!_.IsCooperativeMatrixAccType(matrix_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Matrix type must have UseAccumulator: " + << spvOpcodeString(opcode); + } + + const auto reduce_value = inst->GetOperandAs(3); + + if ((reduce_value & + uint32_t( + spv::CooperativeMatrixReduceMask::CooperativeMatrixReduce2x2)) && + (reduce_value & uint32_t(spv::CooperativeMatrixReduceMask::Row | + spv::CooperativeMatrixReduceMask::Column))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Reduce 2x2 must not be used with Row/Column: " + << spvOpcodeString(opcode); + } + + std::tuple result_rows, result_cols, matrix_rows, + matrix_cols; + result_rows = + _.EvalInt32IfConst(_.FindDef(result_type)->GetOperandAs(3)); + result_cols = + _.EvalInt32IfConst(_.FindDef(result_type)->GetOperandAs(4)); + matrix_rows = _.EvalInt32IfConst(matrix_type->GetOperandAs(3)); + matrix_cols = _.EvalInt32IfConst(matrix_type->GetOperandAs(4)); + + if (reduce_value & + uint32_t( + spv::CooperativeMatrixReduceMask::CooperativeMatrixReduce2x2)) { + if (std::get<1>(result_rows) && std::get<1>(result_cols) && + std::get<1>(matrix_rows) && std::get<1>(matrix_cols) && + (std::get<2>(result_rows) != std::get<2>(matrix_rows) / 2 || + std::get<2>(result_cols) != std::get<2>(matrix_cols) / 2)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "For Reduce2x2, result rows/cols must be half of matrix " + "rows/cols: " + << spvOpcodeString(opcode); + } + } + if (reduce_value == uint32_t(spv::CooperativeMatrixReduceMask::Row)) { + if (std::get<1>(result_rows) && std::get<1>(matrix_rows) && + std::get<2>(result_rows) != std::get<2>(matrix_rows)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "For ReduceRow, result rows must match matrix rows: " + << spvOpcodeString(opcode); + } + } + if (reduce_value == uint32_t(spv::CooperativeMatrixReduceMask::Column)) { + if (std::get<1>(result_cols) && std::get<1>(matrix_cols) && + std::get<2>(result_cols) != std::get<2>(matrix_cols)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "For ReduceColumn, result cols must match matrix cols: " + << spvOpcodeString(opcode); + } + } + + const auto combine_func_id = inst->GetOperandAs(4); + const auto combine_func = _.FindDef(combine_func_id); + if (!combine_func || combine_func->opcode() != spv::Op::OpFunction) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "CombineFunc must be a function: " << spvOpcodeString(opcode); + } + const auto function_type_id = combine_func->GetOperandAs(3); + const auto function_type = _.FindDef(function_type_id); + if (function_type->operands().size() != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "CombineFunc must have two parameters: " + << spvOpcodeString(opcode); + } + for (uint32_t i = 0; i < 3; ++i) { + // checks return type and two params + const auto param_type_id = function_type->GetOperandAs(i + 1); + if (param_type_id != matrix_comp_type_id) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "CombineFunc return type and parameters must match matrix " + "component type: " + << spvOpcodeString(opcode); + } + } + + break; + } + default: break; } diff --git a/third_party/spirv-tools/source/val/validate_atomics.cpp b/third_party/spirv-tools/source/val/validate_atomics.cpp index d6b094c4aa..990ed31518 100644 --- a/third_party/spirv-tools/source/val/validate_atomics.cpp +++ b/third_party/spirv-tools/source/val/validate_atomics.cpp @@ -16,13 +16,11 @@ // Validates correctness of atomic SPIR-V instructions. -#include "source/val/validate.h" - -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_target_env.h" #include "source/util/bitutils.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validate_memory_semantics.h" #include "source/val/validate_scopes.h" #include "source/val/validation_state.h" @@ -146,12 +144,13 @@ spv_result_t AtomicsPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpAtomicFlagClear: { const uint32_t result_type = inst->type_id(); - // All current atomics only are scalar result // Validate return type first so can just check if pointer type is same // (if applicable) if (HasReturnType(opcode)) { if (HasOnlyFloatReturnType(opcode) && - !_.IsFloatScalarType(result_type)) { + (!(_.HasCapability(spv::Capability::AtomicFloat16VectorNV) && + _.IsFloat16Vector2Or4Type(result_type)) && + !_.IsFloatScalarType(result_type))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << spvOpcodeString(opcode) << ": expected Result Type to be float scalar type"; @@ -162,6 +161,9 @@ spv_result_t AtomicsPass(ValidationState_t& _, const Instruction* inst) { << ": expected Result Type to be integer scalar type"; } else if (HasIntOrFloatReturnType(opcode) && !_.IsFloatScalarType(result_type) && + !(opcode == spv::Op::OpAtomicExchange && + _.HasCapability(spv::Capability::AtomicFloat16VectorNV) && + _.IsFloat16Vector2Or4Type(result_type)) && !_.IsIntScalarType(result_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << spvOpcodeString(opcode) @@ -181,7 +183,44 @@ spv_result_t AtomicsPass(ValidationState_t& _, const Instruction* inst) { if (!_.GetPointerTypeInfo(pointer_type, &data_type, &storage_class)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << spvOpcodeString(opcode) - << ": expected Pointer to be of type OpTypePointer"; + << ": expected Pointer to be a pointer type"; + } + + // If the pointer is an untyped pointer, get the data type elsewhere. + if (data_type == 0) { + switch (opcode) { + case spv::Op::OpAtomicLoad: + case spv::Op::OpAtomicExchange: + case spv::Op::OpAtomicFAddEXT: + case spv::Op::OpAtomicCompareExchange: + case spv::Op::OpAtomicCompareExchangeWeak: + case spv::Op::OpAtomicIIncrement: + case spv::Op::OpAtomicIDecrement: + case spv::Op::OpAtomicIAdd: + case spv::Op::OpAtomicISub: + case spv::Op::OpAtomicSMin: + case spv::Op::OpAtomicUMin: + case spv::Op::OpAtomicFMinEXT: + case spv::Op::OpAtomicSMax: + case spv::Op::OpAtomicUMax: + case spv::Op::OpAtomicFMaxEXT: + case spv::Op::OpAtomicAnd: + case spv::Op::OpAtomicOr: + case spv::Op::OpAtomicXor: + data_type = inst->type_id(); + break; + case spv::Op::OpAtomicFlagTestAndSet: + case spv::Op::OpAtomicFlagClear: + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Untyped pointers are not supported by atomic flag " + "instructions"; + break; + case spv::Op::OpAtomicStore: + data_type = _.FindDef(inst->GetOperandAs(3))->type_id(); + break; + default: + break; + } } // Can't use result_type because OpAtomicStore doesn't have a result @@ -224,12 +263,21 @@ spv_result_t AtomicsPass(ValidationState_t& _, const Instruction* inst) { if (opcode == spv::Op::OpAtomicFAddEXT) { // result type being float checked already - if ((_.GetBitWidth(result_type) == 16) && - (!_.HasCapability(spv::Capability::AtomicFloat16AddEXT))) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << spvOpcodeString(opcode) - << ": float add atomics require the AtomicFloat32AddEXT " - "capability"; + if (_.GetBitWidth(result_type) == 16) { + if (_.IsFloat16Vector2Or4Type(result_type)) { + if (!_.HasCapability(spv::Capability::AtomicFloat16VectorNV)) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << spvOpcodeString(opcode) + << ": float vector atomics require the " + "AtomicFloat16VectorNV capability"; + } else { + if (!_.HasCapability(spv::Capability::AtomicFloat16AddEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << spvOpcodeString(opcode) + << ": float add atomics require the AtomicFloat32AddEXT " + "capability"; + } + } } if ((_.GetBitWidth(result_type) == 32) && (!_.HasCapability(spv::Capability::AtomicFloat32AddEXT))) { @@ -247,12 +295,21 @@ spv_result_t AtomicsPass(ValidationState_t& _, const Instruction* inst) { } } else if (opcode == spv::Op::OpAtomicFMinEXT || opcode == spv::Op::OpAtomicFMaxEXT) { - if ((_.GetBitWidth(result_type) == 16) && - (!_.HasCapability(spv::Capability::AtomicFloat16MinMaxEXT))) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << spvOpcodeString(opcode) - << ": float min/max atomics require the " - "AtomicFloat16MinMaxEXT capability"; + if (_.GetBitWidth(result_type) == 16) { + if (_.IsFloat16Vector2Or4Type(result_type)) { + if (!_.HasCapability(spv::Capability::AtomicFloat16VectorNV)) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << spvOpcodeString(opcode) + << ": float vector atomics require the " + "AtomicFloat16VectorNV capability"; + } else { + if (!_.HasCapability(spv::Capability::AtomicFloat16MinMaxEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << spvOpcodeString(opcode) + << ": float min/max atomics require the " + "AtomicFloat16MinMaxEXT capability"; + } + } } if ((_.GetBitWidth(result_type) == 32) && (!_.HasCapability(spv::Capability::AtomicFloat32MinMaxEXT))) { diff --git a/third_party/spirv-tools/source/val/validate_barriers.cpp b/third_party/spirv-tools/source/val/validate_barriers.cpp index 59d886a117..0abd5c8599 100644 --- a/third_party/spirv-tools/source/val/validate_barriers.cpp +++ b/third_party/spirv-tools/source/val/validate_barriers.cpp @@ -16,11 +16,8 @@ #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" -#include "source/spirv_target_env.h" -#include "source/util/bitutils.h" #include "source/val/instruction.h" #include "source/val/validate.h" #include "source/val/validate_memory_semantics.h" diff --git a/third_party/spirv-tools/source/val/validate_bitwise.cpp b/third_party/spirv-tools/source/val/validate_bitwise.cpp index 87c955630f..bb0588a09f 100644 --- a/third_party/spirv-tools/source/val/validate_bitwise.cpp +++ b/third_party/spirv-tools/source/val/validate_bitwise.cpp @@ -14,7 +14,6 @@ // Validates correctness of bitwise instructions. -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_target_env.h" #include "source/val/instruction.h" @@ -65,7 +64,8 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpShiftRightLogical: case spv::Op::OpShiftRightArithmetic: case spv::Op::OpShiftLeftLogical: { - if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type)) + if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && + !_.IsIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -75,7 +75,8 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { const uint32_t shift_type = _.GetOperandTypeId(inst, 3); if (!base_type || - (!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type))) + (!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type) && + !_.IsIntCooperativeVectorNVType(base_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Base to be int scalar or vector: " << spvOpcodeString(opcode); @@ -91,7 +92,8 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { << "as Result Type: " << spvOpcodeString(opcode); if (!shift_type || - (!_.IsIntScalarType(shift_type) && !_.IsIntVectorType(shift_type))) + (!_.IsIntScalarType(shift_type) && !_.IsIntVectorType(shift_type) && + !_.IsIntCooperativeVectorNVType(shift_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Shift to be int scalar or vector: " << spvOpcodeString(opcode); @@ -107,7 +109,8 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpBitwiseXor: case spv::Op::OpBitwiseAnd: case spv::Op::OpNot: { - if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type)) + if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && + !_.IsIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -119,7 +122,8 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { ++operand_index) { const uint32_t type_id = _.GetOperandTypeId(inst, operand_index); if (!type_id || - (!_.IsIntScalarType(type_id) && !_.IsIntVectorType(type_id))) + (!_.IsIntScalarType(type_id) && !_.IsIntVectorType(type_id) && + !_.IsIntCooperativeVectorNVType(type_id))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector as operand: " << spvOpcodeString(opcode) << " operand index " @@ -206,13 +210,14 @@ spv_result_t BitwisePass(ValidationState_t& _, const Instruction* inst) { << spvOpcodeString(opcode); const uint32_t base_type = _.GetOperandTypeId(inst, 2); - const uint32_t base_dimension = _.GetDimension(base_type); - const uint32_t result_dimension = _.GetDimension(result_type); if (spv_result_t error = ValidateBaseType(_, inst, base_type)) { return error; } + const uint32_t base_dimension = _.GetDimension(base_type); + const uint32_t result_dimension = _.GetDimension(result_type); + if (base_dimension != result_dimension) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Base dimension to be equal to Result Type " diff --git a/third_party/spirv-tools/source/val/validate_builtins.cpp b/third_party/spirv-tools/source/val/validate_builtins.cpp index c07dcaddd2..11d926f51c 100644 --- a/third_party/spirv-tools/source/val/validate_builtins.cpp +++ b/third_party/spirv-tools/source/val/validate_builtins.cpp @@ -24,10 +24,8 @@ #include #include #include -#include #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_target_env.h" #include "source/util/bitutils.h" @@ -99,12 +97,16 @@ spv_result_t GetUnderlyingType(ValidationState_t& _, spv::StorageClass GetStorageClass(const Instruction& inst) { switch (inst.opcode()) { case spv::Op::OpTypePointer: + case spv::Op::OpTypeUntypedPointerKHR: case spv::Op::OpTypeForwardPointer: { return spv::StorageClass(inst.word(2)); } case spv::Op::OpVariable: { return spv::StorageClass(inst.word(3)); } + case spv::Op::OpUntypedVariableKHR: { + return spv::StorageClass(inst.word(4)); + } case spv::Op::OpGenericCastToPtrExplicit: { return spv::StorageClass(inst.word(4)); } @@ -120,13 +122,15 @@ typedef enum VUIDError_ { VUIDErrorMax, } VUIDError; -const static uint32_t NumVUIDBuiltins = 36; +const static uint32_t NumVUIDBuiltins = 40; typedef struct { spv::BuiltIn builtIn; uint32_t vuid[VUIDErrorMax]; // execution mode, storage class, type VUIDs } BuiltinVUIDMapping; +// Many built-ins have the same checks (Storage Class, Type, etc) +// This table provides a nice LUT for the VUIDs std::array builtinVUIDInfo = {{ // clang-format off {spv::BuiltIn::SubgroupEqMask, {0, 4370, 4371}}, @@ -165,8 +169,13 @@ std::array builtinVUIDInfo = {{ {spv::BuiltIn::CullMaskKHR, {6735, 6736, 6737}}, {spv::BuiltIn::BaryCoordKHR, {4154, 4155, 4156}}, {spv::BuiltIn::BaryCoordNoPerspKHR, {4160, 4161, 4162}}, - // clang-format off -} }; + {spv::BuiltIn::PrimitivePointIndicesEXT, {7041, 7043, 7044}}, + {spv::BuiltIn::PrimitiveLineIndicesEXT, {7047, 7049, 7050}}, + {spv::BuiltIn::PrimitiveTriangleIndicesEXT, {7053, 7055, 7056}}, + {spv::BuiltIn::CullPrimitiveEXT, {7034, 7035, 7036}}, + + // clang-format on +}}; uint32_t GetVUIDForBuiltin(spv::BuiltIn builtIn, VUIDError type) { uint32_t vuid = 0; @@ -262,6 +271,9 @@ class BuiltInsValidator { // specified. Seeds id_to_at_reference_checks_ with decorated ids if needed. spv_result_t ValidateSingleBuiltInAtDefinition(const Decoration& decoration, const Instruction& inst); + spv_result_t ValidateSingleBuiltInAtDefinitionVulkan( + const Decoration& decoration, const Instruction& inst, + const spv::BuiltIn label); // The following section contains functions which are called when id defined // by |inst| is decorated with BuiltIn |decoration|. @@ -358,6 +370,9 @@ class BuiltInsValidator { spv_result_t ValidateRayTracingBuiltinsAtDefinition( const Decoration& decoration, const Instruction& inst); + spv_result_t ValidateMeshShadingEXTBuiltinsAtDefinition( + const Decoration& decoration, const Instruction& inst); + // The following section contains functions which are called when id defined // by |referenced_inst| is // 1. referenced by |referenced_from_inst| @@ -548,6 +563,11 @@ class BuiltInsValidator { const Instruction& referenced_inst, const Instruction& referenced_from_inst); + spv_result_t ValidateMeshShadingEXTBuiltinsAtReference( + const Decoration& decoration, const Instruction& built_in_inst, + const Instruction& referenced_inst, + const Instruction& referenced_from_inst); + // Validates that |built_in_inst| is not (even indirectly) referenced from // within a function which can be called with |execution_model|. // @@ -583,6 +603,10 @@ class BuiltInsValidator { spv_result_t ValidateI32Arr( const Decoration& decoration, const Instruction& inst, const std::function& diag); + spv_result_t ValidateArrayedI32Vec( + const Decoration& decoration, const Instruction& inst, + uint32_t num_components, + const std::function& diag); spv_result_t ValidateOptionalArrayedI32( const Decoration& decoration, const Instruction& inst, const std::function& diag); @@ -652,6 +676,37 @@ class BuiltInsValidator { // instruction. void Update(const Instruction& inst); + // Check if "inst" is an interface variable + // or type of a interface varibale of any mesh entry point + bool isMeshInterfaceVar(const Instruction& inst) { + auto getUnderlyingTypeId = [&](const Instruction* ifxVar) { + auto pointerTypeInst = _.FindDef(ifxVar->type_id()); + auto typeInst = _.FindDef(pointerTypeInst->GetOperandAs(2)); + while (typeInst->opcode() == spv::Op::OpTypeArray) { + typeInst = _.FindDef(typeInst->GetOperandAs(1)); + }; + return typeInst->id(); + }; + + for (const uint32_t entry_point : _.entry_points()) { + const auto* models = _.GetExecutionModels(entry_point); + if (models->find(spv::ExecutionModel::MeshEXT) != models->end() || + models->find(spv::ExecutionModel::MeshNV) != models->end()) { + for (const auto& desc : _.entry_point_descriptions(entry_point)) { + for (auto interface : desc.interfaces) { + if (inst.opcode() == spv::Op::OpTypeStruct) { + auto varInst = _.FindDef(interface); + if (inst.id() == getUnderlyingTypeId(varInst)) return true; + } else if (inst.id() == interface) { + return true; + } + } + } + } + } + return false; + } + ValidationState_t& _; // Mapping id -> list of rules which validate instruction referencing the @@ -726,7 +781,7 @@ std::string BuiltInsValidator::GetReferenceDesc( ss << " which is decorated with BuiltIn "; ss << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]); + (uint32_t)decoration.builtin()); if (function_id_) { ss << " in function <" << function_id_ << ">"; if (execution_model != spv::ExecutionModel::Max) { @@ -911,6 +966,45 @@ spv_result_t BuiltInsValidator::ValidateI32Vec( return SPV_SUCCESS; } +spv_result_t BuiltInsValidator::ValidateArrayedI32Vec( + const Decoration& decoration, const Instruction& inst, + uint32_t num_components, + const std::function& diag) { + uint32_t underlying_type = 0; + if (spv_result_t error = + GetUnderlyingType(_, decoration, inst, &underlying_type)) { + return error; + } + + const Instruction* const type_inst = _.FindDef(underlying_type); + if (type_inst->opcode() != spv::Op::OpTypeArray) { + return diag(GetDefinitionDesc(decoration, inst) + " is not an array."); + } + + const uint32_t component_type = type_inst->word(2); + if (!_.IsIntVectorType(component_type)) { + return diag(GetDefinitionDesc(decoration, inst) + " is not an int vector."); + } + + const uint32_t actual_num_components = _.GetDimension(component_type); + if (_.GetDimension(component_type) != num_components) { + std::ostringstream ss; + ss << GetDefinitionDesc(decoration, inst) << " has " + << actual_num_components << " components."; + return diag(ss.str()); + } + + const uint32_t bit_width = _.GetBitWidth(component_type); + if (bit_width != 32) { + std::ostringstream ss; + ss << GetDefinitionDesc(decoration, inst) + << " has components with bit width " << bit_width << "."; + return diag(ss.str()); + } + + return SPV_SUCCESS; +} + spv_result_t BuiltInsValidator::ValidateOptionalArrayedF32Vec( const Decoration& decoration, const Instruction& inst, uint32_t num_components, @@ -1066,7 +1160,7 @@ spv_result_t BuiltInsValidator::ValidateF32ArrHelper( if (num_components != 0) { uint64_t actual_num_components = 0; - if (!_.GetConstantValUint64(type_inst->word(3), &actual_num_components)) { + if (!_.EvalConstantValUint64(type_inst->word(3), &actual_num_components)) { assert(0 && "Array type definition is corrupt"); } if (actual_num_components != num_components) { @@ -1116,7 +1210,7 @@ spv_result_t BuiltInsValidator::ValidateNotCalledWithExecutionModel( const char* execution_model_str = _.grammar().lookupOperandName( SPV_OPERAND_TYPE_EXECUTION_MODEL, uint32_t(execution_model)); const char* built_in_str = _.grammar().lookupOperandName( - SPV_OPERAND_TYPE_BUILT_IN, decoration.params()[0]); + SPV_OPERAND_TYPE_BUILT_IN, (uint32_t)decoration.builtin()); return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << (vuid < 0 ? std::string("") : _.VkErrorID(vuid)) << comment << " " << GetIdDesc(referenced_inst) << " depends on " @@ -1147,13 +1241,14 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input && storage_class != spv::StorageClass::Output) { - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) ? 4190 : 4199; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4190 : 4199; return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(vuid) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, @@ -1167,7 +1262,8 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( if (storage_class == spv::StorageClass::Input) { assert(function_id_ == 0); - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) ? 4188 : 4197; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4188 : 4197; id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind( &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this, vuid, "Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance to be " @@ -1193,7 +1289,8 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( if (storage_class == spv::StorageClass::Output) { assert(function_id_ == 0); - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) ? 4189 : 4198; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4189 : 4198; id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind( &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this, vuid, "Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance to be " @@ -1212,7 +1309,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( [this, &decoration, &referenced_from_inst]( const std::string& message) -> spv_result_t { uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4191 : 4200; return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) @@ -1220,7 +1317,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( << "According to the Vulkan spec BuiltIn " << _.grammar().lookupOperandName( SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit float array. " << message; })) { @@ -1240,7 +1337,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( [this, &decoration, &referenced_from_inst]( const std::string& message) -> spv_result_t { uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4191 : 4200; return _.diag(SPV_ERROR_INVALID_DATA, @@ -1249,7 +1346,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( << "According to the Vulkan spec BuiltIn " << _.grammar().lookupOperandName( SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit float array. " << message; })) { @@ -1261,7 +1358,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( [this, &decoration, &referenced_from_inst]( const std::string& message) -> spv_result_t { uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) + (decoration.builtin() == spv::BuiltIn::ClipDistance) ? 4191 : 4200; return _.diag(SPV_ERROR_INVALID_DATA, @@ -1270,7 +1367,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( << "According to the Vulkan spec BuiltIn " << _.grammar().lookupOperandName( SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit float array. " << message; })) { @@ -1281,8 +1378,9 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference( } default: { - uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::ClipDistance) ? 4187 : 4196; + uint32_t vuid = (decoration.builtin() == spv::BuiltIn::ClipDistance) + ? 4187 + : 4196; return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(vuid) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, @@ -2092,6 +2190,17 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveIdAtDefinition( return error; } } + + if (_.HasCapability(spv::Capability::MeshShadingEXT)) { + if (isMeshInterfaceVar(inst) && + !_.HasDecoration(inst.id(), spv::Decoration::PerPrimitiveEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7040) + << "According to the Vulkan spec the variable decorated with " + "Builtin PrimitiveId within the MeshEXT Execution Model must " + "also be decorated with the PerPrimitiveEXT decoration. "; + } + } } // Seed at reference checks with this built-in. @@ -2488,7 +2597,7 @@ spv_result_t BuiltInsValidator::ValidateTessLevelAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -2507,7 +2616,8 @@ spv_result_t BuiltInsValidator::ValidateTessLevelAtReference( if (storage_class == spv::StorageClass::Input) { assert(function_id_ == 0); - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::TessLevelOuter) ? 4391 : 4395; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::TessLevelOuter) ? 4391 : 4395; id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind( &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this, vuid, "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be " @@ -2520,7 +2630,8 @@ spv_result_t BuiltInsValidator::ValidateTessLevelAtReference( if (storage_class == spv::StorageClass::Output) { assert(function_id_ == 0); - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::TessLevelOuter) ? 4392 : 4396; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::TessLevelOuter) ? 4392 : 4396; id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind( &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this, vuid, "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be " @@ -2670,12 +2781,13 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtDefinition( [this, &decoration, &inst](const std::string& message) -> spv_result_t { uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::Layer) ? 4276 : 4408; + (decoration.builtin() == spv::BuiltIn::Layer) ? 4276 : 4408; return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(vuid) << "According to the Vulkan spec BuiltIn " << _.grammar().lookupOperandName( - SPV_OPERAND_TYPE_BUILT_IN, decoration.params()[0]) + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << "variable needs to be a 32-bit int scalar. " << message; })) { @@ -2687,18 +2799,34 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtDefinition( [this, &decoration, &inst](const std::string& message) -> spv_result_t { uint32_t vuid = - (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::Layer) ? 4276 : 4408; + (decoration.builtin() == spv::BuiltIn::Layer) ? 4276 : 4408; return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(vuid) << "According to the Vulkan spec BuiltIn " << _.grammar().lookupOperandName( - SPV_OPERAND_TYPE_BUILT_IN, decoration.params()[0]) + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << "variable needs to be a 32-bit int scalar. " << message; })) { return error; } } + + if (isMeshInterfaceVar(inst) && + _.HasCapability(spv::Capability::MeshShadingEXT) && + !_.HasDecoration(inst.id(), spv::Decoration::PerPrimitiveEXT)) { + const spv::BuiltIn label = spv::BuiltIn(decoration.params()[0]); + uint32_t vkerrid = (label == spv::BuiltIn::Layer) ? 7039 : 7060; + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vkerrid) + << "According to the Vulkan spec the variable decorated with " + "Builtin " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, + decoration.params()[0]) + << " within the MeshEXT Execution Model must also be decorated " + "with the PerPrimitiveEXT decoration. "; + } } // Seed at reference checks with this built-in. @@ -2709,7 +2837,7 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -2823,7 +2951,7 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference( spv_result_t BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateF32Vec( decoration, inst, 3, [this, &inst, builtin](const std::string& message) -> spv_result_t { @@ -2853,7 +2981,7 @@ spv_result_t BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtReference( const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -2897,7 +3025,7 @@ spv_result_t BuiltInsValidator::ValidateFragmentShaderF32Vec3InputAtReference( spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateI32Vec( decoration, inst, 3, [this, &inst, builtin](const std::string& message) -> spv_result_t { @@ -2926,7 +3054,7 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference( const Instruction& referenced_inst, const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -2977,7 +3105,7 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference( spv_result_t BuiltInsValidator::ValidateComputeI32InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (decoration.struct_member_index() != Decoration::kInvalidMember) { return _.diag(SPV_ERROR_INVALID_DATA, &inst) << "BuiltIn " @@ -3011,7 +3139,7 @@ spv_result_t BuiltInsValidator::ValidateComputeI32InputAtReference( const Instruction& referenced_inst, const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -3062,7 +3190,7 @@ spv_result_t BuiltInsValidator::ValidateComputeI32InputAtReference( spv_result_t BuiltInsValidator::ValidateI32InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (decoration.struct_member_index() != Decoration::kInvalidMember) { return _.diag(SPV_ERROR_INVALID_DATA, &inst) << "BuiltIn " @@ -3105,7 +3233,7 @@ spv_result_t BuiltInsValidator::ValidateI32InputAtDefinition( spv_result_t BuiltInsValidator::ValidateI32Vec4InputAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (decoration.struct_member_index() != Decoration::kInvalidMember) { return _.diag(SPV_ERROR_INVALID_DATA, &inst) << "BuiltIn " @@ -3149,16 +3277,8 @@ spv_result_t BuiltInsValidator::ValidateI32Vec4InputAtDefinition( spv_result_t BuiltInsValidator::ValidateWorkgroupSizeAtDefinition( const Decoration& decoration, const Instruction& inst) { + // Vulkan requires 32-bit int, but Universal has no restrictions if (spvIsVulkanEnv(_.context()->target_env)) { - if (spvIsVulkanEnv(_.context()->target_env) && - !spvOpcodeIsConstant(inst.opcode())) { - return _.diag(SPV_ERROR_INVALID_DATA, &inst) - << _.VkErrorID(4426) - << "Vulkan spec requires BuiltIn WorkgroupSize to be a " - "constant. " - << GetIdDesc(inst) << " is not a constant."; - } - if (spv_result_t error = ValidateI32Vec( decoration, inst, 3, [this, &inst](const std::string& message) -> spv_result_t { @@ -3173,6 +3293,34 @@ spv_result_t BuiltInsValidator::ValidateWorkgroupSizeAtDefinition( } } + if (!spvOpcodeIsConstant(inst.opcode())) { + if (spvIsVulkanEnv(_.context()->target_env)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(4426) + << "Vulkan spec requires BuiltIn WorkgroupSize to be a " + "constant. " + << GetIdDesc(inst) << " is not a constant."; + } + } else if (inst.opcode() == spv::Op::OpConstantComposite) { + // can only validate product if static and not spec constant + if (_.FindDef(inst.word(3))->opcode() == spv::Op::OpConstant && + _.FindDef(inst.word(4))->opcode() == spv::Op::OpConstant && + _.FindDef(inst.word(5))->opcode() == spv::Op::OpConstant) { + uint64_t x_size, y_size, z_size; + // ValidateI32Vec above confirms there will be 3 words to read + bool static_x = _.EvalConstantValUint64(inst.word(3), &x_size); + bool static_y = _.EvalConstantValUint64(inst.word(4), &y_size); + bool static_z = _.EvalConstantValUint64(inst.word(5), &z_size); + if (static_x && static_y && static_z && + ((x_size * y_size * z_size) == 0)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << "WorkgroupSize decorations must not have a static " + "product of zero (X = " + << x_size << ", Y = " << y_size << ", Z = " << z_size << ")."; + } + } + } + // Seed at reference checks with this built-in. return ValidateWorkgroupSizeAtReference(decoration, inst, inst, inst); } @@ -3193,7 +3341,7 @@ spv_result_t BuiltInsValidator::ValidateWorkgroupSizeAtReference( << spvLogStringForEnv(_.context()->target_env) << " spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be used only with GLCompute, MeshNV, TaskNV, MeshEXT or " << "TaskEXT execution model. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, @@ -3219,14 +3367,15 @@ spv_result_t BuiltInsValidator::ValidateBaseInstanceOrVertexAtDefinition( decoration, inst, [this, &inst, &decoration](const std::string& message) -> spv_result_t { - uint32_t vuid = (spv::BuiltIn(decoration.params()[0]) == spv::BuiltIn::BaseInstance) - ? 4183 - : 4186; + uint32_t vuid = + (decoration.builtin() == spv::BuiltIn::BaseInstance) ? 4183 + : 4186; return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(vuid) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3241,7 +3390,7 @@ spv_result_t BuiltInsValidator::ValidateBaseInstanceOrVertexAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -3292,8 +3441,9 @@ spv_result_t BuiltInsValidator::ValidateDrawIndexAtDefinition( return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(4209) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3308,7 +3458,7 @@ spv_result_t BuiltInsValidator::ValidateDrawIndexAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -3362,8 +3512,9 @@ spv_result_t BuiltInsValidator::ValidateViewIndexAtDefinition( return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(4403) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3378,7 +3529,7 @@ spv_result_t BuiltInsValidator::ValidateViewIndexAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -3426,8 +3577,9 @@ spv_result_t BuiltInsValidator::ValidateDeviceIndexAtDefinition( return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(4206) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3442,7 +3594,7 @@ spv_result_t BuiltInsValidator::ValidateDeviceIndexAtReference( const Decoration& decoration, const Instruction& built_in_inst, const Instruction& referenced_inst, const Instruction& referenced_from_inst) { - uint32_t operand = decoration.params()[0]; + uint32_t operand = (uint32_t)decoration.builtin(); if (spvIsVulkanEnv(_.context()->target_env)) { const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && @@ -3472,7 +3624,7 @@ spv_result_t BuiltInsValidator::ValidateFragInvocationCountAtDefinition(const De const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateI32( decoration, inst, [this, &inst, &builtin](const std::string& message) -> spv_result_t { @@ -3499,7 +3651,7 @@ spv_result_t BuiltInsValidator::ValidateFragInvocationCountAtReference( const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -3542,7 +3694,7 @@ spv_result_t BuiltInsValidator::ValidateFragInvocationCountAtReference( spv_result_t BuiltInsValidator::ValidateFragSizeAtDefinition(const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateI32Vec( decoration, inst, 2, [this, &inst, &builtin](const std::string& message) -> spv_result_t { @@ -3569,7 +3721,7 @@ spv_result_t BuiltInsValidator::ValidateFragSizeAtReference( const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -3612,7 +3764,7 @@ spv_result_t BuiltInsValidator::ValidateFragSizeAtReference( spv_result_t BuiltInsValidator::ValidateFragStencilRefAtDefinition(const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateI( decoration, inst, [this, &inst, &builtin](const std::string& message) -> spv_result_t { @@ -3639,7 +3791,7 @@ spv_result_t BuiltInsValidator::ValidateFragStencilRefAtReference( const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Output) { @@ -3682,7 +3834,7 @@ spv_result_t BuiltInsValidator::ValidateFragStencilRefAtReference( spv_result_t BuiltInsValidator::ValidateFullyCoveredAtDefinition(const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); if (spv_result_t error = ValidateBool( decoration, inst, [this, &inst, &builtin](const std::string& message) -> spv_result_t { @@ -3709,7 +3861,7 @@ spv_result_t BuiltInsValidator::ValidateFullyCoveredAtReference( const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -3760,8 +3912,9 @@ spv_result_t BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtDefinition( << "According to the " << spvLogStringForEnv(_.context()->target_env) << " spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3785,7 +3938,7 @@ spv_result_t BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtReference( << spvLogStringForEnv(_.context()->target_env) << " spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be only used for " "variables with Input storage class. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, @@ -3814,13 +3967,23 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveShadingRateAtDefinition( return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(4486) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { return error; } + if (isMeshInterfaceVar(inst) && + _.HasCapability(spv::Capability::MeshShadingEXT) && + !_.HasDecoration(inst.id(), spv::Decoration::PerPrimitiveEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7059) + << "The variable decorated with PrimitiveShadingRateKHR " + "within the MeshEXT Execution Model must also be " + "decorated with the PerPrimitiveEXT decoration"; + } } // Seed at reference checks with this built-in. @@ -3838,7 +4001,7 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveShadingRateAtReference( return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(4485) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be only used for variables with Output storage class. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst) @@ -3855,9 +4018,10 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveShadingRateAtReference( default: { return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(4484) << "Vulkan spec allows BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) - << " to be used only with Vertex, Geometry, or MeshNV " + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) + << " to be used only with Vertex, Geometry, MeshNV or MeshEXT " "execution models. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst, execution_model); @@ -3887,8 +4051,9 @@ spv_result_t BuiltInsValidator::ValidateShadingRateAtDefinition( return _.diag(SPV_ERROR_INVALID_DATA, &inst) << _.VkErrorID(4492) << "According to the Vulkan spec BuiltIn " - << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) << " variable needs to be a 32-bit int scalar. " << message; })) { @@ -3911,7 +4076,7 @@ spv_result_t BuiltInsValidator::ValidateShadingRateAtReference( return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(4491) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be only used for variables with Input storage class. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst) @@ -3923,7 +4088,7 @@ spv_result_t BuiltInsValidator::ValidateShadingRateAtReference( return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(4490) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be used only with the Fragment execution model. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst, execution_model); @@ -3944,7 +4109,7 @@ spv_result_t BuiltInsValidator::ValidateShadingRateAtReference( spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition( const Decoration& decoration, const Instruction& inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); switch (builtin) { case spv::BuiltIn::HitTNV: case spv::BuiltIn::RayTminKHR: @@ -4067,7 +4232,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference( const Instruction& referenced_inst, const Instruction& referenced_from_inst) { if (spvIsVulkanEnv(_.context()->target_env)) { - const spv::BuiltIn builtin = spv::BuiltIn(decoration.params()[0]); + const spv::BuiltIn builtin = decoration.builtin(); const spv::StorageClass storage_class = GetStorageClass(referenced_from_inst); if (storage_class != spv::StorageClass::Max && storage_class != spv::StorageClass::Input) { @@ -4075,7 +4240,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference( return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(vuid) << "Vulkan spec allows BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be only used for variables with Input storage class. " << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst) @@ -4088,10 +4253,11 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference( return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) << _.VkErrorID(vuid) << "Vulkan spec does not allow BuiltIn " << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, - decoration.params()[0]) + (uint32_t)decoration.builtin()) << " to be used with the execution model " << _.grammar().lookupOperandName( - SPV_OPERAND_TYPE_EXECUTION_MODEL, uint32_t(execution_model)) + SPV_OPERAND_TYPE_EXECUTION_MODEL, + uint32_t(execution_model)) << ".\n" << GetReferenceDesc(decoration, built_in_inst, referenced_inst, referenced_from_inst, execution_model); @@ -4110,21 +4276,238 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference( return SPV_SUCCESS; } -spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( +spv_result_t BuiltInsValidator::ValidateMeshShadingEXTBuiltinsAtDefinition( const Decoration& decoration, const Instruction& inst) { - const spv::BuiltIn label = spv::BuiltIn(decoration.params()[0]); + if (spvIsVulkanEnv(_.context()->target_env)) { + const spv::BuiltIn builtin = decoration.builtin(); + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType); + switch (builtin) { + case spv::BuiltIn::PrimitivePointIndicesEXT: + if (spv_result_t error = ValidateI32Arr( + decoration, inst, + [this, &inst, &decoration, + &vuid](const std::string& message) -> spv_result_t { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vuid) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn " + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) + << " variable needs to be a 32-bit int array." + << message; + })) { + return error; + } + break; + case spv::BuiltIn::PrimitiveLineIndicesEXT: + if (spv_result_t error = ValidateArrayedI32Vec( + decoration, inst, 2, + [this, &inst, &decoration, + &vuid](const std::string& message) -> spv_result_t { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vuid) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn " + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) + << " variable needs to be a 2-component 32-bit int " + "array." + << message; + })) { + return error; + } + break; + case spv::BuiltIn::PrimitiveTriangleIndicesEXT: + if (spv_result_t error = ValidateArrayedI32Vec( + decoration, inst, 3, + [this, &inst, &decoration, + &vuid](const std::string& message) -> spv_result_t { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vuid) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn " + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) + << " variable needs to be a 3-component 32-bit int " + "array." + << message; + })) { + return error; + } + break; + case spv::BuiltIn::CullPrimitiveEXT: + if (spv_result_t error = ValidateBool( + decoration, inst, + [this, &inst, &decoration, + &vuid](const std::string& message) -> spv_result_t { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(vuid) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn " + << _.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, + (uint32_t)decoration.builtin()) + << " variable needs to be a boolean value " + "array." + << message; + })) { + return error; + } + if (!_.HasDecoration(inst.id(), spv::Decoration::PerPrimitiveEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7038) + << "The variable decorated with CullPrimitiveEXT within the " + "MeshEXT Execution Model must also be decorated with the " + "PerPrimitiveEXT decoration "; + } + break; + default: + assert(0 && "Unexpected mesh EXT builtin"); + } + for (const uint32_t entry_point : _.entry_points()) { + const auto* modes = _.GetExecutionModes(entry_point); + uint64_t maxOutputPrimitives = _.GetOutputPrimitivesEXT(entry_point); + uint32_t underlying_type = 0; + if (spv_result_t error = + GetUnderlyingType(_, decoration, inst, &underlying_type)) { + return error; + } - if (!spvIsVulkanEnv(_.context()->target_env)) { - // Early return. All currently implemented rules are based on Vulkan spec. - // - // TODO: If you are adding validation rules for environments other than - // Vulkan (or general rules which are not environment independent), then - // you need to modify or remove this condition. Consider also adding early - // returns into BuiltIn-specific rules, so that the system doesn't spawn new - // rules which don't do anything. - return SPV_SUCCESS; + uint64_t primitiveArrayDim = 0; + if (_.GetIdOpcode(underlying_type) == spv::Op::OpTypeArray) { + underlying_type = _.FindDef(underlying_type)->word(3u); + if (!_.EvalConstantValUint64(underlying_type, &primitiveArrayDim)) { + assert(0 && "Array type definition is corrupt"); + } + } + switch (builtin) { + case spv::BuiltIn::PrimitivePointIndicesEXT: + if (!modes || !modes->count(spv::ExecutionMode::OutputPoints)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7042) + << "The PrimitivePointIndicesEXT decoration must be used " + "with " + "the OutputPoints Execution Mode. "; + } + if (primitiveArrayDim && primitiveArrayDim != maxOutputPrimitives) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7046) + << "The size of the array decorated with " + "PrimitivePointIndicesEXT must match the value specified " + "by OutputPrimitivesEXT. "; + } + break; + case spv::BuiltIn::PrimitiveLineIndicesEXT: + if (!modes || !modes->count(spv::ExecutionMode::OutputLinesEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7048) + << "The PrimitiveLineIndicesEXT decoration must be used " + "with " + "the OutputLinesEXT Execution Mode. "; + } + if (primitiveArrayDim && primitiveArrayDim != maxOutputPrimitives) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7052) + << "The size of the array decorated with " + "PrimitiveLineIndicesEXT must match the value specified " + "by OutputPrimitivesEXT. "; + } + break; + case spv::BuiltIn::PrimitiveTriangleIndicesEXT: + if (!modes || !modes->count(spv::ExecutionMode::OutputTrianglesEXT)) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7054) + << "The PrimitiveTriangleIndicesEXT decoration must be used " + "with " + "the OutputTrianglesEXT Execution Mode. "; + } + if (primitiveArrayDim && primitiveArrayDim != maxOutputPrimitives) { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(7058) + << "The size of the array decorated with " + "PrimitiveTriangleIndicesEXT must match the value " + "specified " + "by OutputPrimitivesEXT. "; + } + break; + default: + break; // no validation rules + } + } + } + // Seed at reference checks with this built-in. + return ValidateMeshShadingEXTBuiltinsAtReference(decoration, inst, inst, + inst); +} + +spv_result_t BuiltInsValidator::ValidateMeshShadingEXTBuiltinsAtReference( + const Decoration& decoration, const Instruction& built_in_inst, + const Instruction& referenced_inst, + const Instruction& referenced_from_inst) { + if (spvIsVulkanEnv(_.context()->target_env)) { + const spv::BuiltIn builtin = decoration.builtin(); + const spv::StorageClass storage_class = + GetStorageClass(referenced_from_inst); + if (storage_class != spv::StorageClass::Max && + storage_class != spv::StorageClass::Output) { + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass); + return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) + << _.VkErrorID(vuid) << spvLogStringForEnv(_.context()->target_env) + << " spec allows BuiltIn " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, + uint32_t(builtin)) + << " to be only used for variables with Output storage class. " + << GetReferenceDesc(decoration, built_in_inst, referenced_inst, + referenced_from_inst) + << " " << GetStorageClassDesc(referenced_from_inst); + } + for (const spv::ExecutionModel execution_model : execution_models_) { + if (execution_model != spv::ExecutionModel::MeshEXT) { + uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorExecutionModel); + return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) + << _.VkErrorID(vuid) + << spvLogStringForEnv(_.context()->target_env) + << " spec allows BuiltIn " + << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, + uint32_t(builtin)) + << " to be used only with MeshEXT execution model. " + << GetReferenceDesc(decoration, built_in_inst, referenced_inst, + referenced_from_inst, execution_model); + } + } } + if (function_id_ == 0) { + // Propagate this rule to all dependant ids in the global scope. + id_to_at_reference_checks_[referenced_from_inst.id()].push_back( + std::bind(&BuiltInsValidator::ValidateMeshShadingEXTBuiltinsAtReference, + this, decoration, built_in_inst, referenced_from_inst, + std::placeholders::_1)); + } + + return SPV_SUCCESS; +} + +spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( + const Decoration& decoration, const Instruction& inst) { + const spv::BuiltIn label = decoration.builtin(); + // Universial checks + if (label == spv::BuiltIn::WorkgroupSize) { + return ValidateWorkgroupSizeAtDefinition(decoration, inst); + } + + if (spvIsVulkanEnv(_.context()->target_env)) { + return ValidateSingleBuiltInAtDefinitionVulkan(decoration, inst, label); + } + return SPV_SUCCESS; +} + +spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinitionVulkan( + const Decoration& decoration, const Instruction& inst, + const spv::BuiltIn label) { // If you are adding a new BuiltIn enum, please register it here. // If the newly added enum has validation rules associated with it // consider leaving a TODO and/or creating an issue. @@ -4216,9 +4599,6 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( case spv::BuiltIn::VertexIndex: { return ValidateVertexIndexAtDefinition(decoration, inst); } - case spv::BuiltIn::WorkgroupSize: { - return ValidateWorkgroupSizeAtDefinition(decoration, inst); - } case spv::BuiltIn::VertexId: { return ValidateVertexIdAtDefinition(decoration, inst); } @@ -4285,6 +4665,12 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition( case spv::BuiltIn::CullMaskKHR: { return ValidateRayTracingBuiltinsAtDefinition(decoration, inst); } + case spv::BuiltIn::CullPrimitiveEXT: + case spv::BuiltIn::PrimitivePointIndicesEXT: + case spv::BuiltIn::PrimitiveLineIndicesEXT: + case spv::BuiltIn::PrimitiveTriangleIndicesEXT: { + return ValidateMeshShadingEXTBuiltinsAtDefinition(decoration, inst); + } case spv::BuiltIn::PrimitiveShadingRateKHR: { return ValidatePrimitiveShadingRateAtDefinition(decoration, inst); } diff --git a/third_party/spirv-tools/source/val/validate_capability.cpp b/third_party/spirv-tools/source/val/validate_capability.cpp index d70c8273c7..81d2ad52d2 100644 --- a/third_party/spirv-tools/source/val/validate_capability.cpp +++ b/third_party/spirv-tools/source/val/validate_capability.cpp @@ -16,9 +16,7 @@ #include #include -#include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/val/instruction.h" #include "source/val/validate.h" @@ -242,7 +240,7 @@ bool IsEnabledByExtension(ValidationState_t& _, uint32_t capability) { ExtensionSet operand_exts(operand_desc->numExtensions, operand_desc->extensions); - if (operand_exts.IsEmpty()) return false; + if (operand_exts.empty()) return false; return _.HasAnyOfExtensions(operand_exts); } diff --git a/third_party/spirv-tools/source/val/validate_cfg.cpp b/third_party/spirv-tools/source/val/validate_cfg.cpp index 24d2416927..b7e570de77 100644 --- a/third_party/spirv-tools/source/val/validate_cfg.cpp +++ b/third_party/spirv-tools/source/val/validate_cfg.cpp @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include -#include #include #include #include @@ -28,7 +26,6 @@ #include "source/cfa.h" #include "source/opcode.h" #include "source/spirv_constant.h" -#include "source/spirv_target_env.h" #include "source/spirv_validator_options.h" #include "source/val/basic_block.h" #include "source/val/construct.h" @@ -193,6 +190,8 @@ spv_result_t ValidateBranchConditional(ValidationState_t& _, "ID of an OpLabel instruction"; } + // A similar requirement for SPV_KHR_maximal_reconvergence is deferred until + // entry point call trees have been reconrded. if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 6) && true_id == false_id) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "In SPIR-V 1.6 or later, True Label and False Label must be " @@ -251,7 +250,8 @@ spv_result_t ValidateReturnValue(ValidationState_t& _, } if (_.addressing_model() == spv::AddressingModel::Logical && - spv::Op::OpTypePointer == value_type->opcode() && + (spv::Op::OpTypePointer == value_type->opcode() || + spv::Op::OpTypeUntypedPointerKHR == value_type->opcode()) && !_.features().variable_pointers && !_.options()->relax_logical_pointer) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpReturnValue value's type " @@ -468,13 +468,13 @@ std::string ConstructErrorString(const Construct& construct, // headed by |target_block| branches to multiple case constructs. spv_result_t FindCaseFallThrough( ValidationState_t& _, BasicBlock* target_block, uint32_t* case_fall_through, - const BasicBlock* merge, const std::unordered_set& case_targets, - Function* function) { + const Construct& switch_construct, + const std::unordered_set& case_targets) { + const auto* merge = switch_construct.exit_block(); std::vector stack; stack.push_back(target_block); std::unordered_set visited; bool target_reachable = target_block->structurally_reachable(); - int target_depth = function->GetBlockDepth(target_block); while (!stack.empty()) { auto block = stack.back(); stack.pop_back(); @@ -492,9 +492,14 @@ spv_result_t FindCaseFallThrough( } else { // Exiting the case construct to non-merge block. if (!case_targets.count(block->id())) { - int depth = function->GetBlockDepth(block); - if ((depth < target_depth) || - (depth == target_depth && block->is_type(kBlockTypeContinue))) { + // We have already filtered out the following: + // * The switch's merge + // * Other case targets + // * Blocks in the same case construct + // + // So the only remaining valid branches are the structured exits from + // the overall selection construct of the switch. + if (switch_construct.IsStructuredExit(_, block)) { continue; } @@ -526,9 +531,10 @@ spv_result_t FindCaseFallThrough( } spv_result_t StructuredSwitchChecks(ValidationState_t& _, Function* function, - const Instruction* switch_inst, - const BasicBlock* header, - const BasicBlock* merge) { + const Construct& switch_construct) { + const auto* header = switch_construct.entry_block(); + const auto* merge = switch_construct.exit_block(); + const auto* switch_inst = header->terminator(); std::unordered_set case_targets; for (uint32_t i = 1; i < switch_inst->operands().size(); i += 2) { uint32_t target = switch_inst->GetOperandAs(i); @@ -546,6 +552,7 @@ spv_result_t StructuredSwitchChecks(ValidationState_t& _, Function* function, break; } } + std::unordered_map seen_to_fall_through; for (uint32_t i = 1; i < switch_inst->operands().size(); i += 2) { uint32_t target = switch_inst->GetOperandAs(i); @@ -560,13 +567,13 @@ spv_result_t StructuredSwitchChecks(ValidationState_t& _, Function* function, target_block->structurally_reachable() && !header->structurally_dominates(*target_block)) { return _.diag(SPV_ERROR_INVALID_CFG, header->label()) - << "Selection header " << _.getIdName(header->id()) + << "Switch header " << _.getIdName(header->id()) << " does not structurally dominate its case construct " << _.getIdName(target); } if (auto error = FindCaseFallThrough(_, target_block, &case_fall_through, - merge, case_targets, function)) { + switch_construct, case_targets)) { return error; } @@ -671,7 +678,8 @@ spv_result_t ValidateStructuredSelections( // previously. const bool true_label_unseen = seen.insert(true_label).second; const bool false_label_unseen = seen.insert(false_label).second; - if (!merge && true_label_unseen && false_label_unseen) { + if ((!merge || merge->opcode() == spv::Op::OpLoopMerge) && + true_label_unseen && false_label_unseen) { return _.diag(SPV_ERROR_INVALID_CFG, terminator) << "Selection must be structured"; } @@ -838,6 +846,9 @@ spv_result_t StructuredControlFlowChecks( const auto* continue_target = next_inst.block(); if (header->id() != continue_id) { for (auto pred : *continue_target->predecessors()) { + if (!pred->structurally_reachable()) { + continue; + } // Ignore back-edges from within the continue construct. bool is_back_edge = false; for (auto back_edge : back_edges) { @@ -862,9 +873,7 @@ spv_result_t StructuredControlFlowChecks( // Checks rules for case constructs. if (construct.type() == ConstructType::kSelection && header->terminator()->opcode() == spv::Op::OpSwitch) { - const auto terminator = header->terminator(); - if (auto error = - StructuredSwitchChecks(_, function, terminator, header, merge)) { + if (auto error = StructuredSwitchChecks(_, function, construct)) { return error; } } @@ -877,6 +886,95 @@ spv_result_t StructuredControlFlowChecks( return SPV_SUCCESS; } +spv_result_t MaximalReconvergenceChecks(ValidationState_t& _) { + // Find all the entry points with the MaximallyReconvergencesKHR execution + // mode. + std::unordered_set maximal_funcs; + std::unordered_set maximal_entry_points; + for (auto entry_point : _.entry_points()) { + const auto* exec_modes = _.GetExecutionModes(entry_point); + if (exec_modes && + exec_modes->count(spv::ExecutionMode::MaximallyReconvergesKHR)) { + maximal_entry_points.insert(entry_point); + maximal_funcs.insert(entry_point); + } + } + + if (maximal_entry_points.empty()) { + return SPV_SUCCESS; + } + + // Find all the functions reachable from a maximal reconvergence entry point. + for (const auto& func : _.functions()) { + const auto& entry_points = _.EntryPointReferences(func.id()); + for (auto id : entry_points) { + if (maximal_entry_points.count(id)) { + maximal_funcs.insert(func.id()); + break; + } + } + } + + // Check for conditional branches with the same true and false targets. + for (const auto& inst : _.ordered_instructions()) { + if (inst.opcode() == spv::Op::OpBranchConditional) { + const auto true_id = inst.GetOperandAs(1); + const auto false_id = inst.GetOperandAs(2); + if (true_id == false_id && maximal_funcs.count(inst.function()->id())) { + return _.diag(SPV_ERROR_INVALID_ID, &inst) + << "In entry points using the MaximallyReconvergesKHR execution " + "mode, True Label and False Label must be different labels"; + } + } + } + + // Check for invalid multiple predecessors. Only loop headers, continue + // targets, merge targets or switch targets or defaults may have multiple + // unique predecessors. + for (const auto& func : _.functions()) { + if (!maximal_funcs.count(func.id())) continue; + + for (const auto* block : func.ordered_blocks()) { + std::unordered_set unique_preds; + const auto* preds = block->predecessors(); + if (!preds) continue; + + for (const auto* pred : *preds) { + unique_preds.insert(pred->id()); + } + if (unique_preds.size() < 2) continue; + + const auto* terminator = block->terminator(); + const auto index = terminator - &_.ordered_instructions()[0]; + const auto* pre_terminator = &_.ordered_instructions()[index - 1]; + if (pre_terminator->opcode() == spv::Op::OpLoopMerge) continue; + + const auto* label = _.FindDef(block->id()); + bool ok = false; + for (const auto& pair : label->uses()) { + const auto* use_inst = pair.first; + switch (use_inst->opcode()) { + case spv::Op::OpSelectionMerge: + case spv::Op::OpLoopMerge: + case spv::Op::OpSwitch: + ok = true; + break; + default: + break; + } + } + if (!ok) { + return _.diag(SPV_ERROR_INVALID_CFG, label) + << "In entry points using the MaximallyReconvergesKHR " + "execution mode, this basic block must not have multiple " + "unique predecessors"; + } + } + } + + return SPV_SUCCESS; +} + spv_result_t PerformCfgChecks(ValidationState_t& _) { for (auto& function : _.functions()) { // Check all referenced blocks are defined within a function @@ -1001,6 +1099,11 @@ spv_result_t PerformCfgChecks(ValidationState_t& _) { return error; } } + + if (auto error = MaximalReconvergenceChecks(_)) { + return error; + } + return SPV_SUCCESS; } diff --git a/third_party/spirv-tools/source/val/validate_composites.cpp b/third_party/spirv-tools/source/val/validate_composites.cpp index e777f1640e..2afeae78ad 100644 --- a/third_party/spirv-tools/source/val/validate_composites.cpp +++ b/third_party/spirv-tools/source/val/validate_composites.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2017 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,12 +16,10 @@ // Validates correctness of composite SPIR-V instructions. -#include "source/val/validate.h" - -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_target_env.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { @@ -96,7 +96,7 @@ spv_result_t GetExtractInsertValueType(ValidationState_t& _, break; } - if (!_.GetConstantValUint64(type_inst->word(3), &array_size)) { + if (!_.EvalConstantValUint64(type_inst->word(3), &array_size)) { assert(0 && "Array type definition is corrupt"); } if (component_index >= array_size) { @@ -106,7 +106,8 @@ spv_result_t GetExtractInsertValueType(ValidationState_t& _, } break; } - case spv::Op::OpTypeRuntimeArray: { + case spv::Op::OpTypeRuntimeArray: + case spv::Op::OpTypeNodePayloadArrayAMDX: { *member_type = type_inst->word(2); // Array size is unknown. break; @@ -124,6 +125,8 @@ spv_result_t GetExtractInsertValueType(ValidationState_t& _, *member_type = type_inst->word(component_index + 2); break; } + case spv::Op::OpTypeCooperativeVectorNV: + case spv::Op::OpTypeCooperativeMatrixKHR: case spv::Op::OpTypeCooperativeMatrixNV: { *member_type = type_inst->word(2); break; @@ -149,7 +152,8 @@ spv_result_t ValidateVectorExtractDynamic(ValidationState_t& _, const uint32_t vector_type = _.GetOperandTypeId(inst, 2); const spv::Op vector_opcode = _.GetIdOpcode(vector_type); - if (vector_opcode != spv::Op::OpTypeVector) { + if (vector_opcode != spv::Op::OpTypeVector && + vector_opcode != spv::Op::OpTypeCooperativeVectorNV) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Vector type to be OpTypeVector"; } @@ -177,7 +181,8 @@ spv_result_t ValidateVectorInsertDyanmic(ValidationState_t& _, const Instruction* inst) { const uint32_t result_type = inst->type_id(); const spv::Op result_opcode = _.GetIdOpcode(result_type); - if (result_opcode != spv::Op::OpTypeVector) { + if (result_opcode != spv::Op::OpTypeVector && + result_opcode != spv::Op::OpTypeCooperativeVectorNV) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Result Type to be OpTypeVector"; } @@ -215,14 +220,24 @@ spv_result_t ValidateCompositeConstruct(ValidationState_t& _, const uint32_t result_type = inst->type_id(); const spv::Op result_opcode = _.GetIdOpcode(result_type); switch (result_opcode) { - case spv::Op::OpTypeVector: { - const uint32_t num_result_components = _.GetDimension(result_type); + case spv::Op::OpTypeVector: + case spv::Op::OpTypeCooperativeVectorNV: { + uint32_t num_result_components = _.GetDimension(result_type); const uint32_t result_component_type = _.GetComponentType(result_type); uint32_t given_component_count = 0; - if (num_operands <= 3) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected number of constituents to be at least 2"; + bool comp_is_int32 = true, comp_is_const_int32 = true; + + if (result_opcode == spv::Op::OpTypeVector) { + if (num_operands <= 3) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected number of constituents to be at least 2"; + } + } else { + uint32_t comp_count_id = + _.FindDef(result_type)->GetOperandAs(2); + std::tie(comp_is_int32, comp_is_const_int32, num_result_components) = + _.EvalInt32IfConst(comp_count_id); } for (uint32_t operand_index = 2; operand_index < num_operands; @@ -242,7 +257,8 @@ spv_result_t ValidateCompositeConstruct(ValidationState_t& _, } } - if (num_result_components != given_component_count) { + if (comp_is_const_int32 && + num_result_components != given_component_count) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected total number of given components to be equal " << "to the size of Result Type vector"; @@ -290,7 +306,7 @@ spv_result_t ValidateCompositeConstruct(ValidationState_t& _, } uint64_t array_size = 0; - if (!_.GetConstantValUint64(array_inst->word(3), &array_size)) { + if (!_.EvalConstantValUint64(array_inst->word(3), &array_size)) { assert(0 && "Array type definition is corrupt"); } @@ -337,6 +353,25 @@ spv_result_t ValidateCompositeConstruct(ValidationState_t& _, break; } + case spv::Op::OpTypeCooperativeMatrixKHR: { + const auto result_type_inst = _.FindDef(result_type); + assert(result_type_inst); + const auto component_type_id = + result_type_inst->GetOperandAs(1); + + if (3 != num_operands) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Must be only one constituent"; + } + + const uint32_t operand_type_id = _.GetOperandTypeId(inst, 2); + + if (operand_type_id != component_type_id) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Constituent type to be equal to the component type"; + } + break; + } case spv::Op::OpTypeCooperativeMatrixNV: { const auto result_type_inst = _.FindDef(result_type); assert(result_type_inst); diff --git a/third_party/spirv-tools/source/val/validate_constants.cpp b/third_party/spirv-tools/source/val/validate_constants.cpp index a8ee5a6b1e..9c689c5393 100644 --- a/third_party/spirv-tools/source/val/validate_constants.cpp +++ b/third_party/spirv-tools/source/val/validate_constants.cpp @@ -46,9 +46,18 @@ spv_result_t ValidateConstantComposite(ValidationState_t& _, const auto constituent_count = inst->words().size() - 3; switch (result_type->opcode()) { - case spv::Op::OpTypeVector: { - const auto component_count = result_type->GetOperandAs(2); - if (component_count != constituent_count) { + case spv::Op::OpTypeVector: + case spv::Op::OpTypeCooperativeVectorNV: { + uint32_t num_result_components = _.GetDimension(result_type->id()); + bool comp_is_int32 = true, comp_is_const_int32 = true; + + if (result_type->opcode() == spv::Op::OpTypeCooperativeVectorNV) { + uint32_t comp_count_id = result_type->GetOperandAs(2); + std::tie(comp_is_int32, comp_is_const_int32, num_result_components) = + _.EvalInt32IfConst(comp_count_id); + } + + if (comp_is_const_int32 && num_result_components != constituent_count) { // TODO: Output ID's on diagnostic return _.diag(SPV_ERROR_INVALID_ID, inst) << opcode_name @@ -76,7 +85,7 @@ spv_result_t ValidateConstantComposite(ValidationState_t& _, } const auto constituent_result_type = _.FindDef(constituent->type_id()); if (!constituent_result_type || - component_type->opcode() != constituent_result_type->opcode()) { + component_type->id() != constituent_result_type->id()) { return _.diag(SPV_ERROR_INVALID_ID, inst) << opcode_name << " Constituent " << _.getIdName(constituent_id) @@ -243,6 +252,7 @@ spv_result_t ValidateConstantComposite(ValidationState_t& _, } } } break; + case spv::Op::OpTypeCooperativeMatrixKHR: case spv::Op::OpTypeCooperativeMatrixNV: { if (1 != constituent_count) { return _.diag(SPV_ERROR_INVALID_ID, inst) @@ -310,6 +320,8 @@ bool IsTypeNullable(const std::vector& instruction, case spv::Op::OpTypeArray: case spv::Op::OpTypeMatrix: case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: case spv::Op::OpTypeVector: { auto base_type = _.FindDef(instruction[2]); return base_type && IsTypeNullable(base_type->words(), _); @@ -322,6 +334,7 @@ bool IsTypeNullable(const std::vector& instruction, } return true; } + case spv::Op::OpTypeUntypedPointerKHR: case spv::Op::OpTypePointer: if (spv::StorageClass(instruction[2]) == spv::StorageClass::PhysicalStorageBuffer) { diff --git a/third_party/spirv-tools/source/val/validate_conversion.cpp b/third_party/spirv-tools/source/val/validate_conversion.cpp index c67b19685d..c459ec384c 100644 --- a/third_party/spirv-tools/source/val/validate_conversion.cpp +++ b/third_party/spirv-tools/source/val/validate_conversion.cpp @@ -14,7 +14,6 @@ // Validates correctness of conversion instructions. -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" @@ -34,7 +33,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpConvertFToU: { if (!_.IsUnsignedIntScalarType(result_type) && !_.IsUnsignedIntVectorType(result_type) && - !_.IsUnsignedIntCooperativeMatrixType(result_type)) + !_.IsUnsignedIntCooperativeMatrixType(result_type) && + !_.IsUnsignedIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected unsigned int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -42,15 +42,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) && - !_.IsFloatCooperativeMatrixType(input_type))) + !_.IsFloatCooperativeMatrixType(input_type) && + !_.IsFloatCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be float scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -64,7 +70,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpConvertFToS: { if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && - !_.IsIntCooperativeMatrixType(result_type)) + !_.IsIntCooperativeMatrixType(result_type) && + !_.IsIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -72,15 +79,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) && - !_.IsFloatCooperativeMatrixType(input_type))) + !_.IsFloatCooperativeMatrixType(input_type) && + !_.IsFloatCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be float scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -96,7 +109,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpConvertUToF: { if (!_.IsFloatScalarType(result_type) && !_.IsFloatVectorType(result_type) && - !_.IsFloatCooperativeMatrixType(result_type)) + !_.IsFloatCooperativeMatrixType(result_type) && + !_.IsFloatCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected float scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -104,15 +118,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsIntScalarType(input_type) && !_.IsIntVectorType(input_type) && - !_.IsIntCooperativeMatrixType(input_type))) + !_.IsIntCooperativeMatrixType(input_type) && + !_.IsIntCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be int scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -127,7 +147,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpUConvert: { if (!_.IsUnsignedIntScalarType(result_type) && !_.IsUnsignedIntVectorType(result_type) && - !_.IsUnsignedIntCooperativeMatrixType(result_type)) + !_.IsUnsignedIntCooperativeMatrixType(result_type) && + !_.IsUnsignedIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected unsigned int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -135,15 +156,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsIntScalarType(input_type) && !_.IsIntVectorType(input_type) && - !_.IsIntCooperativeMatrixType(input_type))) + !_.IsIntCooperativeMatrixType(input_type) && + !_.IsIntCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be int scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -162,7 +189,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpSConvert: { if (!_.IsIntScalarType(result_type) && !_.IsIntVectorType(result_type) && - !_.IsIntCooperativeMatrixType(result_type)) + !_.IsIntCooperativeMatrixType(result_type) && + !_.IsIntCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected int scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -170,15 +198,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsIntScalarType(input_type) && !_.IsIntVectorType(input_type) && - !_.IsIntCooperativeMatrixType(input_type))) + !_.IsIntCooperativeMatrixType(input_type) && + !_.IsIntCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be int scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -198,7 +232,8 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpFConvert: { if (!_.IsFloatScalarType(result_type) && !_.IsFloatVectorType(result_type) && - !_.IsFloatCooperativeMatrixType(result_type)) + !_.IsFloatCooperativeMatrixType(result_type) && + !_.IsFloatCooperativeVectorNVType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected float scalar or vector type as Result Type: " << spvOpcodeString(opcode); @@ -206,15 +241,21 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const uint32_t input_type = _.GetOperandTypeId(inst, 2); if (!input_type || (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) && - !_.IsFloatCooperativeMatrixType(input_type))) + !_.IsFloatCooperativeMatrixType(input_type) && + !_.IsFloatCooperativeVectorNVType(input_type))) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be float scalar or vector: " << spvOpcodeString(opcode); - if (_.IsCooperativeMatrixType(result_type) || - _.IsCooperativeMatrixType(input_type)) { + if (_.IsCooperativeVectorNVType(result_type) || + _.IsCooperativeVectorNVType(input_type)) { spv_result_t ret = - _.CooperativeMatrixShapesMatch(inst, result_type, input_type); + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } else if (_.IsCooperativeMatrixType(result_type) || + _.IsCooperativeMatrixType(input_type)) { + spv_result_t ret = + _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); if (ret != SPV_SUCCESS) return ret; } else { if (_.GetDimension(result_type) != _.GetDimension(input_type)) @@ -474,21 +515,48 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { const bool input_is_pointer = _.IsPointerType(input_type); const bool input_is_int_scalar = _.IsIntScalarType(input_type); - if (!result_is_pointer && !result_is_int_scalar && - !_.IsIntVectorType(result_type) && + const bool result_is_coopmat = _.IsCooperativeMatrixType(result_type); + const bool input_is_coopmat = _.IsCooperativeMatrixType(input_type); + const bool result_is_coopvec = _.IsCooperativeVectorNVType(result_type); + const bool input_is_coopvec = _.IsCooperativeVectorNVType(input_type); + + if (!result_is_pointer && !result_is_int_scalar && !result_is_coopmat && + !result_is_coopvec && !_.IsIntVectorType(result_type) && !_.IsFloatScalarType(result_type) && !_.IsFloatVectorType(result_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Result Type to be a pointer or int or float vector " << "or scalar type: " << spvOpcodeString(opcode); - if (!input_is_pointer && !input_is_int_scalar && - !_.IsIntVectorType(input_type) && !_.IsFloatScalarType(input_type) && - !_.IsFloatVectorType(input_type)) + if (!input_is_pointer && !input_is_int_scalar && !input_is_coopmat && + !input_is_coopvec && !_.IsIntVectorType(input_type) && + !_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected input to be a pointer or int or float vector " << "or scalar: " << spvOpcodeString(opcode); + if (result_is_coopvec != input_is_coopvec) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative vector can only be cast to another cooperative " + << "vector: " << spvOpcodeString(opcode); + + if (result_is_coopmat != input_is_coopmat) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Cooperative matrix can only be cast to another cooperative " + << "matrix: " << spvOpcodeString(opcode); + + if (result_is_coopvec) { + spv_result_t ret = + _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); + if (ret != SPV_SUCCESS) return ret; + } + + if (result_is_coopmat) { + spv_result_t ret = _.CooperativeMatrixShapesMatch(inst, result_type, + input_type, false); + if (ret != SPV_SUCCESS) return ret; + } + if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 5) || _.HasExtension(kSPV_KHR_physical_storage_buffer)) { const bool result_is_int_vector = _.IsIntVectorType(result_type); @@ -555,6 +623,43 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) { break; } + case spv::Op::OpCooperativeMatrixConvertNV: + case spv::Op::OpCooperativeMatrixTransposeNV: { + if (!_.IsCooperativeMatrixType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected cooperative matrix Result Type: " + << spvOpcodeString(opcode); + } + const uint32_t input_type = _.GetOperandTypeId(inst, 2); + if (!_.IsCooperativeMatrixType(input_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected cooperative matrix type for Matrix input: " + << spvOpcodeString(opcode); + } + + bool swap_row_col = (opcode == spv::Op::OpCooperativeMatrixTransposeNV); + if (auto error = _.CooperativeMatrixShapesMatch( + inst, result_type, input_type, true, swap_row_col)) + return error; + + if (opcode == spv::Op::OpCooperativeMatrixConvertNV) { + if (_.FindDef(result_type)->GetOperandAs(1) != + _.FindDef(input_type)->GetOperandAs(1)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type and Matrix component types mismatch: " + << spvOpcodeString(opcode); + } + } + + if (opcode == spv::Op::OpCooperativeMatrixTransposeNV) { + if (!_.IsCooperativeMatrixBType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result Type must have UseB: " << spvOpcodeString(opcode); + } + } + break; + } + default: break; } diff --git a/third_party/spirv-tools/source/val/validate_debug.cpp b/third_party/spirv-tools/source/val/validate_debug.cpp index c433c939f1..ef537ea027 100644 --- a/third_party/spirv-tools/source/val/validate_debug.cpp +++ b/third_party/spirv-tools/source/val/validate_debug.cpp @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/val/validate.h" - -#include "source/opcode.h" #include "source/spirv_target_env.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/val/validate_decorations.cpp b/third_party/spirv-tools/source/val/validate_decorations.cpp index f9c843521f..256bf0f6f1 100644 --- a/third_party/spirv-tools/source/val/validate_decorations.cpp +++ b/third_party/spirv-tools/source/val/validate_decorations.cpp @@ -21,7 +21,6 @@ #include #include -#include "source/binary.h" #include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" @@ -48,13 +47,6 @@ struct PairHash { } }; -// A functor for hashing decoration types. -struct SpvDecorationHash { - std::size_t operator()(spv::Decoration dec) const { - return static_cast(dec); - } -}; - // Struct member layout attributes that are inherited through arrays. struct LayoutConstraints { explicit LayoutConstraints( @@ -79,26 +71,6 @@ uint32_t GetArrayStride(uint32_t array_id, ValidationState_t& vstate) { return 0; } -// Returns true if the given variable has a BuiltIn decoration. -bool isBuiltInVar(uint32_t var_id, ValidationState_t& vstate) { - const auto& decorations = vstate.id_decorations(var_id); - return std::any_of(decorations.begin(), decorations.end(), - [](const Decoration& d) { - return spv::Decoration::BuiltIn == d.dec_type(); - }); -} - -// Returns true if the given structure type has any members with BuiltIn -// decoration. -bool isBuiltInStruct(uint32_t struct_id, ValidationState_t& vstate) { - const auto& decorations = vstate.id_decorations(struct_id); - return std::any_of( - decorations.begin(), decorations.end(), [](const Decoration& d) { - return spv::Decoration::BuiltIn == d.dec_type() && - Decoration::kInvalidMember != d.struct_member_index(); - }); -} - // Returns true if the given structure type has a Block decoration. bool isBlock(uint32_t struct_id, ValidationState_t& vstate) { const auto& decorations = vstate.id_decorations(struct_id); @@ -197,7 +169,7 @@ uint32_t getBaseAlignment(uint32_t member_id, bool roundUp, case spv::Op::OpTypeSampler: case spv::Op::OpTypeImage: if (vstate.HasCapability(spv::Capability::BindlessTextureNV)) - return baseAlignment = vstate.samplerimage_variable_address_mode() / 8; + return vstate.samplerimage_variable_address_mode() / 8; assert(0); return 0; case spv::Op::OpTypeInt: @@ -252,6 +224,7 @@ uint32_t getBaseAlignment(uint32_t member_id, bool roundUp, break; } case spv::Op::OpTypePointer: + case spv::Op::OpTypeUntypedPointerKHR: baseAlignment = vstate.pointer_size_and_alignment(); break; default: @@ -298,6 +271,7 @@ uint32_t getScalarAlignment(uint32_t type_id, ValidationState_t& vstate) { return max_member_alignment; } break; case spv::Op::OpTypePointer: + case spv::Op::OpTypeUntypedPointerKHR: return vstate.pointer_size_and_alignment(); default: assert(0); @@ -387,6 +361,7 @@ uint32_t getSize(uint32_t member_id, const LayoutConstraints& inherited, return offset + getSize(lastMember, constraint, constraints, vstate); } case spv::Op::OpTypePointer: + case spv::Op::OpTypeUntypedPointerKHR: return vstate.pointer_size_and_alignment(); default: assert(0); @@ -460,7 +435,16 @@ spv_result_t checkLayout(uint32_t struct_id, const char* storage_class_str, return ds; }; - const auto& members = getStructMembers(struct_id, vstate); + // If we are checking the layout of untyped pointers or physical storage + // buffer pointers, we may not actually have a struct here. Instead, pretend + // we have a struct with a single member at offset 0. + const auto& struct_type = vstate.FindDef(struct_id); + std::vector members; + if (struct_type->opcode() == spv::Op::OpTypeStruct) { + members = getStructMembers(struct_id, vstate); + } else { + members.push_back(struct_id); + } // To check for member overlaps, we want to traverse the members in // offset order. @@ -469,31 +453,38 @@ spv_result_t checkLayout(uint32_t struct_id, const char* storage_class_str, uint32_t offset; }; std::vector member_offsets; - member_offsets.reserve(members.size()); - for (uint32_t memberIdx = 0, numMembers = uint32_t(members.size()); - memberIdx < numMembers; memberIdx++) { - uint32_t offset = 0xffffffff; - auto member_decorations = - vstate.id_member_decorations(struct_id, memberIdx); - for (auto decoration = member_decorations.begin; - decoration != member_decorations.end; ++decoration) { - assert(decoration->struct_member_index() == (int)memberIdx); - switch (decoration->dec_type()) { - case spv::Decoration::Offset: - offset = decoration->params()[0]; - break; - default: - break; + + // With untyped pointers or physical storage buffers, we might be checking + // layouts that do not originate from a structure. + if (struct_type->opcode() == spv::Op::OpTypeStruct) { + member_offsets.reserve(members.size()); + for (uint32_t memberIdx = 0, numMembers = uint32_t(members.size()); + memberIdx < numMembers; memberIdx++) { + uint32_t offset = 0xffffffff; + auto member_decorations = + vstate.id_member_decorations(struct_id, memberIdx); + for (auto decoration = member_decorations.begin; + decoration != member_decorations.end; ++decoration) { + assert(decoration->struct_member_index() == (int)memberIdx); + switch (decoration->dec_type()) { + case spv::Decoration::Offset: + offset = decoration->params()[0]; + break; + default: + break; + } } + member_offsets.push_back( + MemberOffsetPair{memberIdx, incoming_offset + offset}); } - member_offsets.push_back( - MemberOffsetPair{memberIdx, incoming_offset + offset}); + std::stable_sort( + member_offsets.begin(), member_offsets.end(), + [](const MemberOffsetPair& lhs, const MemberOffsetPair& rhs) { + return lhs.offset < rhs.offset; + }); + } else { + member_offsets.push_back({0, 0}); } - std::stable_sort( - member_offsets.begin(), member_offsets.end(), - [](const MemberOffsetPair& lhs, const MemberOffsetPair& rhs) { - return lhs.offset < rhs.offset; - }); // Now scan from lowest offset to highest offset. uint32_t nextValidOffset = 0; @@ -615,6 +606,14 @@ spv_result_t checkLayout(uint32_t struct_id, const char* storage_class_str, seen[next_offset % 16] = true; } + } else if (spv::Op::OpTypeMatrix == element_inst->opcode()) { + // Matrix stride would be on the array element in the struct. + const auto stride = constraint.matrix_stride; + if (!IsAlignedTo(stride, alignment)) { + return fail(memberIdx) + << "is a matrix with stride " << stride + << " not satisfying alignment to " << alignment; + } } // Proceed to the element in case it is an array. @@ -667,7 +666,16 @@ bool checkForRequiredDecoration(uint32_t struct_id, spv::Op type, ValidationState_t& vstate) { const auto& members = getStructMembers(struct_id, vstate); for (size_t memberIdx = 0; memberIdx < members.size(); memberIdx++) { - const auto id = members[memberIdx]; + auto id = members[memberIdx]; + if (type == spv::Op::OpTypeMatrix) { + // Matrix decorations also apply to arrays of matrices. + auto memberInst = vstate.FindDef(id); + while (memberInst->opcode() == spv::Op::OpTypeArray || + memberInst->opcode() == spv::Op::OpTypeRuntimeArray) { + memberInst = vstate.FindDef(memberInst->GetOperandAs(1u)); + } + id = memberInst->id(); + } if (type != vstate.FindDef(id)->opcode()) continue; bool found = false; for (auto& dec : vstate.id_decorations(id)) { @@ -759,18 +767,39 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { int num_workgroup_variables = 0; int num_workgroup_variables_with_block = 0; int num_workgroup_variables_with_aliased = 0; + bool has_task_payload = false; for (const auto& desc : descs) { std::unordered_set seen_vars; + std::unordered_set input_var_builtin; + std::unordered_set output_var_builtin; for (auto interface : desc.interfaces) { Instruction* var_instr = vstate.FindDef(interface); - if (!var_instr || spv::Op::OpVariable != var_instr->opcode()) { + if (!var_instr || + (spv::Op::OpVariable != var_instr->opcode() && + spv::Op::OpUntypedVariableKHR != var_instr->opcode())) { return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) - << "Interfaces passed to OpEntryPoint must be of type " - "OpTypeVariable. Found Op" + << "Interfaces passed to OpEntryPoint must be variables. " + "Found Op" << spvOpcodeString(var_instr->opcode()) << "."; } + const bool untyped_pointers = + var_instr->opcode() == spv::Op::OpUntypedVariableKHR; + const auto sc_index = 2u; const spv::StorageClass storage_class = - var_instr->GetOperandAs(2); + var_instr->GetOperandAs(sc_index); + if (vstate.version() >= SPV_SPIRV_VERSION_WORD(1, 4)) { + // SPV_EXT_mesh_shader, at most one task payload is permitted + // per entry point + if (storage_class == spv::StorageClass::TaskPayloadWorkgroupEXT) { + if (has_task_payload) { + return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) + << "There can be at most one OpVariable with storage " + "class TaskPayloadWorkgroupEXT associated with " + "an OpEntryPoint"; + } + has_task_payload = true; + } + } if (vstate.version() >= SPV_SPIRV_VERSION_WORD(1, 4)) { // Starting in 1.4, OpEntryPoint must list all global variables // it statically uses and those interfaces must be unique. @@ -797,45 +826,96 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { } } - const uint32_t ptr_id = var_instr->word(1); - Instruction* ptr_instr = vstate.FindDef(ptr_id); // It is guaranteed (by validator ID checks) that ptr_instr is // OpTypePointer. Word 3 of this instruction is the type being pointed - // to. - const uint32_t type_id = ptr_instr->word(3); + // to. For untyped variables, the pointee type comes from the data type + // operand. + const uint32_t type_id = + untyped_pointers ? var_instr->word(4) + : vstate.FindDef(var_instr->word(1))->word(3); Instruction* type_instr = vstate.FindDef(type_id); - if (type_instr && spv::Op::OpTypeStruct == type_instr->opcode() && - isBuiltInStruct(type_id, vstate)) { - if (!isBlock(type_id, vstate)) { - return vstate.diag(SPV_ERROR_INVALID_DATA, vstate.FindDef(type_id)) - << vstate.VkErrorID(4919) - << "Interface struct has no Block decoration but has " - "BuiltIn members. " - "Location decorations must be used on each member of " - "OpVariable with a structure type that is a block not " - "decorated with Location."; + const bool is_struct = + type_instr && spv::Op::OpTypeStruct == type_instr->opcode(); + + // Search all Built-in (on the variable or the struct) + bool has_built_in = false; + for (auto& dec : + vstate.id_decorations(is_struct ? type_id : interface)) { + if (dec.dec_type() != spv::Decoration::BuiltIn) continue; + has_built_in = true; + + if (!spvIsVulkanEnv(vstate.context()->target_env)) continue; + + const spv::BuiltIn builtin = dec.builtin(); + if (storage_class == spv::StorageClass::Input) { + if (!input_var_builtin.insert(builtin).second) { + return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) + << vstate.VkErrorID(9658) + << "OpEntryPoint contains duplicate input variables " + "with " + << vstate.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, (uint32_t)builtin) + << " builtin"; + } } - if (storage_class == spv::StorageClass::Input) - ++num_builtin_block_inputs; - if (storage_class == spv::StorageClass::Output) - ++num_builtin_block_outputs; - if (num_builtin_block_inputs > 1 || num_builtin_block_outputs > 1) - break; - if (auto error = CheckBuiltInVariable(interface, vstate)) - return error; - } else if (isBuiltInVar(interface, vstate)) { + if (storage_class == spv::StorageClass::Output) { + if (!output_var_builtin.insert(builtin).second) { + return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) + << vstate.VkErrorID(9659) + << "OpEntryPoint contains duplicate output variables " + "with " + << vstate.grammar().lookupOperandName( + SPV_OPERAND_TYPE_BUILT_IN, (uint32_t)builtin) + << " builtin"; + } + } + } + + if (has_built_in) { if (auto error = CheckBuiltInVariable(interface, vstate)) return error; + + if (is_struct) { + if (!isBlock(type_id, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_DATA, + vstate.FindDef(type_id)) + << vstate.VkErrorID(4919) + << "Interface struct has no Block decoration but has " + "BuiltIn members. " + "Location decorations must be used on each member of " + "OpVariable with a structure type that is a block not " + "decorated with Location."; + } + if (storage_class == spv::StorageClass::Input) + ++num_builtin_block_inputs; + if (storage_class == spv::StorageClass::Output) + ++num_builtin_block_outputs; + if (num_builtin_block_inputs > 1 || num_builtin_block_outputs > 1) + break; + } } if (storage_class == spv::StorageClass::Workgroup) { ++num_workgroup_variables; - if (type_instr && spv::Op::OpTypeStruct == type_instr->opcode()) { - if (hasDecoration(type_id, spv::Decoration::Block, vstate)) - ++num_workgroup_variables_with_block; - if (hasDecoration(var_instr->id(), spv::Decoration::Aliased, - vstate)) - ++num_workgroup_variables_with_aliased; + if (type_instr) { + if (spv::Op::OpTypeStruct == type_instr->opcode()) { + if (hasDecoration(type_id, spv::Decoration::Block, vstate)) { + ++num_workgroup_variables_with_block; + } else if (untyped_pointers && + vstate.HasCapability(spv::Capability::Shader)) { + return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) + << "Untyped workgroup variables in shaders must be " + "block decorated"; + } + if (hasDecoration(var_instr->id(), spv::Decoration::Aliased, + vstate)) + ++num_workgroup_variables_with_aliased; + } else if (untyped_pointers && + vstate.HasCapability(spv::Capability::Shader)) { + return vstate.diag(SPV_ERROR_INVALID_ID, var_instr) + << "Untyped workgroup variables in shaders must be block " + "decorated structs"; + } } } @@ -914,29 +994,44 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) { } } - if (vstate.HasCapability( - spv::Capability::WorkgroupMemoryExplicitLayoutKHR) && + const bool workgroup_blocks_allowed = vstate.HasCapability( + spv::Capability::WorkgroupMemoryExplicitLayoutKHR); + if (workgroup_blocks_allowed && + !vstate.HasCapability(spv::Capability::UntypedPointersKHR) && num_workgroup_variables > 0 && num_workgroup_variables_with_block > 0) { if (num_workgroup_variables != num_workgroup_variables_with_block) { - return vstate.diag(SPV_ERROR_INVALID_BINARY, vstate.FindDef(entry_point)) + return vstate.diag(SPV_ERROR_INVALID_BINARY, + vstate.FindDef(entry_point)) << "When declaring WorkgroupMemoryExplicitLayoutKHR, " - "either all or none of the Workgroup Storage Class variables " + "either all or none of the Workgroup Storage Class " + "variables " "in the entry point interface must point to struct types " - "decorated with Block. Entry point id " + "decorated with Block (unless the " + "UntypedPointersKHR capability is declared). " + "Entry point id " << entry_point << " does not meet this requirement."; } if (num_workgroup_variables_with_block > 1 && num_workgroup_variables_with_block != num_workgroup_variables_with_aliased) { - return vstate.diag(SPV_ERROR_INVALID_BINARY, vstate.FindDef(entry_point)) + return vstate.diag(SPV_ERROR_INVALID_BINARY, + vstate.FindDef(entry_point)) << "When declaring WorkgroupMemoryExplicitLayoutKHR, " "if more than one Workgroup Storage Class variable in " "the entry point interface point to a type decorated " - "with Block, all of them must be decorated with Aliased. " - "Entry point id " + "with Block, all of them must be decorated with Aliased " + "(unless the UntypedPointerWorkgroupKHR capability is " + "declared). Entry point id " << entry_point << " does not meet this requirement."; } + } else if (!workgroup_blocks_allowed && + num_workgroup_variables_with_block > 0) { + return vstate.diag(SPV_ERROR_INVALID_BINARY, + vstate.FindDef(entry_point)) + << "Workgroup Storage Class variables can't be decorated with " + "Block unless declaring the WorkgroupMemoryExplicitLayoutKHR " + "capability."; } } } @@ -1031,11 +1126,19 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { std::unordered_set uses_push_constant; for (const auto& inst : vstate.ordered_instructions()) { const auto& words = inst.words(); - if (spv::Op::OpVariable == inst.opcode()) { + auto type_id = inst.type_id(); + const Instruction* type_inst = vstate.FindDef(type_id); + bool scalar_block_layout = false; + MemberConstraints constraints; + if (spv::Op::OpVariable == inst.opcode() || + spv::Op::OpUntypedVariableKHR == inst.opcode()) { + const bool untyped_pointer = + inst.opcode() == spv::Op::OpUntypedVariableKHR; const auto var_id = inst.id(); // For storage class / decoration combinations, see Vulkan 14.5.4 "Offset // and Stride Assignment". - const auto storageClass = inst.GetOperandAs(2); + const auto storageClassVal = words[3]; + const auto storageClass = spv::StorageClass(storageClassVal); const bool uniform = storageClass == spv::StorageClass::Uniform; const bool uniform_constant = storageClass == spv::StorageClass::UniformConstant; @@ -1114,20 +1217,24 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { if (uniform || push_constant || storage_buffer || phys_storage_buffer || workgroup) { const auto ptrInst = vstate.FindDef(words[1]); - assert(spv::Op::OpTypePointer == ptrInst->opcode()); - auto id = ptrInst->words()[3]; - auto id_inst = vstate.FindDef(id); - // Jump through one level of arraying. - if (!workgroup && (id_inst->opcode() == spv::Op::OpTypeArray || - id_inst->opcode() == spv::Op::OpTypeRuntimeArray)) { - id = id_inst->GetOperandAs(1u); - id_inst = vstate.FindDef(id); + assert(spv::Op::OpTypePointer == ptrInst->opcode() || + spv::Op::OpTypeUntypedPointerKHR == ptrInst->opcode()); + auto id = untyped_pointer ? (words.size() > 4 ? words[4] : 0) + : ptrInst->words()[3]; + if (id != 0) { + auto id_inst = vstate.FindDef(id); + // Jump through one level of arraying. + if (!workgroup && + (id_inst->opcode() == spv::Op::OpTypeArray || + id_inst->opcode() == spv::Op::OpTypeRuntimeArray)) { + id = id_inst->GetOperandAs(1u); + id_inst = vstate.FindDef(id); + } + // Struct requirement is checked on variables so just move on here. + if (spv::Op::OpTypeStruct != id_inst->opcode()) continue; + ComputeMemberConstraintsForStruct(&constraints, id, + LayoutConstraints(), vstate); } - // Struct requirement is checked on variables so just move on here. - if (spv::Op::OpTypeStruct != id_inst->opcode()) continue; - MemberConstraints constraints; - ComputeMemberConstraintsForStruct(&constraints, id, LayoutConstraints(), - vstate); // Prepare for messages const char* sc_str = uniform ? "Uniform" @@ -1197,93 +1304,209 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { } } - for (const auto& dec : vstate.id_decorations(id)) { - const bool blockDeco = spv::Decoration::Block == dec.dec_type(); - const bool bufferDeco = - spv::Decoration::BufferBlock == dec.dec_type(); - const bool blockRules = uniform && blockDeco; - const bool bufferRules = - (uniform && bufferDeco) || - ((push_constant || storage_buffer || - phys_storage_buffer || workgroup) && blockDeco); - if (uniform && blockDeco) { - vstate.RegisterPointerToUniformBlock(ptrInst->id()); - vstate.RegisterStructForUniformBlock(id); - } - if ((uniform && bufferDeco) || - ((storage_buffer || phys_storage_buffer) && blockDeco)) { - vstate.RegisterPointerToStorageBuffer(ptrInst->id()); - vstate.RegisterStructForStorageBuffer(id); - } - - if (blockRules || bufferRules) { - const char* deco_str = blockDeco ? "Block" : "BufferBlock"; - spv_result_t recursive_status = SPV_SUCCESS; - const bool scalar_block_layout = workgroup ? - vstate.options()->workgroup_scalar_block_layout : - vstate.options()->scalar_block_layout; - - if (isMissingOffsetInStruct(id, vstate)) { - return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "Structure id " << id << " decorated as " << deco_str - << " must be explicitly laid out with Offset " - "decorations."; + if (id != 0) { + for (const auto& dec : vstate.id_decorations(id)) { + const bool blockDeco = spv::Decoration::Block == dec.dec_type(); + const bool bufferDeco = + spv::Decoration::BufferBlock == dec.dec_type(); + const bool blockRules = uniform && blockDeco; + const bool bufferRules = (uniform && bufferDeco) || + ((push_constant || storage_buffer || + phys_storage_buffer || workgroup) && + blockDeco); + if (uniform && blockDeco) { + vstate.RegisterPointerToUniformBlock(ptrInst->id()); + vstate.RegisterStructForUniformBlock(id); + } + if ((uniform && bufferDeco) || + ((storage_buffer || phys_storage_buffer) && blockDeco)) { + vstate.RegisterPointerToStorageBuffer(ptrInst->id()); + vstate.RegisterStructForStorageBuffer(id); } - if (!checkForRequiredDecoration( - id, - [](spv::Decoration d) { - return d == spv::Decoration::ArrayStride; - }, - spv::Op::OpTypeArray, vstate)) { - return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "Structure id " << id << " decorated as " << deco_str - << " must be explicitly laid out with ArrayStride " - "decorations."; - } + if (blockRules || bufferRules) { + const char* deco_str = blockDeco ? "Block" : "BufferBlock"; + spv_result_t recursive_status = SPV_SUCCESS; + scalar_block_layout = + workgroup ? vstate.options()->workgroup_scalar_block_layout + : vstate.options()->scalar_block_layout; - if (!checkForRequiredDecoration( - id, - [](spv::Decoration d) { - return d == spv::Decoration::MatrixStride; - }, - spv::Op::OpTypeMatrix, vstate)) { - return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "Structure id " << id << " decorated as " << deco_str - << " must be explicitly laid out with MatrixStride " - "decorations."; - } + if (isMissingOffsetInStruct(id, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) + << "Structure id " << id << " decorated as " << deco_str + << " must be explicitly laid out with Offset " + "decorations."; + } - if (!checkForRequiredDecoration( - id, - [](spv::Decoration d) { - return d == spv::Decoration::RowMajor || - d == spv::Decoration::ColMajor; - }, - spv::Op::OpTypeMatrix, vstate)) { - return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) - << "Structure id " << id << " decorated as " << deco_str - << " must be explicitly laid out with RowMajor or " - "ColMajor decorations."; - } + if (!checkForRequiredDecoration( + id, + [](spv::Decoration d) { + return d == spv::Decoration::ArrayStride; + }, + spv::Op::OpTypeArray, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) + << "Structure id " << id << " decorated as " << deco_str + << " must be explicitly laid out with ArrayStride " + "decorations."; + } - if (spvIsVulkanEnv(vstate.context()->target_env)) { - if (blockRules && (SPV_SUCCESS != (recursive_status = checkLayout( - id, sc_str, deco_str, true, + if (!checkForRequiredDecoration( + id, + [](spv::Decoration d) { + return d == spv::Decoration::MatrixStride; + }, + spv::Op::OpTypeMatrix, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) + << "Structure id " << id << " decorated as " << deco_str + << " must be explicitly laid out with MatrixStride " + "decorations."; + } + + if (!checkForRequiredDecoration( + id, + [](spv::Decoration d) { + return d == spv::Decoration::RowMajor || + d == spv::Decoration::ColMajor; + }, + spv::Op::OpTypeMatrix, vstate)) { + return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id)) + << "Structure id " << id << " decorated as " << deco_str + << " must be explicitly laid out with RowMajor or " + "ColMajor decorations."; + } + + if (spvIsVulkanEnv(vstate.context()->target_env)) { + if (blockRules && + (SPV_SUCCESS != + (recursive_status = checkLayout(id, sc_str, deco_str, true, scalar_block_layout, 0, constraints, vstate)))) { - return recursive_status; - } else if (bufferRules && - (SPV_SUCCESS != - (recursive_status = checkLayout( - id, sc_str, deco_str, false, scalar_block_layout, - 0, constraints, vstate)))) { - return recursive_status; + return recursive_status; + } else if (bufferRules && + (SPV_SUCCESS != (recursive_status = checkLayout( + id, sc_str, deco_str, false, + scalar_block_layout, 0, + constraints, vstate)))) { + return recursive_status; + } } } } } } + } else if (type_inst && type_inst->opcode() == spv::Op::OpTypePointer && + type_inst->GetOperandAs(1u) == + spv::StorageClass::PhysicalStorageBuffer) { + const bool buffer = true; + const auto pointee_type_id = type_inst->GetOperandAs(2u); + const auto* data_type_inst = vstate.FindDef(pointee_type_id); + scalar_block_layout = vstate.options()->scalar_block_layout; + if (data_type_inst->opcode() == spv::Op::OpTypeStruct) { + ComputeMemberConstraintsForStruct(&constraints, pointee_type_id, + LayoutConstraints(), vstate); + } + if (auto res = checkLayout(pointee_type_id, "PhysicalStorageBuffer", + "Block", !buffer, scalar_block_layout, 0, + constraints, vstate)) { + return res; + } + } else if (vstate.HasCapability(spv::Capability::UntypedPointersKHR) && + spvIsVulkanEnv(vstate.context()->target_env)) { + // Untyped variables are checked above. Here we check that instructions + // using an untyped pointer have a valid layout. + uint32_t ptr_ty_id = 0; + uint32_t data_type_id = 0; + switch (inst.opcode()) { + case spv::Op::OpUntypedAccessChainKHR: + case spv::Op::OpUntypedInBoundsAccessChainKHR: + case spv::Op::OpUntypedPtrAccessChainKHR: + case spv::Op::OpUntypedInBoundsPtrAccessChainKHR: + ptr_ty_id = inst.type_id(); + data_type_id = inst.GetOperandAs(2); + break; + case spv::Op::OpLoad: + if (vstate.GetIdOpcode(vstate.GetOperandTypeId(&inst, 2)) == + spv::Op::OpTypeUntypedPointerKHR) { + const auto ptr_id = inst.GetOperandAs(2); + ptr_ty_id = vstate.FindDef(ptr_id)->type_id(); + data_type_id = inst.type_id(); + } + break; + case spv::Op::OpStore: + if (vstate.GetIdOpcode(vstate.GetOperandTypeId(&inst, 0)) == + spv::Op::OpTypeUntypedPointerKHR) { + const auto ptr_id = inst.GetOperandAs(0); + ptr_ty_id = vstate.FindDef(ptr_id)->type_id(); + data_type_id = vstate.GetOperandTypeId(&inst, 1); + } + break; + case spv::Op::OpUntypedArrayLengthKHR: + ptr_ty_id = vstate.FindDef(inst.GetOperandAs(3))->type_id(); + data_type_id = inst.GetOperandAs(2); + break; + default: + break; + } + + if (ptr_ty_id == 0 || data_type_id == 0) { + // Not an untyped pointer. + continue; + } + + const auto sc = + vstate.FindDef(ptr_ty_id)->GetOperandAs(1); + + const char* sc_str = + sc == spv::StorageClass::Uniform + ? "Uniform" + : (sc == spv::StorageClass::PushConstant + ? "PushConstant" + : (sc == spv::StorageClass::Workgroup ? "Workgroup" + : "StorageBuffer")); + + auto data_type = vstate.FindDef(data_type_id); + scalar_block_layout = + sc == spv::StorageClass::Workgroup + ? vstate.options()->workgroup_scalar_block_layout + : vstate.options()->scalar_block_layout; + + // If the data type is an array that contains a Block- or + // BufferBlock-decorated struct, then use the struct for layout checks + // instead of the array. In this case, the array represents a descriptor + // array which should not have an explicit layout. + if (data_type->opcode() == spv::Op::OpTypeArray || + data_type->opcode() == spv::Op::OpTypeRuntimeArray) { + const auto ele_type = + vstate.FindDef(data_type->GetOperandAs(1u)); + if (ele_type->opcode() == spv::Op::OpTypeStruct && + (vstate.HasDecoration(ele_type->id(), spv::Decoration::Block) || + vstate.HasDecoration(ele_type->id(), + spv::Decoration::BufferBlock))) { + data_type = ele_type; + data_type_id = ele_type->id(); + } + } + + // Assume uniform storage class uses block rules unless we see a + // BufferBlock decorated struct in the data type. + bool bufferRules = sc == spv::StorageClass::Uniform ? false : true; + if (data_type->opcode() == spv::Op::OpTypeStruct) { + if (sc == spv::StorageClass::Uniform) { + bufferRules = + vstate.HasDecoration(data_type_id, spv::Decoration::BufferBlock); + } + ComputeMemberConstraintsForStruct(&constraints, data_type_id, + LayoutConstraints(), vstate); + } + const char* deco_str = + bufferRules + ? (sc == spv::StorageClass::Uniform ? "BufferBlock" : "Block") + : "Block"; + if (auto result = + checkLayout(data_type_id, sc_str, deco_str, !bufferRules, + scalar_block_layout, 0, constraints, vstate)) { + return result; + } } } return SPV_SUCCESS; @@ -1291,21 +1514,14 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) { // Returns true if |decoration| cannot be applied to the same id more than once. bool AtMostOncePerId(spv::Decoration decoration) { - return decoration == spv::Decoration::ArrayStride; + return decoration != spv::Decoration::UserSemantic && + decoration != spv::Decoration::FuncParamAttr; } // Returns true if |decoration| cannot be applied to the same member more than // once. bool AtMostOncePerMember(spv::Decoration decoration) { - switch (decoration) { - case spv::Decoration::Offset: - case spv::Decoration::MatrixStride: - case spv::Decoration::RowMajor: - case spv::Decoration::ColMajor: - return true; - default: - return false; - } + return decoration != spv::Decoration::UserSemantic; } spv_result_t CheckDecorationsCompatibility(ValidationState_t& vstate) { @@ -1316,7 +1532,8 @@ spv_result_t CheckDecorationsCompatibility(ValidationState_t& vstate) { // to the same id. static const spv::Decoration mutually_exclusive_per_id[][2] = { {spv::Decoration::Block, spv::Decoration::BufferBlock}, - {spv::Decoration::Restrict, spv::Decoration::Aliased}}; + {spv::Decoration::Restrict, spv::Decoration::Aliased}, + {spv::Decoration::RestrictPointer, spv::Decoration::AliasedPointer}}; static const auto num_mutually_exclusive_per_id_pairs = sizeof(mutually_exclusive_per_id) / (2 * sizeof(spv::Decoration)); @@ -1522,23 +1739,29 @@ spv_result_t CheckNonWritableDecoration(ValidationState_t& vstate, const auto opcode = inst.opcode(); const auto type_id = inst.type_id(); if (opcode != spv::Op::OpVariable && - opcode != spv::Op::OpFunctionParameter) { + opcode != spv::Op::OpUntypedVariableKHR && + opcode != spv::Op::OpFunctionParameter && + opcode != spv::Op::OpRawAccessChainNV) { return vstate.diag(SPV_ERROR_INVALID_ID, &inst) << "Target of NonWritable decoration must be a memory object " "declaration (a variable or a function parameter)"; } - const auto var_storage_class = opcode == spv::Op::OpVariable - ? inst.GetOperandAs(2) - : spv::StorageClass::Max; + const auto var_storage_class = + opcode == spv::Op::OpVariable + ? inst.GetOperandAs(2) + : opcode == spv::Op::OpUntypedVariableKHR + ? inst.GetOperandAs(3) + : spv::StorageClass::Max; if ((var_storage_class == spv::StorageClass::Function || var_storage_class == spv::StorageClass::Private) && vstate.features().nonwritable_var_in_function_or_private) { // New permitted feature in SPIR-V 1.4. } else if ( - // It may point to a UBO, SSBO, or storage image. + // It may point to a UBO, SSBO, storage image, or raw access chain. vstate.IsPointerToUniformBlock(type_id) || vstate.IsPointerToStorageBuffer(type_id) || - vstate.IsPointerToStorageImage(type_id)) { + vstate.IsPointerToStorageImage(type_id) || + opcode == spv::Op::OpRawAccessChainNV) { } else { return vstate.diag(SPV_ERROR_INVALID_ID, &inst) << "Target of NonWritable decoration is invalid: must point to a " @@ -1619,6 +1842,7 @@ spv_result_t CheckIntegerWrapDecoration(ValidationState_t& vstate, case spv::Op::OpSNegate: return SPV_SUCCESS; case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: // TODO(dneto): Only certain extended instructions allow these // decorations. For now allow anything. return SPV_SUCCESS; @@ -1685,7 +1909,7 @@ spv_result_t CheckComponentDecoration(ValidationState_t& vstate, if (spvIsVulkanEnv(vstate.context()->target_env)) { // Strip the array, if present. - if (vstate.GetIdOpcode(type_id) == spv::Op::OpTypeArray) { + while (vstate.GetIdOpcode(type_id) == spv::Op::OpTypeArray) { type_id = vstate.FindDef(type_id)->word(2u); } diff --git a/third_party/spirv-tools/source/val/validate_derivatives.cpp b/third_party/spirv-tools/source/val/validate_derivatives.cpp index d87240f606..1a473ba880 100644 --- a/third_party/spirv-tools/source/val/validate_derivatives.cpp +++ b/third_party/spirv-tools/source/val/validate_derivatives.cpp @@ -14,13 +14,11 @@ // Validates correctness of derivative SPIR-V instructions. -#include "source/val/validate.h" - #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { @@ -62,12 +60,14 @@ spv_result_t DerivativesPass(ValidationState_t& _, const Instruction* inst) { ->RegisterExecutionModelLimitation([opcode](spv::ExecutionModel model, std::string* message) { if (model != spv::ExecutionModel::Fragment && - model != spv::ExecutionModel::GLCompute) { + model != spv::ExecutionModel::GLCompute && + model != spv::ExecutionModel::MeshEXT && + model != spv::ExecutionModel::TaskEXT) { if (message) { *message = std::string( - "Derivative instructions require Fragment or GLCompute " - "execution model: ") + + "Derivative instructions require Fragment, GLCompute, " + "MeshEXT or TaskEXT execution model: ") + spvOpcodeString(opcode); } return false; @@ -81,19 +81,23 @@ spv_result_t DerivativesPass(ValidationState_t& _, const Instruction* inst) { const auto* models = state.GetExecutionModels(entry_point->id()); const auto* modes = state.GetExecutionModes(entry_point->id()); if (models && - models->find(spv::ExecutionModel::GLCompute) != models->end() && + (models->find(spv::ExecutionModel::GLCompute) != + models->end() || + models->find(spv::ExecutionModel::MeshEXT) != models->end() || + models->find(spv::ExecutionModel::TaskEXT) != models->end()) && (!modes || - (modes->find(spv::ExecutionMode::DerivativeGroupLinearNV) == + (modes->find(spv::ExecutionMode::DerivativeGroupLinearKHR) == modes->end() && - modes->find(spv::ExecutionMode::DerivativeGroupQuadsNV) == + modes->find(spv::ExecutionMode::DerivativeGroupQuadsKHR) == modes->end()))) { if (message) { - *message = std::string( - "Derivative instructions require " - "DerivativeGroupQuadsNV " - "or DerivativeGroupLinearNV execution mode for " - "GLCompute execution model: ") + - spvOpcodeString(opcode); + *message = + std::string( + "Derivative instructions require " + "DerivativeGroupQuadsKHR " + "or DerivativeGroupLinearKHR execution mode for " + "GLCompute, MeshEXT or TaskEXT execution model: ") + + spvOpcodeString(opcode); } return false; } diff --git a/third_party/spirv-tools/source/val/validate_execution_limitations.cpp b/third_party/spirv-tools/source/val/validate_execution_limitations.cpp index 00c6603581..0221d7ef20 100644 --- a/third_party/spirv-tools/source/val/validate_execution_limitations.cpp +++ b/third_party/spirv-tools/source/val/validate_execution_limitations.cpp @@ -13,8 +13,6 @@ // limitations under the License. #include "source/val/validate.h" - -#include "source/val/function.h" #include "source/val/validation_state.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/val/validate_extensions.cpp b/third_party/spirv-tools/source/val/validate_extensions.cpp index ebb13cfd42..af64e6a950 100644 --- a/third_party/spirv-tools/source/val/validate_extensions.cpp +++ b/third_party/spirv-tools/source/val/validate_extensions.cpp @@ -18,27 +18,37 @@ #include #include -#include "spirv/unified1/NonSemanticClspvReflection.h" - #include "NonSemanticShaderDebugInfo100.h" #include "OpenCLDebugInfo100.h" #include "source/common_debug_info.h" -#include "source/diagnostic.h" #include "source/enum_string_mapping.h" #include "source/extensions.h" #include "source/latest_version_glsl_std_450_header.h" #include "source/latest_version_opencl_std_header.h" -#include "source/opcode.h" #include "source/spirv_constant.h" -#include "source/spirv_target_env.h" #include "source/val/instruction.h" #include "source/val/validate.h" #include "source/val/validation_state.h" +#include "spirv/unified1/NonSemanticClspvReflection.h" namespace spvtools { namespace val { namespace { +std::string ReflectionInstructionName(ValidationState_t& _, + const Instruction* inst) { + spv_ext_inst_desc desc = nullptr; + if (_.grammar().lookupExtInst(SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION, + inst->word(4), &desc) != SPV_SUCCESS || + !desc) { + return std::string("Unknown ExtInst"); + } + std::ostringstream ss; + ss << desc->name; + + return ss.str(); +} + uint32_t GetSizeTBitWidth(const ValidationState_t& _) { if (_.addressing_model() == spv::AddressingModel::Physical32) return 32; @@ -137,7 +147,7 @@ bool DoesDebugInfoOperandMatchExpectation( const Instruction* inst, uint32_t word_index) { if (inst->words().size() <= word_index) return false; auto* debug_inst = _.FindDef(inst->word(word_index)); - if (debug_inst->opcode() != spv::Op::OpExtInst || + if (!spvIsExtendedInstruction(debug_inst->opcode()) || (debug_inst->ext_inst_type() != SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 && debug_inst->ext_inst_type() != SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) || @@ -155,7 +165,7 @@ bool DoesDebugInfoOperandMatchExpectation( const Instruction* inst, uint32_t word_index) { if (inst->words().size() <= word_index) return false; auto* debug_inst = _.FindDef(inst->word(word_index)); - if (debug_inst->opcode() != spv::Op::OpExtInst || + if (!spvIsExtendedInstruction(debug_inst->opcode()) || (debug_inst->ext_inst_type() != SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100) || !expectation( @@ -273,12 +283,14 @@ spv_result_t ValidateOperandDebugType( } spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, - const Instruction* inst) { + const Instruction* inst, + uint32_t version) { + const auto inst_name = ReflectionInstructionName(_, inst); const auto kernel_id = inst->GetOperandAs(4); const auto kernel = _.FindDef(kernel_id); if (kernel->opcode() != spv::Op::OpFunction) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference a function"; + << inst_name << " does not reference a function"; } bool found_kernel = false; @@ -290,18 +302,18 @@ spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, } if (!found_kernel) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference an entry-point"; + << inst_name << " does not reference an entry-point"; } const auto* exec_models = _.GetExecutionModels(kernel_id); if (!exec_models || exec_models->empty()) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference an entry-point"; + << inst_name << " does not reference an entry-point"; } for (auto exec_model : *exec_models) { if (exec_model != spv::ExecutionModel::GLCompute) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel must refer only to GLCompute entry-points"; + << inst_name << " must refer only to GLCompute entry-points"; } } @@ -323,6 +335,37 @@ spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, << "Name must match an entry-point for Kernel"; } + const auto num_operands = inst->operands().size(); + if (version < 5 && num_operands > 6) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Version " << version << " of the " << inst_name + << " instruction can only have 2 additional operands"; + } + + if (num_operands > 6) { + const auto num_args_id = inst->GetOperandAs(6); + if (!IsUint32Constant(_, num_args_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "NumArguments must be a 32-bit unsigned integer OpConstant"; + } + } + + if (num_operands > 7) { + const auto flags_id = inst->GetOperandAs(7); + if (!IsUint32Constant(_, flags_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Flags must be a 32-bit unsigned integer OpConstant"; + } + } + + if (num_operands > 8) { + const auto atts_id = inst->GetOperandAs(8); + if (_.GetIdOpcode(atts_id) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Attributes must be an OpString"; + } + } + return SPV_SUCCESS; } @@ -366,7 +409,7 @@ spv_result_t ValidateClspvReflectionArgumentInfo(ValidationState_t& _, spv_result_t ValidateKernelDecl(ValidationState_t& _, const Instruction* inst) { const auto decl_id = inst->GetOperandAs(4); const auto decl = _.FindDef(decl_id); - if (!decl || decl->opcode() != spv::Op::OpExtInst) { + if (!decl || !spvIsExtendedInstruction(decl->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Kernel must be a Kernel extended instruction"; } @@ -389,7 +432,7 @@ spv_result_t ValidateKernelDecl(ValidationState_t& _, const Instruction* inst) { spv_result_t ValidateArgInfo(ValidationState_t& _, const Instruction* inst, uint32_t info_index) { auto info = _.FindDef(inst->GetOperandAs(info_index)); - if (!info || info->opcode() != spv::Op::OpExtInst) { + if (!info || !spvIsExtendedInstruction(info->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "ArgInfo must be an ArgumentInfo extended instruction"; } @@ -439,8 +482,8 @@ spv_result_t ValidateClspvReflectionArgumentBuffer(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionArgumentPodBuffer(ValidationState_t& _, - const Instruction* inst) { +spv_result_t ValidateClspvReflectionArgumentOffsetBuffer( + ValidationState_t& _, const Instruction* inst) { const auto num_operands = inst->operands().size(); if (auto error = ValidateKernelDecl(_, inst)) { return error; @@ -480,7 +523,7 @@ spv_result_t ValidateClspvReflectionArgumentPodBuffer(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionArgumentPodPushConstant( +spv_result_t ValidateClspvReflectionArgumentPushConstant( ValidationState_t& _, const Instruction* inst) { const auto num_operands = inst->operands().size(); if (auto error = ValidateKernelDecl(_, inst)) { @@ -587,8 +630,8 @@ spv_result_t ValidateClspvReflectionPushConstant(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionConstantData(ValidationState_t& _, - const Instruction* inst) { +spv_result_t ValidateClspvReflectionInitializedData(ValidationState_t& _, + const Instruction* inst) { if (!IsUint32Constant(_, inst->GetOperandAs(4))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; @@ -650,18 +693,250 @@ spv_result_t ValidateClspvReflectionPropertyRequiredWorkgroupSize( return SPV_SUCCESS; } +spv_result_t ValidateClspvReflectionSubgroupMaxSize(ValidationState_t& _, + const Instruction* inst) { + const auto size_id = inst->GetOperandAs(4); + if (!IsUint32Constant(_, size_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPointerRelocation(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "ObjectOffset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PointerOffset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PointerSize must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionImageMetadataPushConstant( + ValidationState_t& _, const Instruction* inst) { + if (auto error = ValidateKernelDecl(_, inst)) { + return error; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Ordinal must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(7))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionImageMetadataUniform( + ValidationState_t& _, const Instruction* inst) { + if (auto error = ValidateKernelDecl(_, inst)) { + return error; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Ordinal must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(7))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Binding must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(8))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(9))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPushConstantData(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + if (_.GetIdOpcode(inst->GetOperandAs(6)) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) << "Data must be an OpString"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfInfo(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PrintfID must be a 32-bit unsigned integer OpConstant"; + } + + if (_.GetIdOpcode(inst->GetOperandAs(5)) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "FormatString must be an OpString"; + } + + for (size_t i = 6; i < inst->operands().size(); ++i) { + if (!IsUint32Constant(_, inst->GetOperandAs(i))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "ArgumentSizes must be a 32-bit unsigned integer OpConstant"; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfStorageBuffer( + ValidationState_t& _, const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Binding must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfPushConstant( + ValidationState_t& _, const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "BufferSize must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, const Instruction* inst, - uint32_t /*version*/) { + uint32_t version) { if (!_.IsVoidType(inst->type_id())) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Return Type must be OpTypeVoid"; } - auto ext_inst = inst->GetOperandAs(3); + uint32_t required_version = 0; + const auto ext_inst = + inst->GetOperandAs(3); switch (ext_inst) { case NonSemanticClspvReflectionKernel: - return ValidateClspvReflectionKernel(_, inst); + case NonSemanticClspvReflectionArgumentInfo: + case NonSemanticClspvReflectionArgumentStorageBuffer: + case NonSemanticClspvReflectionArgumentUniform: + case NonSemanticClspvReflectionArgumentPodStorageBuffer: + case NonSemanticClspvReflectionArgumentPodUniform: + case NonSemanticClspvReflectionArgumentPodPushConstant: + case NonSemanticClspvReflectionArgumentSampledImage: + case NonSemanticClspvReflectionArgumentStorageImage: + case NonSemanticClspvReflectionArgumentSampler: + case NonSemanticClspvReflectionArgumentWorkgroup: + case NonSemanticClspvReflectionSpecConstantWorkgroupSize: + case NonSemanticClspvReflectionSpecConstantGlobalOffset: + case NonSemanticClspvReflectionSpecConstantWorkDim: + case NonSemanticClspvReflectionPushConstantGlobalOffset: + case NonSemanticClspvReflectionPushConstantEnqueuedLocalSize: + case NonSemanticClspvReflectionPushConstantGlobalSize: + case NonSemanticClspvReflectionPushConstantRegionOffset: + case NonSemanticClspvReflectionPushConstantNumWorkgroups: + case NonSemanticClspvReflectionPushConstantRegionGroupOffset: + case NonSemanticClspvReflectionConstantDataStorageBuffer: + case NonSemanticClspvReflectionConstantDataUniform: + case NonSemanticClspvReflectionLiteralSampler: + case NonSemanticClspvReflectionPropertyRequiredWorkgroupSize: + required_version = 1; + break; + case NonSemanticClspvReflectionSpecConstantSubgroupMaxSize: + required_version = 2; + break; + case NonSemanticClspvReflectionArgumentPointerPushConstant: + case NonSemanticClspvReflectionArgumentPointerUniform: + case NonSemanticClspvReflectionProgramScopeVariablesStorageBuffer: + case NonSemanticClspvReflectionProgramScopeVariablePointerRelocation: + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderPushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypePushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderUniform: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypeUniform: + required_version = 3; + break; + case NonSemanticClspvReflectionArgumentStorageTexelBuffer: + case NonSemanticClspvReflectionArgumentUniformTexelBuffer: + required_version = 4; + break; + case NonSemanticClspvReflectionConstantDataPointerPushConstant: + case NonSemanticClspvReflectionProgramScopeVariablePointerPushConstant: + case NonSemanticClspvReflectionPrintfInfo: + case NonSemanticClspvReflectionPrintfBufferStorageBuffer: + case NonSemanticClspvReflectionPrintfBufferPointerPushConstant: + required_version = 5; + break; + default: + break; + } + if (version < required_version) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << ReflectionInstructionName(_, inst) << " requires version " + << required_version << ", but parsed version is " << version; + } + + switch (ext_inst) { + case NonSemanticClspvReflectionKernel: + return ValidateClspvReflectionKernel(_, inst, version); case NonSemanticClspvReflectionArgumentInfo: return ValidateClspvReflectionArgumentInfo(_, inst); case NonSemanticClspvReflectionArgumentStorageBuffer: @@ -669,12 +944,16 @@ spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, case NonSemanticClspvReflectionArgumentSampledImage: case NonSemanticClspvReflectionArgumentStorageImage: case NonSemanticClspvReflectionArgumentSampler: + case NonSemanticClspvReflectionArgumentStorageTexelBuffer: + case NonSemanticClspvReflectionArgumentUniformTexelBuffer: return ValidateClspvReflectionArgumentBuffer(_, inst); case NonSemanticClspvReflectionArgumentPodStorageBuffer: case NonSemanticClspvReflectionArgumentPodUniform: - return ValidateClspvReflectionArgumentPodBuffer(_, inst); + case NonSemanticClspvReflectionArgumentPointerUniform: + return ValidateClspvReflectionArgumentOffsetBuffer(_, inst); case NonSemanticClspvReflectionArgumentPodPushConstant: - return ValidateClspvReflectionArgumentPodPushConstant(_, inst); + case NonSemanticClspvReflectionArgumentPointerPushConstant: + return ValidateClspvReflectionArgumentPushConstant(_, inst); case NonSemanticClspvReflectionArgumentWorkgroup: return ValidateClspvReflectionArgumentWorkgroup(_, inst); case NonSemanticClspvReflectionSpecConstantWorkgroupSize: @@ -691,11 +970,31 @@ spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, return ValidateClspvReflectionPushConstant(_, inst); case NonSemanticClspvReflectionConstantDataStorageBuffer: case NonSemanticClspvReflectionConstantDataUniform: - return ValidateClspvReflectionConstantData(_, inst); + case NonSemanticClspvReflectionProgramScopeVariablesStorageBuffer: + return ValidateClspvReflectionInitializedData(_, inst); case NonSemanticClspvReflectionLiteralSampler: return ValidateClspvReflectionSampler(_, inst); case NonSemanticClspvReflectionPropertyRequiredWorkgroupSize: return ValidateClspvReflectionPropertyRequiredWorkgroupSize(_, inst); + case NonSemanticClspvReflectionSpecConstantSubgroupMaxSize: + return ValidateClspvReflectionSubgroupMaxSize(_, inst); + case NonSemanticClspvReflectionProgramScopeVariablePointerRelocation: + return ValidateClspvReflectionPointerRelocation(_, inst); + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderPushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypePushConstant: + return ValidateClspvReflectionImageMetadataPushConstant(_, inst); + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderUniform: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypeUniform: + return ValidateClspvReflectionImageMetadataUniform(_, inst); + case NonSemanticClspvReflectionConstantDataPointerPushConstant: + case NonSemanticClspvReflectionProgramScopeVariablePointerPushConstant: + return ValidateClspvReflectionPushConstantData(_, inst); + case NonSemanticClspvReflectionPrintfInfo: + return ValidateClspvReflectionPrintfInfo(_, inst); + case NonSemanticClspvReflectionPrintfBufferStorageBuffer: + return ValidateClspvReflectionPrintfStorageBuffer(_, inst); + case NonSemanticClspvReflectionPrintfBufferPointerPushConstant: + return ValidateClspvReflectionPrintfPushConstant(_, inst); default: break; } @@ -758,7 +1057,10 @@ spv_result_t ValidateExtension(ValidationState_t& _, const Instruction* inst) { if (extension == ExtensionToString(kSPV_KHR_workgroup_memory_explicit_layout) || extension == ExtensionToString(kSPV_EXT_mesh_shader) || - extension == ExtensionToString(kSPV_NV_shader_invocation_reorder)) { + extension == ExtensionToString(kSPV_NV_shader_invocation_reorder) || + extension == + ExtensionToString(kSPV_NV_cluster_acceleration_structure) || + extension == ExtensionToString(kSPV_NV_linear_swept_spheres)) { return _.diag(SPV_ERROR_WRONG_VERSION, inst) << extension << " extension requires SPIR-V version 1.4 or later."; } @@ -837,7 +1139,16 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case GLSLstd450NMin: case GLSLstd450NMax: case GLSLstd450NClamp: { - if (!_.IsFloatScalarOrVectorType(result_type)) { + bool supportsCoopVec = + (ext_inst_key == GLSLstd450FMin || ext_inst_key == GLSLstd450FMax || + ext_inst_key == GLSLstd450FClamp || + ext_inst_key == GLSLstd450NMin || ext_inst_key == GLSLstd450NMax || + ext_inst_key == GLSLstd450NClamp || + ext_inst_key == GLSLstd450Step || ext_inst_key == GLSLstd450Fma); + + if (!_.IsFloatScalarOrVectorType(result_type) && + !(supportsCoopVec && + _.IsFloatCooperativeVectorNVType(result_type))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected Result Type to be a float scalar or vector type"; @@ -867,7 +1178,14 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case GLSLstd450FindILsb: case GLSLstd450FindUMsb: case GLSLstd450FindSMsb: { - if (!_.IsIntScalarOrVectorType(result_type)) { + bool supportsCoopVec = + (ext_inst_key == GLSLstd450UMin || ext_inst_key == GLSLstd450UMax || + ext_inst_key == GLSLstd450UClamp || + ext_inst_key == GLSLstd450SMin || ext_inst_key == GLSLstd450SMax || + ext_inst_key == GLSLstd450SClamp); + + if (!_.IsIntScalarOrVectorType(result_type) && + !(supportsCoopVec && _.IsIntCooperativeVectorNVType(result_type))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected Result Type to be an int scalar or vector type"; @@ -879,7 +1197,10 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { for (uint32_t operand_index = 4; operand_index < num_operands; ++operand_index) { const uint32_t operand_type = _.GetOperandTypeId(inst, operand_index); - if (!operand_type || !_.IsIntScalarOrVectorType(operand_type)) { + if (!operand_type || + (!_.IsIntScalarOrVectorType(operand_type) && + !(supportsCoopVec && + _.IsIntCooperativeVectorNVType(operand_type)))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected all operands to be int scalars or vectors"; @@ -932,7 +1253,13 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case GLSLstd450Log2: case GLSLstd450Atan2: case GLSLstd450Pow: { - if (!_.IsFloatScalarOrVectorType(result_type)) { + bool supportsCoopVec = + (ext_inst_key == GLSLstd450Atan || ext_inst_key == GLSLstd450Tanh || + ext_inst_key == GLSLstd450Exp || ext_inst_key == GLSLstd450Log); + + if (!_.IsFloatScalarOrVectorType(result_type) && + !(supportsCoopVec && + _.IsFloatCooperativeVectorNVType(result_type))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected Result Type to be a 16 or 32-bit scalar or " @@ -1681,7 +2008,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { "CrossWorkgroup, Workgroup or Function"; } - if (result_type != p_data_type) { + if (!_.ContainsUntypedPointer(p_type) && result_type != p_data_type) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected data type of the pointer to be equal to Result " @@ -1743,15 +2070,17 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { "CrossWorkgroup, Workgroup or Function"; } - if (!_.IsIntScalarOrVectorType(p_data_type) || - _.GetBitWidth(p_data_type) != 32) { + if ((!_.IsIntScalarOrVectorType(p_data_type) || + _.GetBitWidth(p_data_type) != 32) && + !_.ContainsUntypedPointer(p_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected data type of the pointer to be a 32-bit int " "scalar or vector type"; } - if (_.GetDimension(p_data_type) != num_components) { + if (!_.ContainsUntypedPointer(p_type) && + _.GetDimension(p_data_type) != num_components) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected data type of the pointer to have the same number " @@ -2402,8 +2731,9 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { "Generic, CrossWorkgroup, Workgroup or Function"; } - if (!_.IsFloatScalarType(p_data_type) || - _.GetBitWidth(p_data_type) != 16) { + if ((!_.IsFloatScalarType(p_data_type) || + _.GetBitWidth(p_data_type) != 16) && + !_.ContainsUntypedPointer(p_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected operand P data type to be 16-bit float scalar"; @@ -2464,8 +2794,9 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { "Generic, CrossWorkgroup, Workgroup or Function"; } - if (!_.IsFloatScalarType(p_data_type) || - _.GetBitWidth(p_data_type) != 16) { + if ((!_.IsFloatScalarType(p_data_type) || + _.GetBitWidth(p_data_type) != 16) && + !_.ContainsUntypedPointer(p_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected operand P data type to be 16-bit float scalar"; @@ -2556,8 +2887,9 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { "CrossWorkgroup, Workgroup or Function"; } - if (!_.IsFloatScalarType(p_data_type) || - _.GetBitWidth(p_data_type) != 16) { + if ((!_.IsFloatScalarType(p_data_type) || + _.GetBitWidth(p_data_type) != 16) && + !_.ContainsUntypedPointer(p_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected operand P data type to be 16-bit float scalar"; @@ -2663,14 +2995,41 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { << "expected operand Format to be a pointer"; } - if (format_storage_class != spv::StorageClass::UniformConstant) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << ext_inst_name() << ": " - << "expected Format storage class to be UniformConstant"; + if (_.HasExtension( + Extension::kSPV_EXT_relaxed_printf_string_address_space)) { + if (format_storage_class != spv::StorageClass::UniformConstant && + // Extension SPV_EXT_relaxed_printf_string_address_space allows + // format strings in Global, Local, Private and Generic address + // spaces + + // Global + format_storage_class != spv::StorageClass::CrossWorkgroup && + // Local + format_storage_class != spv::StorageClass::Workgroup && + // Private + format_storage_class != spv::StorageClass::Function && + // Generic + format_storage_class != spv::StorageClass::Generic) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": " + << "expected Format storage class to be UniformConstant, " + "Crossworkgroup, Workgroup, Function, or Generic"; + } + } else { + if (format_storage_class != spv::StorageClass::UniformConstant) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": " + << "expected Format storage class to be UniformConstant"; + } } - if (!_.IsIntScalarType(format_data_type) || - _.GetBitWidth(format_data_type) != 8) { + // If pointer points to an array, get the type of an element + if (_.IsIntArrayType(format_data_type)) + format_data_type = _.GetComponentType(format_data_type); + + if ((!_.IsIntScalarType(format_data_type) || + _.GetBitWidth(format_data_type) != 8) && + !_.ContainsUntypedPointer(format_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": " << "expected Format data type to be 8-bit int"; @@ -2759,7 +3118,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { // validation. case NonSemanticShaderDebugInfo100DebugInfoNone: case NonSemanticShaderDebugInfo100DebugCompilationUnit: - case NonSemanticShaderDebugInfo100DebugTypeBasic: case NonSemanticShaderDebugInfo100DebugTypePointer: case NonSemanticShaderDebugInfo100DebugTypeQualifier: case NonSemanticShaderDebugInfo100DebugTypeArray: @@ -2785,7 +3143,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case NonSemanticShaderDebugInfo100DebugInlinedAt: case NonSemanticShaderDebugInfo100DebugLocalVariable: case NonSemanticShaderDebugInfo100DebugInlinedVariable: - case NonSemanticShaderDebugInfo100DebugDeclare: case NonSemanticShaderDebugInfo100DebugValue: case NonSemanticShaderDebugInfo100DebugOperation: case NonSemanticShaderDebugInfo100DebugExpression: @@ -2794,6 +3151,24 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case NonSemanticShaderDebugInfo100DebugImportedEntity: case NonSemanticShaderDebugInfo100DebugSource: break; + + // These checks are for operands that are differnet in + // ShaderDebugInfo100 + case NonSemanticShaderDebugInfo100DebugTypeBasic: { + CHECK_CONST_UINT_OPERAND("Flags", 8); + break; + } + case NonSemanticShaderDebugInfo100DebugDeclare: { + for (uint32_t word_index = 8; word_index < num_words; ++word_index) { + auto index_inst = _.FindDef(inst->word(word_index)); + auto type_id = index_inst != nullptr ? index_inst->type_id() : 0; + if (type_id == 0 || !IsIntScalar(_, type_id, false, false)) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": " + << "expected index must be scalar integer"; + } + break; + } case NonSemanticShaderDebugInfo100DebugTypeMatrix: { CHECK_DEBUG_OPERAND("Vector Type", CommonDebugInfoDebugTypeVector, 5); @@ -2801,7 +3176,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { uint32_t vector_count = inst->word(6); uint64_t const_val; - if (!_.GetConstantValUint64(vector_count, &const_val)) { + if (!_.EvalConstantValUint64(vector_count, &const_val)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": Vector Count must be 32-bit integer OpConstant"; @@ -2815,14 +3190,84 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } break; } - // TODO: Add validation rules for remaining cases as well. - case NonSemanticShaderDebugInfo100DebugFunctionDefinition: - case NonSemanticShaderDebugInfo100DebugSourceContinued: - case NonSemanticShaderDebugInfo100DebugLine: + case NonSemanticShaderDebugInfo100DebugFunctionDefinition: { + CHECK_DEBUG_OPERAND("Function", CommonDebugInfoDebugFunction, 5); + CHECK_OPERAND("Definition", spv::Op::OpFunction, 6); + const auto* current_function = inst->function(); + if (current_function->first_block()->id() != inst->block()->id()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() + << ": must be in the entry basic block of the function"; + } + + const uint32_t definition_id = inst->word(6); + if (definition_id != current_function->id()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() + << ": operand Definition must point to the OpFunction it is " + "inside"; + } + break; + } + case NonSemanticShaderDebugInfo100DebugLine: { + CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 5); + CHECK_CONST_UINT_OPERAND("Line Start", 6); + CHECK_CONST_UINT_OPERAND("Line End", 7); + CHECK_CONST_UINT_OPERAND("Column Start", 8); + CHECK_CONST_UINT_OPERAND("Column End", 9); + + // above already validates if 32-bit and non-spec constant + // but want to use EvalInt32IfConst to be consistent with other Eval + // locations + bool is_int32 = false, is_const_int32 = false; + uint32_t line_start = 0; + uint32_t line_end = 0; + uint32_t column_start = 0; + uint32_t column_end = 0; + std::tie(is_int32, is_const_int32, line_start) = + _.EvalInt32IfConst(inst->word(6)); + std::tie(is_int32, is_const_int32, line_end) = + _.EvalInt32IfConst(inst->word(7)); + std::tie(is_int32, is_const_int32, column_start) = + _.EvalInt32IfConst(inst->word(8)); + std::tie(is_int32, is_const_int32, column_end) = + _.EvalInt32IfConst(inst->word(9)); + if (line_end < line_start) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": operand Line End (" << line_end + << ") is less than Line Start (" << line_start << ")"; + } else if (line_start == line_end && column_end < column_start) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": operand Column End (" << column_end + << ") is less than Column Start (" << column_start + << ") when Line Start equals Line End"; + } + break; + } + case NonSemanticShaderDebugInfo100DebugSourceContinued: { + CHECK_OPERAND("Text", spv::Op::OpString, 5); + break; + } + case NonSemanticShaderDebugInfo100DebugBuildIdentifier: { + CHECK_OPERAND("Identifier", spv::Op::OpString, 5); + CHECK_CONST_UINT_OPERAND("Flags", 6); + break; + } + case NonSemanticShaderDebugInfo100DebugStoragePath: { + CHECK_OPERAND("Path", spv::Op::OpString, 5); + break; + } + case NonSemanticShaderDebugInfo100DebugEntryPoint: { + CHECK_DEBUG_OPERAND("Entry Point", CommonDebugInfoDebugFunction, 5); + CHECK_DEBUG_OPERAND("Compilation Unit", + CommonDebugInfoDebugCompilationUnit, 6); + CHECK_OPERAND("Compiler Signature", spv::Op::OpString, 7); + CHECK_OPERAND("Command-line Arguments", spv::Op::OpString, 8); + break; + } + + // Has no additional checks case NonSemanticShaderDebugInfo100DebugNoLine: - case NonSemanticShaderDebugInfo100DebugBuildIdentifier: - case NonSemanticShaderDebugInfo100DebugStoragePath: - case NonSemanticShaderDebugInfo100DebugEntryPoint: break; case NonSemanticShaderDebugInfo100InstructionsMax: assert(0); @@ -2869,16 +3314,16 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { break; } case CommonDebugInfoDebugTypePointer: { - auto validate_base_type = - ValidateOperandBaseType(_, inst, 5, ext_inst_name); + auto validate_base_type = ValidateOperandDebugType( + _, "Base Type", inst, 5, ext_inst_name, false); if (validate_base_type != SPV_SUCCESS) return validate_base_type; CHECK_CONST_UINT_OPERAND("Storage Class", 6); CHECK_CONST_UINT_OPERAND("Flags", 7); break; } case CommonDebugInfoDebugTypeQualifier: { - auto validate_base_type = - ValidateOperandBaseType(_, inst, 5, ext_inst_name); + auto validate_base_type = ValidateOperandDebugType( + _, "Base Type", inst, 5, ext_inst_name, false); if (validate_base_type != SPV_SUCCESS) return validate_base_type; CHECK_CONST_UINT_OPERAND("Type Qualifier", 6); break; @@ -2892,7 +3337,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { uint32_t component_count = inst->word(6); if (vulkanDebugInfo) { uint64_t const_val; - if (!_.GetConstantValUint64(component_count, &const_val)) { + if (!_.EvalConstantValUint64(component_count, &const_val)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << ext_inst_name() << ": Component Count must be 32-bit integer OpConstant"; @@ -3124,9 +3569,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } case CommonDebugInfoDebugFunction: { CHECK_OPERAND("Name", spv::Op::OpString, 5); - auto validate_type = ValidateOperandDebugType(_, "Type", inst, 6, - ext_inst_name, false); - if (validate_type != SPV_SUCCESS) return validate_type; + CHECK_DEBUG_OPERAND("Type", CommonDebugInfoDebugTypeFunction, 6); CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 7); CHECK_CONST_UINT_OPERAND("Line", 8); CHECK_CONST_UINT_OPERAND("Column", 9); @@ -3161,9 +3604,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } case CommonDebugInfoDebugFunctionDeclaration: { CHECK_OPERAND("Name", spv::Op::OpString, 5); - auto validate_type = ValidateOperandDebugType(_, "Type", inst, 6, - ext_inst_name, false); - if (validate_type != SPV_SUCCESS) return validate_type; + CHECK_DEBUG_OPERAND("Type", CommonDebugInfoDebugTypeFunction, 6); CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 7); CHECK_CONST_UINT_OPERAND("Line", 8); CHECK_CONST_UINT_OPERAND("Column", 9); @@ -3225,18 +3666,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } CHECK_DEBUG_OPERAND("Expression", CommonDebugInfoDebugExpression, 7); - - if (vulkanDebugInfo) { - for (uint32_t word_index = 8; word_index < num_words; - ++word_index) { - auto index_inst = _.FindDef(inst->word(word_index)); - auto type_id = index_inst != nullptr ? index_inst->type_id() : 0; - if (type_id == 0 || !IsIntScalar(_, type_id, false, false)) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << ext_inst_name() << ": " - << "expected index must be scalar integer"; - } - } break; } case CommonDebugInfoDebugExpression: { @@ -3407,7 +3836,7 @@ spv_result_t ExtensionPass(ValidationState_t& _, const Instruction* inst) { const spv::Op opcode = inst->opcode(); if (opcode == spv::Op::OpExtension) return ValidateExtension(_, inst); if (opcode == spv::Op::OpExtInstImport) return ValidateExtInstImport(_, inst); - if (opcode == spv::Op::OpExtInst) return ValidateExtInst(_, inst); + if (spvIsExtendedInstruction(opcode)) return ValidateExtInst(_, inst); return SPV_SUCCESS; } diff --git a/third_party/spirv-tools/source/val/validate_function.cpp b/third_party/spirv-tools/source/val/validate_function.cpp index db402aa32f..4879a7db5f 100644 --- a/third_party/spirv-tools/source/val/validate_function.cpp +++ b/third_party/spirv-tools/source/val/validate_function.cpp @@ -14,6 +14,7 @@ #include +#include "source/enum_string_mapping.h" #include "source/opcode.h" #include "source/val/instruction.h" #include "source/val/validate.h" @@ -85,7 +86,10 @@ spv_result_t ValidateFunction(ValidationState_t& _, const Instruction* inst) { spv::Op::OpGetKernelPreferredWorkGroupSizeMultiple, spv::Op::OpGetKernelLocalSizeForSubgroupCount, spv::Op::OpGetKernelMaxNumSubgroups, - spv::Op::OpName}; + spv::Op::OpName, + spv::Op::OpCooperativeMatrixPerElementOpNV, + spv::Op::OpCooperativeMatrixReduceNV, + spv::Op::OpCooperativeMatrixLoadTensorNV}; for (auto& pair : inst->uses()) { const auto* use = pair.first; if (std::find(acceptable.begin(), acceptable.end(), use->opcode()) == @@ -148,78 +152,6 @@ spv_result_t ValidateFunctionParameter(ValidationState_t& _, "type of the same index."; } - // Validate that PhysicalStorageBuffer have one of Restrict, Aliased, - // RestrictPointer, or AliasedPointer. - auto param_nonarray_type_id = param_type->id(); - while (_.GetIdOpcode(param_nonarray_type_id) == spv::Op::OpTypeArray) { - param_nonarray_type_id = - _.FindDef(param_nonarray_type_id)->GetOperandAs(1u); - } - if (_.GetIdOpcode(param_nonarray_type_id) == spv::Op::OpTypePointer) { - auto param_nonarray_type = _.FindDef(param_nonarray_type_id); - if (param_nonarray_type->GetOperandAs(1u) == - spv::StorageClass::PhysicalStorageBuffer) { - // check for Aliased or Restrict - const auto& decorations = _.id_decorations(inst->id()); - - bool foundAliased = std::any_of( - decorations.begin(), decorations.end(), [](const Decoration& d) { - return spv::Decoration::Aliased == d.dec_type(); - }); - - bool foundRestrict = std::any_of( - decorations.begin(), decorations.end(), [](const Decoration& d) { - return spv::Decoration::Restrict == d.dec_type(); - }); - - if (!foundAliased && !foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpFunctionParameter " << inst->id() - << ": expected Aliased or Restrict for PhysicalStorageBuffer " - "pointer."; - } - if (foundAliased && foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpFunctionParameter " << inst->id() - << ": can't specify both Aliased and Restrict for " - "PhysicalStorageBuffer pointer."; - } - } else { - const auto pointee_type_id = - param_nonarray_type->GetOperandAs(2); - const auto pointee_type = _.FindDef(pointee_type_id); - if (spv::Op::OpTypePointer == pointee_type->opcode() && - pointee_type->GetOperandAs(1u) == - spv::StorageClass::PhysicalStorageBuffer) { - // check for AliasedPointer/RestrictPointer - const auto& decorations = _.id_decorations(inst->id()); - - bool foundAliased = std::any_of( - decorations.begin(), decorations.end(), [](const Decoration& d) { - return spv::Decoration::AliasedPointer == d.dec_type(); - }); - - bool foundRestrict = std::any_of( - decorations.begin(), decorations.end(), [](const Decoration& d) { - return spv::Decoration::RestrictPointer == d.dec_type(); - }); - - if (!foundAliased && !foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpFunctionParameter " << inst->id() - << ": expected AliasedPointer or RestrictPointer for " - "PhysicalStorageBuffer pointer."; - } - if (foundAliased && foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpFunctionParameter " << inst->id() - << ": can't specify both AliasedPointer and " - "RestrictPointer for PhysicalStorageBuffer pointer."; - } - } - } - } - return SPV_SUCCESS; } @@ -277,7 +209,7 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, function_type->GetOperandAs(param_index); const auto parameter_type = _.FindDef(parameter_type_id); if (!parameter_type || argument_type->id() != parameter_type->id()) { - if (!_.options()->before_hlsl_legalization || + if (!parameter_type || !_.options()->before_hlsl_legalization || !DoPointeesLogicallyMatch(argument_type, parameter_type, _)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpFunctionCall Argument " << _.getIdName(argument_id) @@ -287,7 +219,8 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, } if (_.addressing_model() == spv::AddressingModel::Logical) { - if (parameter_type->opcode() == spv::Op::OpTypePointer && + if ((parameter_type->opcode() == spv::Op::OpTypePointer || + parameter_type->opcode() == spv::Op::OpTypeUntypedPointerKHR) && !_.options()->relax_logical_pointer) { spv::StorageClass sc = parameter_type->GetOperandAs(1u); @@ -316,9 +249,11 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, // Validate memory object declaration requirements. if (argument->opcode() != spv::Op::OpVariable && + argument->opcode() != spv::Op::OpUntypedVariableKHR && argument->opcode() != spv::Op::OpFunctionParameter) { - const bool ssbo_vptr = _.features().variable_pointers && - sc == spv::StorageClass::StorageBuffer; + const bool ssbo_vptr = + _.HasCapability(spv::Capability::VariablePointersStorageBuffer) && + sc == spv::StorageClass::StorageBuffer; const bool wg_vptr = _.HasCapability(spv::Capability::VariablePointers) && sc == spv::StorageClass::Workgroup; @@ -335,6 +270,80 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateCooperativeMatrixPerElementOp(ValidationState_t& _, + const Instruction* inst) { + const auto function_id = inst->GetOperandAs(3); + const auto function = _.FindDef(function_id); + if (!function || spv::Op::OpFunction != function->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV Function " + << _.getIdName(function_id) << " is not a function."; + } + + const auto matrix_id = inst->GetOperandAs(2); + const auto matrix = _.FindDef(matrix_id); + const auto matrix_type_id = matrix->type_id(); + if (!_.IsCooperativeMatrixKHRType(matrix_type_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV Matrix " + << _.getIdName(matrix_id) << " is not a cooperative matrix."; + } + + const auto result_type_id = inst->GetOperandAs(0); + if (matrix_type_id != result_type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV Result Type " + << _.getIdName(result_type_id) << " must match matrix type " + << _.getIdName(matrix_type_id) << "."; + } + + const auto matrix_comp_type_id = + _.FindDef(matrix_type_id)->GetOperandAs(1); + const auto function_type_id = function->GetOperandAs(3); + const auto function_type = _.FindDef(function_type_id); + auto return_type_id = function_type->GetOperandAs(1); + if (return_type_id != matrix_comp_type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV function return type " + << _.getIdName(return_type_id) + << " must match matrix component type " + << _.getIdName(matrix_comp_type_id) << "."; + } + + if (function_type->operands().size() < 5) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV function type " + << _.getIdName(function_type_id) + << " must have a least three parameters."; + } + + const auto param0_id = function_type->GetOperandAs(2); + const auto param1_id = function_type->GetOperandAs(3); + const auto param2_id = function_type->GetOperandAs(4); + if (!_.IsIntScalarType(param0_id) || _.GetBitWidth(param0_id) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV function type first parameter " + "type " + << _.getIdName(param0_id) << " must be a 32-bit integer."; + } + + if (!_.IsIntScalarType(param1_id) || _.GetBitWidth(param1_id) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV function type second " + "parameter type " + << _.getIdName(param1_id) << " must be a 32-bit integer."; + } + + if (param2_id != matrix_comp_type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixPerElementOpNV function type third parameter " + "type " + << _.getIdName(param2_id) << " must match matrix component type."; + } + + return SPV_SUCCESS; +} + } // namespace spv_result_t FunctionPass(ValidationState_t& _, const Instruction* inst) { @@ -348,6 +357,10 @@ spv_result_t FunctionPass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpFunctionCall: if (auto error = ValidateFunctionCall(_, inst)) return error; break; + case spv::Op::OpCooperativeMatrixPerElementOpNV: + if (auto error = ValidateCooperativeMatrixPerElementOp(_, inst)) + return error; + break; default: break; } diff --git a/third_party/spirv-tools/source/val/validate_id.cpp b/third_party/spirv-tools/source/val/validate_id.cpp index 89a5ddd79d..00be150cb5 100644 --- a/third_party/spirv-tools/source/val/validate_id.cpp +++ b/third_party/spirv-tools/source/val/validate_id.cpp @@ -12,25 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/val/validate.h" - -#include - -#include -#include -#include -#include -#include #include -#include #include -#include "source/diagnostic.h" #include "source/instruction.h" #include "source/opcode.h" #include "source/operand.h" -#include "source/spirv_validator_options.h" #include "source/val/function.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" #include "spirv-tools/libspirv.h" @@ -131,15 +120,16 @@ spv_result_t CheckIdDefinitionDominateUse(ValidationState_t& _) { // instruction operand's ID can be forward referenced. spv_result_t IdPass(ValidationState_t& _, Instruction* inst) { auto can_have_forward_declared_ids = - inst->opcode() == spv::Op::OpExtInst && + spvIsExtendedInstruction(inst->opcode()) && spvExtInstIsDebugInfo(inst->ext_inst_type()) ? spvDbgInfoExtOperandCanBeForwardDeclaredFunction( - inst->ext_inst_type(), inst->word(4)) + inst->opcode(), inst->ext_inst_type(), inst->word(4)) : spvOperandCanBeForwardDeclaredFunction(inst->opcode()); // Keep track of a result id defined by this instruction. 0 means it // does not define an id. uint32_t result_id = 0; + bool has_forward_declared_ids = false; for (unsigned i = 0; i < inst->operands().size(); i++) { const spv_parsed_operand_t& operand = inst->operand(i); @@ -173,10 +163,16 @@ spv_result_t IdPass(ValidationState_t& _, Instruction* inst) { !spvOpcodeGeneratesType(opcode) && !spvOpcodeIsDebug(opcode) && !inst->IsDebugInfo() && !inst->IsNonSemantic() && !spvOpcodeIsDecoration(opcode) && opcode != spv::Op::OpFunction && + opcode != spv::Op::OpSizeOf && opcode != spv::Op::OpCooperativeMatrixLengthNV && + opcode != spv::Op::OpCooperativeMatrixLengthKHR && + !spvOpcodeGeneratesUntypedPointer(opcode) && + opcode != spv::Op::OpUntypedArrayLengthKHR && !(opcode == spv::Op::OpSpecConstantOp && - spv::Op(inst->word(3)) == - spv::Op::OpCooperativeMatrixLengthNV)) { + (spv::Op(inst->word(3)) == + spv::Op::OpCooperativeMatrixLengthNV || + spv::Op(inst->word(3)) == + spv::Op::OpCooperativeMatrixLengthKHR))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Operand " << _.getIdName(operand_word) << " cannot be a type"; @@ -185,14 +181,21 @@ spv_result_t IdPass(ValidationState_t& _, Instruction* inst) { !inst->IsNonSemantic() && !spvOpcodeIsDecoration(opcode) && !spvOpcodeIsBranch(opcode) && opcode != spv::Op::OpPhi && opcode != spv::Op::OpExtInst && + opcode != spv::Op::OpExtInstWithForwardRefsKHR && opcode != spv::Op::OpExtInstImport && opcode != spv::Op::OpSelectionMerge && opcode != spv::Op::OpLoopMerge && opcode != spv::Op::OpFunction && + opcode != spv::Op::OpSizeOf && opcode != spv::Op::OpCooperativeMatrixLengthNV && + opcode != spv::Op::OpCooperativeMatrixLengthKHR && + !spvOpcodeGeneratesUntypedPointer(opcode) && + opcode != spv::Op::OpUntypedArrayLengthKHR && !(opcode == spv::Op::OpSpecConstantOp && - spv::Op(inst->word(3)) == - spv::Op::OpCooperativeMatrixLengthNV)) { + (spv::Op(inst->word(3)) == + spv::Op::OpCooperativeMatrixLengthNV || + spv::Op(inst->word(3)) == + spv::Op::OpCooperativeMatrixLengthKHR))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Operand " << _.getIdName(operand_word) << " requires a type"; @@ -205,6 +208,7 @@ spv_result_t IdPass(ValidationState_t& _, Instruction* inst) { ret = SPV_SUCCESS; } } else if (can_have_forward_declared_ids(i)) { + has_forward_declared_ids = true; if (spvOpcodeGeneratesType(inst->opcode()) && !_.IsForwardPointer(operand_word)) { ret = _.diag(SPV_ERROR_INVALID_ID, inst) @@ -234,12 +238,35 @@ spv_result_t IdPass(ValidationState_t& _, Instruction* inst) { << " has not been defined"; } break; + case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER: + // Ideally, this check would live in validate_extensions.cpp. But since + // forward references are only allowed on non-semantic instructions, and + // ID validation is done first, we would fail with a "ID had not been + // defined" error before we could give a more helpful message. For this + // reason, this test is done here, so we can be more helpful to the + // user. + if (inst->opcode() == spv::Op::OpExtInstWithForwardRefsKHR && + !inst->IsNonSemantic()) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "OpExtInstWithForwardRefsKHR is only allowed with " + "non-semantic instructions."; + ret = SPV_SUCCESS; + break; default: ret = SPV_SUCCESS; break; } if (SPV_SUCCESS != ret) return ret; } + const bool must_have_forward_declared_ids = + inst->opcode() == spv::Op::OpExtInstWithForwardRefsKHR; + if (must_have_forward_declared_ids && !has_forward_declared_ids) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Opcode OpExtInstWithForwardRefsKHR must have at least one " + "forward " + "declared ID."; + } + if (result_id) _.RemoveIfForwardDeclared(result_id); return SPV_SUCCESS; diff --git a/third_party/spirv-tools/source/val/validate_image.cpp b/third_party/spirv-tools/source/val/validate_image.cpp index 8f0e6c4d48..a5f91f7f7f 100644 --- a/third_party/spirv-tools/source/val/validate_image.cpp +++ b/third_party/spirv-tools/source/val/validate_image.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Google Inc. +// Copyright (c) 2017 Google Inc. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights // reserved. // @@ -18,7 +18,6 @@ #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" @@ -211,6 +210,7 @@ uint32_t GetPlaneCoordSize(const ImageTypeInfo& info) { case spv::Dim::Dim2D: case spv::Dim::Rect: case spv::Dim::SubpassData: + case spv::Dim::TileImageDataEXT: plane_size = 2; break; case spv::Dim::Dim3D: @@ -219,6 +219,7 @@ uint32_t GetPlaneCoordSize(const ImageTypeInfo& info) { plane_size = 3; break; case spv::Dim::Max: + default: assert(0); break; } @@ -296,7 +297,6 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, spv::ImageOperandsMask::ConstOffsets | spv::ImageOperandsMask::Offsets)) > 1) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << _.VkErrorID(4662) << "Image Operands Offset, ConstOffset, ConstOffsets, Offsets " "cannot be used together"; } @@ -455,13 +455,14 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, } if (!_.options()->before_hlsl_legalization && - spvIsVulkanEnv(_.context()->target_env)) { + spvIsVulkanEnv(_.context()->target_env) && + !_.options()->allow_offset_texture_operand) { if (opcode != spv::Op::OpImageGather && opcode != spv::Op::OpImageDrefGather && opcode != spv::Op::OpImageSparseGather && opcode != spv::Op::OpImageSparseDrefGather) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << _.VkErrorID(4663) + << _.VkErrorID(10213) << "Image Operand Offset can only be used with " "OpImage*Gather operations"; } @@ -495,7 +496,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, } uint64_t array_size = 0; - if (!_.GetConstantValUint64(type_inst->word(3), &array_size)) { + if (!_.EvalConstantValUint64(type_inst->word(3), &array_size)) { assert(0 && "Array type definition is corrupt"); } @@ -693,16 +694,11 @@ spv_result_t ValidateImageReadWrite(ValidationState_t& _, << "storage image"; } - if (info.multisampled == 1 && + if (info.multisampled == 1 && info.arrayed == 1 && info.sampled == 2 && !_.HasCapability(spv::Capability::ImageMSArray)) { -#if 0 - // TODO(atgoo@github.com) The description of this rule in the spec - // is unclear and Glslang doesn't declare ImageMSArray. Need to clarify - // and reenable. return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Capability ImageMSArray is required to access storage " - << "image"; -#endif + << "Capability ImageMSArray is required to access storage " + << "image"; } } else if (info.sampled != 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -854,6 +850,28 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Dim SubpassData requires format Unknown"; } + } else if (info.dim == spv::Dim::TileImageDataEXT) { + if (_.IsVoidType(info.sampled_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim TileImageDataEXT requires Sampled Type to be not " + "OpTypeVoid"; + } + if (info.sampled != 2) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim TileImageDataEXT requires Sampled to be 2"; + } + if (info.format != spv::ImageFormat::Unknown) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim TileImageDataEXT requires format Unknown"; + } + if (info.depth != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim TileImageDataEXT requires Depth to be 0"; + } + if (info.arrayed != 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Dim TileImageDataEXT requires Arrayed to be 0"; + } } else { if (info.multisampled && (info.sampled == 2) && !_.HasCapability(spv::Capability::StorageImageMultisample)) { @@ -897,7 +915,15 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) { if (info.dim == spv::Dim::SubpassData && info.arrayed != 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << _.VkErrorID(6214) << "Dim SubpassData requires Arrayed to be 0"; + << _.VkErrorID(6214) + << "Dim SubpassData requires Arrayed to be 0 in the Vulkan " + "environment"; + } + + if (info.dim == spv::Dim::Rect) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(9638) + << "Dim must not be Rect in the Vulkan environment"; } } @@ -919,6 +945,8 @@ spv_result_t ValidateTypeSampledImage(ValidationState_t& _, } // OpenCL requires Sampled=0, checked elsewhere. // Vulkan uses the Sampled=1 case. + // If Dim is TileImageDataEXT, Sampled must be 2 and this is validated + // elsewhere. if ((info.sampled != 0) && (info.sampled != 1)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(4657) @@ -959,6 +987,15 @@ bool IsAllowedSampledImageOperand(spv::Op opcode, ValidationState_t& _) { case spv::Op::OpImageSparseGather: case spv::Op::OpImageSparseDrefGather: case spv::Op::OpCopyObject: + case spv::Op::OpImageSampleWeightedQCOM: + case spv::Op::OpImageBoxFilterQCOM: + case spv::Op::OpImageBlockMatchSSDQCOM: + case spv::Op::OpImageBlockMatchSADQCOM: + case spv::Op::OpImageBlockMatchWindowSADQCOM: + case spv::Op::OpImageBlockMatchWindowSSDQCOM: + case spv::Op::OpImageBlockMatchGatherSADQCOM: + case spv::Op::OpImageBlockMatchGatherSSDQCOM: + case spv::Op::OpImageSampleFootprintNV: return true; case spv::Op::OpStore: if (_.HasCapability(spv::Capability::BindlessTextureNV)) return true; @@ -970,7 +1007,8 @@ bool IsAllowedSampledImageOperand(spv::Op opcode, ValidationState_t& _) { spv_result_t ValidateSampledImage(ValidationState_t& _, const Instruction* inst) { - if (_.GetIdOpcode(inst->type_id()) != spv::Op::OpTypeSampledImage) { + auto type_inst = _.FindDef(inst->type_id()); + if (type_inst->opcode() != spv::Op::OpTypeSampledImage) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Result Type to be OpTypeSampledImage."; } @@ -987,8 +1025,25 @@ spv_result_t ValidateSampledImage(ValidationState_t& _, << "Corrupt image type definition"; } - // TODO(atgoo@github.com) Check compatibility of result type and received - // image. + // Image operands must match except for depth. + auto sampled_image_id = type_inst->GetOperandAs(1); + if (sampled_image_id != image_type) { + ImageTypeInfo sampled_info; + if (!GetImageTypeInfo(_, sampled_image_id, &sampled_info)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Corrupt image type definition"; + } + if (info.sampled_type != sampled_info.sampled_type || + info.dim != sampled_info.dim || info.arrayed != sampled_info.arrayed || + info.multisampled != sampled_info.multisampled || + info.sampled != sampled_info.sampled || + info.format != sampled_info.format || + info.access_qualifier != sampled_info.access_qualifier) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Image operands must match result image operands except for " + "depth"; + } + } if (spvIsVulkanEnv(_.context()->target_env)) { if (info.sampled != 1) { @@ -1062,31 +1117,51 @@ spv_result_t ValidateSampledImage(ValidationState_t& _, } } } + + const Instruction* ld_inst; + { + int t_idx = inst->GetOperandAs(2); + ld_inst = _.FindDef(t_idx); + } + + if (ld_inst->opcode() == spv::Op::OpLoad) { + int texture_id = ld_inst->GetOperandAs(2); // variable to load + _.RegisterQCOMImageProcessingTextureConsumer(texture_id, ld_inst, inst); + } + return SPV_SUCCESS; } spv_result_t ValidateImageTexelPointer(ValidationState_t& _, const Instruction* inst) { const auto result_type = _.FindDef(inst->type_id()); - if (result_type->opcode() != spv::Op::OpTypePointer) { + if (result_type->opcode() != spv::Op::OpTypePointer && + result_type->opcode() != spv::Op::OpTypeUntypedPointerKHR) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Result Type to be OpTypePointer"; + << "Expected Result Type to be a pointer"; } const auto storage_class = result_type->GetOperandAs(1); if (storage_class != spv::StorageClass::Image) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Result Type to be OpTypePointer whose Storage Class " + << "Expected Result Type to be a pointer whose Storage Class " "operand is Image"; } - const auto ptr_type = result_type->GetOperandAs(2); - const auto ptr_opcode = _.GetIdOpcode(ptr_type); - if (ptr_opcode != spv::Op::OpTypeInt && ptr_opcode != spv::Op::OpTypeFloat && - ptr_opcode != spv::Op::OpTypeVoid) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << "Expected Result Type to be OpTypePointer whose Type operand " - "must be a scalar numerical type or OpTypeVoid"; + uint32_t ptr_type = 0; + if (result_type->opcode() == spv::Op::OpTypePointer) { + ptr_type = result_type->GetOperandAs(2); + const auto ptr_opcode = _.GetIdOpcode(ptr_type); + if (ptr_opcode != spv::Op::OpTypeInt && + ptr_opcode != spv::Op::OpTypeFloat && + ptr_opcode != spv::Op::OpTypeVoid && + !(ptr_opcode == spv::Op::OpTypeVector && + _.HasCapability(spv::Capability::AtomicFloat16VectorNV) && + _.IsFloat16Vector2Or4Type(ptr_type))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Result Type to be a pointer whose Type operand " + "must be a scalar numerical type or OpTypeVoid"; + } } const auto image_ptr = _.FindDef(_.GetOperandTypeId(inst, 2)); @@ -1107,7 +1182,15 @@ spv_result_t ValidateImageTexelPointer(ValidationState_t& _, << "Corrupt image type definition"; } - if (info.sampled_type != ptr_type) { + if (result_type->opcode() == spv::Op::OpTypePointer && + info.sampled_type != ptr_type && + !(_.HasCapability(spv::Capability::AtomicFloat16VectorNV) && + _.IsFloat16Vector2Or4Type(ptr_type) && + _.GetIdOpcode(info.sampled_type) == spv::Op::OpTypeFloat && + ((_.GetDimension(ptr_type) == 2 && + info.format == spv::ImageFormat::Rg16f) || + (_.GetDimension(ptr_type) == 4 && + info.format == spv::ImageFormat::Rgba16f)))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Image 'Sampled Type' to be the same as the Type " "pointed to by Result Type"; @@ -1118,6 +1201,12 @@ spv_result_t ValidateImageTexelPointer(ValidationState_t& _, << "Image Dim SubpassData cannot be used with OpImageTexelPointer"; } + if (info.dim == spv::Dim::TileImageDataEXT) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Image Dim TileImageDataEXT cannot be used with " + "OpImageTexelPointer"; + } + const uint32_t coord_type = _.GetOperandTypeId(inst, 3); if (!coord_type || !_.IsIntScalarOrVectorType(coord_type)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -1159,7 +1248,7 @@ spv_result_t ValidateImageTexelPointer(ValidationState_t& _, if (info.multisampled == 0) { uint64_t ms = 0; - if (!_.GetConstantValUint64(inst->GetOperandAs(4), &ms) || + if (!_.EvalConstantValUint64(inst->GetOperandAs(4), &ms) || ms != 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Sample for Image with MS 0 to be a valid for " @@ -1172,7 +1261,10 @@ spv_result_t ValidateImageTexelPointer(ValidationState_t& _, (info.format != spv::ImageFormat::R64ui) && (info.format != spv::ImageFormat::R32f) && (info.format != spv::ImageFormat::R32i) && - (info.format != spv::ImageFormat::R32ui)) { + (info.format != spv::ImageFormat::R32ui) && + !((info.format == spv::ImageFormat::Rg16f || + info.format == spv::ImageFormat::Rgba16f) && + _.HasCapability(spv::Capability::AtomicFloat16VectorNV))) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(4658) << "Expected the Image Format in Image to be R64i, R64ui, R32f, " @@ -1624,6 +1716,12 @@ spv_result_t ValidateImageRead(ValidationState_t& _, const Instruction* inst) { spvOpcodeString(opcode)); } + if (info.dim == spv::Dim::TileImageDataEXT) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Image Dim TileImageDataEXT cannot be used with " + << spvOpcodeString(opcode); + } + if (_.GetIdOpcode(info.sampled_type) != spv::Op::OpTypeVoid) { const uint32_t result_component_type = _.GetComponentType(actual_result_type); @@ -1686,6 +1784,11 @@ spv_result_t ValidateImageWrite(ValidationState_t& _, const Instruction* inst) { << "Image 'Dim' cannot be SubpassData"; } + if (info.dim == spv::Dim::TileImageDataEXT) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Image 'Dim' cannot be TileImageDataEXT"; + } + if (spv_result_t result = ValidateImageReadWrite(_, inst, info)) return result; @@ -1900,10 +2003,22 @@ spv_result_t ValidateImageQueryFormatOrOrder(ValidationState_t& _, << "Expected Result Type to be int scalar type"; } - if (_.GetIdOpcode(_.GetOperandTypeId(inst, 2)) != spv::Op::OpTypeImage) { + const uint32_t image_type = _.GetOperandTypeId(inst, 2); + if (_.GetIdOpcode(image_type) != spv::Op::OpTypeImage) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected operand to be of type OpTypeImage"; } + + ImageTypeInfo info; + if (!GetImageTypeInfo(_, image_type, &info)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Corrupt image type definition"; + } + + if (info.dim == spv::Dim::TileImageDataEXT) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Image 'Dim' cannot be TileImageDataEXT"; + } return SPV_SUCCESS; } @@ -1913,11 +2028,13 @@ spv_result_t ValidateImageQueryLod(ValidationState_t& _, ->RegisterExecutionModelLimitation( [&](spv::ExecutionModel model, std::string* message) { if (model != spv::ExecutionModel::Fragment && - model != spv::ExecutionModel::GLCompute) { + model != spv::ExecutionModel::GLCompute && + model != spv::ExecutionModel::MeshEXT && + model != spv::ExecutionModel::TaskEXT) { if (message) { *message = std::string( - "OpImageQueryLod requires Fragment or GLCompute execution " - "model"); + "OpImageQueryLod requires Fragment, GLCompute, MeshEXT or " + "TaskEXT execution model"); } return false; } @@ -1929,16 +2046,20 @@ spv_result_t ValidateImageQueryLod(ValidationState_t& _, std::string* message) { const auto* models = state.GetExecutionModels(entry_point->id()); const auto* modes = state.GetExecutionModes(entry_point->id()); - if (models->find(spv::ExecutionModel::GLCompute) != models->end() && - modes->find(spv::ExecutionMode::DerivativeGroupLinearNV) == - modes->end() && - modes->find(spv::ExecutionMode::DerivativeGroupQuadsNV) == - modes->end()) { + if (models && + (models->find(spv::ExecutionModel::GLCompute) != models->end() || + models->find(spv::ExecutionModel::MeshEXT) != models->end() || + models->find(spv::ExecutionModel::TaskEXT) != models->end()) && + (!modes || + (modes->find(spv::ExecutionMode::DerivativeGroupLinearKHR) == + modes->end() && + modes->find(spv::ExecutionMode::DerivativeGroupQuadsKHR) == + modes->end()))) { if (message) { *message = std::string( - "OpImageQueryLod requires DerivativeGroupQuadsNV " - "or DerivativeGroupLinearNV execution mode for GLCompute " - "execution model"); + "OpImageQueryLod requires DerivativeGroupQuadsKHR " + "or DerivativeGroupLinearKHR execution mode for GLCompute, " + "MeshEXT or TaskEXT execution model"); } return false; } @@ -1996,11 +2117,11 @@ spv_result_t ValidateImageQueryLod(ValidationState_t& _, << " components, but given only " << actual_coord_size; } - // The operad is a sampled image. + // The operand is a sampled image. // The sampled image type is already checked to be parameterized by an image // type with Sampled=0 or Sampled=1. Vulkan bans Sampled=0, and so we have // Sampled=1. So the validator already enforces Vulkan VUID 4659: - // OpImageQuerySizeLod must only consume an “Image” operand whose type has + // OpImageQuerySizeLod must only consume an "Image" operand whose type has // its "Sampled" operand set to 1 return SPV_SUCCESS; } @@ -2076,6 +2197,127 @@ spv_result_t ValidateImageSparseTexelsResident(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateImageProcessingQCOMDecoration(ValidationState_t& _, int id, + spv::Decoration decor) { + const Instruction* si_inst = nullptr; + const Instruction* ld_inst = _.FindDef(id); + bool is_intf_obj = (ld_inst->opcode() == spv::Op::OpSampledImage); + if (is_intf_obj == true) { + si_inst = ld_inst; + int t_idx = si_inst->GetOperandAs(2); // texture + ld_inst = _.FindDef(t_idx); + } + if (ld_inst->opcode() != spv::Op::OpLoad) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) << "Expect to see OpLoad"; + } + int texture_id = ld_inst->GetOperandAs(2); // variable to load + if (!_.HasDecoration(texture_id, decor)) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) + << "Missing decoration " << _.SpvDecorationString(decor); + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateImageProcessing2QCOMWindowDecoration(ValidationState_t& _, + int id) { + const Instruction* ld_inst = _.FindDef(id); + bool is_intf_obj = (ld_inst->opcode() != spv::Op::OpSampledImage); + if (is_intf_obj == true) { + if (ld_inst->opcode() != spv::Op::OpLoad) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) << "Expect to see OpLoad"; + } + int texture_id = ld_inst->GetOperandAs(2); // variable to load + spv::Decoration decor = spv::Decoration::BlockMatchTextureQCOM; + if (!_.HasDecoration(texture_id, decor)) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) + << "Missing decoration " << _.SpvDecorationString(decor); + } + decor = spv::Decoration::BlockMatchSamplerQCOM; + if (!_.HasDecoration(texture_id, decor)) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) + << "Missing decoration " << _.SpvDecorationString(decor); + } + } else { + const Instruction* si_inst = ld_inst; + int t_idx = si_inst->GetOperandAs(2); // texture + const Instruction* t_ld_inst = _.FindDef(t_idx); + if (t_ld_inst->opcode() != spv::Op::OpLoad) { + return _.diag(SPV_ERROR_INVALID_DATA, t_ld_inst) + << "Expect to see OpLoad"; + } + int texture_id = t_ld_inst->GetOperandAs(2); // variable to load + spv::Decoration decor = spv::Decoration::BlockMatchTextureQCOM; + if (!_.HasDecoration(texture_id, decor)) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) + << "Missing decoration " << _.SpvDecorationString(decor); + } + int s_idx = si_inst->GetOperandAs(3); // sampler + const Instruction* s_ld_inst = _.FindDef(s_idx); + if (s_ld_inst->opcode() != spv::Op::OpLoad) { + return _.diag(SPV_ERROR_INVALID_DATA, s_ld_inst) + << "Expect to see OpLoad"; + } + int sampler_id = s_ld_inst->GetOperandAs(2); // variable to load + decor = spv::Decoration::BlockMatchSamplerQCOM; + if (!_.HasDecoration(sampler_id, decor)) { + return _.diag(SPV_ERROR_INVALID_DATA, ld_inst) + << "Missing decoration " << _.SpvDecorationString(decor); + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateImageProcessingQCOM(ValidationState_t& _, + const Instruction* inst) { + spv_result_t res = SPV_SUCCESS; + const spv::Op opcode = inst->opcode(); + switch (opcode) { + case spv::Op::OpImageSampleWeightedQCOM: { + int wi_idx = inst->GetOperandAs(4); // weight + res = ValidateImageProcessingQCOMDecoration( + _, wi_idx, spv::Decoration::WeightTextureQCOM); + break; + } + case spv::Op::OpImageBlockMatchSSDQCOM: + case spv::Op::OpImageBlockMatchSADQCOM: { + int tgt_idx = inst->GetOperandAs(2); // target + res = ValidateImageProcessingQCOMDecoration( + _, tgt_idx, spv::Decoration::BlockMatchTextureQCOM); + if (res != SPV_SUCCESS) break; + int ref_idx = inst->GetOperandAs(4); // reference + res = ValidateImageProcessingQCOMDecoration( + _, ref_idx, spv::Decoration::BlockMatchTextureQCOM); + break; + } + case spv::Op::OpImageBlockMatchWindowSSDQCOM: + case spv::Op::OpImageBlockMatchWindowSADQCOM: { + int tgt_idx = inst->GetOperandAs(2); // target + res = ValidateImageProcessing2QCOMWindowDecoration(_, tgt_idx); + if (res != SPV_SUCCESS) break; + int ref_idx = inst->GetOperandAs(4); // reference + res = ValidateImageProcessing2QCOMWindowDecoration(_, ref_idx); + break; + } + case spv::Op::OpImageBlockMatchGatherSSDQCOM: + case spv::Op::OpImageBlockMatchGatherSADQCOM: { + int tgt_idx = inst->GetOperandAs(2); // target + res = ValidateImageProcessingQCOMDecoration( + _, tgt_idx, spv::Decoration::BlockMatchTextureQCOM); + if (res != SPV_SUCCESS) break; + int ref_idx = inst->GetOperandAs(4); // reference + res = ValidateImageProcessingQCOMDecoration( + _, ref_idx, spv::Decoration::BlockMatchTextureQCOM); + break; + } + default: + break; + } + + return res; +} + } // namespace // Validates correctness of image instructions. @@ -2086,12 +2328,14 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { ->RegisterExecutionModelLimitation([opcode](spv::ExecutionModel model, std::string* message) { if (model != spv::ExecutionModel::Fragment && - model != spv::ExecutionModel::GLCompute) { + model != spv::ExecutionModel::GLCompute && + model != spv::ExecutionModel::MeshEXT && + model != spv::ExecutionModel::TaskEXT) { if (message) { *message = std::string( - "ImplicitLod instructions require Fragment or GLCompute " - "execution model: ") + + "ImplicitLod instructions require Fragment, GLCompute, " + "MeshEXT or TaskEXT execution model: ") + spvOpcodeString(opcode); } return false; @@ -2105,19 +2349,22 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { const auto* models = state.GetExecutionModels(entry_point->id()); const auto* modes = state.GetExecutionModes(entry_point->id()); if (models && - models->find(spv::ExecutionModel::GLCompute) != models->end() && + (models->find(spv::ExecutionModel::GLCompute) != models->end() || + models->find(spv::ExecutionModel::MeshEXT) != models->end() || + models->find(spv::ExecutionModel::TaskEXT) != models->end()) && (!modes || - (modes->find(spv::ExecutionMode::DerivativeGroupLinearNV) == + (modes->find(spv::ExecutionMode::DerivativeGroupLinearKHR) == modes->end() && - modes->find(spv::ExecutionMode::DerivativeGroupQuadsNV) == + modes->find(spv::ExecutionMode::DerivativeGroupQuadsKHR) == modes->end()))) { if (message) { - *message = - std::string( - "ImplicitLod instructions require DerivativeGroupQuadsNV " - "or DerivativeGroupLinearNV execution mode for GLCompute " - "execution model: ") + - spvOpcodeString(opcode); + *message = std::string( + "ImplicitLod instructions require " + "DerivativeGroupQuadsKHR " + "or DerivativeGroupLinearKHR execution mode for " + "GLCompute, " + "MeshEXT or TaskEXT execution model: ") + + spvOpcodeString(opcode); } return false; } @@ -2195,6 +2442,16 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpImageSparseTexelsResident: return ValidateImageSparseTexelsResident(_, inst); + case spv::Op::OpImageSampleWeightedQCOM: + case spv::Op::OpImageBoxFilterQCOM: + case spv::Op::OpImageBlockMatchSSDQCOM: + case spv::Op::OpImageBlockMatchSADQCOM: + case spv::Op::OpImageBlockMatchWindowSADQCOM: + case spv::Op::OpImageBlockMatchWindowSSDQCOM: + case spv::Op::OpImageBlockMatchGatherSADQCOM: + case spv::Op::OpImageBlockMatchGatherSSDQCOM: + return ValidateImageProcessingQCOM(_, inst); + default: break; } @@ -2202,5 +2459,98 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { return SPV_SUCCESS; } +bool IsImageInstruction(const spv::Op opcode) { + switch (opcode) { + case spv::Op::OpImageSampleImplicitLod: + case spv::Op::OpImageSampleDrefImplicitLod: + case spv::Op::OpImageSampleProjImplicitLod: + case spv::Op::OpImageSampleProjDrefImplicitLod: + case spv::Op::OpImageSparseSampleImplicitLod: + case spv::Op::OpImageSparseSampleDrefImplicitLod: + case spv::Op::OpImageSparseSampleProjImplicitLod: + case spv::Op::OpImageSparseSampleProjDrefImplicitLod: + + case spv::Op::OpImageSampleExplicitLod: + case spv::Op::OpImageSampleDrefExplicitLod: + case spv::Op::OpImageSampleProjExplicitLod: + case spv::Op::OpImageSampleProjDrefExplicitLod: + case spv::Op::OpImageSparseSampleExplicitLod: + case spv::Op::OpImageSparseSampleDrefExplicitLod: + case spv::Op::OpImageSparseSampleProjExplicitLod: + case spv::Op::OpImageSparseSampleProjDrefExplicitLod: + + case spv::Op::OpImage: + case spv::Op::OpImageFetch: + case spv::Op::OpImageSparseFetch: + case spv::Op::OpImageGather: + case spv::Op::OpImageDrefGather: + case spv::Op::OpImageSparseGather: + case spv::Op::OpImageSparseDrefGather: + case spv::Op::OpImageRead: + case spv::Op::OpImageSparseRead: + case spv::Op::OpImageWrite: + + case spv::Op::OpImageQueryFormat: + case spv::Op::OpImageQueryOrder: + case spv::Op::OpImageQuerySizeLod: + case spv::Op::OpImageQuerySize: + case spv::Op::OpImageQueryLod: + case spv::Op::OpImageQueryLevels: + case spv::Op::OpImageQuerySamples: + + case spv::Op::OpImageSampleWeightedQCOM: + case spv::Op::OpImageBoxFilterQCOM: + case spv::Op::OpImageBlockMatchSSDQCOM: + case spv::Op::OpImageBlockMatchSADQCOM: + case spv::Op::OpImageBlockMatchWindowSADQCOM: + case spv::Op::OpImageBlockMatchWindowSSDQCOM: + case spv::Op::OpImageBlockMatchGatherSADQCOM: + case spv::Op::OpImageBlockMatchGatherSSDQCOM: + return true; + default: + break; + } + return false; +} + +spv_result_t ValidateQCOMImageProcessingTextureUsages(ValidationState_t& _, + const Instruction* inst) { + const spv::Op opcode = inst->opcode(); + if (!IsImageInstruction(opcode)) return SPV_SUCCESS; + + switch (opcode) { + case spv::Op::OpImageSampleWeightedQCOM: + case spv::Op::OpImageBoxFilterQCOM: + case spv::Op::OpImageBlockMatchSSDQCOM: + case spv::Op::OpImageBlockMatchSADQCOM: + break; + case spv::Op::OpImageBlockMatchWindowSADQCOM: + case spv::Op::OpImageBlockMatchWindowSSDQCOM: + case spv::Op::OpImageBlockMatchGatherSADQCOM: + case spv::Op::OpImageBlockMatchGatherSSDQCOM: + break; + default: + for (size_t i = 0; i < inst->operands().size(); ++i) { + int id = inst->GetOperandAs(i); + const Instruction* operand_inst = _.FindDef(id); + if (operand_inst == nullptr) continue; + if (operand_inst->opcode() == spv::Op::OpLoad) { + if (_.IsQCOMImageProcessingTextureConsumer(id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Illegal use of QCOM image processing decorated texture"; + } + } + if (operand_inst->opcode() == spv::Op::OpSampledImage) { + if (_.IsQCOMImageProcessingTextureConsumer(id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Illegal use of QCOM image processing decorated texture"; + } + } + } + break; + } + return SPV_SUCCESS; +} + } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/source/val/validate_instruction.cpp b/third_party/spirv-tools/source/val/validate_instruction.cpp index 1b7847cacb..acb0d6379f 100644 --- a/third_party/spirv-tools/source/val/validate_instruction.cpp +++ b/third_party/spirv-tools/source/val/validate_instruction.cpp @@ -14,26 +14,20 @@ // Performs validation on instructions that appear inside of a SPIR-V block. -#include #include -#include #include #include #include -#include "source/binary.h" -#include "source/diagnostic.h" #include "source/enum_set.h" #include "source/enum_string_mapping.h" #include "source/extensions.h" #include "source/opcode.h" #include "source/operand.h" #include "source/spirv_constant.h" -#include "source/spirv_definition.h" #include "source/spirv_target_env.h" #include "source/spirv_validator_options.h" #include "source/util/string_utils.h" -#include "source/val/function.h" #include "source/val/validate.h" #include "source/val/validation_state.h" @@ -44,14 +38,14 @@ namespace { std::string ToString(const CapabilitySet& capabilities, const AssemblyGrammar& grammar) { std::stringstream ss; - capabilities.ForEach([&grammar, &ss](spv::Capability cap) { + for (auto capability : capabilities) { spv_operand_desc desc; if (SPV_SUCCESS == grammar.lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, - uint32_t(cap), &desc)) + uint32_t(capability), &desc)) ss << desc->name << " "; else - ss << uint32_t(cap) << " "; - }); + ss << uint32_t(capability) << " "; + } return ss.str(); } @@ -184,10 +178,11 @@ spv_result_t CheckRequiredCapabilities(ValidationState_t& state, // Vulkan API requires more capabilities on rounding mode. if (spvIsVulkanEnv(state.context()->target_env)) { - enabling_capabilities.Add(spv::Capability::StorageUniformBufferBlock16); - enabling_capabilities.Add(spv::Capability::StorageUniform16); - enabling_capabilities.Add(spv::Capability::StoragePushConstant16); - enabling_capabilities.Add(spv::Capability::StorageInputOutput16); + enabling_capabilities.insert( + spv::Capability::StorageUniformBufferBlock16); + enabling_capabilities.insert(spv::Capability::StorageUniform16); + enabling_capabilities.insert(spv::Capability::StoragePushConstant16); + enabling_capabilities.insert(spv::Capability::StorageInputOutput16); } } else { enabling_capabilities = state.grammar().filterCapsAgainstTargetEnv( @@ -201,7 +196,7 @@ spv_result_t CheckRequiredCapabilities(ValidationState_t& state, if (inst->opcode() != spv::Op::OpCapability) { const bool enabled_by_cap = state.HasAnyOfCapabilities(enabling_capabilities); - if (!enabling_capabilities.IsEmpty() && !enabled_by_cap) { + if (!enabling_capabilities.empty() && !enabled_by_cap) { return state.diag(SPV_ERROR_INVALID_CAPABILITY, inst) << "Operand " << which_operand << " of " << spvOpcodeString(inst->opcode()) @@ -309,7 +304,7 @@ spv_result_t VersionCheck(ValidationState_t& _, const Instruction* inst) { } ExtensionSet exts(inst_desc->numExtensions, inst_desc->extensions); - if (exts.IsEmpty()) { + if (exts.empty()) { // If no extensions can enable this instruction, then emit error // messages only concerning core SPIR-V versions if errors happen. if (min_version == ~0u) { @@ -475,10 +470,21 @@ spv_result_t InstructionPass(ValidationState_t& _, const Instruction* inst) { } _.set_addressing_model(inst->GetOperandAs(0)); _.set_memory_model(inst->GetOperandAs(1)); - } else if (opcode == spv::Op::OpExecutionMode) { + } else if (opcode == spv::Op::OpExecutionMode || + opcode == spv::Op::OpExecutionModeId) { const uint32_t entry_point = inst->word(1); _.RegisterExecutionModeForEntryPoint(entry_point, spv::ExecutionMode(inst->word(2))); + if (inst->GetOperandAs(1) == + spv::ExecutionMode::LocalSize || + inst->GetOperandAs(1) == + spv::ExecutionMode::LocalSizeId) { + _.RegisterEntryPointLocalSize(entry_point, inst); + } + if (inst->GetOperandAs(1) == + spv::ExecutionMode::OutputPrimitivesEXT) { + _.RegisterEntryPointOutputPrimitivesEXT(entry_point, inst); + } } else if (opcode == spv::Op::OpVariable) { const auto storage_class = inst->GetOperandAs(2); if (auto error = LimitCheckNumVars(_, inst->id(), storage_class)) { diff --git a/third_party/spirv-tools/source/val/validate_interfaces.cpp b/third_party/spirv-tools/source/val/validate_interfaces.cpp index 00a5999bdf..8b96dc8248 100644 --- a/third_party/spirv-tools/source/val/validate_interfaces.cpp +++ b/third_party/spirv-tools/source/val/validate_interfaces.cpp @@ -15,7 +15,6 @@ #include #include -#include "source/diagnostic.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/val/function.h" @@ -35,11 +34,13 @@ const uint32_t kMaxLocations = 4096 * 4; bool is_interface_variable(const Instruction* inst, bool is_spv_1_4) { if (is_spv_1_4) { // Starting in SPIR-V 1.4, all global variables are interface variables. - return inst->opcode() == spv::Op::OpVariable && + return (inst->opcode() == spv::Op::OpVariable || + inst->opcode() == spv::Op::OpUntypedVariableKHR) && inst->GetOperandAs(2u) != spv::StorageClass::Function; } else { - return inst->opcode() == spv::Op::OpVariable && + return (inst->opcode() == spv::Op::OpVariable || + inst->opcode() == spv::Op::OpUntypedVariableKHR) && (inst->GetOperandAs(2u) == spv::StorageClass::Input || inst->GetOperandAs(2u) == @@ -174,8 +175,19 @@ spv_result_t NumConsumedLocations(ValidationState_t& _, const Instruction* type, } break; } + case spv::Op::OpTypePointer: { + if (_.addressing_model() == + spv::AddressingModel::PhysicalStorageBuffer64 && + type->GetOperandAs(1) == + spv::StorageClass::PhysicalStorageBuffer) { + *num_locations = 1; + break; + } + [[fallthrough]]; + } default: - break; + return _.diag(SPV_ERROR_INVALID_DATA, type) + << "Invalid type to assign a location"; } return SPV_SUCCESS; @@ -207,6 +219,14 @@ uint32_t NumConsumedComponents(ValidationState_t& _, const Instruction* type) { // Skip the array. return NumConsumedComponents(_, _.FindDef(type->GetOperandAs(1))); + case spv::Op::OpTypePointer: + if (_.addressing_model() == + spv::AddressingModel::PhysicalStorageBuffer64 && + type->GetOperandAs(1) == + spv::StorageClass::PhysicalStorageBuffer) { + return 2; + } + break; default: // This is an error that is validated elsewhere. break; @@ -224,8 +244,9 @@ spv_result_t GetLocationsForVariable( std::unordered_set* output_index1_locations) { const bool is_fragment = entry_point->GetOperandAs(0) == spv::ExecutionModel::Fragment; - const bool is_output = - variable->GetOperandAs(2) == spv::StorageClass::Output; + const auto sc_index = 2u; + const bool is_output = variable->GetOperandAs(sc_index) == + spv::StorageClass::Output; auto ptr_type_id = variable->GetOperandAs(0); auto ptr_type = _.FindDef(ptr_type_id); auto type_id = ptr_type->GetOperandAs(2); @@ -236,37 +257,24 @@ spv_result_t GetLocationsForVariable( // equal. Also track Patch and PerTaskNV decorations. bool has_location = false; uint32_t location = 0; - bool has_component = false; uint32_t component = 0; bool has_index = false; uint32_t index = 0; bool has_patch = false; bool has_per_task_nv = false; bool has_per_vertex_khr = false; + // Duplicate Location, Component, Index are checked elsewhere. for (auto& dec : _.id_decorations(variable->id())) { if (dec.dec_type() == spv::Decoration::Location) { - if (has_location && dec.params()[0] != location) { - return _.diag(SPV_ERROR_INVALID_DATA, variable) - << "Variable has conflicting location decorations"; - } has_location = true; location = dec.params()[0]; } else if (dec.dec_type() == spv::Decoration::Component) { - if (has_component && dec.params()[0] != component) { - return _.diag(SPV_ERROR_INVALID_DATA, variable) - << "Variable has conflicting component decorations"; - } - has_component = true; component = dec.params()[0]; } else if (dec.dec_type() == spv::Decoration::Index) { if (!is_output || !is_fragment) { return _.diag(SPV_ERROR_INVALID_DATA, variable) << "Index can only be applied to Fragment output variables"; } - if (has_index && dec.params()[0] != index) { - return _.diag(SPV_ERROR_INVALID_DATA, variable) - << "Variable has conflicting index decorations"; - } has_index = true; index = dec.params()[0]; } else if (dec.dec_type() == spv::Decoration::BuiltIn) { @@ -364,12 +372,12 @@ spv_result_t GetLocationsForVariable( sub_type = _.FindDef(sub_type_id); } - for (uint32_t array_idx = 0; array_idx < array_size; ++array_idx) { - uint32_t num_locations = 0; - if (auto error = NumConsumedLocations(_, sub_type, &num_locations)) - return error; + uint32_t num_locations = 0; + if (auto error = NumConsumedLocations(_, sub_type, &num_locations)) + return error; + uint32_t num_components = NumConsumedComponents(_, sub_type); - uint32_t num_components = NumConsumedComponents(_, sub_type); + for (uint32_t array_idx = 0; array_idx < array_size; ++array_idx) { uint32_t array_location = location + (num_locations * array_idx); uint32_t start = array_location * 4; if (kMaxLocations <= start) { @@ -389,6 +397,7 @@ spv_result_t GetLocationsForVariable( for (uint32_t i = start; i < end; ++i) { if (!locs->insert(i).second) { return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << (is_output ? _.VkErrorID(8722) : _.VkErrorID(8721)) << "Entry-point has conflicting " << storage_class << " location assignment at location " << i / 4 << ", component " << i % 4; @@ -460,6 +469,7 @@ spv_result_t GetLocationsForVariable( uint32_t check = 4 * l + c; if (!locations->insert(check).second) { return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << (is_output ? _.VkErrorID(8722) : _.VkErrorID(8721)) << "Entry-point has conflicting " << storage_class << " location assignment at location " << l << ", component " << c; @@ -477,6 +487,7 @@ spv_result_t GetLocationsForVariable( for (uint32_t l = start; l < end; ++l) { if (!locations->insert(l).second) { return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << (is_output ? _.VkErrorID(8722) : _.VkErrorID(8721)) << "Entry-point has conflicting " << storage_class << " location assignment at location " << l / 4 << ", component " << l % 4; @@ -511,11 +522,15 @@ spv_result_t ValidateLocations(ValidationState_t& _, std::unordered_set input_locations; std::unordered_set output_locations_index0; std::unordered_set output_locations_index1; + std::unordered_set patch_locations_index0; + std::unordered_set patch_locations_index1; std::unordered_set seen; for (uint32_t i = 3; i < entry_point->operands().size(); ++i) { auto interface_id = entry_point->GetOperandAs(i); auto interface_var = _.FindDef(interface_id); - auto storage_class = interface_var->GetOperandAs(2); + const auto sc_index = 2u; + auto storage_class = + interface_var->GetOperandAs(sc_index); if (storage_class != spv::StorageClass::Input && storage_class != spv::StorageClass::Output) { continue; @@ -526,6 +541,26 @@ spv_result_t ValidateLocations(ValidationState_t& _, continue; } + // The two Tessellation stages have a "Patch" variable that interface with + // the Location mechanism, but are not suppose to be tied to the "normal" + // input/output Location. + // TODO - SPIR-V allows the Patch decoration to be applied to struct + // members, but is not allowed in GLSL/HLSL + bool has_patch = false; + for (auto& dec : _.id_decorations(interface_var->id())) { + if (dec.dec_type() == spv::Decoration::Patch) { + has_patch = true; + if (auto error = GetLocationsForVariable(_, entry_point, interface_var, + &patch_locations_index0, + &patch_locations_index1)) + return error; + break; + } + } + if (has_patch) { + continue; + } + auto locations = (storage_class == spv::StorageClass::Input) ? &input_locations : &output_locations_index0; @@ -537,6 +572,64 @@ spv_result_t ValidateLocations(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateStorageClass(ValidationState_t& _, + const Instruction* entry_point) { + bool has_push_constant = false; + bool has_ray_payload = false; + bool has_hit_attribute = false; + bool has_callable_data = false; + for (uint32_t i = 3; i < entry_point->operands().size(); ++i) { + auto interface_id = entry_point->GetOperandAs(i); + auto interface_var = _.FindDef(interface_id); + auto storage_class = interface_var->GetOperandAs(2); + switch (storage_class) { + case spv::StorageClass::PushConstant: { + if (has_push_constant) { + return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << _.VkErrorID(6673) + << "Entry-point has more than one variable with the " + "PushConstant storage class in the interface"; + } + has_push_constant = true; + break; + } + case spv::StorageClass::IncomingRayPayloadKHR: { + if (has_ray_payload) { + return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << _.VkErrorID(4700) + << "Entry-point has more than one variable with the " + "IncomingRayPayloadKHR storage class in the interface"; + } + has_ray_payload = true; + break; + } + case spv::StorageClass::HitAttributeKHR: { + if (has_hit_attribute) { + return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << _.VkErrorID(4702) + << "Entry-point has more than one variable with the " + "HitAttributeKHR storage class in the interface"; + } + has_hit_attribute = true; + break; + } + case spv::StorageClass::IncomingCallableDataKHR: { + if (has_callable_data) { + return _.diag(SPV_ERROR_INVALID_DATA, entry_point) + << _.VkErrorID(4706) + << "Entry-point has more than one variable with the " + "IncomingCallableDataKHR storage class in the interface"; + } + has_callable_data = true; + break; + } + default: + break; + } + } + return SPV_SUCCESS; +} + } // namespace spv_result_t ValidateInterfaces(ValidationState_t& _) { @@ -555,6 +648,9 @@ spv_result_t ValidateInterfaces(ValidationState_t& _) { if (auto error = ValidateLocations(_, &inst)) { return error; } + if (auto error = ValidateStorageClass(_, &inst)) { + return error; + } } if (inst.opcode() == spv::Op::OpTypeVoid) break; } diff --git a/third_party/spirv-tools/source/val/validate_layout.cpp b/third_party/spirv-tools/source/val/validate_layout.cpp index 238dd9b2fe..baf36b89bd 100644 --- a/third_party/spirv-tools/source/val/validate_layout.cpp +++ b/third_party/spirv-tools/source/val/validate_layout.cpp @@ -14,12 +14,9 @@ // Source code for logical layout validation as described in section 2.4 -#include - #include "DebugInfo.h" #include "NonSemanticShaderDebugInfo100.h" #include "OpenCLDebugInfo100.h" -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/operand.h" #include "source/val/function.h" @@ -38,6 +35,7 @@ spv_result_t ModuleScopedInstructions(ValidationState_t& _, const Instruction* inst, spv::Op opcode) { switch (opcode) { case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: if (spvExtInstIsDebugInfo(inst->ext_inst_type())) { const uint32_t ext_inst_index = inst->word(4); bool local_debug_info = false; @@ -77,8 +75,8 @@ spv_result_t ModuleScopedInstructions(ValidationState_t& _, if (local_debug_info) { if (_.in_function_body() == false) { - // DebugScope, DebugNoScope, DebugDeclare, DebugValue must - // appear in a function body. + // TODO - Print the actual name of the instruction as this list is + // not complete (see ext_inst_name in ValidateExtInst() for example) return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) << "DebugScope, DebugNoScope, DebugDeclare, DebugValue " << "of debug info extension must appear in a function " @@ -246,6 +244,7 @@ spv_result_t FunctionScopedInstructions(ValidationState_t& _, break; case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: if (spvExtInstIsDebugInfo(inst->ext_inst_type())) { const uint32_t ext_inst_index = inst->word(4); bool local_debug_info = false; diff --git a/third_party/spirv-tools/source/val/validate_literals.cpp b/third_party/spirv-tools/source/val/validate_literals.cpp index 53aae0767a..15cc27a92f 100644 --- a/third_party/spirv-tools/source/val/validate_literals.cpp +++ b/third_party/spirv-tools/source/val/validate_literals.cpp @@ -14,13 +14,10 @@ // Validates literal numbers. -#include "source/val/validate.h" - #include -#include "source/diagnostic.h" -#include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/val/validate_logicals.cpp b/third_party/spirv-tools/source/val/validate_logicals.cpp index dd66ce948e..8a2e5d8c42 100644 --- a/third_party/spirv-tools/source/val/validate_logicals.cpp +++ b/third_party/spirv-tools/source/val/validate_logicals.cpp @@ -14,11 +14,9 @@ // Validates correctness of logical SPIR-V instructions. -#include "source/val/validate.h" - -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { @@ -161,9 +159,11 @@ spv_result_t LogicalsPass(ValidationState_t& _, const Instruction* inst) { const spv::Op type_opcode = type_inst->opcode(); switch (type_opcode) { + case spv::Op::OpTypeUntypedPointerKHR: case spv::Op::OpTypePointer: { if (_.addressing_model() == spv::AddressingModel::Logical && - !_.features().variable_pointers) + !_.HasCapability( + spv::Capability::VariablePointersStorageBuffer)) return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Using pointers with OpSelect requires capability " << "VariablePointers or VariablePointersStorageBuffer"; diff --git a/third_party/spirv-tools/source/val/validate_memory.cpp b/third_party/spirv-tools/source/val/validate_memory.cpp index 57fd23d532..ba45fa84d5 100644 --- a/third_party/spirv-tools/source/val/validate_memory.cpp +++ b/third_party/spirv-tools/source/val/validate_memory.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2018 Google LLC. -// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights -// reserved. +// Modifications Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All +// rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -196,42 +196,15 @@ bool ContainsInvalidBool(ValidationState_t& _, const Instruction* storage, return false; } -bool ContainsCooperativeMatrix(ValidationState_t& _, - const Instruction* storage) { - const size_t elem_type_index = 1; - uint32_t elem_type_id; - Instruction* elem_type; - - switch (storage->opcode()) { - case spv::Op::OpTypeCooperativeMatrixNV: - return true; - case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: - elem_type_id = storage->GetOperandAs(elem_type_index); - elem_type = _.FindDef(elem_type_id); - return ContainsCooperativeMatrix(_, elem_type); - case spv::Op::OpTypeStruct: - for (size_t member_type_index = 1; - member_type_index < storage->operands().size(); - ++member_type_index) { - auto member_type_id = - storage->GetOperandAs(member_type_index); - auto member_type = _.FindDef(member_type_id); - if (ContainsCooperativeMatrix(_, member_type)) return true; - } - break; - default: - break; - } - return false; -} - std::pair GetStorageClass( ValidationState_t& _, const Instruction* inst) { spv::StorageClass dst_sc = spv::StorageClass::Max; spv::StorageClass src_sc = spv::StorageClass::Max; switch (inst->opcode()) { case spv::Op::OpCooperativeMatrixLoadNV: + case spv::Op::OpCooperativeMatrixLoadTensorNV: + case spv::Op::OpCooperativeMatrixLoadKHR: + case spv::Op::OpCooperativeVectorLoadNV: case spv::Op::OpLoad: { auto load_pointer = _.FindDef(inst->GetOperandAs(2)); auto load_pointer_type = _.FindDef(load_pointer->type_id()); @@ -239,6 +212,9 @@ std::pair GetStorageClass( break; } case spv::Op::OpCooperativeMatrixStoreNV: + case spv::Op::OpCooperativeMatrixStoreTensorNV: + case spv::Op::OpCooperativeMatrixStoreKHR: + case spv::Op::OpCooperativeVectorStoreNV: case spv::Op::OpStore: { auto store_pointer = _.FindDef(inst->GetOperandAs(0)); auto store_pointer_type = _.FindDef(store_pointer->type_id()); @@ -275,8 +251,9 @@ int MemoryAccessNumWords(uint32_t mask) { // Returns the scope ID operand for MakeAvailable memory access with mask // at the given operand index. // This function is only called for OpLoad, OpStore, OpCopyMemory and -// OpCopyMemorySized, OpCooperativeMatrixLoadNV, and -// OpCooperativeMatrixStoreNV. +// OpCopyMemorySized, OpCooperativeMatrixLoadNV, +// OpCooperativeMatrixStoreNV, OpCooperativeVectorLoadNV, +// OpCooperativeVectorStoreNV. uint32_t GetMakeAvailableScope(const Instruction* inst, uint32_t mask, uint32_t mask_index) { assert(mask & uint32_t(spv::MemoryAccessMask::MakePointerAvailableKHR)); @@ -287,8 +264,9 @@ uint32_t GetMakeAvailableScope(const Instruction* inst, uint32_t mask, } // This function is only called for OpLoad, OpStore, OpCopyMemory, -// OpCopyMemorySized, OpCooperativeMatrixLoadNV, and -// OpCooperativeMatrixStoreNV. +// OpCopyMemorySized, OpCooperativeMatrixLoadNV, +// OpCooperativeMatrixStoreNV, OpCooperativeVectorLoadNV, +// OpCooperativeVectorStoreNV. uint32_t GetMakeVisibleScope(const Instruction* inst, uint32_t mask, uint32_t mask_index) { assert(mask & uint32_t(spv::MemoryAccessMask::MakePointerVisibleKHR)); @@ -326,7 +304,10 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, const uint32_t mask = inst->GetOperandAs(index); if (mask & uint32_t(spv::MemoryAccessMask::MakePointerAvailableKHR)) { if (inst->opcode() == spv::Op::OpLoad || - inst->opcode() == spv::Op::OpCooperativeMatrixLoadNV) { + inst->opcode() == spv::Op::OpCooperativeMatrixLoadNV || + inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV || + inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR || + inst->opcode() == spv::Op::OpCooperativeVectorLoadNV) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "MakePointerAvailableKHR cannot be used with OpLoad."; } @@ -345,7 +326,10 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, if (mask & uint32_t(spv::MemoryAccessMask::MakePointerVisibleKHR)) { if (inst->opcode() == spv::Op::OpStore || - inst->opcode() == spv::Op::OpCooperativeMatrixStoreNV) { + inst->opcode() == spv::Op::OpCooperativeMatrixStoreNV || + inst->opcode() == spv::Op::OpCooperativeMatrixStoreKHR || + inst->opcode() == spv::Op::OpCooperativeMatrixStoreTensorNV || + inst->opcode() == spv::Op::OpCooperativeVectorStoreNV) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "MakePointerVisibleKHR cannot be used with OpStore."; } @@ -402,53 +386,93 @@ spv_result_t CheckMemoryAccess(ValidationState_t& _, const Instruction* inst, } spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { + const bool untyped_pointer = inst->opcode() == spv::Op::OpUntypedVariableKHR; + auto result_type = _.FindDef(inst->type_id()); - if (!result_type || result_type->opcode() != spv::Op::OpTypePointer) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpVariable Result Type " << _.getIdName(inst->type_id()) - << " is not a pointer type."; + if (untyped_pointer) { + if (!result_type || + result_type->opcode() != spv::Op::OpTypeUntypedPointerKHR) + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Result type must be an untyped pointer"; + } else { + if (!result_type || result_type->opcode() != spv::Op::OpTypePointer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpVariable Result Type " << _.getIdName(inst->type_id()) + << " is not a pointer type."; + } } - const auto type_index = 2; - const auto value_id = result_type->GetOperandAs(type_index); - auto value_type = _.FindDef(value_id); + const auto storage_class_index = 2u; + auto storage_class = + inst->GetOperandAs(storage_class_index); + uint32_t value_id = 0; + if (untyped_pointer) { + const auto has_data_type = 3u < inst->operands().size(); + if (has_data_type) { + value_id = inst->GetOperandAs(3u); + auto data_type = _.FindDef(value_id); + if (!data_type || !spvOpcodeGeneratesType(data_type->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Data type must be a type instruction"; + } + } else { + if (storage_class == spv::StorageClass::Function || + storage_class == spv::StorageClass::Private || + storage_class == spv::StorageClass::Workgroup) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Data type must be specified for Function, Private, and " + "Workgroup storage classes"; + } + if (spvIsVulkanEnv(_.context()->target_env)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Vulkan requires that data type be specified"; + } + } + } - const auto initializer_index = 3; - const auto storage_class_index = 2; + // For OpVariable the data type comes from pointee type of the result type, + // while for OpUntypedVariableKHR the data type comes from the operand. + if (!untyped_pointer) { + value_id = result_type->GetOperandAs(2); + } + auto value_type = value_id == 0 ? nullptr : _.FindDef(value_id); + + const auto initializer_index = untyped_pointer ? 4u : 3u; if (initializer_index < inst->operands().size()) { const auto initializer_id = inst->GetOperandAs(initializer_index); const auto initializer = _.FindDef(initializer_id); const auto is_module_scope_var = - initializer && (initializer->opcode() == spv::Op::OpVariable) && + initializer && + (initializer->opcode() == spv::Op::OpVariable || + initializer->opcode() == spv::Op::OpUntypedVariableKHR) && (initializer->GetOperandAs(storage_class_index) != spv::StorageClass::Function); const auto is_constant = initializer && spvOpcodeIsConstant(initializer->opcode()); if (!initializer || !(is_constant || is_module_scope_var)) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpVariable Initializer " << _.getIdName(initializer_id) + << "Variable Initializer " << _.getIdName(initializer_id) << " is not a constant or module-scope variable."; } if (initializer->type_id() != value_id) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Initializer type must match the type pointed to by the Result " - "Type"; + << "Initializer type must match the data type"; } } - auto storage_class = - inst->GetOperandAs(storage_class_index); if (storage_class != spv::StorageClass::Workgroup && storage_class != spv::StorageClass::CrossWorkgroup && storage_class != spv::StorageClass::Private && storage_class != spv::StorageClass::Function && + storage_class != spv::StorageClass::UniformConstant && storage_class != spv::StorageClass::RayPayloadKHR && storage_class != spv::StorageClass::IncomingRayPayloadKHR && storage_class != spv::StorageClass::HitAttributeKHR && storage_class != spv::StorageClass::CallableDataKHR && storage_class != spv::StorageClass::IncomingCallableDataKHR && storage_class != spv::StorageClass::TaskPayloadWorkgroupEXT && - storage_class != spv::StorageClass::HitObjectAttributeNV) { + storage_class != spv::StorageClass::HitObjectAttributeNV && + storage_class != spv::StorageClass::NodePayloadAMDX) { bool storage_input_or_output = storage_class == spv::StorageClass::Input || storage_class == spv::StorageClass::Output; bool builtin = false; @@ -460,7 +484,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } } - if (!builtin && + if (!builtin && value_type && ContainsInvalidBool(_, value_type, storage_input_or_output)) { if (storage_input_or_output) { return _.diag(SPV_ERROR_INVALID_ID, inst) @@ -475,8 +499,9 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { "can only be used with non-externally visible shader Storage " "Classes: Workgroup, CrossWorkgroup, Private, Function, " "Input, Output, RayPayloadKHR, IncomingRayPayloadKHR, " - "HitAttributeKHR, CallableDataKHR, or " - "IncomingCallableDataKHR"; + "HitAttributeKHR, CallableDataKHR, " + "IncomingCallableDataKHR, NodePayloadAMDX, or " + "UniformConstant"; } } } @@ -489,7 +514,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { if (storage_class == spv::StorageClass::Generic) { return _.diag(SPV_ERROR_INVALID_BINARY, inst) - << "OpVariable storage class cannot be Generic"; + << "Variable storage class cannot be Generic"; } if (inst->function() && storage_class != spv::StorageClass::Function) { @@ -511,17 +536,17 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { result_type->GetOperandAs(result_storage_class_index); if (storage_class != result_storage_class) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "From SPIR-V spec, section 3.32.8 on OpVariable:\n" - << "Its Storage Class operand must be the same as the Storage Class " - << "operand of the result type."; + << "Storage class must match result type storage class"; } // Variable pointer related restrictions. - const auto pointee = _.FindDef(result_type->word(3)); + const auto pointee = untyped_pointer + ? value_id == 0 ? nullptr : _.FindDef(value_id) + : _.FindDef(result_type->word(3)); if (_.addressing_model() == spv::AddressingModel::Logical && !_.options()->relax_logical_pointer) { // VariablePointersStorageBuffer is implied by VariablePointers. - if (pointee->opcode() == spv::Op::OpTypePointer) { + if (pointee && pointee->opcode() == spv::Op::OpTypePointer) { if (!_.HasCapability(spv::Capability::VariablePointersStorageBuffer)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "In Logical addressing, variables may not allocate a pointer " @@ -540,7 +565,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { // Vulkan Push Constant Interface section: Check type of PushConstant // variables. if (storage_class == spv::StorageClass::PushConstant) { - if (pointee->opcode() != spv::Op::OpTypeStruct) { + if (pointee && pointee->opcode() != spv::Op::OpTypeStruct) { return _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(6808) << "PushConstant OpVariable " << _.getIdName(inst->id()) << " has illegal type.\n" @@ -552,11 +577,11 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { // Vulkan Descriptor Set Interface: Check type of UniformConstant and // Uniform variables. if (storage_class == spv::StorageClass::UniformConstant) { - if (!IsAllowedTypeOrArrayOfSame( - _, pointee, - {spv::Op::OpTypeImage, spv::Op::OpTypeSampler, - spv::Op::OpTypeSampledImage, - spv::Op::OpTypeAccelerationStructureKHR})) { + if (pointee && !IsAllowedTypeOrArrayOfSame( + _, pointee, + {spv::Op::OpTypeImage, spv::Op::OpTypeSampler, + spv::Op::OpTypeSampledImage, + spv::Op::OpTypeAccelerationStructureKHR})) { return _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(4655) << "UniformConstant OpVariable " << _.getIdName(inst->id()) << " has illegal type.\n" @@ -569,7 +594,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } if (storage_class == spv::StorageClass::Uniform) { - if (!IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) { + if (pointee && + !IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) { return _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(6807) << "Uniform OpVariable " << _.getIdName(inst->id()) << " has illegal type.\n" @@ -582,7 +608,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } if (storage_class == spv::StorageClass::StorageBuffer) { - if (!IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) { + if (pointee && + !IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) { return _.diag(SPV_ERROR_INVALID_ID, inst) << _.VkErrorID(6807) << "StorageBuffer OpVariable " << _.getIdName(inst->id()) << " has illegal type.\n" @@ -615,11 +642,17 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } } + } - // Initializers in Vulkan are only allowed in some storage clases - if (inst->operands().size() > 3) { + // Vulkan Appendix A: Check that if contains initializer, then + // storage class is Output, Private, or Function. + if (inst->operands().size() > initializer_index && + storage_class != spv::StorageClass::Output && + storage_class != spv::StorageClass::Private && + storage_class != spv::StorageClass::Function) { + if (spvIsVulkanEnv(_.context()->target_env)) { if (storage_class == spv::StorageClass::Workgroup) { - auto init_id = inst->GetOperandAs(3); + auto init_id = inst->GetOperandAs(initializer_index); auto init = _.FindDef(init_id); if (init->opcode() != spv::Op::OpConstantNull) { return _.diag(SPV_ERROR_INVALID_ID, inst) @@ -646,7 +679,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } } - if (inst->operands().size() > 3) { + if (initializer_index < inst->operands().size()) { if (storage_class == spv::StorageClass::TaskPayloadWorkgroupEXT) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpVariable, " << _.getIdName(inst->id()) @@ -669,33 +702,6 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { << "PhysicalStorageBuffer must not be used with OpVariable."; } - auto pointee_base = pointee; - while (pointee_base->opcode() == spv::Op::OpTypeArray) { - pointee_base = _.FindDef(pointee_base->GetOperandAs(1u)); - } - if (pointee_base->opcode() == spv::Op::OpTypePointer) { - if (pointee_base->GetOperandAs(1u) == - spv::StorageClass::PhysicalStorageBuffer) { - // check for AliasedPointer/RestrictPointer - bool foundAliased = - _.HasDecoration(inst->id(), spv::Decoration::AliasedPointer); - bool foundRestrict = - _.HasDecoration(inst->id(), spv::Decoration::RestrictPointer); - if (!foundAliased && !foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpVariable " << inst->id() - << ": expected AliasedPointer or RestrictPointer for " - << "PhysicalStorageBuffer pointer."; - } - if (foundAliased && foundRestrict) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpVariable " << inst->id() - << ": can't specify both AliasedPointer and " - << "RestrictPointer for PhysicalStorageBuffer pointer."; - } - } - } - // Vulkan specific validation rules for OpTypeRuntimeArray if (spvIsVulkanEnv(_.context()->target_env)) { // OpTypeRuntimeArray should only ever be in a container like OpTypeStruct, @@ -763,7 +769,12 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { // Cooperative matrix types can only be allocated in Function or Private if ((storage_class != spv::StorageClass::Function && storage_class != spv::StorageClass::Private) && - ContainsCooperativeMatrix(_, pointee)) { + pointee && + _.ContainsType(pointee->id(), [](const Instruction* type_inst) { + auto opcode = type_inst->opcode(); + return opcode == spv::Op::OpTypeCooperativeMatrixNV || + opcode == spv::Op::OpTypeCooperativeMatrixKHR; + })) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Cooperative matrix types (or types containing them) can only be " "allocated " @@ -771,6 +782,20 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { "parameters"; } + if ((storage_class != spv::StorageClass::Function && + storage_class != spv::StorageClass::Private) && + pointee && + _.ContainsType(pointee->id(), [](const Instruction* type_inst) { + auto opcode = type_inst->opcode(); + return opcode == spv::Op::OpTypeCooperativeVectorNV; + })) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Cooperative vector types (or types containing them) can only be " + "allocated " + << "in Function or Private storage classes or as function " + "parameters"; + } + if (_.HasCapability(spv::Capability::Shader)) { // Don't allow variables containing 16-bit elements without the appropriate // capabilities. @@ -779,7 +804,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { (!_.HasCapability(spv::Capability::Float16) && _.ContainsSizedIntOrFloatType(value_id, spv::Op::OpTypeFloat, 16))) { auto underlying_type = value_type; - while (underlying_type->opcode() == spv::Op::OpTypePointer) { + while (underlying_type && + underlying_type->opcode() == spv::Op::OpTypePointer) { storage_class = underlying_type->GetOperandAs(1u); underlying_type = _.FindDef(underlying_type->GetOperandAs(2u)); @@ -795,7 +821,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } break; case spv::StorageClass::Uniform: - if (!_.HasCapability( + if (underlying_type && + !_.HasCapability( spv::Capability::UniformAndStorageBuffer16BitAccess)) { if (underlying_type->opcode() == spv::Op::OpTypeArray || underlying_type->opcode() == spv::Op::OpTypeRuntimeArray) { @@ -843,7 +870,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { if (!_.HasCapability(spv::Capability::Int8) && _.ContainsSizedIntOrFloatType(value_id, spv::Op::OpTypeInt, 8)) { auto underlying_type = value_type; - while (underlying_type->opcode() == spv::Op::OpTypePointer) { + while (underlying_type && + underlying_type->opcode() == spv::Op::OpTypePointer) { storage_class = underlying_type->GetOperandAs(1u); underlying_type = _.FindDef(underlying_type->GetOperandAs(2u)); @@ -859,7 +887,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) { } break; case spv::StorageClass::Uniform: - if (!_.HasCapability( + if (underlying_type && + !_.HasCapability( spv::Capability::UniformAndStorageBuffer8BitAccess)) { if (underlying_type->opcode() == spv::Op::OpTypeArray || underlying_type->opcode() == spv::Op::OpTypeRuntimeArray) { @@ -924,21 +953,23 @@ spv_result_t ValidateLoad(ValidationState_t& _, const Instruction* inst) { } const auto pointer_type = _.FindDef(pointer->type_id()); - if (!pointer_type || pointer_type->opcode() != spv::Op::OpTypePointer) { + if (!pointer_type || + (pointer_type->opcode() != spv::Op::OpTypePointer && + pointer_type->opcode() != spv::Op::OpTypeUntypedPointerKHR)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpLoad type for pointer " << _.getIdName(pointer_id) << " is not a pointer type."; } - uint32_t pointee_data_type; - spv::StorageClass storage_class; - if (!_.GetPointerTypeInfo(pointer_type->id(), &pointee_data_type, - &storage_class) || - result_type->id() != pointee_data_type) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpLoad Result Type " << _.getIdName(inst->type_id()) - << " does not match Pointer " << _.getIdName(pointer->id()) - << "s type."; + if (pointer_type->opcode() == spv::Op::OpTypePointer) { + const auto pointee_type = + _.FindDef(pointer_type->GetOperandAs(2)); + if (!pointee_type || result_type->id() != pointee_type->id()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpLoad Result Type " << _.getIdName(inst->type_id()) + << " does not match Pointer " << _.getIdName(pointer->id()) + << "s type."; + } } if (!_.options()->before_hlsl_legalization && @@ -961,6 +992,8 @@ spv_result_t ValidateLoad(ValidationState_t& _, const Instruction* inst) { } } + _.RegisterQCOMImageProcessingTextureConsumer(pointer_id, inst, nullptr); + return SPV_SUCCESS; } @@ -979,17 +1012,23 @@ spv_result_t ValidateStore(ValidationState_t& _, const Instruction* inst) { << " is not a logical pointer."; } const auto pointer_type = _.FindDef(pointer->type_id()); - if (!pointer_type || pointer_type->opcode() != spv::Op::OpTypePointer) { + if (!pointer_type || + (pointer_type->opcode() != spv::Op::OpTypePointer && + pointer_type->opcode() != spv::Op::OpTypeUntypedPointerKHR)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpStore type for pointer " << _.getIdName(pointer_id) << " is not a pointer type."; } - const auto type_id = pointer_type->GetOperandAs(2); - const auto type = _.FindDef(type_id); - if (!type || spv::Op::OpTypeVoid == type->opcode()) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpStore Pointer " << _.getIdName(pointer_id) - << "s type is void."; + + Instruction* type = nullptr; + if (pointer_type->opcode() == spv::Op::OpTypePointer) { + const auto type_id = pointer_type->GetOperandAs(2); + type = _.FindDef(type_id); + if (!type || spv::Op::OpTypeVoid == type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpStore Pointer " << _.getIdName(pointer_id) + << "s type is void."; + } } // validate storage class @@ -1066,7 +1105,7 @@ spv_result_t ValidateStore(ValidationState_t& _, const Instruction* inst) { << "s type is void."; } - if (type->id() != object_type->id()) { + if (type && (type->id() != object_type->id())) { if (!_.options()->relax_struct_store || type->opcode() != spv::Op::OpTypeStruct || object_type->opcode() != spv::Op::OpTypeStruct) { @@ -1099,6 +1138,23 @@ spv_result_t ValidateStore(ValidationState_t& _, const Instruction* inst) { } } + if (spvIsVulkanEnv(_.context()->target_env) && + !_.options()->before_hlsl_legalization) { + const auto isForbiddenType = [](const Instruction* type_inst) { + auto opcode = type_inst->opcode(); + return opcode == spv::Op::OpTypeImage || + opcode == spv::Op::OpTypeSampler || + opcode == spv::Op::OpTypeSampledImage || + opcode == spv::Op::OpTypeAccelerationStructureKHR; + }; + if (_.ContainsType(object_type->id(), isForbiddenType)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(6924) + << "Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR objects"; + } + } + return SPV_SUCCESS; } @@ -1171,7 +1227,8 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { const auto target_pointer_type = _.FindDef(target->type_id()); if (!target_pointer_type || - target_pointer_type->opcode() != spv::Op::OpTypePointer) { + (target_pointer_type->opcode() != spv::Op::OpTypePointer && + target_pointer_type->opcode() != spv::Op::OpTypeUntypedPointerKHR)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Target operand " << _.getIdName(target_id) << " is not a pointer."; @@ -1179,35 +1236,52 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { const auto source_pointer_type = _.FindDef(source->type_id()); if (!source_pointer_type || - source_pointer_type->opcode() != spv::Op::OpTypePointer) { + (source_pointer_type->opcode() != spv::Op::OpTypePointer && + source_pointer_type->opcode() != spv::Op::OpTypeUntypedPointerKHR)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Source operand " << _.getIdName(source_id) << " is not a pointer."; } if (inst->opcode() == spv::Op::OpCopyMemory) { - const auto target_type = - _.FindDef(target_pointer_type->GetOperandAs(2)); - if (!target_type || target_type->opcode() == spv::Op::OpTypeVoid) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Target operand " << _.getIdName(target_id) - << " cannot be a void pointer."; + const bool target_typed = + target_pointer_type->opcode() == spv::Op::OpTypePointer; + const bool source_typed = + source_pointer_type->opcode() == spv::Op::OpTypePointer; + Instruction* target_type = nullptr; + Instruction* source_type = nullptr; + if (target_typed) { + target_type = _.FindDef(target_pointer_type->GetOperandAs(2)); + + if (!target_type || target_type->opcode() == spv::Op::OpTypeVoid) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Target operand " << _.getIdName(target_id) + << " cannot be a void pointer."; + } } - const auto source_type = - _.FindDef(source_pointer_type->GetOperandAs(2)); - if (!source_type || source_type->opcode() == spv::Op::OpTypeVoid) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Source operand " << _.getIdName(source_id) - << " cannot be a void pointer."; + if (source_typed) { + source_type = _.FindDef(source_pointer_type->GetOperandAs(2)); + if (!source_type || source_type->opcode() == spv::Op::OpTypeVoid) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Source operand " << _.getIdName(source_id) + << " cannot be a void pointer."; + } } - if (target_type->id() != source_type->id()) { + if (target_type && source_type && target_type->id() != source_type->id()) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Target " << _.getIdName(source_id) << "s type does not match Source " << _.getIdName(source_type->id()) << "s type."; } + + if (!target_type && !source_type) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "One of Source or Target must be a typed pointer"; + } + + if (auto error = CheckMemoryAccess(_, inst, 2)) return error; } else { const auto size_id = inst->GetOperandAs(2); const auto size = _.FindDef(size_id); @@ -1223,7 +1297,6 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { << "Size operand " << _.getIdName(size_id) << " must be a scalar integer type."; } - bool is_zero = true; switch (size->opcode()) { case spv::Op::OpConstantNull: @@ -1250,18 +1323,125 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { // Cannot infer any other opcodes. break; } + + if (_.HasCapability(spv::Capability::Shader)) { + bool is_int = false; + bool is_const = false; + uint32_t value = 0; + std::tie(is_int, is_const, value) = _.EvalInt32IfConst(size_id); + if (is_const) { + if (value % 4 != 0) { + const auto source_sc = + source_pointer_type->GetOperandAs(1); + const auto target_sc = + target_pointer_type->GetOperandAs(1); + const bool int8 = _.HasCapability(spv::Capability::Int8); + const bool ubo_int8 = _.HasCapability( + spv::Capability::UniformAndStorageBuffer8BitAccess); + const bool ssbo_int8 = + _.HasCapability(spv::Capability::StorageBuffer8BitAccess) || + ubo_int8; + const bool pc_int8 = + _.HasCapability(spv::Capability::StoragePushConstant8); + const bool wg_int8 = _.HasCapability( + spv::Capability::WorkgroupMemoryExplicitLayout8BitAccessKHR); + const bool int16 = _.HasCapability(spv::Capability::Int16) || int8; + const bool ubo_int16 = + _.HasCapability( + spv::Capability::UniformAndStorageBuffer16BitAccess) || + ubo_int8; + const bool ssbo_int16 = + _.HasCapability(spv::Capability::StorageBuffer16BitAccess) || + ubo_int16 || ssbo_int8; + const bool pc_int16 = + _.HasCapability(spv::Capability::StoragePushConstant16) || + pc_int8; + const bool io_int16 = + _.HasCapability(spv::Capability::StorageInputOutput16); + const bool wg_int16 = _.HasCapability( + spv::Capability::WorkgroupMemoryExplicitLayout16BitAccessKHR); + + bool source_int16_match = false; + bool target_int16_match = false; + bool source_int8_match = false; + bool target_int8_match = false; + switch (source_sc) { + case spv::StorageClass::StorageBuffer: + source_int16_match = ssbo_int16; + source_int8_match = ssbo_int8; + break; + case spv::StorageClass::Uniform: + source_int16_match = ubo_int16; + source_int8_match = ubo_int8; + break; + case spv::StorageClass::PushConstant: + source_int16_match = pc_int16; + source_int8_match = pc_int8; + break; + case spv::StorageClass::Input: + case spv::StorageClass::Output: + source_int16_match = io_int16; + break; + case spv::StorageClass::Workgroup: + source_int16_match = wg_int16; + source_int8_match = wg_int8; + break; + default: + break; + } + switch (target_sc) { + case spv::StorageClass::StorageBuffer: + target_int16_match = ssbo_int16; + target_int8_match = ssbo_int8; + break; + case spv::StorageClass::Uniform: + target_int16_match = ubo_int16; + target_int8_match = ubo_int8; + break; + case spv::StorageClass::PushConstant: + target_int16_match = pc_int16; + target_int8_match = pc_int8; + break; + // Input is read-only so it cannot be the target pointer. + case spv::StorageClass::Output: + target_int16_match = io_int16; + break; + case spv::StorageClass::Workgroup: + target_int16_match = wg_int16; + target_int8_match = wg_int8; + break; + default: + break; + } + if (!int8 && !int16 && !(source_int16_match && target_int16_match)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a multiple of 4"; + } + if (value % 2 != 0) { + if (!int8 && !(source_int8_match && target_int8_match)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a multiple of 2"; + } + } + } + } + } + + if (auto error = CheckMemoryAccess(_, inst, 3)) return error; } if (auto error = ValidateCopyMemoryMemoryAccess(_, inst)) return error; // Get past the pointers to avoid checking a pointer copy. - auto sub_type = _.FindDef(target_pointer_type->GetOperandAs(2)); - while (sub_type->opcode() == spv::Op::OpTypePointer) { - sub_type = _.FindDef(sub_type->GetOperandAs(2)); - } - if (_.HasCapability(spv::Capability::Shader) && - _.ContainsLimitedUseIntOrFloatType(sub_type->id())) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Cannot copy memory of objects containing 8- or 16-bit types"; + if (target_pointer_type->opcode() == spv::Op::OpTypePointer) { + auto sub_type = _.FindDef(target_pointer_type->GetOperandAs(2)); + while (sub_type->opcode() == spv::Op::OpTypePointer) { + sub_type = _.FindDef(sub_type->GetOperandAs(2)); + } + if (_.HasCapability(spv::Capability::Shader) && + _.ContainsLimitedUseIntOrFloatType(sub_type->id())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Cannot copy memory of objects containing 8- or 16-bit types"; + } } return SPV_SUCCESS; @@ -1272,27 +1452,50 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, std::string instr_name = "Op" + std::string(spvOpcodeString(static_cast(inst->opcode()))); - // The result type must be OpTypePointer. + const bool untyped_pointer = spvOpcodeGeneratesUntypedPointer(inst->opcode()); + + // The result type must be OpTypePointer for regular access chains and an + // OpTypeUntypedPointerKHR for untyped access chains. auto result_type = _.FindDef(inst->type_id()); - if (spv::Op::OpTypePointer != result_type->opcode()) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "The Result Type of " << instr_name << " " - << _.getIdName(inst->id()) << " must be OpTypePointer. Found Op" - << spvOpcodeString(static_cast(result_type->opcode())) - << "."; + if (untyped_pointer) { + if (!result_type || + spv::Op::OpTypeUntypedPointerKHR != result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Result Type of " << instr_name << " " + << _.getIdName(inst->id()) + << " must be OpTypeUntypedPointerKHR. Found Op" + << spvOpcodeString(static_cast(result_type->opcode())) + << "."; + } + } else { + if (!result_type || spv::Op::OpTypePointer != result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Result Type of " << instr_name << " " + << _.getIdName(inst->id()) << " must be OpTypePointer. Found Op" + << spvOpcodeString(static_cast(result_type->opcode())) + << "."; + } } - // Result type is a pointer. Find out what it's pointing to. - // This will be used to make sure the indexing results in the same type. - // OpTypePointer word 3 is the type being pointed to. - const auto result_type_pointee = _.FindDef(result_type->word(3)); + if (untyped_pointer) { + // Base type must be a non-pointer type. + const auto base_type = _.FindDef(inst->GetOperandAs(2)); + if (!base_type || !spvOpcodeGeneratesType(base_type->opcode()) || + base_type->opcode() == spv::Op::OpTypePointer || + base_type->opcode() == spv::Op::OpTypeUntypedPointerKHR) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Base type must be a non-pointer type"; + } + } // Base must be a pointer, pointing to the base of a composite object. - const auto base_index = 2; + const auto base_index = untyped_pointer ? 3 : 2; const auto base_id = inst->GetOperandAs(base_index); const auto base = _.FindDef(base_id); const auto base_type = _.FindDef(base->type_id()); - if (!base_type || spv::Op::OpTypePointer != base_type->opcode()) { + if (!base_type || !(spv::Op::OpTypePointer == base_type->opcode() || + (untyped_pointer && spv::Op::OpTypeUntypedPointerKHR == + base_type->opcode()))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "The Base " << _.getIdName(base_id) << " in " << instr_name << " instruction must be a pointer."; @@ -1310,14 +1513,18 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, } // The type pointed to by OpTypePointer (word 3) must be a composite type. - auto type_pointee = _.FindDef(base_type->word(3)); + auto type_pointee = untyped_pointer + ? _.FindDef(inst->GetOperandAs(2)) + : _.FindDef(base_type->word(3)); // Check Universal Limit (SPIR-V Spec. Section 2.17). // The number of indexes passed to OpAccessChain may not exceed 255 // The instruction includes 4 words + N words (for N indexes) size_t num_indexes = inst->words().size() - 4; if (inst->opcode() == spv::Op::OpPtrAccessChain || - inst->opcode() == spv::Op::OpInBoundsPtrAccessChain) { + inst->opcode() == spv::Op::OpInBoundsPtrAccessChain || + inst->opcode() == spv::Op::OpUntypedPtrAccessChainKHR || + inst->opcode() == spv::Op::OpUntypedInBoundsPtrAccessChainKHR) { // In pointer access chains, the element operand is required, but not // counted as an index. --num_indexes; @@ -1336,9 +1543,11 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, // instruction. The second index will apply similarly to that result, and so // on. Once any non-composite type is reached, there must be no remaining // (unused) indexes. - auto starting_index = 4; + auto starting_index = untyped_pointer ? 5 : 4; if (inst->opcode() == spv::Op::OpPtrAccessChain || - inst->opcode() == spv::Op::OpInBoundsPtrAccessChain) { + inst->opcode() == spv::Op::OpInBoundsPtrAccessChain || + inst->opcode() == spv::Op::OpUntypedPtrAccessChainKHR || + inst->opcode() == spv::Op::OpUntypedInBoundsPtrAccessChainKHR) { ++starting_index; } for (size_t i = starting_index; i < inst->words().size(); ++i) { @@ -1355,68 +1564,197 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, switch (type_pointee->opcode()) { case spv::Op::OpTypeMatrix: case spv::Op::OpTypeVector: + case spv::Op::OpTypeCooperativeVectorNV: case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: case spv::Op::OpTypeArray: - case spv::Op::OpTypeRuntimeArray: { + case spv::Op::OpTypeRuntimeArray: + case spv::Op::OpTypeNodePayloadArrayAMDX: { // In OpTypeMatrix, OpTypeVector, spv::Op::OpTypeCooperativeMatrixNV, - // OpTypeArray, and OpTypeRuntimeArray, word 2 is the Element Type. + // OpTypeCooperativeVectorNV, OpTypeArray, and OpTypeRuntimeArray, word + // 2 is the Element Type. type_pointee = _.FindDef(type_pointee->word(2)); break; } case spv::Op::OpTypeStruct: { // In case of structures, there is an additional constraint on the // index: the index must be an OpConstant. - if (spv::Op::OpConstant != cur_word_instr->opcode()) { - return _.diag(SPV_ERROR_INVALID_ID, cur_word_instr) - << "The passed to " << instr_name - << " to index into a " + int64_t cur_index; + if (!_.EvalConstantValInt64(cur_word, &cur_index)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The passed to " << instr_name << " to index " + << _.getIdName(cur_word) + << " into a " "structure must be an OpConstant."; } - // Get the index value from the OpConstant (word 3 of OpConstant). - // OpConstant could be a signed integer. But it's okay to treat it as - // unsigned because a negative constant int would never be seen as - // correct as a struct offset, since structs can't have more than 2 - // billion members. - const uint32_t cur_index = cur_word_instr->word(3); + // The index points to the struct member we want, therefore, the index // should be less than the number of struct members. - const uint32_t num_struct_members = - static_cast(type_pointee->words().size() - 2); - if (cur_index >= num_struct_members) { - return _.diag(SPV_ERROR_INVALID_ID, cur_word_instr) - << "Index is out of bounds: " << instr_name - << " can not find index " << cur_index - << " into the structure " + const int64_t num_struct_members = + static_cast(type_pointee->words().size() - 2); + if (cur_index >= num_struct_members || cur_index < 0) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Index " << _.getIdName(cur_word) + << " is out of bounds: " << instr_name << " cannot find index " + << cur_index << " into the structure " << _.getIdName(type_pointee->id()) << ". This structure has " << num_struct_members << " members. Largest valid index is " << num_struct_members - 1 << "."; } // Struct members IDs start at word 2 of OpTypeStruct. - auto structMemberId = type_pointee->word(cur_index + 2); + const size_t word_index = static_cast(cur_index) + 2; + auto structMemberId = type_pointee->word(word_index); type_pointee = _.FindDef(structMemberId); break; } default: { // Give an error. reached non-composite type while indexes still remain. - return _.diag(SPV_ERROR_INVALID_ID, cur_word_instr) + return _.diag(SPV_ERROR_INVALID_ID, inst) << instr_name << " reached non-composite type while indexes " "still remain to be traversed."; } } } - // At this point, we have fully walked down from the base using the indeces. - // The type being pointed to should be the same as the result type. - if (type_pointee->id() != result_type_pointee->id()) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << instr_name << " result type (Op" - << spvOpcodeString( - static_cast(result_type_pointee->opcode())) - << ") does not match the type that results from indexing into the " - "base " - " (Op" - << spvOpcodeString(static_cast(type_pointee->opcode())) - << ")."; + + if (!untyped_pointer) { + // Result type is a pointer. Find out what it's pointing to. + // This will be used to make sure the indexing results in the same type. + // OpTypePointer word 3 is the type being pointed to. + const auto result_type_pointee = _.FindDef(result_type->word(3)); + // At this point, we have fully walked down from the base using the indeces. + // The type being pointed to should be the same as the result type. + if (type_pointee->id() != result_type_pointee->id()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << instr_name << " result type (Op" + << spvOpcodeString( + static_cast(result_type_pointee->opcode())) + << ") does not match the type that results from indexing into the " + "base " + " (Op" + << spvOpcodeString(static_cast(type_pointee->opcode())) + << ")."; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateRawAccessChain(ValidationState_t& _, + const Instruction* inst) { + std::string instr_name = "Op" + std::string(spvOpcodeString(inst->opcode())); + + // The result type must be OpTypePointer. + const auto result_type = _.FindDef(inst->type_id()); + if (spv::Op::OpTypePointer != result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The Result Type of " << instr_name << " " + << _.getIdName(inst->id()) << " must be OpTypePointer. Found Op" + << spvOpcodeString(result_type->opcode()) << '.'; + } + + // The pointed storage class must be valid. + const auto storage_class = result_type->GetOperandAs(1); + if (storage_class != spv::StorageClass::StorageBuffer && + storage_class != spv::StorageClass::PhysicalStorageBuffer && + storage_class != spv::StorageClass::Uniform) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The Result Type of " << instr_name << " " + << _.getIdName(inst->id()) + << " must point to a storage class of " + "StorageBuffer, PhysicalStorageBuffer, or Uniform."; + } + + // The pointed type must not be one in the list below. + const auto result_type_pointee = + _.FindDef(result_type->GetOperandAs(2)); + if (result_type_pointee->opcode() == spv::Op::OpTypeArray || + result_type_pointee->opcode() == spv::Op::OpTypeMatrix || + result_type_pointee->opcode() == spv::Op::OpTypeStruct) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The Result Type of " << instr_name << " " + << _.getIdName(inst->id()) + << " must not point to " + "OpTypeArray, OpTypeMatrix, or OpTypeStruct."; + } + + // Validate Stride is a OpConstant. + const auto stride = _.FindDef(inst->GetOperandAs(3)); + if (stride->opcode() != spv::Op::OpConstant) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The Stride of " << instr_name << " " + << _.getIdName(inst->id()) << " must be OpConstant. Found Op" + << spvOpcodeString(stride->opcode()) << '.'; + } + // Stride type must be OpTypeInt + const auto stride_type = _.FindDef(stride->type_id()); + if (stride_type->opcode() != spv::Op::OpTypeInt) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The type of Stride of " << instr_name << " " + << _.getIdName(inst->id()) << " must be OpTypeInt. Found Op" + << spvOpcodeString(stride_type->opcode()) << '.'; + } + + // Index and Offset type must be OpTypeInt with a width of 32 + const auto ValidateType = [&](const char* name, + int operandIndex) -> spv_result_t { + const auto value = _.FindDef(inst->GetOperandAs(operandIndex)); + const auto value_type = _.FindDef(value->type_id()); + if (value_type->opcode() != spv::Op::OpTypeInt) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The type of " << name << " of " << instr_name << " " + << _.getIdName(inst->id()) << " must be OpTypeInt. Found Op" + << spvOpcodeString(value_type->opcode()) << '.'; + } + const auto width = value_type->GetOperandAs(1); + if (width != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The integer width of " << name << " of " << instr_name + << " " << _.getIdName(inst->id()) << " must be 32. Found " + << width << '.'; + } + return SPV_SUCCESS; + }; + spv_result_t result; + result = ValidateType("Index", 4); + if (result != SPV_SUCCESS) { + return result; + } + result = ValidateType("Offset", 5); + if (result != SPV_SUCCESS) { + return result; + } + + uint32_t access_operands = 0; + if (inst->operands().size() >= 7) { + access_operands = inst->GetOperandAs(6); + } + if (access_operands & + uint32_t(spv::RawAccessChainOperandsMask::RobustnessPerElementNV)) { + uint64_t stride_value = 0; + if (_.EvalConstantValUint64(stride->id(), &stride_value) && + stride_value == 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Stride must not be zero when per-element robustness is used."; + } + } + if (access_operands & + uint32_t(spv::RawAccessChainOperandsMask::RobustnessPerComponentNV) || + access_operands & + uint32_t(spv::RawAccessChainOperandsMask::RobustnessPerElementNV)) { + if (storage_class == spv::StorageClass::PhysicalStorageBuffer) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Storage class cannot be PhysicalStorageBuffer when " + "raw access chain robustness is used."; + } + } + if (access_operands & + uint32_t(spv::RawAccessChainOperandsMask::RobustnessPerComponentNV) && + access_operands & + uint32_t(spv::RawAccessChainOperandsMask::RobustnessPerElementNV)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Per-component robustness and per-element robustness are " + "mutually exclusive."; } return SPV_SUCCESS; @@ -1424,7 +1762,8 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, spv_result_t ValidatePtrAccessChain(ValidationState_t& _, const Instruction* inst) { - if (_.addressing_model() == spv::AddressingModel::Logical) { + if (_.addressing_model() == spv::AddressingModel::Logical && + inst->opcode() == spv::Op::OpPtrAccessChain) { if (!_.features().variable_pointers) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Generating variable pointers requires capability " @@ -1435,9 +1774,13 @@ spv_result_t ValidatePtrAccessChain(ValidationState_t& _, // Need to call first, will make sure Base is a valid ID if (auto error = ValidateAccessChain(_, inst)) return error; + const bool untyped_pointer = spvOpcodeGeneratesUntypedPointer(inst->opcode()); + const auto base_id = inst->GetOperandAs(2); const auto base = _.FindDef(base_id); - const auto base_type = _.FindDef(base->type_id()); + const auto base_type = untyped_pointer + ? _.FindDef(inst->GetOperandAs(2)) + : _.FindDef(base->type_id()); const auto base_type_storage_class = base_type->GetOperandAs(1); @@ -1455,15 +1798,17 @@ spv_result_t ValidatePtrAccessChain(ValidationState_t& _, } if (spvIsVulkanEnv(_.context()->target_env)) { + const auto untyped_cap = + untyped_pointer && _.HasCapability(spv::Capability::UntypedPointersKHR); if (base_type_storage_class == spv::StorageClass::Workgroup) { - if (!_.HasCapability(spv::Capability::VariablePointers)) { + if (!_.HasCapability(spv::Capability::VariablePointers) && !untyped_cap) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(7651) << "OpPtrAccessChain Base operand pointing to Workgroup " "storage class must use VariablePointers capability"; } } else if (base_type_storage_class == spv::StorageClass::StorageBuffer) { - if (!_.features().variable_pointers) { + if (!_.features().variable_pointers && !untyped_cap) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(7652) << "OpPtrAccessChain Base operand pointing to StorageBuffer " @@ -1471,7 +1816,8 @@ spv_result_t ValidatePtrAccessChain(ValidationState_t& _, "VariablePointersStorageBuffer capability"; } } else if (base_type_storage_class != - spv::StorageClass::PhysicalStorageBuffer) { + spv::StorageClass::PhysicalStorageBuffer && + !untyped_cap) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(7650) << "OpPtrAccessChain Base operand must point to Workgroup, " @@ -1498,18 +1844,28 @@ spv_result_t ValidateArrayLength(ValidationState_t& state, << " must be OpTypeInt with width 32 and signedness 0."; } - // The structure that is passed in must be an pointer to a structure, whose - // last element is a runtime array. - auto pointer = state.FindDef(inst->GetOperandAs(2)); - auto pointer_type = state.FindDef(pointer->type_id()); - if (pointer_type->opcode() != spv::Op::OpTypePointer) { + const bool untyped = inst->opcode() == spv::Op::OpUntypedArrayLengthKHR; + auto pointer_ty_id = state.GetOperandTypeId(inst, (untyped ? 3 : 2)); + auto pointer_ty = state.FindDef(pointer_ty_id); + if (untyped) { + if (pointer_ty->opcode() != spv::Op::OpTypeUntypedPointerKHR) { + return state.diag(SPV_ERROR_INVALID_ID, inst) + << "Pointer must be an untyped pointer"; + } + } else if (pointer_ty->opcode() != spv::Op::OpTypePointer) { return state.diag(SPV_ERROR_INVALID_ID, inst) << "The Structure's type in " << instr_name << " " << state.getIdName(inst->id()) << " must be a pointer to an OpTypeStruct."; } - auto structure_type = state.FindDef(pointer_type->GetOperandAs(2)); + Instruction* structure_type = nullptr; + if (untyped) { + structure_type = state.FindDef(inst->GetOperandAs(2)); + } else { + structure_type = state.FindDef(pointer_ty->GetOperandAs(2)); + } + if (structure_type->opcode() != spv::Op::OpTypeStruct) { return state.diag(SPV_ERROR_INVALID_ID, inst) << "The Structure's type in " << instr_name << " " @@ -1528,11 +1884,12 @@ spv_result_t ValidateArrayLength(ValidationState_t& state, // The array member must the index of the last element (the run time // array). - if (inst->GetOperandAs(3) != num_of_members - 1) { + const auto index = untyped ? 4 : 3; + if (inst->GetOperandAs(index) != num_of_members - 1) { return state.diag(SPV_ERROR_INVALID_ID, inst) << "The array member in " << instr_name << " " << state.getIdName(inst->id()) - << " must be an the last member of the struct."; + << " must be the last member of the struct."; } return SPV_SUCCESS; } @@ -1553,9 +1910,15 @@ spv_result_t ValidateCooperativeMatrixLengthNV(ValidationState_t& state, << " must be OpTypeInt with width 32 and signedness 0."; } + bool isKhr = inst->opcode() == spv::Op::OpCooperativeMatrixLengthKHR; auto type_id = inst->GetOperandAs(2); auto type = state.FindDef(type_id); - if (type->opcode() != spv::Op::OpTypeCooperativeMatrixNV) { + if (isKhr && type->opcode() != spv::Op::OpTypeCooperativeMatrixKHR) { + return state.diag(SPV_ERROR_INVALID_ID, inst) + << "The type in " << instr_name << " " + << state.getIdName(type_id) + << " must be OpTypeCooperativeMatrixKHR."; + } else if (!isKhr && type->opcode() != spv::Op::OpTypeCooperativeMatrixNV) { return state.diag(SPV_ERROR_INVALID_ID, inst) << "The type in " << instr_name << " " << state.getIdName(type_id) << " must be OpTypeCooperativeMatrixNV."; @@ -1667,6 +2030,733 @@ spv_result_t ValidateCooperativeMatrixLoadStoreNV(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateCooperativeMatrixLoadStoreKHR(ValidationState_t& _, + const Instruction* inst) { + uint32_t type_id; + const char* opname; + if (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) { + type_id = inst->type_id(); + opname = "spv::Op::OpCooperativeMatrixLoadKHR"; + } else { + // get Object operand's type + type_id = _.FindDef(inst->GetOperandAs(1))->type_id(); + opname = "spv::Op::OpCooperativeMatrixStoreKHR"; + } + + auto matrix_type = _.FindDef(type_id); + + if (matrix_type->opcode() != spv::Op::OpTypeCooperativeMatrixKHR) { + if (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeMatrixLoadKHR Result Type " + << _.getIdName(type_id) << " is not a cooperative matrix type."; + } else { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeMatrixStoreKHR Object type " + << _.getIdName(type_id) << " is not a cooperative matrix type."; + } + } + + const auto pointer_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) ? 2u : 0u; + const auto pointer_id = inst->GetOperandAs(pointer_index); + const auto pointer = _.FindDef(pointer_id); + if (!pointer || + ((_.addressing_model() == spv::AddressingModel::Logical) && + ((!_.features().variable_pointers && + !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || + (_.features().variable_pointers && + !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer_id) + << " is not a logical pointer."; + } + + const auto pointer_type_id = pointer->type_id(); + const auto pointer_type = _.FindDef(pointer_type_id); + if (!pointer_type || + !(pointer_type->opcode() == spv::Op::OpTypePointer || + pointer_type->opcode() == spv::Op::OpTypeUntypedPointerKHR)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " type for pointer " << _.getIdName(pointer_id) + << " is not a pointer type."; + } + + const bool untyped = + pointer_type->opcode() == spv::Op::OpTypeUntypedPointerKHR; + const auto storage_class_index = 1u; + const auto storage_class = + pointer_type->GetOperandAs(storage_class_index); + + if (spvIsVulkanEnv(_.context()->target_env)) { + if (storage_class != spv::StorageClass::Workgroup && + storage_class != spv::StorageClass::StorageBuffer && + storage_class != spv::StorageClass::PhysicalStorageBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(8973) << opname + << " storage class for pointer type " + << _.getIdName(pointer_type_id) + << " is not Workgroup, StorageBuffer, or PhysicalStorageBuffer."; + } + } + + if (!untyped) { + const auto pointee_id = pointer_type->GetOperandAs(2); + const auto pointee_type = _.FindDef(pointee_id); + if (!pointee_type || !(_.IsIntScalarOrVectorType(pointee_id) || + _.IsFloatScalarOrVectorType(pointee_id))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer->id()) + << "s Type must be a scalar or vector type."; + } + } + + const auto layout_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) ? 3u : 2u; + const auto layout_id = inst->GetOperandAs(layout_index); + const auto layout_inst = _.FindDef(layout_id); + if (!layout_inst || !_.IsIntScalarType(layout_inst->type_id()) || + !spvOpcodeIsConstant(layout_inst->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "MemoryLayout operand " << _.getIdName(layout_id) + << " must be a 32-bit integer constant instruction."; + } + + bool stride_required = false; + uint64_t layout; + if (_.EvalConstantValUint64(layout_id, &layout)) { + stride_required = + (layout == (uint64_t)spv::CooperativeMatrixLayout::RowMajorKHR) || + (layout == (uint64_t)spv::CooperativeMatrixLayout::ColumnMajorKHR); + } + + const auto stride_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) ? 4u : 3u; + if (inst->operands().size() > stride_index) { + const auto stride_id = inst->GetOperandAs(stride_index); + const auto stride = _.FindDef(stride_id); + if (!stride || !_.IsIntScalarType(stride->type_id())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Stride operand " << _.getIdName(stride_id) + << " must be a scalar integer type."; + } + } else if (stride_required) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "MemoryLayout " << layout << " requires a Stride."; + } + + const auto memory_access_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadKHR) ? 5u : 4u; + if (inst->operands().size() > memory_access_index) { + if (auto error = CheckMemoryAccess(_, inst, memory_access_index)) + return error; + } + + return SPV_SUCCESS; +} + +// Returns the number of instruction words taken up by a tensor addressing +// operands argument and its implied operands. +int TensorAddressingOperandsNumWords(spv::TensorAddressingOperandsMask mask) { + int result = 1; // Count the mask + if ((mask & spv::TensorAddressingOperandsMask::TensorView) != + spv::TensorAddressingOperandsMask::MaskNone) + ++result; + if ((mask & spv::TensorAddressingOperandsMask::DecodeFunc) != + spv::TensorAddressingOperandsMask::MaskNone) + ++result; + return result; +} + +spv_result_t ValidateCooperativeMatrixLoadStoreTensorNV( + ValidationState_t& _, const Instruction* inst) { + uint32_t type_id; + const char* opname; + if (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) { + type_id = inst->type_id(); + opname = "spv::Op::OpCooperativeMatrixLoadTensorNV"; + } else { + // get Object operand's type + type_id = _.FindDef(inst->GetOperandAs(1))->type_id(); + opname = "spv::Op::OpCooperativeMatrixStoreTensorNV"; + } + + auto matrix_type = _.FindDef(type_id); + + if (matrix_type->opcode() != spv::Op::OpTypeCooperativeMatrixKHR) { + if (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeMatrixLoadTensorNV Result Type " + << _.getIdName(type_id) << " is not a cooperative matrix type."; + } else { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeMatrixStoreTensorNV Object type " + << _.getIdName(type_id) << " is not a cooperative matrix type."; + } + } + + const auto pointer_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) ? 2u : 0u; + const auto pointer_id = inst->GetOperandAs(pointer_index); + const auto pointer = _.FindDef(pointer_id); + if (!pointer || + ((_.addressing_model() == spv::AddressingModel::Logical) && + ((!_.features().variable_pointers && + !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || + (_.features().variable_pointers && + !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer_id) + << " is not a logical pointer."; + } + + const auto pointer_type_id = pointer->type_id(); + const auto pointer_type = _.FindDef(pointer_type_id); + if (!pointer_type || pointer_type->opcode() != spv::Op::OpTypePointer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " type for pointer " << _.getIdName(pointer_id) + << " is not a pointer type."; + } + + const auto storage_class_index = 1u; + const auto storage_class = + pointer_type->GetOperandAs(storage_class_index); + + if (storage_class != spv::StorageClass::Workgroup && + storage_class != spv::StorageClass::StorageBuffer && + storage_class != spv::StorageClass::PhysicalStorageBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(8973) << opname + << " storage class for pointer type " + << _.getIdName(pointer_type_id) + << " is not Workgroup, StorageBuffer, or PhysicalStorageBuffer."; + } + + if (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) { + const auto object_index = 3; + const auto object_id = inst->GetOperandAs(object_index); + const auto object = _.FindDef(object_id); + if (!object || object->type_id() != type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Object " << _.getIdName(object_id) + << " type does not match Result Type."; + } + } + + const auto tensor_layout_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) ? 4u : 2u; + const auto tensor_layout_id = + inst->GetOperandAs(tensor_layout_index); + const auto tensor_layout = _.FindDef(tensor_layout_id); + if (!tensor_layout || _.FindDef(tensor_layout->type_id())->opcode() != + spv::Op::OpTypeTensorLayoutNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " TensorLayout " << _.getIdName(tensor_layout_id) + << " does not have a tensor layout type."; + } + + const auto memory_access_index = + (inst->opcode() == spv::Op::OpCooperativeMatrixLoadTensorNV) ? 5u : 3u; + if (inst->operands().size() > memory_access_index) { + if (auto error = CheckMemoryAccess(_, inst, memory_access_index)) + return error; + } + + const auto memory_access_mask = + inst->GetOperandAs(memory_access_index); + const auto tensor_operands_index = + memory_access_index + MemoryAccessNumWords(memory_access_mask); + const auto tensor_operands = + inst->GetOperandAs( + tensor_operands_index); + + if (inst->operands().size() < + tensor_operands_index + + TensorAddressingOperandsNumWords(tensor_operands)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " not enough tensor addressing operands."; + } + + uint32_t tensor_operand_index = tensor_operands_index + 1; + if ((tensor_operands & spv::TensorAddressingOperandsMask::TensorView) != + spv::TensorAddressingOperandsMask::MaskNone) { + const auto tensor_view_id = + inst->GetOperandAs(tensor_operand_index); + const auto tensor_view = _.FindDef(tensor_view_id); + if (!tensor_view || _.FindDef(tensor_view->type_id())->opcode() != + spv::Op::OpTypeTensorViewNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " TensorView " << _.getIdName(tensor_view_id) + << " does not have a tensor view type."; + } + + tensor_operand_index++; + } + + if ((tensor_operands & spv::TensorAddressingOperandsMask::DecodeFunc) != + spv::TensorAddressingOperandsMask::MaskNone) { + if (inst->opcode() == spv::Op::OpCooperativeMatrixStoreTensorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpCooperativeMatrixStoreTensorNV does not support DecodeFunc."; + } + const auto decode_func_id = + inst->GetOperandAs(tensor_operand_index); + const auto decode_func = _.FindDef(decode_func_id); + + if (!decode_func || decode_func->opcode() != spv::Op::OpFunction) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " DecodeFunc " << _.getIdName(decode_func_id) + << " is not a function."; + } + + const auto component_type_index = 1; + const auto component_type_id = + matrix_type->GetOperandAs(component_type_index); + + const auto function_type = + _.FindDef(decode_func->GetOperandAs(3)); + if (function_type->GetOperandAs(1) != component_type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " DecodeFunc " << _.getIdName(decode_func_id) + << " return type must match matrix component type."; + } + + const auto decode_ptr_type_id = function_type->GetOperandAs(2); + const auto decode_ptr_type = _.FindDef(decode_ptr_type_id); + auto decode_storage_class = + decode_ptr_type->GetOperandAs(storage_class_index); + + if (decode_storage_class != spv::StorageClass::PhysicalStorageBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " DecodeFunc " << _.getIdName(decode_func_id) + << " first parameter must be pointer to PhysicalStorageBuffer."; + } + + const auto tensor_layout_type = _.FindDef(tensor_layout->type_id()); + + for (uint32_t param = 3; param < 5; ++param) { + const auto param_type_id = function_type->GetOperandAs(param); + const auto param_type = _.FindDef(param_type_id); + if (param_type->opcode() != spv::Op::OpTypeArray) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " DecodeFunc " << _.getIdName(decode_func_id) + << " second/third parameter must be array of 32-bit integer " + "with " + << " dimension equal to the tensor dimension."; + } + const auto length_index = 2u; + uint64_t array_length; + if (_.EvalConstantValUint64( + param_type->GetOperandAs(length_index), + &array_length)) { + const auto tensor_layout_dim_id = + tensor_layout_type->GetOperandAs(1); + uint64_t dim_value; + if (_.EvalConstantValUint64(tensor_layout_dim_id, &dim_value)) { + if (array_length != dim_value) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " DecodeFunc " + << _.getIdName(decode_func_id) + << " second/third parameter must be array of 32-bit integer " + "with " + << " dimension equal to the tensor dimension."; + } + } + } + } + + tensor_operand_index++; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateInt32Operand(ValidationState_t& _, const Instruction* inst, + uint32_t operand_index, + const char* opcode_name, + const char* operand_name) { + const auto type_id = + _.FindDef(inst->GetOperandAs(operand_index))->type_id(); + if (!_.IsIntScalarType(type_id) || _.GetBitWidth(type_id) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " " << operand_name << " type " + << _.getIdName(type_id) << " is not a 32 bit integer."; + } + return SPV_SUCCESS; +} + +spv_result_t ValidateCooperativeVectorPointer(ValidationState_t& _, + const Instruction* inst, + const char* opname, + uint32_t pointer_index) { + const auto pointer_id = inst->GetOperandAs(pointer_index); + const auto pointer = _.FindDef(pointer_id); + if (!pointer || + ((_.addressing_model() == spv::AddressingModel::Logical) && + ((!_.features().variable_pointers && + !spvOpcodeReturnsLogicalPointer(pointer->opcode())) || + (_.features().variable_pointers && + !spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer_id) + << " is not a logical pointer."; + } + + const auto pointer_type_id = pointer->type_id(); + const auto pointer_type = _.FindDef(pointer_type_id); + if (!pointer_type || pointer_type->opcode() != spv::Op::OpTypePointer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " type for pointer " << _.getIdName(pointer_id) + << " is not a pointer type."; + } + + const auto storage_class_index = 1u; + const auto storage_class = + pointer_type->GetOperandAs(storage_class_index); + + if (storage_class != spv::StorageClass::Workgroup && + storage_class != spv::StorageClass::StorageBuffer && + storage_class != spv::StorageClass::PhysicalStorageBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " storage class for pointer type " + << _.getIdName(pointer_type_id) + << " is not Workgroup or StorageBuffer."; + } + + const auto pointee_id = pointer_type->GetOperandAs(2); + const auto pointee_type = _.FindDef(pointee_id); + if (!pointee_type || + (pointee_type->opcode() != spv::Op::OpTypeArray && + pointee_type->opcode() != spv::Op::OpTypeRuntimeArray)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer->id()) + << "s Type must be an array type."; + } + + const auto array_elem_type_id = pointee_type->GetOperandAs(1); + auto array_elem_type = _.FindDef(array_elem_type_id); + if (!array_elem_type || !(_.IsIntScalarOrVectorType(array_elem_type_id) || + _.IsFloatScalarOrVectorType(array_elem_type_id))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opname << " Pointer " << _.getIdName(pointer->id()) + << "s Type must be an array of scalar or vector type."; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateCooperativeVectorLoadStoreNV(ValidationState_t& _, + const Instruction* inst) { + uint32_t type_id; + const char* opname; + if (inst->opcode() == spv::Op::OpCooperativeVectorLoadNV) { + type_id = inst->type_id(); + opname = "spv::Op::OpCooperativeVectorLoadNV"; + } else { + // get Object operand's type + type_id = _.FindDef(inst->GetOperandAs(2))->type_id(); + opname = "spv::Op::OpCooperativeVectorStoreNV"; + } + + auto vector_type = _.FindDef(type_id); + + if (vector_type->opcode() != spv::Op::OpTypeCooperativeVectorNV) { + if (inst->opcode() == spv::Op::OpCooperativeVectorLoadNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeVectorLoadNV Result Type " + << _.getIdName(type_id) << " is not a cooperative vector type."; + } else { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "spv::Op::OpCooperativeVectorStoreNV Object type " + << _.getIdName(type_id) << " is not a cooperative vector type."; + } + } + + const auto pointer_index = + (inst->opcode() == spv::Op::OpCooperativeVectorLoadNV) ? 2u : 0u; + + if (auto error = + ValidateCooperativeVectorPointer(_, inst, opname, pointer_index)) { + return error; + } + + const auto memory_access_index = + (inst->opcode() == spv::Op::OpCooperativeVectorLoadNV) ? 4u : 3u; + if (inst->operands().size() > memory_access_index) { + if (auto error = CheckMemoryAccess(_, inst, memory_access_index)) + return error; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateCooperativeVectorOuterProductNV(ValidationState_t& _, + const Instruction* inst) { + const auto pointer_index = 0u; + const auto opcode_name = + "spv::Op::OpCooperativeVectorOuterProductAccumulateNV"; + + if (auto error = ValidateCooperativeVectorPointer(_, inst, opcode_name, + pointer_index)) { + return error; + } + + auto type_id = _.FindDef(inst->GetOperandAs(2))->type_id(); + auto a_type = _.FindDef(type_id); + + if (a_type->opcode() != spv::Op::OpTypeCooperativeVectorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " A type " << _.getIdName(type_id) + << " is not a cooperative vector type."; + } + + type_id = _.FindDef(inst->GetOperandAs(3))->type_id(); + auto b_type = _.FindDef(type_id); + + if (b_type->opcode() != spv::Op::OpTypeCooperativeVectorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " B type " << _.getIdName(type_id) + << " is not a cooperative vector type."; + } + + const auto a_component_type_id = a_type->GetOperandAs(1); + const auto b_component_type_id = b_type->GetOperandAs(1); + + if (a_component_type_id != b_component_type_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " A and B component types " + << _.getIdName(a_component_type_id) << " and " + << _.getIdName(b_component_type_id) << " do not match."; + } + + if (auto error = ValidateInt32Operand(_, inst, 1, opcode_name, "Offset")) { + return error; + } + + if (auto error = + ValidateInt32Operand(_, inst, 4, opcode_name, "MemoryLayout")) { + return error; + } + + if (auto error = ValidateInt32Operand(_, inst, 5, opcode_name, + "MatrixInterpretation")) { + return error; + } + + if (inst->operands().size() > 6) { + if (auto error = + ValidateInt32Operand(_, inst, 6, opcode_name, "MatrixStride")) { + return error; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateCooperativeVectorReduceSumNV(ValidationState_t& _, + const Instruction* inst) { + const auto opcode_name = "spv::Op::OpCooperativeVectorReduceSumAccumulateNV"; + const auto pointer_index = 0u; + + if (auto error = ValidateCooperativeVectorPointer(_, inst, opcode_name, + pointer_index)) { + return error; + } + + auto type_id = _.FindDef(inst->GetOperandAs(2))->type_id(); + auto v_type = _.FindDef(type_id); + + if (v_type->opcode() != spv::Op::OpTypeCooperativeVectorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " V type " << _.getIdName(type_id) + << " is not a cooperative vector type."; + } + + if (auto error = ValidateInt32Operand(_, inst, 1, opcode_name, "Offset")) { + return error; + } + + return SPV_SUCCESS; +} + +bool InterpretationIsPacked(spv::ComponentType interp) { + switch (interp) { + case spv::ComponentType::SignedInt8PackedNV: + case spv::ComponentType::UnsignedInt8PackedNV: + return true; + default: + return false; + } +} + +using std::get; + +spv_result_t ValidateCooperativeVectorMatrixMulNV(ValidationState_t& _, + const Instruction* inst) { + const bool has_bias = + inst->opcode() == spv::Op::OpCooperativeVectorMatrixMulAddNV; + const auto opcode_name = has_bias + ? "spv::Op::OpCooperativeVectorMatrixMulAddNV" + : "spv::Op::OpCooperativeVectorMatrixMulNV"; + + const auto bias_offset = has_bias ? 3 : 0; + + const auto result_type_index = 0u; + const auto input_index = 2u; + const auto input_interpretation_index = 3u; + const auto matrix_index = 4u; + const auto matrix_interpretation_index = 6u; + const auto bias_index = 7u; + const auto bias_interpretation_index = 9u; + const auto m_index = 7u + bias_offset; + const auto k_index = 8u + bias_offset; + const auto memory_layout_index = 9u + bias_offset; + const auto transpose_index = 10u + bias_offset; + + const auto result_type_id = inst->GetOperandAs(result_type_index); + const auto input_id = inst->GetOperandAs(input_index); + const auto input_interpretation_id = + inst->GetOperandAs(input_interpretation_index); + const auto matrix_interpretation_id = + inst->GetOperandAs(matrix_interpretation_index); + const auto bias_interpretation_id = + inst->GetOperandAs(bias_interpretation_index); + const auto m_id = inst->GetOperandAs(m_index); + const auto k_id = inst->GetOperandAs(k_index); + const auto memory_layout_id = + inst->GetOperandAs(memory_layout_index); + const auto transpose_id = inst->GetOperandAs(transpose_index); + + if (auto error = ValidateCooperativeVectorPointer(_, inst, opcode_name, + matrix_index)) { + return error; + } + + if (inst->opcode() == spv::Op::OpCooperativeVectorMatrixMulAddNV) { + if (auto error = ValidateCooperativeVectorPointer(_, inst, opcode_name, + bias_index)) { + return error; + } + } + + const auto result_type = _.FindDef(result_type_id); + + if (result_type->opcode() != spv::Op::OpTypeCooperativeVectorNV) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " result type " << _.getIdName(result_type_id) + << " is not a cooperative vector type."; + } + + const auto result_component_type_id = result_type->GetOperandAs(1u); + if (!(_.IsIntScalarType(result_component_type_id) && + _.GetBitWidth(result_component_type_id) == 32) && + !(_.IsFloatScalarType(result_component_type_id) && + (_.GetBitWidth(result_component_type_id) == 32 || + _.GetBitWidth(result_component_type_id) == 16))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " result component type " + << _.getIdName(result_component_type_id) + << " is not a 32 bit int or 16/32 bit float."; + } + + const auto m_eval = _.EvalInt32IfConst(m_id); + const auto rc_eval = + _.EvalInt32IfConst(result_type->GetOperandAs(2u)); + if (get<1>(m_eval) && get<1>(rc_eval) && get<2>(m_eval) != get<2>(rc_eval)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " result type number of components " + << get<2>(rc_eval) << " does not match M " << get<2>(m_eval); + } + + const auto k_eval = _.EvalInt32IfConst(k_id); + + const auto input = _.FindDef(input_id); + const auto input_type = _.FindDef(input->type_id()); + const auto input_num_components_id = input_type->GetOperandAs(2u); + + auto input_interp_eval = _.EvalInt32IfConst(input_interpretation_id); + if (get<1>(input_interp_eval) && + !InterpretationIsPacked(spv::ComponentType{get<2>(input_interp_eval)})) { + const auto inc_eval = _.EvalInt32IfConst(input_num_components_id); + if (get<1>(inc_eval) && get<1>(k_eval) && + get<2>(inc_eval) != get<2>(k_eval)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " input number of components " + << get<2>(inc_eval) << " does not match K " << get<2>(k_eval); + } + } + + if (!_.IsBoolScalarType(_.FindDef(transpose_id)->type_id())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " Transpose " << _.getIdName(transpose_id) + << " is not a scalar boolean."; + } + + const auto check_constant = [&](uint32_t id, + const char* operand_name) -> spv_result_t { + if (!spvOpcodeIsConstant(_.GetIdOpcode(id))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << opcode_name << " " << operand_name << " " + << _.getIdName(id) << " is not a constant instruction."; + } + return SPV_SUCCESS; + }; + + if (auto error = + check_constant(input_interpretation_id, "InputInterpretation")) { + return error; + } + if (auto error = + check_constant(matrix_interpretation_id, "MatrixInterpretation")) { + return error; + } + if (has_bias) { + if (auto error = + check_constant(bias_interpretation_id, "BiasInterpretation")) { + return error; + } + } + if (auto error = check_constant(m_id, "M")) { + return error; + } + if (auto error = check_constant(k_id, "K")) { + return error; + } + if (auto error = check_constant(memory_layout_id, "MemoryLayout")) { + return error; + } + if (auto error = check_constant(transpose_id, "Transpose")) { + return error; + } + + if (auto error = ValidateInt32Operand(_, inst, input_interpretation_index, + opcode_name, "InputInterpretation")) { + return error; + } + if (auto error = ValidateInt32Operand(_, inst, matrix_interpretation_index, + opcode_name, "MatrixInterpretation")) { + return error; + } + if (has_bias) { + if (auto error = ValidateInt32Operand(_, inst, bias_interpretation_index, + opcode_name, "BiasInterpretation")) { + return error; + } + } + if (auto error = ValidateInt32Operand(_, inst, m_index, opcode_name, "M")) { + return error; + } + if (auto error = ValidateInt32Operand(_, inst, k_index, opcode_name, "K")) { + return error; + } + if (auto error = ValidateInt32Operand(_, inst, memory_layout_index, + opcode_name, "MemoryLayout")) { + return error; + } + + return SPV_SUCCESS; +} + spv_result_t ValidatePtrComparison(ValidationState_t& _, const Instruction* inst) { if (_.addressing_model() == spv::AddressingModel::Logical && @@ -1696,7 +2786,8 @@ spv_result_t ValidatePtrComparison(ValidationState_t& _, << "The types of Operand 1 and Operand 2 must match"; } const auto op1_type = _.FindDef(op1->type_id()); - if (!op1_type || op1_type->opcode() != spv::Op::OpTypePointer) { + if (!op1_type || (op1_type->opcode() != spv::Op::OpTypePointer && + op1_type->opcode() != spv::Op::OpTypeUntypedPointerKHR)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Operand type must be a pointer"; } @@ -1728,6 +2819,7 @@ spv_result_t ValidatePtrComparison(ValidationState_t& _, spv_result_t MemoryPass(ValidationState_t& _, const Instruction* inst) { switch (inst->opcode()) { case spv::Op::OpVariable: + case spv::Op::OpUntypedVariableKHR: if (auto error = ValidateVariable(_, inst)) return error; break; case spv::Op::OpLoad: @@ -1741,14 +2833,22 @@ spv_result_t MemoryPass(ValidationState_t& _, const Instruction* inst) { if (auto error = ValidateCopyMemory(_, inst)) return error; break; case spv::Op::OpPtrAccessChain: + case spv::Op::OpUntypedPtrAccessChainKHR: + case spv::Op::OpUntypedInBoundsPtrAccessChainKHR: if (auto error = ValidatePtrAccessChain(_, inst)) return error; break; case spv::Op::OpAccessChain: case spv::Op::OpInBoundsAccessChain: case spv::Op::OpInBoundsPtrAccessChain: + case spv::Op::OpUntypedAccessChainKHR: + case spv::Op::OpUntypedInBoundsAccessChainKHR: if (auto error = ValidateAccessChain(_, inst)) return error; break; + case spv::Op::OpRawAccessChainNV: + if (auto error = ValidateRawAccessChain(_, inst)) return error; + break; case spv::Op::OpArrayLength: + case spv::Op::OpUntypedArrayLengthKHR: if (auto error = ValidateArrayLength(_, inst)) return error; break; case spv::Op::OpCooperativeMatrixLoadNV: @@ -1756,9 +2856,38 @@ spv_result_t MemoryPass(ValidationState_t& _, const Instruction* inst) { if (auto error = ValidateCooperativeMatrixLoadStoreNV(_, inst)) return error; break; + case spv::Op::OpCooperativeMatrixLengthKHR: case spv::Op::OpCooperativeMatrixLengthNV: if (auto error = ValidateCooperativeMatrixLengthNV(_, inst)) return error; break; + case spv::Op::OpCooperativeMatrixLoadKHR: + case spv::Op::OpCooperativeMatrixStoreKHR: + if (auto error = ValidateCooperativeMatrixLoadStoreKHR(_, inst)) + return error; + break; + case spv::Op::OpCooperativeMatrixLoadTensorNV: + case spv::Op::OpCooperativeMatrixStoreTensorNV: + if (auto error = ValidateCooperativeMatrixLoadStoreTensorNV(_, inst)) + return error; + break; + case spv::Op::OpCooperativeVectorLoadNV: + case spv::Op::OpCooperativeVectorStoreNV: + if (auto error = ValidateCooperativeVectorLoadStoreNV(_, inst)) + return error; + break; + case spv::Op::OpCooperativeVectorOuterProductAccumulateNV: + if (auto error = ValidateCooperativeVectorOuterProductNV(_, inst)) + return error; + break; + case spv::Op::OpCooperativeVectorReduceSumAccumulateNV: + if (auto error = ValidateCooperativeVectorReduceSumNV(_, inst)) + return error; + break; + case spv::Op::OpCooperativeVectorMatrixMulNV: + case spv::Op::OpCooperativeVectorMatrixMulAddNV: + if (auto error = ValidateCooperativeVectorMatrixMulNV(_, inst)) + return error; + break; case spv::Op::OpPtrEqual: case spv::Op::OpPtrNotEqual: case spv::Op::OpPtrDiff: diff --git a/third_party/spirv-tools/source/val/validate_memory_semantics.cpp b/third_party/spirv-tools/source/val/validate_memory_semantics.cpp index 748b238618..dab7b5a194 100644 --- a/third_party/spirv-tools/source/val/validate_memory_semantics.cpp +++ b/third_party/spirv-tools/source/val/validate_memory_semantics.cpp @@ -14,7 +14,6 @@ #include "source/val/validate_memory_semantics.h" -#include "source/diagnostic.h" #include "source/spirv_target_env.h" #include "source/util/bitutils.h" #include "source/val/instruction.h" @@ -204,15 +203,12 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _, "storage class"; } -#if 0 - // TODO(atgoo@github.com): this check fails Vulkan CTS, reenable once fixed. if (opcode == spv::Op::OpControlBarrier && value && !includes_storage_class) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << spvOpcodeString(opcode) + << _.VkErrorID(4650) << spvOpcodeString(opcode) << ": expected Memory Semantics to include a Vulkan-supported " "storage class if Memory Semantics is not None"; } -#endif } if (opcode == spv::Op::OpAtomicFlagClear && diff --git a/third_party/spirv-tools/source/val/validate_mesh_shading.cpp b/third_party/spirv-tools/source/val/validate_mesh_shading.cpp index e569e251c0..3bd1dbd38d 100644 --- a/third_party/spirv-tools/source/val/validate_mesh_shading.cpp +++ b/third_party/spirv-tools/source/val/validate_mesh_shading.cpp @@ -15,6 +15,7 @@ // Validates ray query instructions from SPV_KHR_ray_query #include "source/opcode.h" +#include "source/spirv_target_env.h" #include "source/val/instruction.h" #include "source/val/validate.h" #include "source/val/validation_state.h" @@ -22,6 +23,24 @@ namespace spvtools { namespace val { +bool IsInterfaceVariable(ValidationState_t& _, const Instruction* inst, + spv::ExecutionModel model) { + bool foundInterface = false; + for (auto entry_point : _.entry_points()) { + const auto* models = _.GetExecutionModels(entry_point); + if (models->find(model) == models->end()) return false; + for (const auto& desc : _.entry_point_descriptions(entry_point)) { + for (auto interface : desc.interfaces) { + if (inst->id() == interface) { + foundInterface = true; + break; + } + } + } + } + return foundInterface; +} + spv_result_t MeshShadingPass(ValidationState_t& _, const Instruction* inst) { const spv::Op opcode = inst->opcode(); switch (opcode) { @@ -111,7 +130,37 @@ spv_result_t MeshShadingPass(ValidationState_t& _, const Instruction* inst) { // No validation rules (for the moment). break; } + case spv::Op::OpVariable: { + if (_.HasCapability(spv::Capability::MeshShadingEXT)) { + bool meshInterfaceVar = + IsInterfaceVariable(_, inst, spv::ExecutionModel::MeshEXT); + bool fragInterfaceVar = + IsInterfaceVariable(_, inst, spv::ExecutionModel::Fragment); + const spv::StorageClass storage_class = + inst->GetOperandAs(2); + bool storage_output = (storage_class == spv::StorageClass::Output); + bool storage_input = (storage_class == spv::StorageClass::Input); + + if (_.HasDecoration(inst->id(), spv::Decoration::PerPrimitiveEXT)) { + if (fragInterfaceVar && !storage_input) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "PerPrimitiveEXT decoration must be applied only to " + "variables in the Input Storage Class in the Fragment " + "Execution Model."; + } + + if (meshInterfaceVar && !storage_output) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(4336) + << "PerPrimitiveEXT decoration must be applied only to " + "variables in the Output Storage Class in the " + "Storage Class in the MeshEXT Execution Model."; + } + } + } + break; + } default: break; } diff --git a/third_party/spirv-tools/source/val/validate_misc.cpp b/third_party/spirv-tools/source/val/validate_misc.cpp index d71fd2d261..a404134b6e 100644 --- a/third_party/spirv-tools/source/val/validate_misc.cpp +++ b/third_party/spirv-tools/source/val/validate_misc.cpp @@ -50,10 +50,22 @@ spv_result_t ValidateShaderClock(ValidationState_t& _, bool is_int32 = false, is_const_int32 = false; uint32_t value = 0; std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(scope); - if (is_const_int32 && spv::Scope(value) != spv::Scope::Subgroup && - spv::Scope(value) != spv::Scope::Device) { - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << _.VkErrorID(4652) << "Scope must be Subgroup or Device"; + if (is_const_int32) { + spv::Scope scope_val{value}; + if (spvIsVulkanEnv(_.context()->target_env)) { + if (scope_val != spv::Scope::Subgroup && + scope_val != spv::Scope::Device) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(4652) << "Scope must be Subgroup or Device"; + } + } else if (spvIsOpenCLEnv(_.context()->target_env)) { + if (scope_val != spv::Scope::Workgroup && + scope_val != spv::Scope::Subgroup && + scope_val != spv::Scope::Device) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Scope must be Subgroup, Workgroup, or Device"; + } + } } // Result Type must be a 64 - bit unsigned integer type or diff --git a/third_party/spirv-tools/source/val/validate_mode_setting.cpp b/third_party/spirv-tools/source/val/validate_mode_setting.cpp index dfa46466ff..b37b89804b 100644 --- a/third_party/spirv-tools/source/val/validate_mode_setting.cpp +++ b/third_party/spirv-tools/source/val/validate_mode_setting.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2018 Google LLC. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -323,6 +325,42 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) { } } + if (_.EntryPointHasLocalSizeOrId(entry_point_id)) { + const Instruction* local_size_inst = + _.EntryPointLocalSizeOrId(entry_point_id); + if (local_size_inst) { + const auto mode = local_size_inst->GetOperandAs(1); + const uint32_t operand_x = local_size_inst->GetOperandAs(2); + const uint32_t operand_y = local_size_inst->GetOperandAs(3); + const uint32_t operand_z = local_size_inst->GetOperandAs(4); + if (mode == spv::ExecutionMode::LocalSize) { + if ((operand_x * operand_y * operand_z) == 0) { + return _.diag(SPV_ERROR_INVALID_DATA, local_size_inst) + << "Local Size execution mode must not have a product of zero " + "(X " + "= " + << operand_x << ", Y = " << operand_y << ", Z = " << operand_z + << ")."; + } + } else if (mode == spv::ExecutionMode::LocalSizeId) { + // can only validate product if static and not spec constant + // (This is done for us in EvalConstantValUint64) + uint64_t x_size, y_size, z_size; + bool static_x = _.EvalConstantValUint64(operand_x, &x_size); + bool static_y = _.EvalConstantValUint64(operand_y, &y_size); + bool static_z = _.EvalConstantValUint64(operand_z, &z_size); + if (static_x && static_y && static_z && + ((x_size * y_size * z_size) == 0)) { + return _.diag(SPV_ERROR_INVALID_DATA, local_size_inst) + << "Local Size Id execution mode must not have a product of " + "zero " + "(X = " + << x_size << ", Y = " << y_size << ", Z = " << z_size << ")."; + } + } + } + } + return SPV_SUCCESS; } @@ -340,29 +378,111 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, const auto mode = inst->GetOperandAs(1); if (inst->opcode() == spv::Op::OpExecutionModeId) { + bool valid_mode = false; + switch (mode) { + case spv::ExecutionMode::SubgroupsPerWorkgroupId: + case spv::ExecutionMode::LocalSizeHintId: + case spv::ExecutionMode::LocalSizeId: + case spv::ExecutionMode::FPFastMathDefault: + case spv::ExecutionMode::MaximumRegistersIdINTEL: + case spv::ExecutionMode::IsApiEntryAMDX: + case spv::ExecutionMode::MaxNodeRecursionAMDX: + case spv::ExecutionMode::MaxNumWorkgroupsAMDX: + case spv::ExecutionMode::ShaderIndexAMDX: + case spv::ExecutionMode::SharesInputWithAMDX: + case spv::ExecutionMode::StaticNumWorkgroupsAMDX: + valid_mode = true; + break; + default: + valid_mode = false; + break; + } + if (!valid_mode) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpExecutionModeId is only valid when the Mode operand is an " + "execution mode that takes Extra Operands that are id " + "operands."; + } + size_t operand_count = inst->operands().size(); for (size_t i = 2; i < operand_count; ++i) { - const auto operand_id = inst->GetOperandAs(2); + const auto operand_id = inst->GetOperandAs(i); const auto* operand_inst = _.FindDef(operand_id); - if (mode == spv::ExecutionMode::SubgroupsPerWorkgroupId || - mode == spv::ExecutionMode::LocalSizeHintId || - mode == spv::ExecutionMode::LocalSizeId) { - if (!spvOpcodeIsConstant(operand_inst->opcode())) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "For OpExecutionModeId all Extra Operand ids must be " - "constant " - "instructions."; - } - } else { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpExecutionModeId is only valid when the Mode operand is an " - "execution mode that takes Extra Operands that are id " - "operands."; + switch (mode) { + case spv::ExecutionMode::SubgroupsPerWorkgroupId: + case spv::ExecutionMode::LocalSizeHintId: + case spv::ExecutionMode::LocalSizeId: + case spv::ExecutionMode::IsApiEntryAMDX: + case spv::ExecutionMode::MaxNodeRecursionAMDX: + case spv::ExecutionMode::MaxNumWorkgroupsAMDX: + case spv::ExecutionMode::ShaderIndexAMDX: + case spv::ExecutionMode::SharesInputWithAMDX: + case spv::ExecutionMode::StaticNumWorkgroupsAMDX: + if (!spvOpcodeIsConstant(operand_inst->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "For OpExecutionModeId all Extra Operand ids must be " + "constant instructions."; + } + break; + case spv::ExecutionMode::FPFastMathDefault: + if (i == 2) { + if (!_.IsFloatScalarType(operand_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Target Type operand must be a floating-point " + "scalar type"; + } + } else { + bool is_int32 = false; + bool is_const = false; + uint32_t value = 0; + std::tie(is_int32, is_const, value) = + _.EvalInt32IfConst(operand_id); + if (is_int32 && is_const) { + // Valid values include up to 0x00040000 (AllowTransform). + uint32_t invalid_mask = 0xfff80000; + if ((invalid_mask & value) != 0) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Fast Math Default operand is an invalid bitmask " + "value"; + } + if (value & + static_cast(spv::FPFastMathModeMask::Fast)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Fast Math Default operand must not include Fast"; + } + const auto reassoc_contract = + spv::FPFastMathModeMask::AllowContract | + spv::FPFastMathModeMask::AllowReassoc; + if ((value & static_cast( + spv::FPFastMathModeMask::AllowTransform)) != 0 && + ((value & static_cast(reassoc_contract)) != + static_cast(reassoc_contract))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Fast Math Default operand must include " + "AllowContract and AllowReassoc when AllowTransform " + "is specified"; + } + } else { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "The Fast Math Default operand must be a " + "non-specialization constant"; + } + } + break; + default: + break; } } } else if (mode == spv::ExecutionMode::SubgroupsPerWorkgroupId || mode == spv::ExecutionMode::LocalSizeHintId || - mode == spv::ExecutionMode::LocalSizeId) { + mode == spv::ExecutionMode::LocalSizeId || + mode == spv::ExecutionMode::FPFastMathDefault || + mode == spv::ExecutionMode::IsApiEntryAMDX || + mode == spv::ExecutionMode::MaxNodeRecursionAMDX || + mode == spv::ExecutionMode::MaxNumWorkgroupsAMDX || + mode == spv::ExecutionMode::ShaderIndexAMDX || + mode == spv::ExecutionMode::SharesInputWithAMDX || + mode == spv::ExecutionMode::StaticNumWorkgroupsAMDX) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "OpExecutionMode is only valid when the Mode operand is an " "execution mode that takes no Extra Operands, or takes Extra " @@ -479,6 +599,15 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, "tessellation execution model."; } } + if (spvIsVulkanEnv(_.context()->target_env)) { + if (_.HasCapability(spv::Capability::MeshShadingEXT) && + inst->GetOperandAs(2) == 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(7330) + << "In mesh shaders using the MeshEXT Execution Model the " + "OutputVertices Execution Mode must be greater than 0"; + } + } break; case spv::ExecutionMode::OutputLinesEXT: case spv::ExecutionMode::OutputTrianglesEXT: @@ -493,6 +622,27 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, "execution " "model."; } + if (mode == spv::ExecutionMode::OutputPrimitivesEXT && + spvIsVulkanEnv(_.context()->target_env)) { + if (_.HasCapability(spv::Capability::MeshShadingEXT) && + inst->GetOperandAs(2) == 0) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << _.VkErrorID(7331) + << "In mesh shaders using the MeshEXT Execution Model the " + "OutputPrimitivesEXT Execution Mode must be greater than 0"; + } + } + break; + case spv::ExecutionMode::QuadDerivativesKHR: + if (!std::all_of(models->begin(), models->end(), + [](const spv::ExecutionModel& model) { + return (model == spv::ExecutionModel::Fragment || + model == spv::ExecutionModel::GLCompute); + })) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Execution mode can only be used with the Fragment or " + "GLCompute execution model."; + } break; case spv::ExecutionMode::PixelCenterInteger: case spv::ExecutionMode::OriginUpperLeft: @@ -502,6 +652,9 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, case spv::ExecutionMode::DepthGreater: case spv::ExecutionMode::DepthLess: case spv::ExecutionMode::DepthUnchanged: + case spv::ExecutionMode::NonCoherentColorAttachmentReadEXT: + case spv::ExecutionMode::NonCoherentDepthAttachmentReadEXT: + case spv::ExecutionMode::NonCoherentStencilAttachmentReadEXT: case spv::ExecutionMode::PixelInterlockOrderedEXT: case spv::ExecutionMode::PixelInterlockUnorderedEXT: case spv::ExecutionMode::SampleInterlockOrderedEXT: @@ -515,6 +668,7 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, case spv::ExecutionMode::StencilRefUnchangedBackAMD: case spv::ExecutionMode::StencilRefGreaterBackAMD: case spv::ExecutionMode::StencilRefLessBackAMD: + case spv::ExecutionMode::RequireFullQuadsKHR: if (!std::all_of(models->begin(), models->end(), [](const spv::ExecutionModel& model) { return model == spv::ExecutionModel::Fragment; @@ -576,6 +730,20 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _, break; } + if (mode == spv::ExecutionMode::FPFastMathDefault) { + const auto* modes = _.GetExecutionModes(entry_point_id); + if (modes && modes->count(spv::ExecutionMode::ContractionOff)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "FPFastMathDefault and ContractionOff execution modes cannot " + "be applied to the same entry point"; + } + if (modes && modes->count(spv::ExecutionMode::SignedZeroInfNanPreserve)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "FPFastMathDefault and SignedZeroInfNanPreserve execution " + "modes cannot be applied to the same entry point"; + } + } + if (spvIsVulkanEnv(_.context()->target_env)) { if (mode == spv::ExecutionMode::OriginLowerLeft) { return _.diag(SPV_ERROR_INVALID_DATA, inst) @@ -631,8 +799,91 @@ spv_result_t ValidateMemoryModel(ValidationState_t& _, return SPV_SUCCESS; } +bool PerEntryExecutionMode(spv::ExecutionMode mode) { + switch (mode) { + // These execution modes can be specified multiple times per entry point. + case spv::ExecutionMode::DenormPreserve: + case spv::ExecutionMode::DenormFlushToZero: + case spv::ExecutionMode::SignedZeroInfNanPreserve: + case spv::ExecutionMode::RoundingModeRTE: + case spv::ExecutionMode::RoundingModeRTZ: + case spv::ExecutionMode::FPFastMathDefault: + case spv::ExecutionMode::RoundingModeRTPINTEL: + case spv::ExecutionMode::RoundingModeRTNINTEL: + case spv::ExecutionMode::FloatingPointModeALTINTEL: + case spv::ExecutionMode::FloatingPointModeIEEEINTEL: + return false; + default: + return true; + } +} + } // namespace +spv_result_t ValidateFloatControls2(ValidationState_t& _) { + std::unordered_set fp_fast_math_default_entry_points; + for (auto entry_point : _.entry_points()) { + const auto* exec_modes = _.GetExecutionModes(entry_point); + if (exec_modes && + exec_modes->count(spv::ExecutionMode::FPFastMathDefault)) { + fp_fast_math_default_entry_points.insert(entry_point); + } + } + + std::vector> worklist; + for (const auto& inst : _.ordered_instructions()) { + if (inst.opcode() != spv::Op::OpDecorate) { + continue; + } + + const auto decoration = inst.GetOperandAs(1); + const auto target_id = inst.GetOperandAs(0); + const auto target = _.FindDef(target_id); + if (decoration == spv::Decoration::NoContraction) { + worklist.push_back(std::make_pair(target, decoration)); + } else if (decoration == spv::Decoration::FPFastMathMode) { + auto mask = inst.GetOperandAs(2); + if ((mask & spv::FPFastMathModeMask::Fast) != + spv::FPFastMathModeMask::MaskNone) { + worklist.push_back(std::make_pair(target, decoration)); + } + } + } + + std::unordered_set visited; + while (!worklist.empty()) { + const auto inst = worklist.back().first; + const auto decoration = worklist.back().second; + worklist.pop_back(); + + if (!visited.insert(inst).second) { + continue; + } + + const auto function = inst->function(); + if (function) { + const auto& entry_points = _.FunctionEntryPoints(function->id()); + for (auto entry_point : entry_points) { + if (fp_fast_math_default_entry_points.count(entry_point)) { + const std::string dec = decoration == spv::Decoration::NoContraction + ? "NoContraction" + : "FPFastMathMode Fast"; + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << dec + << " cannot be used by an entry point with the " + "FPFastMathDefault execution mode"; + } + } + } else { + for (const auto& pair : inst->uses()) { + worklist.push_back(std::make_pair(pair.first, decoration)); + } + } + } + + return SPV_SUCCESS; +} + spv_result_t ModeSettingPass(ValidationState_t& _, const Instruction* inst) { switch (inst->opcode()) { case spv::Op::OpEntryPoint: @@ -651,5 +902,52 @@ spv_result_t ModeSettingPass(ValidationState_t& _, const Instruction* inst) { return SPV_SUCCESS; } +spv_result_t ValidateDuplicateExecutionModes(ValidationState_t& _) { + using PerEntryKey = std::tuple; + using PerOperandKey = std::tuple; + std::set seen_per_entry; + std::set seen_per_operand; + + const auto lookupMode = [&_](spv::ExecutionMode mode) -> std::string { + spv_operand_desc desc = nullptr; + if (_.grammar().lookupOperand(SPV_OPERAND_TYPE_EXECUTION_MODE, + static_cast(mode), + &desc) == SPV_SUCCESS) { + return std::string(desc->name); + } + return "Unknown"; + }; + + for (const auto& inst : _.ordered_instructions()) { + if (inst.opcode() != spv::Op::OpExecutionMode && + inst.opcode() != spv::Op::OpExecutionModeId) { + continue; + } + + const auto entry = inst.GetOperandAs(0); + const auto mode = inst.GetOperandAs(1); + if (PerEntryExecutionMode(mode)) { + if (!seen_per_entry.insert(std::make_tuple(mode, entry)).second) { + return _.diag(SPV_ERROR_INVALID_ID, &inst) + << lookupMode(mode) + << " execution mode must not be specified multiple times per " + "entry point"; + } + } else { + // Execution modes allowed multiple times all take a single operand. + const auto operand = inst.GetOperandAs(2); + if (!seen_per_operand.insert(std::make_tuple(mode, entry, operand)) + .second) { + return _.diag(SPV_ERROR_INVALID_ID, &inst) + << lookupMode(mode) + << " execution mode must not be specified multiple times for " + "the same entry point and operands"; + } + } + } + + return SPV_SUCCESS; +} + } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/source/val/validate_non_uniform.cpp b/third_party/spirv-tools/source/val/validate_non_uniform.cpp index 5c5e9bd8b4..fd422a50ed 100644 --- a/third_party/spirv-tools/source/val/validate_non_uniform.cpp +++ b/third_party/spirv-tools/source/val/validate_non_uniform.cpp @@ -14,14 +14,11 @@ // Validates correctness of barrier SPIR-V instructions. -#include "source/val/validate.h" - -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" -#include "source/util/bitutils.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validate_scopes.h" #include "source/val/validation_state.h" @@ -29,6 +26,207 @@ namespace spvtools { namespace val { namespace { +spv_result_t ValidateGroupNonUniformElect(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsBoolScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar type"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformAnyAll(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsBoolScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar type"; + } + + if (!_.IsBoolScalarType(_.GetOperandTypeId(inst, 3))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Predicate must be a boolean scalar type"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformAllEqual(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsBoolScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar type"; + } + + const auto value_type = _.GetOperandTypeId(inst, 3); + if (!_.IsFloatScalarOrVectorType(value_type) && + !_.IsIntScalarOrVectorType(value_type) && + !_.IsBoolScalarOrVectorType(value_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a scalar or vector of integer, floating-point, or " + "boolean type"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformBroadcastShuffle(ValidationState_t& _, + const Instruction* inst) { + const auto type_id = inst->type_id(); + if (!_.IsFloatScalarOrVectorType(type_id) && + !_.IsIntScalarOrVectorType(type_id) && + !_.IsBoolScalarOrVectorType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a scalar or vector of integer, floating-point, " + "or boolean type"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 3); + if (value_type_id != type_id) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The type of Value must match the Result type"; + } + + const auto GetOperandName = [](const spv::Op opcode) { + std::string operand; + switch (opcode) { + case spv::Op::OpGroupNonUniformBroadcast: + case spv::Op::OpGroupNonUniformShuffle: + operand = "Id"; + break; + case spv::Op::OpGroupNonUniformShuffleXor: + operand = "Mask"; + break; + case spv::Op::OpGroupNonUniformQuadBroadcast: + operand = "Index"; + break; + case spv::Op::OpGroupNonUniformQuadSwap: + operand = "Direction"; + break; + case spv::Op::OpGroupNonUniformShuffleUp: + case spv::Op::OpGroupNonUniformShuffleDown: + default: + operand = "Delta"; + break; + } + return operand; + }; + + const auto id_type_id = _.GetOperandTypeId(inst, 4); + if (!_.IsUnsignedIntScalarType(id_type_id)) { + std::string operand = GetOperandName(inst->opcode()); + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << operand << " must be an unsigned integer scalar"; + } + + const bool should_be_constant = + inst->opcode() == spv::Op::OpGroupNonUniformQuadSwap || + ((inst->opcode() == spv::Op::OpGroupNonUniformBroadcast || + inst->opcode() == spv::Op::OpGroupNonUniformQuadBroadcast) && + _.version() < SPV_SPIRV_VERSION_WORD(1, 5)); + if (should_be_constant) { + const auto id_id = inst->GetOperandAs(4); + const auto id_op = _.GetIdOpcode(id_id); + if (!spvOpcodeIsConstant(id_op)) { + std::string operand = GetOperandName(inst->opcode()); + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Before SPIR-V 1.5, " << operand + << " must be a constant instruction"; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformBroadcastFirst(ValidationState_t& _, + const Instruction* inst) { + const auto type_id = inst->type_id(); + if (!_.IsFloatScalarOrVectorType(type_id) && + !_.IsIntScalarOrVectorType(type_id) && + !_.IsBoolScalarOrVectorType(type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a scalar or vector of integer, floating-point, " + "or boolean type"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 3); + if (value_type_id != type_id) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The type of Value must match the Result type"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformBallot(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsUnsignedIntVectorType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a 4-component unsigned integer vector"; + } + + if (_.GetDimension(inst->type_id()) != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a 4-component unsigned integer vector"; + } + + const auto pred_type_id = _.GetOperandTypeId(inst, 3); + if (!_.IsBoolScalarType(pred_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Predicate must be a boolean scalar"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformInverseBallot(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsBoolScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 3); + if (!_.IsUnsignedIntVectorType(value_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + if (_.GetDimension(value_type_id) != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformBallotBitExtract(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsBoolScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 3); + if (!_.IsUnsignedIntVectorType(value_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + if (_.GetDimension(value_type_id) != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + const auto id_type_id = _.GetOperandTypeId(inst, 4); + if (!_.IsUnsignedIntScalarType(id_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Id must be an unsigned integer scalar"; + } + + return SPV_SUCCESS; +} + spv_result_t ValidateGroupNonUniformBallotBitCount(ValidationState_t& _, const Instruction* inst) { // Scope is already checked by ValidateExecutionScope() above. @@ -63,6 +261,107 @@ spv_result_t ValidateGroupNonUniformBallotBitCount(ValidationState_t& _, return SPV_SUCCESS; } +spv_result_t ValidateGroupNonUniformBallotFind(ValidationState_t& _, + const Instruction* inst) { + if (!_.IsUnsignedIntScalarType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be an unsigned integer scalar"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 3); + if (!_.IsUnsignedIntVectorType(value_type_id)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + if (_.GetDimension(value_type_id) != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Value must be a 4-component unsigned integer vector"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateGroupNonUniformArithmetic(ValidationState_t& _, + const Instruction* inst) { + const bool is_unsigned = inst->opcode() == spv::Op::OpGroupNonUniformUMin || + inst->opcode() == spv::Op::OpGroupNonUniformUMax; + const bool is_float = inst->opcode() == spv::Op::OpGroupNonUniformFAdd || + inst->opcode() == spv::Op::OpGroupNonUniformFMul || + inst->opcode() == spv::Op::OpGroupNonUniformFMin || + inst->opcode() == spv::Op::OpGroupNonUniformFMax; + const bool is_bool = inst->opcode() == spv::Op::OpGroupNonUniformLogicalAnd || + inst->opcode() == spv::Op::OpGroupNonUniformLogicalOr || + inst->opcode() == spv::Op::OpGroupNonUniformLogicalXor; + if (is_float) { + if (!_.IsFloatScalarOrVectorType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a floating-point scalar or vector"; + } + } else if (is_bool) { + if (!_.IsBoolScalarOrVectorType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be a boolean scalar or vector"; + } + } else if (is_unsigned) { + if (!_.IsUnsignedIntScalarOrVectorType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be an unsigned integer scalar or vector"; + } + } else if (!_.IsIntScalarOrVectorType(inst->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Result must be an integer scalar or vector"; + } + + const auto value_type_id = _.GetOperandTypeId(inst, 4); + if (value_type_id != inst->type_id()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "The type of Value must match the Result type"; + } + + const auto group_op = inst->GetOperandAs(3); + bool is_clustered_reduce = group_op == spv::GroupOperation::ClusteredReduce; + bool is_partitioned_nv = + group_op == spv::GroupOperation::PartitionedReduceNV || + group_op == spv::GroupOperation::PartitionedInclusiveScanNV || + group_op == spv::GroupOperation::PartitionedExclusiveScanNV; + if (inst->operands().size() <= 5) { + if (is_clustered_reduce) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ClusterSize must be present when Operation is ClusteredReduce"; + } else if (is_partitioned_nv) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Ballot must be present when Operation is PartitionedReduceNV, " + "PartitionedInclusiveScanNV, or PartitionedExclusiveScanNV"; + } + } else { + const auto operand_id = inst->GetOperandAs(5); + const auto* operand = _.FindDef(operand_id); + if (is_partitioned_nv) { + if (!operand || !_.IsIntScalarOrVectorType(operand->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Ballot must be a 4-component integer vector"; + } + + if (_.GetDimension(operand->type_id()) != 4) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Ballot must be a 4-component integer vector"; + } + } else { + if (!operand || !_.IsUnsignedIntScalarType(operand->type_id())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ClusterSize must be an unsigned integer scalar"; + } + + if (!spvOpcodeIsConstant(operand->opcode())) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "ClusterSize must be a constant instruction"; + } + } + } + return SPV_SUCCESS; +} + spv_result_t ValidateGroupNonUniformRotateKHR(ValidationState_t& _, const Instruction* inst) { // Scope is already checked by ValidateExecutionScope() above. @@ -90,20 +389,24 @@ spv_result_t ValidateGroupNonUniformRotateKHR(ValidationState_t& _, if (inst->words().size() > 6) { const uint32_t cluster_size_op_id = inst->GetOperandAs(5); - const uint32_t cluster_size_type = _.GetTypeId(cluster_size_op_id); - if (!_.IsUnsignedIntScalarType(cluster_size_type)) { + const Instruction* cluster_size_inst = _.FindDef(cluster_size_op_id); + if (!cluster_size_inst || + !_.IsUnsignedIntScalarType(cluster_size_inst->type_id())) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "ClusterSize must be a scalar of integer type, whose " "Signedness operand is 0."; } - uint64_t cluster_size; - if (!_.GetConstantValUint64(cluster_size_op_id, &cluster_size)) { + if (!spvOpcodeIsConstant(cluster_size_inst->opcode())) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "ClusterSize must come from a constant instruction."; } - if ((cluster_size == 0) || ((cluster_size & (cluster_size - 1)) != 0)) { + uint64_t cluster_size; + const bool valid_const = + _.EvalConstantValUint64(cluster_size_op_id, &cluster_size); + if (valid_const && + ((cluster_size == 0) || ((cluster_size & (cluster_size - 1)) != 0))) { return _.diag(SPV_WARNING, inst) << "Behavior is undefined unless ClusterSize is at least 1 and a " "power of 2."; @@ -123,15 +426,63 @@ spv_result_t NonUniformPass(ValidationState_t& _, const Instruction* inst) { const spv::Op opcode = inst->opcode(); if (spvOpcodeIsNonUniformGroupOperation(opcode)) { - const uint32_t execution_scope = inst->word(3); - if (auto error = ValidateExecutionScope(_, inst, execution_scope)) { - return error; + // OpGroupNonUniformQuadAllKHR and OpGroupNonUniformQuadAnyKHR don't have + // scope paramter + if ((opcode != spv::Op::OpGroupNonUniformQuadAllKHR) && + (opcode != spv::Op::OpGroupNonUniformQuadAnyKHR)) { + const uint32_t execution_scope = inst->GetOperandAs(2); + if (auto error = ValidateExecutionScope(_, inst, execution_scope)) { + return error; + } } } switch (opcode) { + case spv::Op::OpGroupNonUniformElect: + return ValidateGroupNonUniformElect(_, inst); + case spv::Op::OpGroupNonUniformAny: + case spv::Op::OpGroupNonUniformAll: + return ValidateGroupNonUniformAnyAll(_, inst); + case spv::Op::OpGroupNonUniformAllEqual: + return ValidateGroupNonUniformAllEqual(_, inst); + case spv::Op::OpGroupNonUniformBroadcast: + case spv::Op::OpGroupNonUniformShuffle: + case spv::Op::OpGroupNonUniformShuffleXor: + case spv::Op::OpGroupNonUniformShuffleUp: + case spv::Op::OpGroupNonUniformShuffleDown: + case spv::Op::OpGroupNonUniformQuadBroadcast: + case spv::Op::OpGroupNonUniformQuadSwap: + return ValidateGroupNonUniformBroadcastShuffle(_, inst); + case spv::Op::OpGroupNonUniformBroadcastFirst: + return ValidateGroupNonUniformBroadcastFirst(_, inst); + case spv::Op::OpGroupNonUniformBallot: + return ValidateGroupNonUniformBallot(_, inst); + case spv::Op::OpGroupNonUniformInverseBallot: + return ValidateGroupNonUniformInverseBallot(_, inst); + case spv::Op::OpGroupNonUniformBallotBitExtract: + return ValidateGroupNonUniformBallotBitExtract(_, inst); case spv::Op::OpGroupNonUniformBallotBitCount: return ValidateGroupNonUniformBallotBitCount(_, inst); + case spv::Op::OpGroupNonUniformBallotFindLSB: + case spv::Op::OpGroupNonUniformBallotFindMSB: + return ValidateGroupNonUniformBallotFind(_, inst); + case spv::Op::OpGroupNonUniformIAdd: + case spv::Op::OpGroupNonUniformFAdd: + case spv::Op::OpGroupNonUniformIMul: + case spv::Op::OpGroupNonUniformFMul: + case spv::Op::OpGroupNonUniformSMin: + case spv::Op::OpGroupNonUniformUMin: + case spv::Op::OpGroupNonUniformFMin: + case spv::Op::OpGroupNonUniformSMax: + case spv::Op::OpGroupNonUniformUMax: + case spv::Op::OpGroupNonUniformFMax: + case spv::Op::OpGroupNonUniformBitwiseAnd: + case spv::Op::OpGroupNonUniformBitwiseOr: + case spv::Op::OpGroupNonUniformBitwiseXor: + case spv::Op::OpGroupNonUniformLogicalAnd: + case spv::Op::OpGroupNonUniformLogicalOr: + case spv::Op::OpGroupNonUniformLogicalXor: + return ValidateGroupNonUniformArithmetic(_, inst); case spv::Op::OpGroupNonUniformRotateKHR: return ValidateGroupNonUniformRotateKHR(_, inst); default: diff --git a/third_party/spirv-tools/source/val/validate_primitives.cpp b/third_party/spirv-tools/source/val/validate_primitives.cpp index 5e598c3aea..6769090db8 100644 --- a/third_party/spirv-tools/source/val/validate_primitives.cpp +++ b/third_party/spirv-tools/source/val/validate_primitives.cpp @@ -14,13 +14,11 @@ // Validates correctness of primitive SPIR-V instructions. -#include "source/val/validate.h" - #include -#include "source/diagnostic.h" #include "source/opcode.h" #include "source/val/instruction.h" +#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { diff --git a/third_party/spirv-tools/source/val/validate_ray_query.cpp b/third_party/spirv-tools/source/val/validate_ray_query.cpp index 9b67fc922b..bd790ac396 100644 --- a/third_party/spirv-tools/source/val/validate_ray_query.cpp +++ b/third_party/spirv-tools/source/val/validate_ray_query.cpp @@ -23,6 +23,17 @@ namespace spvtools { namespace val { namespace { +uint32_t GetArrayLength(ValidationState_t& _, const Instruction* array_type) { + assert(array_type->opcode() == spv::Op::OpTypeArray); + uint32_t const_int_id = array_type->GetOperandAs(2U); + Instruction* array_length_inst = _.FindDef(const_int_id); + uint32_t array_length = 0; + if (array_length_inst->opcode() == spv::Op::OpConstant) { + array_length = array_length_inst->GetOperandAs(2); + } + return array_length; +} + spv_result_t ValidateRayQueryPointer(ValidationState_t& _, const Instruction* inst, uint32_t ray_query_index) { @@ -263,6 +274,89 @@ spv_result_t RayQueryPass(ValidationState_t& _, const Instruction* inst) { break; } + case spv::Op::OpRayQueryGetClusterIdNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + if (!_.IsIntScalarType(result_type) || _.GetBitWidth(result_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "expected Result Type to be 32-bit int scalar type"; + } + break; + } + + case spv::Op::OpRayQueryGetIntersectionSpherePositionNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + if (!_.IsFloatVectorType(result_type) || + _.GetDimension(result_type) != 3 || + _.GetBitWidth(result_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "expected Result Type to be 32-bit float 3-component " + "vector type"; + } + break; + } + + case spv::Op::OpRayQueryGetIntersectionLSSPositionsNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + auto result_id = _.FindDef(result_type); + if ((result_id->opcode() != spv::Op::OpTypeArray) || + (GetArrayLength(_, result_id) != 2) || + !_.IsFloatVectorType(_.GetComponentType(result_type)) || + _.GetDimension(_.GetComponentType(result_type)) != 3) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 2 element array of 32-bit 3 component float point " + "vector as Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpRayQueryGetIntersectionLSSRadiiNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + if (!_.IsFloatArrayType(result_type) || + (GetArrayLength(_, _.FindDef(result_type)) != 2) || + !_.IsFloatScalarType(_.GetComponentType(result_type))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 32-bit floating point scalar as Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpRayQueryGetIntersectionSphereRadiusNV: + case spv::Op::OpRayQueryGetIntersectionLSSHitValueNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + if (!_.IsFloatScalarType(result_type) || + _.GetBitWidth(result_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "expected Result Type to be 32-bit floating point " + "scalar type"; + } + break; + } + + case spv::Op::OpRayQueryIsSphereHitNV: + case spv::Op::OpRayQueryIsLSSHitNV: { + if (auto error = ValidateRayQueryPointer(_, inst, 2)) return error; + if (auto error = ValidateIntersectionId(_, inst, 3)) return error; + + if (!_.IsBoolScalarType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "expected Result Type to be Boolean " + "scalar type"; + } + + break; + } default: break; } diff --git a/third_party/spirv-tools/source/val/validate_ray_tracing_reorder.cpp b/third_party/spirv-tools/source/val/validate_ray_tracing_reorder.cpp index cb190f91e4..3685a76530 100644 --- a/third_party/spirv-tools/source/val/validate_ray_tracing_reorder.cpp +++ b/third_party/spirv-tools/source/val/validate_ray_tracing_reorder.cpp @@ -26,6 +26,17 @@ namespace val { static const uint32_t KRayParamInvalidId = std::numeric_limits::max(); +uint32_t GetArrayLength(ValidationState_t& _, const Instruction* array_type) { + assert(array_type->opcode() == spv::Op::OpTypeArray); + uint32_t const_int_id = array_type->GetOperandAs(2U); + Instruction* array_length_inst = _.FindDef(const_int_id); + uint32_t array_length = 0; + if (array_length_inst->opcode() == spv::Op::OpConstant) { + array_length = array_length_inst->GetOperandAs(2); + } + return array_length; +} + spv_result_t ValidateHitObjectPointer(ValidationState_t& _, const Instruction* inst, uint32_t hit_object_index) { @@ -614,6 +625,102 @@ spv_result_t RayReorderNVPass(ValidationState_t& _, const Instruction* inst) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "bits must be a 32-bit int scalar"; } + break; + } + + case spv::Op::OpHitObjectGetClusterIdNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsIntScalarType(result_type) || _.GetBitWidth(result_type) != 32) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 32-bit integer type scalar as Result Type: " + << spvOpcodeString(opcode); + break; + } + + case spv::Op::OpHitObjectGetSpherePositionNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsFloatVectorType(result_type) || + _.GetDimension(result_type) != 3 || + _.GetBitWidth(result_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 32-bit floating point 2 component vector type as " + "Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpHitObjectGetSphereRadiusNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsFloatScalarType(result_type) || + _.GetBitWidth(result_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 32-bit floating point scalar as Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpHitObjectGetLSSPositionsNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + auto result_id = _.FindDef(result_type); + if ((result_id->opcode() != spv::Op::OpTypeArray) || + (GetArrayLength(_, result_id) != 2) || + !_.IsFloatVectorType(_.GetComponentType(result_type)) || + _.GetDimension(_.GetComponentType(result_type)) != 3) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 2 element array of 32-bit 3 component float point " + "vector as Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpHitObjectGetLSSRadiiNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsFloatArrayType(result_type) || + (GetArrayLength(_, _.FindDef(result_type)) != 2) || + !_.IsFloatScalarType(_.GetComponentType(result_type))) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected 2 element array of 32-bit floating point scalar as " + "Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpHitObjectIsSphereHitNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsBoolScalarType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Boolean scalar as Result Type: " + << spvOpcodeString(opcode); + } + break; + } + + case spv::Op::OpHitObjectIsLSSHitNV: { + RegisterOpcodeForValidModel(_, inst); + if (auto error = ValidateHitObjectPointer(_, inst, 2)) return error; + + if (!_.IsBoolScalarType(result_type)) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Boolean scalar as Result Type: " + << spvOpcodeString(opcode); + } + break; } default: diff --git a/third_party/spirv-tools/source/val/validate_scopes.cpp b/third_party/spirv-tools/source/val/validate_scopes.cpp index fa1dad9ec9..6b493538a5 100644 --- a/third_party/spirv-tools/source/val/validate_scopes.cpp +++ b/third_party/spirv-tools/source/val/validate_scopes.cpp @@ -14,7 +14,6 @@ #include "source/val/validate_scopes.h" -#include "source/diagnostic.h" #include "source/spirv_target_env.h" #include "source/val/instruction.h" #include "source/val/validation_state.h" @@ -98,8 +97,10 @@ spv_result_t ValidateExecutionScope(ValidationState_t& _, // Vulkan 1.1 specific rules if (_.context()->target_env != SPV_ENV_VULKAN_1_0) { // Scope for Non Uniform Group Operations must be limited to Subgroup - if (spvOpcodeIsNonUniformGroupOperation(opcode) && - value != spv::Scope::Subgroup) { + if ((spvOpcodeIsNonUniformGroupOperation(opcode) && + (opcode != spv::Op::OpGroupNonUniformQuadAllKHR) && + (opcode != spv::Op::OpGroupNonUniformQuadAnyKHR)) && + (value != spv::Scope::Subgroup)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(4642) << spvOpcodeString(opcode) << ": in Vulkan environment Execution scope is limited to " @@ -179,6 +180,8 @@ spv_result_t ValidateExecutionScope(ValidationState_t& _, // Scope for execution must be limited to Workgroup or Subgroup for // non-uniform operations if (spvOpcodeIsNonUniformGroupOperation(opcode) && + opcode != spv::Op::OpGroupNonUniformQuadAllKHR && + opcode != spv::Op::OpGroupNonUniformQuadAnyKHR && value != spv::Scope::Subgroup && value != spv::Scope::Workgroup) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << spvOpcodeString(opcode) @@ -240,7 +243,7 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst, !_.HasCapability(spv::Capability::SubgroupBallotKHR) && !_.HasCapability(spv::Capability::SubgroupVoteKHR)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) - << _.VkErrorID(6997) << spvOpcodeString(opcode) + << _.VkErrorID(7951) << spvOpcodeString(opcode) << ": in Vulkan 1.0 environment Memory Scope is can not be " "Subgroup without SubgroupBallotKHR or SubgroupVoteKHR " "declared"; diff --git a/third_party/spirv-tools/source/val/validate_tensor_layout.cpp b/third_party/spirv-tools/source/val/validate_tensor_layout.cpp new file mode 100644 index 0000000000..35c766b83d --- /dev/null +++ b/third_party/spirv-tools/source/val/validate_tensor_layout.cpp @@ -0,0 +1,184 @@ +// Copyright (c) 2024 NVIDIA Corporation +// +// 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. + +// Validate instructions that manipulate tensor layout and view objects + +#include "source/opcode.h" +#include "source/spirv_target_env.h" +#include "source/val/instruction.h" +#include "source/val/validate.h" +#include "source/val/validation_state.h" + +namespace spvtools { +namespace val { +namespace { + +spv_result_t ValidateTensorLayoutResultTypeNV(ValidationState_t& _, + const Instruction* inst) { + const auto result_type_index = 0; + const auto result_type_id = inst->GetOperandAs(result_type_index); + const auto result_type = _.FindDef(result_type_id); + + if (!result_type || spv::Op::OpTypeTensorLayoutNV != result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Result Type " + << _.getIdName(result_type_id) << " is not a tensor layout type."; + } + return SPV_SUCCESS; +} + +spv_result_t ValidateTensorViewResultTypeNV(ValidationState_t& _, + const Instruction* inst) { + const auto result_type_index = 0; + const auto result_type_id = inst->GetOperandAs(result_type_index); + const auto result_type = _.FindDef(result_type_id); + + if (!result_type || spv::Op::OpTypeTensorViewNV != result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Result Type " + << _.getIdName(result_type_id) << " is not a tensor view type."; + } + return SPV_SUCCESS; +} + +spv_result_t ValidateCreateTensorLayoutNV(ValidationState_t& _, + const Instruction* inst) { + if (auto error = ValidateTensorLayoutResultTypeNV(_, inst)) return error; + + return SPV_SUCCESS; +} + +spv_result_t ValidateCreateTensorViewNV(ValidationState_t& _, + const Instruction* inst) { + if (auto error = ValidateTensorViewResultTypeNV(_, inst)) return error; + + return SPV_SUCCESS; +} + +enum ExpectedNumValues { + DIM, + DIMx2, + ONE, + FOUR, +}; + +spv_result_t ValidateTensorTypeWithDimValuesNV(ValidationState_t& _, + const Instruction* inst, + ExpectedNumValues expected, + bool is_view) { + std::string type_str; + if (is_view) { + if (auto error = ValidateTensorViewResultTypeNV(_, inst)) return error; + type_str = "TensorView"; + } else { + if (auto error = ValidateTensorLayoutResultTypeNV(_, inst)) return error; + type_str = "TensorLayout"; + } + + const auto result_type_id = inst->GetOperandAs(0); + const auto tensor_id = inst->GetOperandAs(2); + const auto tensor = _.FindDef(tensor_id); + if (!tensor || result_type_id != tensor->type_id()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Result Type " + << _.getIdName(result_type_id) << " does not match " << type_str + << " type."; + } + + const auto num_values = inst->operands().size() - 3; + + const auto result_type = _.FindDef(result_type_id); + const auto dim_index = 1; + const auto dim_id = result_type->GetOperandAs(dim_index); + uint64_t dim_value; + if (_.EvalConstantValUint64(dim_id, &dim_value)) { + uint64_t expected_num_values = 0; + switch (expected) { + case DIM: + expected_num_values = dim_value; + break; + case DIMx2: + expected_num_values = dim_value * 2; + break; + case ONE: + expected_num_values = 1; + break; + case FOUR: + expected_num_values = 4; + break; + } + + if (num_values != expected_num_values) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) + << " unexpected number of operands."; + } + } + + for (uint32_t i = 0; i < num_values; ++i) { + const auto val_id = inst->GetOperandAs(i + 3); + const auto val = _.FindDef(val_id); + if (!val || !_.IsIntScalarType(val->type_id()) || + _.GetBitWidth(val->type_id()) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " operand " + << _.getIdName(val_id) << " is not a 32-bit integer."; + } + } + + return SPV_SUCCESS; +} + +} // namespace + +spv_result_t TensorLayoutPass(ValidationState_t& _, const Instruction* inst) { + switch (inst->opcode()) { + case spv::Op::OpCreateTensorLayoutNV: + if (auto error = ValidateCreateTensorLayoutNV(_, inst)) return error; + break; + case spv::Op::OpCreateTensorViewNV: + if (auto error = ValidateCreateTensorViewNV(_, inst)) return error; + break; + case spv::Op::OpTensorLayoutSetBlockSizeNV: + case spv::Op::OpTensorLayoutSetDimensionNV: + case spv::Op::OpTensorLayoutSetStrideNV: + if (auto error = ValidateTensorTypeWithDimValuesNV(_, inst, DIM, false)) + return error; + break; + case spv::Op::OpTensorLayoutSliceNV: + if (auto error = ValidateTensorTypeWithDimValuesNV(_, inst, DIMx2, false)) + return error; + break; + case spv::Op::OpTensorLayoutSetClampValueNV: + if (auto error = ValidateTensorTypeWithDimValuesNV(_, inst, ONE, false)) + return error; + break; + case spv::Op::OpTensorViewSetDimensionNV: + case spv::Op::OpTensorViewSetStrideNV: + if (auto error = ValidateTensorTypeWithDimValuesNV(_, inst, DIM, true)) + return error; + break; + case spv::Op::OpTensorViewSetClipNV: + if (auto error = ValidateTensorTypeWithDimValuesNV(_, inst, FOUR, true)) + return error; + break; + default: + break; + } + + return SPV_SUCCESS; +} + +} // namespace val +} // namespace spvtools diff --git a/third_party/spirv-tools/source/val/validate_type.cpp b/third_party/spirv-tools/source/val/validate_type.cpp index e7adab80fc..c2aca99768 100644 --- a/third_party/spirv-tools/source/val/validate_type.cpp +++ b/third_party/spirv-tools/source/val/validate_type.cpp @@ -1,4 +1,7 @@ // Copyright (c) 2018 Google LLC. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. +// Copyright (c) 2024 NVIDIA Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,21 +27,6 @@ namespace spvtools { namespace val { namespace { -// Returns, as an int64_t, the literal value from an OpConstant or the -// default value of an OpSpecConstant, assuming it is an integral type. -// For signed integers, relies the rule that literal value is sign extended -// to fill out to word granularity. Assumes that the constant value -// has -int64_t ConstantLiteralAsInt64(uint32_t width, - const std::vector& const_words) { - const uint32_t lo_word = const_words[3]; - if (width <= 32) return int32_t(lo_word); - assert(width <= 64); - assert(const_words.size() > 4); - const uint32_t hi_word = const_words[4]; // Must exist, per spec. - return static_cast(uint64_t(lo_word) | uint64_t(hi_word) << 32); -} - // Validates that type declarations are unique, unless multiple declarations // of the same data type are allowed by the specification. // (see section 2.8 Types and Variables) @@ -50,7 +38,9 @@ spv_result_t ValidateUniqueness(ValidationState_t& _, const Instruction* inst) { const auto opcode = inst->opcode(); if (opcode != spv::Op::OpTypeArray && opcode != spv::Op::OpTypeRuntimeArray && + opcode != spv::Op::OpTypeNodePayloadArrayAMDX && opcode != spv::Op::OpTypeStruct && opcode != spv::Op::OpTypePointer && + opcode != spv::Op::OpTypeUntypedPointerKHR && !_.RegisterUniqueTypeDeclaration(inst)) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Duplicate non-aggregate type declarations are not allowed. " @@ -179,6 +169,57 @@ spv_result_t ValidateTypeVector(ValidationState_t& _, const Instruction* inst) { return SPV_SUCCESS; } +spv_result_t ValidateTypeCooperativeVectorNV(ValidationState_t& _, + const Instruction* inst) { + const auto component_index = 1; + const auto component_type_id = inst->GetOperandAs(component_index); + const auto component_type = _.FindDef(component_type_id); + if (!component_type || (spv::Op::OpTypeFloat != component_type->opcode() && + spv::Op::OpTypeInt != component_type->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeVectorNV Component Type " + << _.getIdName(component_type_id) + << " is not a scalar numerical type."; + } + + const auto num_components_index = 2; + const auto num_components_id = + inst->GetOperandAs(num_components_index); + const auto num_components = _.FindDef(num_components_id); + if (!num_components || !spvOpcodeIsConstant(num_components->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeVectorNV component count " + << _.getIdName(num_components_id) + << " is not a scalar constant type."; + } + + // NOTE: Check the initialiser value of the constant + const auto const_inst = num_components->words(); + const auto const_result_type_index = 1; + const auto const_result_type = _.FindDef(const_inst[const_result_type_index]); + if (!const_result_type || spv::Op::OpTypeInt != const_result_type->opcode()) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeVectorNV component count " + << _.getIdName(num_components_id) + << " is not a constant integer type."; + } + + int64_t num_components_value; + if (_.EvalConstantValInt64(num_components_id, &num_components_value)) { + auto& type_words = const_result_type->words(); + const bool is_signed = type_words[3] > 0; + if (num_components_value == 0 || (num_components_value < 0 && is_signed)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeVectorNV component count " + << _.getIdName(num_components_id) + << " default value must be at least 1: found " + << num_components_value; + } + } + + return SPV_SUCCESS; +} + spv_result_t ValidateTypeMatrix(ValidationState_t& _, const Instruction* inst) { const auto column_type_index = 1; const auto column_type_id = inst->GetOperandAs(column_type_index); @@ -225,6 +266,18 @@ spv_result_t ValidateTypeArray(ValidationState_t& _, const Instruction* inst) { << " is a void type."; } + if (_.HasCapability(spv::Capability::Shader)) { + if (element_type->opcode() == spv::Op::OpTypeStruct && + (_.HasDecoration(element_type->id(), spv::Decoration::Block) || + _.HasDecoration(element_type->id(), spv::Decoration::BufferBlock))) { + if (_.HasDecoration(inst->id(), spv::Decoration::ArrayStride)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Array containing a Block or BufferBlock must not be " + "decorated with ArrayStride"; + } + } + } + if (spvIsVulkanEnv(_.context()->target_env) && element_type->opcode() == spv::Op::OpTypeRuntimeArray) { return _.diag(SPV_ERROR_INVALID_ID, inst) @@ -252,29 +305,17 @@ spv_result_t ValidateTypeArray(ValidationState_t& _, const Instruction* inst) { << " is not a constant integer type."; } - switch (length->opcode()) { - case spv::Op::OpSpecConstant: - case spv::Op::OpConstant: { - auto& type_words = const_result_type->words(); - const bool is_signed = type_words[3] > 0; - const uint32_t width = type_words[2]; - const int64_t ivalue = ConstantLiteralAsInt64(width, length->words()); - if (ivalue == 0 || (ivalue < 0 && is_signed)) { - return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeArray Length " << _.getIdName(length_id) - << " default value must be at least 1: found " << ivalue; - } - } break; - case spv::Op::OpConstantNull: + int64_t length_value; + if (_.EvalConstantValInt64(length_id, &length_value)) { + auto& type_words = const_result_type->words(); + const bool is_signed = type_words[3] > 0; + if (length_value == 0 || (length_value < 0 && is_signed)) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "OpTypeArray Length " << _.getIdName(length_id) - << " default value must be at least 1."; - case spv::Op::OpSpecConstantOp: - // Assume it's OK, rather than try to evaluate the operation. - break; - default: - assert(0 && "bug in spvOpcodeIsConstant() or result type isn't int"); + << " default value must be at least 1: found " << length_value; + } } + return SPV_SUCCESS; } @@ -295,6 +336,18 @@ spv_result_t ValidateTypeRuntimeArray(ValidationState_t& _, << " is a void type."; } + if (_.HasCapability(spv::Capability::Shader)) { + if (element_type->opcode() == spv::Op::OpTypeStruct && + (_.HasDecoration(element_type->id(), spv::Decoration::Block) || + _.HasDecoration(element_type->id(), spv::Decoration::BufferBlock))) { + if (_.HasDecoration(inst->id(), spv::Decoration::ArrayStride)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Array containing a Block or BufferBlock must not be " + "decorated with ArrayStride"; + } + } + } + if (spvIsVulkanEnv(_.context()->target_env) && element_type->opcode() == spv::Op::OpTypeRuntimeArray) { return _.diag(SPV_ERROR_INVALID_ID, inst) @@ -349,6 +402,15 @@ spv_result_t ValidateTypeStruct(ValidationState_t& _, const Instruction* inst) { << ", OpTypeRuntimeArray must only be used for the last member " "of an OpTypeStruct"; } + + if (!_.HasDecoration(inst->id(), spv::Decoration::Block) && + !_.HasDecoration(inst->id(), spv::Decoration::BufferBlock)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << _.VkErrorID(4680) + << spvLogStringForEnv(_.context()->target_env) + << ", OpTypeStruct containing an OpTypeRuntimeArray " + << "must be decorated with Block or BufferBlock."; + } } } @@ -356,13 +418,20 @@ spv_result_t ValidateTypeStruct(ValidationState_t& _, const Instruction* inst) { // Struct members start at word 2 of OpTypeStruct instruction. for (size_t word_i = 2; word_i < inst->words().size(); ++word_i) { auto member = inst->word(word_i); - auto memberTypeInstr = _.FindDef(member); - if (memberTypeInstr && spv::Op::OpTypeStruct == memberTypeInstr->opcode()) { - if (_.HasDecoration(memberTypeInstr->id(), spv::Decoration::Block) || - _.HasDecoration(memberTypeInstr->id(), - spv::Decoration::BufferBlock) || - _.GetHasNestedBlockOrBufferBlockStruct(memberTypeInstr->id())) - has_nested_blockOrBufferBlock_struct = true; + if (_.ContainsType( + member, + [&_](const Instruction* type_inst) { + if (type_inst->opcode() == spv::Op::OpTypeStruct && + (_.HasDecoration(type_inst->id(), spv::Decoration::Block) || + _.HasDecoration(type_inst->id(), + spv::Decoration::BufferBlock))) { + return true; + } + return false; + }, + /* traverse_all_types = */ false)) { + has_nested_blockOrBufferBlock_struct = true; + break; } } @@ -543,8 +612,8 @@ spv_result_t ValidateTypeForwardPointer(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateTypeCooperativeMatrixNV(ValidationState_t& _, - const Instruction* inst) { +spv_result_t ValidateTypeCooperativeMatrix(ValidationState_t& _, + const Instruction* inst) { const auto component_type_index = 1; const auto component_type_id = inst->GetOperandAs(component_type_index); @@ -552,7 +621,7 @@ spv_result_t ValidateTypeCooperativeMatrixNV(ValidationState_t& _, if (!component_type || (spv::Op::OpTypeFloat != component_type->opcode() && spv::Op::OpTypeInt != component_type->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeCooperativeMatrixNV Component Type " + << "OpTypeCooperativeMatrix Component Type " << _.getIdName(component_type_id) << " is not a scalar numerical type."; } @@ -563,7 +632,7 @@ spv_result_t ValidateTypeCooperativeMatrixNV(ValidationState_t& _, if (!scope || !_.IsIntScalarType(scope->type_id()) || !spvOpcodeIsConstant(scope->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeCooperativeMatrixNV Scope " << _.getIdName(scope_id) + << "OpTypeCooperativeMatrix Scope " << _.getIdName(scope_id) << " is not a constant instruction with scalar integer type."; } @@ -573,7 +642,7 @@ spv_result_t ValidateTypeCooperativeMatrixNV(ValidationState_t& _, if (!rows || !_.IsIntScalarType(rows->type_id()) || !spvOpcodeIsConstant(rows->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeCooperativeMatrixNV Rows " << _.getIdName(rows_id) + << "OpTypeCooperativeMatrix Rows " << _.getIdName(rows_id) << " is not a constant instruction with scalar integer type."; } @@ -583,10 +652,189 @@ spv_result_t ValidateTypeCooperativeMatrixNV(ValidationState_t& _, if (!cols || !_.IsIntScalarType(cols->type_id()) || !spvOpcodeIsConstant(cols->opcode())) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "OpTypeCooperativeMatrixNV Cols " << _.getIdName(cols_id) + << "OpTypeCooperativeMatrix Cols " << _.getIdName(cols_id) << " is not a constant instruction with scalar integer type."; } + if (inst->opcode() == spv::Op::OpTypeCooperativeMatrixKHR) { + const auto use_index = 5; + const auto use_id = inst->GetOperandAs(use_index); + const auto use = _.FindDef(use_id); + if (!use || !_.IsIntScalarType(use->type_id()) || + !spvOpcodeIsConstant(use->opcode())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeMatrixKHR Use " << _.getIdName(use_id) + << " is not a constant instruction with scalar integer type."; + } + } + + uint64_t scope_value; + if (_.EvalConstantValUint64(scope_id, &scope_value)) { + if (scope_value == static_cast(spv::Scope::Workgroup)) { + for (auto entry_point_id : _.entry_points()) { + if (!_.EntryPointHasLocalSizeOrId(entry_point_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeMatrixKHR with ScopeWorkgroup " + << "used without specifying LocalSize or LocalSizeId " + << "for entry point " << _.getIdName(entry_point_id); + } + const auto local_size = _.EntryPointLocalSizeOrId(entry_point_id); + const auto mode = local_size->GetOperandAs(1); + if (mode == spv::ExecutionMode::LocalSizeId) { + uint32_t local_size_ids[3] = { + local_size->GetOperandAs(2), + local_size->GetOperandAs(3), + local_size->GetOperandAs(4), + }; + for (auto id : local_size_ids) { + if (_.FindDef(id) > inst) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "OpTypeCooperativeMatrixKHR with ScopeWorkgroup " + << "used before LocalSizeId constant value " + << _.getIdName(id) << " is defined."; + } + } + } + } + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateTypeUntypedPointerKHR(ValidationState_t& _, + const Instruction* inst) { + if (spvIsVulkanEnv(_.context()->target_env)) { + const auto sc = inst->GetOperandAs(1); + switch (sc) { + case spv::StorageClass::Workgroup: + if (!_.HasCapability( + spv::Capability::WorkgroupMemoryExplicitLayoutKHR)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Workgroup storage class untyped pointers in Vulkan " + "require WorkgroupMemoryExplicitLayoutKHR be declared"; + } + break; + case spv::StorageClass::StorageBuffer: + case spv::StorageClass::PhysicalStorageBuffer: + case spv::StorageClass::Uniform: + case spv::StorageClass::PushConstant: + break; + default: + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "In Vulkan, untyped pointers can only be used in an " + "explicitly laid out storage class"; + } + } + return SPV_SUCCESS; +} + +spv_result_t ValidateTensorDim(ValidationState_t& _, const Instruction* inst) { + const auto dim_index = 1; + const auto dim_id = inst->GetOperandAs(dim_index); + const auto dim = _.FindDef(dim_id); + if (!dim || !_.IsIntScalarType(dim->type_id()) || + _.GetBitWidth(dim->type_id()) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Dim " + << _.getIdName(dim_id) << " is not a 32-bit integer."; + } + + constexpr uint32_t max_tensor_dim = 5; + + uint64_t dim_value; + if (_.EvalConstantValUint64(dim_id, &dim_value)) { + if (dim_value == 0 || dim_value > max_tensor_dim) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Dim " + << _.getIdName(dim_id) << " must be between 1 and " + << max_tensor_dim << "."; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateTypeTensorLayoutNV(ValidationState_t& _, + const Instruction* inst) { + if (auto error = ValidateTensorDim(_, inst)) return error; + + const auto clamp_index = 2; + const auto clamp_id = inst->GetOperandAs(clamp_index); + const auto clamp = _.FindDef(clamp_id); + if (!clamp || !_.IsIntScalarType(clamp->type_id()) || + _.GetBitWidth(clamp->type_id()) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " ClampMode " + << _.getIdName(clamp_id) << " is not a 32-bit integer."; + } + + uint64_t clamp_value; + if (_.EvalConstantValUint64(clamp_id, &clamp_value)) { + if (clamp_value > + static_cast(spv::TensorClampMode::RepeatMirrored)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " ClampMode " + << _.getIdName(clamp_id) << " must be a valid TensorClampMode."; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateTypeTensorViewNV(ValidationState_t& _, + const Instruction* inst) { + if (auto error = ValidateTensorDim(_, inst)) return error; + + const auto has_dim_index = 2; + const auto has_dim_id = inst->GetOperandAs(has_dim_index); + const auto has_dim = _.FindDef(has_dim_id); + if (!has_dim || !_.IsBoolScalarType(has_dim->type_id())) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " HasDimensions " + << _.getIdName(has_dim_id) << " is not a boolean value."; + } + + uint32_t permutation_mask = 0; + bool all_constant = true; + const auto num_dim = inst->operands().size() - 3; + for (size_t p_index = 3; p_index < inst->operands().size(); ++p_index) { + auto p_id = inst->GetOperandAs(p_index); + const auto p = _.FindDef(p_id); + if (!p || !_.IsIntScalarType(p->type_id()) || + _.GetBitWidth(p->type_id()) != 32) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Permutation " + << _.getIdName(p_id) << " is not a 32-bit integer."; + } + + uint64_t p_value; + if (_.EvalConstantValUint64(p_id, &p_value)) { + if (p_value >= num_dim) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) << " Permutation " + << _.getIdName(p_id) << " must be a valid dimension."; + } + permutation_mask |= 1 << p_value; + } else { + all_constant = false; + } + } + if (all_constant && permutation_mask != (1U << num_dim) - 1U) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) + << " Permutation values don't form a valid permutation."; + } + + uint64_t dim_value; + if (_.EvalConstantValUint64(inst->GetOperandAs(1), &dim_value)) { + if (dim_value != num_dim) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << spvOpcodeString(inst->opcode()) + << " Incorrect number of permutation values."; + } + } + return SPV_SUCCESS; } } // namespace @@ -631,7 +879,20 @@ spv_result_t TypePass(ValidationState_t& _, const Instruction* inst) { if (auto error = ValidateTypeForwardPointer(_, inst)) return error; break; case spv::Op::OpTypeCooperativeMatrixNV: - if (auto error = ValidateTypeCooperativeMatrixNV(_, inst)) return error; + case spv::Op::OpTypeCooperativeMatrixKHR: + if (auto error = ValidateTypeCooperativeMatrix(_, inst)) return error; + break; + case spv::Op::OpTypeCooperativeVectorNV: + if (auto error = ValidateTypeCooperativeVectorNV(_, inst)) return error; + break; + case spv::Op::OpTypeUntypedPointerKHR: + if (auto error = ValidateTypeUntypedPointerKHR(_, inst)) return error; + break; + case spv::Op::OpTypeTensorLayoutNV: + if (auto error = ValidateTypeTensorLayoutNV(_, inst)) return error; + break; + case spv::Op::OpTypeTensorViewNV: + if (auto error = ValidateTypeTensorViewNV(_, inst)) return error; break; default: break; diff --git a/third_party/spirv-tools/source/val/validation_state.cpp b/third_party/spirv-tools/source/val/validation_state.cpp index c95eec366b..4604d6da51 100644 --- a/third_party/spirv-tools/source/val/validation_state.cpp +++ b/third_party/spirv-tools/source/val/validation_state.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2015-2016 The Khronos Group Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +23,7 @@ #include "source/opcode.h" #include "source/spirv_constant.h" #include "source/spirv_target_env.h" +#include "source/util/make_unique.h" #include "source/val/basic_block.h" #include "source/val/construct.h" #include "source/val/function.h" @@ -72,9 +75,11 @@ ModuleLayoutSection InstructionLayoutSection( case spv::Op::OpTypeForwardPointer: return kLayoutTypes; case spv::Op::OpVariable: + case spv::Op::OpUntypedVariableKHR: if (current_section == kLayoutTypes) return kLayoutTypes; return kLayoutFunctionDefinitions; case spv::Op::OpExtInst: + case spv::Op::OpExtInstWithForwardRefsKHR: // spv::Op::OpExtInst is only allowed in types section for certain // extended instruction sets. This will be checked separately. if (current_section == kLayoutTypes) return kLayoutTypes; @@ -359,14 +364,16 @@ void ValidationState_t::RegisterCapability(spv::Capability cap) { // Avoid redundant work. Otherwise the recursion could induce work // quadrdatic in the capability dependency depth. (Ok, not much, but // it's something.) - if (module_capabilities_.Contains(cap)) return; + if (module_capabilities_.contains(cap)) return; - module_capabilities_.Add(cap); + module_capabilities_.insert(cap); spv_operand_desc desc; if (SPV_SUCCESS == grammar_.lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, uint32_t(cap), &desc)) { - CapabilitySet(desc->numCapabilities, desc->capabilities) - .ForEach([this](spv::Capability c) { RegisterCapability(c); }); + for (auto capability : + CapabilitySet(desc->numCapabilities, desc->capabilities)) { + RegisterCapability(capability); + } } switch (cap) { @@ -418,9 +425,9 @@ void ValidationState_t::RegisterCapability(spv::Capability cap) { } void ValidationState_t::RegisterExtension(Extension ext) { - if (module_extensions_.Contains(ext)) return; + if (module_extensions_.contains(ext)) return; - module_extensions_.Add(ext); + module_extensions_.insert(ext); switch (ext) { case kSPV_AMD_gpu_shader_half_float: @@ -608,6 +615,19 @@ void ValidationState_t::RegisterSampledImageConsumer(uint32_t sampled_image_id, sampled_image_consumers_[sampled_image_id].push_back(consumer); } +void ValidationState_t::RegisterQCOMImageProcessingTextureConsumer( + uint32_t texture_id, const Instruction* consumer0, + const Instruction* consumer1) { + if (HasDecoration(texture_id, spv::Decoration::WeightTextureQCOM) || + HasDecoration(texture_id, spv::Decoration::BlockMatchTextureQCOM) || + HasDecoration(texture_id, spv::Decoration::BlockMatchSamplerQCOM)) { + qcom_image_processing_consumers_.insert(consumer0->id()); + if (consumer1) { + qcom_image_processing_consumers_.insert(consumer1->id()); + } + } +} + void ValidationState_t::RegisterStorageClassConsumer( spv::StorageClass storage_class, Instruction* consumer) { if (spvIsVulkanEnv(context()->target_env)) { @@ -665,39 +685,39 @@ void ValidationState_t::RegisterStorageClassConsumer( if (storage_class == spv::StorageClass::CallableDataKHR) { std::string errorVUID = VkErrorID(4704); function(consumer->function()->id()) - ->RegisterExecutionModelLimitation([errorVUID]( - spv::ExecutionModel model, - std::string* message) { - if (model != spv::ExecutionModel::RayGenerationKHR && - model != spv::ExecutionModel::ClosestHitKHR && - model != spv::ExecutionModel::CallableKHR && - model != spv::ExecutionModel::MissKHR) { - if (message) { - *message = errorVUID + - "CallableDataKHR Storage Class is limited to " - "RayGenerationKHR, ClosestHitKHR, CallableKHR, and " - "MissKHR execution model"; - } - return false; - } - return true; - }); + ->RegisterExecutionModelLimitation( + [errorVUID](spv::ExecutionModel model, std::string* message) { + if (model != spv::ExecutionModel::RayGenerationKHR && + model != spv::ExecutionModel::ClosestHitKHR && + model != spv::ExecutionModel::CallableKHR && + model != spv::ExecutionModel::MissKHR) { + if (message) { + *message = + errorVUID + + "CallableDataKHR Storage Class is limited to " + "RayGenerationKHR, ClosestHitKHR, CallableKHR, and " + "MissKHR execution model"; + } + return false; + } + return true; + }); } else if (storage_class == spv::StorageClass::IncomingCallableDataKHR) { std::string errorVUID = VkErrorID(4705); function(consumer->function()->id()) - ->RegisterExecutionModelLimitation([errorVUID]( - spv::ExecutionModel model, - std::string* message) { - if (model != spv::ExecutionModel::CallableKHR) { - if (message) { - *message = errorVUID + - "IncomingCallableDataKHR Storage Class is limited to " - "CallableKHR execution model"; - } - return false; - } - return true; - }); + ->RegisterExecutionModelLimitation( + [errorVUID](spv::ExecutionModel model, std::string* message) { + if (model != spv::ExecutionModel::CallableKHR) { + if (message) { + *message = + errorVUID + + "IncomingCallableDataKHR Storage Class is limited to " + "CallableKHR execution model"; + } + return false; + } + return true; + }); } else if (storage_class == spv::StorageClass::RayPayloadKHR) { std::string errorVUID = VkErrorID(4698); function(consumer->function()->id()) @@ -852,6 +872,9 @@ uint32_t ValidationState_t::GetComponentType(uint32_t id) const { case spv::Op::OpTypeBool: return id; + case spv::Op::OpTypeArray: + return inst->word(2); + case spv::Op::OpTypeVector: return inst->word(2); @@ -859,6 +882,8 @@ uint32_t ValidationState_t::GetComponentType(uint32_t id) const { return GetComponentType(inst->word(2)); case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: return inst->word(2); default: @@ -886,6 +911,8 @@ uint32_t ValidationState_t::GetDimension(uint32_t id) const { return inst->word(3); case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: // Actual dimension isn't known, return 0 return 0; @@ -924,6 +951,19 @@ bool ValidationState_t::IsFloatScalarType(uint32_t id) const { return inst && inst->opcode() == spv::Op::OpTypeFloat; } +bool ValidationState_t::IsFloatArrayType(uint32_t id) const { + const Instruction* inst = FindDef(id); + if (!inst) { + return false; + } + + if (inst->opcode() == spv::Op::OpTypeArray) { + return IsFloatScalarType(GetComponentType(id)); + } + + return false; +} + bool ValidationState_t::IsFloatVectorType(uint32_t id) const { const Instruction* inst = FindDef(id); if (!inst) { @@ -937,6 +977,20 @@ bool ValidationState_t::IsFloatVectorType(uint32_t id) const { return false; } +bool ValidationState_t::IsFloat16Vector2Or4Type(uint32_t id) const { + const Instruction* inst = FindDef(id); + assert(inst); + + if (inst->opcode() == spv::Op::OpTypeVector) { + uint32_t vectorDim = GetDimension(id); + return IsFloatScalarType(GetComponentType(id)) && + (vectorDim == 2 || vectorDim == 4) && + (GetBitWidth(GetComponentType(id)) == 16); + } + + return false; +} + bool ValidationState_t::IsFloatScalarOrVectorType(uint32_t id) const { const Instruction* inst = FindDef(id); if (!inst) { @@ -959,6 +1013,19 @@ bool ValidationState_t::IsIntScalarType(uint32_t id) const { return inst && inst->opcode() == spv::Op::OpTypeInt; } +bool ValidationState_t::IsIntArrayType(uint32_t id) const { + const Instruction* inst = FindDef(id); + if (!inst) { + return false; + } + + if (inst->opcode() == spv::Op::OpTypeArray) { + return IsIntScalarType(GetComponentType(id)); + } + + return false; +} + bool ValidationState_t::IsIntVectorType(uint32_t id) const { const Instruction* inst = FindDef(id); if (!inst) { @@ -1007,6 +1074,23 @@ bool ValidationState_t::IsUnsignedIntVectorType(uint32_t id) const { return false; } +bool ValidationState_t::IsUnsignedIntScalarOrVectorType(uint32_t id) const { + const Instruction* inst = FindDef(id); + if (!inst) { + return false; + } + + if (inst->opcode() == spv::Op::OpTypeInt) { + return inst->GetOperandAs(2) == 0; + } + + if (inst->opcode() == spv::Op::OpTypeVector) { + return IsUnsignedIntScalarType(GetComponentType(id)); + } + + return false; +} + bool ValidationState_t::IsSignedIntScalarType(uint32_t id) const { const Instruction* inst = FindDef(id); return inst && inst->opcode() == spv::Op::OpTypeInt && inst->word(3) == 1; @@ -1118,8 +1202,11 @@ bool ValidationState_t::GetStructMemberTypes( } bool ValidationState_t::IsPointerType(uint32_t id) const { + if (!id) return false; const Instruction* inst = FindDef(id); - return inst && inst->opcode() == spv::Op::OpTypePointer; + assert(inst); + return inst->opcode() == spv::Op::OpTypePointer || + inst->opcode() == spv::Op::OpTypeUntypedPointerKHR; } bool ValidationState_t::GetPointerTypeInfo( @@ -1129,6 +1216,12 @@ bool ValidationState_t::GetPointerTypeInfo( const Instruction* inst = FindDef(id); assert(inst); + if (inst->opcode() == spv::Op::OpTypeUntypedPointerKHR) { + *storage_class = spv::StorageClass(inst->word(2)); + *data_type = 0; + return true; + } + if (inst->opcode() != spv::Op::OpTypePointer) return false; *storage_class = spv::StorageClass(inst->word(2)); @@ -1142,22 +1235,68 @@ bool ValidationState_t::IsAccelerationStructureType(uint32_t id) const { } bool ValidationState_t::IsCooperativeMatrixType(uint32_t id) const { + const Instruction* inst = FindDef(id); + return inst && (inst->opcode() == spv::Op::OpTypeCooperativeMatrixNV || + inst->opcode() == spv::Op::OpTypeCooperativeMatrixKHR); +} + +bool ValidationState_t::IsCooperativeMatrixNVType(uint32_t id) const { const Instruction* inst = FindDef(id); return inst && inst->opcode() == spv::Op::OpTypeCooperativeMatrixNV; } +bool ValidationState_t::IsCooperativeMatrixKHRType(uint32_t id) const { + const Instruction* inst = FindDef(id); + return inst && inst->opcode() == spv::Op::OpTypeCooperativeMatrixKHR; +} + +bool ValidationState_t::IsCooperativeMatrixAType(uint32_t id) const { + if (!IsCooperativeMatrixKHRType(id)) return false; + const Instruction* inst = FindDef(id); + uint64_t matrixUse = 0; + if (EvalConstantValUint64(inst->word(6), &matrixUse)) { + return matrixUse == + static_cast(spv::CooperativeMatrixUse::MatrixAKHR); + } + return false; +} + +bool ValidationState_t::IsCooperativeMatrixBType(uint32_t id) const { + if (!IsCooperativeMatrixKHRType(id)) return false; + const Instruction* inst = FindDef(id); + uint64_t matrixUse = 0; + if (EvalConstantValUint64(inst->word(6), &matrixUse)) { + return matrixUse == + static_cast(spv::CooperativeMatrixUse::MatrixBKHR); + } + return false; +} +bool ValidationState_t::IsCooperativeMatrixAccType(uint32_t id) const { + if (!IsCooperativeMatrixKHRType(id)) return false; + const Instruction* inst = FindDef(id); + uint64_t matrixUse = 0; + if (EvalConstantValUint64(inst->word(6), &matrixUse)) { + return matrixUse == static_cast( + spv::CooperativeMatrixUse::MatrixAccumulatorKHR); + } + return false; +} + bool ValidationState_t::IsFloatCooperativeMatrixType(uint32_t id) const { - if (!IsCooperativeMatrixType(id)) return false; + if (!IsCooperativeMatrixNVType(id) && !IsCooperativeMatrixKHRType(id)) + return false; return IsFloatScalarType(FindDef(id)->word(2)); } bool ValidationState_t::IsIntCooperativeMatrixType(uint32_t id) const { - if (!IsCooperativeMatrixType(id)) return false; + if (!IsCooperativeMatrixNVType(id) && !IsCooperativeMatrixKHRType(id)) + return false; return IsIntScalarType(FindDef(id)->word(2)); } bool ValidationState_t::IsUnsignedIntCooperativeMatrixType(uint32_t id) const { - if (!IsCooperativeMatrixType(id)) return false; + if (!IsCooperativeMatrixNVType(id) && !IsCooperativeMatrixKHRType(id)) + return false; return IsUnsignedIntScalarType(FindDef(id)->word(2)); } @@ -1168,13 +1307,34 @@ bool ValidationState_t::IsUnsigned64BitHandle(uint32_t id) const { GetBitWidth(id) == 32)); } +bool ValidationState_t::IsCooperativeVectorNVType(uint32_t id) const { + const Instruction* inst = FindDef(id); + return inst && inst->opcode() == spv::Op::OpTypeCooperativeVectorNV; +} + +bool ValidationState_t::IsFloatCooperativeVectorNVType(uint32_t id) const { + if (!IsCooperativeVectorNVType(id)) return false; + return IsFloatScalarType(FindDef(id)->word(2)); +} + +bool ValidationState_t::IsIntCooperativeVectorNVType(uint32_t id) const { + if (!IsCooperativeVectorNVType(id)) return false; + return IsIntScalarType(FindDef(id)->word(2)); +} + +bool ValidationState_t::IsUnsignedIntCooperativeVectorNVType( + uint32_t id) const { + if (!IsCooperativeVectorNVType(id)) return false; + return IsUnsignedIntScalarType(FindDef(id)->word(2)); +} + spv_result_t ValidationState_t::CooperativeMatrixShapesMatch( - const Instruction* inst, uint32_t m1, uint32_t m2) { - const auto m1_type = FindDef(m1); + const Instruction* inst, uint32_t result_type_id, uint32_t m2, + bool is_conversion, bool swap_row_col) { + const auto m1_type = FindDef(result_type_id); const auto m2_type = FindDef(m2); - if (m1_type->opcode() != spv::Op::OpTypeCooperativeMatrixNV || - m2_type->opcode() != spv::Op::OpTypeCooperativeMatrixNV) { + if (m1_type->opcode() != m2_type->opcode()) { return diag(SPV_ERROR_INVALID_DATA, inst) << "Expected cooperative matrix types"; } @@ -1187,6 +1347,10 @@ spv_result_t ValidationState_t::CooperativeMatrixShapesMatch( uint32_t m2_rows_id = m2_type->GetOperandAs(3); uint32_t m2_cols_id = m2_type->GetOperandAs(4); + if (swap_row_col) { + std::swap(m1_rows_id, m1_cols_id); + } + bool m1_is_int32 = false, m1_is_const_int32 = false, m2_is_int32 = false, m2_is_const_int32 = false; uint32_t m1_value = 0, m2_value = 0; @@ -1210,7 +1374,7 @@ spv_result_t ValidationState_t::CooperativeMatrixShapesMatch( if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value) { return diag(SPV_ERROR_INVALID_DATA, inst) << "Expected rows of Matrix type and Result Type to be " - << "identical"; + << (swap_row_col ? "swapped with columns" : "identical"); } std::tie(m1_is_int32, m1_is_const_int32, m1_value) = @@ -1221,7 +1385,57 @@ spv_result_t ValidationState_t::CooperativeMatrixShapesMatch( if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value) { return diag(SPV_ERROR_INVALID_DATA, inst) << "Expected columns of Matrix type and Result Type to be " - << "identical"; + << (swap_row_col ? "swapped with rows" : "identical"); + } + + if (m1_type->opcode() == spv::Op::OpTypeCooperativeMatrixKHR) { + uint32_t m1_use_id = m1_type->GetOperandAs(5); + uint32_t m2_use_id = m2_type->GetOperandAs(5); + std::tie(m1_is_int32, m1_is_const_int32, m1_value) = + EvalInt32IfConst(m1_use_id); + std::tie(m2_is_int32, m2_is_const_int32, m2_value) = + EvalInt32IfConst(m2_use_id); + + if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value && + // CooperativeMatrixConversionsNV allows conversions from Acc->A/B + !(is_conversion && + HasCapability(spv::Capability::CooperativeMatrixConversionsNV) && + m2_value == + (uint32_t)spv::CooperativeMatrixUse::MatrixAccumulatorKHR)) { + return diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Use of Matrix type and Result Type to be " + << "identical"; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidationState_t::CooperativeVectorDimensionsMatch( + const Instruction* inst, uint32_t v1, uint32_t v2) { + const auto v1_type = FindDef(v1); + const auto v2_type = FindDef(v2); + + if (v1_type->opcode() != v2_type->opcode()) { + return diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected cooperative vector types"; + } + + uint32_t v1_components_id = v1_type->GetOperandAs(2); + uint32_t v2_components_id = v2_type->GetOperandAs(2); + + bool v1_is_int32 = false, v1_is_const_int32 = false, v2_is_int32 = false, + v2_is_const_int32 = false; + uint32_t v1_value = 0, v2_value = 0; + + std::tie(v1_is_int32, v1_is_const_int32, v1_value) = + EvalInt32IfConst(v1_components_id); + std::tie(v2_is_int32, v2_is_const_int32, v2_value) = + EvalInt32IfConst(v2_components_id); + + if (v1_is_const_int32 && v2_is_const_int32 && v1_value != v2_value) { + return diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected number of components to be identical"; } return SPV_SUCCESS; @@ -1232,20 +1446,23 @@ uint32_t ValidationState_t::GetOperandTypeId(const Instruction* inst, return GetTypeId(inst->GetOperandAs(operand_index)); } -bool ValidationState_t::GetConstantValUint64(uint32_t id, uint64_t* val) const { +bool ValidationState_t::EvalConstantValUint64(uint32_t id, + uint64_t* val) const { const Instruction* inst = FindDef(id); if (!inst) { assert(0 && "Instruction not found"); return false; } - if (inst->opcode() != spv::Op::OpConstant && - inst->opcode() != spv::Op::OpSpecConstant) - return false; - if (!IsIntScalarType(inst->type_id())) return false; - if (inst->words().size() == 4) { + if (inst->opcode() == spv::Op::OpConstantNull) { + *val = 0; + } else if (inst->opcode() != spv::Op::OpConstant) { + // Spec constant values cannot be evaluated so don't consider constant for + // static validation + return false; + } else if (inst->words().size() == 4) { *val = inst->word(3); } else { assert(inst->words().size() == 5); @@ -1255,6 +1472,32 @@ bool ValidationState_t::GetConstantValUint64(uint32_t id, uint64_t* val) const { return true; } +bool ValidationState_t::EvalConstantValInt64(uint32_t id, int64_t* val) const { + const Instruction* inst = FindDef(id); + if (!inst) { + assert(0 && "Instruction not found"); + return false; + } + + if (!IsIntScalarType(inst->type_id())) return false; + + if (inst->opcode() == spv::Op::OpConstantNull) { + *val = 0; + } else if (inst->opcode() != spv::Op::OpConstant) { + // Spec constant values cannot be evaluated so don't consider constant for + // static validation + return false; + } else if (inst->words().size() == 4) { + *val = int32_t(inst->word(3)); + } else { + assert(inst->words().size() == 5); + const uint32_t lo_word = inst->word(3); + const uint32_t hi_word = inst->word(4); + *val = static_cast(uint64_t(lo_word) | uint64_t(hi_word) << 32); + } + return true; +} + std::tuple ValidationState_t::EvalInt32IfConst( uint32_t id) const { const Instruction* const inst = FindDef(id); @@ -1489,6 +1732,8 @@ bool ValidationState_t::ContainsType( case spv::Op::OpTypeImage: case spv::Op::OpTypeSampledImage: case spv::Op::OpTypeCooperativeMatrixNV: + case spv::Op::OpTypeCooperativeMatrixKHR: + case spv::Op::OpTypeCooperativeVectorNV: return ContainsType(inst->GetOperandAs(1u), f, traverse_all_types); case spv::Op::OpTypePointer: @@ -1549,6 +1794,39 @@ bool ValidationState_t::ContainsRuntimeArray(uint32_t id) const { return ContainsType(id, f, /* traverse_all_types = */ false); } +bool ValidationState_t::ContainsUntypedPointer(uint32_t id) const { + const auto inst = FindDef(id); + if (!inst) return false; + if (!spvOpcodeGeneratesType(inst->opcode())) return false; + if (inst->opcode() == spv::Op::OpTypeUntypedPointerKHR) return true; + + switch (inst->opcode()) { + case spv::Op::OpTypeArray: + case spv::Op::OpTypeRuntimeArray: + case spv::Op::OpTypeVector: + case spv::Op::OpTypeMatrix: + case spv::Op::OpTypeImage: + case spv::Op::OpTypeSampledImage: + case spv::Op::OpTypeCooperativeMatrixNV: + return ContainsUntypedPointer(inst->GetOperandAs(1u)); + case spv::Op::OpTypePointer: + if (IsForwardPointer(id)) return false; + return ContainsUntypedPointer(inst->GetOperandAs(2u)); + case spv::Op::OpTypeFunction: + case spv::Op::OpTypeStruct: { + for (uint32_t i = 1; i < inst->operands().size(); ++i) { + if (ContainsUntypedPointer(inst->GetOperandAs(i))) + return true; + } + return false; + } + default: + return false; + } + + return false; +} + bool ValidationState_t::IsValidStorageClass( spv::StorageClass storage_class) const { if (spvIsVulkanEnv(context()->target_env)) { @@ -1572,6 +1850,8 @@ bool ValidationState_t::IsValidStorageClass( case spv::StorageClass::ShaderRecordBufferKHR: case spv::StorageClass::TaskPayloadWorkgroupEXT: case spv::StorageClass::HitObjectAttributeNV: + case spv::StorageClass::TileImageEXT: + case spv::StorageClass::NodePayloadAMDX: return true; default: return false; @@ -1845,6 +2125,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04330); case 4334: return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04334); + case 4336: + return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04336); case 4337: return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04337); case 4345: @@ -2029,6 +2311,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-None-04644); case 4645: return VUID_WRAP(VUID-StandaloneSpirv-None-04645); + case 4650: + return VUID_WRAP(VUID-StandaloneSpirv-OpControlBarrier-04650); case 4651: return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04651); case 4652: @@ -2047,10 +2331,6 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-OpImageTexelPointer-04658); case 4659: return VUID_WRAP(VUID-StandaloneSpirv-OpImageQuerySizeLod-04659); - case 4662: - return VUID_WRAP(VUID-StandaloneSpirv-Offset-04662); - case 4663: - return VUID_WRAP(VUID-StandaloneSpirv-Offset-04663); case 4664: return VUID_WRAP(VUID-StandaloneSpirv-OpImageGather-04664); case 4667: @@ -2077,14 +2357,20 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-RayPayloadKHR-04698); case 4699: return VUID_WRAP(VUID-StandaloneSpirv-IncomingRayPayloadKHR-04699); + case 4700: + return VUID_WRAP(VUID-StandaloneSpirv-IncomingRayPayloadKHR-04700); case 4701: return VUID_WRAP(VUID-StandaloneSpirv-HitAttributeKHR-04701); + case 4702: + return VUID_WRAP(VUID-StandaloneSpirv-HitAttributeKHR-04702); case 4703: return VUID_WRAP(VUID-StandaloneSpirv-HitAttributeKHR-04703); case 4704: return VUID_WRAP(VUID-StandaloneSpirv-CallableDataKHR-04704); case 4705: return VUID_WRAP(VUID-StandaloneSpirv-IncomingCallableDataKHR-04705); + case 4706: + return VUID_WRAP(VUID-StandaloneSpirv-IncomingCallableDataKHR-04706); case 7119: return VUID_WRAP(VUID-StandaloneSpirv-ShaderRecordBufferKHR-07119); case 4708: @@ -2143,6 +2429,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-OpTypeSampledImage-06671); case 6672: return VUID_WRAP(VUID-StandaloneSpirv-Location-06672); + case 6673: + return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-06673); case 6674: return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-06674); case 6675: @@ -2161,16 +2449,66 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06807); case 6808: return VUID_WRAP(VUID-StandaloneSpirv-PushConstant-06808); + case 6924: + return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-06924); case 6925: return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06925); - case 6997: - return VUID_WRAP(VUID-StandaloneSpirv-SubgroupVoteKHR-06997); + case 7034: + return VUID_WRAP(VUID-CullPrimitiveEXT-CullPrimitiveEXT-07034); + case 7035: + return VUID_WRAP(VUID-CullPrimitiveEXT-CullPrimitiveEXT-07035); + case 7036: + return VUID_WRAP(VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036); + case 7038: + return VUID_WRAP(VUID-CullPrimitiveEXT-CullPrimitiveEXT-07038); + case 7039: + return VUID_WRAP(VUID-Layer-Layer-07039); + case 7040: + return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-07040); + case 7041: + return VUID_WRAP(VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07041); + case 7042: + return VUID_WRAP(VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042); + case 7043: + return VUID_WRAP(VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07043); + case 7044: + return VUID_WRAP(VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07044); + case 7046: + return VUID_WRAP(VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07046); + case 7047: + return VUID_WRAP(VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07047); + case 7048: + return VUID_WRAP(VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048); + case 7049: + return VUID_WRAP(VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07049); + case 7050: + return VUID_WRAP(VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07050); + case 7052: + return VUID_WRAP(VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07052); + case 7053: + return VUID_WRAP(VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07053); + case 7054: + return VUID_WRAP(VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07054); + case 7055: + return VUID_WRAP(VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07055); + case 7056: + return VUID_WRAP(VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07056); + case 7058: + return VUID_WRAP(VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07058); + case 7059: + return VUID_WRAP(VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-07059); + case 7060: + return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-07060); case 7102: return VUID_WRAP(VUID-StandaloneSpirv-MeshEXT-07102); - case 7320: - return VUID_WRAP(VUID-StandaloneSpirv-ExecutionModel-07320); case 7290: return VUID_WRAP(VUID-StandaloneSpirv-Input-07290); + case 7320: + return VUID_WRAP(VUID-StandaloneSpirv-ExecutionModel-07320); + case 7330: + return VUID_WRAP(VUID-StandaloneSpirv-MeshEXT-07330); + case 7331: + return VUID_WRAP(VUID-StandaloneSpirv-MeshEXT-07331); case 7650: return VUID_WRAP(VUID-StandaloneSpirv-Base-07650); case 7651: @@ -2179,6 +2517,23 @@ std::string ValidationState_t::VkErrorID(uint32_t id, return VUID_WRAP(VUID-StandaloneSpirv-Base-07652); case 7703: return VUID_WRAP(VUID-StandaloneSpirv-Component-07703); + case 7951: + return VUID_WRAP(VUID-StandaloneSpirv-SubgroupVoteKHR-07951); + case 8721: + return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-08721); + case 8722: + return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-08722); + case 8973: + return VUID_WRAP(VUID-StandaloneSpirv-Pointer-08973); + case 9638: + return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-09638); + case 9658: + return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-09658); + case 9659: + return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-09659); + case 10213: + // This use to be a standalone, but maintenance8 will set allow_offset_texture_operand now + return VUID_WRAP(VUID-RuntimeSpirv-Offset-10213); default: return ""; // unknown id } diff --git a/third_party/spirv-tools/source/val/validation_state.h b/third_party/spirv-tools/source/val/validation_state.h index 4d5ac00618..e97d3d32b4 100644 --- a/third_party/spirv-tools/source/val/validation_state.h +++ b/third_party/spirv-tools/source/val/validation_state.h @@ -240,6 +240,39 @@ class ValidationState_t { entry_point_to_execution_modes_[entry_point].insert(execution_mode); } + /// Registers that the entry point declares its local size + void RegisterEntryPointLocalSize(uint32_t entry_point, + const Instruction* inst) { + entry_point_to_local_size_or_id_[entry_point] = inst; + } + + /// Registers that the entry point maximum number of primitives + /// mesh shader will ever emit + void RegisterEntryPointOutputPrimitivesEXT(uint32_t entry_point, + const Instruction* inst) { + entry_point_to_output_primitives_[entry_point] = inst; + } + + /// Returns the maximum number of primitives mesh shader can emit + uint32_t GetOutputPrimitivesEXT(uint32_t entry_point) { + auto entry = entry_point_to_output_primitives_.find(entry_point); + if (entry != entry_point_to_output_primitives_.end()) { + auto inst = entry->second; + return inst->GetOperandAs(2); + } + return 0; + } + + /// Returns whether the entry point declares its local size + bool EntryPointHasLocalSizeOrId(uint32_t entry_point) const { + return entry_point_to_local_size_or_id_.find(entry_point) != + entry_point_to_local_size_or_id_.end(); + } + /// Returns the id of the local size + const Instruction* EntryPointLocalSizeOrId(uint32_t entry_point) const { + return entry_point_to_local_size_or_id_.find(entry_point)->second; + } + /// Returns the interface descriptions of a given entry point. const std::vector& entry_point_descriptions( uint32_t entry_point) { @@ -317,7 +350,7 @@ class ValidationState_t { /// Returns true if the capability is enabled in the module. bool HasCapability(spv::Capability cap) const { - return module_capabilities_.Contains(cap); + return module_capabilities_.contains(cap); } /// Returns a reference to the set of capabilities in the module. @@ -328,7 +361,7 @@ class ValidationState_t { /// Returns true if the extension is enabled in the module. bool HasExtension(Extension ext) const { - return module_extensions_.Contains(ext); + return module_extensions_.contains(ext); } /// Returns true if any of the capabilities is enabled, or if |capabilities| @@ -485,6 +518,13 @@ class ValidationState_t { void RegisterSampledImageConsumer(uint32_t sampled_image_id, Instruction* consumer); + // Record a cons_id as a consumer of texture_id + // if texture 'texture_id' has a QCOM image processing decoration + // and consumer is a load or a sampled image instruction + void RegisterQCOMImageProcessingTextureConsumer(uint32_t texture_id, + const Instruction* consumer0, + const Instruction* consumer1); + // Record a function's storage class consumer instruction void RegisterStorageClassConsumer(spv::StorageClass storage_class, Instruction* consumer); @@ -594,14 +634,18 @@ class ValidationState_t { // Only works for types not for objects. bool IsVoidType(uint32_t id) const; bool IsFloatScalarType(uint32_t id) const; + bool IsFloatArrayType(uint32_t id) const; bool IsFloatVectorType(uint32_t id) const; + bool IsFloat16Vector2Or4Type(uint32_t id) const; bool IsFloatScalarOrVectorType(uint32_t id) const; bool IsFloatMatrixType(uint32_t id) const; bool IsIntScalarType(uint32_t id) const; + bool IsIntArrayType(uint32_t id) const; bool IsIntVectorType(uint32_t id) const; bool IsIntScalarOrVectorType(uint32_t id) const; bool IsUnsignedIntScalarType(uint32_t id) const; bool IsUnsignedIntVectorType(uint32_t id) const; + bool IsUnsignedIntScalarOrVectorType(uint32_t id) const; bool IsSignedIntScalarType(uint32_t id) const; bool IsSignedIntVectorType(uint32_t id) const; bool IsBoolScalarType(uint32_t id) const; @@ -610,10 +654,19 @@ class ValidationState_t { bool IsPointerType(uint32_t id) const; bool IsAccelerationStructureType(uint32_t id) const; bool IsCooperativeMatrixType(uint32_t id) const; + bool IsCooperativeMatrixNVType(uint32_t id) const; + bool IsCooperativeMatrixKHRType(uint32_t id) const; + bool IsCooperativeMatrixAType(uint32_t id) const; + bool IsCooperativeMatrixBType(uint32_t id) const; + bool IsCooperativeMatrixAccType(uint32_t id) const; bool IsFloatCooperativeMatrixType(uint32_t id) const; bool IsIntCooperativeMatrixType(uint32_t id) const; bool IsUnsignedIntCooperativeMatrixType(uint32_t id) const; bool IsUnsigned64BitHandle(uint32_t id) const; + bool IsCooperativeVectorNVType(uint32_t id) const; + bool IsFloatCooperativeVectorNVType(uint32_t id) const; + bool IsIntCooperativeVectorNVType(uint32_t id) const; + bool IsUnsignedIntCooperativeVectorNVType(uint32_t id) const; // Returns true if |id| is a type id that contains |type| (or integer or // floating point type) of |width| bits. @@ -634,9 +687,8 @@ class ValidationState_t { const std::function& f, bool traverse_all_types = true) const; - // Gets value from OpConstant and OpSpecConstant as uint64. - // Returns false on failure (no instruction, wrong instruction, not int). - bool GetConstantValUint64(uint32_t id, uint64_t* val) const; + // Returns true if |id| is type id that contains an untyped pointer. + bool ContainsUntypedPointer(uint32_t id) const; // Returns type_id if id has type or zero otherwise. uint32_t GetTypeId(uint32_t id) const; @@ -712,6 +764,14 @@ class ValidationState_t { pointer_to_storage_image_.insert(type_id); } + // Tries to evaluate a any scalar integer OpConstant as uint64. + // OpConstantNull is defined as zero for scalar int (will return true) + // OpSpecConstant* return false since their values cannot be relied upon + // during validation. + bool EvalConstantValUint64(uint32_t id, uint64_t* val) const; + // Same as EvalConstantValUint64 but returns a signed int + bool EvalConstantValInt64(uint32_t id, int64_t* val) const; + // Tries to evaluate a 32-bit signed or unsigned scalar integer constant. // Returns tuple . // OpSpecConstant* return |is_const_int32| as false since their values cannot @@ -737,11 +797,17 @@ class ValidationState_t { return SpvDecorationString(uint32_t(decoration)); } - // Returns whether type m1 and type m2 are cooperative matrices with - // the same "shape" (matching scope, rows, cols). If any are specialization - // constants, we assume they can match because we can't prove they don't. + // Returns whether type result_type_id and type m2 are cooperative matrices + // with the same "shape" (matching scope, rows, cols). If any are + // specialization constants, we assume they can match because we can't prove + // they don't. spv_result_t CooperativeMatrixShapesMatch(const Instruction* inst, - uint32_t m1, uint32_t m2); + uint32_t result_type_id, + uint32_t m2, bool is_conversion, + bool swap_row_col = false); + + spv_result_t CooperativeVectorDimensionsMatch(const Instruction* inst, + uint32_t v1, uint32_t v2); // Returns true if |lhs| and |rhs| logically match and, if the decorations of // |rhs| are a subset of |lhs|. @@ -786,6 +852,13 @@ class ValidationState_t { current_layout_section_ = section; } + // Check if instruction 'id' is a consumer of a texture decorated + // with a QCOM image processing decoration + bool IsQCOMImageProcessingTextureConsumer(uint32_t id) { + return qcom_image_processing_consumers_.find(id) != + qcom_image_processing_consumers_.end(); + } + private: ValidationState_t(const ValidationState_t&); @@ -820,6 +893,10 @@ class ValidationState_t { std::unordered_map> sampled_image_consumers_; + /// Stores load instructions that load textures used + // in QCOM image processing functions + std::unordered_set qcom_image_processing_consumers_; + /// A map of operand IDs and their names defined by the OpName instruction std::unordered_map operand_names_; @@ -916,6 +993,14 @@ class ValidationState_t { std::unordered_map> entry_point_to_execution_modes_; + // Mapping entry point -> local size execution mode instruction + std::unordered_map + entry_point_to_local_size_or_id_; + + // Mapping entry point -> OutputPrimitivesEXT execution mode instruction + std::unordered_map + entry_point_to_output_primitives_; + /// Mapping function -> array of entry points inside this /// module which can (indirectly) call the function. std::unordered_map> function_to_entry_points_; diff --git a/third_party/spirv-tools/source/wasm/build.sh b/third_party/spirv-tools/source/wasm/build.sh index f02ae525c3..f4663565e9 100755 --- a/third_party/spirv-tools/source/wasm/build.sh +++ b/third_party/spirv-tools/source/wasm/build.sh @@ -16,6 +16,11 @@ set -e +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory /app + NUM_CORES=$(nproc) echo "Detected $NUM_CORES cores for building" @@ -40,7 +45,7 @@ build() { emcc \ --bind \ -I../../include \ - -std=c++11 \ + -std=c++17 \ ../../source/wasm/spirv-tools.cpp \ source/libSPIRV-Tools.a \ -o spirv-tools.js \ @@ -65,8 +70,8 @@ build() { } if [ ! -d external/spirv-headers ] ; then - echo "Fetching SPIRV-headers" - git clone https://github.com/KhronosGroup/SPIRV-Headers.git external/spirv-headers + echo "Fetching deps" + utils/git-sync-deps fi echo Building ${BASH_REMATCH[1]} diff --git a/third_party/spirv-tools/docker-compose.yml b/third_party/spirv-tools/source/wasm/docker-compose.yml similarity index 84% rename from third_party/spirv-tools/docker-compose.yml rename to third_party/spirv-tools/source/wasm/docker-compose.yml index fb6d114ffb..2340fdb02c 100644 --- a/third_party/spirv-tools/docker-compose.yml +++ b/third_party/spirv-tools/source/wasm/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: build: - image: emscripten/emsdk:2.0.2 + image: emscripten/emsdk:3.1.28 environment: GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER:-} working_dir: /app diff --git a/third_party/spirv-tools/test/CMakeLists.txt b/third_party/spirv-tools/test/CMakeLists.txt index 4ca8ef8fb9..119e9c9f25 100644 --- a/third_party/spirv-tools/test/CMakeLists.txt +++ b/third_party/spirv-tools/test/CMakeLists.txt @@ -12,26 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +if (${SPIRV_SKIP_TESTS}) + return() +endif() + +if (TARGET gmock_main) + message(STATUS "Found Google Mock, building tests.") +else() + message(STATUS "Did not find googletest, tests will not be built. " + "To enable tests place googletest in '/external/googletest'.") +endif() + # Add a SPIR-V Tools unit test. Signature: # add_spvtools_unittest( # TARGET target_name # SRCS src_file.h src_file.cpp # LIBS lib1 lib2 # ) - -if (NOT "${SPIRV_SKIP_TESTS}") - if (TARGET gmock_main) - message(STATUS "Found Google Mock, building tests.") - else() - message(STATUS "Did not find googletest, tests will not be built. " - "To enable tests place googletest in '/external/googletest'.") - endif() -endif() - function(add_spvtools_unittest) if (NOT "${SPIRV_SKIP_TESTS}" AND TARGET gmock_main) set(one_value_args TARGET PCH_FILE) - set(multi_value_args SRCS LIBS ENVIRONMENT) + set(multi_value_args SRCS LIBS ENVIRONMENT DEFINES) cmake_parse_arguments( ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN}) set(target test_${ARG_TARGET}) @@ -40,6 +41,7 @@ function(add_spvtools_unittest) spvtools_pch(SRC_COPY ${ARG_PCH_FILE}) endif() add_executable(${target} ${SRC_COPY}) + target_compile_definitions(${target} PUBLIC ${ARG_DEFINES}) spvtools_default_compile_options(${target}) if(${COMPILER_IS_LIKE_GNU}) target_compile_options(${target} PRIVATE -Wno-undef) @@ -86,6 +88,7 @@ endfunction() set(TEST_SOURCES test_fixture.h unit_spirv.h + ${spirv-tools_SOURCE_DIR}/tools/io.h assembly_context_test.cpp assembly_format_test.cpp @@ -108,9 +111,9 @@ set(TEST_SOURCES fix_word_test.cpp generator_magic_number_test.cpp hex_float_test.cpp + hex_to_text_test.cpp immediate_int_test.cpp libspirv_macros_test.cpp - log_test.cpp named_id_test.cpp name_mapper_test.cpp opcode_make_test.cpp @@ -150,8 +153,10 @@ set(TEST_SOURCES text_to_binary.subgroup_dispatch_test.cpp text_to_binary.reserved_sampling_test.cpp text_word_get_test.cpp + to_string_test.cpp unit_spirv.cpp + ${spirv-tools_SOURCE_DIR}/tools/io.cpp ) spvtools_pch(TEST_SOURCES pch_test) diff --git a/third_party/spirv-tools/test/binary_parse_test.cpp b/third_party/spirv-tools/test/binary_parse_test.cpp index 4c699c1759..1b8d72ec4a 100644 --- a/third_party/spirv-tools/test/binary_parse_test.cpp +++ b/third_party/spirv-tools/test/binary_parse_test.cpp @@ -214,6 +214,40 @@ class BinaryParseTest : public spvtest::TextToBinaryTestBase<::testing::Test> { MockParseClient client_; }; +class CxxBinaryParseTest + : public spvtest::TextToBinaryTestBase<::testing::Test> { + protected: + CxxBinaryParseTest() { + header_parser_ = [this](const spv_endianness_t endianness, + const spv_parsed_header_t& header) { + return this->client_.Header(endianness, header.magic, header.version, + header.generator, header.bound, + header.reserved); + }; + + instruction_parser_ = [this](const spv_parsed_instruction_t& instruction) { + return this->client_.Instruction(ParsedInstruction(instruction)); + }; + } + + ~CxxBinaryParseTest() override { spvDiagnosticDestroy(diagnostic_); } + + void Parse(const SpirvVector& words, bool expected_result, + bool flip_words = false, + spv_target_env env = SPV_ENV_UNIVERSAL_1_0) { + SpirvVector flipped_words(words); + MaybeFlipWords(flip_words, flipped_words.begin(), flipped_words.end()); + spvtools::SpirvTools tools(env); + EXPECT_EQ(expected_result, tools.Parse(flipped_words, header_parser_, + instruction_parser_, &diagnostic_)); + } + + spv_diagnostic diagnostic_ = nullptr; + MockParseClient client_; + HeaderParser header_parser_; + InstructionParser instruction_parser_; +}; + // Adds an EXPECT_CALL to client_->Header() with appropriate parameters, // including bound. Returns the EXPECT_CALL result. #define EXPECT_HEADER(bound) \ @@ -235,6 +269,16 @@ TEST_F(BinaryParseTest, EmptyModuleHasValidHeaderAndNoInstructionCallbacks) { } } +TEST_F(CxxBinaryParseTest, EmptyModuleHasValidHeaderAndNoInstructionCallbacks) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully(""); + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + Parse(words, true, endian_swap); + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, NullDiagnosticsIsOkForGoodParse) { const auto words = CompileSuccessfully(""); EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); @@ -245,6 +289,15 @@ TEST_F(BinaryParseTest, NullDiagnosticsIsOkForGoodParse) { words.size(), invoke_header, invoke_instruction, nullptr)); } +TEST_F(CxxBinaryParseTest, NullDiagnosticsIsOkForGoodParse) { + const auto words = CompileSuccessfully(""); + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_0); + EXPECT_EQ(true, + tools.Parse(words, header_parser_, instruction_parser_, nullptr)); +} + TEST_F(BinaryParseTest, NullDiagnosticsIsOkForBadParse) { auto words = CompileSuccessfully(""); words.push_back(0xffffffff); // Certainly invalid instruction header. @@ -256,6 +309,16 @@ TEST_F(BinaryParseTest, NullDiagnosticsIsOkForBadParse) { words.size(), invoke_header, invoke_instruction, nullptr)); } +TEST_F(CxxBinaryParseTest, NullDiagnosticsIsOkForBadParse) { + auto words = CompileSuccessfully(""); + words.push_back(0xffffffff); // Certainly invalid instruction header. + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_0); + EXPECT_EQ(false, + tools.Parse(words, header_parser_, instruction_parser_, nullptr)); +} + // Make sure that we don't blow up when both the consumer and the diagnostic are // null. TEST_F(BinaryParseTest, NullConsumerNullDiagnosticsForBadParse) { @@ -272,6 +335,18 @@ TEST_F(BinaryParseTest, NullConsumerNullDiagnosticsForBadParse) { invoke_header, invoke_instruction, nullptr)); } +TEST_F(CxxBinaryParseTest, NullConsumerNullDiagnosticsForBadParse) { + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + tools.SetMessageConsumer(nullptr); + + auto words = CompileSuccessfully(""); + words.push_back(0xffffffff); // Certainly invalid instruction header. + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + EXPECT_EQ(false, + tools.Parse(words, header_parser_, instruction_parser_, nullptr)); +} + TEST_F(BinaryParseTest, SpecifyConsumerNullDiagnosticsForGoodParse) { const auto words = CompileSuccessfully(""); @@ -289,6 +364,21 @@ TEST_F(BinaryParseTest, SpecifyConsumerNullDiagnosticsForGoodParse) { EXPECT_EQ(0, invocation); } +TEST_F(CxxBinaryParseTest, SpecifyConsumerNullDiagnosticsForGoodParse) { + const auto words = CompileSuccessfully(""); + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + int invocation = 0; + tools.SetMessageConsumer([&invocation](spv_message_level_t, const char*, + const spv_position_t&, + const char*) { ++invocation; }); + + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + EXPECT_EQ(true, + tools.Parse(words, header_parser_, instruction_parser_, nullptr)); + EXPECT_EQ(0, invocation); +} + TEST_F(BinaryParseTest, SpecifyConsumerNullDiagnosticsForBadParse) { auto words = CompileSuccessfully(""); @@ -315,6 +405,30 @@ TEST_F(BinaryParseTest, SpecifyConsumerNullDiagnosticsForBadParse) { EXPECT_EQ(1, invocation); } +TEST_F(CxxBinaryParseTest, SpecifyConsumerNullDiagnosticsForBadParse) { + auto words = CompileSuccessfully(""); + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + int invocation = 0; + tools.SetMessageConsumer( + [&invocation](spv_message_level_t level, const char* source, + const spv_position_t& position, const char* message) { + ++invocation; + EXPECT_EQ(SPV_MSG_ERROR, level); + EXPECT_STREQ("input", source); + EXPECT_EQ(0u, position.line); + EXPECT_EQ(0u, position.column); + EXPECT_EQ(1u, position.index); + EXPECT_STREQ("Invalid opcode: 65535", message); + }); + + words.push_back(0xffffffff); // Certainly invalid instruction header. + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + EXPECT_EQ(false, + tools.Parse(words, header_parser_, instruction_parser_, nullptr)); + EXPECT_EQ(1, invocation); +} + TEST_F(BinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForGoodParse) { const auto words = CompileSuccessfully(""); @@ -333,6 +447,22 @@ TEST_F(BinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForGoodParse) { EXPECT_EQ(nullptr, diagnostic_); } +TEST_F(CxxBinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForGoodParse) { + const auto words = CompileSuccessfully(""); + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + int invocation = 0; + tools.SetMessageConsumer([&invocation](spv_message_level_t, const char*, + const spv_position_t&, + const char*) { ++invocation; }); + + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + EXPECT_EQ(true, tools.Parse(words, header_parser_, instruction_parser_, + &diagnostic_)); + EXPECT_EQ(0, invocation); + EXPECT_EQ(nullptr, diagnostic_); +} + TEST_F(BinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForBadParse) { auto words = CompileSuccessfully(""); @@ -352,6 +482,23 @@ TEST_F(BinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForBadParse) { EXPECT_STREQ("Invalid opcode: 65535", diagnostic_->error); } +TEST_F(CxxBinaryParseTest, SpecifyConsumerSpecifyDiagnosticsForBadParse) { + auto words = CompileSuccessfully(""); + spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1); + int invocation = 0; + tools.SetMessageConsumer([&invocation](spv_message_level_t, const char*, + const spv_position_t&, + const char*) { ++invocation; }); + + words.push_back(0xffffffff); // Certainly invalid instruction header. + EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback. + EXPECT_EQ(false, tools.Parse(words, header_parser_, instruction_parser_, + &diagnostic_)); + EXPECT_EQ(0, invocation); + EXPECT_STREQ("Invalid opcode: 65535", diagnostic_->error); +} + TEST_F(BinaryParseTest, ModuleWithSingleInstructionHasValidHeaderAndInstructionCallback) { for (bool endian_swap : kSwapEndians) { @@ -365,6 +512,19 @@ TEST_F(BinaryParseTest, } } +TEST_F(CxxBinaryParseTest, + ModuleWithSingleInstructionHasValidHeaderAndInstructionCallback) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully("%1 = OpTypeVoid"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(2).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedVoidTypeInstruction(1))) + .WillOnce(Return(SPV_SUCCESS)); + Parse(words, true, endian_swap); + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, NullHeaderCallbackIsIgnored) { const auto words = CompileSuccessfully("%1 = OpTypeVoid"); EXPECT_CALL(client_, Header(_, _, _, _, _, _)) @@ -408,6 +568,22 @@ TEST_F(BinaryParseTest, TwoScalarTypesGenerateTwoInstructionCallbacks) { } } +TEST_F(CxxBinaryParseTest, TwoScalarTypesGenerateTwoInstructionCallbacks) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully( + "%1 = OpTypeVoid " + "%2 = OpTypeInt 32 1"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(3).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedVoidTypeInstruction(1))) + .WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedInt32TypeInstruction(2))) + .WillOnce(Return(SPV_SUCCESS)); + Parse(words, true, endian_swap); + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, EarlyReturnWithZeroPassingCallbacks) { for (bool endian_swap : kSwapEndians) { const auto words = CompileSuccessfully( @@ -423,6 +599,21 @@ TEST_F(BinaryParseTest, EarlyReturnWithZeroPassingCallbacks) { } } +TEST_F(CxxBinaryParseTest, EarlyReturnWithZeroPassingCallbacks) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully( + "%1 = OpTypeVoid " + "%2 = OpTypeInt 32 1"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(3).WillOnce(Return(SPV_ERROR_INVALID_BINARY)); + // Early exit means no calls to Instruction(). + EXPECT_CALL(client_, Instruction(_)).Times(0); + Parse(words, false, endian_swap); + // On error, the binary parser doesn't generate its own diagnostics. + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, EarlyReturnWithZeroPassingCallbacksAndSpecifiedResultCode) { for (bool endian_swap : kSwapEndians) { @@ -440,6 +631,23 @@ TEST_F(BinaryParseTest, } } +TEST_F(CxxBinaryParseTest, + EarlyReturnWithZeroPassingCallbacksAndSpecifiedResultCode) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully( + "%1 = OpTypeVoid " + "%2 = OpTypeInt 32 1"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(3).WillOnce(Return(SPV_REQUESTED_TERMINATION)); + // Early exit means no calls to Instruction(). + EXPECT_CALL(client_, Instruction(_)).Times(0); + Parse(words, false, endian_swap); + // On early termination, the binary parser doesn't generate its own + // diagnostics. + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, EarlyReturnWithOnePassingCallback) { for (bool endian_swap : kSwapEndians) { const auto words = CompileSuccessfully( @@ -457,6 +665,23 @@ TEST_F(BinaryParseTest, EarlyReturnWithOnePassingCallback) { } } +TEST_F(CxxBinaryParseTest, EarlyReturnWithOnePassingCallback) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully( + "%1 = OpTypeVoid " + "%2 = OpTypeInt 32 1 " + "%3 = OpTypeFloat 32"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(4).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedVoidTypeInstruction(1))) + .WillOnce(Return(SPV_REQUESTED_TERMINATION)); + Parse(words, false, endian_swap); + // On early termination, the binary parser doesn't generate its own + // diagnostics. + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, EarlyReturnWithTwoPassingCallbacks) { for (bool endian_swap : kSwapEndians) { const auto words = CompileSuccessfully( @@ -476,6 +701,25 @@ TEST_F(BinaryParseTest, EarlyReturnWithTwoPassingCallbacks) { } } +TEST_F(CxxBinaryParseTest, EarlyReturnWithTwoPassingCallbacks) { + for (bool endian_swap : kSwapEndians) { + const auto words = CompileSuccessfully( + "%1 = OpTypeVoid " + "%2 = OpTypeInt 32 1 " + "%3 = OpTypeFloat 32"); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(4).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedVoidTypeInstruction(1))) + .WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(MakeParsedInt32TypeInstruction(2))) + .WillOnce(Return(SPV_REQUESTED_TERMINATION)); + Parse(words, false, endian_swap); + // On early termination, the binary parser doesn't generate its own + // diagnostics. + EXPECT_EQ(nullptr, diagnostic_); + } +} + TEST_F(BinaryParseTest, InstructionWithStringOperand) { for (bool endian_swap : kSwapEndians) { const std::string str = @@ -501,6 +745,31 @@ TEST_F(BinaryParseTest, InstructionWithStringOperand) { } } +TEST_F(CxxBinaryParseTest, InstructionWithStringOperand) { + for (bool endian_swap : kSwapEndians) { + const std::string str = + "the future is already here, it's just not evenly distributed"; + const auto str_words = MakeVector(str); + const auto instruction = MakeInstruction(spv::Op::OpName, {99}, str_words); + const auto words = Concatenate({ExpectedHeaderForBound(100), instruction}); + InSequence calls_expected_in_specific_order; + EXPECT_HEADER(100).WillOnce(Return(SPV_SUCCESS)); + const auto operands = std::vector{ + MakeSimpleOperand(1, SPV_OPERAND_TYPE_ID), + MakeLiteralStringOperand(2, static_cast(str_words.size()))}; + EXPECT_CALL( + client_, + Instruction(ParsedInstruction(spv_parsed_instruction_t{ + instruction.data(), static_cast(instruction.size()), + uint16_t(spv::Op::OpName), SPV_EXT_INST_TYPE_NONE, 0 /*type id*/, + 0 /* No result id for OpName*/, operands.data(), + static_cast(operands.size())}))) + .WillOnce(Return(SPV_SUCCESS)); + Parse(words, true, endian_swap); + EXPECT_EQ(nullptr, diagnostic_); + } +} + // Checks for non-zero values for the result_id and ext_inst_type members // spv_parsed_instruction_t. TEST_F(BinaryParseTest, ExtendedInstruction) { @@ -534,6 +803,37 @@ TEST_F(BinaryParseTest, ExtendedInstruction) { EXPECT_EQ(nullptr, diagnostic_); } +TEST_F(CxxBinaryParseTest, ExtendedInstruction) { + const auto words = CompileSuccessfully( + "%extcl = OpExtInstImport \"OpenCL.std\" " + "%result = OpExtInst %float %extcl sqrt %x"); + EXPECT_HEADER(5).WillOnce(Return(SPV_SUCCESS)); + EXPECT_CALL(client_, Instruction(_)).WillOnce(Return(SPV_SUCCESS)); + // We're only interested in the second call to Instruction(): + const auto operands = std::vector{ + MakeSimpleOperand(1, SPV_OPERAND_TYPE_TYPE_ID), + MakeSimpleOperand(2, SPV_OPERAND_TYPE_RESULT_ID), + MakeSimpleOperand(3, + SPV_OPERAND_TYPE_ID), // Extended instruction set Id + MakeSimpleOperand(4, SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER), + MakeSimpleOperand(5, SPV_OPERAND_TYPE_ID), // Id of the argument + }; + const auto instruction = MakeInstruction( + spv::Op::OpExtInst, + {2, 3, 1, static_cast(OpenCLLIB::Entrypoints::Sqrt), 4}); + EXPECT_CALL(client_, + Instruction(ParsedInstruction(spv_parsed_instruction_t{ + instruction.data(), static_cast(instruction.size()), + uint16_t(spv::Op::OpExtInst), SPV_EXT_INST_TYPE_OPENCL_STD, + 2 /*type id*/, 3 /*result id*/, operands.data(), + static_cast(operands.size())}))) + .WillOnce(Return(SPV_SUCCESS)); + // Since we are actually checking the output, don't test the + // endian-swapped version. + Parse(words, true, false); + EXPECT_EQ(nullptr, diagnostic_); +} + // A binary parser diagnostic test case where we provide the words array // pointer and word count explicitly. struct WordsAndCountDiagnosticCase { @@ -854,7 +1154,10 @@ INSTANTIATE_TEST_SUITE_P( {"%2 = OpSpecConstantOp %1 !1000 %2", "Invalid OpSpecConstantOp opcode: 1000"}, {"OpCapability !9999", "Invalid capability operand: 9999"}, - {"OpSource !9999 100", "Invalid source language operand: 9999"}, + {"OpSource !9999 100", + "Invalid source language operand: 9999, if you are creating a new " + "source language please use value 0 (Unknown) and when ready, add " + "your source language to SPIRV-Headers"}, {"OpEntryPoint !9999", "Invalid execution model operand: 9999"}, {"OpMemoryModel !9999", "Invalid addressing model operand: 9999"}, {"OpMemoryModel Logical !9999", "Invalid memory model operand: 9999"}, diff --git a/third_party/spirv-tools/test/binary_to_text.literal_test.cpp b/third_party/spirv-tools/test/binary_to_text.literal_test.cpp index 5956984b13..58e1f187a1 100644 --- a/third_party/spirv-tools/test/binary_to_text.literal_test.cpp +++ b/third_party/spirv-tools/test/binary_to_text.literal_test.cpp @@ -33,6 +33,7 @@ TEST_P(RoundTripLiteralsTest, Sample) { for (bool endian_swap : kSwapEndians) { EXPECT_THAT( EncodeAndDecodeSuccessfully(GetParam(), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, SPV_ENV_UNIVERSAL_1_0, endian_swap), Eq(GetParam())); } @@ -68,6 +69,7 @@ TEST_P(RoundTripSpecialCaseLiteralsTest, Sample) { for (bool endian_swap : kSwapEndians) { EXPECT_THAT(EncodeAndDecodeSuccessfully(std::get<0>(GetParam()), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, SPV_ENV_UNIVERSAL_1_0, endian_swap), Eq(std::get<1>(GetParam()))); } diff --git a/third_party/spirv-tools/test/binary_to_text_test.cpp b/third_party/spirv-tools/test/binary_to_text_test.cpp index 85d5bd1d2d..dde73e238b 100644 --- a/third_party/spirv-tools/test/binary_to_text_test.cpp +++ b/third_party/spirv-tools/test/binary_to_text_test.cpp @@ -247,9 +247,9 @@ using RoundTripInstructionsTest = spvtest::TextToBinaryTestBase< ::testing::TestWithParam>>; TEST_P(RoundTripInstructionsTest, Sample) { - EXPECT_THAT(EncodeAndDecodeSuccessfully(std::get<1>(GetParam()), - SPV_BINARY_TO_TEXT_OPTION_NONE, - std::get<0>(GetParam())), + EXPECT_THAT(EncodeAndDecodeSuccessfully( + std::get<1>(GetParam()), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, std::get<0>(GetParam())), Eq(std::get<1>(GetParam()))); } @@ -402,6 +402,59 @@ INSTANTIATE_TEST_SUITE_P( "OpDecorateId %1 MaxByteOffsetId %2\n", }))); +INSTANTIATE_TEST_SUITE_P( + CacheControlsINTEL, RoundTripInstructionsTest, + Combine( + ::testing::Values(SPV_ENV_UNIVERSAL_1_0), + ::testing::ValuesIn(std::vector{ + "OpDecorate %1 CacheControlLoadINTEL 0 UncachedINTEL\n", + "OpDecorate %1 CacheControlLoadINTEL 1 CachedINTEL\n", + "OpDecorate %1 CacheControlLoadINTEL 2 StreamingINTEL\n", + "OpDecorate %1 CacheControlLoadINTEL 3 InvalidateAfterReadINTEL\n", + "OpDecorate %1 CacheControlLoadINTEL 4 ConstCachedINTEL\n", + "OpDecorate %1 CacheControlStoreINTEL 0 UncachedINTEL\n", + "OpDecorate %1 CacheControlStoreINTEL 1 WriteThroughINTEL\n", + "OpDecorate %1 CacheControlStoreINTEL 2 WriteBackINTEL\n", + "OpDecorate %1 CacheControlStoreINTEL 3 StreamingINTEL\n", + }))); + +INSTANTIATE_TEST_SUITE_P( + HostAccessINTEL, RoundTripInstructionsTest, + Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0), + ::testing::ValuesIn(std::vector{ + "OpDecorate %1 HostAccessINTEL NoneINTEL \"none\"\n", + "OpDecorate %1 HostAccessINTEL ReadINTEL \"read\"\n", + "OpDecorate %1 HostAccessINTEL WriteINTEL \"write\"\n", + "OpDecorate %1 HostAccessINTEL ReadWriteINTEL \"readwrite\"\n", + }))); + +// clang-format off +INSTANTIATE_TEST_SUITE_P( + MatrixMultiplyAccumulateOperands, RoundTripInstructionsTest, + Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0), + ::testing::ValuesIn(std::vector{ + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 None\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixASignedComponentsINTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBSignedComponentsINTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixCBFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixResultBFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixAPackedInt8INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBPackedInt8INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixAPackedInt4INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBPackedInt4INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixATF32INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBTF32INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixCBFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixAPackedFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBPackedFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixAPackedBFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 MatrixBPackedBFloat16INTEL\n", + "%2 = OpSubgroupMatrixMultiplyAccumulateINTEL %1 %3 %4 %5 %6 " + "MatrixASignedComponentsINTEL|MatrixBSignedComponentsINTEL|MatrixAPackedInt8INTEL|MatrixBPackedInt8INTEL\n", + }))); +// clang-format on + using MaskSorting = TextToBinaryTest; TEST_F(MaskSorting, MasksAreSortedFromLSBToMSB) { @@ -464,6 +517,1462 @@ OpStore %2 %3 Aligned|Volatile 4 ; bogus, but not indented expected); } +TEST_F(IndentTest, NestedIf) { + const std::string input = R"( +OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Fragment %100 "main" +OpExecutionMode %100 OriginUpperLeft +OpName %var "var" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%bool = OpTypeBool +%5 = OpConstantNull %bool +%true = OpConstantTrue %bool +%false = OpConstantFalse %bool +%uint = OpTypeInt 32 0 +%int = OpTypeInt 32 1 +%uint_42 = OpConstant %uint 42 +%int_42 = OpConstant %int 42 +%13 = OpTypeFunction %uint +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%uint_2 = OpConstant %uint 2 +%uint_3 = OpConstant %uint 3 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%uint_6 = OpConstant %uint 6 +%uint_7 = OpConstant %uint 7 +%uint_8 = OpConstant %uint 8 +%uint_10 = OpConstant %uint 10 +%uint_20 = OpConstant %uint 20 +%uint_30 = OpConstant %uint 30 +%uint_40 = OpConstant %uint 40 +%uint_50 = OpConstant %uint 50 +%uint_90 = OpConstant %uint 90 +%uint_99 = OpConstant %uint 99 +%_ptr_Private_uint = OpTypePointer Private %uint +%var = OpVariable %_ptr_Private_uint Private +%uint_999 = OpConstant %uint 999 +%100 = OpFunction %void None %3 +%10 = OpLabel +OpStore %var %uint_0 +OpSelectionMerge %99 None +OpBranchConditional %5 %30 %40 +%30 = OpLabel +OpStore %var %uint_1 +OpBranch %99 +%40 = OpLabel +OpStore %var %uint_2 +OpBranch %99 +%99 = OpLabel +OpStore %var %uint_999 +OpReturn +OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %20 = OpConstant %8 6 + %21 = OpConstant %8 7 + %22 = OpConstant %8 8 + %23 = OpConstant %8 10 + %24 = OpConstant %8 20 + %25 = OpConstant %8 30 + %26 = OpConstant %8 40 + %27 = OpConstant %8 50 + %28 = OpConstant %8 90 + %29 = OpConstant %8 99 + %31 = OpTypePointer Private %8 + %1 = OpVariable %31 Private + %32 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + + %10 = OpLabel + OpStore %1 %14 + OpSelectionMerge %99 None + OpBranchConditional %5 %30 %40 + + %30 = OpLabel + OpStore %1 %15 + OpBranch %99 + + %40 = OpLabel + OpStore %1 %16 + OpBranch %99 + + %99 = OpLabel + OpStore %1 %32 + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, NestedWhile) { + const std::string input = R"( +OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Fragment %100 "main" +OpExecutionMode %100 OriginUpperLeft +OpName %var "var" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%bool = OpTypeBool +%5 = OpConstantNull %bool +%true = OpConstantTrue %bool +%false = OpConstantFalse %bool +%uint = OpTypeInt 32 0 +%int = OpTypeInt 32 1 +%uint_42 = OpConstant %uint 42 +%int_42 = OpConstant %int 42 +%13 = OpTypeFunction %uint +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%uint_2 = OpConstant %uint 2 +%uint_3 = OpConstant %uint 3 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%uint_6 = OpConstant %uint 6 +%uint_7 = OpConstant %uint 7 +%uint_8 = OpConstant %uint 8 +%uint_10 = OpConstant %uint 10 +%uint_20 = OpConstant %uint 20 +%uint_30 = OpConstant %uint 30 +%uint_40 = OpConstant %uint 40 +%uint_50 = OpConstant %uint 50 +%uint_90 = OpConstant %uint 90 +%uint_99 = OpConstant %uint 99 +%_ptr_Private_uint = OpTypePointer Private %uint +%var = OpVariable %_ptr_Private_uint Private +%uint_999 = OpConstant %uint 999 +%100 = OpFunction %void None %3 +%10 = OpLabel +OpStore %var %uint_0 +OpBranch %20 +%20 = OpLabel +OpStore %var %uint_1 +OpLoopMerge %99 %20 None +OpBranch %80 +%80 = OpLabel +OpStore %var %uint_2 +OpBranchConditional %5 %99 %20 +%99 = OpLabel +OpStore %var %uint_3 +OpReturn +OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %30 = OpConstant %8 99 + %31 = OpTypePointer Private %8 + %1 = OpVariable %31 Private + %32 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + + %10 = OpLabel + OpStore %1 %14 + OpBranch %20 + + %20 = OpLabel + OpStore %1 %15 + OpLoopMerge %99 %20 None + OpBranch %80 + + %80 = OpLabel + OpStore %1 %16 + OpBranchConditional %5 %99 %20 + + %99 = OpLabel + OpStore %1 %17 + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, NestedLoopInLoop) { + const std::string input = R"( +OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Fragment %100 "main" +OpExecutionMode %100 OriginUpperLeft +OpName %var "var" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%bool = OpTypeBool +%5 = OpConstantNull %bool +%true = OpConstantTrue %bool +%false = OpConstantFalse %bool +%uint = OpTypeInt 32 0 +%int = OpTypeInt 32 1 +%uint_42 = OpConstant %uint 42 +%int_42 = OpConstant %int 42 +%13 = OpTypeFunction %uint +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%uint_2 = OpConstant %uint 2 +%uint_3 = OpConstant %uint 3 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%uint_6 = OpConstant %uint 6 +%uint_7 = OpConstant %uint 7 +%uint_8 = OpConstant %uint 8 +%uint_10 = OpConstant %uint 10 +%uint_20 = OpConstant %uint 20 +%uint_30 = OpConstant %uint 30 +%uint_40 = OpConstant %uint 40 +%uint_50 = OpConstant %uint 50 +%uint_90 = OpConstant %uint 90 +%uint_99 = OpConstant %uint 99 +%_ptr_Private_uint = OpTypePointer Private %uint +%var = OpVariable %_ptr_Private_uint Private +%uint_999 = OpConstant %uint 999 +%100 = OpFunction %void None %3 +%10 = OpLabel +OpBranch %20 +%20 = OpLabel +OpLoopMerge %99 %50 None +OpBranchConditional %5 %30 %99 +%30 = OpLabel +OpLoopMerge %49 %40 None +OpBranchConditional %true %35 %49 +%35 = OpLabel +OpBranch %37 +%37 = OpLabel +OpBranch %40 +%40 = OpLabel +OpBranch %30 +%49 = OpLabel +OpBranch %50 +%50 = OpLabel +OpBranch %20 +%99 = OpLabel +OpReturn +OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + + %10 = OpLabel + OpBranch %20 + + %20 = OpLabel + OpLoopMerge %99 %50 None + OpBranchConditional %5 %30 %99 + + %30 = OpLabel + OpLoopMerge %49 %40 None + OpBranchConditional %6 %35 %49 + + %35 = OpLabel + OpBranch %37 + + %37 = OpLabel + OpBranch %40 + + %40 = OpLabel + OpBranch %30 + + %49 = OpLabel + OpBranch %50 + + %50 = OpLabel + OpBranch %20 + + %99 = OpLabel + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, NestedSwitch) { + const std::string input = R"( +OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Fragment %100 "main" +OpExecutionMode %100 OriginUpperLeft +OpName %var "var" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%bool = OpTypeBool +%5 = OpConstantNull %bool +%true = OpConstantTrue %bool +%false = OpConstantFalse %bool +%uint = OpTypeInt 32 0 +%int = OpTypeInt 32 1 +%uint_42 = OpConstant %uint 42 +%int_42 = OpConstant %int 42 +%13 = OpTypeFunction %uint +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%uint_2 = OpConstant %uint 2 +%uint_3 = OpConstant %uint 3 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%uint_6 = OpConstant %uint 6 +%uint_7 = OpConstant %uint 7 +%uint_8 = OpConstant %uint 8 +%uint_10 = OpConstant %uint 10 +%uint_20 = OpConstant %uint 20 +%uint_30 = OpConstant %uint 30 +%uint_40 = OpConstant %uint 40 +%uint_50 = OpConstant %uint 50 +%uint_90 = OpConstant %uint 90 +%uint_99 = OpConstant %uint 99 +%_ptr_Private_uint = OpTypePointer Private %uint +%var = OpVariable %_ptr_Private_uint Private +%uint_999 = OpConstant %uint 999 +%100 = OpFunction %void None %3 +%10 = OpLabel +OpSelectionMerge %99 None +OpSwitch %uint_42 %80 20 %20 30 %30 +%20 = OpLabel +OpBranch %80 +%80 = OpLabel +OpBranch %30 +%30 = OpLabel +OpBranch %99 +%99 = OpLabel +OpReturn +OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + + %10 = OpLabel + OpSelectionMerge %99 None + OpSwitch %11 %80 20 %20 30 %30 + + %20 = OpLabel + OpBranch %80 + + %80 = OpLabel + OpBranch %30 + + %30 = OpLabel + OpBranch %99 + + %99 = OpLabel + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, ReorderedIf) { + const std::string input = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + %10 = OpLabel + OpSelectionMerge %99 None + OpBranchConditional %5 %20 %50 + %99 = OpLabel + OpReturn + %20 = OpLabel + OpSelectionMerge %49 None + OpBranchConditional %5 %30 %40 + %49 = OpLabel + OpBranch %99 + %40 = OpLabel + OpBranch %49 + %30 = OpLabel + OpBranch %49 + %50 = OpLabel + OpSelectionMerge %79 None + OpBranchConditional %5 %60 %70 + %79 = OpLabel + OpBranch %99 + %60 = OpLabel + OpBranch %79 + %70 = OpLabel + OpBranch %79 + OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + %10 = OpLabel + OpSelectionMerge %99 None + OpBranchConditional %5 %20 %50 + %20 = OpLabel + OpSelectionMerge %49 None + OpBranchConditional %5 %30 %40 + %30 = OpLabel + OpBranch %49 + %40 = OpLabel + OpBranch %49 + %49 = OpLabel + OpBranch %99 + %50 = OpLabel + OpSelectionMerge %79 None + OpBranchConditional %5 %60 %70 + %60 = OpLabel + OpBranch %79 + %70 = OpLabel + OpBranch %79 + %79 = OpLabel + OpBranch %99 + %99 = OpLabel + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, ReorderedFallThroughInSwitch) { + const std::string input = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + %10 = OpLabel + OpSelectionMerge %99 None + OpSwitch %11 %50 20 %20 50 %50 + %99 = OpLabel + OpReturn + %20 = OpLabel + OpSelectionMerge %49 None + OpBranchConditional %5 %30 %40 + %49 = OpLabel + OpBranchConditional %5 %99 %50 + %30 = OpLabel + OpBranch %49 + %40 = OpLabel + OpBranch %49 + %50 = OpLabel + OpSelectionMerge %79 None + OpBranchConditional %5 %60 %70 + %79 = OpLabel + OpBranch %99 + %60 = OpLabel + OpBranch %79 + %70 = OpLabel + OpBranch %79 + OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %100 "main" + OpExecutionMode %100 OriginUpperLeft + OpName %1 "var" + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %4 = OpTypeBool + %5 = OpConstantNull %4 + %6 = OpConstantTrue %4 + %7 = OpConstantFalse %4 + %8 = OpTypeInt 32 0 + %9 = OpTypeInt 32 1 + %11 = OpConstant %8 42 + %12 = OpConstant %9 42 + %13 = OpTypeFunction %8 + %14 = OpConstant %8 0 + %15 = OpConstant %8 1 + %16 = OpConstant %8 2 + %17 = OpConstant %8 3 + %18 = OpConstant %8 4 + %19 = OpConstant %8 5 + %21 = OpConstant %8 6 + %22 = OpConstant %8 7 + %23 = OpConstant %8 8 + %24 = OpConstant %8 10 + %25 = OpConstant %8 20 + %26 = OpConstant %8 30 + %27 = OpConstant %8 40 + %28 = OpConstant %8 50 + %29 = OpConstant %8 90 + %31 = OpConstant %8 99 + %32 = OpTypePointer Private %8 + %1 = OpVariable %32 Private + %33 = OpConstant %8 999 + %100 = OpFunction %2 None %3 + %10 = OpLabel + OpSelectionMerge %99 None + OpSwitch %11 %50 20 %20 50 %50 + %20 = OpLabel + OpSelectionMerge %49 None + OpBranchConditional %5 %30 %40 + %30 = OpLabel + OpBranch %49 + %40 = OpLabel + OpBranch %49 + %49 = OpLabel + OpBranchConditional %5 %99 %50 + %50 = OpLabel + OpSelectionMerge %79 None + OpBranchConditional %5 %60 %70 + %60 = OpLabel + OpBranch %79 + %70 = OpLabel + OpBranch %79 + %79 = OpLabel + OpBranch %99 + %99 = OpLabel + OpReturn + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(IndentTest, ReorderedNested) { + const std::string input = R"( +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %4 "main" %204 +OpExecutionMode %4 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "main" +OpName %16 "ff(vf2;f1;" +OpName %14 "g" +OpName %15 "f" +OpName %19 "vg" +OpName %20 "Block140" +OpMemberName %20 0 "a" +OpMemberName %20 1 "b" +OpName %22 "b140" +OpName %35 "sv" +OpName %39 "s" +OpName %46 "f" +OpName %51 "g" +OpName %57 "x" +OpName %69 "param" +OpName %75 "i" +OpName %80 "vc" +OpName %88 "j" +OpName %95 "size" +OpName %174 "v" +OpName %187 "i" +OpName %204 "o_color" +OpMemberDecorate %20 0 Offset 0 +OpMemberDecorate %20 1 Offset 16 +OpDecorate %20 Block +OpDecorate %22 DescriptorSet 1 +OpDecorate %22 Binding 0 +OpDecorate %39 DescriptorSet 0 +OpDecorate %39 Binding 1 +OpDecorate %95 SpecId 20 +OpDecorate %204 Location 2 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 2 +%8 = OpTypePointer Function %7 +%9 = OpTypeVector %6 4 +%10 = OpTypeInt 32 0 +%11 = OpConstant %10 2 +%12 = OpTypeArray %9 %11 +%13 = OpTypeFunction %12 %8 %6 +%18 = OpTypePointer Private %9 +%19 = OpVariable %18 Private +%20 = OpTypeStruct %6 %9 +%21 = OpTypePointer Uniform %20 +%22 = OpVariable %21 Uniform +%23 = OpTypeInt 32 1 +%24 = OpConstant %23 1 +%25 = OpTypePointer Uniform %9 +%28 = OpConstant %6 0 +%29 = OpConstantComposite %9 %28 %28 %28 %28 +%34 = OpTypePointer Function %9 +%36 = OpTypeImage %6 2D 0 0 0 1 Unknown +%37 = OpTypeSampledImage %36 +%38 = OpTypePointer UniformConstant %37 +%39 = OpVariable %38 UniformConstant +%41 = OpConstantComposite %7 %28 %28 +%45 = OpTypePointer Function %6 +%47 = OpConstant %23 0 +%48 = OpTypePointer Uniform %6 +%53 = OpConstant %6 1 +%55 = OpTypeBool +%56 = OpTypePointer Function %55 +%58 = OpConstant %10 0 +%59 = OpTypePointer Private %6 +%74 = OpTypePointer Function %23 +%87 = OpTypePointer Function %10 +%95 = OpSpecConstant %10 2 +%100 = OpConstant %10 1 +%109 = OpConstantComposite %9 %53 %53 %53 %53 +%127 = OpConstant %23 10 +%139 = OpConstant %6 2 +%143 = OpConstant %6 3 +%158 = OpConstant %6 4 +%177 = OpConstant %6 0.5 +%195 = OpConstant %23 100 +%202 = OpTypeVector %10 4 +%203 = OpTypePointer Output %202 +%204 = OpVariable %203 Output +%4 = OpFunction %2 None %3 +%5 = OpLabel +%35 = OpVariable %34 Function +%46 = OpVariable %45 Function +%51 = OpVariable %45 Function +%57 = OpVariable %56 Function +%69 = OpVariable %8 Function +%75 = OpVariable %74 Function +%80 = OpVariable %34 Function +%88 = OpVariable %87 Function +%174 = OpVariable %45 Function +%187 = OpVariable %74 Function +%26 = OpAccessChain %25 %22 %24 +%27 = OpLoad %9 %26 +OpStore %19 %27 +%40 = OpLoad %37 %39 +%42 = OpImageSampleImplicitLod %9 %40 %41 +%43 = OpLoad %9 %19 +%44 = OpFAdd %9 %42 %43 +OpStore %35 %44 +%49 = OpAccessChain %48 %22 %47 +%50 = OpLoad %6 %49 +OpStore %46 %50 +%52 = OpLoad %6 %46 +%54 = OpFAdd %6 %52 %53 +OpStore %51 %54 +%60 = OpAccessChain %59 %19 %58 +%61 = OpLoad %6 %60 +%62 = OpFOrdGreaterThan %55 %61 %28 +OpSelectionMerge %64 None +OpBranchConditional %62 %63 %64 +%64 = OpLabel +%73 = OpPhi %55 %62 %5 %72 %63 +OpStore %57 %73 +OpStore %75 %47 +OpBranch %76 +%197 = OpLabel +OpBranch %190 +%63 = OpLabel +%65 = OpLoad %6 %46 +%66 = OpLoad %6 %51 +%67 = OpCompositeConstruct %7 %65 %66 +%68 = OpLoad %6 %51 +OpStore %69 %67 +%70 = OpFunctionCall %12 %16 %69 %68 +%71 = OpCompositeExtract %6 %70 0 0 +%72 = OpFOrdGreaterThan %55 %71 %28 +OpBranch %64 +%77 = OpLabel +%81 = OpLoad %9 %19 +OpStore %80 %81 +%82 = OpAccessChain %45 %80 %58 +%83 = OpLoad %6 %82 +%84 = OpFOrdGreaterThan %55 %83 %28 +OpSelectionMerge %86 None +OpBranchConditional %84 %85 %113 +%85 = OpLabel +OpStore %88 %58 +OpBranch %89 +%89 = OpLabel +OpLoopMerge %91 %92 None +OpBranch %93 +%93 = OpLabel +%94 = OpLoad %10 %88 +%96 = OpULessThan %55 %94 %95 +OpBranchConditional %96 %90 %91 +%105 = OpLabel +OpBranch %92 +%198 = OpLabel +OpBranch %191 +%163 = OpLabel +OpBranch %136 +%104 = OpLabel +OpBranch %91 +%76 = OpLabel +OpLoopMerge %78 %79 None +OpBranch %77 +%92 = OpLabel +%107 = OpLoad %10 %88 +%108 = OpIAdd %10 %107 %24 +OpStore %88 %108 +OpBranch %89 +%91 = OpLabel +%110 = OpLoad %9 %80 +%111 = OpFAdd %9 %110 %109 +OpStore %80 %111 +OpBranch %79 +%113 = OpLabel +%114 = OpLoad %9 %80 +%115 = OpFSub %9 %114 %109 +OpStore %80 %115 +OpBranch %86 +%132 = OpLabel +%137 = OpLoad %6 %51 +%138 = OpFAdd %6 %137 %53 +OpStore %51 %138 +OpBranch %133 +%86 = OpLabel +%116 = OpAccessChain %45 %80 %100 +%117 = OpLoad %6 %116 +%118 = OpFOrdGreaterThan %55 %117 %28 +OpSelectionMerge %120 None +OpBranchConditional %118 %119 %120 +%119 = OpLabel +OpBranch %78 +%120 = OpLabel +%122 = OpAccessChain %45 %80 %11 +%123 = OpLoad %6 %122 +%124 = OpFAdd %6 %123 %53 +%125 = OpAccessChain %45 %80 %11 +OpStore %125 %124 +OpBranch %79 +%79 = OpLabel +%126 = OpLoad %23 %75 +%128 = OpSLessThan %55 %126 %127 +OpBranchConditional %128 %76 %78 +%78 = OpLabel +%129 = OpAccessChain %48 %22 %47 +%130 = OpLoad %6 %129 +%131 = OpConvertFToS %23 %130 +OpSelectionMerge %136 None +OpSwitch %131 %135 0 %132 1 %132 2 %132 3 %133 4 %134 +%90 = OpLabel +%97 = OpLoad %9 %19 +%98 = OpLoad %9 %80 +%99 = OpFAdd %9 %98 %97 +OpStore %80 %99 +%101 = OpAccessChain %45 %80 %100 +%102 = OpLoad %6 %101 +%103 = OpFOrdLessThan %55 %102 %28 +OpSelectionMerge %105 None +OpBranchConditional %103 %104 %105 +%161 = OpLabel +OpLoopMerge %163 %164 None +OpBranch %165 +%165 = OpLabel +%166 = OpLoad %6 %51 +%167 = OpFOrdLessThan %55 %166 %139 +OpBranchConditional %167 %162 %163 +%164 = OpLabel +OpBranch %161 +%162 = OpLabel +%168 = OpLoad %6 %46 +%169 = OpFOrdLessThan %55 %168 %53 +OpSelectionMerge %171 None +OpBranchConditional %169 %170 %171 +%135 = OpLabel +%159 = OpLoad %6 %51 +%160 = OpFAdd %6 %159 %158 +OpStore %51 %160 +OpBranch %161 +%133 = OpLabel +%140 = OpLoad %6 %51 +%141 = OpFAdd %6 %140 %139 +OpStore %51 %141 +OpBranch %136 +%134 = OpLabel +%144 = OpLoad %6 %51 +%145 = OpFAdd %6 %144 %143 +OpStore %51 %145 +OpBranch %146 +%146 = OpLabel +OpLoopMerge %148 %149 None +OpBranch %150 +%150 = OpLabel +%151 = OpLoad %6 %51 +%152 = OpFOrdLessThan %55 %151 %139 +OpBranchConditional %152 %147 %148 +%147 = OpLabel +%153 = OpLoad %6 %46 +%154 = OpFOrdLessThan %55 %153 %53 +OpSelectionMerge %156 None +OpBranchConditional %154 %155 %156 +%155 = OpLabel +OpBranch %148 +%156 = OpLabel +OpBranch %149 +%149 = OpLabel +OpBranch %146 +%148 = OpLabel +OpBranch %135 +%136 = OpLabel +OpStore %174 %53 +%175 = OpAccessChain %45 %35 %58 +%176 = OpLoad %6 %175 +%178 = OpFOrdLessThanEqual %55 %176 %177 +OpSelectionMerge %180 None +OpBranchConditional %178 %179 %181 +%179 = OpLabel +OpStore %174 %28 +OpBranch %180 +%185 = OpLabel +OpStore %174 %139 +OpBranch %186 +%181 = OpLabel +%182 = OpAccessChain %45 %35 %58 +%183 = OpLoad %6 %182 +%184 = OpFOrdGreaterThanEqual %55 %183 %177 +OpSelectionMerge %186 None +OpBranchConditional %184 %185 %186 +%170 = OpLabel +OpBranch %163 +%171 = OpLabel +OpBranch %164 +%186 = OpLabel +OpBranch %180 +%188 = OpLabel +OpLoopMerge %190 %191 None +OpBranch %189 +%189 = OpLabel +%192 = OpLoad %9 %19 +%193 = OpFAdd %9 %192 %109 +OpStore %19 %193 +%194 = OpLoad %23 %187 +%196 = OpSGreaterThan %55 %194 %195 +OpSelectionMerge %198 None +OpBranchConditional %196 %197 %198 +%180 = OpLabel +OpStore %187 %47 +OpBranch %188 +%191 = OpLabel +%200 = OpLoad %23 %187 +%201 = OpIAdd %23 %200 %24 +OpStore %187 %201 +OpBranch %188 +%190 = OpLabel +OpReturn +OpFunctionEnd +%16 = OpFunction %12 None %13 +%14 = OpFunctionParameter %8 +%15 = OpFunctionParameter %6 +%17 = OpLabel +%30 = OpCompositeConstruct %9 %15 %15 %15 %15 +%31 = OpCompositeConstruct %12 %29 %30 +OpReturnValue %31 +OpFunctionEnd +)"; + const std::string expected = + R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %204 + OpExecutionMode %4 OriginUpperLeft + OpSource GLSL 450 + OpName %4 "main" + OpName %16 "ff(vf2;f1;" + OpName %14 "g" + OpName %15 "f" + OpName %19 "vg" + OpName %20 "Block140" + OpMemberName %20 0 "a" + OpMemberName %20 1 "b" + OpName %22 "b140" + OpName %35 "sv" + OpName %39 "s" + OpName %46 "f" + OpName %51 "g" + OpName %57 "x" + OpName %69 "param" + OpName %75 "i" + OpName %80 "vc" + OpName %88 "j" + OpName %95 "size" + OpName %174 "v" + OpName %187 "i" + OpName %204 "o_color" + OpMemberDecorate %20 0 Offset 0 + OpMemberDecorate %20 1 Offset 16 + OpDecorate %20 Block + OpDecorate %22 DescriptorSet 1 + OpDecorate %22 Binding 0 + OpDecorate %39 DescriptorSet 0 + OpDecorate %39 Binding 1 + OpDecorate %95 SpecId 20 + OpDecorate %204 Location 2 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypeVector %6 2 + %8 = OpTypePointer Function %7 + %9 = OpTypeVector %6 4 + %10 = OpTypeInt 32 0 + %11 = OpConstant %10 2 + %12 = OpTypeArray %9 %11 + %13 = OpTypeFunction %12 %8 %6 + %18 = OpTypePointer Private %9 + %19 = OpVariable %18 Private + %20 = OpTypeStruct %6 %9 + %21 = OpTypePointer Uniform %20 + %22 = OpVariable %21 Uniform + %23 = OpTypeInt 32 1 + %24 = OpConstant %23 1 + %25 = OpTypePointer Uniform %9 + %28 = OpConstant %6 0 + %29 = OpConstantComposite %9 %28 %28 %28 %28 + %34 = OpTypePointer Function %9 + %36 = OpTypeImage %6 2D 0 0 0 1 Unknown + %37 = OpTypeSampledImage %36 + %38 = OpTypePointer UniformConstant %37 + %39 = OpVariable %38 UniformConstant + %41 = OpConstantComposite %7 %28 %28 + %45 = OpTypePointer Function %6 + %47 = OpConstant %23 0 + %48 = OpTypePointer Uniform %6 + %53 = OpConstant %6 1 + %55 = OpTypeBool + %56 = OpTypePointer Function %55 + %58 = OpConstant %10 0 + %59 = OpTypePointer Private %6 + %74 = OpTypePointer Function %23 + %87 = OpTypePointer Function %10 + %95 = OpSpecConstant %10 2 + %100 = OpConstant %10 1 + %109 = OpConstantComposite %9 %53 %53 %53 %53 + %127 = OpConstant %23 10 + %139 = OpConstant %6 2 + %143 = OpConstant %6 3 + %158 = OpConstant %6 4 + %177 = OpConstant %6 0.5 + %195 = OpConstant %23 100 + %202 = OpTypeVector %10 4 + %203 = OpTypePointer Output %202 + %204 = OpVariable %203 Output + %4 = OpFunction %2 None %3 + + %5 = OpLabel + %35 = OpVariable %34 Function + %46 = OpVariable %45 Function + %51 = OpVariable %45 Function + %57 = OpVariable %56 Function + %69 = OpVariable %8 Function + %75 = OpVariable %74 Function + %80 = OpVariable %34 Function + %88 = OpVariable %87 Function + %174 = OpVariable %45 Function + %187 = OpVariable %74 Function + %26 = OpAccessChain %25 %22 %24 + %27 = OpLoad %9 %26 + OpStore %19 %27 + %40 = OpLoad %37 %39 + %42 = OpImageSampleImplicitLod %9 %40 %41 + %43 = OpLoad %9 %19 + %44 = OpFAdd %9 %42 %43 + OpStore %35 %44 + %49 = OpAccessChain %48 %22 %47 + %50 = OpLoad %6 %49 + OpStore %46 %50 + %52 = OpLoad %6 %46 + %54 = OpFAdd %6 %52 %53 + OpStore %51 %54 + %60 = OpAccessChain %59 %19 %58 + %61 = OpLoad %6 %60 + %62 = OpFOrdGreaterThan %55 %61 %28 + OpSelectionMerge %64 None + OpBranchConditional %62 %63 %64 + + %63 = OpLabel + %65 = OpLoad %6 %46 + %66 = OpLoad %6 %51 + %67 = OpCompositeConstruct %7 %65 %66 + %68 = OpLoad %6 %51 + OpStore %69 %67 + %70 = OpFunctionCall %12 %16 %69 %68 + %71 = OpCompositeExtract %6 %70 0 0 + %72 = OpFOrdGreaterThan %55 %71 %28 + OpBranch %64 + + %64 = OpLabel + %73 = OpPhi %55 %62 %5 %72 %63 + OpStore %57 %73 + OpStore %75 %47 + OpBranch %76 + + %76 = OpLabel + OpLoopMerge %78 %79 None + OpBranch %77 + + %77 = OpLabel + %81 = OpLoad %9 %19 + OpStore %80 %81 + %82 = OpAccessChain %45 %80 %58 + %83 = OpLoad %6 %82 + %84 = OpFOrdGreaterThan %55 %83 %28 + OpSelectionMerge %86 None + OpBranchConditional %84 %85 %113 + + %85 = OpLabel + OpStore %88 %58 + OpBranch %89 + + %89 = OpLabel + OpLoopMerge %91 %92 None + OpBranch %93 + + %93 = OpLabel + %94 = OpLoad %10 %88 + %96 = OpULessThan %55 %94 %95 + OpBranchConditional %96 %90 %91 + + %90 = OpLabel + %97 = OpLoad %9 %19 + %98 = OpLoad %9 %80 + %99 = OpFAdd %9 %98 %97 + OpStore %80 %99 + %101 = OpAccessChain %45 %80 %100 + %102 = OpLoad %6 %101 + %103 = OpFOrdLessThan %55 %102 %28 + OpSelectionMerge %105 None + OpBranchConditional %103 %104 %105 + + %104 = OpLabel + OpBranch %91 + + %105 = OpLabel + OpBranch %92 + + %92 = OpLabel + %107 = OpLoad %10 %88 + %108 = OpIAdd %10 %107 %24 + OpStore %88 %108 + OpBranch %89 + + %91 = OpLabel + %110 = OpLoad %9 %80 + %111 = OpFAdd %9 %110 %109 + OpStore %80 %111 + OpBranch %79 + + %113 = OpLabel + %114 = OpLoad %9 %80 + %115 = OpFSub %9 %114 %109 + OpStore %80 %115 + OpBranch %86 + + %86 = OpLabel + %116 = OpAccessChain %45 %80 %100 + %117 = OpLoad %6 %116 + %118 = OpFOrdGreaterThan %55 %117 %28 + OpSelectionMerge %120 None + OpBranchConditional %118 %119 %120 + + %119 = OpLabel + OpBranch %78 + + %120 = OpLabel + %122 = OpAccessChain %45 %80 %11 + %123 = OpLoad %6 %122 + %124 = OpFAdd %6 %123 %53 + %125 = OpAccessChain %45 %80 %11 + OpStore %125 %124 + OpBranch %79 + + %79 = OpLabel + %126 = OpLoad %23 %75 + %128 = OpSLessThan %55 %126 %127 + OpBranchConditional %128 %76 %78 + + %78 = OpLabel + %129 = OpAccessChain %48 %22 %47 + %130 = OpLoad %6 %129 + %131 = OpConvertFToS %23 %130 + OpSelectionMerge %136 None + OpSwitch %131 %135 0 %132 1 %132 2 %132 3 %133 4 %134 + + %132 = OpLabel + %137 = OpLoad %6 %51 + %138 = OpFAdd %6 %137 %53 + OpStore %51 %138 + OpBranch %133 + + %133 = OpLabel + %140 = OpLoad %6 %51 + %141 = OpFAdd %6 %140 %139 + OpStore %51 %141 + OpBranch %136 + + %134 = OpLabel + %144 = OpLoad %6 %51 + %145 = OpFAdd %6 %144 %143 + OpStore %51 %145 + OpBranch %146 + + %146 = OpLabel + OpLoopMerge %148 %149 None + OpBranch %150 + + %150 = OpLabel + %151 = OpLoad %6 %51 + %152 = OpFOrdLessThan %55 %151 %139 + OpBranchConditional %152 %147 %148 + + %147 = OpLabel + %153 = OpLoad %6 %46 + %154 = OpFOrdLessThan %55 %153 %53 + OpSelectionMerge %156 None + OpBranchConditional %154 %155 %156 + + %155 = OpLabel + OpBranch %148 + + %156 = OpLabel + OpBranch %149 + + %149 = OpLabel + OpBranch %146 + + %148 = OpLabel + OpBranch %135 + + %135 = OpLabel + %159 = OpLoad %6 %51 + %160 = OpFAdd %6 %159 %158 + OpStore %51 %160 + OpBranch %161 + + %161 = OpLabel + OpLoopMerge %163 %164 None + OpBranch %165 + + %165 = OpLabel + %166 = OpLoad %6 %51 + %167 = OpFOrdLessThan %55 %166 %139 + OpBranchConditional %167 %162 %163 + + %162 = OpLabel + %168 = OpLoad %6 %46 + %169 = OpFOrdLessThan %55 %168 %53 + OpSelectionMerge %171 None + OpBranchConditional %169 %170 %171 + + %170 = OpLabel + OpBranch %163 + + %171 = OpLabel + OpBranch %164 + + %164 = OpLabel + OpBranch %161 + + %163 = OpLabel + OpBranch %136 + + %136 = OpLabel + OpStore %174 %53 + %175 = OpAccessChain %45 %35 %58 + %176 = OpLoad %6 %175 + %178 = OpFOrdLessThanEqual %55 %176 %177 + OpSelectionMerge %180 None + OpBranchConditional %178 %179 %181 + + %179 = OpLabel + OpStore %174 %28 + OpBranch %180 + + %181 = OpLabel + %182 = OpAccessChain %45 %35 %58 + %183 = OpLoad %6 %182 + %184 = OpFOrdGreaterThanEqual %55 %183 %177 + OpSelectionMerge %186 None + OpBranchConditional %184 %185 %186 + + %185 = OpLabel + OpStore %174 %139 + OpBranch %186 + + %186 = OpLabel + OpBranch %180 + + %180 = OpLabel + OpStore %187 %47 + OpBranch %188 + + %188 = OpLabel + OpLoopMerge %190 %191 None + OpBranch %189 + + %189 = OpLabel + %192 = OpLoad %9 %19 + %193 = OpFAdd %9 %192 %109 + OpStore %19 %193 + %194 = OpLoad %23 %187 + %196 = OpSGreaterThan %55 %194 %195 + OpSelectionMerge %198 None + OpBranchConditional %196 %197 %198 + + %197 = OpLabel + OpBranch %190 + + %198 = OpLabel + OpBranch %191 + + %191 = OpLabel + %200 = OpLoad %23 %187 + %201 = OpIAdd %23 %200 %24 + OpStore %187 %201 + OpBranch %188 + + %190 = OpLabel + OpReturn + OpFunctionEnd + %16 = OpFunction %12 None %13 + %14 = OpFunctionParameter %8 + %15 = OpFunctionParameter %6 + + %17 = OpLabel + %30 = OpCompositeConstruct %9 %15 %15 %15 %15 + %31 = OpCompositeConstruct %12 %29 %30 + OpReturnValue %31 + OpFunctionEnd +)"; + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT | + SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + using FriendlyNameDisassemblyTest = spvtest::TextToBinaryTest; TEST_F(FriendlyNameDisassemblyTest, Sample) { @@ -494,16 +2003,628 @@ OpMemoryModel Logical GLSL450 %2 = OpTypeVoid )"; const std::string expected = - R"(OpCapability Shader ; 0x00000014 -OpMemoryModel Logical GLSL450 ; 0x0000001c -%1 = OpTypeInt 32 0 ; 0x00000028 -%2 = OpTypeVoid ; 0x00000038 + R"(OpCapability Shader ; 0x00000014 +OpMemoryModel Logical GLSL450 ; 0x0000001c +%1 = OpTypeInt 32 0 ; 0x00000028 +%2 = OpTypeVoid ; 0x00000038 )"; EXPECT_THAT(EncodeAndDecodeSuccessfully( input, SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET), expected); } +TEST_F(TextToBinaryTest, Comments) { + const std::string input = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %63 "main" %4 %22 +OpExecutionMode %63 OriginUpperLeft +OpSource GLSL 450 +OpName %4 "_ue" +OpName %8 "_uf" +OpName %11 "_ug" +OpName %12 "_uA" +OpMemberName %12 0 "_ux" +OpName %14 "_uc" +OpName %15 "_uB" +OpMemberName %15 0 "_ux" +OpName %20 "_ud" +OpName %22 "_ucol" +OpName %26 "ANGLEDepthRangeParams" +OpMemberName %26 0 "near" +OpMemberName %26 1 "far" +OpMemberName %26 2 "diff" +OpMemberName %26 3 "reserved" +OpName %27 "ANGLEUniformBlock" +OpMemberName %27 0 "viewport" +OpMemberName %27 1 "clipDistancesEnabled" +OpMemberName %27 2 "xfbActiveUnpaused" +OpMemberName %27 3 "xfbVerticesPerInstance" +OpMemberName %27 4 "numSamples" +OpMemberName %27 5 "xfbBufferOffsets" +OpMemberName %27 6 "acbBufferOffsets" +OpMemberName %27 7 "depthRange" +OpName %29 "ANGLEUniforms" +OpName %33 "_uc" +OpName %32 "_uh" +OpName %49 "_ux" +OpName %50 "_uy" +OpName %48 "_ui" +OpName %63 "main" +OpName %65 "param" +OpName %68 "param" +OpName %73 "param" +OpDecorate %4 Location 0 +OpDecorate %8 RelaxedPrecision +OpDecorate %8 DescriptorSet 0 +OpDecorate %8 Binding 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %12 0 RelaxedPrecision +OpDecorate %12 Block +OpDecorate %14 DescriptorSet 0 +OpDecorate %14 Binding 2 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 RelaxedPrecision +OpDecorate %15 BufferBlock +OpDecorate %20 DescriptorSet 0 +OpDecorate %20 Binding 3 +OpDecorate %22 RelaxedPrecision +OpDecorate %22 Location 0 +OpMemberDecorate %26 0 Offset 0 +OpMemberDecorate %26 1 Offset 4 +OpMemberDecorate %26 2 Offset 8 +OpMemberDecorate %26 3 Offset 12 +OpMemberDecorate %27 0 Offset 0 +OpMemberDecorate %27 1 Offset 16 +OpMemberDecorate %27 2 Offset 20 +OpMemberDecorate %27 3 Offset 24 +OpMemberDecorate %27 4 Offset 28 +OpMemberDecorate %27 5 Offset 32 +OpMemberDecorate %27 6 Offset 48 +OpMemberDecorate %27 7 Offset 64 +OpMemberDecorate %27 2 RelaxedPrecision +OpMemberDecorate %27 4 RelaxedPrecision +OpDecorate %27 Block +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 4 +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision +OpDecorate %36 RelaxedPrecision +OpDecorate %37 RelaxedPrecision +OpDecorate %38 RelaxedPrecision +OpDecorate %39 RelaxedPrecision +OpDecorate %41 RelaxedPrecision +OpDecorate %42 RelaxedPrecision +OpDecorate %43 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision +OpDecorate %50 RelaxedPrecision +OpDecorate %52 RelaxedPrecision +OpDecorate %53 RelaxedPrecision +OpDecorate %54 RelaxedPrecision +OpDecorate %55 RelaxedPrecision +OpDecorate %56 RelaxedPrecision +OpDecorate %57 RelaxedPrecision +OpDecorate %58 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %60 RelaxedPrecision +OpDecorate %67 RelaxedPrecision +OpDecorate %68 RelaxedPrecision +OpDecorate %72 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %75 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %77 RelaxedPrecision +OpDecorate %80 RelaxedPrecision +OpDecorate %81 RelaxedPrecision +%1 = OpTypeFloat 32 +%2 = OpTypeVector %1 4 +%5 = OpTypeImage %1 2D 0 0 0 1 Unknown +%6 = OpTypeSampledImage %5 +%9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 +%12 = OpTypeStruct %2 +%15 = OpTypeStruct %2 +%16 = OpTypeInt 32 0 +%17 = OpConstant %16 2 +%18 = OpTypeArray %15 %17 +%23 = OpTypeInt 32 1 +%24 = OpTypeVector %23 4 +%25 = OpTypeVector %16 4 +%26 = OpTypeStruct %1 %1 %1 %1 +%27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 +%35 = OpTypeVector %1 2 +%40 = OpTypeVector %23 2 +%61 = OpTypeVoid +%69 = OpConstant %16 0 +%78 = OpConstant %16 1 +%3 = OpTypePointer Input %2 +%7 = OpTypePointer UniformConstant %6 +%10 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer Uniform %12 +%19 = OpTypePointer Uniform %18 +%21 = OpTypePointer Output %2 +%28 = OpTypePointer Uniform %27 +%30 = OpTypePointer Function %2 +%70 = OpTypePointer Uniform %2 +%31 = OpTypeFunction %2 %30 +%47 = OpTypeFunction %2 %30 %30 +%62 = OpTypeFunction %61 +%4 = OpVariable %3 Input +%8 = OpVariable %7 UniformConstant +%11 = OpVariable %10 UniformConstant +%14 = OpVariable %13 Uniform +%20 = OpVariable %19 Uniform +%22 = OpVariable %21 Output +%29 = OpVariable %28 Uniform +%32 = OpFunction %2 None %31 +%33 = OpFunctionParameter %30 +%34 = OpLabel +%36 = OpLoad %6 %8 +%37 = OpLoad %2 %33 +%38 = OpVectorShuffle %35 %37 %37 0 1 +%39 = OpImageSampleImplicitLod %2 %36 %38 +%41 = OpLoad %2 %33 +%42 = OpVectorShuffle %35 %41 %41 2 3 +%43 = OpConvertFToS %40 %42 +%44 = OpLoad %9 %11 +%45 = OpImageRead %2 %44 %43 +%46 = OpFAdd %2 %39 %45 +OpReturnValue %46 +OpFunctionEnd +%48 = OpFunction %2 None %47 +%49 = OpFunctionParameter %30 +%50 = OpFunctionParameter %30 +%51 = OpLabel +%52 = OpLoad %2 %49 +%53 = OpVectorShuffle %35 %52 %52 0 1 +%54 = OpLoad %2 %50 +%55 = OpVectorShuffle %35 %54 %54 2 3 +%56 = OpCompositeExtract %1 %53 0 +%57 = OpCompositeExtract %1 %53 1 +%58 = OpCompositeExtract %1 %55 0 +%59 = OpCompositeExtract %1 %55 1 +%60 = OpCompositeConstruct %2 %56 %57 %58 %59 +OpReturnValue %60 +OpFunctionEnd +%63 = OpFunction %61 None %62 +%64 = OpLabel +%65 = OpVariable %30 Function +%68 = OpVariable %30 Function +%73 = OpVariable %30 Function +%66 = OpLoad %2 %4 +OpStore %65 %66 +%67 = OpFunctionCall %2 %32 %65 +%71 = OpAccessChain %70 %14 %69 +%72 = OpLoad %2 %71 +OpStore %68 %72 +%74 = OpAccessChain %70 %20 %69 %69 +%75 = OpLoad %2 %74 +OpStore %73 %75 +%76 = OpFunctionCall %2 %48 %68 %73 +%77 = OpFAdd %2 %67 %76 +%79 = OpAccessChain %70 %20 %78 %69 +%80 = OpLoad %2 %79 +%81 = OpFAdd %2 %77 %80 +OpStore %22 %81 +OpReturn +OpFunctionEnd +)"; + const std::string expected = R"( OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %63 "main" %4 %22 + OpExecutionMode %63 OriginUpperLeft + + ; Debug Information + OpSource GLSL 450 + OpName %4 "_ue" ; id %4 + OpName %8 "_uf" ; id %8 + OpName %11 "_ug" ; id %11 + OpName %12 "_uA" ; id %12 + OpMemberName %12 0 "_ux" + OpName %14 "_uc" ; id %14 + OpName %15 "_uB" ; id %15 + OpMemberName %15 0 "_ux" + OpName %20 "_ud" ; id %20 + OpName %22 "_ucol" ; id %22 + OpName %26 "ANGLEDepthRangeParams" ; id %26 + OpMemberName %26 0 "near" + OpMemberName %26 1 "far" + OpMemberName %26 2 "diff" + OpMemberName %26 3 "reserved" + OpName %27 "ANGLEUniformBlock" ; id %27 + OpMemberName %27 0 "viewport" + OpMemberName %27 1 "clipDistancesEnabled" + OpMemberName %27 2 "xfbActiveUnpaused" + OpMemberName %27 3 "xfbVerticesPerInstance" + OpMemberName %27 4 "numSamples" + OpMemberName %27 5 "xfbBufferOffsets" + OpMemberName %27 6 "acbBufferOffsets" + OpMemberName %27 7 "depthRange" + OpName %29 "ANGLEUniforms" ; id %29 + OpName %33 "_uc" ; id %33 + OpName %32 "_uh" ; id %32 + OpName %49 "_ux" ; id %49 + OpName %50 "_uy" ; id %50 + OpName %48 "_ui" ; id %48 + OpName %63 "main" ; id %63 + OpName %65 "param" ; id %65 + OpName %68 "param" ; id %68 + OpName %73 "param" ; id %73 + + ; Annotations + OpDecorate %4 Location 0 + OpDecorate %8 RelaxedPrecision + OpDecorate %8 DescriptorSet 0 + OpDecorate %8 Binding 0 + OpDecorate %11 DescriptorSet 0 + OpDecorate %11 Binding 1 + OpMemberDecorate %12 0 Offset 0 + OpMemberDecorate %12 0 RelaxedPrecision + OpDecorate %12 Block + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 2 + OpMemberDecorate %15 0 Offset 0 + OpMemberDecorate %15 0 RelaxedPrecision + OpDecorate %15 BufferBlock + OpDecorate %20 DescriptorSet 0 + OpDecorate %20 Binding 3 + OpDecorate %22 RelaxedPrecision + OpDecorate %22 Location 0 + OpMemberDecorate %26 0 Offset 0 + OpMemberDecorate %26 1 Offset 4 + OpMemberDecorate %26 2 Offset 8 + OpMemberDecorate %26 3 Offset 12 + OpMemberDecorate %27 0 Offset 0 + OpMemberDecorate %27 1 Offset 16 + OpMemberDecorate %27 2 Offset 20 + OpMemberDecorate %27 3 Offset 24 + OpMemberDecorate %27 4 Offset 28 + OpMemberDecorate %27 5 Offset 32 + OpMemberDecorate %27 6 Offset 48 + OpMemberDecorate %27 7 Offset 64 + OpMemberDecorate %27 2 RelaxedPrecision + OpMemberDecorate %27 4 RelaxedPrecision + OpDecorate %27 Block + OpDecorate %29 DescriptorSet 0 + OpDecorate %29 Binding 4 + OpDecorate %32 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %38 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %43 RelaxedPrecision + OpDecorate %48 RelaxedPrecision + OpDecorate %49 RelaxedPrecision + OpDecorate %50 RelaxedPrecision + OpDecorate %52 RelaxedPrecision + OpDecorate %53 RelaxedPrecision + OpDecorate %54 RelaxedPrecision + OpDecorate %55 RelaxedPrecision + OpDecorate %56 RelaxedPrecision + OpDecorate %57 RelaxedPrecision + OpDecorate %58 RelaxedPrecision + OpDecorate %59 RelaxedPrecision + OpDecorate %60 RelaxedPrecision + OpDecorate %67 RelaxedPrecision + OpDecorate %68 RelaxedPrecision + OpDecorate %72 RelaxedPrecision + OpDecorate %73 RelaxedPrecision + OpDecorate %75 RelaxedPrecision + OpDecorate %76 RelaxedPrecision + OpDecorate %77 RelaxedPrecision + OpDecorate %80 RelaxedPrecision + OpDecorate %81 RelaxedPrecision + + ; Types, variables and constants + %1 = OpTypeFloat 32 + %2 = OpTypeVector %1 4 + %5 = OpTypeImage %1 2D 0 0 0 1 Unknown + %6 = OpTypeSampledImage %5 + %9 = OpTypeImage %1 2D 0 0 0 2 Rgba8 + %12 = OpTypeStruct %2 ; Block + %15 = OpTypeStruct %2 ; BufferBlock + %16 = OpTypeInt 32 0 + %17 = OpConstant %16 2 + %18 = OpTypeArray %15 %17 + %23 = OpTypeInt 32 1 + %24 = OpTypeVector %23 4 + %25 = OpTypeVector %16 4 + %26 = OpTypeStruct %1 %1 %1 %1 + %27 = OpTypeStruct %2 %16 %16 %23 %23 %24 %25 %26 ; Block + %35 = OpTypeVector %1 2 + %40 = OpTypeVector %23 2 + %61 = OpTypeVoid + %69 = OpConstant %16 0 + %78 = OpConstant %16 1 + %3 = OpTypePointer Input %2 + %7 = OpTypePointer UniformConstant %6 + %10 = OpTypePointer UniformConstant %9 + %13 = OpTypePointer Uniform %12 + %19 = OpTypePointer Uniform %18 + %21 = OpTypePointer Output %2 + %28 = OpTypePointer Uniform %27 + %30 = OpTypePointer Function %2 + %70 = OpTypePointer Uniform %2 + %31 = OpTypeFunction %2 %30 + %47 = OpTypeFunction %2 %30 %30 + %62 = OpTypeFunction %61 + %4 = OpVariable %3 Input ; Location 0 + %8 = OpVariable %7 UniformConstant ; RelaxedPrecision, DescriptorSet 0, Binding 0 + %11 = OpVariable %10 UniformConstant ; DescriptorSet 0, Binding 1 + %14 = OpVariable %13 Uniform ; DescriptorSet 0, Binding 2 + %20 = OpVariable %19 Uniform ; DescriptorSet 0, Binding 3 + %22 = OpVariable %21 Output ; RelaxedPrecision, Location 0 + %29 = OpVariable %28 Uniform ; DescriptorSet 0, Binding 4 + + ; Function 32 + %32 = OpFunction %2 None %31 ; RelaxedPrecision + %33 = OpFunctionParameter %30 ; RelaxedPrecision + %34 = OpLabel + %36 = OpLoad %6 %8 ; RelaxedPrecision + %37 = OpLoad %2 %33 ; RelaxedPrecision + %38 = OpVectorShuffle %35 %37 %37 0 1 ; RelaxedPrecision + %39 = OpImageSampleImplicitLod %2 %36 %38 ; RelaxedPrecision + %41 = OpLoad %2 %33 ; RelaxedPrecision + %42 = OpVectorShuffle %35 %41 %41 2 3 ; RelaxedPrecision + %43 = OpConvertFToS %40 %42 ; RelaxedPrecision + %44 = OpLoad %9 %11 + %45 = OpImageRead %2 %44 %43 + %46 = OpFAdd %2 %39 %45 + OpReturnValue %46 + OpFunctionEnd + + ; Function 48 + %48 = OpFunction %2 None %47 ; RelaxedPrecision + %49 = OpFunctionParameter %30 ; RelaxedPrecision + %50 = OpFunctionParameter %30 ; RelaxedPrecision + %51 = OpLabel + %52 = OpLoad %2 %49 ; RelaxedPrecision + %53 = OpVectorShuffle %35 %52 %52 0 1 ; RelaxedPrecision + %54 = OpLoad %2 %50 ; RelaxedPrecision + %55 = OpVectorShuffle %35 %54 %54 2 3 ; RelaxedPrecision + %56 = OpCompositeExtract %1 %53 0 ; RelaxedPrecision + %57 = OpCompositeExtract %1 %53 1 ; RelaxedPrecision + %58 = OpCompositeExtract %1 %55 0 ; RelaxedPrecision + %59 = OpCompositeExtract %1 %55 1 ; RelaxedPrecision + %60 = OpCompositeConstruct %2 %56 %57 %58 %59 ; RelaxedPrecision + OpReturnValue %60 + OpFunctionEnd + + ; Function 63 + %63 = OpFunction %61 None %62 + %64 = OpLabel + %65 = OpVariable %30 Function + %68 = OpVariable %30 Function ; RelaxedPrecision + %73 = OpVariable %30 Function ; RelaxedPrecision + %66 = OpLoad %2 %4 + OpStore %65 %66 + %67 = OpFunctionCall %2 %32 %65 ; RelaxedPrecision + %71 = OpAccessChain %70 %14 %69 + %72 = OpLoad %2 %71 ; RelaxedPrecision + OpStore %68 %72 + %74 = OpAccessChain %70 %20 %69 %69 + %75 = OpLoad %2 %74 ; RelaxedPrecision + OpStore %73 %75 + %76 = OpFunctionCall %2 %48 %68 %73 ; RelaxedPrecision + %77 = OpFAdd %2 %67 %76 ; RelaxedPrecision + %79 = OpAccessChain %70 %20 %78 %69 + %80 = OpLoad %2 %79 ; RelaxedPrecision + %81 = OpFAdd %2 %77 %80 ; RelaxedPrecision + OpStore %22 %81 + OpReturn + OpFunctionEnd +)"; + + EXPECT_THAT( + EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_COMMENT | SPV_BINARY_TO_TEXT_OPTION_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + +TEST_F(TextToBinaryTest, NestedWithComments) { + const std::string input = R"(OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpName %4 "main" + OpName %8 "v" + OpName %44 "color" + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output + %4 = OpFunction %2 None %3 + %5 = OpLabel + %9 = OpLoad %6 %8 + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + %13 = OpLabel + %18 = OpLoad %6 %8 + %19 = OpExtInst %6 %1 Log %18 + %20 = OpLoad %6 %8 + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 + %24 = OpFMul %6 %19 %23 + %25 = OpLoad %6 %8 + %26 = OpExtInst %6 %1 Sin %25 + %27 = OpLoad %6 %8 + %28 = OpExtInst %6 %1 Cos %27 + %29 = OpLoad %6 %8 + %30 = OpExtInst %6 %1 Exp %29 + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 + OpBranch %14 + %32 = OpLabel + %33 = OpLoad %6 %8 + %34 = OpExtInst %6 %1 Sqrt %33 + %35 = OpLoad %6 %8 + %36 = OpExtInst %6 %1 FSign %35 + %37 = OpLoad %6 %8 + %39 = OpExtInst %6 %1 FMax %37 %38 + %40 = OpLoad %6 %8 + %41 = OpExtInst %6 %1 Floor %40 + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 + OpBranch %14 + %14 = OpLabel + %45 = OpPhi %15 %31 %13 %42 %32 + OpStore %44 %45 + OpReturn + OpFunctionEnd +)"; + const std::string expected = R"( OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %8 %44 + OpExecutionMode %4 OriginUpperLeft + + ; Debug Information + OpSource ESSL 310 + OpName %4 "main" ; id %4 + OpName %8 "v" ; id %8 + OpName %44 "color" ; id %44 + + ; Annotations + OpDecorate %8 RelaxedPrecision + OpDecorate %8 Location 0 + OpDecorate %9 RelaxedPrecision + OpDecorate %18 RelaxedPrecision + OpDecorate %19 RelaxedPrecision + OpDecorate %20 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %24 RelaxedPrecision + OpDecorate %25 RelaxedPrecision + OpDecorate %26 RelaxedPrecision + OpDecorate %27 RelaxedPrecision + OpDecorate %28 RelaxedPrecision + OpDecorate %29 RelaxedPrecision + OpDecorate %30 RelaxedPrecision + OpDecorate %31 RelaxedPrecision + OpDecorate %33 RelaxedPrecision + OpDecorate %34 RelaxedPrecision + OpDecorate %35 RelaxedPrecision + OpDecorate %36 RelaxedPrecision + OpDecorate %37 RelaxedPrecision + OpDecorate %39 RelaxedPrecision + OpDecorate %40 RelaxedPrecision + OpDecorate %41 RelaxedPrecision + OpDecorate %42 RelaxedPrecision + OpDecorate %44 RelaxedPrecision + OpDecorate %44 Location 0 + OpDecorate %45 RelaxedPrecision + + ; Types, variables and constants + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 + %7 = OpTypePointer Input %6 + %8 = OpVariable %7 Input ; RelaxedPrecision, Location 0 + %10 = OpConstant %6 0 + %11 = OpTypeBool + %15 = OpTypeVector %6 4 + %16 = OpTypePointer Function %15 + %21 = OpConstant %6 -0.5 + %22 = OpConstant %6 -0.300000012 + %38 = OpConstant %6 0.5 + %43 = OpTypePointer Output %15 + %44 = OpVariable %43 Output ; RelaxedPrecision, Location 0 + + + ; Function 4 + %4 = OpFunction %2 None %3 + + %5 = OpLabel + %9 = OpLoad %6 %8 ; RelaxedPrecision + %12 = OpFOrdLessThanEqual %11 %9 %10 + OpSelectionMerge %14 None + OpBranchConditional %12 %13 %32 + + %13 = OpLabel + %18 = OpLoad %6 %8 ; RelaxedPrecision + %19 = OpExtInst %6 %1 Log %18 ; RelaxedPrecision + %20 = OpLoad %6 %8 ; RelaxedPrecision + %23 = OpExtInst %6 %1 FClamp %20 %21 %22 ; RelaxedPrecision + %24 = OpFMul %6 %19 %23 ; RelaxedPrecision + %25 = OpLoad %6 %8 ; RelaxedPrecision + %26 = OpExtInst %6 %1 Sin %25 ; RelaxedPrecision + %27 = OpLoad %6 %8 ; RelaxedPrecision + %28 = OpExtInst %6 %1 Cos %27 ; RelaxedPrecision + %29 = OpLoad %6 %8 ; RelaxedPrecision + %30 = OpExtInst %6 %1 Exp %29 ; RelaxedPrecision + %31 = OpCompositeConstruct %15 %24 %26 %28 %30 ; RelaxedPrecision + OpBranch %14 + + %32 = OpLabel + %33 = OpLoad %6 %8 ; RelaxedPrecision + %34 = OpExtInst %6 %1 Sqrt %33 ; RelaxedPrecision + %35 = OpLoad %6 %8 ; RelaxedPrecision + %36 = OpExtInst %6 %1 FSign %35 ; RelaxedPrecision + %37 = OpLoad %6 %8 ; RelaxedPrecision + %39 = OpExtInst %6 %1 FMax %37 %38 ; RelaxedPrecision + %40 = OpLoad %6 %8 ; RelaxedPrecision + %41 = OpExtInst %6 %1 Floor %40 ; RelaxedPrecision + %42 = OpCompositeConstruct %15 %34 %36 %39 %41 ; RelaxedPrecision + OpBranch %14 + + %14 = OpLabel + %45 = OpPhi %15 %31 %13 %42 %32 ; RelaxedPrecision + OpStore %44 %45 + OpReturn + OpFunctionEnd +)"; + + EXPECT_THAT( + EncodeAndDecodeSuccessfully( + input, + SPV_BINARY_TO_TEXT_OPTION_COMMENT | SPV_BINARY_TO_TEXT_OPTION_INDENT | + SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS), + expected); +} + // Test version string. TEST_F(TextToBinaryTest, VersionString) { auto words = CompileSuccessfully(""); diff --git a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp index 9944c2cf1f..bd5a7d5873 100644 --- a/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp @@ -95,8 +95,7 @@ TEST(DiffTest, OpextinstInSrcOnly) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 15 -+; Bound: 16 + ; Bound: 15 ; Schema: 0 OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" @@ -199,8 +198,7 @@ TEST(DiffTest, OpextinstInSrcOnlyNoDebug) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 15 -+; Bound: 16 + ; Bound: 15 ; Schema: 0 OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" diff --git a/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp index f3afc701b3..d4b6846bfe 100644 --- a/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/basic_autogen.cpp @@ -129,7 +129,7 @@ TEST(DiffTest, Basic) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 36 ++; Bound: 30 ; Schema: 0 OpCapability Shader +%27 = OpExtInstImport "GLSL.std.450" @@ -272,7 +272,7 @@ OpFunctionEnd ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 36 ++; Bound: 30 ; Schema: 0 OpCapability Shader +%27 = OpExtInstImport "GLSL.std.450" @@ -324,7 +324,7 @@ TEST(DiffTest, BasicDumpIds) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 36 ++; Bound: 30 ; Schema: 0 OpCapability Shader +%27 = OpExtInstImport "GLSL.std.450" @@ -384,8 +384,8 @@ TEST(DiffTest, BasicDumpIds) { 6 -> 14 [TypeInt] 13 -> 19 [TypePointer] 14 -> 27 [Variable] - 15 -> 34 [Constant] - 16 -> 35 [TypeArray] + 15 -> 28 [Constant] + 16 -> 29 [TypeArray] 17 -> 11 [TypeStruct] 18 -> 12 [TypePointer] 19 -> 13 [Variable] diff --git a/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp index 16975ff47e..2b6d7d8099 100644 --- a/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/constant_array_size_autogen.cpp @@ -125,7 +125,7 @@ TEST(DiffTest, ConstantArraySize) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 34 ++; Bound: 28 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -259,7 +259,7 @@ OpFunctionEnd ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 34 ++; Bound: 28 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 diff --git a/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake b/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake index 6440d0b9ca..51cb62fab0 100644 --- a/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake +++ b/third_party/spirv-tools/test/diff/diff_files/diff_test_files_autogen.cmake @@ -36,6 +36,7 @@ list(APPEND DIFF_TEST_FILES "diff_files/large_functions_small_diffs_autogen.cpp" "diff_files/multiple_different_entry_points_autogen.cpp" "diff_files/multiple_same_entry_points_autogen.cpp" +"diff_files/ray_query_types_autogen.cpp" "diff_files/reordered_if_blocks_autogen.cpp" "diff_files/reordered_switch_blocks_autogen.cpp" "diff_files/small_functions_small_diffs_autogen.cpp" diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp index 0d34654f84..ec9074c640 100644 --- a/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_fragment_autogen.cpp @@ -977,7 +977,7 @@ OpFunctionEnd ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 82 -+; Bound: 92 ++; Bound: 89 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -1030,8 +1030,7 @@ OpFunctionEnd +OpDecorate %83 DescriptorSet 0 +OpDecorate %83 Binding 0 OpDecorate %32 RelaxedPrecision --OpDecorate %33 RelaxedPrecision -+OpDecorate %84 RelaxedPrecision + OpDecorate %33 RelaxedPrecision OpDecorate %36 RelaxedPrecision OpDecorate %37 RelaxedPrecision OpDecorate %38 RelaxedPrecision @@ -1040,10 +1039,8 @@ OpFunctionEnd OpDecorate %42 RelaxedPrecision OpDecorate %43 RelaxedPrecision OpDecorate %48 RelaxedPrecision --OpDecorate %49 RelaxedPrecision --OpDecorate %50 RelaxedPrecision -+OpDecorate %85 RelaxedPrecision -+OpDecorate %86 RelaxedPrecision + OpDecorate %49 RelaxedPrecision + OpDecorate %50 RelaxedPrecision OpDecorate %52 RelaxedPrecision OpDecorate %53 RelaxedPrecision OpDecorate %54 RelaxedPrecision @@ -1082,13 +1079,13 @@ OpFunctionEnd %61 = OpTypeVoid %69 = OpConstant %16 0 %78 = OpConstant %16 1 -+%88 = OpTypePointer Private %2 ++%85 = OpTypePointer Private %2 %3 = OpTypePointer Input %2 %7 = OpTypePointer UniformConstant %6 %10 = OpTypePointer UniformConstant %9 %13 = OpTypePointer Uniform %12 %19 = OpTypePointer Uniform %18 -+%89 = OpTypePointer Private %2 ++%86 = OpTypePointer Private %2 %21 = OpTypePointer Output %2 %28 = OpTypePointer Uniform %27 %30 = OpTypePointer Function %2 @@ -1106,19 +1103,16 @@ OpFunctionEnd %22 = OpVariable %21 Output -%29 = OpVariable %28 Uniform +%83 = OpVariable %28 Uniform -+%90 = OpConstant %23 0 -+%91 = OpConstant %1 0.5 ++%87 = OpConstant %23 0 ++%88 = OpConstant %1 0.5 %32 = OpFunction %2 None %31 --%33 = OpFunctionParameter %30 -+%84 = OpFunctionParameter %30 + %33 = OpFunctionParameter %30 %34 = OpLabel %36 = OpLoad %6 %8 --%37 = OpLoad %2 %33 -+%37 = OpLoad %2 %84 + %37 = OpLoad %2 %33 %38 = OpVectorShuffle %35 %37 %37 0 1 %39 = OpImageSampleImplicitLod %2 %36 %38 --%41 = OpLoad %2 %33 -+%41 = OpLoad %2 %84 + %41 = OpLoad %2 %33 %42 = OpVectorShuffle %35 %41 %41 2 3 %43 = OpConvertFToS %40 %42 %44 = OpLoad %9 %11 @@ -1127,16 +1121,12 @@ OpFunctionEnd OpReturnValue %46 OpFunctionEnd %48 = OpFunction %2 None %47 --%49 = OpFunctionParameter %30 --%50 = OpFunctionParameter %30 -+%85 = OpFunctionParameter %30 -+%86 = OpFunctionParameter %30 + %49 = OpFunctionParameter %30 + %50 = OpFunctionParameter %30 %51 = OpLabel --%52 = OpLoad %2 %49 -+%52 = OpLoad %2 %85 + %52 = OpLoad %2 %49 %53 = OpVectorShuffle %35 %52 %52 0 1 --%54 = OpLoad %2 %50 -+%54 = OpLoad %2 %86 + %54 = OpLoad %2 %50 %55 = OpVectorShuffle %35 %54 %54 2 3 %56 = OpCompositeExtract %1 %53 0 %57 = OpCompositeExtract %1 %53 1 @@ -1154,9 +1144,9 @@ OpFunctionEnd OpStore %65 %66 %67 = OpFunctionCall %2 %32 %65 -%71 = OpAccessChain %70 %14 %69 -+%87 = OpAccessChain %70 %82 %69 ++%84 = OpAccessChain %70 %82 %69 -%72 = OpLoad %2 %71 -+%72 = OpLoad %2 %87 ++%72 = OpLoad %2 %84 OpStore %68 %72 -%74 = OpAccessChain %70 %20 %69 %69 +%74 = OpAccessChain %70 %14 %69 %69 diff --git a/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp index f65ee5a198..134ebb4a54 100644 --- a/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/different_decorations_vertex_autogen.cpp @@ -777,7 +777,7 @@ OpFunctionEnd ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 58 -+; Bound: 79 ++; Bound: 77 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -817,12 +817,10 @@ OpFunctionEnd -OpMemberDecorate %23 3 BuiltIn CullDistance OpDecorate %23 Block OpDecorate %28 RelaxedPrecision --OpDecorate %29 RelaxedPrecision -+OpDecorate %59 RelaxedPrecision + OpDecorate %29 RelaxedPrecision OpDecorate %31 RelaxedPrecision OpDecorate %32 RelaxedPrecision --OpDecorate %33 RelaxedPrecision -+OpDecorate %60 RelaxedPrecision + OpDecorate %33 RelaxedPrecision OpDecorate %35 RelaxedPrecision OpDecorate %36 RelaxedPrecision OpDecorate %37 RelaxedPrecision @@ -845,9 +843,9 @@ OpFunctionEnd +%23 = OpTypeStruct %2 %38 = OpTypeVoid %45 = OpConstant %12 0 -+%65 = OpTypePointer Private %2 ++%63 = OpTypePointer Private %2 %3 = OpTypePointer Input %2 -+%66 = OpTypePointer Private %2 ++%64 = OpTypePointer Private %2 %7 = OpTypePointer Output %2 %10 = OpTypePointer Uniform %9 %18 = OpTypePointer Uniform %17 @@ -865,26 +863,21 @@ OpFunctionEnd -%19 = OpVariable %18 Uniform +%19 = OpVariable %10 Uniform %20 = OpVariable %7 Output -+%58 = OpVariable %66 Private ++%58 = OpVariable %64 Private %25 = OpVariable %24 Output -+%67 = OpConstant %13 0 -+%68 = OpConstant %1 0.5 ++%65 = OpConstant %13 0 ++%66 = OpConstant %1 0.5 %28 = OpFunction %2 None %27 --%29 = OpFunctionParameter %26 -+%59 = OpFunctionParameter %26 + %29 = OpFunctionParameter %26 %30 = OpLabel --%31 = OpLoad %2 %29 -+%31 = OpLoad %2 %59 + %31 = OpLoad %2 %29 OpReturnValue %31 OpFunctionEnd %32 = OpFunction %2 None %27 --%33 = OpFunctionParameter %26 -+%60 = OpFunctionParameter %26 + %33 = OpFunctionParameter %26 %34 = OpLabel --%35 = OpLoad %2 %33 -+%35 = OpLoad %2 %60 --%36 = OpLoad %2 %33 -+%36 = OpLoad %2 %60 + %35 = OpLoad %2 %33 + %36 = OpLoad %2 %33 %37 = OpFAdd %2 %35 %36 OpReturnValue %37 OpFunctionEnd @@ -894,41 +887,41 @@ OpFunctionEnd %50 = OpVariable %26 Function %53 = OpVariable %26 Function -%43 = OpLoad %2 %4 -+%61 = OpLoad %2 %5 ++%59 = OpLoad %2 %5 -OpStore %42 %43 -+OpStore %42 %61 ++OpStore %42 %59 %44 = OpFunctionCall %2 %28 %42 -%47 = OpAccessChain %46 %11 %45 -+%62 = OpAccessChain %46 %19 %45 ++%60 = OpAccessChain %46 %19 %45 -%48 = OpLoad %2 %47 -+%48 = OpLoad %2 %62 ++%48 = OpLoad %2 %60 %49 = OpFAdd %2 %44 %48 -OpStore %8 %49 +OpStore %20 %49 -%51 = OpLoad %2 %5 -+%63 = OpLoad %2 %6 ++%61 = OpLoad %2 %6 -OpStore %50 %51 -+OpStore %50 %63 ++OpStore %50 %61 %52 = OpFunctionCall %2 %32 %50 -%54 = OpLoad %2 %6 -+%64 = OpLoad %2 %4 ++%62 = OpLoad %2 %4 -OpStore %53 %54 -+OpStore %53 %64 ++OpStore %53 %62 %55 = OpFunctionCall %2 %28 %53 %56 = OpFAdd %2 %52 %55 %57 = OpAccessChain %7 %25 %45 OpStore %57 %56 -+%69 = OpAccessChain %7 %25 %67 -+%70 = OpLoad %2 %69 -+%71 = OpCompositeExtract %1 %70 0 -+%72 = OpCompositeExtract %1 %70 1 -+%73 = OpCompositeExtract %1 %70 2 -+%74 = OpCompositeExtract %1 %70 3 -+%76 = OpFNegate %1 %71 -+%77 = OpFAdd %1 %73 %74 -+%78 = OpFMul %1 %77 %68 -+%75 = OpCompositeConstruct %2 %72 %76 %78 %74 -+OpStore %69 %75 ++%67 = OpAccessChain %7 %25 %65 ++%68 = OpLoad %2 %67 ++%69 = OpCompositeExtract %1 %68 0 ++%70 = OpCompositeExtract %1 %68 1 ++%71 = OpCompositeExtract %1 %68 2 ++%72 = OpCompositeExtract %1 %68 3 ++%74 = OpFNegate %1 %69 ++%75 = OpFAdd %1 %71 %72 ++%76 = OpFMul %1 %75 %66 ++%73 = OpCompositeConstruct %2 %70 %74 %76 %72 ++OpStore %67 %73 OpReturn OpFunctionEnd )"; diff --git a/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp index 3a077fb0eb..e31a4a89ec 100644 --- a/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/different_function_parameter_count_autogen.cpp @@ -128,7 +128,7 @@ TEST(DiffTest, DifferentFunctionParameterCount) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 25 -+; Bound: 33 ++; Bound: 31 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -143,7 +143,7 @@ TEST(DiffTest, DifferentFunctionParameterCount) { +OpName %26 "v2" OpName %20 "o" OpName %23 "param" -+OpName %31 "param" ++OpName %29 "param" OpDecorate %20 RelaxedPrecision OpDecorate %20 Location 0 %2 = OpTypeVoid @@ -162,13 +162,13 @@ TEST(DiffTest, DifferentFunctionParameterCount) { %4 = OpFunction %2 None %3 %5 = OpLabel %23 = OpVariable %8 Function -+%31 = OpVariable %8 Function ++%29 = OpVariable %8 Function OpStore %23 %22 -%24 = OpFunctionCall %7 %11 %23 -+OpStore %31 %15 -+%32 = OpFunctionCall %7 %11 %23 %31 ++OpStore %29 %15 ++%30 = OpFunctionCall %7 %11 %23 %29 -OpStore %20 %24 -+OpStore %20 %32 ++OpStore %20 %30 OpReturn OpFunctionEnd -%11 = OpFunction %7 None %9 @@ -280,7 +280,7 @@ TEST(DiffTest, DifferentFunctionParameterCountNoDebug) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 25 -+; Bound: 34 ++; Bound: 31 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -306,28 +306,26 @@ TEST(DiffTest, DifferentFunctionParameterCountNoDebug) { %4 = OpFunction %2 None %3 %5 = OpLabel %23 = OpVariable %8 Function -+%32 = OpVariable %8 Function ++%29 = OpVariable %8 Function OpStore %23 %22 -%24 = OpFunctionCall %7 %11 %23 -+OpStore %32 %15 -+%33 = OpFunctionCall %7 %11 %23 %32 ++OpStore %29 %15 ++%30 = OpFunctionCall %7 %11 %23 %29 -OpStore %20 %24 -+OpStore %20 %33 ++OpStore %20 %30 OpReturn OpFunctionEnd -%11 = OpFunction %7 None %9 +%11 = OpFunction %7 None %25 --%10 = OpFunctionParameter %8 + %10 = OpFunctionParameter %8 +%26 = OpFunctionParameter %8 -+%27 = OpFunctionParameter %8 %12 = OpLabel --%13 = OpLoad %7 %10 -+%13 = OpLoad %7 %26 + %13 = OpLoad %7 %10 -%16 = OpFAdd %7 %13 %15 -+%28 = OpLoad %7 %27 -+%29 = OpFAdd %7 %13 %28 ++%27 = OpLoad %7 %26 ++%28 = OpFAdd %7 %13 %27 -OpReturnValue %16 -+OpReturnValue %29 ++OpReturnValue %28 OpFunctionEnd )"; Options options; diff --git a/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp index 4f91319871..fee34aea57 100644 --- a/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/extra_if_block_autogen.cpp @@ -303,7 +303,7 @@ TEST(DiffTest, ExtraIfBlock) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 69 -+; Bound: 81 ++; Bound: 77 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -352,10 +352,10 @@ TEST(DiffTest, ExtraIfBlock) { OpDecorate %54 RelaxedPrecision OpDecorate %55 RelaxedPrecision OpDecorate %56 RelaxedPrecision -+OpDecorate %72 RelaxedPrecision ++OpDecorate %70 RelaxedPrecision OpDecorate %57 RelaxedPrecision -+OpDecorate %77 RelaxedPrecision -+OpDecorate %78 RelaxedPrecision ++OpDecorate %75 RelaxedPrecision ++OpDecorate %76 RelaxedPrecision OpDecorate %58 RelaxedPrecision OpDecorate %63 RelaxedPrecision OpDecorate %63 Location 0 @@ -383,7 +383,7 @@ TEST(DiffTest, ExtraIfBlock) { %32 = OpConstant %19 1 %49 = OpConstant %6 10 %52 = OpConstant %6 0.5 -+%76 = OpConstant %6 0.100000001 ++%74 = OpConstant %6 0.100000001 %53 = OpConstant %6 0.699999988 %61 = OpTypeVector %6 4 %62 = OpTypePointer Output %61 @@ -439,20 +439,20 @@ TEST(DiffTest, ExtraIfBlock) { %55 = OpLoad %6 %45 %56 = OpFMul %6 %55 %54 OpStore %45 %56 -+%71 = OpAccessChain %21 %18 %32 -+%72 = OpLoad %15 %71 -+%73 = OpINotEqual %25 %72 %24 -+OpSelectionMerge %75 None -+OpBranchConditional %73 %74 %75 -+%74 = OpLabel ++%69 = OpAccessChain %21 %18 %32 ++%70 = OpLoad %15 %69 ++%71 = OpINotEqual %25 %70 %24 ++OpSelectionMerge %73 None ++OpBranchConditional %71 %72 %73 ++%72 = OpLabel %57 = OpLoad %6 %45 -+%77 = OpFSub %6 %57 %76 -+OpStore %45 %77 -+OpBranch %75 -+%75 = OpLabel -+%78 = OpLoad %6 %45 ++%75 = OpFSub %6 %57 %74 ++OpStore %45 %75 ++OpBranch %73 ++%73 = OpLabel ++%76 = OpLoad %6 %45 -%58 = OpExtInst %6 %1 Exp %57 -+%58 = OpExtInst %6 %1 Exp %78 ++%58 = OpExtInst %6 %1 Exp %76 OpReturnValue %58 OpFunctionEnd )"; @@ -716,7 +716,7 @@ TEST(DiffTest, ExtraIfBlockNoDebug) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 69 -+; Bound: 81 ++; Bound: 77 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -754,10 +754,10 @@ TEST(DiffTest, ExtraIfBlockNoDebug) { OpDecorate %54 RelaxedPrecision OpDecorate %55 RelaxedPrecision OpDecorate %56 RelaxedPrecision -+OpDecorate %72 RelaxedPrecision ++OpDecorate %70 RelaxedPrecision OpDecorate %57 RelaxedPrecision -+OpDecorate %77 RelaxedPrecision -+OpDecorate %78 RelaxedPrecision ++OpDecorate %75 RelaxedPrecision ++OpDecorate %76 RelaxedPrecision OpDecorate %58 RelaxedPrecision OpDecorate %63 RelaxedPrecision OpDecorate %63 Location 0 @@ -785,7 +785,7 @@ TEST(DiffTest, ExtraIfBlockNoDebug) { %32 = OpConstant %19 1 %49 = OpConstant %6 10 %52 = OpConstant %6 0.5 -+%76 = OpConstant %6 0.100000001 ++%74 = OpConstant %6 0.100000001 %53 = OpConstant %6 0.699999988 %61 = OpTypeVector %6 4 %62 = OpTypePointer Output %61 @@ -841,20 +841,20 @@ TEST(DiffTest, ExtraIfBlockNoDebug) { %55 = OpLoad %6 %45 %56 = OpFMul %6 %55 %54 OpStore %45 %56 -+%71 = OpAccessChain %21 %18 %32 -+%72 = OpLoad %15 %71 -+%73 = OpINotEqual %25 %72 %24 -+OpSelectionMerge %75 None -+OpBranchConditional %73 %74 %75 -+%74 = OpLabel ++%69 = OpAccessChain %21 %18 %32 ++%70 = OpLoad %15 %69 ++%71 = OpINotEqual %25 %70 %24 ++OpSelectionMerge %73 None ++OpBranchConditional %71 %72 %73 ++%72 = OpLabel %57 = OpLoad %6 %45 -+%77 = OpFSub %6 %57 %76 -+OpStore %45 %77 -+OpBranch %75 -+%75 = OpLabel -+%78 = OpLoad %6 %45 ++%75 = OpFSub %6 %57 %74 ++OpStore %45 %75 ++OpBranch %73 ++%73 = OpLabel ++%76 = OpLoad %6 %45 -%58 = OpExtInst %6 %1 Exp %57 -+%58 = OpExtInst %6 %1 Exp %78 ++%58 = OpExtInst %6 %1 Exp %76 OpReturnValue %58 OpFunctionEnd )"; diff --git a/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp index 187722e891..11bb811799 100644 --- a/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/int_vs_uint_constants_autogen.cpp @@ -371,10 +371,10 @@ TEST(DiffTest, IntVsUintConstantsDumpIds) { 3 -> 16 [TypePointer] 4 -> 17 [Variable] 5 -> 8 [TypeInt] - 8 -> 23 [TypeVector] + 8 -> 21 [TypeVector] 13 -> 19 [TypePointer] - 15 -> 29 [Constant] - 16 -> 30 [TypeArray] + 15 -> 22 [Constant] + 16 -> 23 [TypeArray] 17 -> 11 [TypeStruct] 18 -> 12 [TypePointer] 19 -> 13 [Variable] diff --git a/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp index 9d011661c6..00bee6be3a 100644 --- a/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/multiple_same_entry_points_autogen.cpp @@ -125,9 +125,8 @@ TEST(DiffTest, MultipleSameEntryPoints) { OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -+OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpEntryPoint Vertex %4 "main1" %8 %10 --OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpSource ESSL 310 OpName %4 "main1" OpName %12 "main2" @@ -257,9 +256,8 @@ TEST(DiffTest, MultipleSameEntryPointsNoDebug) { OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -+OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpEntryPoint Vertex %4 "main1" %8 %10 --OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpSource ESSL 310 OpDecorate %8 Location 0 OpDecorate %10 Location 0 @@ -304,9 +302,8 @@ TEST(DiffTest, MultipleSameEntryPointsDumpIds) { OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -+OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpEntryPoint Vertex %4 "main1" %8 %10 --OpEntryPoint Vertex %12 "main2" %13 %14 %15 + OpEntryPoint Vertex %12 "main2" %13 %14 %15 OpSource ESSL 310 OpName %4 "main1" OpName %12 "main2" diff --git a/third_party/spirv-tools/test/diff/diff_files/ray_query_types_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_autogen.cpp new file mode 100644 index 0000000000..5507def64e --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_autogen.cpp @@ -0,0 +1,148 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by generate_tests.py +// +// Copyright (c) 2022 Google LLC. +// +// 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 "../diff_test_utils.h" + +#include "gtest/gtest.h" + +namespace spvtools { +namespace diff { +namespace { + +// Test that OpTypeAccelerationStructureNV and OpTypeRayQueryKHR are +// matched. +constexpr char kSrc[] = R"(OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd)"; +constexpr char kDst[] = R"(; SPIR-V +; Version: 1.4 +; Generator: rspirv +; Bound: 95 +OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd +)"; + +TEST(DiffTest, RayQueryTypes) { + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 45 + ; Schema: 0 + OpCapability RayQueryKHR + OpCapability Shader + OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %43 "main" + OpExecutionMode %43 LocalSize 1 1 1 + %2 = OpTypeVoid + %3 = OpTypeAccelerationStructureKHR + %13 = OpTypeRayQueryKHR + %44 = OpTypeFunction %2 + %43 = OpFunction %2 None %44 + %42 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrc, kDst, kDiff, options); +} + +TEST(DiffTest, RayQueryTypesNoDebug) { + constexpr char kSrcNoDebug[] = R"(OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd +)"; + constexpr char kDstNoDebug[] = R"(; SPIR-V +; Version: 1.4 +; Generator: rspirv +; Bound: 95 +OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd +)"; + constexpr char kDiff[] = R"( ; SPIR-V + ; Version: 1.6 + ; Generator: Khronos SPIR-V Tools Assembler; 0 + ; Bound: 45 + ; Schema: 0 + OpCapability RayQueryKHR + OpCapability Shader + OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %43 "main" + OpExecutionMode %43 LocalSize 1 1 1 + %2 = OpTypeVoid + %3 = OpTypeAccelerationStructureKHR + %13 = OpTypeRayQueryKHR + %44 = OpTypeFunction %2 + %43 = OpFunction %2 None %44 + %42 = OpLabel + OpReturn + OpFunctionEnd +)"; + Options options; + DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); +} + +} // namespace +} // namespace diff +} // namespace spvtools diff --git a/third_party/spirv-tools/test/diff/diff_files/ray_query_types_dst.spvasm b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_dst.spvasm new file mode 100644 index 0000000000..5f8be53d44 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_dst.spvasm @@ -0,0 +1,18 @@ +; SPIR-V +; Version: 1.4 +; Generator: rspirv +; Bound: 95 +OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/ray_query_types_src.spvasm b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_src.spvasm new file mode 100644 index 0000000000..0b64015b56 --- /dev/null +++ b/third_party/spirv-tools/test/diff/diff_files/ray_query_types_src.spvasm @@ -0,0 +1,16 @@ +;; Test that OpTypeAccelerationStructureNV and OpTypeRayQueryKHR are +;; matched. +OpCapability RayQueryKHR +OpCapability Shader +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %43 "main" +OpExecutionMode %43 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeAccelerationStructureNV +%13 = OpTypeRayQueryKHR +%44 = OpTypeFunction %2 +%43 = OpFunction %2 None %44 +%42 = OpLabel +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp index 0788199f9f..3abaf40de3 100644 --- a/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_if_blocks_autogen.cpp @@ -203,8 +203,7 @@ TEST(DiffTest, ReorderedIfBlocks) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 46 -+; Bound: 47 + ; Bound: 46 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -471,8 +470,7 @@ TEST(DiffTest, ReorderedIfBlocksNoDebug) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 46 -+; Bound: 47 + ; Bound: 46 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" diff --git a/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp index c0ba48d1e9..ade5350e79 100644 --- a/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/reordered_switch_blocks_autogen.cpp @@ -212,8 +212,7 @@ TEST(DiffTest, ReorderedSwitchBlocks) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 58 -+; Bound: 62 + ; Bound: 58 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" @@ -485,8 +484,7 @@ TEST(DiffTest, ReorderedSwitchBlocksNoDebug) { constexpr char kDiff[] = R"( ; SPIR-V ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 --; Bound: 58 -+; Bound: 62 + ; Bound: 58 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" diff --git a/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp index 1962d27e70..98ad072748 100644 --- a/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp +++ b/third_party/spirv-tools/test/diff/diff_files/spec_constant_array_size_autogen.cpp @@ -125,7 +125,7 @@ TEST(DiffTest, SpecConstantArraySize) { ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 36 ++; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -140,7 +140,7 @@ TEST(DiffTest, SpecConstantArraySize) { OpName %19 "" OpName %22 "main" OpDecorate %4 Location 0 -+OpDecorate %34 SpecId 4 ++OpDecorate %27 SpecId 4 OpMemberDecorate %17 1 RelaxedPrecision OpMemberDecorate %17 0 BuiltIn Position OpMemberDecorate %17 1 BuiltIn PointSize @@ -153,10 +153,10 @@ TEST(DiffTest, SpecConstantArraySize) { %8 = OpTypeVector %5 4 -%15 = OpConstant %5 8 -%16 = OpTypeArray %1 %15 -+%34 = OpSpecConstant %5 8 -+%35 = OpTypeArray %1 %34 ++%27 = OpSpecConstant %5 8 ++%28 = OpTypeArray %1 %27 -%17 = OpTypeStruct %2 %1 %16 %16 -+%17 = OpTypeStruct %2 %1 %35 %35 ++%17 = OpTypeStruct %2 %1 %28 %28 %20 = OpTypeVoid %25 = OpConstant %5 0 %3 = OpTypePointer Input %2 @@ -261,14 +261,14 @@ OpFunctionEnd ; Version: 1.6 ; Generator: Khronos SPIR-V Tools Assembler; 0 -; Bound: 27 -+; Bound: 36 ++; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %22 "main" %4 %19 OpSource GLSL 450 OpDecorate %4 Location 0 -+OpDecorate %34 SpecId 4 ++OpDecorate %27 SpecId 4 OpMemberDecorate %17 1 RelaxedPrecision OpMemberDecorate %17 0 BuiltIn Position OpMemberDecorate %17 1 BuiltIn PointSize @@ -281,10 +281,10 @@ OpFunctionEnd %8 = OpTypeVector %5 4 -%15 = OpConstant %5 8 -%16 = OpTypeArray %1 %15 -+%34 = OpSpecConstant %5 8 -+%35 = OpTypeArray %1 %34 ++%27 = OpSpecConstant %5 8 ++%28 = OpTypeArray %1 %27 -%17 = OpTypeStruct %2 %1 %16 %16 -+%17 = OpTypeStruct %2 %1 %35 %35 ++%17 = OpTypeStruct %2 %1 %28 %28 %20 = OpTypeVoid %25 = OpConstant %5 0 %3 = OpTypePointer Input %2 diff --git a/third_party/spirv-tools/test/diff/diff_test.cpp b/third_party/spirv-tools/test/diff/diff_test.cpp index 3b63c69c7c..da869315da 100644 --- a/third_party/spirv-tools/test/diff/diff_test.cpp +++ b/third_party/spirv-tools/test/diff/diff_test.cpp @@ -20,7 +20,6 @@ #include "source/opt/ir_context.h" #include "source/spirv_constant.h" #include "spirv-tools/libspirv.hpp" -#include "tools/io.h" #include "tools/util/cli_consumer.h" #include diff --git a/third_party/spirv-tools/test/diff/diff_test_utils.cpp b/third_party/spirv-tools/test/diff/diff_test_utils.cpp index 14bb821536..3bea9c3b18 100644 --- a/third_party/spirv-tools/test/diff/diff_test_utils.cpp +++ b/third_party/spirv-tools/test/diff/diff_test_utils.cpp @@ -18,7 +18,6 @@ #include "source/opt/ir_context.h" #include "spirv-tools/libspirv.hpp" -#include "tools/io.h" #include "tools/util/cli_consumer.h" #include "gtest/gtest.h" diff --git a/third_party/spirv-tools/test/enum_set_test.cpp b/third_party/spirv-tools/test/enum_set_test.cpp index 1f727158ee..08a4693d6c 100644 --- a/third_party/spirv-tools/test/enum_set_test.cpp +++ b/third_party/spirv-tools/test/enum_set_test.cpp @@ -12,12 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/enum_set.h" + #include +#include +#include #include #include #include "gmock/gmock.h" -#include "source/enum_set.h" #include "test/unit_spirv.h" namespace spvtools { @@ -25,208 +28,800 @@ namespace { using spvtest::ElementsIn; using ::testing::Eq; +using ::testing::Values; using ::testing::ValuesIn; +enum class TestEnum : uint32_t { + ZERO = 0, + ONE = 1, + TWO = 2, + THREE = 3, + FOUR = 4, + FIVE = 5, + EIGHT = 8, + TWENTY = 20, + TWENTY_FOUR = 24, + THIRTY = 30, + ONE_HUNDRED = 100, + ONE_HUNDRED_FIFTY = 150, + TWO_HUNDRED = 200, + THREE_HUNDRED = 300, + FOUR_HUNDRED = 400, + FIVE_HUNDRED = 500, + SIX_HUNDRED = 600, +}; + +constexpr std::array kCapabilities{ + spv::Capability::Matrix, + spv::Capability::Shader, + spv::Capability::Geometry, + spv::Capability::Tessellation, + spv::Capability::Addresses, + spv::Capability::Linkage, + spv::Capability::Kernel, + spv::Capability::Vector16, + spv::Capability::Float16Buffer, + spv::Capability::Float16, + spv::Capability::Float64, + spv::Capability::Int64, + spv::Capability::Int64Atomics, + spv::Capability::ImageBasic, + spv::Capability::ImageReadWrite, + spv::Capability::ImageMipmap, + spv::Capability::Pipes, + spv::Capability::Groups, + spv::Capability::DeviceEnqueue, + spv::Capability::LiteralSampler, + spv::Capability::AtomicStorage, + spv::Capability::Int16, + spv::Capability::TessellationPointSize, + spv::Capability::GeometryPointSize, + spv::Capability::ImageGatherExtended, + spv::Capability::StorageImageMultisample, + spv::Capability::UniformBufferArrayDynamicIndexing, + spv::Capability::SampledImageArrayDynamicIndexing, + spv::Capability::StorageBufferArrayDynamicIndexing, + spv::Capability::StorageImageArrayDynamicIndexing, + spv::Capability::ClipDistance, + spv::Capability::CullDistance, + spv::Capability::ImageCubeArray, + spv::Capability::SampleRateShading, + spv::Capability::ImageRect, + spv::Capability::SampledRect, + spv::Capability::GenericPointer, + spv::Capability::Int8, + spv::Capability::InputAttachment, + spv::Capability::SparseResidency, + spv::Capability::MinLod, + spv::Capability::Sampled1D, + spv::Capability::Image1D, + spv::Capability::SampledCubeArray, + spv::Capability::SampledBuffer, + spv::Capability::ImageBuffer, + spv::Capability::ImageMSArray, + spv::Capability::StorageImageExtendedFormats, + spv::Capability::ImageQuery, + spv::Capability::DerivativeControl, + spv::Capability::InterpolationFunction, + spv::Capability::TransformFeedback, + spv::Capability::GeometryStreams, + spv::Capability::StorageImageReadWithoutFormat, + spv::Capability::StorageImageWriteWithoutFormat, + spv::Capability::MultiViewport, + spv::Capability::SubgroupDispatch, + spv::Capability::NamedBarrier, + spv::Capability::PipeStorage, + spv::Capability::GroupNonUniform, + spv::Capability::GroupNonUniformVote, + spv::Capability::GroupNonUniformArithmetic, + spv::Capability::GroupNonUniformBallot, + spv::Capability::GroupNonUniformShuffle, + spv::Capability::GroupNonUniformShuffleRelative, + spv::Capability::GroupNonUniformClustered, + spv::Capability::GroupNonUniformQuad, + spv::Capability::ShaderLayer, + spv::Capability::ShaderViewportIndex, + spv::Capability::UniformDecoration, + spv::Capability::CoreBuiltinsARM, + spv::Capability::FragmentShadingRateKHR, + spv::Capability::SubgroupBallotKHR, + spv::Capability::DrawParameters, + spv::Capability::WorkgroupMemoryExplicitLayoutKHR, + spv::Capability::WorkgroupMemoryExplicitLayout8BitAccessKHR, + spv::Capability::WorkgroupMemoryExplicitLayout16BitAccessKHR, + spv::Capability::SubgroupVoteKHR, + spv::Capability::StorageBuffer16BitAccess, + spv::Capability::StorageUniformBufferBlock16, + spv::Capability::StorageUniform16, + spv::Capability::UniformAndStorageBuffer16BitAccess, + spv::Capability::StoragePushConstant16, + spv::Capability::StorageInputOutput16, + spv::Capability::DeviceGroup, + spv::Capability::MultiView, + spv::Capability::VariablePointersStorageBuffer, + spv::Capability::VariablePointers, + spv::Capability::AtomicStorageOps, + spv::Capability::SampleMaskPostDepthCoverage, + spv::Capability::StorageBuffer8BitAccess, + spv::Capability::UniformAndStorageBuffer8BitAccess, + spv::Capability::StoragePushConstant8, + spv::Capability::DenormPreserve, + spv::Capability::DenormFlushToZero, + spv::Capability::SignedZeroInfNanPreserve, + spv::Capability::RoundingModeRTE, + spv::Capability::RoundingModeRTZ, + spv::Capability::RayQueryProvisionalKHR, + spv::Capability::RayQueryKHR, + spv::Capability::RayTraversalPrimitiveCullingKHR, + spv::Capability::RayTracingKHR, + spv::Capability::Float16ImageAMD, + spv::Capability::ImageGatherBiasLodAMD, + spv::Capability::FragmentMaskAMD, + spv::Capability::StencilExportEXT, + spv::Capability::ImageReadWriteLodAMD, + spv::Capability::Int64ImageEXT, + spv::Capability::ShaderClockKHR, + spv::Capability::SampleMaskOverrideCoverageNV, + spv::Capability::GeometryShaderPassthroughNV, + spv::Capability::ShaderViewportIndexLayerEXT, + spv::Capability::ShaderViewportIndexLayerNV, + spv::Capability::ShaderViewportMaskNV, + spv::Capability::ShaderStereoViewNV, + spv::Capability::PerViewAttributesNV, + spv::Capability::FragmentFullyCoveredEXT, + spv::Capability::MeshShadingNV, + spv::Capability::ImageFootprintNV, + spv::Capability::MeshShadingEXT, + spv::Capability::FragmentBarycentricKHR, + spv::Capability::FragmentBarycentricNV, + spv::Capability::ComputeDerivativeGroupQuadsNV, + spv::Capability::FragmentDensityEXT, + spv::Capability::ShadingRateNV, + spv::Capability::GroupNonUniformPartitionedNV, + spv::Capability::ShaderNonUniform, + spv::Capability::ShaderNonUniformEXT, + spv::Capability::RuntimeDescriptorArray, + spv::Capability::RuntimeDescriptorArrayEXT, + spv::Capability::InputAttachmentArrayDynamicIndexing, + spv::Capability::InputAttachmentArrayDynamicIndexingEXT, + spv::Capability::UniformTexelBufferArrayDynamicIndexing, + spv::Capability::UniformTexelBufferArrayDynamicIndexingEXT, + spv::Capability::StorageTexelBufferArrayDynamicIndexing, + spv::Capability::StorageTexelBufferArrayDynamicIndexingEXT, + spv::Capability::UniformBufferArrayNonUniformIndexing, + spv::Capability::UniformBufferArrayNonUniformIndexingEXT, + spv::Capability::SampledImageArrayNonUniformIndexing, + spv::Capability::SampledImageArrayNonUniformIndexingEXT, + spv::Capability::StorageBufferArrayNonUniformIndexing, + spv::Capability::StorageBufferArrayNonUniformIndexingEXT, + spv::Capability::StorageImageArrayNonUniformIndexing, + spv::Capability::StorageImageArrayNonUniformIndexingEXT, + spv::Capability::InputAttachmentArrayNonUniformIndexing, + spv::Capability::InputAttachmentArrayNonUniformIndexingEXT, + spv::Capability::UniformTexelBufferArrayNonUniformIndexing, + spv::Capability::UniformTexelBufferArrayNonUniformIndexingEXT, + spv::Capability::StorageTexelBufferArrayNonUniformIndexing, + spv::Capability::StorageTexelBufferArrayNonUniformIndexingEXT, + spv::Capability::RayTracingNV, + spv::Capability::RayTracingMotionBlurNV, + spv::Capability::VulkanMemoryModel, + spv::Capability::VulkanMemoryModelKHR, + spv::Capability::VulkanMemoryModelDeviceScope, + spv::Capability::VulkanMemoryModelDeviceScopeKHR, + spv::Capability::PhysicalStorageBufferAddresses, + spv::Capability::PhysicalStorageBufferAddressesEXT, + spv::Capability::ComputeDerivativeGroupLinearNV, + spv::Capability::RayTracingProvisionalKHR, + spv::Capability::CooperativeMatrixNV, + spv::Capability::FragmentShaderSampleInterlockEXT, + spv::Capability::FragmentShaderShadingRateInterlockEXT, + spv::Capability::ShaderSMBuiltinsNV, + spv::Capability::FragmentShaderPixelInterlockEXT, + spv::Capability::DemoteToHelperInvocation, + spv::Capability::DemoteToHelperInvocationEXT, + spv::Capability::RayTracingOpacityMicromapEXT, + spv::Capability::ShaderInvocationReorderNV, + spv::Capability::BindlessTextureNV, + spv::Capability::SubgroupShuffleINTEL, + spv::Capability::SubgroupBufferBlockIOINTEL, + spv::Capability::SubgroupImageBlockIOINTEL, + spv::Capability::SubgroupImageMediaBlockIOINTEL, + spv::Capability::RoundToInfinityINTEL, + spv::Capability::FloatingPointModeINTEL, + spv::Capability::IntegerFunctions2INTEL, + spv::Capability::FunctionPointersINTEL, + spv::Capability::IndirectReferencesINTEL, + spv::Capability::AsmINTEL, + spv::Capability::AtomicFloat32MinMaxEXT, + spv::Capability::AtomicFloat64MinMaxEXT, + spv::Capability::AtomicFloat16MinMaxEXT, + spv::Capability::VectorComputeINTEL, + spv::Capability::VectorAnyINTEL, + spv::Capability::ExpectAssumeKHR, + spv::Capability::SubgroupAvcMotionEstimationINTEL, + spv::Capability::SubgroupAvcMotionEstimationIntraINTEL, + spv::Capability::SubgroupAvcMotionEstimationChromaINTEL, + spv::Capability::VariableLengthArrayINTEL, + spv::Capability::FunctionFloatControlINTEL, + spv::Capability::FPGAMemoryAttributesINTEL, + spv::Capability::FPFastMathModeINTEL, + spv::Capability::ArbitraryPrecisionIntegersINTEL, + spv::Capability::ArbitraryPrecisionFloatingPointINTEL, + spv::Capability::UnstructuredLoopControlsINTEL, + spv::Capability::FPGALoopControlsINTEL, + spv::Capability::KernelAttributesINTEL, + spv::Capability::FPGAKernelAttributesINTEL, + spv::Capability::FPGAMemoryAccessesINTEL, + spv::Capability::FPGAClusterAttributesINTEL, + spv::Capability::LoopFuseINTEL, + spv::Capability::FPGADSPControlINTEL, + spv::Capability::MemoryAccessAliasingINTEL, + spv::Capability::FPGAInvocationPipeliningAttributesINTEL, + spv::Capability::FPGABufferLocationINTEL, + spv::Capability::ArbitraryPrecisionFixedPointINTEL, + spv::Capability::USMStorageClassesINTEL, + spv::Capability::RuntimeAlignedAttributeINTEL, + spv::Capability::IOPipesINTEL, + spv::Capability::BlockingPipesINTEL, + spv::Capability::FPGARegINTEL, + spv::Capability::DotProductInputAll, + spv::Capability::DotProductInputAllKHR, + spv::Capability::DotProductInput4x8Bit, + spv::Capability::DotProductInput4x8BitKHR, + spv::Capability::DotProductInput4x8BitPacked, + spv::Capability::DotProductInput4x8BitPackedKHR, + spv::Capability::DotProduct, + spv::Capability::DotProductKHR, + spv::Capability::RayCullMaskKHR, + spv::Capability::BitInstructions, + spv::Capability::GroupNonUniformRotateKHR, + spv::Capability::AtomicFloat32AddEXT, + spv::Capability::AtomicFloat64AddEXT, + spv::Capability::LongCompositesINTEL, + spv::Capability::OptNoneINTEL, + spv::Capability::AtomicFloat16AddEXT, + spv::Capability::DebugInfoModuleINTEL, + spv::Capability::SplitBarrierINTEL, + spv::Capability::GroupUniformArithmeticKHR, + spv::Capability::Max, +}; + +namespace { +std::vector enumerateValuesFromToWithStep(size_t start, size_t end, + size_t step) { + assert(end > start && "end > start"); + std::vector orderedValues; + for (size_t i = start; i < end; i += step) { + orderedValues.push_back(static_cast(i)); + } + return orderedValues; +} + +EnumSet createSetUnorderedInsertion( + const std::vector& values) { + std::vector shuffledValues(values.cbegin(), values.cend()); + std::mt19937 rng(0); + std::shuffle(shuffledValues.begin(), shuffledValues.end(), rng); + EnumSet set; + for (auto value : shuffledValues) { + set.insert(value); + } + return set; +} +} // namespace + TEST(EnumSet, IsEmpty1) { - EnumSet set; - EXPECT_TRUE(set.IsEmpty()); - set.Add(0); - EXPECT_FALSE(set.IsEmpty()); + EnumSet set; + EXPECT_TRUE(set.empty()); + set.insert(TestEnum::ZERO); + EXPECT_FALSE(set.empty()); } TEST(EnumSet, IsEmpty2) { - EnumSet set; - EXPECT_TRUE(set.IsEmpty()); - set.Add(150); - EXPECT_FALSE(set.IsEmpty()); + EnumSet set; + EXPECT_TRUE(set.empty()); + set.insert(TestEnum::ONE_HUNDRED_FIFTY); + EXPECT_FALSE(set.empty()); } TEST(EnumSet, IsEmpty3) { - EnumSet set(4); - EXPECT_FALSE(set.IsEmpty()); + EnumSet set(TestEnum::FOUR); + EXPECT_FALSE(set.empty()); } TEST(EnumSet, IsEmpty4) { - EnumSet set(300); - EXPECT_FALSE(set.IsEmpty()); + EnumSet set(TestEnum::THREE_HUNDRED); + EXPECT_FALSE(set.empty()); } TEST(EnumSetHasAnyOf, EmptySetEmptyQuery) { - const EnumSet set; - const EnumSet empty; + const EnumSet set; + const EnumSet empty; EXPECT_TRUE(set.HasAnyOf(empty)); - EXPECT_TRUE(EnumSet().HasAnyOf(EnumSet())); + EXPECT_TRUE(EnumSet().HasAnyOf(EnumSet())); } TEST(EnumSetHasAnyOf, MaskSetEmptyQuery) { - EnumSet set; - const EnumSet empty; - set.Add(5); - set.Add(8); + EnumSet set; + const EnumSet empty; + set.insert(TestEnum::FIVE); + set.insert(TestEnum::EIGHT); EXPECT_TRUE(set.HasAnyOf(empty)); } TEST(EnumSetHasAnyOf, OverflowSetEmptyQuery) { - EnumSet set; - const EnumSet empty; - set.Add(200); - set.Add(300); + EnumSet set; + const EnumSet empty; + set.insert(TestEnum::TWO_HUNDRED); + set.insert(TestEnum::THREE_HUNDRED); EXPECT_TRUE(set.HasAnyOf(empty)); } TEST(EnumSetHasAnyOf, EmptyQuery) { - EnumSet set; - const EnumSet empty; - set.Add(5); - set.Add(8); - set.Add(200); - set.Add(300); + EnumSet set; + const EnumSet empty; + set.insert(TestEnum::FIVE); + set.insert(TestEnum::EIGHT); + set.insert(TestEnum::TWO_HUNDRED); + set.insert(TestEnum::THREE_HUNDRED); EXPECT_TRUE(set.HasAnyOf(empty)); } TEST(EnumSetHasAnyOf, EmptyQueryAlwaysTrue) { - EnumSet set; - const EnumSet empty; + EnumSet set; + const EnumSet empty; EXPECT_TRUE(set.HasAnyOf(empty)); - set.Add(5); + set.insert(TestEnum::FIVE); EXPECT_TRUE(set.HasAnyOf(empty)); - EXPECT_TRUE(EnumSet(100).HasAnyOf(EnumSet())); + EXPECT_TRUE( + EnumSet(TestEnum::ONE_HUNDRED).HasAnyOf(EnumSet())); } TEST(EnumSetHasAnyOf, ReflexiveMask) { - EnumSet set(3); - set.Add(24); - set.Add(30); + EnumSet set(TestEnum::THREE); + set.insert(TestEnum::TWENTY_FOUR); + set.insert(TestEnum::THIRTY); EXPECT_TRUE(set.HasAnyOf(set)); } TEST(EnumSetHasAnyOf, ReflexiveOverflow) { - EnumSet set(200); - set.Add(300); - set.Add(400); + EnumSet set(TestEnum::TWO_HUNDRED); + set.insert(TestEnum::TWO_HUNDRED); + set.insert(TestEnum::FOUR_HUNDRED); EXPECT_TRUE(set.HasAnyOf(set)); } TEST(EnumSetHasAnyOf, Reflexive) { - EnumSet set(3); - set.Add(24); - set.Add(300); - set.Add(400); + EnumSet set(TestEnum::THREE); + set.insert(TestEnum::TWENTY_FOUR); + set.insert(TestEnum::THREE_HUNDRED); + set.insert(TestEnum::FOUR_HUNDRED); EXPECT_TRUE(set.HasAnyOf(set)); } TEST(EnumSetHasAnyOf, EmptySetHasNone) { - EnumSet set; - EnumSet items; + EnumSet set; + EnumSet items; for (uint32_t i = 0; i < 200; ++i) { - items.Add(i); + TestEnum enumValue = static_cast(i); + items.insert(enumValue); EXPECT_FALSE(set.HasAnyOf(items)); - EXPECT_FALSE(set.HasAnyOf(EnumSet(i))); + EXPECT_FALSE(set.HasAnyOf(EnumSet(enumValue))); } } TEST(EnumSetHasAnyOf, MaskSetMaskQuery) { - EnumSet set(0); - EnumSet items(1); + EnumSet set(TestEnum::ZERO); + EnumSet items(TestEnum::ONE); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(2); - items.Add(3); + set.insert(TestEnum::TWO); + items.insert(TestEnum::THREE); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(3); + set.insert(TestEnum::THREE); EXPECT_TRUE(set.HasAnyOf(items)); - set.Add(4); + set.insert(TestEnum::FOUR); EXPECT_TRUE(set.HasAnyOf(items)); } TEST(EnumSetHasAnyOf, OverflowSetOverflowQuery) { - EnumSet set(100); - EnumSet items(200); + EnumSet set(TestEnum::ONE_HUNDRED); + EnumSet items(TestEnum::TWO_HUNDRED); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(300); - items.Add(400); + set.insert(TestEnum::THREE_HUNDRED); + items.insert(TestEnum::FOUR_HUNDRED); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(200); + set.insert(TestEnum::TWO_HUNDRED); EXPECT_TRUE(set.HasAnyOf(items)); - set.Add(500); + set.insert(TestEnum::FIVE_HUNDRED); EXPECT_TRUE(set.HasAnyOf(items)); } TEST(EnumSetHasAnyOf, GeneralCase) { - EnumSet set(0); - EnumSet items(100); + EnumSet set(TestEnum::ZERO); + EnumSet items(TestEnum::ONE_HUNDRED); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(300); - items.Add(4); + set.insert(TestEnum::THREE_HUNDRED); + items.insert(TestEnum::FOUR); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(5); - items.Add(500); + set.insert(TestEnum::FIVE); + items.insert(TestEnum::FIVE_HUNDRED); EXPECT_FALSE(set.HasAnyOf(items)); - set.Add(500); + set.insert(TestEnum::FIVE_HUNDRED); EXPECT_TRUE(set.HasAnyOf(items)); - EXPECT_FALSE(set.HasAnyOf(EnumSet(20))); - EXPECT_FALSE(set.HasAnyOf(EnumSet(600))); - EXPECT_TRUE(set.HasAnyOf(EnumSet(5))); - EXPECT_TRUE(set.HasAnyOf(EnumSet(300))); - EXPECT_TRUE(set.HasAnyOf(EnumSet(0))); + EXPECT_FALSE(set.HasAnyOf(EnumSet(TestEnum::TWENTY))); + EXPECT_FALSE(set.HasAnyOf(EnumSet(TestEnum::SIX_HUNDRED))); + EXPECT_TRUE(set.HasAnyOf(EnumSet(TestEnum::FIVE))); + EXPECT_TRUE(set.HasAnyOf(EnumSet(TestEnum::THREE_HUNDRED))); + EXPECT_TRUE(set.HasAnyOf(EnumSet(TestEnum::ZERO))); } TEST(EnumSet, DefaultIsEmpty) { - EnumSet set; + EnumSet set; for (uint32_t i = 0; i < 1000; ++i) { - EXPECT_FALSE(set.Contains(i)); + EXPECT_FALSE(set.contains(static_cast(i))); + } +} + +TEST(EnumSet, EqualityCompareEmpty) { + EnumSet set1; + EnumSet set2; + + EXPECT_TRUE(set1 == set2); + EXPECT_FALSE(set1 != set2); +} + +TEST(EnumSet, EqualityCompareSame) { + EnumSet set1; + EnumSet set2; + + set1.insert(TestEnum::ONE); + set1.insert(TestEnum::TWENTY); + set2.insert(TestEnum::TWENTY); + set2.insert(TestEnum::ONE); + + EXPECT_TRUE(set1 == set2); + EXPECT_FALSE(set1 != set2); +} + +TEST(EnumSet, EqualityCompareDifferent) { + EnumSet set1; + EnumSet set2; + + set1.insert(TestEnum::ONE); + set1.insert(TestEnum::TWENTY); + set2.insert(TestEnum::FIVE); + set2.insert(TestEnum::ONE); + + EXPECT_FALSE(set1 == set2); + EXPECT_TRUE(set1 != set2); +} + +TEST(EnumSet, ConstructFromIterators) { + auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1); + EnumSet set1 = createSetUnorderedInsertion(orderedValues); + + EnumSet set2(orderedValues.cbegin(), orderedValues.cend()); + + EXPECT_EQ(set1, set2); +} + +TEST(EnumSet, InsertUsingIteratorRange) { + auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1); + EnumSet set1 = createSetUnorderedInsertion(orderedValues); + + EnumSet set2; + set2.insert(orderedValues.cbegin(), orderedValues.cend()); + + EXPECT_EQ(set1, set2); +} + +TEST(CapabilitySet, RangeBasedLoopOrderIsEnumOrder) { + auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1); + auto set = createSetUnorderedInsertion(orderedValues); + + size_t index = 0; + for (auto value : set) { + ASSERT_THAT(value, Eq(orderedValues[index])); + index++; } } TEST(CapabilitySet, ConstructSingleMemberMatrix) { CapabilitySet s(spv::Capability::Matrix); - EXPECT_TRUE(s.Contains(spv::Capability::Matrix)); - EXPECT_FALSE(s.Contains(spv::Capability::Shader)); - EXPECT_FALSE(s.Contains(static_cast(1000))); + EXPECT_TRUE(s.contains(spv::Capability::Matrix)); + EXPECT_FALSE(s.contains(spv::Capability::Shader)); + EXPECT_FALSE(s.contains(static_cast(1000))); } TEST(CapabilitySet, ConstructSingleMemberMaxInMask) { CapabilitySet s(static_cast(63)); - EXPECT_FALSE(s.Contains(spv::Capability::Matrix)); - EXPECT_FALSE(s.Contains(spv::Capability::Shader)); - EXPECT_TRUE(s.Contains(static_cast(63))); - EXPECT_FALSE(s.Contains(static_cast(64))); - EXPECT_FALSE(s.Contains(static_cast(1000))); + EXPECT_FALSE(s.contains(spv::Capability::Matrix)); + EXPECT_FALSE(s.contains(spv::Capability::Shader)); + EXPECT_TRUE(s.contains(static_cast(63))); + EXPECT_FALSE(s.contains(static_cast(64))); + EXPECT_FALSE(s.contains(static_cast(1000))); } TEST(CapabilitySet, ConstructSingleMemberMinOverflow) { // Check the first one that forces overflow beyond the mask. CapabilitySet s(static_cast(64)); - EXPECT_FALSE(s.Contains(spv::Capability::Matrix)); - EXPECT_FALSE(s.Contains(spv::Capability::Shader)); - EXPECT_FALSE(s.Contains(static_cast(63))); - EXPECT_TRUE(s.Contains(static_cast(64))); - EXPECT_FALSE(s.Contains(static_cast(1000))); + EXPECT_FALSE(s.contains(spv::Capability::Matrix)); + EXPECT_FALSE(s.contains(spv::Capability::Shader)); + EXPECT_FALSE(s.contains(static_cast(63))); + EXPECT_TRUE(s.contains(static_cast(64))); + EXPECT_FALSE(s.contains(static_cast(1000))); } TEST(CapabilitySet, ConstructSingleMemberMaxOverflow) { // Check the max 32-bit signed int. CapabilitySet s(static_cast(0x7fffffffu)); - EXPECT_FALSE(s.Contains(spv::Capability::Matrix)); - EXPECT_FALSE(s.Contains(spv::Capability::Shader)); - EXPECT_FALSE(s.Contains(static_cast(1000))); - EXPECT_TRUE(s.Contains(static_cast(0x7fffffffu))); + EXPECT_FALSE(s.contains(spv::Capability::Matrix)); + EXPECT_FALSE(s.contains(spv::Capability::Shader)); + EXPECT_FALSE(s.contains(static_cast(1000))); + EXPECT_TRUE(s.contains(static_cast(0x7fffffffu))); } TEST(CapabilitySet, AddEnum) { CapabilitySet s(spv::Capability::Shader); - s.Add(spv::Capability::Kernel); - s.Add(static_cast(42)); - EXPECT_FALSE(s.Contains(spv::Capability::Matrix)); - EXPECT_TRUE(s.Contains(spv::Capability::Shader)); - EXPECT_TRUE(s.Contains(spv::Capability::Kernel)); - EXPECT_TRUE(s.Contains(static_cast(42))); + s.insert(spv::Capability::Kernel); + s.insert(static_cast(42)); + EXPECT_FALSE(s.contains(spv::Capability::Matrix)); + EXPECT_TRUE(s.contains(spv::Capability::Shader)); + EXPECT_TRUE(s.contains(spv::Capability::Kernel)); + EXPECT_TRUE(s.contains(static_cast(42))); +} + +TEST(CapabilitySet, InsertReturnsIteratorToInserted) { + CapabilitySet set; + + auto[it, inserted] = set.insert(spv::Capability::Kernel); + + EXPECT_TRUE(inserted); + EXPECT_EQ(*it, spv::Capability::Kernel); +} + +TEST(CapabilitySet, InsertReturnsIteratorToElementOnDoubleInsertion) { + CapabilitySet set; + EXPECT_FALSE(set.contains(spv::Capability::Shader)); + { + auto[it, inserted] = set.insert(spv::Capability::Shader); + EXPECT_TRUE(inserted); + EXPECT_EQ(*it, spv::Capability::Shader); + } + EXPECT_TRUE(set.contains(spv::Capability::Shader)); + + auto[it, inserted] = set.insert(spv::Capability::Shader); + + EXPECT_FALSE(inserted); + EXPECT_EQ(*it, spv::Capability::Shader); + EXPECT_TRUE(set.contains(spv::Capability::Shader)); +} + +TEST(CapabilitySet, InsertWithHintWorks) { + CapabilitySet set; + EXPECT_FALSE(set.contains(spv::Capability::Shader)); + + auto it = set.insert(set.begin(), spv::Capability::Shader); + + EXPECT_EQ(*it, spv::Capability::Shader); + EXPECT_TRUE(set.contains(spv::Capability::Shader)); +} + +TEST(CapabilitySet, InsertWithEndHintWorks) { + CapabilitySet set; + EXPECT_FALSE(set.contains(spv::Capability::Shader)); + + auto it = set.insert(set.end(), spv::Capability::Shader); + + EXPECT_EQ(*it, spv::Capability::Shader); + EXPECT_TRUE(set.contains(spv::Capability::Shader)); +} + +TEST(CapabilitySet, IteratorCanBeCopied) { + CapabilitySet set; + set.insert(spv::Capability::Matrix); + set.insert(spv::Capability::Shader); + set.insert(spv::Capability::Geometry); + set.insert(spv::Capability::Float64); + set.insert(spv::Capability::Float16); + + auto a = set.begin(); + ++a; + auto b = a; + + EXPECT_EQ(*b, *a); + ++b; + EXPECT_NE(*b, *a); + + ++a; + EXPECT_EQ(*b, *a); + + ++a; + EXPECT_NE(*b, *a); +} + +TEST(CapabilitySet, IteratorBeginToEndPostfix) { + auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 1); + auto set = createSetUnorderedInsertion(orderedValues); + + size_t index = 0; + for (auto it = set.cbegin(); it != set.cend(); it++, index++) { + EXPECT_EQ(*it, orderedValues[index]); + } +} + +TEST(CapabilitySet, IteratorBeginToEndPrefix) { + auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 1); + auto set = createSetUnorderedInsertion(orderedValues); + + size_t index = 0; + for (auto it = set.cbegin(); it != set.cend(); ++it, index++) { + EXPECT_EQ(*it, orderedValues[index]); + } +} + +TEST(CapabilitySet, IteratorBeginToEndPrefixStep) { + auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 8); + auto set = createSetUnorderedInsertion(orderedValues); + + size_t index = 0; + for (auto it = set.cbegin(); it != set.cend(); ++it, index++) { + ASSERT_EQ(*it, orderedValues[index]); + } +} + +TEST(CapabilitySet, IteratorBeginOnEmpty) { + CapabilitySet set; + + auto begin = set.begin(); + auto end = set.end(); + ASSERT_EQ(begin, end); +} + +TEST(CapabilitySet, IteratorBeginOnSingleNonZeroValue) { + CapabilitySet set; + set.insert(spv::Capability::Shader); + + auto begin = set.begin(); + auto end = set.end(); + + ASSERT_NE(begin, end); + ASSERT_EQ(*begin, spv::Capability::Shader); +} + +TEST(CapabilitySet, IteratorForLoopNonZeroValue) { + CapabilitySet set; + set.insert(spv::Capability::Shader); + set.insert(spv::Capability::Tessellation); + + auto begin = set.begin(); + auto end = set.end(); + + ASSERT_NE(begin, end); + ASSERT_EQ(*begin, spv::Capability::Shader); + + begin++; + ASSERT_NE(begin, end); + ASSERT_EQ(*begin, spv::Capability::Tessellation); + + begin++; + ASSERT_EQ(begin, end); +} + +TEST(CapabilitySet, IteratorPastEnd) { + CapabilitySet set; + set.insert(spv::Capability::Shader); + + auto begin = set.begin(); + auto end = set.end(); + + ASSERT_NE(begin, end); + ASSERT_EQ(*begin, spv::Capability::Shader); + + begin++; + ASSERT_EQ(begin, end); + + begin++; + ASSERT_EQ(begin, end); +} + +TEST(CapabilitySet, CompatibleWithSTLFind) { + CapabilitySet set; + set.insert(spv::Capability::Matrix); + set.insert(spv::Capability::Shader); + set.insert(spv::Capability::Geometry); + set.insert(spv::Capability::Tessellation); + set.insert(spv::Capability::Addresses); + set.insert(spv::Capability::Linkage); + set.insert(spv::Capability::Kernel); + set.insert(spv::Capability::Vector16); + set.insert(spv::Capability::Float16Buffer); + set.insert(spv::Capability::Float64); + + { + auto it = std::find(set.cbegin(), set.cend(), spv::Capability::Vector16); + ASSERT_NE(it, set.end()); + ASSERT_EQ(*it, spv::Capability::Vector16); + } + + { + auto it = std::find(set.cbegin(), set.cend(), spv::Capability::Float16); + ASSERT_EQ(it, set.end()); + } +} + +TEST(CapabilitySet, CompatibleWithSTLForEach) { + auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 15); + auto set = createSetUnorderedInsertion(orderedValues); + + size_t index = 0; + std::for_each(set.cbegin(), set.cend(), [&](auto item) { + ASSERT_EQ(item, orderedValues[index]); + index++; + }); } TEST(CapabilitySet, InitializerListEmpty) { CapabilitySet s{}; for (uint32_t i = 0; i < 1000; i++) { - EXPECT_FALSE(s.Contains(static_cast(i))); + EXPECT_FALSE(s.contains(static_cast(i))); + } +} + +TEST(CapabilitySet, LargeSetHasInsertedElements) { + CapabilitySet set; + for (auto c : kCapabilities) { + EXPECT_FALSE(set.contains(c)); + } + + for (auto c : kCapabilities) { + set.insert(c); + EXPECT_TRUE(set.contains(c)); + } + + for (auto c : kCapabilities) { + EXPECT_TRUE(set.contains(c)); + } +} + +TEST(CapabilitySet, LargeSetHasUnsortedInsertedElements) { + std::vector shuffledCapabilities(kCapabilities.cbegin(), + kCapabilities.cend()); + std::mt19937 rng(0); + std::shuffle(shuffledCapabilities.begin(), shuffledCapabilities.end(), rng); + CapabilitySet set; + for (auto c : shuffledCapabilities) { + EXPECT_FALSE(set.contains(c)); + } + + for (auto c : shuffledCapabilities) { + set.insert(c); + EXPECT_TRUE(set.contains(c)); + } + + for (auto c : shuffledCapabilities) { + EXPECT_TRUE(set.contains(c)); + } +} + +TEST(CapabilitySet, LargeSetHasUnsortedRemovedElement) { + std::vector shuffledCapabilities(kCapabilities.cbegin(), + kCapabilities.cend()); + std::mt19937 rng(0); + std::shuffle(shuffledCapabilities.begin(), shuffledCapabilities.end(), rng); + CapabilitySet set; + for (auto c : shuffledCapabilities) { + set.insert(c); + EXPECT_TRUE(set.contains(c)); + } + + for (auto c : kCapabilities) { + set.erase(c); + } + + for (auto c : shuffledCapabilities) { + EXPECT_FALSE(set.contains(c)); } } @@ -251,9 +846,6 @@ TEST_P(CapabilitySetForEachTest, MoveConstructor) { CapabilitySet copy(GetParam().capabilities); CapabilitySet moved(std::move(copy)); EXPECT_THAT(ElementsIn(moved), Eq(GetParam().expected)); - - // The moved-from set is empty. - EXPECT_THAT(ElementsIn(copy), Eq(std::vector{})); } TEST_P(CapabilitySetForEachTest, OperatorEquals) { @@ -263,7 +855,7 @@ TEST_P(CapabilitySetForEachTest, OperatorEquals) { TEST_P(CapabilitySetForEachTest, OperatorEqualsSelfAssign) { CapabilitySet assigned{GetParam().capabilities}; - assigned = assigned; + assigned = assigned; // NOLINT EXPECT_THAT(ElementsIn(assigned), Eq(GetParam().expected)); } @@ -287,5 +879,20 @@ INSTANTIATE_TEST_SUITE_P( static_cast(0x7fffffff)}}, })); +using BoundaryTestWithParam = ::testing::TestWithParam; + +TEST_P(BoundaryTestWithParam, InsertedContains) { + CapabilitySet set; + set.insert(GetParam()); + EXPECT_TRUE(set.contains(GetParam())); +} + +INSTANTIATE_TEST_SUITE_P( + Samples, BoundaryTestWithParam, + Values(static_cast(0), static_cast(63), + static_cast(64), static_cast(65), + static_cast(127), static_cast(128), + static_cast(129))); + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/ext_inst.non_semantic_test.cpp b/third_party/spirv-tools/test/ext_inst.non_semantic_test.cpp index 870684e9bf..506218933e 100644 --- a/third_party/spirv-tools/test/ext_inst.non_semantic_test.cpp +++ b/third_party/spirv-tools/test/ext_inst.non_semantic_test.cpp @@ -41,8 +41,7 @@ TEST_F(NonSemanticRoundTripTest, NonSemanticInsts) { %8 = OpExtInstImport "NonSemantic.Testing.AnotherUnknownExtInstSet" %9 = OpExtInst %4 %8 613874321 %7 %5 %6 )"; - std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_0); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } diff --git a/third_party/spirv-tools/test/fuzz/CMakeLists.txt b/third_party/spirv-tools/test/fuzz/CMakeLists.txt index 56af0b9dd6..6232d6c4dd 100644 --- a/third_party/spirv-tools/test/fuzz/CMakeLists.txt +++ b/third_party/spirv-tools/test/fuzz/CMakeLists.txt @@ -123,7 +123,8 @@ if (${SPIRV_BUILD_FUZZER}) transformation_wrap_early_terminator_in_function_test.cpp transformation_wrap_region_in_selection_test.cpp transformation_wrap_vector_synonym_test.cpp - uniform_buffer_element_descriptor_test.cpp) + uniform_buffer_element_descriptor_test.cpp + ${spirv-tools_SOURCE_DIR}/tools/io.cpp) if (${SPIRV_ENABLE_LONG_FUZZER_TESTS}) # These are long-running tests that depend on random seeds. We do not want diff --git a/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp b/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp index 93c9c584d9..b238455dbb 100644 --- a/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp +++ b/third_party/spirv-tools/test/fuzz/fuzz_test_util.cpp @@ -145,7 +145,7 @@ void DumpTransformationsJson( const protobufs::TransformationSequence& transformations, const char* filename) { std::string json_string; - auto json_options = google::protobuf::util::JsonOptions(); + auto json_options = google::protobuf::util::JsonPrintOptions(); json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations, &json_string, json_options); diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_dead_block_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_dead_block_test.cpp index 3c9e6b43c4..534ad6932c 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_dead_block_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_dead_block_test.cpp @@ -295,11 +295,16 @@ TEST(TransformationAddDeadBlockTest, TargetBlockMustNotBeLoopMergeOrContinue) { OpBranch %8 %8 = OpLabel OpLoopMerge %12 %11 None + OpBranch %13 + %13 = OpLabel + OpSelectionMerge %14 None OpBranchConditional %5 %9 %10 %9 = OpLabel OpBranch %11 %10 = OpLabel OpBranch %12 + %14 = OpLabel + OpUnreachable %11 = OpLabel OpBranch %8 %12 = OpLabel diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_dead_break_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_dead_break_test.cpp index 5302d8a6e3..fd46c96aa1 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_dead_break_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_dead_break_test.cpp @@ -2743,6 +2743,9 @@ TEST(TransformationAddDeadBreakTest, RespectDominanceRules7) { OpBranch %100 %100 = OpLabel OpLoopMerge %101 %104 None + OpBranch %105 + %105 = OpLabel + OpSelectionMerge %106 None OpBranchConditional %11 %102 %103 %103 = OpLabel %200 = OpCopyObject %10 %11 @@ -2752,6 +2755,8 @@ TEST(TransformationAddDeadBreakTest, RespectDominanceRules7) { OpReturn %102 = OpLabel OpBranch %103 + %106 = OpLabel + OpUnreachable %104 = OpLabel OpBranch %100 OpFunctionEnd @@ -2791,12 +2796,17 @@ TEST(TransformationAddDeadBreakTest, RespectDominanceRules8) { OpBranch %100 %100 = OpLabel OpLoopMerge %101 %104 None + OpBranch %105 + %105 = OpLabel + OpSelectionMerge %106 None OpBranchConditional %11 %102 %103 %103 = OpLabel %200 = OpCopyObject %10 %11 OpBranch %101 %102 = OpLabel OpBranch %103 + %106 = OpLabel + OpUnreachable %101 = OpLabel %201 = OpCopyObject %10 %200 OpReturn diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_no_contraction_decoration_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_no_contraction_decoration_test.cpp index 4fc9d2d56f..1280b815e0 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_no_contraction_decoration_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_no_contraction_decoration_test.cpp @@ -36,7 +36,6 @@ TEST(TransformationAddNoContractionDecorationTest, BasicScenarios) { OpName %8 "x" OpName %10 "y" OpName %14 "i" - OpDecorate %32 NoContraction %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 @@ -110,9 +109,8 @@ TEST(TransformationAddNoContractionDecorationTest, BasicScenarios) { ASSERT_FALSE(TransformationAddNoContractionDecoration(24).IsApplicable( context.get(), transformation_context)); - // It is valid to add NoContraction to each of these ids (and it's fine to - // have duplicates of the decoration, in the case of 32). - for (uint32_t result_id : {32u, 32u, 27u, 29u, 39u}) { + // It is valid to add NoContraction to each of these ids. + for (uint32_t result_id : {32u, 27u, 29u, 39u}) { TransformationAddNoContractionDecoration transformation(result_id); ASSERT_TRUE( transformation.IsApplicable(context.get(), transformation_context)); @@ -134,8 +132,6 @@ TEST(TransformationAddNoContractionDecorationTest, BasicScenarios) { OpName %10 "y" OpName %14 "i" OpDecorate %32 NoContraction - OpDecorate %32 NoContraction - OpDecorate %32 NoContraction OpDecorate %27 NoContraction OpDecorate %29 NoContraction OpDecorate %39 NoContraction diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_opphi_synonym_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_opphi_synonym_test.cpp index 4aca30ce61..03fd39a12d 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_opphi_synonym_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_opphi_synonym_test.cpp @@ -365,8 +365,7 @@ TEST(TransformationAddOpPhiSynonymTest, VariablePointers) { MakeSynonymFact(12, 16)); // Remove the VariablePointers capability. - context.get()->get_feature_mgr()->RemoveCapability( - spv::Capability::VariablePointers); + context.get()->RemoveCapability(spv::Capability::VariablePointers); // The VariablePointers capability is required to add an OpPhi instruction of // pointer type. @@ -374,8 +373,7 @@ TEST(TransformationAddOpPhiSynonymTest, VariablePointers) { .IsApplicable(context.get(), transformation_context)); // Add the VariablePointers capability back. - context.get()->get_feature_mgr()->AddCapability( - spv::Capability::VariablePointers); + context.get()->AddCapability(spv::Capability::VariablePointers); // If the ids have pointer type, the storage class must be Workgroup or // StorageBuffer, but it is Function in this case. diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_relaxed_decoration_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_relaxed_decoration_test.cpp index c4408827f5..979eeb7227 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_relaxed_decoration_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_relaxed_decoration_test.cpp @@ -86,9 +86,8 @@ TEST(TransformationAddRelaxedDecorationTest, BasicScenarios) { // Invalid: 28 is in a dead block, but returns bool (not numeric). ASSERT_FALSE(TransformationAddRelaxedDecoration(28).IsApplicable( context.get(), transformation_context)); - // It is valid to add RelaxedPrecision to 25 (and it's fine to - // have a duplicate). - for (uint32_t result_id : {25u, 25u}) { + // It is valid to add RelaxedPrecision to 25 + for (uint32_t result_id : {25u}) { TransformationAddRelaxedDecoration transformation(result_id); ASSERT_TRUE( transformation.IsApplicable(context.get(), transformation_context)); @@ -110,7 +109,6 @@ TEST(TransformationAddRelaxedDecorationTest, BasicScenarios) { OpName %10 "b" OpName %14 "c" OpDecorate %25 RelaxedPrecision - OpDecorate %25 RelaxedPrecision %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_type_float_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_type_float_test.cpp index 75f37887ae..135190acbf 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_type_float_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_type_float_test.cpp @@ -74,7 +74,7 @@ TEST(TransformationAddTypeFloatTest, IsApplicable) { // By default, SPIR-V does not support 64-bit float types. // Below we add such capability, so the test should now pass. - context.get()->get_feature_mgr()->AddCapability(spv::Capability::Float64); + context.get()->AddCapability(spv::Capability::Float64); ASSERT_TRUE(TransformationAddTypeFloat(7, 64).IsApplicable( context.get(), transformation_context)); diff --git a/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp b/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp index b41d420371..e31730cc2f 100644 --- a/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp +++ b/third_party/spirv-tools/test/fuzz/transformation_add_type_int_test.cpp @@ -88,13 +88,13 @@ TEST(TransformationAddTypeIntTest, IsApplicable) { // By default SPIR-V does not support 16-bit integers. // Below we add such capability, so the test should now be successful. - context.get()->get_feature_mgr()->AddCapability(spv::Capability::Int16); + context.get()->AddCapability(spv::Capability::Int16); ASSERT_TRUE(TransformationAddTypeInt(7, 16, true) .IsApplicable(context.get(), transformation_context)); // By default SPIR-V does not support 64-bit integers. // Below we add such capability, so the test should now pass. - context.get()->get_feature_mgr()->AddCapability(spv::Capability::Int64); + context.get()->AddCapability(spv::Capability::Int64); ASSERT_TRUE(TransformationAddTypeInt(7, 64, true) .IsApplicable(context.get(), transformation_context)); diff --git a/third_party/spirv-tools/test/hex_float_test.cpp b/third_party/spirv-tools/test/hex_float_test.cpp index 25d3c707a7..a44d9ec793 100644 --- a/third_party/spirv-tools/test/hex_float_test.cpp +++ b/third_party/spirv-tools/test/hex_float_test.cpp @@ -1348,9 +1348,11 @@ std::ostream& operator<<(std::ostream& os, const StreamParseCase& fspc) { return os; } -using FloatStreamParseTest = ::testing::TestWithParam>; +using Float32StreamParseTest = ::testing::TestWithParam>; +using Float16StreamParseTest = + ::testing::TestWithParam>; -TEST_P(FloatStreamParseTest, Samples) { +TEST_P(Float32StreamParseTest, Samples) { std::stringstream input(GetParam().literal); HexFloat> parsed_value(0.0f); // Hex floats must be read with the stream input operator. @@ -1367,8 +1369,87 @@ TEST_P(FloatStreamParseTest, Samples) { } } +// Returns a Float16 constructed from its sign bit, unbiased exponent, and +// mantissa. +Float16 makeF16(int sign_bit, int unbiased_exp, int mantissa) { + EXPECT_LE(0, sign_bit); + EXPECT_LE(sign_bit, 1); + // Exponent is 5 bits, with bias of 15. + EXPECT_LE(-15, unbiased_exp); // -15 means zero or subnormal + EXPECT_LE(unbiased_exp, 16); // 16 means infinity or NaN + EXPECT_LE(0, mantissa); + EXPECT_LE(mantissa, 0x3ff); + const unsigned biased_exp = 15 + unbiased_exp; + const uint32_t as_bits = sign_bit << 15 | (biased_exp << 10) | mantissa; + EXPECT_LE(as_bits, 0xffffu); + return Float16(static_cast(as_bits)); +} + +TEST_P(Float16StreamParseTest, Samples) { + std::stringstream input(GetParam().literal); + HexFloat> parsed_value(makeF16(0, 0, 0)); + // Hex floats must be read with the stream input operator. + input >> parsed_value; + if (GetParam().expect_success) { + EXPECT_FALSE(input.fail()); + std::string suffix; + input >> suffix; + const auto got = parsed_value.value(); + const auto expected = GetParam().expected_value.value(); + EXPECT_EQ(got.data(), expected.data()) + << "got: " << got << " expected: " << expected; + } else { + EXPECT_TRUE(input.fail()); + } +} + INSTANTIATE_TEST_SUITE_P( - HexFloatExponentMissingDigits, FloatStreamParseTest, + HexFloat32FillSignificantDigits, Float32StreamParseTest, + ::testing::ValuesIn(std::vector>{ + {"0x123456p0", true, "", ldexpf(0x123456, 0)}, + // Patterns that fill all mantissa bits + {"0x1.fffffep+23", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1f.ffffep+19", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1ff.fffep+15", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1fff.ffep+11", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1ffff.fep+7", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1fffff.ep+3", true, "", ldexpf(0x1fffffe, -1)}, + {"0x1fffffe.p-1", true, "", ldexpf(0x1fffffe, -1)}, + {"0xffffff.p+0", true, "", ldexpf(0x1fffffe, -1)}, + {"0xffffff.p+0", true, "", ldexpf(0xffffff, 0)}, + // Now drop some bits in the middle + {"0xa5a5a5.p+0", true, "", ldexpf(0xa5a5a5, 0)}, + {"0x5a5a5a.p+0", true, "", ldexpf(0x5a5a5a, 0)}})); + +INSTANTIATE_TEST_SUITE_P( + HexFloat32ExcessSignificantDigits, Float32StreamParseTest, + ::testing::ValuesIn(std::vector>{ + // Base cases + {"0x1.fffffep0", true, "", ldexpf(0xffffff, -23)}, + {"0xa5a5a5p0", true, "", ldexpf(0xa5a5a5, 0)}, + {"0xa.5a5a5p+9", true, "", ldexpf(0xa5a5a5, -11)}, + {"0x5a5a5ap0", true, "", ldexpf(0x5a5a5a, 0)}, + {"0x5.a5a5ap+9", true, "", ldexpf(0x5a5a5a, -11)}, + // Truncate extra bits: zeroes + {"0x1.fffffe0p0", true, "", ldexpf(0xffffff, -23)}, + {"0xa5a5a5000p0", true, "", ldexpf(0xa5a5a5, 12)}, + {"0xa.5a5a5000p+9", true, "", ldexpf(0xa5a5a5, -11)}, + {"0x5a5a5a000p0", true, "", ldexpf(0x5a5a5a, 12)}, + {"0x5.a5a5a000p+9", true, "", ldexpf(0x5a5a5a, -11)}, + // Truncate extra bits: ones + {"0x1.ffffffp0", // Extra bits in the last nibble + true, "", ldexpf(0xffffff, -23)}, + {"0x1.fffffffp0", true, "", ldexpf(0xffffff, -23)}, + {"0xa5a5a5fffp0", true, "", ldexpf(0xa5a5a5, 12)}, + {"0xa.5a5a5fffp+9", true, "", ldexpf(0xa5a5a5, -11)}, + {"0x5a5a5afffp0", + // The 5 nibble (0101), leads with 0, so the result can fit a leading + // 1 bit , yielding 8 (1000). + true, "", ldexpf(0x5a5a5a8, 8)}, + {"0x5.a5a5afffp+9", true, "", ldexpf(0x5a5a5a8, 8 - 32 + 9)}})); + +INSTANTIATE_TEST_SUITE_P( + HexFloat32ExponentMissingDigits, Float32StreamParseTest, ::testing::ValuesIn(std::vector>{ {"0x1.0p1", true, "", 2.0f}, {"0x1.0p1a", true, "a", 2.0f}, @@ -1388,7 +1469,7 @@ INSTANTIATE_TEST_SUITE_P( {"0x1.0p--", false, "", 0.0f}})); INSTANTIATE_TEST_SUITE_P( - HexFloatExponentTrailingSign, FloatStreamParseTest, + HexFloat32ExponentTrailingSign, Float32StreamParseTest, ::testing::ValuesIn(std::vector>{ // Don't consume a sign after the binary exponent digits. {"0x1.0p1", true, "", 2.0f}, @@ -1396,7 +1477,7 @@ INSTANTIATE_TEST_SUITE_P( {"0x1.0p1-", true, "-", 2.0f}})); INSTANTIATE_TEST_SUITE_P( - HexFloatPositiveExponentOverflow, FloatStreamParseTest, + HexFloat32PositiveExponentOverflow, Float32StreamParseTest, ::testing::ValuesIn(std::vector>{ // Positive exponents {"0x1.0p1", true, "", 2.0f}, // fine, a normal number @@ -1412,7 +1493,7 @@ INSTANTIATE_TEST_SUITE_P( })); INSTANTIATE_TEST_SUITE_P( - HexFloatNegativeExponentOverflow, FloatStreamParseTest, + HexFloat32NegativeExponentOverflow, Float32StreamParseTest, ::testing::ValuesIn(std::vector>{ // Positive results, digits before '.' {"0x1.0p-126", true, "", @@ -1436,7 +1517,109 @@ INSTANTIATE_TEST_SUITE_P( {"0x0.0p-5000000000", true, "", 0.0f}, // zero mantissa, zero result })); -// TODO(awoloszyn): Add fp16 tests and HexFloatTraits. +INSTANTIATE_TEST_SUITE_P( + HexFloat16ExcessSignificantDigits, Float16StreamParseTest, + ::testing::ValuesIn(std::vector>{ + // Zero + {"0x1.c00p0", true, "", makeF16(0, 0, 0x300)}, + {"0x0p0", true, "", makeF16(0, -15, 0x0)}, + {"0x000.0000p0", true, "", makeF16(0, -15, 0x0)}, + // All leading 1s + {"0x1p0", true, "", makeF16(0, 0, 0x0)}, + {"0x1.8p0", true, "", makeF16(0, 0, 0x200)}, + {"0x1.cp0", true, "", makeF16(0, 0, 0x300)}, + {"0x1.ep0", true, "", makeF16(0, 0, 0x380)}, + {"0x1.fp0", true, "", makeF16(0, 0, 0x3c0)}, + {"0x1.f8p0", true, "", makeF16(0, 0, 0x3e0)}, + {"0x1.fcp0", true, "", makeF16(0, 0, 0x3f0)}, + {"0x1.fep0", true, "", makeF16(0, 0, 0x3f8)}, + {"0x1.ffp0", true, "", makeF16(0, 0, 0x3fc)}, + // Fill trailing zeros to all significant places + // that might be used for significant digits. + {"0x1.ff8p0", true, "", makeF16(0, 0, 0x3fe)}, + {"0x1.ffcp0", true, "", makeF16(0, 0, 0x3ff)}, + {"0x1.800p0", true, "", makeF16(0, 0, 0x200)}, + {"0x1.c00p0", true, "", makeF16(0, 0, 0x300)}, + {"0x1.e00p0", true, "", makeF16(0, 0, 0x380)}, + {"0x1.f00p0", true, "", makeF16(0, 0, 0x3c0)}, + {"0x1.f80p0", true, "", makeF16(0, 0, 0x3e0)}, + {"0x1.fc0p0", true, "", makeF16(0, 0, 0x3f0)}, + {"0x1.fe0p0", true, "", makeF16(0, 0, 0x3f8)}, + {"0x1.ff0p0", true, "", makeF16(0, 0, 0x3fc)}, + {"0x1.ff8p0", true, "", makeF16(0, 0, 0x3fe)}, + {"0x1.ffcp0", true, "", makeF16(0, 0, 0x3ff)}, + // Add several trailing zeros + {"0x1.c00000p0", true, "", makeF16(0, 0, 0x300)}, + {"0x1.e00000p0", true, "", makeF16(0, 0, 0x380)}, + {"0x1.f00000p0", true, "", makeF16(0, 0, 0x3c0)}, + {"0x1.f80000p0", true, "", makeF16(0, 0, 0x3e0)}, + {"0x1.fc0000p0", true, "", makeF16(0, 0, 0x3f0)}, + {"0x1.fe0000p0", true, "", makeF16(0, 0, 0x3f8)}, + {"0x1.ff0000p0", true, "", makeF16(0, 0, 0x3fc)}, + {"0x1.ff8000p0", true, "", makeF16(0, 0, 0x3fe)}, + {"0x1.ffcp0000", true, "", makeF16(0, 0, 0x3ff)}, + // Samples that drop out bits in the middle. + // 5 = 0101 4 = 0100 + // a = 1010 8 = 1000 + {"0x1.5a4p0", true, "", makeF16(0, 0, 0x169)}, + {"0x1.a58p0", true, "", makeF16(0, 0, 0x296)}, + // Samples that drop out bits *and* truncate significant bits + // that can't be represented. + {"0x1.5a40000p0", true, "", makeF16(0, 0, 0x169)}, + {"0x1.5a7ffffp0", true, "", makeF16(0, 0, 0x169)}, + {"0x1.a580000p0", true, "", makeF16(0, 0, 0x296)}, + {"0x1.a5bffffp0", true, "", makeF16(0, 0, 0x296)}, + // Try some negations. + {"-0x0p0", true, "", makeF16(1, -15, 0x0)}, + {"-0x000.0000p0", true, "", makeF16(1, -15, 0x0)}, + {"-0x1.5a40000p0", true, "", makeF16(1, 0, 0x169)}, + {"-0x1.5a7ffffp0", true, "", makeF16(1, 0, 0x169)}, + {"-0x1.a580000p0", true, "", makeF16(1, 0, 0x296)}, + {"-0x1.a5bffffp0", true, "", makeF16(1, 0, 0x296)}})); + +INSTANTIATE_TEST_SUITE_P( + HexFloat16IncreasingExponentsAndMantissa, Float16StreamParseTest, + ::testing::ValuesIn(std::vector>{ + // Zero + {"0x0p0", true, "", makeF16(0, -15, 0x0)}, + {"0x0p5000000000000", true, "", makeF16(0, -15, 0x0)}, + {"-0x0p5000000000000", true, "", makeF16(1, -15, 0x0)}, + // Leading 1 + {"0x1p0", true, "", makeF16(0, 0, 0x0)}, + {"0x1p1", true, "", makeF16(0, 1, 0x0)}, + {"0x1p16", true, "", makeF16(0, 16, 0x0)}, + {"0x1p-1", true, "", makeF16(0, -1, 0x0)}, + {"0x1p-14", true, "", makeF16(0, -14, 0x0)}, + // Leading 2 + {"0x2p0", true, "", makeF16(0, 1, 0x0)}, + {"0x2p1", true, "", makeF16(0, 2, 0x0)}, + {"0x2p15", true, "", makeF16(0, 16, 0x0)}, + {"0x2p-1", true, "", makeF16(0, 0, 0x0)}, + {"0x2p-15", true, "", makeF16(0, -14, 0x0)}, + // Leading 8 + {"0x8p0", true, "", makeF16(0, 3, 0x0)}, + {"0x8p1", true, "", makeF16(0, 4, 0x0)}, + {"0x8p13", true, "", makeF16(0, 16, 0x0)}, + {"0x8p-3", true, "", makeF16(0, 0, 0x0)}, + {"0x8p-17", true, "", makeF16(0, -14, 0x0)}, + // Leading 10 + {"0x10.0p0", true, "", makeF16(0, 4, 0x0)}, + {"0x10.0p1", true, "", makeF16(0, 5, 0x0)}, + {"0x10.0p12", true, "", makeF16(0, 16, 0x0)}, + {"0x10.0p-5", true, "", makeF16(0, -1, 0x0)}, + {"0x10.0p-18", true, "", makeF16(0, -14, 0x0)}, + // Samples that drop out bits *and* truncate significant bits + // that can't be represented. + // Progressively increase the leading digit. + {"0x1.5a40000p0", true, "", makeF16(0, 0, 0x169)}, + {"0x1.5a7ffffp0", true, "", makeF16(0, 0, 0x169)}, + {"0x2.5a40000p0", true, "", makeF16(0, 1, 0x0b4)}, + {"0x2.5a7ffffp0", true, "", makeF16(0, 1, 0x0b4)}, + {"0x4.5a40000p0", true, "", makeF16(0, 2, 0x05a)}, + {"0x4.5a7ffffp0", true, "", makeF16(0, 2, 0x05a)}, + {"0x8.5a40000p0", true, "", makeF16(0, 3, 0x02d)}, + {"0x8.5a7ffffp0", true, "", makeF16(0, 3, 0x02d)}})); + } // namespace } // namespace utils } // namespace spvtools diff --git a/third_party/spirv-tools/test/hex_to_text_test.cpp b/third_party/spirv-tools/test/hex_to_text_test.cpp new file mode 100644 index 0000000000..cc5c673f8d --- /dev/null +++ b/third_party/spirv-tools/test/hex_to_text_test.cpp @@ -0,0 +1,429 @@ +// Copyright (c) 2024 Google LLC. +// +// 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 + +#include "gmock/gmock.h" +#include "test/test_fixture.h" +#include "tools/io.h" + +namespace spvtools { +namespace { + +using spvtest::ScopedContext; + +class HexToText : public ::testing::Test { + public: + void VerifyDisassembly(const char* hex_stream, + const char* expected_disassembly) { + std::vector stream(hex_stream, hex_stream + strlen(hex_stream)); + std::vector binary; + + // Convert hext to binary first. + EXPECT_TRUE(ConvertHexToBinary(stream, &binary)); + + // Then disassemble it. + spv_diagnostic diagnostic = nullptr; + spv_text disassembly = nullptr; + EXPECT_EQ(spvBinaryToText(ScopedContext().context, binary.data(), + binary.size(), SPV_BINARY_TO_TEXT_OPTION_NONE, + &disassembly, &diagnostic), + SPV_SUCCESS); + EXPECT_EQ(diagnostic, nullptr); + + // Verify disassembly is as expected and clean up. + EXPECT_STREQ(disassembly->str, expected_disassembly); + + spvDiagnosticDestroy(diagnostic); + spvTextDestroy(disassembly); + } + + void EnsureError(const char* hex_stream) { + std::vector stream(hex_stream, hex_stream + strlen(hex_stream)); + std::vector binary; + + // Make sure there is a parse error + EXPECT_FALSE(ConvertHexToBinary(stream, &binary)); + } +}; + +// The actual assembly doesn't matter, just the hex parsing. All the tests use +// the following SPIR-V. +constexpr char kDisassembly[] = R"(; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 11 +; Schema: 0 +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %1 "main" %2 %3 +OpName %2 "fancy_attribute" +OpName %3 "useful_output" +OpDecorate %2 Location 4 +OpDecorate %3 Location 2 +%4 = OpTypeFloat 32 +%5 = OpTypePointer Input %4 +%2 = OpVariable %5 Input +%6 = OpTypePointer Output %4 +%3 = OpVariable %6 Output +%7 = OpTypeVoid +%8 = OpTypeFunction %7 +%1 = OpFunction %7 None %8 +%9 = OpLabel +%10 = OpLoad %4 %2 +OpStore %3 %10 +OpReturn +OpFunctionEnd +)"; + +TEST_F(HexToText, Words) { + constexpr char kHex[] = R"(0x07230203, 0x00010600, 0x00070000, 0x0000000b +0x00000000, 0x00020011, 0x00000001, 0x0003000e +0x00000000, 0x00000001, 0x0007000f, 0x00000000 +0x00000001, 0x6e69616d, 0x00000000, 0x00000002 +0x00000003, 0x00060005, 0x00000002, 0x636e6166 +0x74615f79, 0x62697274, 0x00657475, 0x00060005 +0x00000003, 0x66657375, 0x6f5f6c75, 0x75707475 +0x00000074, 0x00040047, 0x00000002, 0x0000001e +0x00000004, 0x00040047, 0x00000003, 0x0000001e +0x00000002, 0x00030016, 0x00000004, 0x00000020 +0x00040020, 0x00000005, 0x00000001, 0x00000004 +0x0004003b, 0x00000005, 0x00000002, 0x00000001 +0x00040020, 0x00000006, 0x00000003, 0x00000004 +0x0004003b, 0x00000006, 0x00000003, 0x00000003 +0x00020013, 0x00000007, 0x00030021, 0x00000008 +0x00000007, 0x00050036, 0x00000007, 0x00000001 +0x00000000, 0x00000008, 0x000200f8, 0x00000009 +0x0004003d, 0x00000004, 0x0000000a, 0x00000002 +0x0003003e, 0x00000003, 0x0000000a, 0x000100fd +0x00010038)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, WordsLeadingSpace) { + constexpr char kHex[] = R"( +x07230203, x00010600, x00070000, x0000000b +x00000000, x00020011, x00000001, x0003000e +x00000000, x00000001, x0007000f, x00000000 +x00000001, x6e69616d, x00000000, x00000002 +x00000003, x00060005, x00000002, x636e6166 +x74615f79, x62697274, x00657475, x00060005 +x00000003, x66657375, x6f5f6c75, x75707475 +x00000074, x00040047, x00000002, x0000001e +x00000004, x00040047, x00000003, x0000001e +x00000002, x00030016, x00000004, x00000020 +x00040020, x00000005, x00000001, x00000004 +x0004003b, x00000005, x00000002, x00000001 +x00040020, x00000006, x00000003, x00000004 +x0004003b, x00000006, x00000003, x00000003 +x00020013, x00000007, x00030021, x00000008 +x00000007, x00050036, x00000007, x00000001 +x00000000, x00000008, x000200f8, x00000009 +x0004003d, x00000004, x0000000a, x00000002 +x0003003e, x00000003, x0000000a, x000100fd +x00010038)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, WordsTrailingSpace) { + constexpr char kHex[] = R"(0X7230203, 0X10600, 0X70000, 0XB +0X0, 0X20011, 0X1, 0X3000E +0X0, 0X1, 0X7000F, 0X0 +0X1, X6E69616D, 0X0, 0X2 +0X3, 0X60005, 0X2, X636E6166 +X74615F79, X62697274, 0X657475, 0X60005 +0X3, X66657375, X6F5F6C75, X75707475 +0X74, 0X40047, 0X2, 0X1E +0X4, 0X40047, 0X3, 0X1E +0X2, 0X30016, 0X4, 0X20 +0X40020, 0X5, 0X1, 0X4 +0X4003B, 0X5, 0X2, 0X1 +0X40020, 0X6, 0X3, 0X4 +0X4003B, 0X6, 0X3, 0X3 +0X20013, 0X7, 0X30021, 0X8 +0X7, 0X50036, 0X7, 0X1 +0X0, 0X8, 0X200F8, 0X9 +0X4003D, 0X4, 0XA, 0X2 +0X3003E, 0X3, 0XA, 0X100FD +0X10038 + +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, BytesLittleEndian) { + constexpr char kHex[] = R"( +0x03 0x02 0x23 0x07 0x00 0x06 0x01 0x00 0x00 0x00 0x07 0x00 0x0b 0x00 0x00 0x00 +0x00 0x00 0x00 0x00 0x11 0x00 0x02 0x00 0x01 0x00 0x00 0x00 0x0e 0x00 0x03 0x00 +0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x0f 0x00 0x07 0x00 0x00 0x00 0x00 0x00 +0x01 0x00 0x00 0x00 0x6d 0x61 0x69 0x6e 0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00 +0x03 0x00 0x00 0x00 0x05 0x00 0x06 0x00 0x02 0x00 0x00 0x00 0x66 0x61 0x6e 0x63 +0x79 0x5f 0x61 0x74 0x74 0x72 0x69 0x62 0x75 0x74 0x65 0x00 0x05 0x00 0x06 0x00 +0x03 0x00 0x00 0x00 0x75 0x73 0x65 0x66 0x75 0x6c 0x5f 0x6f 0x75 0x74 0x70 0x75 +0x74 0x00 0x00 0x00 0x47 0x00 0x04 0x00 0x02 0x00 0x00 0x00 0x1e 0x00 0x00 0x00 +0x04 0x00 0x00 0x00 0x47 0x00 0x04 0x00 0x03 0x00 0x00 0x00 0x1e 0x00 0x00 0x00 +0x02 0x00 0x00 0x00 0x16 0x00 0x03 0x00 0x04 0x00 0x00 0x00 0x20 0x00 0x00 0x00 +0x20 0x00 0x04 0x00 0x05 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x04 0x00 0x00 0x00 +0x3b 0x00 0x04 0x00 0x05 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x01 0x00 0x00 0x00 +0x20 0x00 0x04 0x00 0x06 0x00 0x00 0x00 0x03 0x00 0x00 0x00 0x04 0x00 0x00 0x00 +0x3b 0x00 0x04 0x00 0x06 0x00 0x00 0x00 0x03 0x00 0x00 0x00 0x03 0x00 0x00 0x00 +0x13 0x00 0x02 0x00 0x07 0x00 0x00 0x00 0x21 0x00 0x03 0x00 0x08 0x00 0x00 0x00 +0x07 0x00 0x00 0x00 0x36 0x00 0x05 0x00 0x07 0x00 0x00 0x00 0x01 0x00 0x00 0x00 +0x00 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0xf8 0x00 0x02 0x00 0x09 0x00 0x00 0x00 +0x3d 0x00 0x04 0x00 0x04 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x02 0x00 0x00 0x00 +0x3e 0x00 0x03 0x00 0x03 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0xfd 0x00 0x01 0x00 +0x38 0x00 0x01 0x00 +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, BytesBigEndian) { + constexpr char kHex[] = R"( +X07,X23,X02,X03, X00,X01,X06,X00, X00,X07,X00,X00, X00,X00,X00,X0B +X00,X00,X00,X00, X00,X02,X00,X11, X00,X00,X00,X01, X00,X03,X00,X0E +X00,X00,X00,X00, X00,X00,X00,X01, X00,X07,X00,X0F, X00,X00,X00,X00 +X00,X00,X00,X01, X6E,X69,X61,X6D, X00,X00,X00,X00, X00,X00,X00,X02 +X00,X00,X00,X03, X00,X06,X00,X05, X00,X00,X00,X02, X63,X6E,X61,X66 +X74,X61,X5F,X79, X62,X69,X72,X74, X00,X65,X74,X75, X00,X06,X00,X05 +X00,X00,X00,X03, X66,X65,X73,X75, X6F,X5F,X6C,X75, X75,X70,X74,X75 +X00,X00,X00,X74, X00,X04,X00,X47, X00,X00,X00,X02, X00,X00,X00,X1E +X00,X00,X00,X04, X00,X04,X00,X47, X00,X00,X00,X03, X00,X00,X00,X1E +X00,X00,X00,X02, X00,X03,X00,X16, X00,X00,X00,X04, X00,X00,X00,X20 +X00,X04,X00,X20, X00,X00,X00,X05, X00,X00,X00,X01, X00,X00,X00,X04 +X00,X04,X00,X3B, X00,X00,X00,X05, X00,X00,X00,X02, X00,X00,X00,X01 +X00,X04,X00,X20, X00,X00,X00,X06, X00,X00,X00,X03, X00,X00,X00,X04 +X00,X04,X00,X3B, X00,X00,X00,X06, X00,X00,X00,X03, X00,X00,X00,X03 +X00,X02,X00,X13, X00,X00,X00,X07, X00,X03,X00,X21, X00,X00,X00,X08 +X00,X00,X00,X07, X00,X05,X00,X36, X00,X00,X00,X07, X00,X00,X00,X01 +X00,X00,X00,X00, X00,X00,X00,X08, X00,X02,X00,XF8, X00,X00,X00,X09 +X00,X04,X00,X3D, X00,X00,X00,X04, X00,X00,X00,X0A, X00,X00,X00,X02 +X00,X03,X00,X3E, X00,X00,X00,X03, X00,X00,X00,X0A, X00,X01,X00,XFD +X00,X01,X00,X38, +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, StreamLittleEndian) { + constexpr char kHex[] = R"( +03 02 23 07 00 06 01 00 00 00 07 00 0b 00 00 00 +00 00 00 00 11 00 02 00 01 00 00 00 0e 00 03 00 +00 00 00 00 01 00 00 00 0f 00 07 00 00 00 00 00 +01 00 00 00 6d 61 69 6e 00 00 00 00 02 00 00 00 +03 00 00 00 05 00 06 00 02 00 00 00 66 61 6e 63 +79 5f 61 74 74 72 69 62 75 74 65 00 05 00 06 00 +03 00 00 00 75 73 65 66 75 6c 5f 6f 75 74 70 75 +74 00 00 00 47 00 04 00 02 00 00 00 1e 00 00 00 +04 00 00 00 47 00 04 00 03 00 00 00 1e 00 00 00 +02 00 00 00 16 00 03 00 04 00 00 00 20 00 00 00 +20 00 04 00 05 00 00 00 01 00 00 00 04 00 00 00 +3b 00 04 00 05 00 00 00 02 00 00 00 01 00 00 00 +20 00 04 00 06 00 00 00 03 00 00 00 04 00 00 00 +3b 00 04 00 06 00 00 00 03 00 00 00 03 00 00 00 +13 00 02 00 07 00 00 00 21 00 03 00 08 00 00 00 +07 00 00 00 36 00 05 00 07 00 00 00 01 00 00 00 +00 00 00 00 08 00 00 00 f8 00 02 00 09 00 00 00 +3d 00 04 00 04 00 00 00 0a 00 00 00 02 00 00 00 +3e 00 03 00 03 00 00 00 0a 00 00 00 fd 00 01 00 +38 00 01 00 +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, StreamLittleEndianNoDelim) { + constexpr char kHex[] = R"( +0302230700060100000007000B000000 +0000000011000200010000000E000300 +00000000010000000F00070000000000 +010000006D61696E0000000002000000 +03000000050006000200000066616E63 +795F6174747269627574650005000600 +0300000075736566756C5F6F75747075 +7400000047000400020000001E000000 +0400000047000400030000001E000000 +02000000160003000400000020000000 +20000400050000000100000004000000 +3B000400050000000200000001000000 +20000400060000000300000004000000 +3B000400060000000300000003000000 +13000200070000002100030008000000 +07000000360005000700000001000000 +0000000008000000F800020009000000 +3D000400040000000A00000002000000 +3E000300030000000A000000FD000100 +38000100 +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, StreamBigEndian) { + constexpr char kHex[] = R"( +07230203, 00010600, 00070000, 0000000b +00000000, 00020011, 00000001, 0003000e +00000000, 00000001, 0007000f, 00000000 +00000001, 6e69616d, 00000000, 00000002 +00000003, 00060005, 00000002, 636e6166 +74615f79, 62697274, 00657475, 00060005 +00000003, 66657375, 6f5f6c75, 75707475 +00000074, 00040047, 00000002, 0000001e +00000004, 00040047, 00000003, 0000001e +00000002, 00030016, 00000004, 00000020 +00040020, 00000005, 00000001, 00000004 +0004003b, 00000005, 00000002, 00000001 +00040020, 00000006, 00000003, 00000004 +0004003b, 00000006, 00000003, 00000003 +00020013, 00000007, 00030021, 00000008 +00000007, 00050036, 00000007, 00000001 +00000000, 00000008, 000200f8, 00000009 +0004003d, 00000004, 0000000a, 00000002 +0003003e, 00000003, 0000000a, 000100fd +00010038, +)"; + + VerifyDisassembly(kHex, kDisassembly); +} + +TEST_F(HexToText, WordsNoDelimieter) { + constexpr char kHex[] = R"(0x07230203 0x00010600 0x00070000 0x0000000b +0x00000000 0x00020011 0x00000001 0x0003000e +0x00000000 0x00000001 0x0007000f 0x00000000 +0x00000001 0x6e69616d 0x00000000 0x00000002 +0x00000003 0x00060005 0x00000002 0x636e6166 +0x74615f79 0x62697274 0x00657475 0x00060005 +0x00000003 0x666573750x6f5f6c75 0x75707475 +0x00000074 0x00040047 0x00000002 0x0000001e +0x00000004 0x00040047 0x00000003 0x0000001e +0x00000002 0x00030016 0x00000004 0x00000020 +0x00040020 0x00000005 0x00000001 0x00000004 +0x0004003b 0x00000005 0x00000002 0x00000001 +0x00040020 0x00000006 0x00000003 0x00000004 +0x0004003b 0x00000006 0x00000003 0x00000003 +0x00020013 0x00000007 0x00030021 0x00000008 +0x00000007 0x00050036 0x00000007 0x00000001 +0x00000000 0x00000008 0x000200f8 0x00000009 +0x0004003d 0x00000004 0x0000000a 0x00000002 +0x0003003e 0x00000003 0x0000000a 0x000100fd +0x00010038)"; + + EnsureError(kHex); +} + +TEST_F(HexToText, InvalidFirstToken) { + constexpr char kHex[] = R"(0x17230203, 0x00010600, 0x00070000, 0x0000000b +0x00000000, 0x00020011, 0x00000001, 0x0003000e +0x00000000, 0x00000001, 0x0007000f, 0x00000000 +0x00000001, 0x6e69616d, 0x00000000, 0x00000002 +0x00000003, 0x00060005, 0x00000002, 0x636e6166 +0x74615f79, 0x62697274, 0x00657475, 0x00060005 +0x00000003, 0x66657375, 0x6f5f6c75, 0x75707475 +0x00000074, 0x00040047, 0x00000002, 0x0000001e +0x00000004, 0x00040047, 0x00000003, 0x0000001e +0x00000002, 0x00030016, 0x00000004, 0x00000020 +0x00040020, 0x00000005, 0x00000001, 0x00000004 +0x0004003b, 0x00000005, 0x00000002, 0x00000001 +0x00040020, 0x00000006, 0x00000003, 0x00000004 +0x0004003b, 0x00000006, 0x00000003, 0x00000003 +0x00020013, 0x00000007, 0x00030021, 0x00000008 +0x00000007, 0x00050036, 0x00000007, 0x00000001 +0x00000000, 0x00000008, 0x000200f8, 0x00000009 +0x0004003d, 0x00000004, 0x0000000a, 0x00000002 +0x0003003e, 0x00000003, 0x0000000a, 0x000100fd +0x00010038)"; + + EnsureError(kHex); +} + +TEST_F(HexToText, NonHexCharacter) { + // Note: a 6 is replaced with G in this stream + constexpr char kHex[] = R"(0x07230203, 0x00010600, 0x00070000, 0x0000000b +0x00000000, 0x00020011, 0x00000001, 0x0003000e +0x00000000, 0x00000001, 0x0007000f, 0x00000000 +0x00000001, 0x6e69616d, 0x00000000, 0x00000002 +0x00000003, 0x00060005, 0x00000002, 0x636e6166 +0x74615f79, 0x62697274, 0x00657475, 0x00060005 +0x00000003, 0x66657375, 0x6f5f6c75, 0x75707475 +0x00000074, 0x00040047, 0x00000002, 0x0000001e +0x00000004, 0x00040047, 0x00000003, 0x0000001e +0x00000002, 0x0003001G, 0x00000004, 0x00000020 +0x00040020, 0x00000005, 0x00000001, 0x00000004 +0x0004003b, 0x00000005, 0x00000002, 0x00000001 +0x00040020, 0x00000006, 0x00000003, 0x00000004 +0x0004003b, 0x00000006, 0x00000003, 0x00000003 +0x00020013, 0x00000007, 0x00030021, 0x00000008 +0x00000007, 0x00050036, 0x00000007, 0x00000001 +0x00000000, 0x00000008, 0x000200f8, 0x00000009 +0x0004003d, 0x00000004, 0x0000000a, 0x00000002 +0x0003003e, 0x00000003, 0x0000000a, 0x000100fd +0x00010038)"; + + EnsureError(kHex); +} + +TEST_F(HexToText, MissingExpectedPrefix) { + constexpr char kHex[] = R"(0x07230203, 0x00010600, 0x00070000, 0x0000000b +0x00000000, 0x00020011, 0x00000001, 0x0003000e +0x00000000, 0x00000001, 0x0007000f, 0x00000000 +0x00000001, 0x6e69616d, 0x00000000, 0x00000002 +0x00000003, 0x00060005, 0x00000002, 0x636e6166 +0x74615f79, 0x62697274, 0x00657475, 0x00060005 +0x00000003, 0x66657375, 0x6f5f6c75, 0x75707475 +0x00000074, 0x00040047, 0x00000002, 0x0000001e +0x00000004, 0x00040047, 0x00000003, 0x0000001e +0x00000002, 0x00030016, 0x00000004, 0x00000020 +0x00040020, 0x00000005, 00000001, 0x00000004 +0x0004003b, 0x00000005, 0x00000002, 0x00000001 +0x00040020, 0x00000006, 0x00000003, 0x00000004 +0x0004003b, 0x00000006, 0x00000003, 0x00000003 +0x00020013, 0x00000007, 0x00030021, 0x00000008 +0x00000007, 0x00050036, 0x00000007, 0x00000001 +0x00000000, 0x00000008, 0x000200f8, 0x00000009 +0x0004003d, 0x00000004, 0x0000000a, 0x00000002 +0x0003003e, 0x00000003, 0x0000000a, 0x000100fd +0x00010038)"; + + EnsureError(kHex); +} + +TEST_F(HexToText, UnexpectedPrefix) { + constexpr char kHex[] = R"(07230203, 00010600, 00070000, 0000000b +00000000, 00020011, 00000001, 0003000e +00000000, 00000001, 0007000f, 00000000 +00000001, 6e69616d, 00000000, 00000002 +00000003, 00060005, 00000002, 636e6166 +74615f79, 62697274, 00657475, 00060005 +00000003, 66657375, 6f5f6c75, 75707475 +00000074, 00040047, 00000002, 0000001e +00000004, 00040047, 00000003, 0000001e +00000002, 00030016, 00000004, 00000020 +00040020, 00000005, 0x00000001, 00000004 +0004003b, 00000005, 00000002, 00000001 +00040020, 00000006, 00000003, 00000004 +0004003b, 00000006, 00000003, 00000003 +00020013, 00000007, 00030021, 00000008 +00000007, 00050036, 00000007, 00000001 +00000000, 00000008, 000200f8, 00000009 +0004003d, 00000004, 0000000a, 00000002 +0003003e, 00000003, 0000000a, 000100fd +00010038)"; + + EnsureError(kHex); +} +} // namespace +} // namespace spvtools diff --git a/third_party/spirv-tools/test/immediate_int_test.cpp b/third_party/spirv-tools/test/immediate_int_test.cpp index 8e7a8fd304..44f96e21a4 100644 --- a/third_party/spirv-tools/test/immediate_int_test.cpp +++ b/third_party/spirv-tools/test/immediate_int_test.cpp @@ -136,19 +136,25 @@ TEST_F(ImmediateIntTest, IntegerFollowingImmediate) { } // Literal floats after ! are handled correctly. +// Insert OpNop to avoid reading the immediate value as the extra FP encoding +// operand to OpTypeFloat. TEST_F(ImmediateIntTest, FloatFollowingImmediate) { - EXPECT_EQ( - CompiledInstructions("%1 = OpTypeFloat 32\n%2 = OpConstant %1 0.123"), - CompiledInstructions("%1 = OpTypeFloat 32\n!0x0004002b %1 !2 0.123")); - EXPECT_EQ( - CompiledInstructions("%1 = OpTypeFloat 32\n%2 = OpConstant %1 -0.5"), - CompiledInstructions("%1 = OpTypeFloat 32\n!0x0004002b %1 !2 -0.5")); - EXPECT_EQ( - CompiledInstructions("%1 = OpTypeFloat 32\n%2 = OpConstant %1 0.123"), - CompiledInstructions("%1 = OpTypeFloat 32\n!0x0004002b %1 %2 0.123")); - EXPECT_EQ( - CompiledInstructions("%1 = OpTypeFloat 32\n%2 = OpConstant %1 -0.5"), - CompiledInstructions("%1 = OpTypeFloat 32\n!0x0004002b %1 %2 -0.5")); + EXPECT_EQ(CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop %2 = OpConstant %1 0.123"), + CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop !0x0004002b %1 !2 0.123")); + EXPECT_EQ(CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop %2 = OpConstant %1 -0.5"), + CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop !0x0004002b %1 !2 -0.5")); + EXPECT_EQ(CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop %2 = OpConstant %1 0.123"), + CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop !0x0004002b %1 %2 0.123")); + EXPECT_EQ(CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop %2 = OpConstant %1 -0.5"), + CompiledInstructions( + "%1 = OpTypeFloat 32\nOpNop !0x0004002b %1 %2 -0.5")); EXPECT_EQ(Concatenate({ MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}), @@ -203,9 +209,9 @@ TEST_F(ImmediateIntTest, InvalidStatement) { TEST_F(ImmediateIntTest, InvalidStatementBetweenValidOnes) { EXPECT_THAT(Subvector(CompileSuccessfully( - "%10 = OpTypeFloat 32 !5 !6 !7 OpEmitVertex"), + "%10 = OpTypeInt 32 0 !5 !6 !7 OpEmitVertex"), kFirstInstruction), - ElementsAre(spvOpcodeMake(3, spv::Op::OpTypeFloat), 1, 32, 5, 6, + ElementsAre(spvOpcodeMake(4, spv::Op::OpTypeInt), 1, 32, 0, 5, 6, 7, spvOpcodeMake(1, spv::Op::OpEmitVertex))); } diff --git a/third_party/spirv-tools/test/link/binary_version_test.cpp b/third_party/spirv-tools/test/link/binary_version_test.cpp index 78da1aeced..384255a468 100644 --- a/third_party/spirv-tools/test/link/binary_version_test.cpp +++ b/third_party/spirv-tools/test/link/binary_version_test.cpp @@ -73,5 +73,21 @@ TEST_F(BinaryVersion, Mismatch) { "through 1) vs 1.5 (input module 2).")); } +TEST_F(BinaryVersion, UseHighest) { + // clang-format off + spvtest::Binaries binaries = { + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 3)), + CreateBinary(SPV_SPIRV_VERSION_WORD(1, 5)), + }; + // clang-format on + LinkerOptions options; + options.SetUseHighestVersion(true); + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary, options)) + << GetErrorMessage(); + EXPECT_THAT(GetErrorMessage(), std::string()); + EXPECT_EQ(SPV_SPIRV_VERSION_WORD(1, 5), linked_binary[1]); +} + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp b/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp index 6b02fc46dd..6e71da3260 100644 --- a/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp +++ b/third_party/spirv-tools/test/link/matching_imports_to_exports_test.cpp @@ -15,6 +15,7 @@ #include #include "gmock/gmock.h" +#include "gtest/gtest.h" #include "test/link/linker_fixture.h" namespace spvtools { @@ -174,14 +175,18 @@ OpDecorate %1 LinkageAttributes "foo" Export %1 = OpVariable %2 Uniform %3 )"; - spvtest::Binary linked_binary; - EXPECT_EQ(SPV_ERROR_INVALID_BINARY, - AssembleAndLink({body1, body2}, &linked_binary)) - << GetErrorMessage(); - EXPECT_THAT( - GetErrorMessage(), - HasSubstr("Type mismatch on symbol \"foo\" between imported " - "variable/function %1 and exported variable/function %4")); + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %4")); + } } TEST_F(MatchingImportsToExports, MultipleDefinitions) { @@ -216,13 +221,17 @@ OpDecorate %1 LinkageAttributes "foo" Export %1 = OpVariable %2 Uniform %3 )"; - spvtest::Binary linked_binary; - EXPECT_EQ(SPV_ERROR_INVALID_BINARY, - AssembleAndLink({body1, body2, body3}, &linked_binary)) - << GetErrorMessage(); - EXPECT_THAT(GetErrorMessage(), - HasSubstr("Too many external references, 2, were found " - "for \"foo\".")); + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2, body3}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT(GetErrorMessage(), + HasSubstr("Too many external references, 2, were found " + "for \"foo\".")); + } } TEST_F(MatchingImportsToExports, SameNameDifferentTypes) { @@ -289,14 +298,18 @@ OpDecorate %1 LinkageAttributes "foo" Export %1 = OpVariable %2 Uniform %3 )"; - spvtest::Binary linked_binary; - EXPECT_EQ(SPV_ERROR_INVALID_BINARY, - AssembleAndLink({body1, body2}, &linked_binary)) - << GetErrorMessage(); - EXPECT_THAT( - GetErrorMessage(), - HasSubstr("Type mismatch on symbol \"foo\" between imported " - "variable/function %1 and exported variable/function %4")); + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %4")); + } } TEST_F(MatchingImportsToExports, @@ -557,5 +570,446 @@ OpFunctionEnd EXPECT_EQ(expected_res, res_body); } +TEST_F(MatchingImportsToExports, FunctionCall) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %3 "param" +OpDecorate %1 LinkageAttributes "foo" Import + %5 = OpTypeVoid + %6 = OpTypeInt 32 0 + %9 = OpTypePointer Function %6 + %7 = OpTypeFunction %5 %9 + %1 = OpFunction %5 None %7 + %3 = OpFunctionParameter %9 +OpFunctionEnd + %8 = OpFunction %5 None %7 + %4 = OpFunctionParameter %9 +%10 = OpLabel +%11 = OpFunctionCall %5 %1 %4 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpDecorate %1 LinkageAttributes "foo" Export +%3 = OpTypeVoid +%4 = OpTypeInt 32 0 +%7 = OpTypePointer Function %4 +%5 = OpTypeFunction %3 %7 +%1 = OpFunction %3 None %5 +%2 = OpFunctionParameter %7 +%6 = OpLabel +OpReturn +OpFunctionEnd +)"; + + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + ASSERT_EQ(SPV_SUCCESS, + AssembleAndLink({body1, body2}, &linked_binary, options)) + << GetErrorMessage(); + + const std::string expected_res = R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpModuleProcessed "Linked by SPIR-V Tools Linker" +%3 = OpTypeVoid +%4 = OpTypeInt 32 0 +%5 = OpTypePointer Function %4 +%6 = OpTypeFunction %3 %5 +%7 = OpFunction %3 None %6 +%8 = OpFunctionParameter %5 +%9 = OpLabel +%10 = OpFunctionCall %3 %1 %8 +OpReturn +OpFunctionEnd +%1 = OpFunction %3 None %6 +%2 = OpFunctionParameter %5 +%11 = OpLabel +OpReturn +OpFunctionEnd +)"; + + std::string res_body; + SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + << GetErrorMessage(); + EXPECT_EQ(expected_res, res_body); + } +} + +TEST_F(MatchingImportsToExports, FunctionSignatureMismatchPointer) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %3 "param" +OpDecorate %1 LinkageAttributes "foo" Import + %5 = OpTypeVoid + %6 = OpTypeInt 8 0 + %9 = OpTypePointer Function %6 + %7 = OpTypeFunction %5 %9 + %1 = OpFunction %5 None %7 + %3 = OpFunctionParameter %9 +OpFunctionEnd + %8 = OpFunction %5 None %7 + %4 = OpFunctionParameter %9 +%10 = OpLabel +%11 = OpFunctionCall %5 %1 %4 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpDecorate %1 LinkageAttributes "foo" Export +%3 = OpTypeVoid +%4 = OpTypeInt 32 0 +%7 = OpTypePointer Function %4 +%5 = OpTypeFunction %3 %7 +%1 = OpFunction %3 None %5 +%2 = OpFunctionParameter %7 +%6 = OpLabel +OpReturn +OpFunctionEnd +)"; + + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %11")); + + LinkerOptions options; + options.SetAllowPtrTypeMismatch(true); + ASSERT_EQ(SPV_SUCCESS, + AssembleAndLink({body1, body2}, &linked_binary, options)) + << GetErrorMessage(); + + const std::string expected_res = R"(OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpModuleProcessed "Linked by SPIR-V Tools Linker" +%3 = OpTypeVoid +%4 = OpTypeInt 8 0 +%5 = OpTypePointer Function %4 +%6 = OpTypeFunction %3 %5 +%7 = OpTypeInt 32 0 +%8 = OpTypePointer Function %7 +%9 = OpTypeFunction %3 %8 +%10 = OpFunction %3 None %6 +%11 = OpFunctionParameter %5 +%12 = OpLabel +%13 = OpBitcast %8 %11 +%14 = OpFunctionCall %3 %1 %13 +OpReturn +OpFunctionEnd +%1 = OpFunction %3 None %9 +%2 = OpFunctionParameter %8 +%15 = OpLabel +OpReturn +OpFunctionEnd +)"; + std::string res_body; + SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); + ASSERT_EQ(SPV_SUCCESS, Disassemble(linked_binary, &res_body)) + << GetErrorMessage(); + EXPECT_EQ(expected_res, res_body); +} + +TEST_F(MatchingImportsToExports, FunctionSignatureMismatchValue) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %3 "param" +OpDecorate %1 LinkageAttributes "foo" Import + %5 = OpTypeVoid + %6 = OpTypeInt 8 0 + %7 = OpTypeFunction %5 %6 + %1 = OpFunction %5 None %7 + %3 = OpFunctionParameter %6 +OpFunctionEnd + %8 = OpFunction %5 None %7 + %4 = OpFunctionParameter %6 +%10 = OpLabel +%11 = OpFunctionCall %5 %1 %4 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpDecorate %1 LinkageAttributes "foo" Export +%3 = OpTypeVoid +%4 = OpTypeInt 32 0 +%5 = OpTypeFunction %3 %4 +%1 = OpFunction %3 None %5 +%2 = OpFunctionParameter %4 +%6 = OpLabel +OpReturn +OpFunctionEnd +)"; + + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + ASSERT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %10")); + } +} + +TEST_F(MatchingImportsToExports, FunctionSignatureMismatchTypePointerInt) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %3 "param" +OpDecorate %1 LinkageAttributes "foo" Import + %5 = OpTypeVoid + %6 = OpTypeInt 64 0 + %7 = OpTypeFunction %5 %6 + %1 = OpFunction %5 None %7 + %3 = OpFunctionParameter %6 +OpFunctionEnd + %8 = OpFunction %5 None %7 + %4 = OpFunctionParameter %6 +%10 = OpLabel +%11 = OpFunctionCall %5 %1 %4 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpDecorate %1 LinkageAttributes "foo" Export +%3 = OpTypeVoid +%4 = OpTypeInt 64 0 +%7 = OpTypePointer Function %4 +%5 = OpTypeFunction %3 %7 +%1 = OpFunction %3 None %5 +%2 = OpFunctionParameter %7 +%6 = OpLabel +OpReturn +OpFunctionEnd +)"; + + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + ASSERT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %10")); + } +} + +TEST_F(MatchingImportsToExports, FunctionSignatureMismatchTypeIntPointer) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %3 "param" +OpDecorate %1 LinkageAttributes "foo" Import + %5 = OpTypeVoid + %6 = OpTypeInt 64 0 + %9 = OpTypePointer Function %6 + %7 = OpTypeFunction %5 %9 + %1 = OpFunction %5 None %7 + %3 = OpFunctionParameter %9 +OpFunctionEnd + %8 = OpFunction %5 None %7 + %4 = OpFunctionParameter %9 +%10 = OpLabel +%11 = OpFunctionCall %5 %1 %4 +OpReturn +OpFunctionEnd +)"; + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpMemoryModel Physical64 OpenCL +OpName %1 "foo" +OpName %2 "param" +OpDecorate %1 LinkageAttributes "foo" Export +%3 = OpTypeVoid +%4 = OpTypeInt 64 0 +%5 = OpTypeFunction %3 %4 +%1 = OpFunction %3 None %5 +%2 = OpFunctionParameter %4 +%6 = OpLabel +OpReturn +OpFunctionEnd +)"; + + LinkerOptions options; + for (int i = 0; i < 2; i++) { + spvtest::Binary linked_binary; + options.SetAllowPtrTypeMismatch(i == 1); + ASSERT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Type mismatch on symbol \"foo\" between imported " + "variable/function %1 and exported variable/function %11")); + } +} + +TEST_F(MatchingImportsToExports, LinkOnceODRLinkageVarSingle) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" LinkOnceODR +%2 = OpTypeFloat 32 +%3 = OpConstant %2 3.1415 +%1 = OpVariable %2 Uniform %3 +)"; + + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" Import +%2 = OpTypeFloat 32 +%1 = OpVariable %2 Uniform +)"; + spvtest::Binary linked_binary; + EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary)) + << GetErrorMessage(); +} + +TEST_F(MatchingImportsToExports, LinkOnceODRLinkageFunMultiple) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" LinkOnceODR +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%1 = OpFunction %2 Inline %3 +%4 = OpLabel +OpReturn +OpFunctionEnd +)"; + + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" Import +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%1 = OpFunction %2 None %3 +OpFunctionEnd +)"; + spvtest::Binary linked_binary; + EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body1, body2}, &linked_binary)) + << GetErrorMessage(); +} + +TEST_F(MatchingImportsToExports, LinkOnceODRAndExport) { + const std::string body1 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" LinkOnceODR +%2 = OpTypeFloat 32 +%3 = OpConstant %2 3.1415 +%1 = OpVariable %2 Uniform %3 +)"; + + const std::string body2 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" Export +%2 = OpTypeFloat 32 +%3 = OpConstant %2 2.7183 +%1 = OpVariable %2 Uniform %3 +)"; + + const std::string body3 = R"( +OpCapability Linkage +OpCapability Addresses +OpCapability Kernel +OpExtension "SPV_KHR_linkonce_odr" +OpMemoryModel Physical64 OpenCL +OpDecorate %1 LinkageAttributes "foo" Import +%2 = OpTypeFloat 32 +%1 = OpVariable %2 Uniform +)"; + spvtest::Binary linked_binary; + ASSERT_EQ(SPV_ERROR_INVALID_BINARY, + AssembleAndLink({body1, body2, body3}, &linked_binary)) + << GetErrorMessage(); + EXPECT_THAT( + GetErrorMessage(), + HasSubstr("Combination of Export and LinkOnceODR is not allowed, found " + "for \"foo\"")); +} + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/log_test.cpp b/third_party/spirv-tools/test/log_test.cpp deleted file mode 100644 index ec66aa1ece..0000000000 --- a/third_party/spirv-tools/test/log_test.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2016 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "source/opt/log.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -namespace spvtools { -namespace { - -using ::testing::MatchesRegex; - -TEST(Log, Unimplemented) { - int invocation = 0; - auto consumer = [&invocation](spv_message_level_t level, const char* source, - const spv_position_t&, const char* message) { - ++invocation; - EXPECT_EQ(SPV_MSG_INTERNAL_ERROR, level); - EXPECT_THAT(source, MatchesRegex(".*log_test.cpp$")); - EXPECT_STREQ("unimplemented: the-ultimite-feature", message); - }; - - SPIRV_UNIMPLEMENTED(consumer, "the-ultimite-feature"); - EXPECT_EQ(1, invocation); -} - -TEST(Log, Unreachable) { - int invocation = 0; - auto consumer = [&invocation](spv_message_level_t level, const char* source, - const spv_position_t&, const char* message) { - ++invocation; - EXPECT_EQ(SPV_MSG_INTERNAL_ERROR, level); - EXPECT_THAT(source, MatchesRegex(".*log_test.cpp$")); - EXPECT_STREQ("unreachable", message); - }; - - SPIRV_UNREACHABLE(consumer); - EXPECT_EQ(1, invocation); -} - -} // namespace -} // namespace spvtools diff --git a/third_party/spirv-tools/test/opcode_require_capabilities_test.cpp b/third_party/spirv-tools/test/opcode_require_capabilities_test.cpp index 37097c6ff2..615c09429e 100644 --- a/third_party/spirv-tools/test/opcode_require_capabilities_test.cpp +++ b/third_party/spirv-tools/test/opcode_require_capabilities_test.cpp @@ -61,8 +61,33 @@ INSTANTIATE_TEST_SUITE_P( ExpectedOpCodeCapabilities{ spv::Op::OpImageSparseSampleImplicitLod, CapabilitySet{spv::Capability::SparseResidency}}, - ExpectedOpCodeCapabilities{spv::Op::OpCopyMemorySized, - CapabilitySet{spv::Capability::Addresses}}, + ExpectedOpCodeCapabilities{ + spv::Op::OpCopyMemorySized, + CapabilitySet{spv::Capability::Addresses, + spv::Capability::UntypedPointersKHR}}, + ExpectedOpCodeCapabilities{spv::Op::OpArrayLength, + CapabilitySet{spv::Capability::Shader}}, + ExpectedOpCodeCapabilities{spv::Op::OpFunction, CapabilitySet()}, + ExpectedOpCodeCapabilities{spv::Op::OpConvertFToS, CapabilitySet()}, + ExpectedOpCodeCapabilities{ + spv::Op::OpEmitStreamVertex, + CapabilitySet{spv::Capability::GeometryStreams}}, + ExpectedOpCodeCapabilities{ + spv::Op::OpTypeNamedBarrier, + CapabilitySet{spv::Capability::NamedBarrier}}, + ExpectedOpCodeCapabilities{ + spv::Op::OpGetKernelMaxNumSubgroups, + CapabilitySet{spv::Capability::SubgroupDispatch}}, + ExpectedOpCodeCapabilities{spv::Op::OpImageQuerySamples, + CapabilitySet{spv::Capability::Kernel, + spv::Capability::ImageQuery}}, + ExpectedOpCodeCapabilities{ + spv::Op::OpImageSparseSampleImplicitLod, + CapabilitySet{spv::Capability::SparseResidency}}, + ExpectedOpCodeCapabilities{ + spv::Op::OpCopyMemorySized, + CapabilitySet{spv::Capability::Addresses, + spv::Capability::UntypedPointersKHR}}, ExpectedOpCodeCapabilities{spv::Op::OpArrayLength, CapabilitySet{spv::Capability::Shader}}, ExpectedOpCodeCapabilities{spv::Op::OpFunction, CapabilitySet()}, diff --git a/third_party/spirv-tools/test/operand_capabilities_test.cpp b/third_party/spirv-tools/test/operand_capabilities_test.cpp index 10ed82a180..53dbe07010 100644 --- a/third_party/spirv-tools/test/operand_capabilities_test.cpp +++ b/third_party/spirv-tools/test/operand_capabilities_test.cpp @@ -18,7 +18,12 @@ #include #include "gmock/gmock.h" +#include "source/assembly_grammar.h" #include "source/enum_set.h" +#include "source/operand.h" +#include "source/spirv_target_env.h" +#include "source/table.h" +#include "spirv-tools/libspirv.h" #include "test/unit_spirv.h" namespace spvtools { @@ -31,6 +36,25 @@ using ::testing::TestWithParam; using ::testing::Values; using ::testing::ValuesIn; +// Emits a CapabilitySet to the given ostream, returning the ostream. +inline std::ostream& operator<<(std::ostream& out, const CapabilitySet& cs) { + out << "CapabilitySet{"; + auto ctx = spvContextCreate(SPV_ENV_UNIVERSAL_1_0); + spvtools::AssemblyGrammar grammar(ctx); + bool first = true; + for (auto c : cs) { + if (!first) { + out << " "; + first = false; + } + out << grammar.lookupOperandName(SPV_OPERAND_TYPE_CAPABILITY, uint32_t(c)) + << "(" << uint32_t(c) << ")"; + } + spvContextDestroy(ctx); + out << "}"; + return out; +} + // A test case for mapping an enum to a capability mask. struct EnumCapabilityCase { spv_operand_type_t type; @@ -38,6 +62,16 @@ struct EnumCapabilityCase { CapabilitySet expected_capabilities; }; +// Emits an EnumCapabilityCase to the given output stream. This is used +// to emit failure cases when they occur, which helps debug tests. +inline std::ostream& operator<<(std::ostream& out, EnumCapabilityCase e) { + out << "{" << spvOperandTypeStr(e.type) << " " << e.value << " " + << e.expected_capabilities << " }"; + return out; +} + +using EnvEnumCapabilityCase = std::tuple; + // Test fixture for testing EnumCapabilityCases. using EnumCapabilityTest = TestWithParam>; @@ -56,7 +90,7 @@ TEST_P(EnumCapabilityTest, Sample) { EXPECT_THAT(ElementsIn(cap_set), Eq(ElementsIn(std::get<1>(GetParam()).expected_capabilities))) - << " capability value " << std::get<1>(GetParam()).value; + << " enum value " << std::get<1>(GetParam()).value; spvContextDestroy(context); } @@ -223,12 +257,12 @@ INSTANTIATE_TEST_SUITE_P( Dim, EnumCapabilityTest, Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), ValuesIn(std::vector{ - CASE2(DIMENSIONALITY, Dim::Dim1D, Sampled1D, Image1D), - CASE3(DIMENSIONALITY, Dim::Dim2D, Kernel, Shader, ImageMSArray), + CASE1(DIMENSIONALITY, Dim::Dim1D, Sampled1D), + CASE0(DIMENSIONALITY, Dim::Dim2D), CASE0(DIMENSIONALITY, Dim::Dim3D), - CASE2(DIMENSIONALITY, Dim::Cube, Shader, ImageCubeArray), - CASE2(DIMENSIONALITY, Dim::Rect, SampledRect, ImageRect), - CASE2(DIMENSIONALITY, Dim::Buffer, SampledBuffer, ImageBuffer), + CASE1(DIMENSIONALITY, Dim::Cube, Shader), + CASE1(DIMENSIONALITY, Dim::Rect, SampledRect), + CASE1(DIMENSIONALITY, Dim::Buffer, SampledBuffer), CASE1(DIMENSIONALITY, Dim::SubpassData, InputAttachment), }))); @@ -237,25 +271,21 @@ INSTANTIATE_TEST_SUITE_P( SamplerAddressingMode, EnumCapabilityTest, Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), ValuesIn(std::vector{ - CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::None, - Kernel), - CASE1(SAMPLER_ADDRESSING_MODE, - SamplerAddressingMode::ClampToEdge, Kernel), - CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Clamp, - Kernel), - CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Repeat, - Kernel), - CASE1(SAMPLER_ADDRESSING_MODE, - SamplerAddressingMode::RepeatMirrored, Kernel), - }))); + CASE0(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::None), + CASE0(SAMPLER_ADDRESSING_MODE, + SamplerAddressingMode::ClampToEdge), + CASE0(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Clamp), + CASE0(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Repeat), + CASE0(SAMPLER_ADDRESSING_MODE, + SamplerAddressingMode::RepeatMirrored)}))); // See SPIR-V Section 3.10 Sampler Filter Mode INSTANTIATE_TEST_SUITE_P( SamplerFilterMode, EnumCapabilityTest, Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), ValuesIn(std::vector{ - CASE1(SAMPLER_FILTER_MODE, SamplerFilterMode::Nearest, Kernel), - CASE1(SAMPLER_FILTER_MODE, SamplerFilterMode::Linear, Kernel), + CASE0(SAMPLER_FILTER_MODE, SamplerFilterMode::Nearest), + CASE0(SAMPLER_FILTER_MODE, SamplerFilterMode::Linear), }))); // See SPIR-V Section 3.11 Image Format @@ -310,56 +340,56 @@ INSTANTIATE_TEST_SUITE_P( // See SPIR-V Section 3.12 Image Channel Order INSTANTIATE_TEST_SUITE_P( ImageChannelOrder, EnumCapabilityTest, - Combine( - Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), - ValuesIn(std::vector{ - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::R, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::A, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RG, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RA, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGB, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBA, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::BGRA, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ARGB, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Intensity, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Luminance, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Rx, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGx, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBx, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Depth, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::DepthStencil, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGB, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBx, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBA, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sBGRA, Kernel), - CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ABGR, Kernel), - }))); + Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), + ValuesIn(std::vector{ + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::R), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::A), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RG), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RA), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGB), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBA), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::BGRA), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ARGB), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Intensity), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Luminance), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Rx), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGx), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBx), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Depth), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::DepthStencil), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGB), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBx), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBA), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sBGRA), + CASE0(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ABGR), + }))); // See SPIR-V Section 3.13 Image Channel Data Type INSTANTIATE_TEST_SUITE_P( ImageChannelDataType, EnumCapabilityTest, - Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), - ValuesIn(std::vector{ - // clang-format off - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt8, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt16, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt8, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt16, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort565, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort555, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt8, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt16, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt32, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt8, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt16, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt32, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::HalfFloat, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::Float, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt24, Kernel), - CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010_2, Kernel), - // clang-format on - }))); + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), + ValuesIn(std::vector{ + // clang-format off + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt8), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt16), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt8), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt16), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort565), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort555), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt8), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt16), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt32), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt8), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt16), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt32), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::HalfFloat), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::Float), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt24), + CASE0(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010_2), + // clang-format on + }))); // See SPIR-V Section 3.14 Image Operands INSTANTIATE_TEST_SUITE_P( @@ -417,7 +447,7 @@ INSTANTIATE_TEST_SUITE_P( // See SPIR-V Section 3.20 Decoration INSTANTIATE_TEST_SUITE_P( - Decoration, EnumCapabilityTest, + Decoration_1_1, EnumCapabilityTest, Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1), ValuesIn(std::vector{ CASE1(DECORATION, Decoration::RelaxedPrecision, Shader), @@ -461,7 +491,8 @@ INSTANTIATE_TEST_SUITE_P( CASE1(DECORATION, Decoration::XfbBuffer, TransformFeedback), CASE1(DECORATION, Decoration::XfbStride, TransformFeedback), CASE1(DECORATION, Decoration::FuncParamAttr, Kernel), - CASE1(DECORATION, Decoration::FPFastMathMode, Kernel), + CASE2(DECORATION, Decoration::FPFastMathMode, Kernel, + FloatControls2), CASE1(DECORATION, Decoration::LinkageAttributes, Linkage), CASE1(DECORATION, Decoration::NoContraction, Shader), CASE1(DECORATION, Decoration::InputAttachmentIndex, @@ -469,6 +500,13 @@ INSTANTIATE_TEST_SUITE_P( CASE1(DECORATION, Decoration::Alignment, Kernel), }))); +// See SPIR-V Section 3.20 Decoration +INSTANTIATE_TEST_SUITE_P(Decoration_1_6, EnumCapabilityTest, + Combine(Values(SPV_ENV_UNIVERSAL_1_6), + ValuesIn(std::vector{ + CASE2(DECORATION, Decoration::Uniform, + Shader, UniformDecoration)}))); + #if 0 // SpecId has different requirements in v1.0 and v1.1: INSTANTIATE_TEST_SUITE_P(DecorationSpecIdV10, EnumCapabilityTest, diff --git a/third_party/spirv-tools/test/opt/CMakeLists.txt b/third_party/spirv-tools/test/opt/CMakeLists.txt index af24e6599c..4ef119deab 100644 --- a/third_party/spirv-tools/test/opt/CMakeLists.txt +++ b/third_party/spirv-tools/test/opt/CMakeLists.txt @@ -21,6 +21,7 @@ add_spvtools_unittest(TARGET opt analyze_live_input_test.cpp assembly_builder_test.cpp block_merge_test.cpp + c_interface_test.cpp ccp_test.cpp cfg_cleanup_test.cpp cfg_test.cpp @@ -59,12 +60,10 @@ add_spvtools_unittest(TARGET opt inline_opaque_test.cpp inline_test.cpp insert_extract_elim_test.cpp - inst_bindless_check_test.cpp - inst_buff_addr_check_test.cpp - inst_debug_printf_test.cpp instruction_list_test.cpp instruction_test.cpp interface_var_sroa_test.cpp + invocation_interlock_placement_test.cpp interp_fixup_test.cpp ir_builder.cpp ir_context_test.cpp @@ -76,8 +75,10 @@ add_spvtools_unittest(TARGET opt local_single_block_elim.cpp local_single_store_elim_test.cpp local_ssa_elim_test.cpp + modify_maximal_reconvergence_test.cpp module_test.cpp module_utils.h + opextinst_forward_ref_fixup_pass_test.cpp optimizer_test.cpp pass_manager_test.cpp pass_merge_return_test.cpp @@ -102,6 +103,9 @@ add_spvtools_unittest(TARGET opt strip_debug_info_test.cpp strip_nonsemantic_info_test.cpp struct_cfg_analysis_test.cpp + struct_packing_test.cpp + switch_descriptorset_test.cpp + trim_capabilities_pass_test.cpp type_manager_test.cpp types_test.cpp unify_const_test.cpp @@ -114,3 +118,12 @@ add_spvtools_unittest(TARGET opt LIBS SPIRV-Tools-opt PCH_FILE pch_test_opt ) +if (NOT "${SPIRV_SKIP_TESTS}" AND TARGET gmock_main) + if (MSVC) + if (${MSVC_VERSION} LESS 1920) + # The VS 2017 debug build requires /bigobj on test_opt + # https://github.com/KhronosGroup/SPIRV-Tools/issues/5335 + target_compile_options(test_opt PRIVATE /bigobj) + endif() + endif() +endif() diff --git a/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp b/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp index 0d941519cd..f792ada73f 100644 --- a/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp +++ b/third_party/spirv-tools/test/opt/aggressive_dead_code_elim_test.cpp @@ -16,6 +16,7 @@ #include #include +#include "gmock/gmock.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -26,6 +27,8 @@ namespace { using AggressiveDCETest = PassTest<::testing::Test>; +using ::testing::HasSubstr; + TEST_F(AggressiveDCETest, EliminateExtendedInst) { // #version 140 // @@ -6764,7 +6767,7 @@ TEST_F(AggressiveDCETest, ShaderDebugInfoKeepInFunctionElimStoreVar) { %60 = OpExtInst %void %1 DebugTypeVector %59 %uint_4 %58 = OpExtInst %void %1 DebugTypeMember %10 %60 %55 %uint_12 %uint_5 %uint_0 %uint_128 %uint_3 %57 = OpExtInst %void %1 DebugTypeComposite %8 %uint_1 %55 %uint_10 %uint_1 %56 %8 %uint_128 %uint_3 %58 - %63 = OpExtInst %void %1 DebugTypeVector %59 %uint_2 + %63 = OpExtInst %void %1 DebugTypeVector %59 %uint_2 %62 = OpExtInst %void %1 DebugTypeMember %12 %63 %55 %uint_7 %uint_5 %uint_0 %uint_64 %uint_3 %61 = OpExtInst %void %1 DebugTypeComposite %11 %uint_1 %55 %uint_5 %uint_1 %56 %11 %uint_64 %uint_3 %62 %64 = OpExtInst %void %1 DebugTypeComposite %13 %uint_0 %55 %uint_0 %uint_0 %56 %14 %51 %uint_3 @@ -7568,7 +7571,7 @@ TEST_F(AggressiveDCETest, PreserveInterface) { OpExtension "SPV_KHR_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint RayGenerationNV %2 "main" %3 %4 +OpEntryPoint RayGenerationKHR %2 "main" %3 %4 OpDecorate %3 Location 0 OpDecorate %4 DescriptorSet 2 OpDecorate %4 Binding 0 @@ -7577,8 +7580,8 @@ OpDecorate %4 Binding 0 %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %float = OpTypeFloat 32 -%_ptr_CallableDataNV_float = OpTypePointer CallableDataNV %float -%3 = OpVariable %_ptr_CallableDataNV_float CallableDataNV +%_ptr_CallableDataKHR_float = OpTypePointer CallableDataKHR %float +%3 = OpVariable %_ptr_CallableDataKHR_float CallableDataKHR %13 = OpTypeAccelerationStructureKHR %_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 %4 = OpVariable %_ptr_UniformConstant_13 UniformConstant @@ -7857,6 +7860,443 @@ TEST_F(AggressiveDCETest, RemoveOutputFalse) { SinglePassRunAndMatch(text, true, false, false); } +TEST_F(AggressiveDCETest, RemoveWhenUsingPrintfExtension) { + // Remove dead n_out output variable from module + const std::string text = R"( +; CHECK: OpExtInstImport "NonSemantic.DebugPrintf" +; CHECK-NOT: OpVariable + OpCapability Shader + %1 = OpExtInstImport "NonSemantic.DebugPrintf" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 8 8 1 + OpSource HLSL 660 + OpName %main "main" + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %5 = OpTypeFunction %void +%_ptr_Function_uint = OpTypePointer Function %uint + %main = OpFunction %void None %5 + %7 = OpLabel + %8 = OpVariable %_ptr_Function_uint Function + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SinglePassRunAndMatch(text, true); +} + +TEST_F(AggressiveDCETest, FunctionReturnPointer) { + // Run DCE when a function returning a pointer to a reference is present + + const std::string text = R"( + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint Vertex %2 "main" %3 %4 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_buffer_reference" + OpSourceExtension "GL_EXT_scalar_block_layout" + OpName %4 "color" + OpMemberDecorate %5 0 Offset 0 + OpDecorate %5 Block + OpMemberDecorate %7 0 Offset 0 + OpDecorate %7 Block + OpDecorate %8 AliasedPointer + OpDecorate %4 Location 0 + %9 = OpTypeVoid + %10 = OpTypeFunction %9 + OpTypeForwardPointer %11 PhysicalStorageBuffer + %12 = OpTypeInt 32 0 + %5 = OpTypeStruct %12 + %11 = OpTypePointer PhysicalStorageBuffer %5 +;CHECK: [[pt:%\w+]] = OpTypePointer PhysicalStorageBuffer {{%\w+}} + %13 = OpTypeFunction %11 +;CHECK: [[pt_fn:%\w+]] = OpTypeFunction [[pt]] + %7 = OpTypeStruct %11 + %14 = OpTypePointer PushConstant %7 + %3 = OpVariable %14 PushConstant + %15 = OpTypeInt 32 1 + %16 = OpConstant %15 0 + %17 = OpTypePointer PushConstant %11 + %18 = OpTypePointer Function %11 + %19 = OpTypeFloat 32 + %20 = OpTypeVector %19 4 + %21 = OpTypePointer Output %20 + %4 = OpVariable %21 Output + %22 = OpConstant %19 1 + %23 = OpConstant %19 0 + %24 = OpConstantComposite %20 %22 %23 %22 %22 + %6 = OpFunction %11 None %13 +;CHECK: [[fn:%\w+]] = OpFunction [[pt]] None [[pt_fn]] + %27 = OpLabel + %28 = OpAccessChain %17 %3 %16 + %29 = OpLoad %11 %28 + OpReturnValue %29 + OpFunctionEnd + %2 = OpFunction %9 None %10 + %25 = OpLabel + %8 = OpVariable %18 Function + %26 = OpFunctionCall %11 %6 +;CHECK: {{%\w+}} = OpFunctionCall [[pt]] [[fn]] + OpStore %8 %26 + OpStore %4 %24 + OpReturn + OpFunctionEnd +)"; + + // For physical storage buffer support + SetTargetEnv(SPV_ENV_VULKAN_1_2); + SinglePassRunAndMatch(text, true); +} + +TEST_F(AggressiveDCETest, KeepBeginEndInvocationInterlock) { + // OpBeginInvocationInterlockEXT and OpEndInvocationInterlockEXT delimit a + // critical section. As such, they should be treated as if they have side + // effects and should not be removed. + const std::string test = + R"(OpCapability Shader +OpCapability FragmentShaderSampleInterlockEXT +OpExtension "SPV_EXT_fragment_shader_interlock" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %1 "main" %gl_FragCoord +OpExecutionMode %1 OriginUpperLeft +OpExecutionMode %1 SampleInterlockOrderedEXT +OpDecorate %gl_FragCoord BuiltIn FragCoord +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%void = OpTypeVoid +%8 = OpTypeFunction %void +%bool = OpTypeBool +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input +%1 = OpFunction %void None %8 +%10 = OpLabel +%11 = OpLoad %v4float %gl_FragCoord +%12 = OpCompositeExtract %float %11 0 +%13 = OpFOrdGreaterThan %bool %12 %float_0 +OpSelectionMerge %14 None +OpBranchConditional %13 %15 %16 +%15 = OpLabel +OpBeginInvocationInterlockEXT +OpBranch %14 +%16 = OpLabel +OpBeginInvocationInterlockEXT +OpBranch %14 +%14 = OpLabel +OpEndInvocationInterlockEXT +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(test, test, true, true); +} + +TEST_F(AggressiveDCETest, StoringAPointer) { + // A store that stores a pointer should not be kept live because the value + // being stored is eventually loaded from. + + const std::string text = R"( + OpCapability CooperativeMatrixKHR + OpCapability Shader + OpExtension "SPV_KHR_cooperative_matrix" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" %2 + OpExecutionMode %1 LocalSize 64 1 1 + OpSource HLSL 600 + OpDecorate %2 DescriptorSet 0 + OpDecorate %2 Binding 0 + OpDecorate %_runtimearr_int ArrayStride 4 + OpMemberDecorate %_struct_4 0 Offset 0 + OpDecorate %_struct_4 Block + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_64 = OpConstant %uint 64 + %uint_3 = OpConstant %uint 3 + %uint_16 = OpConstant %uint 16 + %uint_4 = OpConstant %uint 4 +%coop_stride = OpConstant %int 42 +%_runtimearr_int = OpTypeRuntimeArray %int + %_struct_4 = OpTypeStruct %_runtimearr_int +%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4 + %void = OpTypeVoid + %16 = OpTypeFunction %void +; CHECK: [[mat:%\w+]] = OpTypeCooperativeMatrixKHR %int %uint_3 %uint_16 %uint_4 %uint_0 + %17 = OpTypeCooperativeMatrixKHR %int %uint_3 %uint_16 %uint_4 %uint_0 +; CHECK: [[struct:%\w+]] = OpTypeStruct [[mat]] + %_struct_18 = OpTypeStruct %17 +; CHECK: [[ptr:%\w+]] = OpTypePointer Function [[struct]] +%_ptr_Function__struct_18 = OpTypePointer Function %_struct_18 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int +%_ptr_Function_17 = OpTypePointer Function %17 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Function__ptr_Function_int = OpTypePointer Function %_ptr_Function_int + %2 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer + +; The stored to the fist two variables should be removed and the variables +; as well. The only function scope variable should be the cooperative matrix. +; CHECK: OpFunction +; CHECK-NOT: OpVariable %_ptr_Function__ptr_Function_int Function +; CHECK: OpVariable [[ptr]] Function +; CHECK-NOT: OpVariable + %1 = OpFunction %void None %16 + %24 = OpLabel + %25 = OpVariable %_ptr_Function__ptr_Function_int Function + %26 = OpVariable %_ptr_Function__ptr_Function_int Function + %27 = OpVariable %_ptr_Function__struct_18 Function + %28 = OpAccessChain %_ptr_StorageBuffer_int %2 %int_0 %uint_0 + %29 = OpCooperativeMatrixLoadKHR %17 %28 %int_1 %coop_stride + %30 = OpCompositeConstruct %_struct_18 %29 + OpStore %27 %30 + %31 = OpAccessChain %_ptr_Function_17 %27 %int_0 + %32 = OpAccessChain %_ptr_Function_int %27 %int_0 %uint_0 + OpStore %26 %32 + %33 = OpLoad %int %32 + %34 = OpIAdd %int %33 %int_1 + OpStore %25 %32 + OpStore %32 %34 + %35 = OpAccessChain %_ptr_StorageBuffer_int %2 %int_0 %uint_64 + %36 = OpLoad %17 %31 + OpCooperativeMatrixStoreKHR %35 %36 %int_0 %coop_stride + OpReturn + OpFunctionEnd +)"; + + // For physical storage buffer support + SetTargetEnv(SPV_ENV_VULKAN_1_2); + SinglePassRunAndMatch(text, true); +} + +TEST_F(AggressiveDCETest, FunctionDeclaration) { + // Ensure the optimizer can handle traversing over a function declaration + // 'myfunc' which has no blocks + + const std::string text = R"(OpCapability Linkage +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %PSMain "main" %entryPointParam_PSMain +OpExecutionMode %PSMain OriginUpperLeft +OpSource Slang 1 +OpName %myfunc "myfunc" +OpName %entryPointParam_PSMain "entryPointParam_PSMain" +OpName %PSMain "PSMain" +OpDecorate %myfunc LinkageAttributes "_S6myfuncp0pv4f" Import +OpDecorate %entryPointParam_PSMain Location 0 +%void = OpTypeVoid +%5 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%8 = OpTypeFunction %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%entryPointParam_PSMain = OpVariable %_ptr_Output_v4float Output +%myfunc = OpFunction %v4float None %8 +OpFunctionEnd +%PSMain = OpFunction %void None %5 +%10 = OpLabel +%11 = OpFunctionCall %v4float %myfunc +OpStore %entryPointParam_PSMain %11 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndCheck(text, text, true, true); +} + +TEST_F(AggressiveDCETest, MarkCentroidInterpolantLive) { + const std::string spirv = + R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_COLOR "in.var.COLOR" +OpName %out_var_SV_Target "out.var.SV_Target" +OpName %main "main" +OpName %param_var_p1 "param.var.p1" +OpDecorate %in_var_COLOR Location 0 +OpDecorate %out_var_SV_Target Location 0 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%void = OpTypeVoid +%11 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output +%main = OpFunction %void None %11 +%13 = OpLabel +%14 = OpVariable %_ptr_Function_v4float Function +%param_var_p1 = OpVariable %_ptr_Function_v4float Function +%15 = OpLoad %v4float %in_var_COLOR +OpStore %param_var_p1 %15 +%16 = OpExtInst %v4float %1 InterpolateAtCentroid %param_var_p1 +OpStore %14 %16 +%17 = OpLoad %v4float %14 +OpStore %out_var_SV_Target %17 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(spirv, spirv, true, false); +} + +TEST_F(AggressiveDCETest, MarkSampleInterpolantLive) { + const std::string spirv = + R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_COLOR "in.var.COLOR" +OpName %out_var_SV_Target "out.var.SV_Target" +OpName %main "main" +OpName %param_var_p1 "param.var.p1" +OpDecorate %in_var_COLOR Location 0 +OpDecorate %out_var_SV_Target Location 0 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 1 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%void = OpTypeVoid +%12 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output +%int_123 = OpConstant %int 123 +%main = OpFunction %void None %12 +%15 = OpLabel +%16 = OpVariable %_ptr_Function_v4float Function +%param_var_p1 = OpVariable %_ptr_Function_v4float Function +%17 = OpLoad %v4float %in_var_COLOR +OpStore %param_var_p1 %17 +%18 = OpExtInst %v4float %1 InterpolateAtSample %param_var_p1 %int_123 +OpStore %16 %18 +%19 = OpLoad %v4float %16 +OpStore %out_var_SV_Target %19 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(spirv, spirv, true, false); +} + +TEST_F(AggressiveDCETest, MarkOffsetInterpolantLive) { + const std::string spirv = + R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_COLOR "in.var.COLOR" +OpName %out_var_SV_Target "out.var.SV_Target" +OpName %main "main" +OpName %param_var_p1 "param.var.p1" +OpDecorate %in_var_COLOR Location 0 +OpDecorate %out_var_SV_Target Location 0 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 1 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%void = OpTypeVoid +%12 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output +%int_123 = OpConstant %int 123 +%main = OpFunction %void None %12 +%15 = OpLabel +%16 = OpVariable %_ptr_Function_v4float Function +%param_var_p1 = OpVariable %_ptr_Function_v4float Function +%17 = OpLoad %v4float %in_var_COLOR +OpStore %param_var_p1 %17 +%18 = OpExtInst %v4float %1 InterpolateAtOffset %param_var_p1 %int_123 +OpStore %16 %18 +%19 = OpLoad %v4float %16 +OpStore %out_var_SV_Target %19 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(spirv, spirv, true, false); +} + +TEST_F(AggressiveDCETest, NoEliminateOpSource) { + // Should not eliminate OpSource + + const std::string text = + R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_TARGET +OpExecutionMode %main OriginUpperLeft +%4 = OpString "D:\\directxshadercompiler\\tools\\clang\\test\\CodeGenSPIRV\\spirv.debug.opsource.include.hlsl" +%5 = OpString "D:\\directxshadercompiler\\tools\\clang\\test\\CodeGenSPIRV/spirv.debug.opsource.include-file.hlsli" +OpSource HLSL 600 %4 "// RUN: %dxc -T ps_6_0 -E main -Zi %s -spirv | FileCheck %s +#include \"spirv.debug.opsource.include-file.hlsli\" + +struct ColorType +{ + float4 position : SV_POSITION; + float4 color : COLOR; +}; + +float4 main(UBER_TYPE(Color) input) : SV_TARGET +{ + return input.color; +} +" +OpSource HLSL 600 %5 "#define UBER_TYPE(x) x ## Type +" +OpName %in_var_COLOR "in.var.COLOR" +OpName %out_var_SV_TARGET "out.var.SV_TARGET" +OpName %main "main" +OpDecorate %in_var_COLOR Location 0 +OpDecorate %out_var_SV_TARGET Location 0 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%void = OpTypeVoid +%11 = OpTypeFunction %void +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output +OpLine %4 22 1 +%main = OpFunction %void None %11 +OpNoLine +%12 = OpLabel +OpLine %4 22 1 +%13 = OpLoad %v4float %in_var_COLOR +OpStore %out_var_SV_TARGET %13 +OpLine %4 25 1 +OpReturn +OpFunctionEnd +)"; + + auto result = SinglePassRunAndDisassemble( + text, /* skip_nop = */ true, /* skip_validation = */ false); + + EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result)); + const std::string& output = std::get<0>(result); + EXPECT_THAT( + output, + HasSubstr("OpSource HLSL 600 %5 \"#define UBER_TYPE(x) x ## Type")); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/amd_ext_to_khr.cpp b/third_party/spirv-tools/test/opt/amd_ext_to_khr.cpp index 3340e898ce..a520d600b1 100644 --- a/third_party/spirv-tools/test/opt/amd_ext_to_khr.cpp +++ b/third_party/spirv-tools/test/opt/amd_ext_to_khr.cpp @@ -26,15 +26,17 @@ using AmdExtToKhrTest = PassTest<::testing::Test>; using ::testing::HasSubstr; -std::string GetTest(std::string op_code, std::string new_op_code) { +std::string GetTest(std::string op_code, std::string new_op_code, + bool is_float = false) { const std::string text = R"( ; CHECK: OpCapability Shader ; CHECK-NOT: OpExtension "SPV_AMD_shader_ballot" ; CHECK: OpFunction ; CHECK-NEXT: OpLabel -; CHECK-NEXT: [[undef:%\w+]] = OpUndef %uint +; CHECK-NEXT: [[undef:%\w+]] = OpUndef % ; CHECK-NEXT: )" + new_op_code + - R"( %uint %uint_3 Reduce [[undef]] + " %" + (is_float ? "float" : "uint") + + R"( %uint_3 Reduce [[undef]] OpCapability Shader OpCapability Groups OpExtension "SPV_AMD_shader_ballot" @@ -44,12 +46,15 @@ std::string GetTest(std::string op_code, std::string new_op_code) { %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 %uint_3 = OpConstant %uint 3 %1 = OpFunction %void None %3 %6 = OpLabel - %7 = OpUndef %uint + %7 = OpUndef %)" + + (is_float ? "float" : "uint") + R"( %8 = )" + op_code + - R"( %uint %uint_3 Reduce %7 + " %" + (is_float ? "float" : "uint") + + R"( %uint_3 Reduce %7 OpReturn OpFunctionEnd @@ -64,7 +69,7 @@ TEST_F(AmdExtToKhrTest, ReplaceGroupIAddNonUniformAMD) { } TEST_F(AmdExtToKhrTest, ReplaceGroupFAddNonUniformAMD) { std::string text = - GetTest("OpGroupFAddNonUniformAMD", "OpGroupNonUniformFAdd"); + GetTest("OpGroupFAddNonUniformAMD", "OpGroupNonUniformFAdd", true); SinglePassRunAndMatch(text, true); } TEST_F(AmdExtToKhrTest, ReplaceGroupUMinNonUniformAMD) { @@ -79,7 +84,7 @@ TEST_F(AmdExtToKhrTest, ReplaceGroupSMinNonUniformAMD) { } TEST_F(AmdExtToKhrTest, ReplaceGroupFMinNonUniformAMD) { std::string text = - GetTest("OpGroupFMinNonUniformAMD", "OpGroupNonUniformFMin"); + GetTest("OpGroupFMinNonUniformAMD", "OpGroupNonUniformFMin", true); SinglePassRunAndMatch(text, true); } TEST_F(AmdExtToKhrTest, ReplaceGroupUMaxNonUniformAMD) { @@ -94,7 +99,7 @@ TEST_F(AmdExtToKhrTest, ReplaceGroupSMaxNonUniformAMD) { } TEST_F(AmdExtToKhrTest, ReplaceGroupFMaxNonUniformAMD) { std::string text = - GetTest("OpGroupFMaxNonUniformAMD", "OpGroupNonUniformFMax"); + GetTest("OpGroupFMaxNonUniformAMD", "OpGroupNonUniformFMax", true); SinglePassRunAndMatch(text, true); } diff --git a/third_party/spirv-tools/test/opt/analyze_live_input_test.cpp b/third_party/spirv-tools/test/opt/analyze_live_input_test.cpp index c2a8f4cb59..7f1ff2e0ce 100644 --- a/third_party/spirv-tools/test/opt/analyze_live_input_test.cpp +++ b/third_party/spirv-tools/test/opt/analyze_live_input_test.cpp @@ -15,7 +15,6 @@ #include -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/block_merge_test.cpp b/third_party/spirv-tools/test/opt/block_merge_test.cpp index 57c5061fd3..331ce3a7ae 100644 --- a/third_party/spirv-tools/test/opt/block_merge_test.cpp +++ b/third_party/spirv-tools/test/opt/block_merge_test.cpp @@ -1320,6 +1320,148 @@ OpFunctionEnd SinglePassRunAndMatch(text, true); } +TEST_F(BlockMergeTest, MaximalReconvergenceNoMeldToMerge) { + const std::string text = R"( + OpCapability Shader + OpCapability GroupNonUniformBallot + OpCapability GroupNonUniformArithmetic + OpExtension "SPV_KHR_maximal_reconvergence" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID %output + OpExecutionMode %main LocalSize 1 1 1 + OpExecutionMode %main MaximallyReconvergesKHR + OpSource HLSL 660 + OpName %type_RWStructuredBuffer_uint "type.RWStructuredBuffer.uint" + OpName %output "output" + OpName %main "main" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %output DescriptorSet 0 + OpDecorate %output Binding 0 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %type_RWStructuredBuffer_uint 0 Offset 0 + OpDecorate %type_RWStructuredBuffer_uint Block + %uint = OpTypeInt 32 0 + %bool = OpTypeBool + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %_runtimearr_uint = OpTypeRuntimeArray %uint + %type_RWStructuredBuffer_uint = OpTypeStruct %_runtimearr_uint + %_ptr_StorageBuffer_type_RWStructuredBuffer_uint = OpTypePointer StorageBuffer %type_RWStructuredBuffer_uint + %v3uint = OpTypeVector %uint 3 + %_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %15 = OpTypeFunction %void + %uint_3 = OpConstant %uint 3 + %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %output = OpVariable %_ptr_StorageBuffer_type_RWStructuredBuffer_uint StorageBuffer + %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %main = OpFunction %void None %15 + %18 = OpLabel + %19 = OpLoad %v3uint %gl_GlobalInvocationID + OpBranch %20 + %20 = OpLabel + OpLoopMerge %21 %22 None +; CHECK: OpLoopMerge [[merge:%\w+]] [[continue:%\w+]] + OpBranch %23 + %23 = OpLabel + %24 = OpCompositeExtract %uint %19 0 + %25 = OpGroupNonUniformBroadcastFirst %uint %uint_3 %24 + %26 = OpIEqual %bool %24 %25 + OpSelectionMerge %27 None + OpBranchConditional %26 %28 %27 + %28 = OpLabel + %29 = OpGroupNonUniformIAdd %int %uint_3 Reduce %int_1 + %30 = OpBitcast %uint %29 + OpBranch %21 +; CHECK: [[t1:%\w+]] = OpGroupNonUniformIAdd %int %uint_3 Reduce %int_1 +; CHECK-NEXT: [[t2:%\w+]] = OpBitcast %uint [[t1]] +; CHECK-NEXT: OpBranch [[merge]] + %27 = OpLabel + OpBranch %22 + %22 = OpLabel + OpBranch %20 + %21 = OpLabel + %31 = OpAccessChain %_ptr_StorageBuffer_uint %output %int_0 %24 + OpStore %31 %30 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SinglePassRunAndMatch(text, true); +} + +TEST_F(BlockMergeTest, NoMaximalReconvergenceMeldToMerge) { + const std::string text = R"( + OpCapability Shader + OpCapability GroupNonUniformBallot + OpCapability GroupNonUniformArithmetic + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID %output + OpExecutionMode %main LocalSize 1 1 1 + OpSource HLSL 660 + OpName %type_RWStructuredBuffer_uint "type.RWStructuredBuffer.uint" + OpName %output "output" + OpName %main "main" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %output DescriptorSet 0 + OpDecorate %output Binding 0 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %type_RWStructuredBuffer_uint 0 Offset 0 + OpDecorate %type_RWStructuredBuffer_uint Block + %uint = OpTypeInt 32 0 + %bool = OpTypeBool + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %_runtimearr_uint = OpTypeRuntimeArray %uint + %type_RWStructuredBuffer_uint = OpTypeStruct %_runtimearr_uint + %_ptr_StorageBuffer_type_RWStructuredBuffer_uint = OpTypePointer StorageBuffer %type_RWStructuredBuffer_uint + %v3uint = OpTypeVector %uint 3 + %_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %15 = OpTypeFunction %void + %uint_3 = OpConstant %uint 3 + %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %output = OpVariable %_ptr_StorageBuffer_type_RWStructuredBuffer_uint StorageBuffer + %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %main = OpFunction %void None %15 + %18 = OpLabel + %19 = OpLoad %v3uint %gl_GlobalInvocationID + OpBranch %20 + %20 = OpLabel + OpLoopMerge %21 %22 None +; CHECK: OpLoopMerge [[merge:%\w+]] [[continue:%\w+]] + OpBranch %23 + %23 = OpLabel + %24 = OpCompositeExtract %uint %19 0 + %25 = OpGroupNonUniformBroadcastFirst %uint %uint_3 %24 + %26 = OpIEqual %bool %24 %25 + OpSelectionMerge %27 None + OpBranchConditional %26 %28 %27 + %28 = OpLabel + %29 = OpGroupNonUniformIAdd %int %uint_3 Reduce %int_1 + %30 = OpBitcast %uint %29 + OpBranch %21 +; CHECK: [[merge]] = OpLabel +; CHECK-NEXT: [[t1:%\w+]] = OpGroupNonUniformIAdd %int %uint_3 Reduce %int_1 +; CHECK-NEXT: [[t2:%\w+]] = OpBitcast %uint [[t1]] + %27 = OpLabel + OpBranch %22 + %22 = OpLabel + OpBranch %20 + %21 = OpLabel + %31 = OpAccessChain %_ptr_StorageBuffer_uint %output %int_0 %24 + OpStore %31 %30 + OpReturn + OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_3); + SinglePassRunAndMatch(text, true); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // More complex control flow diff --git a/third_party/spirv-tools/test/opt/c_interface_test.cpp b/third_party/spirv-tools/test/opt/c_interface_test.cpp new file mode 100644 index 0000000000..a1725255ce --- /dev/null +++ b/third_party/spirv-tools/test/opt/c_interface_test.cpp @@ -0,0 +1,534 @@ +// Copyright (c) 2023 Nintendo +// +// 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 +#include + +#include "gtest/gtest.h" +#include "spirv-tools/libspirv.h" + +namespace spvtools { +namespace { + +TEST(OptimizerCInterface, DefaultConsumerWithValidationNoPassesForInvalidInput) { + const uint32_t spirv[] = { + 0xDEADFEED, // Invalid Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x01000000, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + // Do not register any passes + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, true); + + spv_binary binary = nullptr; + EXPECT_NE(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_EQ(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, SpecifyConsumerWithValidationNoPassesForInvalidInput) { + const uint32_t spirv[] = { + 0xDEADFEED, // Invalid Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x01000000, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + spvOptimizerSetMessageConsumer( + optimizer, + [](spv_message_level_t, const char*, const spv_position_t*, + const char* message) { + std::cout << message << std::endl; + }); + + // Do not register any passes + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, true); + + testing::internal::CaptureStdout(); + + spv_binary binary = nullptr; + EXPECT_NE(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_EQ(binary, nullptr); + + auto output = testing::internal::GetCapturedStdout(); + EXPECT_STRNE(output.c_str(), ""); + + spvOptimizerOptionsDestroy(options); + + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerWithValidationNoPassesForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000001, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + // Do not register any passes + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, true); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Should remain unchanged + EXPECT_EQ(binary->wordCount, sizeof(spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, spirv, sizeof(spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerNoPassesForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + // Do not register any passes + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, true); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Should remain unchanged + EXPECT_EQ(binary->wordCount, sizeof(spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, spirv, sizeof(spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerLegalizationPassesForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + spvOptimizerRegisterLegalizationPasses(optimizer); + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, false); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Only check that SPV_SUCCESS is returned, do not verify output + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerPerformancePassesForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + const uint32_t expected_spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000001, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + spvOptimizerRegisterPerformancePasses(optimizer); + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, false); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Unreferenced OpTypeInt and OpConstant should be removed + EXPECT_EQ(binary->wordCount, sizeof(expected_spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, expected_spirv, + sizeof(expected_spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerSizePassesForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + const uint32_t expected_spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000001, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + spvOptimizerRegisterSizePasses(optimizer); + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, false); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Unreferenced OpTypeInt and OpConstant should be removed + EXPECT_EQ(binary->wordCount, sizeof(expected_spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, expected_spirv, + sizeof(expected_spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerPassFromFlagForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + const uint32_t expected_spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000001, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + EXPECT_TRUE(spvOptimizerRegisterPassFromFlag( + optimizer, "--eliminate-dead-code-aggressive")); + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, false); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Unreferenced OpTypeInt and OpConstant should be removed + EXPECT_EQ(binary->wordCount, sizeof(expected_spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, expected_spirv, + sizeof(expected_spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerPassesFromFlagsForValidInput) { + const uint32_t spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000003, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001, // GLSL450 + 0x00040015, // OpTypeInt + 0x00000001, // %1 + 0x00000020, // 32 Bits + 0x00000000, // Unsigned + 0x0004002B, // OpConstant + 0x00000001, // %1 + 0x00000002, // %2 + 0x00000001 // 1 + }; + const uint32_t expected_spirv[] = { + 0x07230203, // Magic + 0x00010100, // Version 1.1 + 0x00000000, // No Generator + 0x00000001, // Bound + 0x00000000, // Schema + 0x00020011, // OpCapability + 0x00000001, // Shader + 0x00020011, // OpCapability + 0x00000005, // Linkage + 0x0003000E, // OpMemoryModel + 0x00000000, // Logical + 0x00000001 // GLSL450 + }; + + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + const char* flags[2] = { + "--eliminate-dead-const", + "--eliminate-dead-code-aggressive" + }; + + EXPECT_TRUE(spvOptimizerRegisterPassesFromFlags( + optimizer, flags, sizeof(flags) / sizeof(const char*))); + + auto options = spvOptimizerOptionsCreate(); + ASSERT_NE(options, nullptr); + spvOptimizerOptionsSetRunValidator(options, false); + + spv_binary binary = nullptr; + EXPECT_EQ(SPV_SUCCESS, + spvOptimizerRun(optimizer, spirv, sizeof(spirv) / sizeof(uint32_t), + &binary, options)); + ASSERT_NE(binary, nullptr); + + spvOptimizerOptionsDestroy(options); + + // Unreferenced OpTypeInt and OpConstant should be removed + EXPECT_EQ(binary->wordCount, sizeof(expected_spirv) / sizeof(uint32_t)); + EXPECT_EQ(memcmp(binary->code, expected_spirv, + sizeof(expected_spirv) / sizeof(uint32_t)), 0); + + spvBinaryDestroy(binary); + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerInvalidPassFromFlag) { + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + EXPECT_FALSE(spvOptimizerRegisterPassFromFlag( + optimizer, "--this-is-not-a-valid-pass")); + + spvOptimizerDestroy(optimizer); +} + +TEST(OptimizerCInterface, DefaultConsumerInvalidPassesFromFlags) { + auto optimizer = spvOptimizerCreate(SPV_ENV_UNIVERSAL_1_1); + ASSERT_NE(optimizer, nullptr); + + const char* flags[2] = { + "--eliminate-dead-const", + "--this-is-not-a-valid-pass" + }; + + EXPECT_FALSE(spvOptimizerRegisterPassesFromFlags( + optimizer, flags, sizeof(flags) / sizeof(const char*))); + + spvOptimizerDestroy(optimizer); +} + +} // namespace +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/ccp_test.cpp b/third_party/spirv-tools/test/opt/ccp_test.cpp index f0f2436240..a8e9557db0 100644 --- a/third_party/spirv-tools/test/opt/ccp_test.cpp +++ b/third_party/spirv-tools/test/opt/ccp_test.cpp @@ -14,7 +14,6 @@ #include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/ccp_pass.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/code_sink_test.cpp b/third_party/spirv-tools/test/opt/code_sink_test.cpp index bf5029b67c..98033fb0a6 100644 --- a/third_party/spirv-tools/test/opt/code_sink_test.cpp +++ b/third_party/spirv-tools/test/opt/code_sink_test.cpp @@ -14,7 +14,6 @@ #include -#include "gmock/gmock.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/combine_access_chains_test.cpp b/third_party/spirv-tools/test/opt/combine_access_chains_test.cpp index 5be3ba6384..ef7addc7eb 100644 --- a/third_party/spirv-tools/test/opt/combine_access_chains_test.cpp +++ b/third_party/spirv-tools/test/opt/combine_access_chains_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/compact_ids_test.cpp b/third_party/spirv-tools/test/opt/compact_ids_test.cpp index 7c232fe4c3..42f23517ed 100644 --- a/third_party/spirv-tools/test/opt/compact_ids_test.cpp +++ b/third_party/spirv-tools/test/opt/compact_ids_test.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/constant_manager_test.cpp b/third_party/spirv-tools/test/opt/constant_manager_test.cpp index 14e14ec20e..54c86527e4 100644 --- a/third_party/spirv-tools/test/opt/constant_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/constant_manager_test.cpp @@ -13,9 +13,7 @@ // limitations under the License. #include -#include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/build_module.h" #include "source/opt/constants.h" diff --git a/third_party/spirv-tools/test/opt/constants_test.cpp b/third_party/spirv-tools/test/opt/constants_test.cpp index 55c92a513f..1d4c738fc3 100644 --- a/third_party/spirv-tools/test/opt/constants_test.cpp +++ b/third_party/spirv-tools/test/opt/constants_test.cpp @@ -16,7 +16,6 @@ #include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/types.h" diff --git a/third_party/spirv-tools/test/opt/convert_relaxed_to_half_test.cpp b/third_party/spirv-tools/test/opt/convert_relaxed_to_half_test.cpp index 6a06de84f7..c5774045c3 100644 --- a/third_party/spirv-tools/test/opt/convert_relaxed_to_half_test.cpp +++ b/third_party/spirv-tools/test/opt/convert_relaxed_to_half_test.cpp @@ -1570,6 +1570,218 @@ TEST_F(ConvertToHalfTest, HandleNonRelaxedPhi) { EXPECT_EQ(Pass::Status::SuccessWithChange, std::get<1>(result)); } +TEST_F(ConvertToHalfTest, DoNotReplaceStructMember) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/4814 + + // This test is a case with a non-relaxed phi with a relaxed operand. + // A convert must be inserted at the end of the block associated with + // the operand. + const std::string test = + R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %PSMain "PSMain" %out_var_SV_TARGET %MyConstants +OpExecutionMode %PSMain OriginUpperLeft +OpSource HLSL 600 +OpName %type_ConstantBuffer_myStruct "type.ConstantBuffer.myStruct" +OpMemberName %type_ConstantBuffer_myStruct 0 "f" +OpName %MyConstants "MyConstants" +OpName %out_var_SV_TARGET "out.var.SV_TARGET" +OpName %PSMain "PSMain" +OpDecorate %out_var_SV_TARGET Location 0 +OpDecorate %MyConstants DescriptorSet 1 +OpDecorate %MyConstants Binding 2 +OpMemberDecorate %type_ConstantBuffer_myStruct 0 Offset 0 +OpDecorate %type_ConstantBuffer_myStruct Block +%float = OpTypeFloat 32 +%type_ConstantBuffer_myStruct = OpTypeStruct %float +%_ptr_Uniform_type_ConstantBuffer_myStruct = OpTypePointer Uniform %type_ConstantBuffer_myStruct +%_ptr_Output_float = OpTypePointer Output %float +%void = OpTypeVoid +%9 = OpTypeFunction %void +%MyConstants = OpVariable %_ptr_Uniform_type_ConstantBuffer_myStruct Uniform +%out_var_SV_TARGET = OpVariable %_ptr_Output_float Output +%PSMain = OpFunction %void None %9 +%10 = OpLabel +%11 = OpLoad %type_ConstantBuffer_myStruct %MyConstants +%12 = OpCompositeExtract %float %11 0 +OpStore %out_var_SV_TARGET %12 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndCheck(test, test, true); +} + +TEST_F(ConvertToHalfTest, PreserveImageOperandPrecision) { + // Ensure that a non-relaxed texture coordinate does not get relaxed nor + // converted to half precision if the image instruction is marked relaxed. + + // Also ensure that a relaxed local variable does get converted to half + // precision before being passed to an image opeartor. + + // #version 310 es + // + // precision mediump float; + // + // layout(location = 10) in highp vec4 vertex_uv01; + // layout(binding = 0, set = 3) uniform sampler2D materialParams_baseColorMap; + // + // layout(location = 0) out vec4 fragColor; + // + // void main() { + // vec4 uv = vec4(2.0); + // fragColor = texture(materialParams_baseColorMap, uv.xy); + // fragColor = texture(materialParams_baseColorMap, vertex_uv01.xy); + // } + const std::string test = R"( + OpCapability Shader + OpCapability Float16 + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %4 "main" %13 %25 + OpExecutionMode %4 OriginUpperLeft + OpSource ESSL 310 + OpDecorate %9 RelaxedPrecision +;CHECK: OpDecorate [[uv:%\w+]] RelaxedPrecision + OpDecorate %13 Location 0 + OpDecorate %17 DescriptorSet 3 + OpDecorate %17 Binding 0 + OpDecorate %18 RelaxedPrecision + OpDecorate %23 RelaxedPrecision + OpDecorate %25 Location 10 + %2 = OpTypeVoid + %3 = OpTypeFunction %2 + %6 = OpTypeFloat 32 +;CHECK: [[float32_t:%\w+]] = OpTypeFloat 32 + %7 = OpTypeVector %6 4 +;CHECK: [[vec4_t:%\w+]] = OpTypeVector [[float32_t]] 4 + %8 = OpTypePointer Function %7 + %10 = OpConstant %6 2 + %11 = OpConstantComposite %7 %10 %10 %10 %10 + %12 = OpTypePointer Output %7 +;CHECK: [[output_ptr_t:%\w+]] = OpTypePointer Output [[vec4_t]] + %13 = OpVariable %12 Output +;CHECK: [[output:%\w+]] = OpVariable [[output_ptr_t]] Output + %14 = OpTypeImage %6 2D 0 0 0 1 Unknown + %15 = OpTypeSampledImage %14 + %16 = OpTypePointer UniformConstant %15 + %17 = OpVariable %16 UniformConstant + %19 = OpTypeVector %6 2 +;CHECK: [[vec2_t:%\w+]] = OpTypeVector [[float32_t]] 2 + %24 = OpTypePointer Input %7 +;CHECK: [[input_ptr_t:%\w+]] = OpTypePointer Input [[vec4_t]] + %25 = OpVariable %24 Input + %29 = OpTypeFloat 16 +;CHECK: [[float16_t:%\w+]] = OpTypeFloat 16 + %30 = OpTypeVector %29 4 + %33 = OpTypeVector %29 2 +;CHECK: [[vec2_16b_t:%\w+]] = OpTypeVector [[float16_t]] 2 + %4 = OpFunction %2 None %3 + %5 = OpLabel + +; The only Function storage variable is marked as relaxed + %9 = OpVariable %8 Function +;CHECK: [[uv]] = OpVariable {{%\w+}} Function + OpStore %9 %11 + %18 = OpLoad %15 %17 + %20 = OpLoad %7 %9 + %31 = OpFConvert %30 %20 + %32 = OpFConvert %30 %20 + +; The first sample op should get a 16b coordinate + %21 = OpVectorShuffle %33 %31 %32 0 1 +;CHECK: [[uv_16b:%\w+]] = OpVectorShuffle [[vec2_16b_t]] + %22 = OpImageSampleImplicitLod %7 %18 %21 +;CHECK: OpImageSampleImplicitLod [[vec4_t]] {{%\w+}} [[uv_16b]] + + OpStore %13 %22 + %23 = OpLoad %15 %17 + %26 = OpLoad %7 %25 + +; The second sample op should get a 32b coordinate + %27 = OpVectorShuffle %19 %26 %26 0 1 +;CHECK: [[uv_32b:%\w+]] = OpVectorShuffle [[vec2_t]] + %28 = OpImageSampleImplicitLod %7 %23 %27 +;CHECK: OpImageSampleImplicitLod [[vec4_t]] {{%\w+}} [[uv_32b]] + + OpStore %13 %28 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch(test, true); +} + +TEST_F(ConvertToHalfTest, DontRelaxDecoratedOpCompositeExtract) { + // This test checks that a OpCompositeExtract with a Struct operand won't be + // relaxed, even if it is explicitly decorated with RelaxedPrecision. + const std::string test = + R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %1 "main" +OpExecutionMode %1 OriginUpperLeft +OpDecorate %9 RelaxedPrecision +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_struct_6 = OpTypeStruct %v4float +%7 = OpUndef %_struct_6 +%1 = OpFunction %void None %3 +%8 = OpLabel +%9 = OpCompositeExtract %float %7 0 3 +OpReturn +OpFunctionEnd +)"; + + const std::string expected = + R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %1 "main" +OpExecutionMode %1 OriginUpperLeft +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_struct_6 = OpTypeStruct %v4float +%7 = OpUndef %_struct_6 +%1 = OpFunction %void None %3 +%8 = OpLabel +%9 = OpCompositeExtract %float %7 0 3 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndCheck(test, expected, true); +} + +TEST_F(ConvertToHalfTest, DontRelaxOpCompositeExtract) { + // This test checks that a OpCompositeExtract with a Struct operand won't be + // relaxed, even if its result has no uses. + const std::string test = + R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %1 "main" +OpExecutionMode %1 OriginUpperLeft +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_struct_6 = OpTypeStruct %v4float +%7 = OpUndef %_struct_6 +%1 = OpFunction %void None %3 +%8 = OpLabel +%9 = OpCompositeExtract %float %7 0 3 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndCheck(test, test, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/copy_prop_array_test.cpp b/third_party/spirv-tools/test/opt/copy_prop_array_test.cpp index d6e376ecc7..7d8a325401 100644 --- a/third_party/spirv-tools/test/opt/copy_prop_array_test.cpp +++ b/third_party/spirv-tools/test/opt/copy_prop_array_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include "gmock/gmock.h" @@ -1943,6 +1942,210 @@ OpFunctionEnd SinglePassRunAndCheck(text, text, false); } + +// If the size of an array used in an OpCompositeInsert is not known at compile +// time, then we should not propagate the array, because we do not have a single +// array that represents the final value. +TEST_F(CopyPropArrayPassTest, SpecConstSizedArray) { + const std::string text = R"(OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main" +OpExecutionMode %2 OriginUpperLeft +%void = OpTypeVoid +%4 = OpTypeFunction %void +%int = OpTypeInt 32 1 +%uint = OpTypeInt 32 0 +%7 = OpSpecConstant %uint 32 +%_arr_int_7 = OpTypeArray %int %7 +%int_63 = OpConstant %int 63 +%uint_0 = OpConstant %uint 0 +%bool = OpTypeBool +%int_0 = OpConstant %int 0 +%int_587202566 = OpConstant %int 587202566 +%false = OpConstantFalse %bool +%_ptr_Function__arr_int_7 = OpTypePointer Function %_arr_int_7 +%16 = OpUndef %_arr_int_7 +%2 = OpFunction %void None %4 +%17 = OpLabel +%18 = OpVariable %_ptr_Function__arr_int_7 Function +%19 = OpCompositeInsert %_arr_int_7 %int_0 %16 0 +OpStore %18 %19 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, false); +} + +TEST_F(CopyPropArrayPassTest, InterpolateFunctions) { + const std::string before = R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_COLOR "in.var.COLOR" +OpName %main "main" +OpName %offset "offset" +OpDecorate %in_var_COLOR Location 0 +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%v2float = OpTypeVector %float 2 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%void = OpTypeVoid +%19 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%main = OpFunction %void None %19 +%20 = OpLabel +%45 = OpVariable %_ptr_Function_v4float Function +%25 = OpLoad %v4float %in_var_COLOR +OpStore %45 %25 +; CHECK: OpExtInst %v4float %1 InterpolateAtCentroid %in_var_COLOR +%52 = OpExtInst %v4float %1 InterpolateAtCentroid %45 +; CHECK: OpExtInst %v4float %1 InterpolateAtSample %in_var_COLOR %int_0 +%54 = OpExtInst %v4float %1 InterpolateAtSample %45 %int_0 +%offset = OpCompositeConstruct %v2float %float_0 %float_0 +; CHECK: OpExtInst %v4float %1 InterpolateAtOffset %in_var_COLOR %offset +%56 = OpExtInst %v4float %1 InterpolateAtOffset %45 %offset +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER | + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + SinglePassRunAndMatch(before, false); +} + +TEST_F(CopyPropArrayPassTest, InterpolateMultiPropagation) { + const std::string before = R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_COLOR +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_COLOR "in.var.COLOR" +OpName %main "main" +OpName %param_var_color "param.var.color" +OpDecorate %in_var_COLOR Location 0 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%void = OpTypeVoid +%19 = OpTypeFunction %void +%_ptr_Function_v4float = OpTypePointer Function %v4float +%in_var_COLOR = OpVariable %_ptr_Input_v4float Input +%main = OpFunction %void None %19 +%20 = OpLabel +%45 = OpVariable %_ptr_Function_v4float Function +%param_var_color = OpVariable %_ptr_Function_v4float Function +%25 = OpLoad %v4float %in_var_COLOR +OpStore %param_var_color %25 +; CHECK: OpExtInst %v4float %1 InterpolateAtCentroid %in_var_COLOR +%52 = OpExtInst %v4float %1 InterpolateAtCentroid %param_var_color +%49 = OpLoad %v4float %param_var_color +OpStore %45 %49 +; CHECK: OpExtInst %v4float %1 InterpolateAtCentroid %in_var_COLOR +%54 = OpExtInst %v4float %1 InterpolateAtCentroid %45 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER | + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + SinglePassRunAndMatch(before, false); +} + +TEST_F(CopyPropArrayPassTest, PropagateScalar) { + const std::string before = R"(OpCapability InterpolationFunction +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %in_var_SV_InstanceID +OpExecutionMode %main OriginUpperLeft +OpSource HLSL 680 +OpName %in_var_SV_InstanceID "in.var.SV_InstanceID" +OpName %main "main" +OpDecorate %in_var_SV_InstanceID Location 0 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%void = OpTypeVoid +%19 = OpTypeFunction %void +%_ptr_Function_float = OpTypePointer Function %float +%in_var_SV_InstanceID = OpVariable %_ptr_Input_float Input +%main = OpFunction %void None %19 +%20 = OpLabel +%45 = OpVariable %_ptr_Function_float Function +%25 = OpLoad %v4float %in_var_SV_InstanceID +OpStore %45 %25 +; CHECK: OpExtInst %v4float %1 InterpolateAtCentroid %in_var_SV_InstanceID +%52 = OpExtInst %v4float %1 InterpolateAtCentroid %45 +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER | + SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); + SinglePassRunAndMatch(before, false); +} + +TEST_F(CopyPropArrayPassTest, StoreToAccessChain) { + const std::string before = R"(OpCapability InterpolationFunction +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +OpMemoryModel Logical GLSL450 +OpEntryPoint MeshEXT %1 "main" %2 %3 +OpExecutionMode %1 LocalSize 128 1 1 +OpExecutionMode %1 OutputTrianglesEXT +OpExecutionMode %1 OutputVertices 64 +OpExecutionMode %1 OutputPrimitivesEXT 126 +OpDecorate %3 Flat +OpDecorate %3 Location 2 +%uint = OpTypeInt 32 0 +%uint_4 = OpConstant %uint 4 +%uint_32 = OpConstant %uint 32 +%_arr_uint_uint_32 = OpTypeArray %uint %uint_32 +%_struct_8 = OpTypeStruct %_arr_uint_uint_32 +%_ptr_TaskPayloadWorkgroupEXT__struct_8 = OpTypePointer TaskPayloadWorkgroupEXT %_struct_8 +%uint_64 = OpConstant %uint 64 +%_arr_uint_uint_64 = OpTypeArray %uint %uint_64 +%_ptr_Output__arr_uint_uint_64 = OpTypePointer Output %_arr_uint_uint_64 +%void = OpTypeVoid +%14 = OpTypeFunction %void +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Function__arr_uint_uint_32 = OpTypePointer Function %_arr_uint_uint_32 +%_ptr_Output_uint = OpTypePointer Output %uint +%2 = OpVariable %_ptr_TaskPayloadWorkgroupEXT__struct_8 TaskPayloadWorkgroupEXT +%3 = OpVariable %_ptr_Output__arr_uint_uint_64 Output +%1 = OpFunction %void None %14 +%18 = OpLabel +%19 = OpVariable %_ptr_Function__arr_uint_uint_32 Function +%20 = OpLoad %_struct_8 %2 +%21 = OpCompositeExtract %_arr_uint_uint_32 %20 0 +; CHECK: %28 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT__arr_uint_uint_32 %2 %uint_0 +OpStore %19 %21 +; CHECK: %22 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_uint %28 %uint_4 +%22 = OpAccessChain %_ptr_Function_uint %19 %uint_4 +%23 = OpLoad %uint %22 +%24 = OpAccessChain %_ptr_Output_uint %3 %uint_4 +OpStore %24 %23 +OpReturn +OpFunctionEnd +)"; + + SetTargetEnv(SPV_ENV_UNIVERSAL_1_4); + SinglePassRunAndMatch(before, true); +} } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/dataflow.cpp b/third_party/spirv-tools/test/opt/dataflow.cpp index 51473d84e7..dcb6bc6afe 100644 --- a/third_party/spirv-tools/test/opt/dataflow.cpp +++ b/third_party/spirv-tools/test/opt/dataflow.cpp @@ -17,7 +17,6 @@ #include #include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "opt/function_utils.h" #include "source/opt/build_module.h" diff --git a/third_party/spirv-tools/test/opt/dead_insert_elim_test.cpp b/third_party/spirv-tools/test/opt/dead_insert_elim_test.cpp index 268e659063..fcc3dde48d 100644 --- a/third_party/spirv-tools/test/opt/dead_insert_elim_test.cpp +++ b/third_party/spirv-tools/test/opt/dead_insert_elim_test.cpp @@ -736,6 +736,113 @@ OpFunctionEnd SinglePassRunAndMatch(text, true); } +TEST_F(DeadInsertElimTest, PhiOverEmptyStruct) { + // Reproducer for nullptr access error in MarkInsertChain + // that occurs when processing a phi operation with an + // empty struct result type. + // + // Note: Disassembly created from HLSL source with + // dxc -T cs_6_6 -spirv -Oconfig= + // --eliminate-dead-branches,--merge-return,--ssa-rewrite + // + // RWBuffer buf; + // + // struct S { }; + // + // S fn() { + // S s = (S)0; + // if (buf[0] > 0) { + // return s; + // } + // return s; + // } + // + // [numthreads(1,1,1)] + // void main() { + // fn(); + // } + + const std::string disassembly = + R"(OpCapability Shader + OpCapability SampledBuffer + OpCapability ImageBuffer + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource HLSL 660 + OpName %S "S" + OpName %type_buffer_image "type.buffer.image" + OpName %buf "buf" + OpName %main "main" + OpName %src_main "src.main" + OpName %bb_entry "bb.entry" + OpName %fn "fn" + OpName %bb_entry_0 "bb.entry" + OpName %s "s" + OpName %if_true "if.true" + OpName %if_merge "if.merge" + OpDecorate %buf DescriptorSet 0 + OpDecorate %buf Binding 0 + %S = OpTypeStruct + %4 = OpConstantNull %S + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %float = OpTypeFloat 32 + %float_0 = OpConstant %float 0 +%type_buffer_image = OpTypeImage %float Buffer 2 0 0 2 R32f +%_ptr_UniformConstant_type_buffer_image = OpTypePointer UniformConstant %type_buffer_image + %void = OpTypeVoid + %12 = OpTypeFunction %void + %19 = OpTypeFunction %S +%_ptr_Function_S = OpTypePointer Function %S + %v4float = OpTypeVector %float 4 + %bool = OpTypeBool + %buf = OpVariable %_ptr_UniformConstant_type_buffer_image UniformConstant + %false = OpConstantFalse %bool +%_ptr_Function_bool = OpTypePointer Function %bool + %true = OpConstantTrue %bool + %main = OpFunction %void None %12 + %13 = OpLabel + %14 = OpFunctionCall %void %src_main + OpReturn + OpFunctionEnd + %src_main = OpFunction %void None %12 + %bb_entry = OpLabel + %17 = OpFunctionCall %S %fn + OpReturn + OpFunctionEnd + %fn = OpFunction %S None %19 + %bb_entry_0 = OpLabel + %39 = OpVariable %_ptr_Function_bool Function %false + %34 = OpVariable %_ptr_Function_S Function + %s = OpVariable %_ptr_Function_S Function + OpSelectionMerge %33 None + OpSwitch %uint_0 %36 + %36 = OpLabel + OpStore %s %4 + %23 = OpLoad %type_buffer_image %buf + %25 = OpImageRead %v4float %23 %uint_0 None + %26 = OpCompositeExtract %float %25 0 + %28 = OpFOrdGreaterThan %bool %26 %float_0 + OpSelectionMerge %if_merge None + OpBranchConditional %28 %if_true %if_merge + %if_true = OpLabel + OpStore %39 %true + OpStore %34 %4 + OpBranch %33 + %if_merge = OpLabel + OpStore %39 %true + OpStore %34 %4 + OpBranch %33 + %33 = OpLabel + %41 = OpPhi %S %4 %if_true %4 %if_merge + OpReturnValue %41 + OpFunctionEnd +)"; + // Used to crash with a nullptr access violation when processing %41 + SinglePassRunToBinary(disassembly, true); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // diff --git a/third_party/spirv-tools/test/opt/debug_info_manager_test.cpp b/third_party/spirv-tools/test/opt/debug_info_manager_test.cpp index 9e479c0fb5..9c75728030 100644 --- a/third_party/spirv-tools/test/opt/debug_info_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/debug_info_manager_test.cpp @@ -15,11 +15,8 @@ #include "source/opt/debug_info_manager.h" #include -#include #include -#include "effcee/effcee.h" -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/build_module.h" #include "source/opt/instruction.h" @@ -802,6 +799,84 @@ void main(float in_var_color : COLOR) { 7); } +TEST(DebugInfoManager, ConvertGlobalToLocal) { + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "PSMain" %3 + OpExecutionMode %2 OriginUpperLeft + %4 = OpString "C:\\local\\Temp\\2528091a-6811-4e62-9ed5-02f1547c2016.hlsl" + %5 = OpString "float" + %6 = OpString "Pi" + %float = OpTypeFloat 32 +%float_3_1415 = OpConstant %float 3.1415 + %uint = OpTypeInt 32 0 + %uint_32 = OpConstant %uint 32 +%_ptr_Private_float = OpTypePointer Private %float +%_ptr_Function_float = OpTypePointer Function %float + %void = OpTypeVoid + %uint_3 = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_4 = OpConstant %uint 4 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_8 = OpConstant %uint 8 + %uint_6 = OpConstant %uint 6 + %uint_20 = OpConstant %uint 20 + %25 = OpTypeFunction %void + %uint_11 = OpConstant %uint 11 + %3 = OpVariable %_ptr_Private_float Private + %8 = OpExtInst %void %1 DebugTypeBasic %5 %uint_32 %uint_3 %uint_0 + %12 = OpExtInst %void %1 DebugSource %4 + %13 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %12 %uint_5 + %17 = OpExtInst %void %1 DebugGlobalVariable %6 %8 %12 %uint_6 %uint_20 %13 %6 %3 %uint_8 + %2 = OpFunction %void None %25 + %27 = OpLabel + %29 = OpVariable %_ptr_Function_float Function + OpStore %3 %float_3_1415 + %28 = OpExtInst %void %1 DebugLine %12 %uint_11 %uint_11 %uint_1 %uint_1 + OpReturn + OpFunctionEnd + )"; + + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + auto* def_use_mgr = context->get_def_use_mgr(); + auto* dbg_var = def_use_mgr->GetDef(17); + EXPECT_EQ(dbg_var->GetCommonDebugOpcode(), + OpenCLDebugInfo100DebugGlobalVariable); + EXPECT_EQ(dbg_var->NumInOperands(), 11); + + std::vector originalOperands; + for (uint32_t i = 0; i < dbg_var->NumInOperands(); ++i) { + originalOperands.emplace_back(dbg_var->GetInOperand((i))); + } + + auto* local_var = def_use_mgr->GetDef(29); + auto* dbg_info_mgr = context->get_debug_info_mgr(); + dbg_info_mgr->ConvertDebugGlobalToLocalVariable(dbg_var, local_var); + + EXPECT_EQ(dbg_var->NumInOperands(), 9); + + // This checks that the first two inoperands are correct. + EXPECT_EQ(dbg_var->GetCommonDebugOpcode(), + OpenCLDebugInfo100DebugLocalVariable); + + // Then next 6 operands should be the same as the original instruction. + EXPECT_EQ(dbg_var->GetInOperand(2), originalOperands[2]); + EXPECT_EQ(dbg_var->GetInOperand(3), originalOperands[3]); + EXPECT_EQ(dbg_var->GetInOperand(4), originalOperands[4]); + EXPECT_EQ(dbg_var->GetInOperand(5), originalOperands[5]); + EXPECT_EQ(dbg_var->GetInOperand(6), originalOperands[6]); + EXPECT_EQ(dbg_var->GetInOperand(7), originalOperands[7]); + + // The flags operand should have shifted because operand 8 and 9 in the global + // instruction are not relevant. + EXPECT_EQ(dbg_var->GetInOperand(8), originalOperands[10]); +} + } // namespace } // namespace analysis } // namespace opt diff --git a/third_party/spirv-tools/test/opt/decoration_manager_test.cpp b/third_party/spirv-tools/test/opt/decoration_manager_test.cpp index cf3516a9ff..b287d5ec97 100644 --- a/third_party/spirv-tools/test/opt/decoration_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/decoration_manager_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include diff --git a/third_party/spirv-tools/test/opt/def_use_test.cpp b/third_party/spirv-tools/test/opt/def_use_test.cpp index 431501274c..5f7731be3b 100644 --- a/third_party/spirv-tools/test/opt/def_use_test.cpp +++ b/third_party/spirv-tools/test/opt/def_use_test.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include #include diff --git a/third_party/spirv-tools/test/opt/desc_sroa_test.cpp b/third_party/spirv-tools/test/opt/desc_sroa_test.cpp index 91c950e88e..f86fa3a8fa 100644 --- a/third_party/spirv-tools/test/opt/desc_sroa_test.cpp +++ b/third_party/spirv-tools/test/opt/desc_sroa_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -200,7 +198,8 @@ TEST_F(DescriptorScalarReplacementTest, ExpandArrayOfTextures) { )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, ExpandArrayOfSamplers) { @@ -251,7 +250,8 @@ TEST_F(DescriptorScalarReplacementTest, ExpandArrayOfSamplers) { OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, ExpandArrayOfSSBOs) { @@ -310,7 +310,8 @@ TEST_F(DescriptorScalarReplacementTest, ExpandArrayOfSSBOs) { OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, NameNewVariables) { @@ -372,7 +373,8 @@ TEST_F(DescriptorScalarReplacementTest, NameNewVariables) { OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, DontExpandCBuffers) { @@ -432,7 +434,8 @@ TEST_F(DescriptorScalarReplacementTest, DontExpandCBuffers) { OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, DontExpandStructuredBuffers) { @@ -499,7 +502,8 @@ TEST_F(DescriptorScalarReplacementTest, DontExpandStructuredBuffers) { OpFunctionEnd )"; - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, StructureArrayNames) { @@ -513,7 +517,39 @@ TEST_F(DescriptorScalarReplacementTest, StructureArrayNames) { )"; const std::string text = checks + GetStructureArrayTestSpirv(); - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); +} + +TEST_F(DescriptorScalarReplacementTest, + FlattensArraysOfStructsButNoResourceArrays) { + // Check that only the composite array is flattenned, but internal resource + // arrays are left as-is. + const std::string checks = R"( +; CHECK: OpName %globalS_0__0__t "globalS[0][0].t" +; CHECK: OpName %globalS_0__0__s "globalS[0][0].s" +; CHECK: OpName %globalS_1__1__t "globalS[1][1].t" +; CHECK: OpName %globalS_1__1__s "globalS[1][1].s" +; CHECK-NOT: OpName %globalS_1__1__t_0_ +; CHECK-NOT: OpName %globalS_1__1__s_0_ + )"; + + const std::string text = checks + GetStructureArrayTestSpirv(); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/false); +} + +TEST_F(DescriptorScalarReplacementTest, FlattenNothingIfAskedTo) { + // Not useful, but checks what happens if both are set to false. + // In such case, nothing happens. + const std::string checks = R"( +; CHECK: OpName %globalS +; CHECK-NOT: OpName %globalS_ + )"; + + const std::string text = checks + GetStructureArrayTestSpirv(); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/false, /* flatten_arrays=*/false); } TEST_F(DescriptorScalarReplacementTest, StructureArrayBindings) { @@ -527,7 +563,8 @@ TEST_F(DescriptorScalarReplacementTest, StructureArrayBindings) { )"; const std::string text = checks + GetStructureArrayTestSpirv(); - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, StructureArrayReplacements) { @@ -542,7 +579,8 @@ TEST_F(DescriptorScalarReplacementTest, StructureArrayReplacements) { )"; const std::string text = checks + GetStructureArrayTestSpirv(); - SinglePassRunAndMatch(text, true); + SinglePassRunAndMatch( + text, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, ResourceStructAsFunctionParam) { @@ -726,7 +764,9 @@ TEST_F(DescriptorScalarReplacementTest, ResourceStructAsFunctionParam) { ; CHECK: OpFAdd %v4float [[sample_3]] [[sample_4]] )"; - SinglePassRunAndMatch(checks + shader, true); + SinglePassRunAndMatch( + checks + shader, true, /* flatten_composites=*/true, + /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, BindingForResourceArrayOfStructs) { @@ -767,7 +807,8 @@ TEST_F(DescriptorScalarReplacementTest, BindingForResourceArrayOfStructs) { OpFunctionEnd )"; - SinglePassRunAndMatch(shader, true); + SinglePassRunAndMatch( + shader, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, MemberDecorationForResourceStruct) { @@ -830,7 +871,8 @@ TEST_F(DescriptorScalarReplacementTest, MemberDecorationForResourceStruct) { OpFunctionEnd )"; - SinglePassRunAndMatch(shader, true); + SinglePassRunAndMatch( + shader, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); } TEST_F(DescriptorScalarReplacementTest, DecorateStringForReflect) { @@ -917,7 +959,230 @@ TEST_F(DescriptorScalarReplacementTest, DecorateStringForReflect) { OpFunctionEnd )"; - SinglePassRunAndMatch(shader, true); + SinglePassRunAndMatch( + shader, true, /* flatten_composites=*/true, /* flatten_arrays=*/true); +} + +TEST_F(DescriptorScalarReplacementTest, ExpandArrayInOpEntryPoint) { + const std::string text = R"(; SPIR-V +; Version: 1.6 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + +; CHECK: OpEntryPoint GLCompute %main "main" %output_0_ %output_1_ + + OpEntryPoint GLCompute %main "main" %output + OpExecutionMode %main LocalSize 1 1 1 + OpSource HLSL 670 + OpName %type_RWByteAddressBuffer "type.RWByteAddressBuffer" + OpName %output "output" + OpName %main "main" + OpName %src_main "src.main" + OpName %bb_entry "bb.entry" + +; CHECK: OpDecorate %output_1_ DescriptorSet 0 +; CHECK: OpDecorate %output_1_ Binding 1 +; CHECK: OpDecorate %output_0_ DescriptorSet 0 +; CHECK: OpDecorate %output_0_ Binding 0 + + OpDecorate %output DescriptorSet 0 + OpDecorate %output Binding 0 + + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %type_RWByteAddressBuffer 0 Offset 0 + OpDecorate %type_RWByteAddressBuffer Block + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_32 = OpConstant %uint 32 +%_runtimearr_uint = OpTypeRuntimeArray %uint +%type_RWByteAddressBuffer = OpTypeStruct %_runtimearr_uint +%_arr_type_RWByteAddressBuffer_uint_2 = OpTypeArray %type_RWByteAddressBuffer %uint_2 +%_ptr_StorageBuffer__arr_type_RWByteAddressBuffer_uint_2 = OpTypePointer StorageBuffer %_arr_type_RWByteAddressBuffer_uint_2 + %void = OpTypeVoid + %23 = OpTypeFunction %void +%_ptr_StorageBuffer_type_RWByteAddressBuffer = OpTypePointer StorageBuffer %type_RWByteAddressBuffer +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + +; CHECK: %output_1_ = OpVariable %_ptr_StorageBuffer_type_RWByteAddressBuffer StorageBuffer +; CHECK: %output_0_ = OpVariable %_ptr_StorageBuffer_type_RWByteAddressBuffer StorageBuffer + + %output = OpVariable %_ptr_StorageBuffer__arr_type_RWByteAddressBuffer_uint_2 StorageBuffer + + %main = OpFunction %void None %23 + %26 = OpLabel + %27 = OpFunctionCall %void %src_main + OpReturn + OpFunctionEnd + %src_main = OpFunction %void None %23 + %bb_entry = OpLabel + %28 = OpAccessChain %_ptr_StorageBuffer_type_RWByteAddressBuffer %output %int_1 + %29 = OpShiftRightLogical %uint %uint_0 %uint_2 + %30 = OpAccessChain %_ptr_StorageBuffer_uint %28 %uint_0 %29 + OpStore %30 %uint_32 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch( + text, false, /* flatten_composites=*/true, /* flatten_arrays=*/true); +} + +TEST_F(DescriptorScalarReplacementTest, + ExpandArrayWhenCompositeExpensionIsOff) { + const std::string text = R"(; SPIR-V +; Version: 1.6 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + +; CHECK: OpEntryPoint GLCompute %main "main" %output_0_ %output_1_ + + OpEntryPoint GLCompute %main "main" %output + OpExecutionMode %main LocalSize 1 1 1 + OpSource HLSL 670 + OpName %type_RWByteAddressBuffer "type.RWByteAddressBuffer" + OpName %output "output" + OpName %main "main" + OpName %src_main "src.main" + OpName %bb_entry "bb.entry" + +; CHECK: OpDecorate %output_1_ DescriptorSet 0 +; CHECK: OpDecorate %output_1_ Binding 1 +; CHECK: OpDecorate %output_0_ DescriptorSet 0 +; CHECK: OpDecorate %output_0_ Binding 0 + + OpDecorate %output DescriptorSet 0 + OpDecorate %output Binding 0 + + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %type_RWByteAddressBuffer 0 Offset 0 + OpDecorate %type_RWByteAddressBuffer Block + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_32 = OpConstant %uint 32 +%_runtimearr_uint = OpTypeRuntimeArray %uint +%type_RWByteAddressBuffer = OpTypeStruct %_runtimearr_uint +%_arr_type_RWByteAddressBuffer_uint_2 = OpTypeArray %type_RWByteAddressBuffer %uint_2 +%_ptr_StorageBuffer__arr_type_RWByteAddressBuffer_uint_2 = OpTypePointer StorageBuffer %_arr_type_RWByteAddressBuffer_uint_2 + %void = OpTypeVoid + %23 = OpTypeFunction %void +%_ptr_StorageBuffer_type_RWByteAddressBuffer = OpTypePointer StorageBuffer %type_RWByteAddressBuffer +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + +; CHECK: %output_1_ = OpVariable %_ptr_StorageBuffer_type_RWByteAddressBuffer StorageBuffer +; CHECK: %output_0_ = OpVariable %_ptr_StorageBuffer_type_RWByteAddressBuffer StorageBuffer + + %output = OpVariable %_ptr_StorageBuffer__arr_type_RWByteAddressBuffer_uint_2 StorageBuffer + + %main = OpFunction %void None %23 + %26 = OpLabel + %27 = OpFunctionCall %void %src_main + OpReturn + OpFunctionEnd + %src_main = OpFunction %void None %23 + %bb_entry = OpLabel + %28 = OpAccessChain %_ptr_StorageBuffer_type_RWByteAddressBuffer %output %int_1 + %29 = OpShiftRightLogical %uint %uint_0 %uint_2 + %30 = OpAccessChain %_ptr_StorageBuffer_uint %28 %uint_0 %29 + OpStore %30 %uint_32 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch( + text, false, /* flatten_composites=*/false, /* flatten_arrays=*/true); +} + +TEST_F(DescriptorScalarReplacementTest, ExpandStructButNotArray) { + const std::string text = R"(; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 41 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %out_var_SV_Target + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 660 + OpName %type_2d_image "type.2d.image" + OpName %Textures "Textures" + OpName %type_sampler "type.sampler" + OpName %out_var_SV_Target "out.var.SV_Target" + OpName %main "main" + OpName %type_sampled_image "type.sampled.image" + OpName %TheStruct "TheStruct" + OpMemberName %StructOfResources 0 "Texture" + OpMemberName %StructOfResources 1 "Sampler" +; CHECK: OpName %TheStruct_Sampler "TheStruct.Sampler" +; CHECK: OpName %TheStruct_Texture "TheStruct.Texture" + OpDecorate %out_var_SV_Target Location 0 + OpDecorate %Textures DescriptorSet 0 + OpDecorate %Textures Binding 0 + OpDecorate %TheStruct DescriptorSet 0 + OpDecorate %TheStruct Binding 10 +; CHECK: OpDecorate %TheStruct_Sampler DescriptorSet 0 +; CHECK: OpDecorate %TheStruct_Sampler Binding 11 +; CHECK: OpDecorate %TheStruct_Texture DescriptorSet 0 +; CHECK: OpDecorate %TheStruct_Texture Binding 10 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %float = OpTypeFloat 32 + %float_0 = OpConstant %float 0 + %v2float = OpTypeVector %float 2 + %13 = OpConstantComposite %v2float %float_0 %float_0 + %uint = OpTypeInt 32 0 + %uint_10 = OpConstant %uint 10 + %type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown + %_arr_type_2d_image_uint_10 = OpTypeArray %type_2d_image %uint_10 +%_ptr_UniformConstant__arr_type_2d_image_uint_10 = OpTypePointer UniformConstant %_arr_type_2d_image_uint_10 + %type_sampler = OpTypeSampler + %StructOfResources = OpTypeStruct %type_2d_image %type_sampler +%_ptr_UniformConstant__struct_18 = OpTypePointer UniformConstant %StructOfResources + %v4float = OpTypeVector %float 4 + %_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %23 = OpTypeFunction %void +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image + %_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler + %type_sampled_image = OpTypeSampledImage %type_2d_image + %Textures = OpVariable %_ptr_UniformConstant__arr_type_2d_image_uint_10 UniformConstant + %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output + %TheStruct = OpVariable %_ptr_UniformConstant__struct_18 UniformConstant + %main = OpFunction %void None %23 + %26 = OpLabel + %27 = OpAccessChain %_ptr_UniformConstant_type_2d_image %Textures %int_0 + %28 = OpLoad %type_2d_image %27 + %29 = OpAccessChain %_ptr_UniformConstant_type_sampler %TheStruct %int_1 + %31 = OpLoad %type_sampler %29 +; CHECK: %31 = OpLoad %type_sampler %TheStruct_Sampler + %32 = OpSampledImage %type_sampled_image %28 %31 + %33 = OpImageSampleImplicitLod %v4float %32 %13 None + %34 = OpAccessChain %_ptr_UniformConstant_type_2d_image %TheStruct %int_0 + %35 = OpLoad %type_2d_image %34 +; CHECK: %35 = OpLoad %type_2d_image %TheStruct_Texture + %36 = OpAccessChain %_ptr_UniformConstant_type_sampler %TheStruct %int_1 + %37 = OpLoad %type_sampler %36 +; CHECK: %37 = OpLoad %type_sampler %TheStruct_Sampler + %38 = OpSampledImage %type_sampled_image %35 %37 + %39 = OpImageSampleImplicitLod %v4float %38 %13 None + %40 = OpFAdd %v4float %33 %39 + OpStore %out_var_SV_Target %40 + OpReturn + OpFunctionEnd + )"; + + SinglePassRunAndMatch( + text, false, /* flatten_composites=*/true, /* flatten_arrays=*/false); } } // namespace diff --git a/third_party/spirv-tools/test/opt/dominator_tree/common_dominators.cpp b/third_party/spirv-tools/test/opt/dominator_tree/common_dominators.cpp index dfa03e986a..9573afa228 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/common_dominators.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/common_dominators.cpp @@ -13,9 +13,7 @@ // limitations under the License. #include -#include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/build_module.h" #include "source/opt/ir_context.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp b/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp index 4fccef0527..2a5bc98a75 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/generated.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs.cpp b/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs.cpp index 0552b75801..848296a236 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs.cpp @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. - #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs_post.cpp b/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs_post.cpp index ad759df868..217bdece1f 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs_post.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/nested_ifs_post.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/nested_loops.cpp b/third_party/spirv-tools/test/opt/dominator_tree/nested_loops.cpp index 7d03937b1a..a82f4095c4 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/nested_loops.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/nested_loops.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/nested_loops_with_unreachables.cpp b/third_party/spirv-tools/test/opt/dominator_tree/nested_loops_with_unreachables.cpp index e87e8ddab3..2c91bd1e2f 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/nested_loops_with_unreachables.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/nested_loops_with_unreachables.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/post.cpp b/third_party/spirv-tools/test/opt/dominator_tree/post.cpp index bb10fdef1d..acbf01272b 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/post.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/post.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/simple.cpp b/third_party/spirv-tools/test/opt/dominator_tree/simple.cpp index d11854d550..eae243850e 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/simple.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/simple.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/switch_case_fallthrough.cpp b/third_party/spirv-tools/test/opt/dominator_tree/switch_case_fallthrough.cpp index d9dd7d1619..9eeb4103b2 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/switch_case_fallthrough.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/switch_case_fallthrough.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for.cpp b/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for.cpp index 469e5c142d..bf95930d17 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for_post.cpp b/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for_post.cpp index 8d3e37b4a4..57278f50e0 100644 --- a/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for_post.cpp +++ b/third_party/spirv-tools/test/opt/dominator_tree/unreachable_for_post.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp index 87aab54511..ec4c284e68 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_const_test.cpp @@ -13,9 +13,6 @@ // limitations under the License. #include -#include -#include -#include #include #include #include diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_functions_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_functions_test.cpp index 96deb2a68c..e9f79a10f2 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_functions_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_functions_test.cpp @@ -517,6 +517,39 @@ OpFunctionEnd SinglePassRunAndMatch(text, true); } +TEST_F(EliminateDeadFunctionsBasicTest, DependentNonSemanticChain) { + const std::string text = R"( +; CHECK: OpEntryPoint GLCompute [[main:%\w+]] +; CHECK: [[main]] = OpFunction +; CHECK-NOT: = OpFunction +; CHECK: [[ext1:%\w+]] = OpExtInst %void {{%\w+}} 1 [[main]] +; CHECK: [[ext2:%\w+]] = OpExtInst %void {{%\w+}} 2 [[ext1]] +; CHECK: [[ext3:%\w+]] = OpExtInst %void {{%\w+}} 3 [[ext1]] [[ext2]] +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%1 = OpExtInstImport "NonSemantic.Test" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpReturn +OpFunctionEnd +%dead = OpFunction %void None %void_fn +%dead_entry = OpLabel +OpReturn +OpFunctionEnd +%2 = OpExtInst %void %1 1 %main +%3 = OpExtInst %void %1 2 %2 +%4 = OpExtInst %void %1 3 %2 %3 +)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_0); + SinglePassRunAndMatch(text, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_io_components_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_io_components_test.cpp index da26cefde5..b7a2fb5056 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_io_components_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_io_components_test.cpp @@ -15,7 +15,6 @@ #include -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_member_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_member_test.cpp index 4438f3d864..bb0ec039bc 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_member_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_member_test.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include "assembly_builder.h" -#include "gmock/gmock.h" #include "pass_fixture.h" #include "pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/eliminate_dead_output_stores_test.cpp b/third_party/spirv-tools/test/opt/eliminate_dead_output_stores_test.cpp index 470e709ebb..4c2e44c001 100644 --- a/third_party/spirv-tools/test/opt/eliminate_dead_output_stores_test.cpp +++ b/third_party/spirv-tools/test/opt/eliminate_dead_output_stores_test.cpp @@ -15,7 +15,6 @@ #include -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/feature_manager_test.cpp b/third_party/spirv-tools/test/opt/feature_manager_test.cpp index 94c7734b8e..7e8f92c3c1 100644 --- a/third_party/spirv-tools/test/opt/feature_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/feature_manager_test.cpp @@ -14,9 +14,7 @@ #include #include -#include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/build_module.h" #include "source/opt/ir_context.h" @@ -89,6 +87,25 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" Extension::kSPV_KHR_storage_buffer_storage_class)); } +TEST_F(FeatureManagerTest, GetExtensionsReturnsExtensions) { + const std::string text = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" + )"; + + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text); + ASSERT_NE(context, nullptr); + + const auto& extensions = context->get_feature_mgr()->GetExtensions(); + EXPECT_EQ(extensions.size(), 2); + EXPECT_TRUE(extensions.contains(Extension::kSPV_KHR_variable_pointers)); + EXPECT_TRUE( + extensions.contains(Extension::kSPV_KHR_storage_buffer_storage_class)); +} + // Test capability checks. TEST_F(FeatureManagerTest, ExplicitlyPresent1) { const std::string text = R"( @@ -144,6 +161,24 @@ OpMemoryModel Logical GLSL450 context->get_feature_mgr()->HasCapability(spv::Capability::Kernel)); } +TEST_F(FeatureManagerTest, GetCapabilitiesReturnsImplicitCapabilities) { + const std::string text = R"( +OpCapability Tessellation +OpMemoryModel Logical GLSL450 + )"; + + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text); + ASSERT_NE(context, nullptr); + + const auto& capabilities = context->get_feature_mgr()->GetCapabilities(); + // Tesselation implies Shader, which implies Matrix. + EXPECT_EQ(capabilities.size(), 3); + EXPECT_TRUE(capabilities.contains(spv::Capability::Tessellation)); + EXPECT_TRUE(capabilities.contains(spv::Capability::Shader)); + EXPECT_TRUE(capabilities.contains(spv::Capability::Matrix)); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp b/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp index ecd13a866d..606ed261ed 100644 --- a/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp +++ b/third_party/spirv-tools/test/opt/fix_func_call_arguments_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/fix_storage_class_test.cpp b/third_party/spirv-tools/test/opt/fix_storage_class_test.cpp index 1c0101a0e6..01a75e0d95 100644 --- a/third_party/spirv-tools/test/opt/fix_storage_class_test.cpp +++ b/third_party/spirv-tools/test/opt/fix_storage_class_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -876,6 +874,164 @@ TEST_F(FixTypeTest, FixPhiInLoop) { SinglePassRunAndMatch(text, false); } +TEST_F(FixStorageClassTest, SupportsU64Index) { + const std::string text = R"( +; CHECK: OpAccessChain %_ptr_Uniform_float + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "testMain" %gl_LocalInvocationID + OpExecutionMode %1 LocalSize 8 8 1 + OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId + OpDecorate %8 DescriptorSet 0 + OpDecorate %8 Binding 0 + OpDecorate %_runtimearr_float ArrayStride 4 + OpMemberDecorate %_struct_7 0 Offset 0 + OpDecorate %_struct_7 BufferBlock + %ulong = OpTypeInt 64 0 + %ulong_0 = OpConstant %ulong 0 + %float = OpTypeFloat 32 + %float_123 = OpConstant %float 123 + %uint = OpTypeInt 32 0 + %uint_10 = OpConstant %uint 10 +%_runtimearr_float = OpTypeRuntimeArray %float + %_struct_7 = OpTypeStruct %_runtimearr_float +%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %30 = OpTypeFunction %void +%_ptr_Uniform_float = OpTypePointer Uniform %float + %8 = OpVariable %_ptr_Uniform__struct_7 Uniform +%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %30 + %38 = OpLabel + %44 = OpLoad %v3uint %gl_LocalInvocationID + %59 = OpCompositeExtract %uint %44 0 + %60 = OpAccessChain %_ptr_Uniform_float %8 %ulong_0 %59 + OpStore %60 %float_123 + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} + +TEST_F(FixStorageClassTest, CorrectlyProcessAccessChainOnCoopMatrix) { + const std::string text = R"(OpCapability CooperativeMatrixKHR +OpCapability Shader +OpExtension "SPV_KHR_cooperative_matrix" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %1 "main" +OpExecutionMode %1 LocalSize 64 1 1 +OpSource HLSL 600 +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_3 = OpConstant %uint 3 +%uint_16 = OpConstant %uint 16 +%uint_4 = OpConstant %uint 4 +%9 = OpTypeCooperativeMatrixKHR %int %uint_3 %uint_16 %uint_4 %uint_0 +%void = OpTypeVoid +%11 = OpTypeFunction %void +%_struct_12 = OpTypeStruct %9 +%_ptr_Function__struct_12 = OpTypePointer Function %_struct_12 +%_ptr_Function_9 = OpTypePointer Function %9 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Function__ptr_Function_int = OpTypePointer Function %_ptr_Function_int +%1 = OpFunction %void None %11 +%17 = OpLabel +%18 = OpVariable %_ptr_Function__ptr_Function_int Function +%19 = OpVariable %_ptr_Function__struct_12 Function +%20 = OpAccessChain %_ptr_Function_9 %19 %int_0 +%21 = OpAccessChain %_ptr_Function_int %20 %uint_4 +OpStore %18 %21 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, false, false); +} + +// Tests that the pass is not confused when there are multiple definitions +// of a pointer type to the same type with the same storage class. +TEST_F(FixStorageClassTest, DuplicatePointerType) { + const std::string text = R"(OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %1 "main" +OpExecutionMode %1 LocalSize 64 1 1 +OpSource HLSL 600 +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_3 = OpConstant %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%void = OpTypeVoid +%7 = OpTypeFunction %void +%_struct_8 = OpTypeStruct %_arr_uint_uint_3 +%_ptr_Function__struct_8 = OpTypePointer Function %_struct_8 +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Function__arr_uint_uint_3 = OpTypePointer Function %_arr_uint_uint_3 +%_ptr_Function_uint_0 = OpTypePointer Function %uint +%_ptr_Function__ptr_Function_uint_0 = OpTypePointer Function %_ptr_Function_uint_0 +%1 = OpFunction %void None %7 +%14 = OpLabel +%15 = OpVariable %_ptr_Function__ptr_Function_uint_0 Function +%16 = OpVariable %_ptr_Function__struct_8 Function +%17 = OpAccessChain %_ptr_Function__arr_uint_uint_3 %16 %uint_0 +%18 = OpAccessChain %_ptr_Function_uint_0 %17 %uint_0 +OpStore %15 %18 +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(text, text, false); +} + +// This example is generated by DXC when certain inline spiir-v is used. +// The intention is that the function scope variable will eventually be +// optimized away, removing the type mismatch. We want to make sure the +// OpCopyObject is rewritten, and that the pass does not fail. +TEST_F(FixStorageClassTest, DoNotFailWithMismatchedPointerTypes) { + const std::string text = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" %38 + OpExecutionMode %1 LocalSize 64 1 1 + OpSource HLSL 600 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_float_uint_64 = OpTypeArray %float %uint_64 +%_ptr_Workgroup__arr_float_uint_64 = OpTypePointer Workgroup %_arr_float_uint_64 + %void = OpTypeVoid + %80 = OpTypeFunction %void +%_ptr_Workgroup_float = OpTypePointer Workgroup %float +%_ptr_Function__ptr_Workgroup_float = OpTypePointer Function %_ptr_Workgroup_float +%_ptr_Workgroup_float_0 = OpTypePointer Workgroup %float + %38 = OpVariable %_ptr_Workgroup__arr_float_uint_64 Workgroup + %1 = OpFunction %void None %80 + %98 = OpLabel +; CHECK: [[var:%\d+]] = OpVariable %_ptr_Function__ptr_Workgroup_float Function + %113 = OpVariable %_ptr_Function__ptr_Workgroup_float Function +; CHECK: [[ac:%\d+]] = OpAccessChain %_ptr_Workgroup_float_0 {{%\d+}} %int_0 + %136 = OpAccessChain %_ptr_Workgroup_float_0 %38 %int_0 +; Verify that the type for the OpCopyObject has changed to match [[ac]]. +; CHECK: [[copy:%\d+]] = OpCopyObject %_ptr_Workgroup_float_0 [[ac]] + %137 = OpCopyObject %_ptr_Workgroup_float %136 +; This has a type mismatch, but this is because we do not have a way to copy +; a pointer from one type to another, so FixStorageClass cannot do anything +; about it. We want fix storage class to leave it as is, and the validator +; will report an error if the store is not remove by a later optimization. +; CHECK: OpStore [[var]] [[copy]] + OpStore %113 %137 + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} } // namespace } // namespace opt diff --git a/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp b/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp index 63207fd21f..d7ac2ab789 100644 --- a/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp +++ b/third_party/spirv-tools/test/opt/flatten_decoration_test.cpp @@ -16,7 +16,6 @@ #include #include -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/fold_spec_const_op_composite_test.cpp b/third_party/spirv-tools/test/opt/fold_spec_const_op_composite_test.cpp index f83e86e961..335e0f5162 100644 --- a/third_party/spirv-tools/test/opt/fold_spec_const_op_composite_test.cpp +++ b/third_party/spirv-tools/test/opt/fold_spec_const_op_composite_test.cpp @@ -674,6 +674,31 @@ TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, CompositeInsertMatrixNull) { SinglePassRunAndMatch(test, false); } +// Silently ignore spec constants that cannot be folded +TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, UnfoldableOp) { + const std::string test = R"( + OpCapability Shader + OpCapability SignedZeroInfNanPreserve + OpExtension "SPV_KHR_float_controls" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" + OpSource GLSL 450 + OpDecorate %v SpecId 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v = OpConstant %float 0x1p-1 +%c = OpSpecConstantOp %float QuantizeToF16 %v +;CHECK: {{%\w+}} = OpSpecConstantOp {{%\w+}} QuantizeToF16 {{%\w+}} + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(test, false); +} + // All types and some common constants that are potentially required in // FoldSpecConstantOpAndCompositeTest. std::vector CommonTypesAndConstants() { @@ -1033,14 +1058,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%true = OpConstantTrue %bool", - "%true_0 = OpConstantTrue %bool", "%spec_bool_t_vec = OpConstantComposite %v2bool %bool_true %bool_true", - "%false = OpConstantFalse %bool", - "%false_0 = OpConstantFalse %bool", "%spec_bool_f_vec = OpConstantComposite %v2bool %bool_false %bool_false", - "%false_1 = OpConstantFalse %bool", - "%false_2 = OpConstantFalse %bool", "%spec_bool_from_null = OpConstantComposite %v2bool %bool_false %bool_false", }, }, @@ -1055,14 +1074,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%true = OpConstantTrue %bool", - "%true_0 = OpConstantTrue %bool", "%spec_bool_t_vec = OpConstantComposite %v2bool %bool_true %bool_true", - "%false = OpConstantFalse %bool", - "%false_0 = OpConstantFalse %bool", "%spec_bool_f_vec = OpConstantComposite %v2bool %bool_false %bool_false", - "%false_1 = OpConstantFalse %bool", - "%false_2 = OpConstantFalse %bool", "%spec_bool_from_null = OpConstantComposite %v2bool %bool_false %bool_false", }, }, @@ -1077,14 +1090,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%int_1 = OpConstant %int 1", - "%int_1_0 = OpConstant %int 1", "%spec_int_one_vec = OpConstantComposite %v2int %signed_one %signed_one", - "%int_0 = OpConstant %int 0", - "%int_0_0 = OpConstant %int 0", "%spec_int_zero_vec = OpConstantComposite %v2int %signed_zero %signed_zero", - "%int_0_1 = OpConstant %int 0", - "%int_0_2 = OpConstant %int 0", "%spec_int_from_null = OpConstantComposite %v2int %signed_zero %signed_zero", }, }, @@ -1099,14 +1106,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%int_1 = OpConstant %int 1", - "%int_1_0 = OpConstant %int 1", "%spec_int_one_vec = OpConstantComposite %v2int %signed_one %signed_one", - "%int_0 = OpConstant %int 0", - "%int_0_0 = OpConstant %int 0", "%spec_int_zero_vec = OpConstantComposite %v2int %signed_zero %signed_zero", - "%int_0_1 = OpConstant %int 0", - "%int_0_2 = OpConstant %int 0", "%spec_int_from_null = OpConstantComposite %v2int %signed_zero %signed_zero", }, }, @@ -1121,14 +1122,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%uint_1 = OpConstant %uint 1", - "%uint_1_0 = OpConstant %uint 1", "%spec_uint_one_vec = OpConstantComposite %v2uint %unsigned_one %unsigned_one", - "%uint_0 = OpConstant %uint 0", - "%uint_0_0 = OpConstant %uint 0", "%spec_uint_zero_vec = OpConstantComposite %v2uint %unsigned_zero %unsigned_zero", - "%uint_0_1 = OpConstant %uint 0", - "%uint_0_2 = OpConstant %uint 0", "%spec_uint_from_null = OpConstantComposite %v2uint %unsigned_zero %unsigned_zero", }, }, @@ -1143,14 +1138,8 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%uint_1 = OpConstant %uint 1", - "%uint_1_0 = OpConstant %uint 1", "%spec_uint_one_vec = OpConstantComposite %v2uint %unsigned_one %unsigned_one", - "%uint_0 = OpConstant %uint 0", - "%uint_0_0 = OpConstant %uint 0", "%spec_uint_zero_vec = OpConstantComposite %v2uint %unsigned_zero %unsigned_zero", - "%uint_0_1 = OpConstant %uint 0", - "%uint_0_2 = OpConstant %uint 0", "%spec_uint_from_null = OpConstantComposite %v2uint %unsigned_zero %unsigned_zero", }, }, @@ -1159,8 +1148,6 @@ INSTANTIATE_TEST_SUITE_P( { // original { - "%spec_uint_zero = OpSpecConstantOp %uint UConvert %bool_false", - "%spec_uint_one = OpSpecConstantOp %uint UConvert %bool_true", "%spec_ulong_zero = OpSpecConstantOp %ulong UConvert %unsigned_zero", "%spec_ulong_one = OpSpecConstantOp %ulong UConvert %unsigned_one", "%spec_short_zero = OpSpecConstantOp %ushort UConvert %unsigned_zero", @@ -1172,8 +1159,6 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%spec_uint_zero = OpConstant %uint 0", - "%spec_uint_one = OpConstant %uint 1", "%spec_ulong_zero = OpConstant %ulong 0", "%spec_ulong_one = OpConstant %ulong 1", "%spec_short_zero = OpConstant %ushort 0", @@ -1211,24 +1196,13 @@ INSTANTIATE_TEST_SUITE_P( { // original { - "%spec_v2uint_zero = OpSpecConstantOp %v2uint UConvert %bool_false_vec", - "%spec_v2uint_one = OpSpecConstantOp %v2uint UConvert %bool_true_vec", "%spec_v2ulong_zero = OpSpecConstantOp %v2ulong UConvert %unsigned_zero_vec", "%spec_v2ulong_one = OpSpecConstantOp %v2ulong UConvert %unsigned_one_vec", }, // expected { - "%uint_0 = OpConstant %uint 0", - "%uint_0_0 = OpConstant %uint 0", - "%spec_v2uint_zero = OpConstantComposite %v2uint %unsigned_zero %unsigned_zero", - "%uint_1 = OpConstant %uint 1", - "%uint_1_0 = OpConstant %uint 1", - "%spec_v2uint_one = OpConstantComposite %v2uint %unsigned_one %unsigned_one", - "%ulong_0 = OpConstant %ulong 0", - "%ulong_0_0 = OpConstant %ulong 0", "%spec_v2ulong_zero = OpConstantComposite %v2ulong %ulong_zero %ulong_zero", "%ulong_1 = OpConstant %ulong 1", - "%ulong_1_0 = OpConstant %ulong 1", "%spec_v2ulong_one = OpConstantComposite %v2ulong %ulong_1 %ulong_1", }, }, @@ -1243,14 +1217,10 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%long_0 = OpConstant %long 0", - "%long_0_0 = OpConstant %long 0", "%spec_v2long_zero = OpConstantComposite %v2long %long_zero %long_zero", "%long_1 = OpConstant %long 1", - "%long_1_0 = OpConstant %long 1", "%spec_v2long_one = OpConstantComposite %v2long %long_1 %long_1", "%long_n1 = OpConstant %long -1", - "%long_n1_0 = OpConstant %long -1", "%spec_v2long_minus_one = OpConstantComposite %v2long %long_n1 %long_n1", }, }, @@ -1347,7 +1317,7 @@ INSTANTIATE_TEST_SUITE_P( { "%int_minus_1 = OpConstant %int -1", "%int_minus_2 = OpConstant %int -2", - "%int_neg_null = OpConstant %int 0", + "%int_neg_null = OpConstantNull %int", "%int_max = OpConstant %int 2147483647", "%int_neg_max = OpConstant %int -2147483647", }, @@ -1528,15 +1498,10 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%int_n1 = OpConstant %int -1", - "%int_n1_0 = OpConstant %int -1", "%v2int_minus_1 = OpConstantComposite %v2int %signed_minus_one %signed_minus_one", "%int_n2 = OpConstant %int -2", - "%int_n2_0 = OpConstant %int -2", "%v2int_minus_2 = OpConstantComposite %v2int %int_n2 %int_n2", - "%int_0 = OpConstant %int 0", - "%int_0_0 = OpConstant %int 0", - "%v2int_neg_null = OpConstantComposite %v2int %signed_zero %signed_zero", + "%v2int_neg_null = OpConstantComposite %v2int %signed_null %signed_null", }, }, // vector integer (including null vetors) add, sub, div, mul @@ -1558,35 +1523,23 @@ INSTANTIATE_TEST_SUITE_P( // expected { "%int_5 = OpConstant %int 5", - "%int_5_0 = OpConstant %int 5", "%spec_v2int_iadd = OpConstantComposite %v2int %int_5 %int_5", "%int_n4 = OpConstant %int -4", - "%int_n4_0 = OpConstant %int -4", "%spec_v2int_isub = OpConstantComposite %v2int %int_n4 %int_n4", "%int_n2 = OpConstant %int -2", - "%int_n2_0 = OpConstant %int -2", "%spec_v2int_sdiv = OpConstantComposite %v2int %int_n2 %int_n2", "%int_n6 = OpConstant %int -6", - "%int_n6_0 = OpConstant %int -6", "%spec_v2int_imul = OpConstantComposite %v2int %int_n6 %int_n6", - "%int_n6_1 = OpConstant %int -6", - "%int_n6_2 = OpConstant %int -6", "%spec_v2int_iadd_null = OpConstantComposite %v2int %int_n6 %int_n6", "%uint_5 = OpConstant %uint 5", - "%uint_5_0 = OpConstant %uint 5", "%spec_v2uint_iadd = OpConstantComposite %v2uint %uint_5 %uint_5", "%uint_4294967292 = OpConstant %uint 4294967292", - "%uint_4294967292_0 = OpConstant %uint 4294967292", "%spec_v2uint_isub = OpConstantComposite %v2uint %uint_4294967292 %uint_4294967292", "%uint_1431655764 = OpConstant %uint 1431655764", - "%uint_1431655764_0 = OpConstant %uint 1431655764", "%spec_v2uint_udiv = OpConstantComposite %v2uint %uint_1431655764 %uint_1431655764", "%uint_2863311528 = OpConstant %uint 2863311528", - "%uint_2863311528_0 = OpConstant %uint 2863311528", "%spec_v2uint_imul = OpConstantComposite %v2uint %uint_2863311528 %uint_2863311528", - "%uint_2863311528_1 = OpConstant %uint 2863311528", - "%uint_2863311528_2 = OpConstant %uint 2863311528", "%spec_v2uint_isub_null = OpConstantComposite %v2uint %uint_2863311528 %uint_2863311528", }, }, @@ -1630,34 +1583,17 @@ INSTANTIATE_TEST_SUITE_P( "%v2int_minus_3 = OpConstantComposite %v2int %int_minus_3 %int_minus_3", // srem - "%int_1 = OpConstant %int 1", - "%int_1_0 = OpConstant %int 1", "%7_srem_3 = OpConstantComposite %v2int %signed_one %signed_one", - "%int_n1 = OpConstant %int -1", - "%int_n1_0 = OpConstant %int -1", "%minus_7_srem_3 = OpConstantComposite %v2int %signed_minus_one %signed_minus_one", - "%int_1_1 = OpConstant %int 1", - "%int_1_2 = OpConstant %int 1", "%7_srem_minus_3 = OpConstantComposite %v2int %signed_one %signed_one", - "%int_n1_1 = OpConstant %int -1", - "%int_n1_2 = OpConstant %int -1", "%minus_7_srem_minus_3 = OpConstantComposite %v2int %signed_minus_one %signed_minus_one", // smod - "%int_1_3 = OpConstant %int 1", - "%int_1_4 = OpConstant %int 1", "%7_smod_3 = OpConstantComposite %v2int %signed_one %signed_one", - "%int_2 = OpConstant %int 2", - "%int_2_0 = OpConstant %int 2", "%minus_7_smod_3 = OpConstantComposite %v2int %signed_two %signed_two", "%int_n2 = OpConstant %int -2", - "%int_n2_0 = OpConstant %int -2", "%7_smod_minus_3 = OpConstantComposite %v2int %int_n2 %int_n2", - "%int_n1_3 = OpConstant %int -1", - "%int_n1_4 = OpConstant %int -1", "%minus_7_smod_minus_3 = OpConstantComposite %v2int %signed_minus_one %signed_minus_one", // umod - "%uint_1 = OpConstant %uint 1", - "%uint_1_0 = OpConstant %uint 1", "%7_umod_3 = OpConstantComposite %v2uint %unsigned_one %unsigned_one", }, }, @@ -1677,26 +1613,15 @@ INSTANTIATE_TEST_SUITE_P( }, // expected { - "%int_2 = OpConstant %int 2", - "%int_2_0 = OpConstant %int 2", "%xor_1_3 = OpConstantComposite %v2int %signed_two %signed_two", - "%int_0 = OpConstant %int 0", - "%int_0_0 = OpConstant %int 0", "%and_1_2 = OpConstantComposite %v2int %signed_zero %signed_zero", - "%int_3 = OpConstant %int 3", - "%int_3_0 = OpConstant %int 3", "%or_1_2 = OpConstantComposite %v2int %signed_three %signed_three", "%unsigned_31 = OpConstant %uint 31", "%v2unsigned_31 = OpConstantComposite %v2uint %unsigned_31 %unsigned_31", "%uint_2147483648 = OpConstant %uint 2147483648", - "%uint_2147483648_0 = OpConstant %uint 2147483648", "%unsigned_left_shift_max = OpConstantComposite %v2uint %uint_2147483648 %uint_2147483648", - "%uint_1 = OpConstant %uint 1", - "%uint_1_0 = OpConstant %uint 1", "%unsigned_right_shift_logical = OpConstantComposite %v2uint %unsigned_one %unsigned_one", - "%int_n1 = OpConstant %int -1", - "%int_n1_0 = OpConstant %int -1", "%signed_right_shift_arithmetic = OpConstantComposite %v2int %signed_minus_one %signed_minus_one", }, }, @@ -2066,7 +1991,6 @@ INSTANTIATE_TEST_SUITE_P( "%spec_int_20 = OpConstant %int 101", "%used_vec_a = OpConstantComposite %v2int %spec_int_18 %spec_int_19", "%int_10201 = OpConstant %int 10201", - "%int_1 = OpConstant %int 1", "%used_vec_b = OpConstantComposite %v2int %int_10201 %signed_one", "%spec_int_21 = OpConstant %int 10201", "%array = OpConstantComposite %type_arr_int_4 %spec_int_20 %spec_int_20 %spec_int_21 %spec_int_21", diff --git a/third_party/spirv-tools/test/opt/fold_test.cpp b/third_party/spirv-tools/test/opt/fold_test.cpp index 06b91f3a66..003c44915e 100644 --- a/third_party/spirv-tools/test/opt/fold_test.cpp +++ b/third_party/spirv-tools/test/opt/fold_test.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "effcee/effcee.h" @@ -27,7 +26,6 @@ #include "source/opt/ir_context.h" #include "source/opt/module.h" #include "spirv-tools/libspirv.hpp" -#include "test/opt/pass_utils.h" namespace spvtools { namespace opt { @@ -68,42 +66,136 @@ struct InstructionFoldingCase { ResultType expected_result; }; +std::tuple, Instruction*> GetInstructionToFold( + const std::string test_body, const uint32_t id_to_fold, + spv_target_env spv_env) { + // Build module. + std::unique_ptr context = + BuildModule(spv_env, nullptr, test_body, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_NE(nullptr, context); + if (context == nullptr) { + return {nullptr, nullptr}; + } + + // Fold the instruction to test. + if (id_to_fold != 0) { + analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); + Instruction* inst = def_use_mgr->GetDef(id_to_fold); + return {std::move(context), inst}; + } + + // If there is not ID, we get the instruction just before a terminator + // instruction. That could be a return or abort. This is used for cases where + // the instruction we want to fold does not have a result id. + Function* func = &*context->module()->begin(); + for (auto& bb : *func) { + Instruction* terminator = bb.terminator(); + if (terminator->IsReturnOrAbort()) { + return {std::move(context), terminator->PreviousNode()}; + } + } + return {nullptr, nullptr}; +} + +std::tuple, Instruction*> FoldInstruction( + const std::string test_body, const uint32_t id_to_fold, + spv_target_env spv_env) { + // Build module. + std::unique_ptr context; + Instruction* inst = nullptr; + std::tie(context, inst) = + GetInstructionToFold(test_body, id_to_fold, spv_env); + + if (context == nullptr) { + return {nullptr, nullptr}; + } + + std::unique_ptr original_inst(inst->Clone(context.get())); + bool succeeded = context->get_instruction_folder().FoldInstruction(inst); + EXPECT_EQ(inst->result_id(), original_inst->result_id()); + EXPECT_EQ(inst->type_id(), original_inst->type_id()); + + if (!succeeded && inst != nullptr) { + EXPECT_EQ(inst->NumInOperands(), original_inst->NumInOperands()); + for (uint32_t i = 0; i < inst->NumInOperands(); ++i) { + EXPECT_EQ(inst->GetOperand(i), original_inst->GetOperand(i)); + } + } + + return {std::move(context), succeeded ? inst : nullptr}; +} + +template +void CheckForExpectedScalarConstant(Instruction* inst, + ElementType expected_result, + Function GetValue) { + ASSERT_TRUE(inst); + + IRContext* context = inst->context(); + analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); + while (inst->opcode() == spv::Op::OpCopyObject) { + inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); + } + + // Make sure we have a constant. + analysis::ConstantManager* const_mrg = context->get_constant_mgr(); + const analysis::Constant* constant = const_mrg->GetConstantFromInst(inst); + ASSERT_TRUE(constant); + + // Make sure the constant is a scalar. + const analysis::ScalarConstant* result = constant->AsScalarConstant(); + ASSERT_TRUE(result); + + // Check if the result matches the expected value. + // If ExpectedType is not a float type, it should cast the value to a double + // and never get a nan. + if (!std::isnan(static_cast(expected_result))) { + EXPECT_EQ(expected_result, GetValue(result)); + } else { + EXPECT_TRUE(std::isnan(static_cast(GetValue(result)))); + } +} + +template +void CheckForExpectedVectorConstant(Instruction* inst, + std::vector expected_result, + Function GetValue) { + ASSERT_TRUE(inst); + + IRContext* context = inst->context(); + EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); + analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); + inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); + std::vector opcodes = {spv::Op::OpConstantComposite}; + EXPECT_THAT(opcodes, Contains(inst->opcode())); + analysis::ConstantManager* const_mrg = context->get_constant_mgr(); + const analysis::Constant* result = const_mrg->GetConstantFromInst(inst); + EXPECT_NE(result, nullptr); + if (result != nullptr) { + const std::vector& componenets = + result->AsVectorConstant()->GetComponents(); + EXPECT_EQ(componenets.size(), expected_result.size()); + for (size_t i = 0; i < componenets.size(); i++) { + EXPECT_EQ(expected_result[i], GetValue(componenets[i])); + } + } +} + using IntegerInstructionFoldingTest = ::testing::TestWithParam>; TEST_P(IntegerInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_TRUE(succeeded); - if (inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - EXPECT_EQ(inst->opcode(), spv::Op::OpConstant); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::Constant* constant = const_mrg->GetConstantFromInst(inst); - // We expect to see either integer types or 16-bit float types here. - EXPECT_TRUE((constant->AsIntConstant() != nullptr) || - ((constant->AsFloatConstant() != nullptr) && - (constant->type()->AsFloat()->width() == 16))); - const analysis::ScalarConstant* result = - const_mrg->GetConstantFromInst(inst)->AsScalarConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - EXPECT_EQ(result->GetU32BitValue(), tc.expected_result); - } - } + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedScalarConstant( + inst, tc.expected_result, [](const analysis::Constant* c) { + return c->AsScalarConstant()->GetU32BitValue(); + }); } // Returns a common SPIR-V header for all of the test that follow. @@ -123,6 +215,8 @@ OpCapability Float64 OpCapability Int8 OpCapability Int16 OpCapability Int64 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %main "main" @@ -149,14 +243,20 @@ OpName %main "main" %ulong = OpTypeInt 64 0 %v2int = OpTypeVector %int 2 %v4int = OpTypeVector %int 4 +%v2short = OpTypeVector %short 2 +%v2long = OpTypeVector %long 2 +%v4long = OpTypeVector %long 4 %v4float = OpTypeVector %float 4 %v4double = OpTypeVector %double 4 %v2uint = OpTypeVector %uint 2 +%v2ulong = OpTypeVector %ulong 2 %v2float = OpTypeVector %float 2 %v2double = OpTypeVector %double 2 %v2half = OpTypeVector %half 2 %v2bool = OpTypeVector %bool 2 %m2x2int = OpTypeMatrix %v2int 2 +%mat4v2float = OpTypeMatrix %v2float 4 +%mat2v4float = OpTypeMatrix %v4float 2 %mat4v4float = OpTypeMatrix %v4float 4 %mat4v4double = OpTypeMatrix %v4double 4 %struct_v2int_int_int = OpTypeStruct %v2int %int %int @@ -175,16 +275,18 @@ OpName %main "main" %_ptr_struct_v2int_int_int = OpTypePointer Function %struct_v2int_int_int %_ptr_v2float = OpTypePointer Function %v2float %_ptr_v2double = OpTypePointer Function %v2double +%int_2 = OpConstant %int 2 +%int_arr_2 = OpTypeArray %int %int_2 %short_0 = OpConstant %short 0 %short_2 = OpConstant %short 2 %short_3 = OpConstant %short 3 +%short_n5 = OpConstant %short -5 %ubyte_1 = OpConstant %ubyte 1 %byte_n1 = OpConstant %byte -1 %100 = OpConstant %int 0 ; Need a def with an numerical id to define id maps. %103 = OpConstant %int 7 ; Need a def with an numerical id to define id maps. %int_0 = OpConstant %int 0 %int_1 = OpConstant %int 1 -%int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 %int_4 = OpConstant %int 4 %int_10 = OpConstant %int 10 @@ -198,12 +300,20 @@ OpName %main "main" %long_1 = OpConstant %long 1 %long_2 = OpConstant %long 2 %long_3 = OpConstant %long 3 +%long_n3 = OpConstant %long -3 +%long_7 = OpConstant %long 7 +%long_n7 = OpConstant %long -7 %long_10 = OpConstant %long 10 +%long_32768 = OpConstant %long 32768 +%long_n57344 = OpConstant %long -57344 +%long_n4611686018427387904 = OpConstant %long -4611686018427387904 %long_4611686018427387904 = OpConstant %long 4611686018427387904 %long_n1 = OpConstant %long -1 %long_n3689348814741910323 = OpConstant %long -3689348814741910323 %long_min = OpConstant %long -9223372036854775808 %long_max = OpConstant %long 9223372036854775807 +%ulong_7 = OpConstant %ulong 7 +%ulong_4611686018427387904 = OpConstant %ulong 4611686018427387904 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -224,8 +334,12 @@ OpName %main "main" %v2int_2_2 = OpConstantComposite %v2int %int_2 %int_2 %v2int_2_3 = OpConstantComposite %v2int %int_2 %int_3 %v2int_3_2 = OpConstantComposite %v2int %int_3 %int_2 +%v2int_n1_n24 = OpConstantComposite %v2int %int_n1 %int_n24 %v2int_4_4 = OpConstantComposite %v2int %int_4 %int_4 %v2int_min_max = OpConstantComposite %v2int %int_min %int_max +%v2short_2_n5 = OpConstantComposite %v2short %short_2 %short_n5 +%v2long_2_2 = OpConstantComposite %v2long %long_2 %long_2 +%v2long_2_3 = OpConstantComposite %v2long %long_2 %long_3 %v2bool_null = OpConstantNull %v2bool %v2bool_true_false = OpConstantComposite %v2bool %true %false %v2bool_false_true = OpConstantComposite %v2bool %false %true @@ -283,6 +397,7 @@ OpName %main "main" %v2double_null = OpConstantNull %v2double %108 = OpConstant %half 0 %half_1 = OpConstant %half 1 +%half_2 = OpConstant %half 2 %half_0_1 = OpConstantComposite %v2half %108 %half_1 %106 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 %v4float_0_0_0_0 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 @@ -291,8 +406,10 @@ OpName %main "main" %v4float_1_1_1_1 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %v4float_1_2_3_4 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4 %v4float_null = OpConstantNull %v4float -%mat4v4float_null = OpConstantComposite %mat4v4float %v4float_null %v4float_null %v4float_null %v4float_null +%mat2v4float_null = OpConstantNull %mat2v4float +%mat4v4float_null = OpConstantNull %mat4v4float %mat4v4float_1_2_3_4 = OpConstantComposite %mat4v4float %v4float_1_2_3_4 %v4float_1_2_3_4 %v4float_1_2_3_4 %v4float_1_2_3_4 +%mat4v4float_1_2_3_4_null = OpConstantComposite %mat4v4float %v4float_1_2_3_4 %v4float_null %v4float_1_2_3_4 %v4float_null %107 = OpConstantComposite %v4double %double_0 %double_0 %double_0 %double_0 %v4double_0_0_0_0 = OpConstantComposite %v4double %double_0 %double_0 %double_0 %double_0 %v4double_0_0_0_1 = OpConstantComposite %v4double %double_0 %double_0 %double_0 %double_1 @@ -301,8 +418,9 @@ OpName %main "main" %v4double_1_2_3_4 = OpConstantComposite %v4double %double_1 %double_2 %double_3 %double_4 %v4double_1_1_1_0p5 = OpConstantComposite %v4double %double_1 %double_1 %double_1 %double_0p5 %v4double_null = OpConstantNull %v4double -%mat4v4double_null = OpConstantComposite %mat4v4double %v4double_null %v4double_null %v4double_null %v4double_null +%mat4v4double_null = OpConstantNull %mat4v4double %mat4v4double_1_2_3_4 = OpConstantComposite %mat4v4double %v4double_1_2_3_4 %v4double_1_2_3_4 %v4double_1_2_3_4 %v4double_1_2_3_4 +%mat4v4double_1_2_3_4_null = OpConstantComposite %mat4v4double %v4double_1_2_3_4 %v4double_null %v4double_1_2_3_4 %v4double_null %v4float_n1_2_1_3 = OpConstantComposite %v4float %float_n1 %float_2 %float_1 %float_3 %uint_0x3f800000 = OpConstant %uint 0x3f800000 %uint_0xbf800000 = OpConstant %uint 0xbf800000 @@ -313,8 +431,17 @@ OpName %main "main" %int_0xC05FD666 = OpConstant %int 0xC05FD666 %int_0x66666666 = OpConstant %int 0x66666666 %v4int_0x3FF00000_0x00000000_0xC05FD666_0x66666666 = OpConstantComposite %v4int %int_0x00000000 %int_0x3FF00000 %int_0x66666666 %int_0xC05FD666 +%ushort_0x4400 = OpConstant %ushort 0x4400 +%short_0x4400 = OpConstant %short 0x4400 %ushort_0xBC00 = OpConstant %ushort 0xBC00 %short_0xBC00 = OpConstant %short 0xBC00 +%int_arr_2_undef = OpUndef %int_arr_2 +%int_coop_matrix = OpTypeCooperativeMatrixKHR %int %uint_3 %uint_3 %uint_32 %uint_0 +%undef_int_coop_matrix = OpUndef %int_coop_matrix +%uint_coop_matrix = OpTypeCooperativeMatrixKHR %uint %uint_3 %uint_3 %uint_32 %uint_0 +%undef_uint_coop_matrix = OpUndef %uint_coop_matrix +%float_coop_matrix = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_3 %uint_32 %uint_0 +%undef_float_coop_matrix = OpUndef %float_coop_matrix )"; return header; @@ -748,7 +875,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 1), - // Test case 44: UClamp 1 2 x + // Test case 46: UClamp 1 2 x InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -757,7 +884,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 2), - // Test case 45: UClamp 2 x 1 + // Test case 47: UClamp 2 x 1 InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -766,7 +893,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 1), - // Test case 46: Bit-cast int 0 to unsigned int + // Test case 48: Bit-cast int 0 to unsigned int InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -774,7 +901,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0), - // Test case 47: Bit-cast int -24 to unsigned int + // Test case 49: Bit-cast int -24 to unsigned int InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -782,7 +909,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, static_cast(-24)), - // Test case 48: Bit-cast float 1.0f to unsigned int + // Test case 50: Bit-cast float 1.0f to unsigned int InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -790,7 +917,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, static_cast(0x3f800000)), - // Test case 49: Bit-cast ushort 0xBC00 to ushort + // Test case 51: Bit-cast ushort 0xBC00 to ushort InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -798,15 +925,15 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0xBC00), - // Test case 50: Bit-cast short 0xBC00 to ushort + // Test case 52: Bit-cast short 0xBC00 to ushort InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%2 = OpBitcast %ushort %short_0xBC00\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 0xFFFFBC00), - // Test case 51: Bit-cast half 1 to ushort + 2, 0xBC00), + // Test case 53: Bit-cast half 1 to ushort InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -814,15 +941,15 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0x3C00), - // Test case 52: Bit-cast ushort 0xBC00 to short + // Test case 54: Bit-cast ushort 0xBC00 to short InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%2 = OpBitcast %short %ushort_0xBC00\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 0xBC00), - // Test case 53: Bit-cast short 0xBC00 to short + 2, 0xFFFFBC00), + // Test case 55: Bit-cast short 0xBC00 to short InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -830,7 +957,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0xFFFFBC00), - // Test case 54: Bit-cast half 1 to short + // Test case 56: Bit-cast half 1 to short InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -838,7 +965,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0x3C00), - // Test case 55: Bit-cast ushort 0xBC00 to half + // Test case 57: Bit-cast ushort 0xBC00 to half InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -846,7 +973,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0xBC00), - // Test case 56: Bit-cast short 0xBC00 to half + // Test case 58: Bit-cast short 0xBC00 to half InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -854,7 +981,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0xFFFFBC00), - // Test case 57: Bit-cast half 1 to half + // Test case 59: Bit-cast half 1 to half InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -862,7 +989,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 0x3C00), - // Test case 58: Bit-cast ubyte 1 to byte + // Test case 60: Bit-cast ubyte 1 to byte InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -870,58 +997,302 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, 1), - // Test case 59: Bit-cast byte -1 to ubyte + // Test case 61: Bit-cast byte -1 to ubyte InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%2 = OpBitcast %ubyte %byte_n1\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 0xFFFFFFFF) + 2, 0xFF), + // Test case 62: Negate 2. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %int %int_2\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -2), + // Test case 63: Negate negative short. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %short %short_0xBC00\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0x4400 /* expected to be sign extended. */), + // Test case 64: Negate positive short. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %short %short_0x4400\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0xFFFFBC00 /* expected to be sign extended. */), + // Test case 65: Negate a negative short. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %ushort %ushort_0xBC00\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0x4400 /* expected to be zero extended. */), + // Test case 66: Negate positive short. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %ushort %ushort_0x4400\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0xBC00 /* expected to be zero extended. */), + // Test case 67: Fold 2 + 3 (short) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIAdd %short %short_2 %short_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 5), + // Test case 68: Fold 2 + -5 (short) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIAdd %short %short_2 %short_n5\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -3), + // Test case 69: Fold int(3ll) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSConvert %int %long_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 3), + // Test case 70: Fold short(-3ll) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSConvert %short %long_n3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -3), + // Test case 71: Fold short(32768ll) - This should do a sign extend when + // converting to short. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSConvert %short %long_32768\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, -32768), + // Test case 72: Fold short(-57344) - This should do a sign extend when + // converting to short making the upper bits 0. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSConvert %short %long_n57344\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 8192), + // Test case 73: Fold int(-5(short)). The -5 should be interpreted as an unsigned value, and be zero extended to 32-bits. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpUConvert %uint %short_n5\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 65531), + // Test case 74: Fold short(-24(int)). The upper bits should be cleared. So 0xFFFFFFE8 should become 0x0000FFE8. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpUConvert %ushort %int_n24\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 65512) )); // clang-format on -using IntVectorInstructionFoldingTest = - ::testing::TestWithParam>>; +using LongIntegerInstructionFoldingTest = + ::testing::TestWithParam>; -TEST_P(IntVectorInstructionFoldingTest, Case) { +TEST_P(LongIntegerInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedScalarConstant( + inst, tc.expected_result, [](const analysis::Constant* c) { + return c->AsScalarConstant()->GetU64BitValue(); + }); +} - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - spv::Op original_opcode = inst->opcode(); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); +INSTANTIATE_TEST_SUITE_P( + TestCase, LongIntegerInstructionFoldingTest, + ::testing::Values( + // Test case 0: fold 1+4611686018427387904 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpIAdd %long %long_1 %long_4611686018427387904\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 1 + 4611686018427387904), + // Test case 1: fold 1-4611686018427387904 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpISub %long %long_1 %long_4611686018427387904\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 1 - 4611686018427387904), + // Test case 2: fold 2*4611686018427387904 + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpIMul %long %long_2 %long_4611686018427387904\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 9223372036854775808ull), + // Test case 3: fold 4611686018427387904/2 (unsigned) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpUDiv %ulong %ulong_4611686018427387904 %ulong_2\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 4611686018427387904 / 2), + // Test case 4: fold 4611686018427387904/2 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSDiv %long %long_4611686018427387904 %long_2\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 4611686018427387904 / 2), + // Test case 5: fold -4611686018427387904/2 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSDiv %long %long_n4611686018427387904 %long_2\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, -4611686018427387904 / 2), + // Test case 6: fold 4611686018427387904 mod 7 (unsigned) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpUMod %ulong %ulong_4611686018427387904 %ulong_7\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 4611686018427387904ull % 7ull), + // Test case 7: fold 7 mod 3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSMod %long %long_7 %long_3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, 1ull), + // Test case 8: fold 7 rem 3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSRem %long %long_7 %long_3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, 1ull), + // Test case 9: fold 7 mod -3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSMod %long %long_7 %long_n3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, -2ll), + // Test case 10: fold 7 rem 3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSRem %long %long_7 %long_n3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, 1ll), + // Test case 11: fold -7 mod 3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSMod %long %long_n7 %long_3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, 2ll), + // Test case 12: fold -7 rem 3 (signed) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSRem %long %long_n7 %long_3\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, -1ll), + // Test case 13: fold long(-24) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSConvert %long %int_n24\n" + "OpReturn\n" + + "OpFunctionEnd", + 2, -24ll), + // Test case 14: fold long(-24) + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + "%2 = OpSConvert %long %int_10\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 10ll), + // Test case 15: fold long(-24(short)). + // The upper bits should be cleared. So 0xFFFFFFE8 should become + // 0x000000000000FFE8. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + "%2 = OpUConvert %ulong %short_n5\n" + + "OpReturn\n" + "OpFunctionEnd", + 2, 65531ull))); - // Make sure the instruction folded as expected. - EXPECT_EQ(succeeded, inst == nullptr || inst->opcode() != original_opcode); - if (succeeded && inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - std::vector opcodes = {spv::Op::OpConstantComposite}; - EXPECT_THAT(opcodes, Contains(inst->opcode())); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::Constant* result = const_mrg->GetConstantFromInst(inst); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - const std::vector& componenets = - result->AsVectorConstant()->GetComponents(); - EXPECT_EQ(componenets.size(), tc.expected_result.size()); - for (size_t i = 0; i < componenets.size(); i++) { - EXPECT_EQ(tc.expected_result[i], componenets[i]->GetU32()); - } - } - } +using UIntVectorInstructionFoldingTest = + ::testing::TestWithParam>>; + +TEST_P(UIntVectorInstructionFoldingTest, Case) { + const auto& tc = GetParam(); + + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedVectorConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->GetU32(); }); } // clang-format off -INSTANTIATE_TEST_SUITE_P(TestCase, IntVectorInstructionFoldingTest, +INSTANTIATE_TEST_SUITE_P(TestCase, UIntVectorInstructionFoldingTest, ::testing::Values( // Test case 0: fold 0*n InstructionFoldingCase>( @@ -942,24 +1313,6 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0,3}), - InstructionFoldingCase>( - Header() + "%main = OpFunction %void None %void_func\n" + - "%main_lab = OpLabel\n" + - "%n = OpVariable %_ptr_int Function\n" + - "%load = OpLoad %int %n\n" + - "%2 = OpVectorShuffle %v2int %v2int_null %v2int_2_3 4294967295 3\n" + - "OpReturn\n" + - "OpFunctionEnd", - 2, {0,0}), - InstructionFoldingCase>( - Header() + "%main = OpFunction %void None %void_func\n" + - "%main_lab = OpLabel\n" + - "%n = OpVariable %_ptr_int Function\n" + - "%load = OpLoad %int %n\n" + - "%2 = OpVectorShuffle %v2int %v2int_null %v2int_2_3 0 4294967295 \n" + - "OpReturn\n" + - "OpFunctionEnd", - 2, {0,0}), // Test case 4: fold bit-cast int -24 to unsigned int InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -969,46 +1322,156 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntVectorInstructionFoldingTest, "%2 = OpBitcast %v2uint %v2int_min_max\n" + "OpReturn\n" + "OpFunctionEnd", - 2, {2147483648, 2147483647}) + 2, {2147483648, 2147483647}), + // Test case 5: fold SNegate vector of uint + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSNegate %v2uint %v2uint_0x3f800000_0xbf800000\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {static_cast(-0x3f800000), static_cast(-0xbf800000)}), + // Test case 6: fold vector components of uint (including integer overflow) + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIAdd %v2uint %v2uint_0x3f800000_0xbf800000 %v2uint_0x3f800000_0xbf800000\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {0x7f000000u, 0x7f000000u}), + // Test case 6: fold vector components of uint + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSConvert %v2int %v2short_2_n5\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {2,static_cast(-5)}), + // Test case 6: fold vector components of uint (incuding integer overflow) + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpUConvert %v2uint %v2short_2_n5\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {2,65531}) )); // clang-format on +using IntVectorInstructionFoldingTest = + ::testing::TestWithParam>>; + +TEST_P(IntVectorInstructionFoldingTest, Case) { + const auto& tc = GetParam(); + + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + + CheckForExpectedVectorConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->GetS32(); }); +} + +// clang-format off +INSTANTIATE_TEST_SUITE_P(TestCase, IntVectorInstructionFoldingTest, +::testing::Values( + // Test case 0: fold negate of a vector + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %v2int %v2int_2_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {-2, -3}), + // Test case 1: fold negate of a vector containing negative values. + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %v2int %v2int_n1_n24\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {1, 24}), + // Test case 2: fold negate of a vector at the limits + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %v2int %v2int_min_max\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {INT_MIN, -INT_MAX}), + // Test case 3: fold vector components of int + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIMul %v2int %v2int_2_3 %v2int_2_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {4,9}) +)); +// clang-format on + +using LongIntVectorInstructionFoldingTest = + ::testing::TestWithParam>>; + +TEST_P(LongIntVectorInstructionFoldingTest, Case) { + const auto& tc = GetParam(); + + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedVectorConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->GetU64(); }); +} + +// clang-format off +INSTANTIATE_TEST_SUITE_P(TestCase, LongIntVectorInstructionFoldingTest, + ::testing::Values( + // Test case 0: fold {2,2} + {2,3} (Testing that the vector logic works + // correctly. Scalar tests will check that the 64-bit values are correctly + // folded.) + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpIAdd %v2long %v2long_2_2 %v2long_2_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {4,5}), + // Test case 0: fold {2,2} / {2,3} (Testing that the vector logic works + // correctly. Scalar tests will check that the 64-bit values are correctly + // folded.) + InstructionFoldingCase>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpSDiv %v2long %v2long_2_2 %v2long_2_3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {1,0}) + )); +// clang-format on + using DoubleVectorInstructionFoldingTest = ::testing::TestWithParam>>; TEST_P(DoubleVectorInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_TRUE(succeeded); - if (succeeded && inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - std::vector opcodes = {spv::Op::OpConstantComposite}; - EXPECT_THAT(opcodes, Contains(inst->opcode())); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::Constant* result = const_mrg->GetConstantFromInst(inst); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - const std::vector& componenets = - result->AsVectorConstant()->GetComponents(); - EXPECT_EQ(componenets.size(), tc.expected_result.size()); - for (size_t i = 0; i < componenets.size(); i++) { - EXPECT_EQ(tc.expected_result[i], componenets[i]->GetDouble()); - } - } - } + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedVectorConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->GetDouble(); }); } // clang-format off @@ -1050,7 +1513,16 @@ INSTANTIATE_TEST_SUITE_P(TestCase, DoubleVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {30.0,30.0,30.0,30.0}), - // Test case 4: OpMatrixTimesVector Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}} {0.0, 0.0, 0.0, 0.0} + // Test case 4: OpVectorTimesMatrix Non-Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, Null, {1.0, 2.0, 3.0, 4.0}, Null} {1.0, 2.0, 3.0, 4.0} {30.0, 0.0, 30.0, 0.0} + InstructionFoldingCase>( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpVectorTimesMatrix %v4double %v4double_1_2_3_4 %mat4v4double_1_2_3_4_null\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {30.0,0.0,30.0,0.0}), + // Test case 5: OpMatrixTimesVector Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}} {0.0, 0.0, 0.0, 0.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1059,7 +1531,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, DoubleVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0,0.0,0.0,0.0}), - // Test case 5: OpMatrixTimesVector Non-Zero Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} + // Test case 6: OpMatrixTimesVector Non-Zero Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1068,7 +1540,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, DoubleVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0,0.0,0.0,0.0}), - // Test case 6: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {10.0, 20.0, 30.0, 40.0} + // Test case 7: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {10.0, 20.0, 30.0, 40.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1076,7 +1548,16 @@ INSTANTIATE_TEST_SUITE_P(TestCase, DoubleVectorInstructionFoldingTest, "%2 = OpMatrixTimesVector %v4double %mat4v4double_1_2_3_4 %v4double_1_2_3_4\n" + "OpReturn\n" + "OpFunctionEnd", - 2, {10.0,20.0,30.0,40.0}) + 2, {10.0,20.0,30.0,40.0}), + // Test case 8: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, Null, {1.0, 2.0, 3.0, 4.0}, Null} {10.0, 20.0, 30.0, 40.0} + InstructionFoldingCase>( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpMatrixTimesVector %v4double %mat4v4double_1_2_3_4_null %v4double_1_2_3_4\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {4.0,8.0,12.0,16.0}) )); using FloatVectorInstructionFoldingTest = @@ -1085,37 +1566,10 @@ using FloatVectorInstructionFoldingTest = TEST_P(FloatVectorInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - spv::Op original_opcode = inst->opcode(); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_EQ(succeeded, inst == nullptr || inst->opcode() != original_opcode); - if (succeeded && inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - std::vector opcodes = {spv::Op::OpConstantComposite}; - EXPECT_THAT(opcodes, Contains(inst->opcode())); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::Constant* result = const_mrg->GetConstantFromInst(inst); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - const std::vector& componenets = - result->AsVectorConstant()->GetComponents(); - EXPECT_EQ(componenets.size(), tc.expected_result.size()); - for (size_t i = 0; i < componenets.size(); i++) { - EXPECT_EQ(tc.expected_result[i], componenets[i]->GetFloat()); - } - } - } + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = FoldInstruction(tc.test_body, tc.id_to_fold,SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedVectorConstant(inst, tc.expected_result, [](const analysis::Constant* c){ return c->GetFloat();}); } // clang-format off @@ -1155,7 +1609,16 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0f,0.0f,0.0f,0.0f}), - // Test case 4: OpVectorTimesMatrix Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} + // Test case 4: OpVectorTimesMatrix Non-Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, Null, {1.0, 2.0, 3.0, 4.0}, Null} {1.0, 2.0, 3.0, 4.0} {30.0, 0.0, 30.0, 0.0} + InstructionFoldingCase>( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpVectorTimesMatrix %v4float %v4float_1_2_3_4 %mat4v4float_1_2_3_4_null\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {30.0,0.0,30.0,0.0}), + // Test case 5: OpVectorTimesMatrix Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1164,7 +1627,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0f,0.0f,0.0f,0.0f}), - // Test case 5: OpVectorTimesMatrix Non-Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {1.0, 2.0, 3.0, 4.0} {30.0, 30.0, 30.0, 30.0} + // Test case 6: OpVectorTimesMatrix Non-Zero Non-Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {1.0, 2.0, 3.0, 4.0} {30.0, 30.0, 30.0, 30.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1173,7 +1636,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {30.0f,30.0f,30.0f,30.0f}), - // Test case 6: OpMatrixTimesVector Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}} {0.0, 0.0, 0.0, 0.0} + // Test case 7: OpMatrixTimesVector Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}} {0.0, 0.0, 0.0, 0.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1182,7 +1645,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0f,0.0f,0.0f,0.0f}), - // Test case 7: OpMatrixTimesVector Non-Zero Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} + // Test case 8: OpMatrixTimesVector Non-Zero Zero {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {0.0, 0.0, 0.0, 0.0} {0.0, 0.0, 0.0, 0.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1191,7 +1654,7 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "OpReturn\n" + "OpFunctionEnd", 2, {0.0f,0.0f,0.0f,0.0f}), - // Test case 8: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {10.0, 20.0, 30.0, 40.0} + // Test case 9: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}, {1.0, 2.0, 3.0, 4.0}} {10.0, 20.0, 30.0, 40.0} InstructionFoldingCase>( Header() + "%main = OpFunction %void None %void_func\n" + @@ -1199,42 +1662,101 @@ INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest, "%2 = OpMatrixTimesVector %v4float %mat4v4float_1_2_3_4 %v4float_1_2_3_4\n" + "OpReturn\n" + "OpFunctionEnd", - 2, {10.0f,20.0f,30.0f,40.0f}) + 2, {10.0f,20.0f,30.0f,40.0f}), + // Test case 10: OpMatrixTimesVector Non-Zero Non-Zero {1.0, 2.0, 3.0, 4.0} {{1.0, 2.0, 3.0, 4.0}, Null, {1.0, 2.0, 3.0, 4.0}, Null} {10.0, 20.0, 30.0, 40.0} + InstructionFoldingCase>( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpMatrixTimesVector %v4float %mat4v4float_1_2_3_4_null %v4float_1_2_3_4\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {4.0,8.0,12.0,16.0}) )); // clang-format on + +using FloatMatrixInstructionFoldingTest = ::testing::TestWithParam< + InstructionFoldingCase>>>; + +TEST_P(FloatMatrixInstructionFoldingTest, Case) { + const auto& tc = GetParam(); + + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + + EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); + if (inst->opcode() == spv::Op::OpCopyObject) { + analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); + inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); + analysis::ConstantManager* const_mgr = context->get_constant_mgr(); + const analysis::Constant* result = const_mgr->GetConstantFromInst(inst); + EXPECT_NE(result, nullptr); + if (result != nullptr) { + std::vector matrix = + result->AsMatrixConstant()->GetComponents(); + EXPECT_EQ(matrix.size(), tc.expected_result.size()); + for (size_t c = 0; c < matrix.size(); c++) { + if (matrix[c]->AsNullConstant() != nullptr) { + matrix[c] = const_mgr->GetNullCompositeConstant(matrix[c]->type()); + } + const analysis::VectorConstant* column_const = + matrix[c]->AsVectorConstant(); + ASSERT_NE(column_const, nullptr); + const std::vector& column = + column_const->GetComponents(); + EXPECT_EQ(column.size(), tc.expected_result[c].size()); + for (size_t r = 0; r < column.size(); r++) { + EXPECT_EQ(tc.expected_result[c][r], column[r]->GetFloat()); + } + } + } + } +} + +// clang-format off +INSTANTIATE_TEST_SUITE_P(TestCase, FloatMatrixInstructionFoldingTest, +::testing::Values( + // Test case 0: OpTranspose square null matrix + InstructionFoldingCase>>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpTranspose %mat4v4float %mat4v4float_null\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {{0.0f, 0.0f, 0.0f, 0.0f},{0.0f, 0.0f, 0.0f, 0.0f},{0.0f, 0.0f, 0.0f, 0.0f},{0.0f, 0.0f, 0.0f, 0.0f}}), + // Test case 1: OpTranspose rectangular null matrix + InstructionFoldingCase>>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpTranspose %mat4v2float %mat2v4float_null\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {{0.0f, 0.0f},{0.0f, 0.0f},{0.0f, 0.0f},{0.0f, 0.0f}}), + InstructionFoldingCase>>( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpTranspose %mat4v4float %mat4v4float_1_2_3_4\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, {{1.0f, 1.0f, 1.0f, 1.0f},{2.0f, 2.0f, 2.0f, 2.0f},{3.0f, 3.0f, 3.0f, 3.0f},{4.0f, 4.0f, 4.0f, 4.0f}}) +)); +// clang-format on + using BooleanInstructionFoldingTest = ::testing::TestWithParam>; TEST_P(BooleanInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_TRUE(succeeded); - if (inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - std::vector bool_opcodes = {spv::Op::OpConstantTrue, - spv::Op::OpConstantFalse}; - EXPECT_THAT(bool_opcodes, Contains(inst->opcode())); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::BoolConstant* result = - const_mrg->GetConstantFromInst(inst)->AsBoolConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - EXPECT_EQ(result->value(), tc.expected_result); - } - } + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedScalarConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->AsBoolConstant()->value(); }); } // clang-format off @@ -1820,35 +2342,15 @@ using FloatInstructionFoldingTest = TEST_P(FloatInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_TRUE(succeeded); - if (inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - EXPECT_EQ(inst->opcode(), spv::Op::OpConstant); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::FloatConstant* result = - const_mrg->GetConstantFromInst(inst)->AsFloatConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - if (!std::isnan(tc.expected_result)) { - EXPECT_EQ(result->GetFloatValue(), tc.expected_result); - } else { - EXPECT_TRUE(std::isnan(result->GetFloatValue())); - } - } - } + CheckForExpectedScalarConstant(inst, tc.expected_result, + [](const analysis::Constant* c) { + return c->AsFloatConstant()->GetFloatValue(); + }); } // Not testing NaNs because there are no expectations concerning NaNs according @@ -2253,35 +2755,14 @@ using DoubleInstructionFoldingTest = TEST_P(DoubleInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_TRUE(succeeded); - if (inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); - inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); - EXPECT_EQ(inst->opcode(), spv::Op::OpConstant); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::FloatConstant* result = - const_mrg->GetConstantFromInst(inst)->AsFloatConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - if (!std::isnan(tc.expected_result)) { - EXPECT_EQ(result->GetDoubleValue(), tc.expected_result); - } else { - EXPECT_TRUE(std::isnan(result->GetDoubleValue())); - } - } - } + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); + CheckForExpectedScalarConstant( + inst, tc.expected_result, [](const analysis::Constant* c) { + return c->AsFloatConstant()->GetDoubleValue(); + }); } // clang-format off @@ -3139,32 +3620,22 @@ using IntegerInstructionFoldingTestWithMap = TEST_P(IntegerInstructionFoldingTestWithMap, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + GetInstructionToFold(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_5); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); inst = context->get_instruction_folder().FoldInstructionToConstant(inst, tc.id_map); - - // Make sure the instruction folded as expected. EXPECT_NE(inst, nullptr); - if (inst != nullptr) { - EXPECT_EQ(inst->opcode(), spv::Op::OpConstant); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::IntConstant* result = - const_mrg->GetConstantFromInst(inst)->AsIntConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - EXPECT_EQ(result->GetU32BitValue(), tc.expected_result); - } - } + + CheckForExpectedScalarConstant(inst, tc.expected_result, + [](const analysis::Constant* c) { + return c->AsIntConstant()->GetU32BitValue(); + }); } // clang-format off + INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTestWithMap, ::testing::Values( // Test case 0: fold %3 = 0; %3 * n @@ -3187,32 +3658,16 @@ using BooleanInstructionFoldingTestWithMap = TEST_P(BooleanInstructionFoldingTestWithMap, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); - - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + GetInstructionToFold(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_5); inst = context->get_instruction_folder().FoldInstructionToConstant(inst, tc.id_map); - - // Make sure the instruction folded as expected. - EXPECT_NE(inst, nullptr); - if (inst != nullptr) { - std::vector bool_opcodes = {spv::Op::OpConstantTrue, - spv::Op::OpConstantFalse}; - EXPECT_THAT(bool_opcodes, Contains(inst->opcode())); - analysis::ConstantManager* const_mrg = context->get_constant_mgr(); - const analysis::BoolConstant* result = - const_mrg->GetConstantFromInst(inst)->AsBoolConstant(); - EXPECT_NE(result, nullptr); - if (result != nullptr) { - EXPECT_EQ(result->value(), tc.expected_result); - } - } + ASSERT_NE(inst, nullptr); + CheckForExpectedScalarConstant( + inst, tc.expected_result, + [](const analysis::Constant* c) { return c->AsBoolConstant()->value(); }); } // clang-format off @@ -3238,30 +3693,15 @@ using GeneralInstructionFoldingTest = TEST_P(GeneralInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_EQ(inst->result_id(), original_inst->result_id()); - EXPECT_EQ(inst->type_id(), original_inst->type_id()); - EXPECT_TRUE((!succeeded) == (tc.expected_result == 0)); - if (succeeded) { + EXPECT_TRUE((inst == nullptr) == (tc.expected_result == 0)); + if (inst != nullptr) { EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); EXPECT_EQ(inst->GetSingleWordInOperand(0), tc.expected_result); - } else { - EXPECT_EQ(inst->NumInOperands(), original_inst->NumInOperands()); - for (uint32_t i = 0; i < inst->NumInOperands(); ++i) { - EXPECT_EQ(inst->GetOperand(i), original_inst->GetOperand(i)); - } } } @@ -3688,23 +4128,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerArithmeticTestCases, GeneralInstructionFoldingTe "OpReturn\n" + "OpFunctionEnd", 2, 0), - // Test case 38: Don't fold 2 + 3 (long), bad length - InstructionFoldingCase( - Header() + "%main = OpFunction %void None %void_func\n" + - "%main_lab = OpLabel\n" + - "%2 = OpIAdd %long %long_2 %long_3\n" + - "OpReturn\n" + - "OpFunctionEnd", - 2, 0), - // Test case 39: Don't fold 2 + 3 (short), bad length - InstructionFoldingCase( - Header() + "%main = OpFunction %void None %void_func\n" + - "%main_lab = OpLabel\n" + - "%2 = OpIAdd %short %short_2 %short_3\n" + - "OpReturn\n" + - "OpFunctionEnd", - 2, 0), - // Test case 40: fold 1*n + // Test case 38: fold 1*n InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -3714,7 +4138,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerArithmeticTestCases, GeneralInstructionFoldingTe "OpReturn\n" + "OpFunctionEnd", 2, 3), - // Test case 41: fold n*1 + // Test case 39: fold n*1 InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + @@ -3724,7 +4148,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerArithmeticTestCases, GeneralInstructionFoldingTe "OpReturn\n" + "OpFunctionEnd", 2, 3), - // Test case 42: Don't fold comparisons of 64-bit types + // Test case 40: Don't fold comparisons of 64-bit types // (https://github.com/KhronosGroup/SPIRV-Tools/issues/3343). InstructionFoldingCase( Header() + "%main = OpFunction %void None %void_func\n" + @@ -3732,6 +4156,62 @@ INSTANTIATE_TEST_SUITE_P(IntegerArithmeticTestCases, GeneralInstructionFoldingTe "%2 = OpSLessThan %bool %long_0 %long_2\n" + "OpReturn\n" + "OpFunctionEnd", + 2, 0), + // Test case 41: Don't fold OpSNegate for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSNegate %int_coop_matrix %undef_int_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 42: Don't fold OpIAdd for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIAdd %int_coop_matrix %undef_int_coop_matrix %undef_int_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 43: Don't fold OpISub for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpISub %int_coop_matrix %undef_int_coop_matrix %undef_int_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 44: Don't fold OpIMul for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpIMul %int_coop_matrix %undef_int_coop_matrix %undef_int_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 45: Don't fold OpSDiv for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpSDiv %int_coop_matrix %undef_int_coop_matrix %undef_int_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 46: Don't fold OpUDiv for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpUDiv %uint_coop_matrix %undef_uint_coop_matrix %undef_uint_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 47: Don't fold OpMatrixTimesScalar for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpMatrixTimesScalar %uint_coop_matrix %undef_uint_coop_matrix %uint_3\n" + + "OpReturn\n" + + "OpFunctionEnd", 2, 0) )); @@ -4262,6 +4742,65 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes "%2 = OpDot %half %half_0_1 %half_0_1\n" + "OpReturn\n" + "OpFunctionEnd", + 2, 0), + // Test case 23: Don't fold 1.0(half) / 2.0(half) + // We do not have to code to emulate 16-bit float operations. Just make sure we do not crash. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_half Function\n" + + "%3 = OpLoad %half %n\n" + + "%2 = OpFDiv %half %half_1 %half_2\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 24: Don't fold OpFNegate for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFNegate %float_coop_matrix %undef_float_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 25: Don't fold OpIAdd for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFAdd %float_coop_matrix %undef_float_coop_matrix %undef_float_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 26: Don't fold OpISub for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFSub %float_coop_matrix %undef_float_coop_matrix %undef_float_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 27: Don't fold OpIMul for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFMul %float_coop_matrix %undef_float_coop_matrix %undef_float_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 28: Don't fold OpSDiv for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpFDiv %float_coop_matrix %undef_float_coop_matrix %undef_float_coop_matrix\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 29: Don't fold OpMatrixTimesScalar for cooperative matrices. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%2 = OpMatrixTimesScalar %float_coop_matrix %undef_float_coop_matrix %float_3\n" + + "OpReturn\n" + + "OpFunctionEnd", 2, 0) )); @@ -4574,7 +5113,31 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT "%2 = OpIAdd %v2int %v2int_0_0 %3\n" + "OpReturn\n" + "OpFunctionEnd", - 2, 3) + 2, 3), + // Test case 8: Don't fold because of undefined value. Using 4294967295 + // means that entry is undefined. We do not expect it to ever happen, so + // not worth folding. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpVectorShuffle %v2int %v2int_null %v2int_2_3 4294967295 3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0), + // Test case 9: Don't fold because of undefined value. Using 4294967295 + // means that entry is undefined. We do not expect it to ever happen, so + // not worth folding. + InstructionFoldingCase( + Header() + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%n = OpVariable %_ptr_int Function\n" + + "%load = OpLoad %int %n\n" + + "%2 = OpVectorShuffle %v2int %v2int_null %v2int_2_3 0 4294967295 \n" + + "OpReturn\n" + + "OpFunctionEnd", + 2, 0) )); INSTANTIATE_TEST_SUITE_P(ClampAndCmpLHS, GeneralInstructionFoldingTest, @@ -4896,30 +5459,15 @@ using ToNegateFoldingTest = TEST_P(ToNegateFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = + FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_1); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - - // Make sure the instruction folded as expected. - EXPECT_EQ(inst->result_id(), original_inst->result_id()); - EXPECT_EQ(inst->type_id(), original_inst->type_id()); - EXPECT_TRUE((!succeeded) == (tc.expected_result == 0)); - if (succeeded) { + EXPECT_TRUE((inst == nullptr) == (tc.expected_result == 0)); + if (inst != nullptr) { EXPECT_EQ(inst->opcode(), spv::Op::OpFNegate); EXPECT_EQ(inst->GetSingleWordInOperand(0), tc.expected_result); - } else { - EXPECT_EQ(inst->NumInOperands(), original_inst->NumInOperands()); - for (uint32_t i = 0; i < inst->NumInOperands(); ++i) { - EXPECT_EQ(inst->GetOperand(i), original_inst->GetOperand(i)); - } } } @@ -5018,19 +5566,12 @@ using MatchingInstructionFoldingTest = TEST_P(MatchingInstructionFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = FoldInstruction(tc.test_body, tc.id_to_fold,SPV_ENV_UNIVERSAL_1_1); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - EXPECT_EQ(succeeded, tc.expected_result); - if (succeeded) { + EXPECT_EQ(inst != nullptr, tc.expected_result); + if (inst != nullptr) { Match(tc.test_body, context.get()); } } @@ -5399,7 +5940,195 @@ INSTANTIATE_TEST_SUITE_P(MergeNegateTest, MatchingInstructionFoldingTest, "%2 = OpFNegate %v2double %v2double_null\n" + "OpReturn\n" + "OpFunctionEnd", - 2, true) + 2, true), + // Test case 20: fold snegate with OpIMul. + // -(x * 2) = x * -2 + InstructionFoldingCase( + Header() + + "; CHECK: [[long:%\\w+]] = OpTypeInt 64 1\n" + + "; CHECK: [[long_n2:%\\w+]] = OpConstant [[long]] -2\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[long]]\n" + + "; CHECK: %4 = OpIMul [[long]] [[ld]] [[long_n2]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_long Function\n" + + "%2 = OpLoad %long %var\n" + + "%3 = OpIMul %long %2 %long_2\n" + + "%4 = OpSNegate %long %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 21: fold snegate with OpIMul. + // -(x * 2) = x * -2 + InstructionFoldingCase( + Header() + + "; CHECK-DAG: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[uint:%\\w+]] = OpTypeInt 32 0\n" + + "; CHECK: [[uint_n2:%\\w+]] = OpConstant [[uint]] 4294967294\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpIMul [[int]] [[ld]] [[uint_n2]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpIMul %int %2 %uint_2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 22: fold snegate with OpIMul. + // -(-24 * x) = x * 24 + InstructionFoldingCase( + Header() + + "; CHECK-DAG: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[int_24:%\\w+]] = OpConstant [[int]] 24\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpIMul [[int]] [[ld]] [[int_24]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpIMul %int %int_n24 %2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 23: fold snegate with OpIMul with UINT_MAX + // -(UINT_MAX * x) = x + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpCopyObject [[int]] [[ld]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpIMul %int %uint_max %2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 24: fold snegate with OpIMul using -INT_MAX + // -(x * 2147483649u) = x * 2147483647u + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[uint:%\\w+]] = OpTypeInt 32 0\n" + + "; CHECK: [[uint_2147483647:%\\w+]] = OpConstant [[uint]] 2147483647\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpIMul [[int]] [[ld]] [[uint_2147483647]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpIMul %int %2 %uint_2147483649\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 25: fold snegate with OpSDiv (long). + // -(x / 2) = x / -2 + InstructionFoldingCase( + Header() + + "; CHECK: [[long:%\\w+]] = OpTypeInt 64 1\n" + + "; CHECK: [[long_n2:%\\w+]] = OpConstant [[long]] -2\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[long]]\n" + + "; CHECK: %4 = OpSDiv [[long]] [[ld]] [[long_n2]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_long Function\n" + + "%2 = OpLoad %long %var\n" + + "%3 = OpSDiv %long %2 %long_2\n" + + "%4 = OpSNegate %long %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 26: fold snegate with OpSDiv (int). + // -(x / 2) = x / -2 + InstructionFoldingCase( + Header() + + "; CHECK-DAG: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK-DAG: [[uint:%\\w+]] = OpTypeInt 32 0\n" + + "; CHECK: [[uint_n2:%\\w+]] = OpConstant [[uint]] 4294967294\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpSDiv [[int]] [[ld]] [[uint_n2]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpSDiv %int %2 %uint_2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 27: fold snegate with OpSDiv. + // -(-24 / x) = 24 / x + InstructionFoldingCase( + Header() + + "; CHECK-DAG: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[int_24:%\\w+]] = OpConstant [[int]] 24\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpSDiv [[int]] [[int_24]] [[ld]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpSDiv %int %int_n24 %2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 28: fold snegate with OpSDiv with UINT_MAX + // -(UINT_MAX / x) = (1 / x) + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[uint:%\\w+]] = OpTypeInt 32 0\n" + + "; CHECK: [[uint_1:%\\w+]] = OpConstant [[uint]] 1\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpSDiv [[int]] [[uint_1]] [[ld]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpSDiv %int %uint_max %2\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 29: fold snegate with OpSDiv using -INT_MAX + // -(x / 2147483647u) = x / 2147483647 + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[uint:%\\w+]] = OpTypeInt 32 0\n" + + "; CHECK: [[uint_2147483647:%\\w+]] = OpConstant [[uint]] 2147483647\n" + + "; CHECK: [[ld:%\\w+]] = OpLoad [[int]]\n" + + "; CHECK: %4 = OpSDiv [[int]] [[ld]] [[uint_2147483647]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpSDiv %int %2 %uint_2147483649\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, true), + // Test case 30: Don't fold snegate int OpUDiv. The operands are interpreted + // as unsigned, so negating an operand is not the same a negating the + // result. + InstructionFoldingCase( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%var = OpVariable %_ptr_int Function\n" + + "%2 = OpLoad %int %var\n" + + "%3 = OpUDiv %int %2 %uint_1\n" + + "%4 = OpSNegate %int %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, false) )); INSTANTIATE_TEST_SUITE_P(ReciprocalFDivTest, MatchingInstructionFoldingTest, @@ -7363,7 +8092,56 @@ INSTANTIATE_TEST_SUITE_P(CompositeExtractOrInsertMatchingTest, MatchingInstructi "%5 = OpCompositeConstruct %v2int %3 %4\n" + "OpReturn\n" + "OpFunctionEnd", - 5, true) + 5, true), + // Test case 16: Don't fold when type cannot be deduced to a constant. + InstructionFoldingCase( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%4 = OpCompositeInsert %struct_v2int_int_int %int_1 %struct_v2int_int_int_null 2\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, false), + // Test case 17: Don't fold when index into composite is out of bounds. + InstructionFoldingCase( + Header() + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%4 = OpCompositeExtract %int %struct_v2int_int_int 3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, false), + // Test case 18: Fold when every element of an array is inserted. + InstructionFoldingCase( + Header() + + "; CHECK: [[int:%\\w+]] = OpTypeInt 32 1\n" + + "; CHECK: [[int2:%\\w+]] = OpConstant [[int]] 2\n" + + "; CHECK-DAG: [[arr_type:%\\w+]] = OpTypeArray [[int]] [[int2]]\n" + + "; CHECK-DAG: [[int10:%\\w+]] = OpConstant [[int]] 10\n" + + "; CHECK-DAG: [[int1:%\\w+]] = OpConstant [[int]] 1\n" + + "; CHECK: [[construct:%\\w+]] = OpCompositeConstruct [[arr_type]] [[int10]] [[int1]]\n" + + "; CHECK: %5 = OpCopyObject [[arr_type]] [[construct]]\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%4 = OpCompositeInsert %int_arr_2 %int_10 %int_arr_2_undef 0\n" + + "%5 = OpCompositeInsert %int_arr_2 %int_1 %4 1\n" + + "OpReturn\n" + + "OpFunctionEnd", + 5, true), + // Test case 19: Don't fold for isomorphic structs + InstructionFoldingCase( + Header() + + "%structA = OpTypeStruct %ulong\n" + + "%structB = OpTypeStruct %ulong\n" + + "%structC = OpTypeStruct %structB\n" + + "%struct_a_undef = OpUndef %structA\n" + + "%main = OpFunction %void None %void_func\n" + + "%main_lab = OpLabel\n" + + "%3 = OpCompositeExtract %ulong %struct_a_undef 0\n" + + "%4 = OpCompositeConstruct %structB %3\n" + + "OpReturn\n" + + "OpFunctionEnd", + 4, false) )); INSTANTIATE_TEST_SUITE_P(DotProductMatchingTest, MatchingInstructionFoldingTest, @@ -7469,21 +8247,15 @@ INSTANTIATE_TEST_SUITE_P(VectorShuffleMatchingTest, MatchingInstructionFoldingTe 3, true) )); +// Issue #5658: The Adreno compiler does not handle 16-bit FMA instructions well. +// We want to avoid this by not generating FMA. We decided to never generate +// FMAs because, from a SPIR-V perspective, it is neutral. The ICD can generate +// the FMA if it wants. The simplest code is no code. INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTest, ::testing::Values( - // Test case 0: (x * y) + a = Fma(x, y, a) + // Test case 0: Don't fold (x * y) + a InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_float Function\n" + @@ -7497,20 +8269,10 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true), - // Test case 1: a + (x * y) = Fma(x, y, a) + 3, false), + // Test case 1: Don't fold a + (x * y) InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_float Function\n" + @@ -7524,20 +8286,10 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true), - // Test case 2: (x * y) + a = Fma(x, y, a) with vectors + 3, false), + // Test case 2: Don't fold (x * y) + a with vectors InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_v4float Function\n" + @@ -7551,20 +8303,10 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true), - // Test case 3: a + (x * y) = Fma(x, y, a) with vectors + 3,false), + // Test case 3: Don't fold a + (x * y) with vectors InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_float Function\n" + @@ -7578,46 +8320,8 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true), - // Test 4: that the OpExtInstImport instruction is generated if it is missing. - InstructionFoldingCase( - std::string() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + - "OpCapability Shader\n" + - "OpMemoryModel Logical GLSL450\n" + - "OpEntryPoint Fragment %main \"main\"\n" + - "OpExecutionMode %main OriginUpperLeft\n" + - "OpSource GLSL 140\n" + - "OpName %main \"main\"\n" + - "%void = OpTypeVoid\n" + - "%void_func = OpTypeFunction %void\n" + - "%bool = OpTypeBool\n" + - "%float = OpTypeFloat 32\n" + - "%_ptr_float = OpTypePointer Function %float\n" + - "%main = OpFunction %void None %void_func\n" + - "%main_lab = OpLabel\n" + - "%x = OpVariable %_ptr_float Function\n" + - "%y = OpVariable %_ptr_float Function\n" + - "%a = OpVariable %_ptr_float Function\n" + - "%lx = OpLoad %float %x\n" + - "%ly = OpLoad %float %y\n" + - "%mul = OpFMul %float %lx %ly\n" + - "%la = OpLoad %float %a\n" + - "%3 = OpFAdd %float %mul %la\n" + - "OpStore %a %3\n" + - "OpReturn\n" + - "OpFunctionEnd", - 3, true), - // Test 5: Don't fold if the multiple is marked no contract. + 3, false), + // Test 4: Don't fold if the multiple is marked no contract. InstructionFoldingCase( std::string() + "OpCapability Shader\n" + @@ -7646,7 +8350,7 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpReturn\n" + "OpFunctionEnd", 3, false), - // Test 6: Don't fold if the add is marked no contract. + // Test 5: Don't fold if the add is marked no contract. InstructionFoldingCase( std::string() + "OpCapability Shader\n" + @@ -7675,20 +8379,9 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpReturn\n" + "OpFunctionEnd", 3, false), - // Test case 7: (x * y) - a = Fma(x, y, -a) + // Test case 6: Don't fold (x * y) - a InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[na:%\\w+]] = OpFNegate {{%\\w+}} [[la]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[lx]] [[ly]] [[na]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_float Function\n" + @@ -7702,21 +8395,10 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true), - // Test case 8: a - (x * y) = Fma(-x, y, a) + 3, false), + // Test case 7: Don't fold a - (x * y) InstructionFoldingCase( Header() + - "; CHECK: [[ext:%\\w+]] = OpExtInstImport \"GLSL.std.450\"\n" + - "; CHECK: OpFunction\n" + - "; CHECK: [[x:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[y:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[a:%\\w+]] = OpVariable {{%\\w+}} Function\n" + - "; CHECK: [[lx:%\\w+]] = OpLoad {{%\\w+}} [[x]]\n" + - "; CHECK: [[ly:%\\w+]] = OpLoad {{%\\w+}} [[y]]\n" + - "; CHECK: [[la:%\\w+]] = OpLoad {{%\\w+}} [[a]]\n" + - "; CHECK: [[nx:%\\w+]] = OpFNegate {{%\\w+}} [[lx]]\n" + - "; CHECK: [[fma:%\\w+]] = OpExtInst {{%\\w+}} [[ext]] Fma [[nx]] [[ly]] [[la]]\n" + - "; CHECK: OpStore {{%\\w+}} [[fma]]\n" + "%main = OpFunction %void None %void_func\n" + "%main_lab = OpLabel\n" + "%x = OpVariable %_ptr_float Function\n" + @@ -7730,7 +8412,7 @@ INSTANTIATE_TEST_SUITE_P(FmaGenerationMatchingTest, MatchingInstructionFoldingTe "OpStore %a %3\n" + "OpReturn\n" + "OpFunctionEnd", - 3, true) + 3, false) )); using MatchingInstructionWithNoResultFoldingTest = @@ -7742,27 +8424,13 @@ using MatchingInstructionWithNoResultFoldingTest = TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = FoldInstruction(tc.test_body, tc.id_to_fold,SPV_ENV_UNIVERSAL_1_1); - // Fold the instruction to test. - Instruction* inst = nullptr; - Function* func = &*context->module()->begin(); - for (auto& bb : *func) { - Instruction* terminator = bb.terminator(); - if (terminator->IsReturnOrAbort()) { - inst = terminator->PreviousNode(); - break; - } - } - assert(inst && "Invalid test. Could not find instruction to fold."); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - EXPECT_EQ(succeeded, tc.expected_result); - if (succeeded) { + // Find the instruction to test. + EXPECT_EQ(inst != nullptr, tc.expected_result); + if (inst != nullptr) { Match(tc.test_body, context.get()); } } @@ -8102,8 +8770,9 @@ TEST_P(EntryPointFoldingTest, Case) { SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); ASSERT_NE(nullptr, context); - // Fold the instruction to test. + // Find the first entry point. That is the instruction we want to fold. Instruction* inst = nullptr; + ASSERT_FALSE(context->module()->entry_points().empty()); inst = &*context->module()->entry_points().begin(); assert(inst && "Invalid test. Could not find entry point instruction to fold."); std::unique_ptr original_inst(inst->Clone(context.get())); @@ -8196,19 +8865,12 @@ using SPV14FoldingTest = TEST_P(SPV14FoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_4, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = FoldInstruction(tc.test_body, tc.id_to_fold,SPV_ENV_UNIVERSAL_1_4); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - EXPECT_EQ(succeeded, tc.expected_result); - if (succeeded) { + EXPECT_EQ(inst != nullptr, tc.expected_result); + if (inst != nullptr) { Match(tc.test_body, context.get()); } } @@ -8309,19 +8971,12 @@ using FloatControlsFoldingTest = TEST_P(FloatControlsFoldingTest, Case) { const auto& tc = GetParam(); - // Build module. - std::unique_ptr context = - BuildModule(SPV_ENV_UNIVERSAL_1_4, nullptr, tc.test_body, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - ASSERT_NE(nullptr, context); + std::unique_ptr context; + Instruction* inst; + std::tie(context, inst) = FoldInstruction(tc.test_body, tc.id_to_fold, SPV_ENV_UNIVERSAL_1_4); - // Fold the instruction to test. - analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); - Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold); - std::unique_ptr original_inst(inst->Clone(context.get())); - bool succeeded = context->get_instruction_folder().FoldInstruction(inst); - EXPECT_EQ(succeeded, tc.expected_result); - if (succeeded) { + EXPECT_EQ(inst != nullptr, tc.expected_result); + if (inst != nullptr) { Match(tc.test_body, context.get()); } } @@ -8393,6 +9048,7 @@ std::string ImageOperandsTestBody(const std::string& image_instruction) { %v3int = OpTypeVector %int 3 %Texture = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant %gSampler = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant + %110 = OpConstantComposite %v2int %5 %5 %101 = OpConstantComposite %v2int %int_n1 %int_n1 %20 = OpConstantComposite %v2float %float_0 %float_0 %main = OpFunction %void None %22 @@ -8452,7 +9108,12 @@ INSTANTIATE_TEST_SUITE_P(ImageOperandsBitmaskFoldingTest, MatchingInstructionWit InstructionFoldingCase(ImageOperandsTestBody( " OpImageWrite %88 %5 %101 Offset %101 \n" "; CHECK: OpImageWrite %88 %5 %101 ConstOffset %101 \n") - , 0 /* No result-id */, true) + , 0 /* No result-id */, true), + // Test case 8: OpImageFetch with zero constant Offset + InstructionFoldingCase(ImageOperandsTestBody( + " %89 = OpImageFetch %10 %88 %101 Lod|Offset %5 %110 \n" + "; CHECK: %89 = OpImageFetch %10 %88 %101 Lod %5 \n") + , 89, true) )); } // namespace diff --git a/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp b/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp index ad0fc32ea0..1ccaa3ef0e 100644 --- a/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp +++ b/third_party/spirv-tools/test/opt/freeze_spec_const_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include diff --git a/third_party/spirv-tools/test/opt/function_test.cpp b/third_party/spirv-tools/test/opt/function_test.cpp index 09cca33492..6a40e93878 100644 --- a/third_party/spirv-tools/test/opt/function_test.cpp +++ b/third_party/spirv-tools/test/opt/function_test.cpp @@ -13,8 +13,6 @@ // limitations under the License. #include -#include -#include #include #include "function_utils.h" diff --git a/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp b/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp index 057b909def..a1a3b7d3fd 100644 --- a/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp +++ b/third_party/spirv-tools/test/opt/graphics_robust_access_test.cpp @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include -#include "gmock/gmock.h" #include "pass_fixture.h" #include "pass_utils.h" #include "source/opt/graphics_robust_access_pass.h" diff --git a/third_party/spirv-tools/test/opt/if_conversion_test.cpp b/third_party/spirv-tools/test/opt/if_conversion_test.cpp index dc7f83163d..c1425e830c 100644 --- a/third_party/spirv-tools/test/opt/if_conversion_test.cpp +++ b/third_party/spirv-tools/test/opt/if_conversion_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/inline_test.cpp b/third_party/spirv-tools/test/opt/inline_test.cpp index 1e5d9f3b4a..ef7ac37d18 100644 --- a/third_party/spirv-tools/test/opt/inline_test.cpp +++ b/third_party/spirv-tools/test/opt/inline_test.cpp @@ -3749,13 +3749,13 @@ float4 main(float4 color : COLOR) : SV_TARGET { %color = OpFunctionParameter %_ptr_Function_v4float %bb_entry = OpLabel %140 = OpExtInst %void %1 DebugFunctionDefinition %22 %src_main - %141 = OpExtInst %void %1 DebugLine %5 %uint_1 %uint_1 %uint_1 %uint_1 + %141 = OpExtInst %void %1 DebugLine %15 %uint_1 %uint_1 %uint_1 %uint_1 %34 = OpExtInst %void %1 DebugScope %22 %36 = OpExtInst %void %1 DebugDeclare %25 %color %13 %38 = OpExtInst %void %1 DebugScope %26 - %142 = OpExtInst %void %1 DebugLine %5 %uint_2 %uint_2 %uint_10 %uint_10 + %142 = OpExtInst %void %1 DebugLine %15 %uint_2 %uint_2 %uint_10 %uint_10 %39 = OpLoad %v4float %color - %143 = OpExtInst %void %1 DebugLine %5 %uint_2 %uint_2 %uint_3 %uint_3 + %143 = OpExtInst %void %1 DebugLine %15 %uint_2 %uint_2 %uint_3 %uint_3 OpReturnValue %39 OpFunctionEnd )"; @@ -4422,6 +4422,55 @@ OpFunctionEnd SinglePassRunAndMatch(text, true); } +TEST_F(InlineTest, DecorateReturnVariableWithAliasedPointer) { + const std::string text = R"(OpCapability Int64 + OpCapability VariablePointers + OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_KHR_variable_pointers" + OpExtension "SPV_KHR_physical_storage_buffer" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %1 LocalSize 8 8 1 + OpDecorate %_ptr_PhysicalStorageBuffer__struct_5 ArrayStride 8 + OpMemberDecorate %_struct_3 0 Offset 0 + OpMemberDecorate %_struct_3 1 Offset 8 + OpDecorate %_ptr_PhysicalStorageBuffer_int ArrayStride 4 + OpMemberDecorate %_struct_5 0 Offset 0 + OpMemberDecorate %_struct_5 1 Offset 4 + OpDecorate %6 Aliased +; CHECK: OpDecorate %22 AliasedPointer + %void = OpTypeVoid + %8 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + OpTypeForwardPointer %_ptr_PhysicalStorageBuffer__struct_5 PhysicalStorageBuffer + %_struct_3 = OpTypeStruct %int %_ptr_PhysicalStorageBuffer__struct_5 +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int + %_struct_5 = OpTypeStruct %int %int + %11 = OpTypeFunction %_ptr_PhysicalStorageBuffer_int %_ptr_PhysicalStorageBuffer__struct_5 +%_ptr_PhysicalStorageBuffer__struct_5 = OpTypePointer PhysicalStorageBuffer %_struct_5 +%_ptr_Function__struct_3 = OpTypePointer Function %_struct_3 + %1 = OpFunction %void None %8 + %13 = OpLabel + %14 = OpVariable %_ptr_Function__struct_3 Function + %15 = OpLoad %_struct_3 %14 + %16 = OpCompositeExtract %_ptr_PhysicalStorageBuffer__struct_5 %15 1 + %17 = OpFunctionCall %_ptr_PhysicalStorageBuffer_int %18 %16 + OpReturn + OpFunctionEnd + %18 = OpFunction %_ptr_PhysicalStorageBuffer_int None %11 + %6 = OpFunctionParameter %_ptr_PhysicalStorageBuffer__struct_5 + %19 = OpLabel + %20 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %6 %int_0 + OpReturnValue %20 + OpFunctionEnd)"; + + SetTargetEnv(SPV_ENV_VULKAN_1_2); + SinglePassRunAndMatch(text, true); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // Empty modules diff --git a/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp b/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp deleted file mode 100644 index 4f4b6681c3..0000000000 --- a/third_party/spirv-tools/test/opt/inst_bindless_check_test.cpp +++ /dev/null @@ -1,5639 +0,0 @@ -// Copyright (c) 2017-2022 Valve Corporation -// Copyright (c) 2017-2022 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Bindless Check Instrumentation Tests. - -#include -#include - -#include "test/opt/assembly_builder.h" -#include "test/opt/pass_fixture.h" -#include "test/opt/pass_utils.h" - -namespace spvtools { -namespace opt { -namespace { - -using InstBindlessTest = PassTest<::testing::Test>; - -static const std::string kOutputDecorations = R"( -; CHECK: OpDecorate [[output_buffer_type:%inst_bindless_OutputBuffer]] Block -; CHECK: OpMemberDecorate [[output_buffer_type]] 0 Offset 0 -; CHECK: OpMemberDecorate [[output_buffer_type]] 1 Offset 4 -; CHECK: OpDecorate [[output_buffer_var:%\w+]] DescriptorSet 7 -; CHECK: OpDecorate [[output_buffer_var]] Binding 0 -)"; - -static const std::string kOutputGlobals = R"( -; CHECK: [[output_buffer_type]] = OpTypeStruct %uint %uint %_runtimearr_uint -; CHECK: [[output_ptr_type:%\w+]] = OpTypePointer StorageBuffer [[output_buffer_type]] -; CHECK: [[output_buffer_var]] = OpVariable [[output_ptr_type]] StorageBuffer -)"; - -static const std::string kStreamWrite4Begin = R"( -; CHECK: %inst_bindless_stream_write_4 = OpFunction %void None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_4:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_1 -; CHECK: {{%\w+}} = OpAtomicIAdd %uint {{%\w+}} %uint_4 %uint_0 %uint_10 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpArrayLength %uint [[output_buffer_var]] 2 -; CHECK: {{%\w+}} = OpULessThanEqual %bool {{%\w+}} {{%\w+}} -; CHECK: OpSelectionMerge {{%\w+}} None -; CHECK: OpBranchConditional {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_23 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_2 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_1]] -)"; - -static const std::string kStreamWrite4End = R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_7 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_8 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_3]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_9 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_4]] -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: OpReturn -; CHECK: OpFunctionEnd -)"; - -// clang-format off -static const std::string kStreamWrite4Frag = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpLoad %v4float %gl_FragCoord -; CHECK: {{%\w+}} = OpBitcast %v4uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite4Tese = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_2 -; CHECK: {{%\w+}} = OpLoad %uint %gl_PrimitiveID -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %v3float %gl_TessCoord -; CHECK: {{%\w+}} = OpBitcast %v3uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_6 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite4Vert = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpLoad %uint %gl_VertexIndex -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint %gl_InstanceIndex -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite4Compute = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpLoad %v3uint %gl_GlobalInvocationID -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 2 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_6 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite4Ray = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %v3uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 0 -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 1 -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 2 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_6 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; -// clang-format on - -static const std::string kStreamWrite5Begin = R"( -; CHECK: %inst_bindless_stream_write_5 = OpFunction %void None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_4:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_5:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_1 -; CHECK: {{%\w+}} = OpAtomicIAdd %uint {{%\w+}} %uint_4 %uint_0 %uint_11 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_11 -; CHECK: {{%\w+}} = OpArrayLength %uint [[output_buffer_var]] 2 -; CHECK: {{%\w+}} = OpULessThanEqual %bool {{%\w+}} {{%\w+}} -; CHECK: OpSelectionMerge {{%\w+}} None -; CHECK: OpBranchConditional {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_11 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_23 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_2 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_1]] -)"; - -static const std::string kStreamWrite5End = R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_7 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_8 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_3]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_9 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_4]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_5]] -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: OpReturn -; CHECK: OpFunctionEnd -)"; - -// clang-format off -static const std::string kStreamWrite5Frag = kStreamWrite5Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpLoad %v4float %gl_FragCoord -; CHECK: {{%\w+}} = OpBitcast %v4uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite5Vert = kStreamWrite5Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpLoad %uint %gl_VertexIndex -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint %gl_InstanceIndex -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite5End; -// clang-format on - -static const std::string kInputDecorations = R"( -; CHECK: OpDecorate [[input_buffer_type:%inst_bindless_InputBuffer]] Block -; CHECK: OpMemberDecorate [[input_buffer_type]] 0 Offset 0 -; CHECK: OpDecorate [[input_buffer_var:%\w+]] DescriptorSet 7 -; CHECK: OpDecorate [[input_buffer_var]] Binding 1 -)"; - -static const std::string kInputGlobals = R"( -; CHECK: [[input_buffer_type]] = OpTypeStruct %_runtimearr_uint -; CHECK: [[input_ptr_type:%\w+]] = OpTypePointer StorageBuffer [[input_buffer_type]] -; CHECK: [[input_buffer_var]] = OpVariable [[input_ptr_type]] StorageBuffer -)"; - -static const std::string kDirectRead2 = R"( -; CHECK: %inst_bindless_direct_read_2 = OpFunction %uint None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 [[param_1]] -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: OpReturnValue {{%\w+}} -; CHECK: OpFunctionEnd -)"; - -static const std::string kDirectRead3 = R"( - ;CHECK: %inst_bindless_direct_read_3 = OpFunction %uint None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint - ;CHECK: {{%\w+}} = OpLabel - ;CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 [[param_1]] - ;CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} - ;CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_2]] - ;CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} - ;CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} - ;CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_3]] - ;CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} - ;CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} - ;CHECK: OpReturnValue {{%\w+}} - ;CHECK: OpFunctionEnd -)"; - -static const std::string kDirectRead4 = R"( -; CHECK: %inst_bindless_direct_read_4 = OpFunction %uint None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_4:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 [[param_1]] -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_3]] -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} [[param_4]] -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %uint {{%\w+}} -; CHECK: OpReturnValue {{%\w+}} -; CHECK: OpFunctionEnd -)"; - -TEST_F(InstBindlessTest, NoInstrumentConstIndexInbounds) { - // Texture2D g_tColor[128]; - // - // SamplerState g_sAniso; - // - // struct PS_INPUT - // { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT - // { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) - // { - // PS_OUTPUT ps_output; - // - // ps_output.vColor = g_tColor[ 37 ].Sample(g_sAniso, i.vTextureCoords.xy); - // return ps_output; - // } - - const std::string before = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -%void = OpTypeVoid -%8 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%int_37 = OpConstant %int 37 -%15 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%_arr_15_uint_128 = OpTypeArray %15 %uint_128 -%_ptr_UniformConstant__arr_15_uint_128 = OpTypePointer UniformConstant %_arr_15_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_15_uint_128 UniformConstant -%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15 -%21 = OpTypeSampler -%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 -%g_sAniso = OpVariable %_ptr_UniformConstant_21 UniformConstant -%23 = OpTypeSampledImage %15 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -%MainPs = OpFunction %void None %8 -%26 = OpLabel -%27 = OpLoad %v2float %i_vTextureCoords -%28 = OpAccessChain %_ptr_UniformConstant_15 %g_tColor %int_37 -%29 = OpLoad %15 %28 -%30 = OpLoad %21 %g_sAniso -%31 = OpSampledImage %23 %29 %30 -%32 = OpImageSampleImplicitLod %v4float %31 %27 -OpStore %_entryPointOutput_vColor %32 -OpReturn -OpFunctionEnd -)"; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndCheck( - before, before, true, true, 7u, 23u, false, false, false, false, false); -} - -TEST_F(InstBindlessTest, NoInstrumentNonBindless) { - // This test verifies that the pass will correctly not instrument vanilla - // texture sample. - // - // Texture2D g_tColor; - // - // SamplerState g_sAniso; - // - // struct PS_INPUT - // { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT - // { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) - // { - // PS_OUTPUT ps_output; - // ps_output.vColor = - // g_tColor.Sample(g_sAniso, i.vTextureCoords.xy); - // return ps_output; - // } - - const std::string whole_file = - R"(OpCapability Shader -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 0 -OpDecorate %g_tColor Binding 0 -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %g_sAniso Binding 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -%void = OpTypeVoid -%8 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%12 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 -%g_tColor = OpVariable %_ptr_UniformConstant_12 UniformConstant -%14 = OpTypeSampler -%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 -%g_sAniso = OpVariable %_ptr_UniformConstant_14 UniformConstant -%16 = OpTypeSampledImage %12 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -%MainPs = OpFunction %void None %8 -%19 = OpLabel -%20 = OpLoad %v2float %i_vTextureCoords -%21 = OpLoad %12 %g_tColor -%22 = OpLoad %14 %g_sAniso -%23 = OpSampledImage %16 %21 %22 -%24 = OpImageSampleImplicitLod %v4float %23 %20 -OpStore %_entryPointOutput_vColor %24 -OpReturn -OpFunctionEnd -)"; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndCheck(whole_file, whole_file, true, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, Simple) { - // Texture2D g_tColor[128]; - // - // layout(push_constant) cbuffer PerViewConstantBuffer_t - // { - // uint g_nDataIdx; - // }; - // - // SamplerState g_sAniso; - // - // struct PS_INPUT - // { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT - // { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) - // { - // PS_OUTPUT ps_output; - // ps_output.vColor = - // g_tColor[ g_nDataIdx ].Sample(g_sAniso, i.vTextureCoords.xy); - // return ps_output; - // } - - const std::string entry = R"( -OpCapability Shader -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -)"; - - // clang-format off - const std::string names_annots = R"( -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)"; - - const std::string consts_types_vars = R"( -%void = OpTypeVoid -%10 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%16 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%_arr_16_uint_128 = OpTypeArray %16 %uint_128 -%_ptr_UniformConstant__arr_16_uint_128 = OpTypePointer UniformConstant %_arr_16_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_16_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16 -%24 = OpTypeSampler -%_ptr_UniformConstant_24 = OpTypePointer UniformConstant %24 -%g_sAniso = OpVariable %_ptr_UniformConstant_24 UniformConstant -%26 = OpTypeSampledImage %16 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: %bool = OpTypeBool -; CHECK: %48 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %103 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %10 -%29 = OpLabel -%30 = OpLoad %v2float %i_vTextureCoords -%31 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%32 = OpLoad %uint %31 -%33 = OpAccessChain %_ptr_UniformConstant_16 %g_tColor %32 -%34 = OpLoad %16 %33 -%35 = OpLoad %24 %g_sAniso -%36 = OpSampledImage %26 %34 %35 -%37 = OpImageSampleImplicitLod %v4float %36 %30 -OpStore %_entryPointOutput_vColor %37 -; CHECK-NOT: %37 = OpImageSampleImplicitLod %v4float %36 %30 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %37 -; CHECK: %40 = OpULessThan %bool %32 %uint_128 -; CHECK: OpSelectionMerge %41 None -; CHECK: OpBranchConditional %40 %42 %43 -; CHECK: %42 = OpLabel -; CHECK: %44 = OpLoad %16 %33 -; CHECK: %45 = OpSampledImage %26 %44 %35 -; CHECK: %46 = OpImageSampleImplicitLod %v4float %45 %30 -; CHECK: OpBranch %41 -; CHECK: %43 = OpLabel -; CHECK: %102 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_56 %uint_0 %32 %uint_128 -; CHECK: OpBranch %41 -; CHECK: %41 = OpLabel -; CHECK: %104 = OpPhi %v4float %46 %42 %103 %43 -; CHECK: OpStore %_entryPointOutput_vColor %104 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - entry + names_annots + consts_types_vars + main_func + output_func, true, - 7u, 23u, false, false, false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentMultipleInstructions) { - // Texture2D g_tColor[128]; - // - // layout(push_constant) cbuffer PerViewConstantBuffer_t - // { - // uint g_nDataIdx; - // uint g_nDataIdx2; - // }; - // - // SamplerState g_sAniso; - // - // struct PS_INPUT - // { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT - // { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) - // { - // PS_OUTPUT ps_output; - // - // float t = g_tColor[g_nDataIdx ].Sample(g_sAniso, i.vTextureCoords.xy); - // float t2 = g_tColor[g_nDataIdx2].Sample(g_sAniso, i.vTextureCoords.xy); - // ps_output.vColor = t + t2; - // return ps_output; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpMemberDecorate %PerViewConstantBuffer_t 1 Offset 4 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%10 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%int_1 = OpConstant %int 1 -%17 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%_arr_17_uint_128 = OpTypeArray %17 %uint_128 -%_ptr_UniformConstant__arr_17_uint_128 = OpTypePointer UniformConstant %_arr_17_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_17_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_17 = OpTypePointer UniformConstant %17 -%25 = OpTypeSampler -%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 -%g_sAniso = OpVariable %_ptr_UniformConstant_25 UniformConstant -%27 = OpTypeSampledImage %17 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: %bool = OpTypeBool -; CHECK: %56 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %111 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = - R"(%MainPs = OpFunction %void None %10 -%30 = OpLabel -%31 = OpLoad %v2float %i_vTextureCoords -%32 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%33 = OpLoad %uint %32 -%34 = OpAccessChain %_ptr_UniformConstant_17 %g_tColor %33 -%35 = OpLoad %17 %34 -%36 = OpLoad %25 %g_sAniso -%37 = OpSampledImage %27 %35 %36 -%38 = OpImageSampleImplicitLod %v4float %37 %31 -; CHECK-NOT: %38 = OpImageSampleImplicitLod %v4float %37 %31 -; CHECK: %48 = OpULessThan %bool %33 %uint_128 -; CHECK: OpSelectionMerge %49 None -; CHECK: OpBranchConditional %48 %50 %51 -; CHECK: %50 = OpLabel -; CHECK: %52 = OpLoad %17 %34 -; CHECK: %53 = OpSampledImage %27 %52 %36 -; CHECK: %54 = OpImageSampleImplicitLod %v4float %53 %31 -; CHECK: OpBranch %49 -; CHECK: %51 = OpLabel -; CHECK: %110 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_58 %uint_0 %33 %uint_128 -; CHECK: OpBranch %49 -; CHECK: %49 = OpLabel -; CHECK: %112 = OpPhi %v4float %54 %50 %111 %51 -%39 = OpAccessChain %_ptr_PushConstant_uint %_ %int_1 -%40 = OpLoad %uint %39 -%41 = OpAccessChain %_ptr_UniformConstant_17 %g_tColor %40 -%42 = OpLoad %17 %41 -%43 = OpSampledImage %27 %42 %36 -%44 = OpImageSampleImplicitLod %v4float %43 %31 -%45 = OpFAdd %v4float %38 %44 -; CHECK-NOT: %44 = OpImageSampleImplicitLod %v4float %43 %31 -; CHECK-NOT: %45 = OpFAdd %v4float %38 %44 -; CHECK: %113 = OpULessThan %bool %40 %uint_128 -; CHECK: OpSelectionMerge %114 None -; CHECK: OpBranchConditional %113 %115 %116 -; CHECK: %115 = OpLabel -; CHECK: %117 = OpLoad %17 %41 -; CHECK: %118 = OpSampledImage %27 %117 %36 -; CHECK: %119 = OpImageSampleImplicitLod %v4float %118 %31 -; CHECK: OpBranch %114 -; CHECK: %116 = OpLabel -; CHECK: %121 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_64 %uint_0 %40 %uint_128 -; CHECK: OpBranch %114 -; CHECK: %114 = OpLabel -; CHECK: %122 = OpPhi %v4float %119 %115 %111 %116 -; CHECK: %45 = OpFAdd %v4float %112 %122 -OpStore %_entryPointOutput_vColor %45 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentOpImage) { - // This test verifies that the pass will correctly instrument shader - // using OpImage. This test was created by editing the SPIR-V - // from the Simple test. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability StorageImageReadWithoutFormat -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%v2int = OpTypeVector %int 2 -%int_0 = OpConstant %int 0 -%20 = OpTypeImage %float 2D 0 0 0 0 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%39 = OpTypeSampledImage %20 -%_arr_39_uint_128 = OpTypeArray %39 %uint_128 -%_ptr_UniformConstant__arr_39_uint_128 = OpTypePointer UniformConstant %_arr_39_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_39_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_39 = OpTypePointer UniformConstant %39 -%_ptr_Input_v2int = OpTypePointer Input %v2int -%i_vTextureCoords = OpVariable %_ptr_Input_v2int Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: uint_0 = OpConstant %uint 0 -; CHECK: bool = OpTypeBool -; CHECK: %86 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %141 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %3 -%5 = OpLabel -%53 = OpLoad %v2int %i_vTextureCoords -%63 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%64 = OpLoad %uint %63 -%65 = OpAccessChain %_ptr_UniformConstant_39 %g_tColor %64 -%66 = OpLoad %39 %65 -%75 = OpImage %20 %66 -%71 = OpImageRead %v4float %75 %53 -OpStore %_entryPointOutput_vColor %71 -; CHECK-NOT: %71 = OpImageRead %v4float %75 %53 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %71 -; CHECK: %78 = OpULessThan %bool %64 %uint_128 -; CHECK: OpSelectionMerge %79 None -; CHECK: OpBranchConditional %78 %80 %81 -; CHECK: %80 = OpLabel -; CHECK: %82 = OpLoad %39 %65 -; CHECK: %83 = OpImage %20 %82 -; CHECK: %84 = OpImageRead %v4float %83 %53 -; CHECK: OpBranch %79 -; CHECK: %81 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %64 %uint_128 -; CHECK: OpBranch %79 -; CHECK: %79 = OpLabel -; CHECK: %142 = OpPhi %v4float %84 %80 %141 %81 -; CHECK: OpStore %_entryPointOutput_vColor %142 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentSampledImage) { - // This test verifies that the pass will correctly instrument shader - // using sampled image. This test was created by editing the SPIR-V - // from the Simple test. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%20 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%39 = OpTypeSampledImage %20 -%_arr_39_uint_128 = OpTypeArray %39 %uint_128 -%_ptr_UniformConstant__arr_39_uint_128 = OpTypePointer UniformConstant %_arr_39_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_39_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_39 = OpTypePointer UniformConstant %39 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: uint_0 = OpConstant %uint 0 -; CHECK: bool = OpTypeBool -; CHECK: %81 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %136 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %3 -%5 = OpLabel -%53 = OpLoad %v2float %i_vTextureCoords -%63 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%64 = OpLoad %uint %63 -%65 = OpAccessChain %_ptr_UniformConstant_39 %g_tColor %64 -%66 = OpLoad %39 %65 -%71 = OpImageSampleImplicitLod %v4float %66 %53 -OpStore %_entryPointOutput_vColor %71 -; CHECK-NOT: %71 = OpImageSampleImplicitLod %v4float %66 %53 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %71 -; CHECK: %74 = OpULessThan %bool %64 %uint_128 -; CHECK: OpSelectionMerge %75 None -; CHECK: OpBranchConditional %74 %76 %77 -; CHECK: %76 = OpLabel -; CHECK: %78 = OpLoad %39 %65 -; CHECK: %79 = OpImageSampleImplicitLod %v4float %78 %53 -; CHECK: OpBranch %75 -; CHECK: %77 = OpLabel -; CHECK: %135 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_49 %uint_0 %64 %uint_128 -; CHECK: OpBranch %75 -; CHECK: %75 = OpLabel -; CHECK: %137 = OpPhi %v4float %79 %76 %136 %77 -; CHECK: OpStore %_entryPointOutput_vColor %137 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentImageWrite) { - // This test verifies that the pass will correctly instrument shader - // doing bindless image write. This test was created by editing the SPIR-V - // from the Simple test. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability StorageImageWriteWithoutFormat -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 3 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%v2int = OpTypeVector %int 2 -%int_0 = OpConstant %int 0 -%20 = OpTypeImage %float 2D 0 0 0 0 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%80 = OpConstantNull %v4float -%_arr_20_uint_128 = OpTypeArray %20 %uint_128 -%_ptr_UniformConstant__arr_20_uint_128 = OpTypePointer UniformConstant %_arr_20_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_20_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 -%_ptr_Input_v2int = OpTypePointer Input %v2int -%i_vTextureCoords = OpVariable %_ptr_Input_v2int Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: uint_0 = OpConstant %uint 0 -; CHECK: bool = OpTypeBool -; CHECK: %41 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: _runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %3 -%5 = OpLabel -%53 = OpLoad %v2int %i_vTextureCoords -%63 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%64 = OpLoad %uint %63 -%65 = OpAccessChain %_ptr_UniformConstant_20 %g_tColor %64 -%66 = OpLoad %20 %65 -OpImageWrite %66 %53 %80 -OpStore %_entryPointOutput_vColor %80 -; CHECK-NOT: OpImageWrite %66 %53 %80 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %80 -; CHECK: %35 = OpULessThan %bool %30 %uint_128 -; CHECK: OpSelectionMerge %36 None -; CHECK: OpBranchConditional %35 %37 %38 -; CHECK: %37 = OpLabel -; CHECK: %39 = OpLoad %16 %31 -; CHECK: OpImageWrite %39 %28 %19 -; CHECK: OpBranch %36 -; CHECK: %38 = OpLabel -; CHECK: %95 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %30 %uint_128 -; CHECK: OpBranch %36 -; CHECK: %36 = OpLabel -; CHECK: OpStore %_entryPointOutput_vColor %19 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentVertexSimple) { - // This test verifies that the pass will correctly instrument shader - // doing bindless image write. This test was created by editing the SPIR-V - // from the Simple test. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability Sampled1D -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %main "main" %_ %coords2D -OpSource GLSL 450 -OpName %main "main" -OpName %lod "lod" -OpName %coords1D "coords1D" -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 %texSampler1D "texSampler1D" -OpName %foo "foo" -OpMemberName %foo 0 "g_idx" -OpName %__0 "" -OpName %coords2D "coords2D" -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex -; CHECK: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex -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 %texSampler1D DescriptorSet 0 -OpDecorate %texSampler1D Binding 3 -OpMemberDecorate %foo 0 Offset 0 -OpDecorate %foo Block -OpDecorate %__0 DescriptorSet 0 -OpDecorate %__0 Binding 5 -OpDecorate %coords2D Location 0 -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float -%float_3 = OpConstant %float 3 -%float_1_78900003 = OpConstant %float 1.78900003 -%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 -%21 = OpTypeImage %float 1D 0 0 0 1 Unknown -%22 = OpTypeSampledImage %21 -%uint_128 = OpConstant %uint 128 -%_arr_22_uint_128 = OpTypeArray %22 %uint_128 -%_ptr_UniformConstant__arr_22_uint_128 = OpTypePointer UniformConstant %_arr_22_uint_128 -%texSampler1D = OpVariable %_ptr_UniformConstant__arr_22_uint_128 UniformConstant -%foo = OpTypeStruct %int -%_ptr_Uniform_foo = OpTypePointer Uniform %foo -%__0 = OpVariable %_ptr_Uniform_foo Uniform -%_ptr_Uniform_int = OpTypePointer Uniform %int -%_ptr_UniformConstant_22 = OpTypePointer UniformConstant %22 -%_ptr_Output_v4float = OpTypePointer Output %v4float -%v2float = OpTypeVector %float 2 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%coords2D = OpVariable %_ptr_Input_v2float Input -; CHECK: %bool = OpTypeBool -; CHECK: %54 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_uint = OpTypePointer Input %uint -; CHECK: %gl_VertexIndex = OpVariable %_ptr_Input_uint Input -; CHECK: %gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -; CHECK: %106 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%lod = OpVariable %_ptr_Function_float Function -%coords1D = OpVariable %_ptr_Function_float Function -OpStore %lod %float_3 -OpStore %coords1D %float_1_78900003 -%31 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 -%32 = OpLoad %int %31 -%34 = OpAccessChain %_ptr_UniformConstant_22 %texSampler1D %32 -%35 = OpLoad %22 %34 -%36 = OpLoad %float %coords1D -%37 = OpLoad %float %lod -%38 = OpImageSampleExplicitLod %v4float %35 %36 Lod %37 -%40 = OpAccessChain %_ptr_Output_v4float %_ %int_0 -OpStore %40 %38 -; CHECK-NOT: %38 = OpImageSampleExplicitLod %v4float %35 %36 Lod %37 -; CHECK-NOT: %40 = OpAccessChain %_ptr_Output_v4float %_ %int_0 -; CHECK-NOT: OpStore %40 %38 -; CHECK: %46 = OpULessThan %bool %37 %uint_128 -; CHECK: OpSelectionMerge %47 None -; CHECK: OpBranchConditional %46 %48 %49 -; CHECK: %48 = OpLabel -; CHECK: %50 = OpLoad %25 %38 -; CHECK: %51 = OpImageSampleExplicitLod %v4float %50 %40 Lod %41 -; CHECK: OpBranch %47 -; CHECK: %49 = OpLabel -; CHECK: %52 = OpBitcast %uint %37 -; CHECK: %105 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_74 %uint_0 %52 %uint_128 -; CHECK: OpBranch %47 -; CHECK: %47 = OpLabel -; CHECK: %107 = OpPhi %v4float %51 %48 %106 %49 -; CHECK: %43 = OpAccessChain %_ptr_Output_v4float %_ %int_0 -; CHECK: OpStore %43 %107 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Vert; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, InstrumentTeseSimple) { - // This test verifies that the pass will correctly instrument tessellation - // evaluation shader doing bindless buffer load. - // - // clang-format off - // - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(std140, set = 0, binding = 0) uniform ufoo { uint index; } uniform_index_buffer; - // - // layout(set = 0, binding = 1) buffer bfoo { vec4 val; } adds[11]; - // - // layout(triangles, equal_spacing, cw) in; - // - // void main() { - // gl_Position = adds[uniform_index_buffer.index].val; - // } - // - - const std::string defs = R"( -OpCapability Tessellation -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint TessellationEvaluation %main "main" %_ -; CHECK: OpEntryPoint TessellationEvaluation %main "main" %_ %gl_PrimitiveID %gl_TessCoord -OpExecutionMode %main Triangles -OpExecutionMode %main SpacingEqual -OpExecutionMode %main VertexOrderCw -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -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 %bfoo "bfoo" -OpMemberName %bfoo 0 "val" -OpName %adds "adds" -OpName %ufoo "ufoo" -OpMemberName %ufoo 0 "index" -OpName %uniform_index_buffer "uniform_index_buffer" -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 -OpMemberDecorate %bfoo 0 Offset 0 -OpDecorate %bfoo Block -OpDecorate %adds DescriptorSet 0 -OpDecorate %adds Binding 1 -OpMemberDecorate %ufoo 0 Offset 0 -OpDecorate %ufoo Block -OpDecorate %uniform_index_buffer DescriptorSet 0 -OpDecorate %uniform_index_buffer Binding 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId -; CHECK: OpDecorate %gl_TessCoord BuiltIn TessCoord -%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 -%bfoo = OpTypeStruct %v4float -%uint_11 = OpConstant %uint 11 -%_arr_bfoo_uint_11 = OpTypeArray %bfoo %uint_11 -%_ptr_StorageBuffer__arr_bfoo_uint_11 = OpTypePointer StorageBuffer %_arr_bfoo_uint_11 -%adds = OpVariable %_ptr_StorageBuffer__arr_bfoo_uint_11 StorageBuffer -%ufoo = OpTypeStruct %uint -%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo -%uniform_index_buffer = OpVariable %_ptr_Uniform_ufoo Uniform -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float -%_ptr_Output_v4float = OpTypePointer Output %v4float -; CHECK: %bool = OpTypeBool -; CHECK: %40 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_uint = OpTypePointer Input %uint -; CHECK: %gl_PrimitiveID = OpVariable %_ptr_Input_uint Input -; CHECK: %v3float = OpTypeVector %float 3 -; CHECK: %_ptr_Input_v3float = OpTypePointer Input %v3float -; CHECK: %gl_TessCoord = OpVariable %_ptr_Input_v3float Input -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %101 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%25 = OpAccessChain %_ptr_Uniform_uint %uniform_index_buffer %int_0 -%26 = OpLoad %uint %25 -%28 = OpAccessChain %_ptr_StorageBuffer_v4float %adds %26 %int_0 -%29 = OpLoad %v4float %28 -; CHECK-NOT: %29 = OpLoad %v4float %28 -; CHECK: %34 = OpULessThan %bool %28 %uint_11 -; CHECK: OpSelectionMerge %35 None -; CHECK: OpBranchConditional %34 %36 %37 -; CHECK: %36 = OpLabel -; CHECK: %38 = OpLoad %v4float %29 -; CHECK: OpBranch %35 -; CHECK: %37 = OpLabel -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_63 %uint_0 %28 %uint_11 -; CHECK: OpBranch %35 -; CHECK: %35 = OpLabel -; CHECK: %102 = OpPhi %v4float %38 %36 %101 %37 -%31 = OpAccessChain %_ptr_Output_v4float %_ %int_0 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: OpStore %31 %102 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Tese; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + output_func, - true, 7u, 23u, false, false, - false, false, false); -} - -TEST_F(InstBindlessTest, MultipleDebugFunctions) { - // Same source as Simple, but compiled -g and not optimized, especially not - // inlined. The OpSource has had the source extracted for the sake of brevity. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%2 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -%1 = OpString "foo5.frag" -OpSource HLSL 500 %1 -OpName %MainPs "MainPs" -OpName %PS_INPUT "PS_INPUT" -OpMemberName %PS_INPUT 0 "vTextureCoords" -OpName %PS_OUTPUT "PS_OUTPUT" -OpMemberName %PS_OUTPUT 0 "vColor" -OpName %_MainPs_struct_PS_INPUT_vf21_ "@MainPs(struct-PS_INPUT-vf21;" -OpName %i "i" -OpName %ps_output "ps_output" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %g_sAniso "g_sAniso" -OpName %i_0 "i" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpName %param "param" -OpDecorate %g_tColor DescriptorSet 0 -OpDecorate %g_tColor Binding 0 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %g_sAniso Binding 1 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%4 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%PS_INPUT = OpTypeStruct %v2float -%_ptr_Function_PS_INPUT = OpTypePointer Function %PS_INPUT -%v4float = OpTypeVector %float 4 -%PS_OUTPUT = OpTypeStruct %v4float -%13 = OpTypeFunction %PS_OUTPUT %_ptr_Function_PS_INPUT -%_ptr_Function_PS_OUTPUT = OpTypePointer Function %PS_OUTPUT -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%21 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%_arr_21_uint_128 = OpTypeArray %21 %uint_128 -%_ptr_UniformConstant__arr_21_uint_128 = OpTypePointer UniformConstant %_arr_21_uint_128 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_21_uint_128 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 -%36 = OpTypeSampler -%_ptr_UniformConstant_36 = OpTypePointer UniformConstant %36 -%g_sAniso = OpVariable %_ptr_UniformConstant_36 UniformConstant -%40 = OpTypeSampledImage %21 -%_ptr_Function_v2float = OpTypePointer Function %v2float -%_ptr_Function_v4float = OpTypePointer Function %v4float -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: %bool = OpTypeBool -; CHECK: %70 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %125 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string func1 = R"( -%MainPs = OpFunction %void None %4 -%6 = OpLabel -%i_0 = OpVariable %_ptr_Function_PS_INPUT Function -%param = OpVariable %_ptr_Function_PS_INPUT Function -OpLine %1 21 0 -%54 = OpLoad %v2float %i_vTextureCoords -%55 = OpAccessChain %_ptr_Function_v2float %i_0 %int_0 -OpStore %55 %54 -%59 = OpLoad %PS_INPUT %i_0 -OpStore %param %59 -%60 = OpFunctionCall %PS_OUTPUT %_MainPs_struct_PS_INPUT_vf21_ %param -%61 = OpCompositeExtract %v4float %60 0 -OpStore %_entryPointOutput_vColor %61 -OpReturn -OpFunctionEnd -)"; - - const std::string func2 = R"( -%_MainPs_struct_PS_INPUT_vf21_ = OpFunction %PS_OUTPUT None %13 -%i = OpFunctionParameter %_ptr_Function_PS_INPUT -%16 = OpLabel -%ps_output = OpVariable %_ptr_Function_PS_OUTPUT Function -OpLine %1 24 0 -%31 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%32 = OpLoad %uint %31 -%34 = OpAccessChain %_ptr_UniformConstant_21 %g_tColor %32 -%35 = OpLoad %21 %34 -%39 = OpLoad %36 %g_sAniso -%41 = OpSampledImage %40 %35 %39 -%43 = OpAccessChain %_ptr_Function_v2float %i %int_0 -%44 = OpLoad %v2float %43 -%45 = OpImageSampleImplicitLod %v4float %41 %44 -; CHECK-NOT: %45 = OpImageSampleImplicitLod %v4float %41 %44 -; CHECK: OpNoLine -; CHECK: %62 = OpULessThan %bool %50 %uint_128 -; CHECK: OpSelectionMerge %63 None -; CHECK: OpBranchConditional %62 %64 %65 -; CHECK: %64 = OpLabel -; CHECK: %66 = OpLoad %27 %51 -; CHECK: %67 = OpSampledImage %37 %66 %53 -; CHECK: OpLine %5 24 0 -; CHECK: %68 = OpImageSampleImplicitLod %v4float %67 %56 -; CHECK: OpNoLine -; CHECK: OpBranch %63 -; CHECK: %65 = OpLabel -; CHECK: %124 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_109 %uint_0 %50 %uint_128 -; CHECK: OpBranch %63 -; CHECK: %63 = OpLabel -; CHECK: %126 = OpPhi %v4float %68 %64 %125 %65 -; CHECK: OpLine %5 24 0 -%47 = OpAccessChain %_ptr_Function_v4float %ps_output %int_0 -OpStore %47 %45 -OpLine %1 25 0 -%48 = OpLoad %PS_OUTPUT %ps_output -OpReturnValue %48 -OpFunctionEnd -)"; - - const std::string output_func = kStreamWrite4Frag; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - defs + func1 + func2 + output_func, true, 7u, 23u, false, false, false, - false, false); -} - -TEST_F(InstBindlessTest, RuntimeArray) { - // This test verifies that the pass will correctly instrument shader - // with runtime descriptor array. This test was created by editing the - // SPIR-V from the Simple test. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability RuntimeDescriptorArray -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" -OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" -OpName %_ "" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 1 -OpDecorate %g_tColor Binding 2 -OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 -OpDecorate %PerViewConstantBuffer_t Block -OpDecorate %g_sAniso DescriptorSet 1 -OpDecorate %g_sAniso Binding 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%20 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_1 = OpConstant %uint 1 -%_rarr_20 = OpTypeRuntimeArray %20 -%_ptr_UniformConstant__arr_20 = OpTypePointer UniformConstant %_rarr_20 -%g_tColor = OpVariable %_ptr_UniformConstant__arr_20 UniformConstant -%PerViewConstantBuffer_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t -%_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint -%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 -%35 = OpTypeSampler -%_ptr_UniformConstant_35 = OpTypePointer UniformConstant %35 -%g_sAniso = OpVariable %_ptr_UniformConstant_35 UniformConstant -%39 = OpTypeSampledImage %20 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: %41 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %65 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %116 = OpConstantNull %v4float -; CHECK: %119 = OpTypeFunction %uint %uint %uint %uint %uint -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %3 -%5 = OpLabel -%53 = OpLoad %v2float %i_vTextureCoords -%63 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 -%64 = OpLoad %uint %63 -%65 = OpAccessChain %_ptr_UniformConstant_20 %g_tColor %64 -%66 = OpLoad %20 %65 -%67 = OpLoad %35 %g_sAniso -%68 = OpSampledImage %39 %66 %67 -%71 = OpImageSampleImplicitLod %v4float %68 %53 -OpStore %_entryPointOutput_vColor %71 -; CHECK-NOT: %71 = OpImageSampleImplicitLod %v4float %68 %53 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %71 -; CHECK: %55 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_2 %uint_2 -; CHECK: %57 = OpULessThan %bool %32 %55 -; CHECK: OpSelectionMerge %58 None -; CHECK: OpBranchConditional %57 %59 %60 -; CHECK: %59 = OpLabel -; CHECK: %61 = OpLoad %16 %33 -; CHECK: %62 = OpSampledImage %26 %61 %35 -; CHECK: %136 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_1 %uint_2 %32 -; CHECK: %137 = OpULessThan %bool %uint_0 %136 -; CHECK: OpSelectionMerge %138 None -; CHECK: OpBranchConditional %137 %139 %140 -; CHECK: %139 = OpLabel -; CHECK: %141 = OpLoad %16 %33 -; CHECK: %142 = OpSampledImage %26 %141 %35 -; CHECK: %143 = OpImageSampleImplicitLod %v4float %142 %30 -; CHECK: OpBranch %138 -; CHECK: %140 = OpLabel -; CHECK: %144 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_59 %uint_1 %32 %uint_0 -; CHECK: OpBranch %138 -; CHECK: %138 = OpLabel -; CHECK: %145 = OpPhi %v4float %143 %139 %116 %140 -; CHECK: OpBranch %58 -; CHECK: %60 = OpLabel -; CHECK: %115 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_59 %uint_0 %32 %55 -; CHECK: OpBranch %58 -; CHECK: %58 = OpLabel -; CHECK: %117 = OpPhi %v4float %145 %138 %116 %60 -; CHECK: OpStore %_entryPointOutput_vColor %117 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstrumentInitCheckOnScalarDescriptor) { - // This test verifies that the pass will correctly instrument vanilla - // texture sample on a scalar descriptor with an initialization check if the - // input_init_enable argument is set to true. This can happen when the - // descriptor indexing extension is enabled in the API but the SPIR-V - // does not have the extension enabled because it does not contain a - // runtime array. This is the same shader as NoInstrumentNonBindless. - - // clang-format off - const std::string defs = R"( -OpCapability Shader -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor -; CHECK: OpEntryPoint Fragment %MainPs "MainPs" %i_vTextureCoords %_entryPointOutput_vColor %gl_FragCoord -OpExecutionMode %MainPs OriginUpperLeft -OpSource HLSL 500 -OpName %MainPs "MainPs" -OpName %g_tColor "g_tColor" -OpName %g_sAniso "g_sAniso" -OpName %i_vTextureCoords "i.vTextureCoords" -OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" -OpDecorate %g_tColor DescriptorSet 0 -OpDecorate %g_tColor Binding 0 -OpDecorate %g_sAniso DescriptorSet 0 -OpDecorate %g_sAniso Binding 0 -OpDecorate %i_vTextureCoords Location 0 -OpDecorate %_entryPointOutput_vColor Location 0 -; check: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; check: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%8 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%12 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 -%g_tColor = OpVariable %_ptr_UniformConstant_12 UniformConstant -%14 = OpTypeSampler -%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 -%g_sAniso = OpVariable %_ptr_UniformConstant_14 UniformConstant -%16 = OpTypeSampledImage %12 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %28 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %61 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %113 = OpConstantNull %v4float -)"; - // clang-format on - - const std::string main_func = R"( -%MainPs = OpFunction %void None %8 -%19 = OpLabel -%20 = OpLoad %v2float %i_vTextureCoords -%21 = OpLoad %12 %g_tColor -%22 = OpLoad %14 %g_sAniso -%23 = OpSampledImage %16 %21 %22 -%24 = OpImageSampleImplicitLod %v4float %23 %20 -OpStore %_entryPointOutput_vColor %24 -; CHECK-NOT: %24 = OpImageSampleImplicitLod %v4float %23 %20 -; CHECK-NOT: OpStore %_entryPointOutput_vColor %24 -; CHECK: %50 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %52 = OpULessThan %bool %uint_0 %50 -; CHECK: OpSelectionMerge %54 None -; CHECK: OpBranchConditional %52 %55 %56 -; CHECK: %55 = OpLabel -; CHECK: %57 = OpLoad %12 %g_tColor -; CHECK: %58 = OpSampledImage %16 %57 %22 -; CHECK: %59 = OpImageSampleImplicitLod %v4float %58 %20 -; CHECK: OpBranch %54 -; CHECK: %56 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_39 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %54 -; CHECK: %54 = OpLabel -; CHECK: %114 = OpPhi %v4float %59 %55 %113 %56 -; CHECK: OpStore %_entryPointOutput_vColor %114 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead4 + kStreamWrite4Frag; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, SPV14AddToEntryPoint) { - const std::string text = R"( -; CHECK: OpEntryPoint Fragment {{%\w+}} "foo" {{%\w+}} {{%\w+}} {{%\w+}} [[v1:%\w+]] [[v2:%\w+]] -; CHECK: OpDecorate [[v1]] DescriptorSet 7 -; CHECK: OpDecorate [[v2]] DescriptorSet 7 -; CHECK: [[v1]] = OpVariable {{%\w+}} StorageBuffer -; CHECK: [[v2]] = OpVariable {{%\w+}} StorageBuffer -OpCapability Shader -OpExtension "SPV_EXT_descriptor_indexing" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %foo "foo" %gid %image_var %sampler_var -OpExecutionMode %foo OriginUpperLeft -OpDecorate %image_var DescriptorSet 0 -OpDecorate %image_var Binding 0 -OpDecorate %sampler_var DescriptorSet 0 -OpDecorate %sampler_var Binding 1 -OpDecorate %gid DescriptorSet 0 -OpDecorate %gid Binding 2 -OpDecorate %struct Block -OpMemberDecorate %struct 0 Offset 0 -%void = OpTypeVoid -%int = OpTypeInt 32 0 -%int_0 = OpConstant %int 0 -%v3int = OpTypeVector %int 3 -%float = OpTypeFloat 32 -%v3float = OpTypeVector %float 3 -%v4float = OpTypeVector %float 4 -%struct = OpTypeStruct %v3int -%ptr_ssbo_struct = OpTypePointer StorageBuffer %struct -%ptr_ssbo_v3int = OpTypePointer StorageBuffer %v3int -%gid = OpVariable %ptr_ssbo_struct StorageBuffer -%image = OpTypeImage %float 3D 0 0 0 1 Unknown -%ptr_uc_image = OpTypePointer UniformConstant %image -%sampler = OpTypeSampler -%ptr_uc_sampler = OpTypePointer UniformConstant %sampler -%image_var = OpVariable %ptr_uc_image UniformConstant -%sampler_var = OpVariable %ptr_uc_sampler UniformConstant -%sampled = OpTypeSampledImage %image -%void_fn = OpTypeFunction %void -%foo = OpFunction %void None %void_fn -%entry = OpLabel -%ld_image = OpLoad %image %image_var -%ld_sampler = OpLoad %sampler %sampler_var -%gep = OpAccessChain %ptr_ssbo_v3int %gid %int_0 -%ld_gid = OpLoad %v3int %gep -%convert = OpConvertUToF %v3float %ld_gid -%sampled_image = OpSampledImage %sampled %ld_image %ld_sampler -%sample = OpImageSampleImplicitLod %v4float %sampled_image %convert -OpReturn -OpFunctionEnd -)"; - - SetTargetEnv(SPV_ENV_VULKAN_1_1_SPIRV_1_4); - SinglePassRunAndMatch(text, true, 7u, 23u, true, true, - false, false, false); -} - -TEST_F(InstBindlessTest, SPV14AddToEntryPoints) { - const std::string text = R"( -; CHECK: OpEntryPoint Fragment {{%\w+}} "foo" {{%\w+}} {{%\w+}} {{%\w+}} [[v1:%\w+]] [[v2:%\w+]] -; CHECK: OpEntryPoint Fragment {{%\w+}} "bar" {{%\w+}} {{%\w+}} {{%\w+}} [[v1:%\w+]] [[v2:%\w+]] -; CHECK: OpDecorate [[v1]] DescriptorSet 7 -; CHECK: OpDecorate [[v2]] DescriptorSet 7 -; CHECK: [[v1]] = OpVariable {{%\w+}} StorageBuffer -; CHECK: [[v2]] = OpVariable {{%\w+}} StorageBuffer -OpCapability Shader -OpExtension "SPV_EXT_descriptor_indexing" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %foo "foo" %gid %image_var %sampler_var -OpEntryPoint Fragment %foo "bar" %gid %image_var %sampler_var -OpExecutionMode %foo OriginUpperLeft -OpDecorate %image_var DescriptorSet 0 -OpDecorate %image_var Binding 0 -OpDecorate %sampler_var DescriptorSet 0 -OpDecorate %sampler_var Binding 1 -OpDecorate %gid DescriptorSet 0 -OpDecorate %gid Binding 2 -OpDecorate %struct Block -OpMemberDecorate %struct 0 Offset 0 -%void = OpTypeVoid -%int = OpTypeInt 32 0 -%int_0 = OpConstant %int 0 -%v3int = OpTypeVector %int 3 -%float = OpTypeFloat 32 -%v3float = OpTypeVector %float 3 -%v4float = OpTypeVector %float 4 -%struct = OpTypeStruct %v3int -%ptr_ssbo_struct = OpTypePointer StorageBuffer %struct -%ptr_ssbo_v3int = OpTypePointer StorageBuffer %v3int -%gid = OpVariable %ptr_ssbo_struct StorageBuffer -%image = OpTypeImage %float 3D 0 0 0 1 Unknown -%ptr_uc_image = OpTypePointer UniformConstant %image -%sampler = OpTypeSampler -%ptr_uc_sampler = OpTypePointer UniformConstant %sampler -%image_var = OpVariable %ptr_uc_image UniformConstant -%sampler_var = OpVariable %ptr_uc_sampler UniformConstant -%sampled = OpTypeSampledImage %image -%void_fn = OpTypeFunction %void -%foo = OpFunction %void None %void_fn -%entry = OpLabel -%ld_image = OpLoad %image %image_var -%ld_sampler = OpLoad %sampler %sampler_var -%gep = OpAccessChain %ptr_ssbo_v3int %gid %int_0 -%ld_gid = OpLoad %v3int %gep -%convert = OpConvertUToF %v3float %ld_gid -%sampled_image = OpSampledImage %sampled %ld_image %ld_sampler -%sample = OpImageSampleImplicitLod %v4float %sampled_image %convert -OpReturn -OpFunctionEnd -)"; - - SetTargetEnv(SPV_ENV_VULKAN_1_1_SPIRV_1_4); - SinglePassRunAndMatch(text, true, 7u, 23u, true, true, - false, false, false); -} - -TEST_F(InstBindlessTest, InstBoundsAndInitLoadUnsizedUBOArray) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location=0) in nonuniformEXT flat int nu_ii; - // layout(location=0) out float b; - // - // layout(binding=3) uniform uname { float a; } uniformBuffer[]; - // - // void main() - // { - // b = uniformBuffer[nu_ii].a; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability ShaderNonUniform -OpCapability RuntimeDescriptorArray -OpCapability UniformBufferArrayNonUniformIndexing -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %b %nu_ii -; CHECK: OpEntryPoint Fragment %main "main" %b %nu_ii %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %b "b" -OpName %uname "uname" -OpMemberName %uname 0 "a" -OpName %uniformBuffer "uniformBuffer" -OpName %nu_ii "nu_ii" -OpDecorate %b Location 0 -OpMemberDecorate %uname 0 Offset 0 -OpDecorate %uname Block -OpDecorate %uniformBuffer DescriptorSet 0 -OpDecorate %uniformBuffer Binding 3 -OpDecorate %nu_ii Flat -OpDecorate %nu_ii Location 0 -OpDecorate %nu_ii NonUniform -OpDecorate %16 NonUniform -OpDecorate %20 NonUniform -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %130 NonUniform -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -; CHECK: OpDecorate %127 NonUniform -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%b = OpVariable %_ptr_Output_float Output -%uname = OpTypeStruct %float -%_runtimearr_uname = OpTypeRuntimeArray %uname -%_ptr_Uniform__runtimearr_uname = OpTypePointer Uniform %_runtimearr_uname -%uniformBuffer = OpVariable %_ptr_Uniform__runtimearr_uname Uniform -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%nu_ii = OpVariable %_ptr_Input_int Input -%int_0 = OpConstant %int 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %26 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v4float = OpTypeVector %float 4 -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%16 = OpLoad %int %nu_ii -%19 = OpAccessChain %_ptr_Uniform_float %uniformBuffer %16 %int_0 -%20 = OpLoad %float %19 -OpStore %b %20 -; CHECK-NOT: %20 = OpLoad %float %19 -; CHECK-NOT: OpStore %b %20 -; CHECK: %40 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_3 -; CHECK: %42 = OpULessThan %bool %7 %40 -; CHECK: OpSelectionMerge %43 None -; CHECK: OpBranchConditional %42 %44 %45 -; CHECK: %44 = OpLabel -; CHECK: %103 = OpBitcast %uint %7 -; CHECK: %122 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %103 -; CHECK: %123 = OpULessThan %bool %uint_0 %122 -; CHECK: OpSelectionMerge %124 None -; CHECK: OpBranchConditional %123 %125 %126 -; CHECK: %125 = OpLabel -; CHECK: %127 = OpLoad %float %20 -; CHECK: OpBranch %124 -; CHECK: %126 = OpLabel -; CHECK: %128 = OpBitcast %uint %7 -; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 -; CHECK: OpBranch %124 -; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 -; CHECK: OpBranch %43 -; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 -; CHECK: OpBranch %43 -; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstBoundsAndInitLoadUnsizedSSBOArrayDeprecated) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location=0) in nonuniformEXT flat int nu_ii; - // layout(location=0) out float b; - // - // layout(binding=3) buffer bname { float b; } storageBuffer[]; - // - // void main() - // { - // b = storageBuffer[nu_ii].b; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability ShaderNonUniform -OpCapability RuntimeDescriptorArray -OpCapability StorageBufferArrayNonUniformIndexing -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %b %nu_ii -; CHECK: OpEntryPoint Fragment %main "main" %b %nu_ii %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %b "b" -OpName %bname "bname" -OpMemberName %bname 0 "a" -OpName %storageBuffer "storageBuffer" -OpName %nu_ii "nu_ii" -OpDecorate %b Location 0 -OpMemberDecorate %bname 0 Offset 0 -OpDecorate %bname Block -OpDecorate %storageBuffer DescriptorSet 0 -OpDecorate %storageBuffer Binding 3 -OpDecorate %nu_ii Flat -OpDecorate %nu_ii Location 0 -OpDecorate %nu_ii NonUniform -OpDecorate %16 NonUniform -OpDecorate %20 NonUniform -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %130 NonUniform -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -; CHECK: OpDecorate %127 NonUniform -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%b = OpVariable %_ptr_Output_float Output -%bname = OpTypeStruct %float -%_runtimearr_bname = OpTypeRuntimeArray %bname -%_ptr_StorageBuffer__runtimearr_bname = OpTypePointer StorageBuffer %_runtimearr_bname -%storageBuffer = OpVariable %_ptr_StorageBuffer__runtimearr_bname StorageBuffer -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%nu_ii = OpVariable %_ptr_Input_int Input -%int_0 = OpConstant %int 0 -%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %26 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v4float = OpTypeVector %float 4 -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%16 = OpLoad %int %nu_ii -%19 = OpAccessChain %_ptr_StorageBuffer_float %storageBuffer %16 %int_0 -%20 = OpLoad %float %19 -OpStore %b %20 -; CHECK-NOT: %20 = OpLoad %float %19 -; CHECK-NOT: OpStore %b %20 -; CHECK: %40 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_3 -; CHECK: %42 = OpULessThan %bool %7 %40 -; CHECK: OpSelectionMerge %43 None -; CHECK: OpBranchConditional %42 %44 %45 -; CHECK: %44 = OpLabel -; CHECK: %103 = OpBitcast %uint %7 -; CHECK: %122 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %103 -; CHECK: %123 = OpULessThan %bool %uint_0 %122 -; CHECK: OpSelectionMerge %124 None -; CHECK: OpBranchConditional %123 %125 %126 -; CHECK: %125 = OpLabel -; CHECK: %127 = OpLoad %float %20 -; CHECK: OpBranch %124 -; CHECK: %126 = OpLabel -; CHECK: %128 = OpBitcast %uint %7 -; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 -; CHECK: OpBranch %124 -; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 -; CHECK: OpBranch %43 -; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 -; CHECK: OpBranch %43 -; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstBoundsAndInitLoadUnsizedSSBOArray) { - // Same as Deprecated but declaring as StorageBuffer Block - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability ShaderNonUniform -OpCapability RuntimeDescriptorArray -OpCapability StorageBufferArrayNonUniformIndexing -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %b %nu_ii -; CHECK: OpEntryPoint Fragment %main "main" %b %nu_ii %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %b "b" -OpName %bname "bname" -OpMemberName %bname 0 "a" -OpName %storageBuffer "storageBuffer" -OpName %nu_ii "nu_ii" -OpDecorate %b Location 0 -OpMemberDecorate %bname 0 Offset 0 -OpDecorate %bname Block -OpDecorate %storageBuffer DescriptorSet 0 -OpDecorate %storageBuffer Binding 3 -OpDecorate %nu_ii Flat -OpDecorate %nu_ii Location 0 -OpDecorate %nu_ii NonUniform -OpDecorate %16 NonUniform -OpDecorate %20 NonUniform -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %130 NonUniform -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -; CHECK: OpDecorate %127 NonUniform -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%b = OpVariable %_ptr_Output_float Output -%bname = OpTypeStruct %float -%_runtimearr_bname = OpTypeRuntimeArray %bname -%_ptr_StorageBuffer__runtimearr_bname = OpTypePointer StorageBuffer %_runtimearr_bname -%storageBuffer = OpVariable %_ptr_StorageBuffer__runtimearr_bname StorageBuffer -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%nu_ii = OpVariable %_ptr_Input_int Input -%int_0 = OpConstant %int 0 -%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %26 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v4float = OpTypeVector %float 4 -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%16 = OpLoad %int %nu_ii -%19 = OpAccessChain %_ptr_StorageBuffer_float %storageBuffer %16 %int_0 -%20 = OpLoad %float %19 -OpStore %b %20 -; CHECK-NOT: %20 = OpLoad %float %19 -; CHECK-NOT: OpStore %b %20 -; CHECK: %40 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_3 -; CHECK: %42 = OpULessThan %bool %7 %40 -; CHECK: OpSelectionMerge %43 None -; CHECK: OpBranchConditional %42 %44 %45 -; CHECK: %44 = OpLabel -; CHECK: %103 = OpBitcast %uint %7 -; CHECK: %122 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %103 -; CHECK: %123 = OpULessThan %bool %uint_0 %122 -; CHECK: OpSelectionMerge %124 None -; CHECK: OpBranchConditional %123 %125 %126 -; CHECK: %125 = OpLabel -; CHECK: %127 = OpLoad %float %20 -; CHECK: OpBranch %124 -; CHECK: %126 = OpLabel -; CHECK: %128 = OpBitcast %uint %7 -; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 -; CHECK: OpBranch %124 -; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 -; CHECK: OpBranch %43 -; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 -; CHECK: OpBranch %43 -; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstInitLoadUBOScalar) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location=0) out float b; - // layout(binding=3) uniform uname { float a; } uniformBuffer; - // - // void main() - // { - // b = uniformBuffer.a; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %b -; CHECK: OpEntryPoint Fragment %main "main" %b %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %b "b" -OpName %uname "uname" -OpMemberName %uname 0 "a" -OpName %uniformBuffer "uniformBuffer" -OpDecorate %b Location 0 -OpMemberDecorate %uname 0 Offset 0 -OpDecorate %uname Block -OpDecorate %uniformBuffer DescriptorSet 0 -OpDecorate %uniformBuffer Binding 3 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%b = OpVariable %_ptr_Output_float Output -%uname = OpTypeStruct %float -%_ptr_Uniform_uname = OpTypePointer Uniform %uname -%uniformBuffer = OpVariable %_ptr_Uniform_uname Uniform -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %int = OpTypeInt 32 1 -; CHECK: %_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %21 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %52 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v4float = OpTypeVector %float 4 -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %104 = OpConstantNull %float -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%15 = OpAccessChain %_ptr_Uniform_float %uniformBuffer %int_0 -%16 = OpLoad %float %15 -OpStore %b %16 -; CHECK-NOT: %16 = OpLoad %float %15 -; CHECK-NOT: OpStore %b %16 -; CHECK: %43 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %uint_0 -; CHECK: %45 = OpULessThan %bool %uint_0 %43 -; CHECK: OpSelectionMerge %47 None -; CHECK: OpBranchConditional %45 %48 %49 -; CHECK: %48 = OpLabel -; CHECK: %50 = OpLoad %float %15 -; CHECK: OpBranch %47 -; CHECK: %49 = OpLabel -; CHECK: %103 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_32 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %47 -; CHECK: %47 = OpLabel -; CHECK: %105 = OpPhi %float %50 %48 %104 %49 -; CHECK: OpStore %b %105 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead4 + kStreamWrite4Frag; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstBoundsInitStoreUnsizedSSBOArray) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location=0) in nonuniformEXT flat int nu_ii; - // layout(location=1) in float b; - // - // layout(binding=4) buffer bname { float b; } storageBuffer[]; - // - // void main() - // { - // storageBuffer[nu_ii].b = b; - // } - - // clang-format off - const std::string defs = R"(OpCapability Shader -OpCapability ShaderNonUniform -OpCapability RuntimeDescriptorArray -OpCapability StorageBufferArrayNonUniformIndexing -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %nu_ii %b -; CHECK: OpEntryPoint Fragment %main "main" %nu_ii %b %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %bname "bname" -OpMemberName %bname 0 "b" -OpName %storageBuffer "storageBuffer" -OpName %nu_ii "nu_ii" -OpName %b "b" -OpMemberDecorate %bname 0 Offset 0 -OpDecorate %bname BufferBlock -OpDecorate %storageBuffer DescriptorSet 0 -OpDecorate %storageBuffer Binding 4 -OpDecorate %nu_ii Flat -OpDecorate %nu_ii Location 0 -OpDecorate %nu_ii NonUniform -OpDecorate %14 NonUniform -OpDecorate %b Location 1 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%bname = OpTypeStruct %float -%_runtimearr_bname = OpTypeRuntimeArray %bname -%_ptr_Uniform__runtimearr_bname = OpTypePointer Uniform %_runtimearr_bname -%storageBuffer = OpVariable %_ptr_Uniform__runtimearr_bname Uniform -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%nu_ii = OpVariable %_ptr_Input_int Input -%int_0 = OpConstant %int 0 -%_ptr_Input_float = OpTypePointer Input %float -%b = OpVariable %_ptr_Input_float Input -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %26 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %48 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %102 = OpTypeFunction %uint %uint %uint %uint %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%14 = OpLoad %int %nu_ii -%18 = OpLoad %float %b -%20 = OpAccessChain %_ptr_Uniform_float %storageBuffer %14 %int_0 -OpStore %20 %18 -; CHECK-NOT: OpStore %20 %18 -; CHECK: %40 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_4 -; CHECK: %42 = OpULessThan %bool %7 %40 -; CHECK: OpSelectionMerge %43 None -; CHECK: OpBranchConditional %42 %44 %45 -; CHECK: %44 = OpLabel -; CHECK: %100 = OpBitcast %uint %7 -; CHECK: %119 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_4 %100 -; CHECK: %120 = OpULessThan %bool %uint_0 %119 -; CHECK: OpSelectionMerge %121 None -; CHECK: OpBranchConditional %120 %122 %123 -; CHECK: %122 = OpLabel -; CHECK: OpStore %20 %19 -; CHECK: OpBranch %121 -; CHECK: %123 = OpLabel -; CHECK: %124 = OpBitcast %uint %7 -; CHECK: %125 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %124 %uint_0 -; CHECK: OpBranch %121 -; CHECK: %121 = OpLabel -; CHECK: OpBranch %43 -; CHECK: %45 = OpLabel -; CHECK: %46 = OpBitcast %uint %7 -; CHECK: %99 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %46 %40 -; CHECK: OpBranch %43 -; CHECK: %43 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstBoundsInitLoadSizedUBOArray) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location=0) in nonuniformEXT flat int nu_ii; - // layout(location=0) out float b; - // - // layout(binding=3) uniform uname { float a; } uniformBuffer[128]; - // - // void main() - // { - // b = uniformBuffer[nu_ii].a; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability ShaderNonUniform -OpCapability UniformBufferArrayNonUniformIndexing -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %b %nu_ii -; CHECK: OpEntryPoint Fragment %main "main" %b %nu_ii %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %b "b" -OpName %uname "uname" -OpMemberName %uname 0 "a" -OpName %uniformBuffer "uniformBuffer" -OpName %nu_ii "nu_ii" -OpDecorate %b Location 0 -OpMemberDecorate %uname 0 Offset 0 -OpDecorate %uname Block -OpDecorate %uniformBuffer DescriptorSet 0 -OpDecorate %uniformBuffer Binding 3 -OpDecorate %nu_ii Flat -OpDecorate %nu_ii Location 0 -OpDecorate %nu_ii NonUniform -OpDecorate %18 NonUniform -OpDecorate %22 NonUniform -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)" + kInputDecorations + R"( -; CHECK: OpDecorate %117 NonUniform -%void = OpTypeVoid -%3 = OpTypeFunction %void -%float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%b = OpVariable %_ptr_Output_float Output -%uname = OpTypeStruct %float -%uint = OpTypeInt 32 0 -%uint_128 = OpConstant %uint 128 -%_arr_uname_uint_128 = OpTypeArray %uname %uint_128 -%_ptr_Uniform__arr_uname_uint_128 = OpTypePointer Uniform %_arr_uname_uint_128 -%uniformBuffer = OpVariable %_ptr_Uniform__arr_uname_uint_128 Uniform -%int = OpTypeInt 32 1 -%_ptr_Input_int = OpTypePointer Input %int -%nu_ii = OpVariable %_ptr_Input_int Input -%int_0 = OpConstant %int 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %bool = OpTypeBool -; CHECK: %32 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %v4float = OpTypeVector %float 4 -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %88 = OpConstantNull %float -; CHECK: %92 = OpTypeFunction %uint %uint %uint %uint %uint -)" + kInputGlobals; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%18 = OpLoad %int %nu_ii -%21 = OpAccessChain %_ptr_Uniform_float %uniformBuffer %18 %int_0 -%22 = OpLoad %float %21 -OpStore %b %22 -; CHECK-NOT: %22 = OpLoad %float %21 -; CHECK-NOT: OpStore %b %22 -; CHECK: %25 = OpULessThan %bool %7 %uint_128 -; CHECK: OpSelectionMerge %26 None -; CHECK: OpBranchConditional %25 %27 %28 -; CHECK: %27 = OpLabel -; CHECK: %90 = OpBitcast %uint %7 -; CHECK: %112 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %90 -; CHECK: %113 = OpULessThan %bool %uint_0 %112 -; CHECK: OpSelectionMerge %114 None -; CHECK: OpBranchConditional %113 %115 %116 -; CHECK: %115 = OpLabel -; CHECK: %117 = OpLoad %float %22 -; CHECK: OpBranch %114 -; CHECK: %116 = OpLabel -; CHECK: %118 = OpBitcast %uint %7 -; CHECK: %119 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_46 %uint_1 %118 %uint_0 -; CHECK: OpBranch %114 -; CHECK: %114 = OpLabel -; CHECK: %120 = OpPhi %float %117 %115 %88 %116 -; CHECK: OpBranch %26 -; CHECK: %28 = OpLabel -; CHECK: %30 = OpBitcast %uint %7 -; CHECK: %87 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_46 %uint_0 %30 %uint_128 -; CHECK: OpBranch %26 -; CHECK: %26 = OpLabel -; CHECK: %89 = OpPhi %float %120 %114 %88 %28 -; CHECK: OpStore %b %89 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kStreamWrite4Frag + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsComputeShaderInitLoadVariableSizedSampledImagesArray) { - // #version 450 - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout (local_size_x = 1, local_size_y = 1) in; - // - // layout(set = 0, binding = 0, std140) buffer Input { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability Shader -OpCapability RuntimeDescriptorArray -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %main "main" -; CHECK: OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID -OpExecutionMode %main LocalSize 1 1 1 -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %Input "Input" -OpMemberName %Input 0 "index" -OpMemberName %Input 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %Input 0 Offset 0 -OpMemberDecorate %Input 1 Offset 4 -OpDecorate %Input BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%Input = OpTypeStruct %uint %float -%_ptr_Uniform_Input = OpTypePointer Uniform %Input -%sbo = OpVariable %_ptr_Uniform_Input Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input -; CHECK: %112 = OpConstantNull %v4float -; CHECK: %115 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %140 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %132 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %133 = OpULessThan %bool %uint_0 %132 -; CHECK: OpSelectionMerge %134 None -; CHECK: OpBranchConditional %133 %135 %136 -; CHECK: %135 = OpLabel -; CHECK: %137 = OpLoad %uint %25 -; CHECK: OpBranch %134 -; CHECK: %136 = OpLabel -; CHECK: %139 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_47 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %134 -; CHECK: %134 = OpLabel -; CHECK: %141 = OpPhi %uint %137 %135 %140 %136 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %141 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %141 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %142 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %141 -; CHECK: %143 = OpULessThan %bool %uint_0 %142 -; CHECK: OpSelectionMerge %144 None -; CHECK: OpBranchConditional %143 %145 %146 -; CHECK: %145 = OpLabel -; CHECK: %147 = OpLoad %13 %27 -; CHECK: %148 = OpImageRead %v4float %147 %20 -; CHECK: OpBranch %144 -; CHECK: %146 = OpLabel -; CHECK: %149 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_50 %uint_1 %141 %uint_0 -; CHECK: OpBranch %144 -; CHECK: %144 = OpLabel -; CHECK: %150 = OpPhi %v4float %148 %145 %112 %146 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %111 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_50 %uint_0 %141 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %113 = OpPhi %v4float %150 %144 %112 %53 -; CHECK: %30 = OpCompositeExtract %float %113 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %151 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %152 = OpULessThan %bool %uint_0 %151 -; CHECK: OpSelectionMerge %153 None -; CHECK: OpBranchConditional %152 %154 %155 -; CHECK: %154 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %153 -; CHECK: %155 = OpLabel -; CHECK: %157 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_53 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %153 -; CHECK: %153 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = - kDirectRead2 + kStreamWrite4Compute + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsRayGenerationInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint RayGenerationNV %main "main" -; CHECK: OpEntryPoint RayGenerationNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsIntersectionInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint IntersectionNV %main "main" -; CHECK: OpEntryPoint IntersectionNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsAnyHitInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint AnyHitNV %main "main" -; CHECK: OpEntryPoint AnyHitNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsClosestHitInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint ClosestHitNV %main "main" -; CHECK: OpEntryPoint ClosestHitNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsMissInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint MissNV %main "main" -; CHECK: OpEntryPoint MissNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, - InstBoundsCallableInitLoadVariableSizedSampledImagesArray) { - // #version 460 - // #extension GL_EXT_nonuniform_qualifier : require - // #extension GL_NV_ray_tracing : require - // - // layout(set = 0, binding = 0, std140) buffer StorageBuffer { - // uint index; - // float red; - // } sbo; - // - // layout(set = 0, binding = 1, rgba32f) readonly uniform image2D images[]; - // - // void main() - // { - // sbo.red = imageLoad(images[sbo.index], ivec2(0, 0)).r; - // } - - // clang-format off - const std::string defs = R"( -OpCapability RuntimeDescriptorArray -OpCapability RayTracingNV -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_NV_ray_tracing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint CallableNV %main "main" -; CHECK: OpEntryPoint CallableNV %main "main" %89 -OpSource GLSL 460 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpSourceExtension "GL_NV_ray_tracing" -OpName %main "main" -OpName %StorageBuffer "StorageBuffer" -OpMemberName %StorageBuffer 0 "index" -OpMemberName %StorageBuffer 1 "red" -OpName %sbo "sbo" -OpName %images "images" -OpMemberDecorate %StorageBuffer 0 Offset 0 -OpMemberDecorate %StorageBuffer 1 Offset 4 -OpDecorate %StorageBuffer BufferBlock -OpDecorate %sbo DescriptorSet 0 -OpDecorate %sbo Binding 0 -OpDecorate %images DescriptorSet 0 -OpDecorate %images Binding 1 -OpDecorate %images NonWritable -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV -%void = OpTypeVoid -%3 = OpTypeFunction %void -%uint = OpTypeInt 32 0 -%float = OpTypeFloat 32 -%StorageBuffer = OpTypeStruct %uint %float -%_ptr_Uniform_StorageBuffer = OpTypePointer Uniform %StorageBuffer -%sbo = OpVariable %_ptr_Uniform_StorageBuffer Uniform -%int = OpTypeInt 32 1 -%int_1 = OpConstant %int 1 -%13 = OpTypeImage %float 2D 0 0 0 2 Rgba32f -%_runtimearr_13 = OpTypeRuntimeArray %13 -%_ptr_UniformConstant__runtimearr_13 = OpTypePointer UniformConstant %_runtimearr_13 -%images = OpVariable %_ptr_UniformConstant__runtimearr_13 UniformConstant -%int_0 = OpConstant %int 0 -%_ptr_Uniform_uint = OpTypePointer Uniform %uint -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%v2int = OpTypeVector %int 2 -%25 = OpConstantComposite %v2int %int_0 %int_0 -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%19 = OpAccessChain %_ptr_Uniform_uint %sbo %int_0 -%20 = OpLoad %uint %19 -%22 = OpAccessChain %_ptr_UniformConstant_13 %images %20 -%23 = OpLoad %13 %22 -%27 = OpImageRead %v4float %23 %25 -%29 = OpCompositeExtract %float %27 0 -%31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -OpStore %31 %29 -; CHECK-NOT: OpStore %31 %29 -; CHECK: %133 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %134 = OpULessThan %bool %uint_0 %133 -; CHECK: OpSelectionMerge %135 None -; CHECK: OpBranchConditional %134 %136 %137 -; CHECK: %136 = OpLabel -; CHECK: %138 = OpLoad %uint %25 -; CHECK: OpBranch %135 -; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %135 -; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 -; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 -; CHECK: %28 = OpLoad %13 %27 -; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 -; CHECK: %50 = OpULessThan %bool %142 %48 -; CHECK: OpSelectionMerge %51 None -; CHECK: OpBranchConditional %50 %52 %53 -; CHECK: %52 = OpLabel -; CHECK: %54 = OpLoad %13 %27 -; CHECK: %143 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %142 -; CHECK: %144 = OpULessThan %bool %uint_0 %143 -; CHECK: OpSelectionMerge %145 None -; CHECK: OpBranchConditional %144 %146 %147 -; CHECK: %146 = OpLabel -; CHECK: %148 = OpLoad %13 %27 -; CHECK: %149 = OpImageRead %v4float %148 %20 -; CHECK: OpBranch %145 -; CHECK: %147 = OpLabel -; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 -; CHECK: OpBranch %145 -; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 -; CHECK: OpBranch %51 -; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 -; CHECK: OpBranch %51 -; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 -; CHECK: %30 = OpCompositeExtract %float %114 0 -; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 -; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %153 = OpULessThan %bool %uint_0 %152 -; CHECK: OpSelectionMerge %154 None -; CHECK: OpBranchConditional %153 %155 %156 -; CHECK: %155 = OpLabel -; CHECK: OpStore %31 %30 -; CHECK: OpBranch %154 -; CHECK: %156 = OpLabel -; CHECK: %158 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_54 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %154 -; CHECK: %154 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kDirectRead2 + kStreamWrite4Ray + kDirectRead4; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, InstBoundsInitSameBlockOpReplication) { - // Test that same block ops like OpSampledImage are replicated properly - // where needed. - // - // clang-format off - // - // #version 450 core - // #extension GL_EXT_nonuniform_qualifier : enable - // - // layout(location = 0) in vec2 inTexcoord; - // layout(location = 0) out vec4 outColor; - // - // layout(set = 0, binding = 0) uniform Uniforms { - // vec2 var0; - // } uniforms; - // - // layout(set = 0, binding = 1) uniform sampler uniformSampler; - // layout(set = 0, binding = 2) uniform texture2D uniformTex; - // layout(set = 0, binding = 3) uniform texture2D uniformTexArr[8]; - // - // void main() { - // int index = 0; - // float x = texture(sampler2D(uniformTexArr[nonuniformEXT(index)], uniformSampler), inTexcoord.xy).x; - // float y = texture(sampler2D(uniformTex, uniformSampler), inTexcoord.xy * uniforms.var0.xy).x; - // outColor = vec4(x, y, 0.0, 0.0); - // } - // - - const std::string defs = R"( -OpCapability Shader -OpCapability ShaderNonUniformEXT -OpCapability SampledImageArrayNonUniformIndexingEXT -OpExtension "SPV_EXT_descriptor_indexing" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %inTexcoord %outColor -; CHECK: OpEntryPoint Fragment %main "main" %inTexcoord %outColor %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_EXT_nonuniform_qualifier" -OpName %main "main" -OpName %index "index" -OpName %x "x" -OpName %uniformTexArr "uniformTexArr" -OpName %uniformSampler "uniformSampler" -OpName %inTexcoord "inTexcoord" -OpName %y "y" -OpName %uniformTex "uniformTex" -OpName %Uniforms "Uniforms" -OpMemberName %Uniforms 0 "var0" -OpName %uniforms "uniforms" -OpName %outColor "outColor" -OpDecorate %uniformTexArr DescriptorSet 0 -OpDecorate %uniformTexArr Binding 3 -OpDecorate %19 NonUniformEXT -OpDecorate %22 NonUniformEXT -OpDecorate %uniformSampler DescriptorSet 0 -OpDecorate %uniformSampler Binding 1 -OpDecorate %inTexcoord Location 0 -OpDecorate %uniformTex DescriptorSet 0 -OpDecorate %uniformTex Binding 2 -OpMemberDecorate %Uniforms 0 Offset 0 -OpDecorate %Uniforms Block -OpDecorate %uniforms DescriptorSet 0 -OpDecorate %uniforms Binding 0 -OpDecorate %outColor Location 0 -; CHECK: OpDecorate %63 NonUniform -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)" + kInputDecorations + R"( -; CHECK: OpDecorate %151 NonUniform -%void = OpTypeVoid -%3 = OpTypeFunction %void -%int = OpTypeInt 32 1 -%_ptr_Function_int = OpTypePointer Function %int -%int_0 = OpConstant %int 0 -%float = OpTypeFloat 32 -%_ptr_Function_float = OpTypePointer Function %float -%13 = OpTypeImage %float 2D 0 0 0 1 Unknown -%uint = OpTypeInt 32 0 -%uint_8 = OpConstant %uint 8 -%_arr_13_uint_8 = OpTypeArray %13 %uint_8 -%_ptr_UniformConstant__arr_13_uint_8 = OpTypePointer UniformConstant %_arr_13_uint_8 -%uniformTexArr = OpVariable %_ptr_UniformConstant__arr_13_uint_8 UniformConstant -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%23 = OpTypeSampler -%_ptr_UniformConstant_23 = OpTypePointer UniformConstant %23 -%uniformSampler = OpVariable %_ptr_UniformConstant_23 UniformConstant -%27 = OpTypeSampledImage %13 -%v2float = OpTypeVector %float 2 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%inTexcoord = OpVariable %_ptr_Input_v2float Input -%v4float = OpTypeVector %float 4 -%uint_0 = OpConstant %uint 0 -%uniformTex = OpVariable %_ptr_UniformConstant_13 UniformConstant -%Uniforms = OpTypeStruct %v2float -%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms -%uniforms = OpVariable %_ptr_Uniform_Uniforms Uniform -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float -%_ptr_Output_v4float = OpTypePointer Output %v4float -%outColor = OpVariable %_ptr_Output_v4float Output -%float_0 = OpConstant %float 0 -; CHECK: %bool = OpTypeBool -; CHECK: %68 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %122 = OpConstantNull %v4float -; CHECK: %126 = OpTypeFunction %uint %uint %uint %uint %uint -)" + kInputGlobals + R"( -; CHECK: %165 = OpConstantNull %v2float -)"; - // clang-format on - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%index = OpVariable %_ptr_Function_int Function -%x = OpVariable %_ptr_Function_float Function -%y = OpVariable %_ptr_Function_float Function -OpStore %index %int_0 -%19 = OpLoad %int %index -%21 = OpAccessChain %_ptr_UniformConstant_13 %uniformTexArr %19 -%22 = OpLoad %13 %21 -%26 = OpLoad %23 %uniformSampler -%28 = OpSampledImage %27 %22 %26 -%32 = OpLoad %v2float %inTexcoord -%34 = OpImageSampleImplicitLod %v4float %28 %32 -%36 = OpCompositeExtract %float %34 0 -OpStore %x %36 -%39 = OpLoad %13 %uniformTex -%40 = OpLoad %23 %uniformSampler -%41 = OpSampledImage %27 %39 %40 -%42 = OpLoad %v2float %inTexcoord -%47 = OpAccessChain %_ptr_Uniform_v2float %uniforms %int_0 -%48 = OpLoad %v2float %47 -%49 = OpFMul %v2float %42 %48 -%50 = OpImageSampleImplicitLod %v4float %41 %49 -%51 = OpCompositeExtract %float %50 0 -; CHECK-NOT: %51 = OpCompositeExtract %float %50 0 -; CHECK: %157 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -; CHECK: %158 = OpULessThan %bool %uint_0 %157 -; CHECK: OpSelectionMerge %159 None -; CHECK: OpBranchConditional %158 %160 %161 -; CHECK: %160 = OpLabel -; CHECK: %162 = OpLoad %v2float %47 -; CHECK: OpBranch %159 -; CHECK: %161 = OpLabel -; CHECK: %164 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_87 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %159 -; CHECK: %159 = OpLabel -; CHECK: %166 = OpPhi %v2float %162 %160 %165 %161 -; CHECK: %49 = OpFMul %v2float %42 %166 -; CHECK: %167 = OpSampledImage %27 %39 %40 -; CHECK: %168 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_2 %uint_0 -; CHECK: %169 = OpULessThan %bool %uint_0 %168 -; CHECK: OpSelectionMerge %170 None -; CHECK: OpBranchConditional %169 %171 %172 -; CHECK: %171 = OpLabel -; CHECK: %173 = OpLoad %13 %uniformTex -; CHECK: %174 = OpSampledImage %27 %173 %40 -; CHECK: %175 = OpImageSampleImplicitLod %v4float %174 %49 -; CHECK: OpBranch %170 -; CHECK: %172 = OpLabel -; CHECK: %177 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_89 %uint_1 %uint_0 %uint_0 -; CHECK: OpBranch %170 -; CHECK: %170 = OpLabel -; CHECK: %178 = OpPhi %v4float %175 %171 %122 %172 -; CHECK: %51 = OpCompositeExtract %float %178 0 -OpStore %y %51 -%54 = OpLoad %float %x -%55 = OpLoad %float %y -%57 = OpCompositeConstruct %v4float %54 %55 %float_0 %float_0 -OpStore %outColor %57 -OpReturn -OpFunctionEnd -)"; - - const std::string new_funcs = kStreamWrite4Frag + kDirectRead4; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(defs + main_func + new_funcs, - true, 7u, 23u, true, true, false, - false, false); -} - -TEST_F(InstBindlessTest, MultipleUniformNonAggregateRefsNoDescInit) { - // Check that uniform refs do not go out-of-bounds. All checks use same input - // buffer read function call result at top of function for uniform buffer - // length. Because descriptor indexing is not being checked, we can avoid one - // buffer load. - // - // Texture2D g_tColor; - // SamplerState g_sAniso; - // - // layout(push_constant) cbuffer PerViewPushConst_t { bool g_B; }; - // - // cbuffer PerViewConstantBuffer_t { - // float2 g_TexOff0; - // float2 g_TexOff1; - // }; - // - // struct PS_INPUT { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) { - // PS_OUTPUT ps_output; - // float2 off; - // float2 vtc; - // if (g_B) - // off = g_TexOff0; - // else - // off = g_TexOff1; - // vtc = i.vTextureCoords.xy + off; - // ps_output.vColor = g_tColor.Sample(g_sAniso, vtc); - // return ps_output; - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor -;CHECK: OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %MainPs OriginUpperLeft - OpSource HLSL 500 - OpName %MainPs "MainPs" - OpName %PerViewPushConst_t "PerViewPushConst_t" - OpMemberName %PerViewPushConst_t 0 "g_B" - OpName %_ "" - OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" - OpMemberName %PerViewConstantBuffer_t 0 "g_TexOff0" - OpMemberName %PerViewConstantBuffer_t 1 "g_TexOff1" - OpName %__0 "" - OpName %g_tColor "g_tColor" - OpName %g_sAniso "g_sAniso" - OpName %i_vTextureCoords "i.vTextureCoords" - OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" - OpMemberDecorate %PerViewPushConst_t 0 Offset 0 - OpDecorate %PerViewPushConst_t Block - OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 - OpMemberDecorate %PerViewConstantBuffer_t 1 Offset 8 - OpDecorate %PerViewConstantBuffer_t Block - OpDecorate %__0 DescriptorSet 0 - OpDecorate %__0 Binding 1 - OpDecorate %g_tColor DescriptorSet 0 - OpDecorate %g_tColor Binding 0 - OpDecorate %g_sAniso DescriptorSet 0 - OpDecorate %g_sAniso Binding 2 - OpDecorate %i_vTextureCoords Location 0 - OpDecorate %_entryPointOutput_vColor Location 0 - ;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( - ;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %uint = OpTypeInt 32 0 -%PerViewPushConst_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewPushConst_t = OpTypePointer PushConstant %PerViewPushConst_t - %_ = OpVariable %_ptr_PushConstant_PerViewPushConst_t PushConstant - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint - %bool = OpTypeBool - %uint_0 = OpConstant %uint 0 -%PerViewConstantBuffer_t = OpTypeStruct %v2float %v2float -%_ptr_Uniform_PerViewConstantBuffer_t = OpTypePointer Uniform %PerViewConstantBuffer_t - %__0 = OpVariable %_ptr_Uniform_PerViewConstantBuffer_t Uniform -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %int_1 = OpConstant %int 1 - %49 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_49 = OpTypePointer UniformConstant %49 - %g_tColor = OpVariable %_ptr_UniformConstant_49 UniformConstant - %53 = OpTypeSampler -%_ptr_UniformConstant_53 = OpTypePointer UniformConstant %53 - %g_sAniso = OpVariable %_ptr_UniformConstant_53 UniformConstant - %57 = OpTypeSampledImage %49 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output - ;CHECK: %122 = OpTypeFunction %uint %uint %uint %uint - ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint - )" + kInputGlobals + R"( - ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint - ;CHECK: %148 = OpTypeFunction %void %uint %uint %uint %uint %uint - )" + kOutputGlobals + R"( - ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float - ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input - ;CHECK: %v4uint = OpTypeVector %uint 4 - ;CHECK: %202 = OpConstantNull %v2float - %MainPs = OpFunction %void None %3 - %5 = OpLabel - ;CHECK: %140 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_1 %uint_0 - ;CHECK: OpBranch %117 - ;CHECK: %117 = OpLabel - ;CHECK: OpBranch %116 - ;CHECK: %116 = OpLabel - %69 = OpLoad %v2float %i_vTextureCoords - %82 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0 - %83 = OpLoad %uint %82 - %84 = OpINotEqual %bool %83 %uint_0 - OpSelectionMerge %91 None - OpBranchConditional %84 %85 %88 - %85 = OpLabel - %86 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 - %87 = OpLoad %v2float %86 - ;CHECK-NOT: %87 = OpLoad %v2float %86 - ;CHECK: %119 = OpIAdd %uint %uint_0 %uint_7 - ;CHECK: %141 = OpULessThan %bool %119 %140 - ;CHECK: OpSelectionMerge %143 None - ;CHECK: OpBranchConditional %141 %144 %145 - ;CHECK: %144 = OpLabel - ;CHECK: %146 = OpLoad %v2float %86 - ;CHECK: OpBranch %143 - ;CHECK: %145 = OpLabel - ;CHECK: %201 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_71 %uint_4 %uint_0 %119 %140 - ;CHECK: OpBranch %143 - ;CHECK: %143 = OpLabel - ;CHECK: %203 = OpPhi %v2float %146 %144 %202 %145 - OpBranch %91 - %88 = OpLabel - %89 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_1 - %90 = OpLoad %v2float %89 - ;CHECK-NOT: %90 = OpLoad %v2float %89 - ;CHECK: %204 = OpIAdd %uint %uint_8 %uint_7 - ;CHECK: %205 = OpULessThan %bool %204 %140 - ;CHECK: OpSelectionMerge %206 None - ;CHECK: OpBranchConditional %205 %207 %208 - ;CHECK: %207 = OpLabel - ;CHECK: %209 = OpLoad %v2float %89 - ;CHECK: OpBranch %206 - ;CHECK: %208 = OpLabel - ;CHECK: %211 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_75 %uint_4 %uint_0 %204 %140 - ;CHECK: OpBranch %206 - ;CHECK: %206 = OpLabel - ;CHECK: %212 = OpPhi %v2float %209 %207 %202 %208 - OpBranch %91 - %91 = OpLabel - %115 = OpPhi %v2float %87 %85 %90 %88 - ;CHECK-NOT: %115 = OpPhi %v2float %87 %85 %90 %88 - ;CHECK: %115 = OpPhi %v2float %203 %143 %212 %206 - %95 = OpFAdd %v2float %69 %115 - %96 = OpLoad %49 %g_tColor - %97 = OpLoad %53 %g_sAniso - %98 = OpSampledImage %57 %96 %97 - %100 = OpImageSampleImplicitLod %v4float %98 %95 - OpStore %_entryPointOutput_vColor %100 - OpReturn - OpFunctionEnd -)" + kDirectRead3 + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, UniformArrayRefNoDescInit) { - // Check that uniform array ref does not go out-of-bounds. - // - // Texture2D g_tColor; - // SamplerState g_sAniso; - // - // layout(push_constant) cbuffer PerViewPushConst_t { uint g_c; }; - // - // struct PerBatchEnvMapConstantBuffer_t { - // float4x3 g_matEnvMapWorldToLocal; - // float4 g_vEnvironmentMapBoxMins; - // float2 g_TexOff; - // }; - // - // cbuffer _BindlessFastEnvMapCB_PS_t { - // PerBatchEnvMapConstantBuffer_t g_envMapConstants[128]; - // }; - // - // struct PS_INPUT { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) { - // PS_OUTPUT ps_output; - // float2 off; - // float2 vtc; - // off = g_envMapConstants[g_c].g_TexOff; - // vtc = i.vTextureCoords.xy + off; - // ps_output.vColor = g_tColor.Sample(g_sAniso, vtc); - // return ps_output; - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor - OpExecutionMode %MainPs OriginUpperLeft - OpSource HLSL 500 - OpName %MainPs "MainPs" - OpName %PerBatchEnvMapConstantBuffer_t "PerBatchEnvMapConstantBuffer_t" - OpMemberName %PerBatchEnvMapConstantBuffer_t 0 "g_matEnvMapWorldToLocal" - OpMemberName %PerBatchEnvMapConstantBuffer_t 1 "g_vEnvironmentMapBoxMins" - OpMemberName %PerBatchEnvMapConstantBuffer_t 2 "g_TexOff" - OpName %_BindlessFastEnvMapCB_PS_t "_BindlessFastEnvMapCB_PS_t" - OpMemberName %_BindlessFastEnvMapCB_PS_t 0 "g_envMapConstants" - OpName %_ "" - OpName %PerViewPushConst_t "PerViewPushConst_t" - OpMemberName %PerViewPushConst_t 0 "g_c" - OpName %__0 "" - OpName %g_tColor "g_tColor" - OpName %g_sAniso "g_sAniso" - OpName %i_vTextureCoords "i.vTextureCoords" - OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 RowMajor - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 Offset 0 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 MatrixStride 16 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 1 Offset 48 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 2 Offset 64 - OpDecorate %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 ArrayStride 80 - OpMemberDecorate %_BindlessFastEnvMapCB_PS_t 0 Offset 0 - OpDecorate %_BindlessFastEnvMapCB_PS_t Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 2 - OpMemberDecorate %PerViewPushConst_t 0 Offset 0 - OpDecorate %PerViewPushConst_t Block - OpDecorate %g_tColor DescriptorSet 0 - OpDecorate %g_tColor Binding 0 - OpDecorate %g_sAniso DescriptorSet 0 - OpDecorate %g_sAniso Binding 1 - OpDecorate %i_vTextureCoords Location 0 - OpDecorate %_entryPointOutput_vColor Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 -%mat4v3float = OpTypeMatrix %v3float 4 -%PerBatchEnvMapConstantBuffer_t = OpTypeStruct %mat4v3float %v4float %v2float - %uint = OpTypeInt 32 0 - %uint_128 = OpConstant %uint 128 -%_arr_PerBatchEnvMapConstantBuffer_t_uint_128 = OpTypeArray %PerBatchEnvMapConstantBuffer_t %uint_128 -%_BindlessFastEnvMapCB_PS_t = OpTypeStruct %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 -%_ptr_Uniform__BindlessFastEnvMapCB_PS_t = OpTypePointer Uniform %_BindlessFastEnvMapCB_PS_t - %_ = OpVariable %_ptr_Uniform__BindlessFastEnvMapCB_PS_t Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%PerViewPushConst_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewPushConst_t = OpTypePointer PushConstant %PerViewPushConst_t - %__0 = OpVariable %_ptr_PushConstant_PerViewPushConst_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint - %int_2 = OpConstant %int 2 -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %46 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 - %g_tColor = OpVariable %_ptr_UniformConstant_46 UniformConstant - %50 = OpTypeSampler -%_ptr_UniformConstant_50 = OpTypePointer UniformConstant %50 - %g_sAniso = OpVariable %_ptr_UniformConstant_50 UniformConstant - %54 = OpTypeSampledImage %46 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -;CHECK: %105 = OpTypeFunction %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %bool = OpTypeBool -;CHECK: %132 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %185 = OpConstantNull %v2float - %MainPs = OpFunction %void None %3 - %5 = OpLabel -;CHECK: %123 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_2 %uint_0 -;CHECK: OpBranch %93 -;CHECK: %93 = OpLabel -;CHECK: OpBranch %92 -;CHECK: %92 = OpLabel - %66 = OpLoad %v2float %i_vTextureCoords - %79 = OpAccessChain %_ptr_PushConstant_uint %__0 %int_0 - %80 = OpLoad %uint %79 - %81 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 %80 %int_2 - %82 = OpLoad %v2float %81 -;CHECK-NOT: %82 = OpLoad %v2float %81 -;CHECK: %96 = OpIMul %uint %uint_80 %80 -;CHECK: %97 = OpIAdd %uint %uint_0 %96 -;CHECK: %99 = OpIAdd %uint %97 %uint_64 -;CHECK: %101 = OpIAdd %uint %99 %uint_7 -;CHECK: %125 = OpULessThan %bool %101 %123 -;CHECK: OpSelectionMerge %127 None -;CHECK: OpBranchConditional %125 %128 %129 -;CHECK: %128 = OpLabel -;CHECK: %130 = OpLoad %v2float %81 -;CHECK: OpBranch %127 -;CHECK: %129 = OpLabel -;CHECK: %184 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %123 -;CHECK: OpBranch %127 -;CHECK: %127 = OpLabel -;CHECK: %186 = OpPhi %v2float %130 %128 %185 %129 - %86 = OpFAdd %v2float %66 %82 -;CHECK-NOT: %86 = OpFAdd %v2float %66 %82 -;CHECK: %86 = OpFAdd %v2float %66 %186 - %87 = OpLoad %46 %g_tColor - %88 = OpLoad %50 %g_sAniso - %89 = OpSampledImage %54 %87 %88 - %91 = OpImageSampleImplicitLod %v4float %89 %86 - OpStore %_entryPointOutput_vColor %91 - OpReturn - OpFunctionEnd -)" + kDirectRead3 + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, UniformArrayRefWithDescInit) { - // The buffer-oob and desc-init checks should use the same debug - // output buffer write function. - // - // Same source as UniformArrayRefNoDescInit - - // clang-format off - const std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor -;CHECK: OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %MainPs OriginUpperLeft - OpSource HLSL 500 - OpName %MainPs "MainPs" - OpName %PerBatchEnvMapConstantBuffer_t "PerBatchEnvMapConstantBuffer_t" - OpMemberName %PerBatchEnvMapConstantBuffer_t 0 "g_matEnvMapWorldToLocal" - OpMemberName %PerBatchEnvMapConstantBuffer_t 1 "g_vEnvironmentMapBoxMins" - OpMemberName %PerBatchEnvMapConstantBuffer_t 2 "g_TexOff" - OpName %_BindlessFastEnvMapCB_PS_t "_BindlessFastEnvMapCB_PS_t" - OpMemberName %_BindlessFastEnvMapCB_PS_t 0 "g_envMapConstants" - OpName %_ "" - OpName %PerViewPushConst_t "PerViewPushConst_t" - OpMemberName %PerViewPushConst_t 0 "g_c" - OpName %__0 "" - OpName %g_tColor "g_tColor" - OpName %g_sAniso "g_sAniso" - OpName %i_vTextureCoords "i.vTextureCoords" - OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 RowMajor - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 Offset 0 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 MatrixStride 16 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 1 Offset 48 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 2 Offset 64 - OpDecorate %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 ArrayStride 80 - OpMemberDecorate %_BindlessFastEnvMapCB_PS_t 0 Offset 0 - OpDecorate %_BindlessFastEnvMapCB_PS_t Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 2 - OpMemberDecorate %PerViewPushConst_t 0 Offset 0 - OpDecorate %PerViewPushConst_t Block - OpDecorate %g_tColor DescriptorSet 0 - OpDecorate %g_tColor Binding 0 - OpDecorate %g_sAniso DescriptorSet 0 - OpDecorate %g_sAniso Binding 1 - OpDecorate %i_vTextureCoords Location 0 - OpDecorate %_entryPointOutput_vColor Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 -%mat4v3float = OpTypeMatrix %v3float 4 -%PerBatchEnvMapConstantBuffer_t = OpTypeStruct %mat4v3float %v4float %v2float - %uint = OpTypeInt 32 0 - %uint_128 = OpConstant %uint 128 -%_arr_PerBatchEnvMapConstantBuffer_t_uint_128 = OpTypeArray %PerBatchEnvMapConstantBuffer_t %uint_128 -%_BindlessFastEnvMapCB_PS_t = OpTypeStruct %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 -%_ptr_Uniform__BindlessFastEnvMapCB_PS_t = OpTypePointer Uniform %_BindlessFastEnvMapCB_PS_t - %_ = OpVariable %_ptr_Uniform__BindlessFastEnvMapCB_PS_t Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 -%PerViewPushConst_t = OpTypeStruct %uint -%_ptr_PushConstant_PerViewPushConst_t = OpTypePointer PushConstant %PerViewPushConst_t - %__0 = OpVariable %_ptr_PushConstant_PerViewPushConst_t PushConstant -%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint - %int_2 = OpConstant %int 2 -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %46 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 - %g_tColor = OpVariable %_ptr_UniformConstant_46 UniformConstant - %50 = OpTypeSampler -%_ptr_UniformConstant_50 = OpTypePointer UniformConstant %50 - %g_sAniso = OpVariable %_ptr_UniformConstant_50 UniformConstant - %54 = OpTypeSampledImage %46 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -;CHECK: %104 = OpTypeFunction %uint %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %bool = OpTypeBool -;CHECK: %135 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %189 = OpConstantNull %v2float -;CHECK: %201 = OpConstantNull %v4float - %MainPs = OpFunction %void None %3 - %5 = OpLabel -;CHECK: %126 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_2 %uint_0 -;CHECK: %191 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 -;CHECK: OpBranch %93 -;CHECK: %93 = OpLabel -;CHECK: OpBranch %92 -;CHECK: %92 = OpLabel - %66 = OpLoad %v2float %i_vTextureCoords - %79 = OpAccessChain %_ptr_PushConstant_uint %__0 %int_0 - %80 = OpLoad %uint %79 - %81 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 %80 %int_2 - %82 = OpLoad %v2float %81 - %86 = OpFAdd %v2float %66 %82 -;CHECK-NOT: %82 = OpLoad %v2float %81 -;CHECK-NOT: %86 = OpFAdd %v2float %66 %82 -;CHECK: %96 = OpIMul %uint %uint_80 %80 -;CHECK: %97 = OpIAdd %uint %uint_0 %96 -;CHECK: %99 = OpIAdd %uint %97 %uint_64 -;CHECK: %101 = OpIAdd %uint %99 %uint_7 -;CHECK: %128 = OpULessThan %bool %101 %126 -;CHECK: OpSelectionMerge %130 None -;CHECK: OpBranchConditional %128 %131 %132 -;CHECK: %131 = OpLabel -;CHECK: %133 = OpLoad %v2float %81 -;CHECK: OpBranch %130 -;CHECK: %132 = OpLabel -;CHECK: %188 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %126 -;CHECK: OpBranch %130 -;CHECK: %130 = OpLabel -;CHECK: %190 = OpPhi %v2float %133 %131 %189 %132 -;CHECK: %86 = OpFAdd %v2float %66 %190 - %87 = OpLoad %46 %g_tColor - %88 = OpLoad %50 %g_sAniso - %89 = OpSampledImage %54 %87 %88 - %91 = OpImageSampleImplicitLod %v4float %89 %86 - OpStore %_entryPointOutput_vColor %91 -;CHECK-NOT: %91 = OpImageSampleImplicitLod %v4float %89 %86 -;CHECK-NOT: OpStore %_entryPointOutput_vColor %91 -;CHECK: %192 = OpULessThan %bool %uint_0 %191 -;CHECK: OpSelectionMerge %193 None -;CHECK: OpBranchConditional %192 %194 %195 -;CHECK: %194 = OpLabel -;CHECK: %196 = OpLoad %46 %g_tColor -;CHECK: %197 = OpSampledImage %54 %196 %88 -;CHECK: %198 = OpImageSampleImplicitLod %v4float %197 %86 -;CHECK: OpBranch %193 -;CHECK: %195 = OpLabel -;CHECK: %200 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_83 %uint_1 %uint_0 %uint_0 %uint_0 -;CHECK: OpBranch %193 -;CHECK: %193 = OpLabel -;CHECK: %202 = OpPhi %v4float %198 %194 %201 %195 -;CHECK: OpStore %_entryPointOutput_vColor %202 - OpReturn - OpFunctionEnd -)" + kDirectRead4 + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, true, true, - true, false, true); -} - -TEST_F(InstBindlessTest, Descriptor16BitIdxRef) { - // Check that descriptor indexed with 16bit index is inbounds and - // initialized - // - // Use Simple source with min16uint g_nDataIdx - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability Int16 - OpCapability StoragePushConstant16 -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %MainPs "MainPs" %g_tColor %_ %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor -;CHECK: OpEntryPoint Fragment %MainPs "MainPs" %g_tColor %_ %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor %inst_bindless_output_buffer %gl_FragCoord %inst_bindless_input_buffer - OpExecutionMode %MainPs OriginUpperLeft - OpSource HLSL 500 - OpName %MainPs "MainPs" - OpName %g_tColor "g_tColor" - OpName %PerViewConstantBuffer_t "PerViewConstantBuffer_t" - OpMemberName %PerViewConstantBuffer_t 0 "g_nDataIdx" - OpName %_ "" - OpName %g_sAniso "g_sAniso" - OpName %i_vTextureCoords "i.vTextureCoords" - OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" - OpDecorate %g_tColor DescriptorSet 0 - OpDecorate %g_tColor Binding 0 - OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0 - OpDecorate %PerViewConstantBuffer_t Block - OpDecorate %g_sAniso DescriptorSet 0 - OpDecorate %g_sAniso Binding 0 - OpDecorate %i_vTextureCoords Location 0 - OpDecorate %_entryPointOutput_vColor Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)" + kInputDecorations + R"( - %void = OpTypeVoid - %10 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %16 = OpTypeImage %float 2D 0 0 0 1 Unknown - %uint = OpTypeInt 32 0 - %uint_128 = OpConstant %uint 128 -%_arr_16_uint_128 = OpTypeArray %16 %uint_128 -%_ptr_UniformConstant__arr_16_uint_128 = OpTypePointer UniformConstant %_arr_16_uint_128 - %g_tColor = OpVariable %_ptr_UniformConstant__arr_16_uint_128 UniformConstant - %ushort = OpTypeInt 16 0 -%PerViewConstantBuffer_t = OpTypeStruct %ushort -%_ptr_PushConstant_PerViewConstantBuffer_t = OpTypePointer PushConstant %PerViewConstantBuffer_t - %_ = OpVariable %_ptr_PushConstant_PerViewConstantBuffer_t PushConstant -%_ptr_PushConstant_ushort = OpTypePointer PushConstant %ushort -%_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16 - %25 = OpTypeSampler -%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 - %g_sAniso = OpVariable %_ptr_UniformConstant_25 UniformConstant - %27 = OpTypeSampledImage %16 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -;CHECK: %bool = OpTypeBool -;CHECK: %51 = OpTypeFunction %void %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %106 = OpConstantNull %v4float -;CHECK: %111 = OpTypeFunction %uint %uint %uint %uint %uint -)" + kInputGlobals + R"( - %MainPs = OpFunction %void None %10 - %30 = OpLabel -;CHECK: OpBranch %108 -;CHECK: %108 = OpLabel -;CHECK: OpBranch %39 -;CHECK: %39 = OpLabel - %31 = OpLoad %v2float %i_vTextureCoords - %32 = OpAccessChain %_ptr_PushConstant_ushort %_ %int_0 - %33 = OpLoad %ushort %32 - %34 = OpAccessChain %_ptr_UniformConstant_16 %g_tColor %33 - %35 = OpLoad %16 %34 - %36 = OpLoad %25 %g_sAniso - %37 = OpSampledImage %27 %35 %36 - %38 = OpImageSampleImplicitLod %v4float %37 %31 - OpStore %_entryPointOutput_vColor %38 -;CHECK-NOT: %38 = OpImageSampleImplicitLod %v4float %37 %31 -;CHECK-NOT: OpStore %_entryPointOutput_vColor %38 -;CHECK: %41 = OpUConvert %uint %33 -;CHECK: %43 = OpULessThan %bool %41 %uint_128 -;CHECK: OpSelectionMerge %44 None -;CHECK: OpBranchConditional %43 %45 %46 -;CHECK: %45 = OpLabel -;CHECK: %47 = OpLoad %16 %34 -;CHECK: %48 = OpSampledImage %27 %47 %36 -;CHECK: %109 = OpUConvert %uint %33 -;CHECK: %131 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %109 -;CHECK: %132 = OpULessThan %bool %uint_0 %131 -;CHECK: OpSelectionMerge %133 None -;CHECK: OpBranchConditional %132 %134 %135 -;CHECK: %134 = OpLabel -;CHECK: %136 = OpLoad %16 %34 -;CHECK: %137 = OpSampledImage %27 %136 %36 -;CHECK: %138 = OpImageSampleImplicitLod %v4float %137 %31 -;CHECK: OpBranch %133 -;CHECK: %135 = OpLabel -;CHECK: %139 = OpUConvert %uint %33 -;CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_60 %uint_1 %139 %uint_0 -;CHECK: OpBranch %133 -;CHECK: %133 = OpLabel -;CHECK: %141 = OpPhi %v4float %138 %134 %106 %135 -;CHECK: OpBranch %44 -;CHECK: %46 = OpLabel -;CHECK: %105 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_60 %uint_0 %41 %uint_128 -;CHECK: OpBranch %44 -;CHECK: %44 = OpLabel -;CHECK: %107 = OpPhi %v4float %141 %133 %106 %46 -;CHECK: OpStore %_entryPointOutput_vColor %107 - OpReturn - OpFunctionEnd -)" + kStreamWrite4Frag + kDirectRead4; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, true, true, - false, false, true); -} - -TEST_F(InstBindlessTest, UniformArray16bitIdxRef) { - // Check that uniform array ref with 16bit index does not go out-of-bounds. - // - // Texture2D g_tColor; - // SamplerState g_sAniso; - // - // layout(push_constant) cbuffer PerViewPushConst_t { min16uint g_c; }; - // - // struct PerBatchEnvMapConstantBuffer_t { - // float4x3 g_matEnvMapWorldToLocal; - // float4 g_vEnvironmentMapBoxMins; - // float2 g_TexOff; - // }; - // - // cbuffer _BindlessFastEnvMapCB_PS_t { - // PerBatchEnvMapConstantBuffer_t g_envMapConstants[128]; - // }; - // - // struct PS_INPUT { - // float2 vTextureCoords : TEXCOORD2; - // }; - // - // struct PS_OUTPUT { - // float4 vColor : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) { - // PS_OUTPUT ps_output; - // float2 off; - // float2 vtc; - // off = g_envMapConstants[g_c].g_TexOff; - // vtc = i.vTextureCoords.xy + off; - // ps_output.vColor = g_tColor.Sample(g_sAniso, vtc); - // return ps_output; - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability Int16 - OpCapability StoragePushConstant16 -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor -;CHECK: OpEntryPoint Fragment %MainPs "MainPs" %_ %__0 %g_tColor %g_sAniso %i_vTextureCoords %_entryPointOutput_vColor %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %MainPs OriginUpperLeft - OpSource HLSL 500 - OpName %MainPs "MainPs" - OpName %PerBatchEnvMapConstantBuffer_t "PerBatchEnvMapConstantBuffer_t" - OpMemberName %PerBatchEnvMapConstantBuffer_t 0 "g_matEnvMapWorldToLocal" - OpMemberName %PerBatchEnvMapConstantBuffer_t 1 "g_vEnvironmentMapBoxMins" - OpMemberName %PerBatchEnvMapConstantBuffer_t 2 "g_TexOff" - OpName %_BindlessFastEnvMapCB_PS_t "_BindlessFastEnvMapCB_PS_t" - OpMemberName %_BindlessFastEnvMapCB_PS_t 0 "g_envMapConstants" - OpName %_ "" - OpName %PerViewPushConst_t "PerViewPushConst_t" - OpMemberName %PerViewPushConst_t 0 "g_c" - OpName %__0 "" - OpName %g_tColor "g_tColor" - OpName %g_sAniso "g_sAniso" - OpName %i_vTextureCoords "i.vTextureCoords" - OpName %_entryPointOutput_vColor "@entryPointOutput.vColor" - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 RowMajor - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 Offset 0 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 0 MatrixStride 16 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 1 Offset 48 - OpMemberDecorate %PerBatchEnvMapConstantBuffer_t 2 Offset 64 - OpDecorate %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 ArrayStride 80 - OpMemberDecorate %_BindlessFastEnvMapCB_PS_t 0 Offset 0 - OpDecorate %_BindlessFastEnvMapCB_PS_t Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpMemberDecorate %PerViewPushConst_t 0 Offset 0 - OpDecorate %PerViewPushConst_t Block - OpDecorate %g_tColor DescriptorSet 0 - OpDecorate %g_tColor Binding 0 - OpDecorate %g_sAniso DescriptorSet 0 - OpDecorate %g_sAniso Binding 0 - OpDecorate %i_vTextureCoords Location 0 - OpDecorate %_entryPointOutput_vColor Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %14 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 - %v4float = OpTypeVector %float 4 - %v3float = OpTypeVector %float 3 -%mat4v3float = OpTypeMatrix %v3float 4 -%PerBatchEnvMapConstantBuffer_t = OpTypeStruct %mat4v3float %v4float %v2float - %uint = OpTypeInt 32 0 - %uint_128 = OpConstant %uint 128 -%_arr_PerBatchEnvMapConstantBuffer_t_uint_128 = OpTypeArray %PerBatchEnvMapConstantBuffer_t %uint_128 -%_BindlessFastEnvMapCB_PS_t = OpTypeStruct %_arr_PerBatchEnvMapConstantBuffer_t_uint_128 -%_ptr_Uniform__BindlessFastEnvMapCB_PS_t = OpTypePointer Uniform %_BindlessFastEnvMapCB_PS_t - %_ = OpVariable %_ptr_Uniform__BindlessFastEnvMapCB_PS_t Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %ushort = OpTypeInt 16 0 -%PerViewPushConst_t = OpTypeStruct %ushort -%_ptr_PushConstant_PerViewPushConst_t = OpTypePointer PushConstant %PerViewPushConst_t - %__0 = OpVariable %_ptr_PushConstant_PerViewPushConst_t PushConstant -%_ptr_PushConstant_ushort = OpTypePointer PushConstant %ushort - %int_2 = OpConstant %int 2 -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %30 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_30 = OpTypePointer UniformConstant %30 - %g_tColor = OpVariable %_ptr_UniformConstant_30 UniformConstant - %32 = OpTypeSampler -%_ptr_UniformConstant_32 = OpTypePointer UniformConstant %32 - %g_sAniso = OpVariable %_ptr_UniformConstant_32 UniformConstant - %34 = OpTypeSampledImage %30 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%i_vTextureCoords = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output -;CHECK: %61 = OpTypeFunction %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %bool = OpTypeBool -;CHECK: %88 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %142 = OpConstantNull %v2float - %MainPs = OpFunction %void None %14 - %37 = OpLabel -;CHECK: %79 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 -;CHECK: OpBranch %49 -;CHECK: %49 = OpLabel -;CHECK: OpBranch %48 -;CHECK: %48 = OpLabel - %38 = OpLoad %v2float %i_vTextureCoords - %39 = OpAccessChain %_ptr_PushConstant_ushort %__0 %int_0 - %40 = OpLoad %ushort %39 - %41 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 %40 %int_2 - %42 = OpLoad %v2float %41 - %43 = OpFAdd %v2float %38 %42 -;CHECK-NOT: %42 = OpLoad %v2float %41 -;CHECK-NOT: %43 = OpFAdd %v2float %38 %42 -;CHECK: %52 = OpUConvert %uint %40 -;CHECK: %53 = OpIMul %uint %uint_80 %52 -;CHECK: %54 = OpIAdd %uint %uint_0 %53 -;CHECK: %56 = OpIAdd %uint %54 %uint_64 -;CHECK: %58 = OpIAdd %uint %56 %uint_7 -;CHECK: %81 = OpULessThan %bool %58 %79 -;CHECK: OpSelectionMerge %83 None -;CHECK: OpBranchConditional %81 %84 %85 -;CHECK: %84 = OpLabel -;CHECK: %86 = OpLoad %v2float %41 -;CHECK: OpBranch %83 -;CHECK: %85 = OpLabel -;CHECK: %141 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_81 %uint_4 %uint_0 %58 %79 -;CHECK: OpBranch %83 -;CHECK: %83 = OpLabel -;CHECK: %143 = OpPhi %v2float %86 %84 %142 %85 -;CHECK: %43 = OpFAdd %v2float %38 %143 - %44 = OpLoad %30 %g_tColor - %45 = OpLoad %32 %g_sAniso - %46 = OpSampledImage %34 %44 %45 - %47 = OpImageSampleImplicitLod %v4float %46 %43 - OpStore %_entryPointOutput_vColor %47 - OpReturn - OpFunctionEnd - )" + kDirectRead3 + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, UniformMatrixRefRowMajor) { - // The buffer-oob row major matrix check - // - // #version 450 - // #extension GL_EXT_scalar_block_layout : enable - // - // layout(location = 0) in highp vec4 a_position; - // layout(location = 0) out mediump float v_vtxResult; - // - // layout(set = 0, binding = 0, std430, row_major) uniform Block - // { - // lowp mat4x2 var; - // }; - // - // void main (void) - // { - // v_vtxResult = var[2][1]; - // } - - // clang-format off - std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position -;CHECK: OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_VertexIndex %gl_InstanceIndex - OpSource GLSL 450 - OpSourceExtension "GL_EXT_scalar_block_layout" - OpName %main "main" - OpName %v_vtxResult "v_vtxResult" - OpName %Block "Block" - OpMemberName %Block 0 "var" - OpName %_ "" - OpName %a_position "a_position" - OpDecorate %v_vtxResult RelaxedPrecision - OpDecorate %v_vtxResult Location 0 - OpMemberDecorate %Block 0 RowMajor - OpMemberDecorate %Block 0 RelaxedPrecision - OpMemberDecorate %Block 0 Offset 0 - OpMemberDecorate %Block 0 MatrixStride 16 - OpDecorate %Block Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %21 RelaxedPrecision -;CHECK-NOT: OpDecorate %21 RelaxedPrecision -;CHECK: OpDecorate %116 RelaxedPrecision - OpDecorate %a_position Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -;CHECK: OpDecorate %61 RelaxedPrecision -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex -;CHECK: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%v_vtxResult = OpVariable %_ptr_Output_float Output - %v2float = OpTypeVector %float 2 -%mat4v2float = OpTypeMatrix %v2float 4 - %Block = OpTypeStruct %mat4v2float -%_ptr_Uniform_Block = OpTypePointer Uniform %Block - %_ = OpVariable %_ptr_Uniform_Block Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_2 = OpConstant %int 2 - %uint = OpTypeInt 32 0 - %uint_1 = OpConstant %uint 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float - %a_position = OpVariable %_ptr_Input_v4float Input -;CHECK; %37 = OpTypeFunction %uint %uint %uint %uint -;CHECK;%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK;%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK; %bool = OpTypeBool -;CHECK; %63 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK;%_ptr_Input_uint = OpTypePointer Input %uint -;CHECK;%gl_VertexIndex = OpVariable %_ptr_Input_uint Input -;CHECK;%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK; %uint_5 = OpConstant %uint 5 -;CHECK; %uint_7 = OpConstant %uint 7 -;CHECK; %uint_8 = OpConstant %uint 8 -;CHECK; %uint_9 = OpConstant %uint 9 -;CHECK; %uint_10 = OpConstant %uint 10 -;CHECK; %uint_45 = OpConstant %uint 45 -;CHECK; %115 = OpConstantNull %float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: %55 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 -;CHECK: OpBranch %26 -;CHECK: %26 = OpLabel -;CHECK: OpBranch %25 -;CHECK: %25 = OpLabel - %20 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_2 %uint_1 - %21 = OpLoad %float %20 -;CHECK-NOT: %21 = OpLoad %float %20 -;CHECK: %30 = OpIMul %uint %uint_4 %int_2 -;CHECK: %31 = OpIAdd %uint %uint_0 %30 -;CHECK: %32 = OpIMul %uint %uint_16 %uint_1 -;CHECK: %33 = OpIAdd %uint %31 %32 -;CHECK: %35 = OpIAdd %uint %33 %uint_3 -;CHECK: %57 = OpULessThan %bool %35 %55 -;CHECK: OpSelectionMerge %58 None -;CHECK: OpBranchConditional %57 %59 %60 -;CHECK: %59 = OpLabel -;CHECK: %61 = OpLoad %float %20 -;CHECK: OpBranch %58 -;CHECK: %60 = OpLabel -;CHECK: %114 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 -;CHECK: OpBranch %58 -;CHECK: %58 = OpLabel -;CHECK: %116 = OpPhi %float %61 %59 %115 %60 - OpStore %v_vtxResult %21 -;CHECK-NOT: OpStore %v_vtxResult %21 -;CHECK: OpStore %v_vtxResult %116 - OpReturn - OpFunctionEnd - )" + kDirectRead3 + kStreamWrite5Vert; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, UniformMatrixRefColumnMajor) { - // The buffer-oob column major matrix check - // - // #version 450 - // #extension GL_EXT_scalar_block_layout : enable - // - // layout(location = 0) in highp vec4 a_position; - // layout(location = 0) out mediump float v_vtxResult; - // - // layout(set = 0, binding = 0, std430, column_major) uniform Block - // { - // lowp mat4x2 var; - // }; - // - // void main (void) - // { - // v_vtxResult = var[2][1]; - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position -;CHECK: OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_VertexIndex %gl_InstanceIndex - OpSource GLSL 450 - OpSourceExtension "GL_EXT_scalar_block_layout" - OpName %main "main" - OpName %v_vtxResult "v_vtxResult" - OpName %Block "Block" - OpMemberName %Block 0 "var" - OpName %_ "" - OpName %a_position "a_position" - OpDecorate %v_vtxResult RelaxedPrecision - OpDecorate %v_vtxResult Location 0 - OpMemberDecorate %Block 0 ColMajor - OpMemberDecorate %Block 0 RelaxedPrecision - OpMemberDecorate %Block 0 Offset 0 - OpMemberDecorate %Block 0 MatrixStride 8 - OpDecorate %Block Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %21 RelaxedPrecision -;CHECK-NOT: OpDecorate %21 RelaxedPrecision -;CHECK: OpDecorate %115 RelaxedPrecision - OpDecorate %a_position Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -;CHECK: OpDecorate %61 RelaxedPrecision -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex -;CHECK: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 -%_ptr_Output_float = OpTypePointer Output %float -%v_vtxResult = OpVariable %_ptr_Output_float Output - %v2float = OpTypeVector %float 2 -%mat4v2float = OpTypeMatrix %v2float 4 - %Block = OpTypeStruct %mat4v2float -%_ptr_Uniform_Block = OpTypePointer Uniform %Block - %_ = OpVariable %_ptr_Uniform_Block Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_2 = OpConstant %int 2 - %uint = OpTypeInt 32 0 - %uint_1 = OpConstant %uint 1 -%_ptr_Uniform_float = OpTypePointer Uniform %float - %v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float - %a_position = OpVariable %_ptr_Input_v4float Input -;CHECK: %37 = OpTypeFunction %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %bool = OpTypeBool -;CHECK: %63 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_Input_uint = OpTypePointer Input %uint -;CHECK:%gl_VertexIndex = OpVariable %_ptr_Input_uint Input -;CHECK:%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK: %114 = OpConstantNull %float -%main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: %55 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 -;CHECK: OpBranch %26 -;CHECK: %26 = OpLabel -;CHECK: OpBranch %25 -;CHECK: %25 = OpLabel - %20 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_2 %uint_1 - %21 = OpLoad %float %20 -;CHECK-NOT: %21 = OpLoad %float %20 -;CHECK: %29 = OpIMul %uint %uint_8 %int_2 -;CHECK: %30 = OpIAdd %uint %uint_0 %29 -;CHECK: %32 = OpIMul %uint %uint_4 %uint_1 -;CHECK: %33 = OpIAdd %uint %30 %32 -;CHECK: %35 = OpIAdd %uint %33 %uint_3 -;CHECK: %57 = OpULessThan %bool %35 %55 -;CHECK: OpSelectionMerge %58 None -;CHECK: OpBranchConditional %57 %59 %60 -;CHECK: %59 = OpLabel -;CHECK: %61 = OpLoad %float %20 -;CHECK: OpBranch %58 -;CHECK: %60 = OpLabel -;CHECK: %113 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 -;CHECK: OpBranch %58 -;CHECK: %58 = OpLabel -;CHECK: %115 = OpPhi %float %61 %59 %114 %60 - OpStore %v_vtxResult %21 -;CHECK-NOT: OpStore %v_vtxResult %21 -;CHECK: OpStore %v_vtxResult %115 - OpReturn - OpFunctionEnd - )" + kDirectRead3 + kStreamWrite5Vert; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - ValidatorOptions()->uniform_buffer_standard_layout = true; - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, UniformMatrixVecRefRowMajor) { - // The buffer-oob row major matrix vector ref check - // - // #version 450 - // #extension GL_EXT_scalar_block_layout : enable - // - // layout(location = 0) in highp vec4 a_position; - // layout(location = 0) out highp vec2 v_vtxResult; - // - // layout(set = 0, binding = 0, std430, row_major) uniform Block - // { - // lowp mat2 var[3][4]; - // }; - // - // void main (void) - // { - // v_vtxResult = var[2][3][1]; - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position -;CHECK: OpEntryPoint Vertex %main "main" %v_vtxResult %_ %a_position %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_VertexIndex %gl_InstanceIndex - OpSource GLSL 450 - OpSourceExtension "GL_EXT_scalar_block_layout" - OpName %main "main" - OpName %v_vtxResult "v_vtxResult" - OpName %Block "Block" - OpMemberName %Block 0 "var" - OpName %_ "" - OpName %a_position "a_position" - OpDecorate %v_vtxResult Location 0 - OpDecorate %_arr_mat2v2float_uint_4 ArrayStride 32 - OpDecorate %_arr__arr_mat2v2float_uint_4_uint_3 ArrayStride 128 - OpMemberDecorate %Block 0 RowMajor - OpMemberDecorate %Block 0 RelaxedPrecision - OpMemberDecorate %Block 0 Offset 0 - OpMemberDecorate %Block 0 MatrixStride 16 - OpDecorate %Block Block - OpDecorate %_ DescriptorSet 0 - OpDecorate %_ Binding 0 - OpDecorate %26 RelaxedPrecision -;CHECK-NOT: OpDecorate %26 RelaxedPrecision -;CHECK: OpDecorate %125 RelaxedPrecision - OpDecorate %a_position Location 0 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kInputDecorations + R"( -;CHECK: OpDecorate %70 RelaxedPrecision -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex -;CHECK: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v2float = OpTypeVector %float 2 -%_ptr_Output_v2float = OpTypePointer Output %v2float -%v_vtxResult = OpVariable %_ptr_Output_v2float Output -%mat2v2float = OpTypeMatrix %v2float 2 - %uint = OpTypeInt 32 0 - %uint_4 = OpConstant %uint 4 -%_arr_mat2v2float_uint_4 = OpTypeArray %mat2v2float %uint_4 - %uint_3 = OpConstant %uint 3 -%_arr__arr_mat2v2float_uint_4_uint_3 = OpTypeArray %_arr_mat2v2float_uint_4 %uint_3 - %Block = OpTypeStruct %_arr__arr_mat2v2float_uint_4_uint_3 -%_ptr_Uniform_Block = OpTypePointer Uniform %Block - %_ = OpVariable %_ptr_Uniform_Block Uniform - %int = OpTypeInt 32 1 - %int_0 = OpConstant %int 0 - %int_2 = OpConstant %int 2 - %int_3 = OpConstant %int 3 - %int_1 = OpConstant %int 1 -%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %v4float = OpTypeVector %float 4 -%_ptr_Input_v4float = OpTypePointer Input %v4float - %a_position = OpVariable %_ptr_Input_v4float Input -;CHECK: %46 = OpTypeFunction %uint %uint %uint %uint -;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kInputGlobals + R"( -;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %bool = OpTypeBool -;CHECK: %72 = OpTypeFunction %void %uint %uint %uint %uint %uint -)" + kOutputGlobals + R"( -;CHECK:%_ptr_Input_uint = OpTypePointer Input %uint -;CHECK:%gl_VertexIndex = OpVariable %_ptr_Input_uint Input -;CHECK:%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK: %124 = OpConstantNull %v2float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: %64 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 -;CHECK: OpBranch %31 -;CHECK: %31 = OpLabel -;CHECK: OpBranch %30 -;CHECK: %30 = OpLabel - %25 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 %int_2 %int_3 %int_1 - %26 = OpLoad %v2float %25 - OpStore %v_vtxResult %26 -;CHECK-NOT: %26 = OpLoad %v2float %25 -;CHECK-NOT: OpStore %v_vtxResult %26 -;CHECK: %34 = OpIMul %uint %uint_128 %int_2 -;CHECK: %35 = OpIAdd %uint %uint_0 %34 -;CHECK: %37 = OpIMul %uint %uint_32 %int_3 -;CHECK: %38 = OpIAdd %uint %35 %37 -;CHECK: %40 = OpIMul %uint %uint_4 %int_1 -;CHECK: %41 = OpIAdd %uint %38 %40 -;CHECK: %43 = OpIAdd %uint %41 %uint_19 -;CHECK: %66 = OpULessThan %bool %43 %64 -;CHECK: OpSelectionMerge %67 None -;CHECK: OpBranchConditional %66 %68 %69 -;CHECK: %68 = OpLabel -;CHECK: %70 = OpLoad %v2float %25 -;CHECK: OpBranch %67 -;CHECK: %69 = OpLabel -;CHECK: %123 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_51 %uint_4 %uint_0 %43 %64 -;CHECK: OpBranch %67 -;CHECK: %67 = OpLabel -;CHECK: %125 = OpPhi %v2float %70 %68 %124 %69 -;CHECK: OpStore %v_vtxResult %125 - OpReturn - OpFunctionEnd - )" + kDirectRead3 + kStreamWrite5Vert; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, false, true); -} - -TEST_F(InstBindlessTest, ImageBufferOOBRead) { - // Texel buffer (imagebuffer) oob check for ImageRead - // - // #version 450 - // layout(set=3, binding=7, r32f) uniform readonly imageBuffer s; - // layout(location=11) out vec4 x; - // layout(location=13) in flat int ii; - // - // void main(){ - // x = imageLoad(s, ii); - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability ImageBuffer -;CHECK: OpCapability ImageQuery -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %x %s %ii - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %x "x" - OpName %s "s" - OpName %ii "ii" - OpDecorate %x Location 11 - OpDecorate %s DescriptorSet 3 - OpDecorate %s Binding 7 - OpDecorate %s NonWritable - OpDecorate %ii Flat - OpDecorate %ii Location 13 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %_ptr_Output_v4float = OpTypePointer Output %v4float - %x = OpVariable %_ptr_Output_v4float Output - %10 = OpTypeImage %float Buffer 0 0 0 2 R32f - %_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10 - %s = OpVariable %_ptr_UniformConstant_10 UniformConstant - %int = OpTypeInt 32 1 - %_ptr_Input_int = OpTypePointer Input %int - %ii = OpVariable %_ptr_Input_int Input -;CHECK: %uint = OpTypeInt 32 0 -;CHECK: %bool = OpTypeBool -;CHECK: %35 = OpTypeFunction %void %uint %uint %uint %uint %uint -;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %93 = OpConstantNull %v4float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: OpBranch %21 -;CHECK: %21 = OpLabel -;CHECK: OpBranch %20 -;CHECK: %20 = OpLabel -;CHECK: OpBranch %19 -;CHECK: %19 = OpLabel - %13 = OpLoad %10 %s - %17 = OpLoad %int %ii - %18 = OpImageRead %v4float %13 %17 - OpStore %x %18 -;CHECK-NOT: %18 = OpImageRead %v4float %13 %17 -;CHECK-NOT: OpStore %x %18 -;CHECK: %23 = OpBitcast %uint %17 -;CHECK: %25 = OpImageQuerySize %uint %13 -;CHECK: %27 = OpULessThan %bool %23 %25 -;CHECK: OpSelectionMerge %29 None -;CHECK: OpBranchConditional %27 %30 %31 -;CHECK: %30 = OpLabel -;CHECK: %32 = OpLoad %10 %s -;CHECK: %33 = OpImageRead %v4float %32 %17 -;CHECK: OpBranch %29 -;CHECK: %31 = OpLabel -;CHECK: %92 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_33 %uint_7 %uint_0 %23 %25 -;CHECK: OpBranch %29 -;CHECK: %29 = OpLabel -;CHECK: %94 = OpPhi %v4float %33 %30 %93 %31 -;CHECK: OpStore %x %94 - OpReturn - OpFunctionEnd - )" + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, true, true); -} - -TEST_F(InstBindlessTest, ImageBufferOOBWrite) { - // Texel buffer (imagebuffer) oob check for ImageWrite - // - // #version 450 - // layout(set=3, binding=7, r32f) uniform readonly imageBuffer s; - // layout(location=11) out vec4 x; - // layout(location=13) in flat int ii; - // - // void main(){ - // imageStore(s, ii, x); - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability ImageBuffer -;CHECK: OpCapability ImageQuery -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %s %ii %x -;CHECK: OpEntryPoint Fragment %main "main" %s %ii %x %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %s "s" - OpName %ii "ii" - OpName %x "x" - OpDecorate %s DescriptorSet 3 - OpDecorate %s Binding 7 - OpDecorate %s NonReadable - OpDecorate %ii Flat - OpDecorate %ii Location 13 - OpDecorate %x Location 11 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %7 = OpTypeImage %float Buffer 0 0 0 2 R32f - %_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7 - %s = OpVariable %_ptr_UniformConstant_7 UniformConstant - %int = OpTypeInt 32 1 - %_ptr_Input_int = OpTypePointer Input %int - %ii = OpVariable %_ptr_Input_int Input - %v4float = OpTypeVector %float 4 - %_ptr_Output_v4float = OpTypePointer Output %v4float - %x = OpVariable %_ptr_Output_v4float Output -;CHECK: %uint = OpTypeInt 32 0 -;CHECK: %bool = OpTypeBool -;CHECK: %34 = OpTypeFunction %void %uint %uint %uint %uint %uint -;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: OpBranch %21 -;CHECK: %21 = OpLabel -;CHECK: OpBranch %20 -;CHECK: %20 = OpLabel -;CHECK: OpBranch %19 -;CHECK: %19 = OpLabel - %10 = OpLoad %7 %s - %14 = OpLoad %int %ii - %18 = OpLoad %v4float %x - OpImageWrite %10 %14 %18 -;CHECK-NOT: OpImageWrite %10 %14 %18 -;CHECK: %23 = OpBitcast %uint %14 -;CHECK: %25 = OpImageQuerySize %uint %10 -;CHECK: %27 = OpULessThan %bool %23 %25 -;CHECK: OpSelectionMerge %29 None -;CHECK: OpBranchConditional %27 %30 %31 -;CHECK: %30 = OpLabel -;CHECK: %32 = OpLoad %7 %s -;CHECK: OpImageWrite %32 %14 %18 -;CHECK: OpBranch %29 -;CHECK: %31 = OpLabel -;CHECK: %91 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_34 %uint_7 %uint_0 %23 %25 -;CHECK: OpBranch %29 -;CHECK: %29 = OpLabel - OpReturn - OpFunctionEnd - )" + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, true, true); -} - -TEST_F(InstBindlessTest, TextureBufferOOBFetch) { - // Texel buffer (texturebuffer) oob check for ImageFetch - // - // #version 450 - // layout(set=3, binding=7) uniform textureBuffer s; - // layout(location=11) out vec4 x; - // layout(location=13) in flat int ii; - // - // void main(){ - // x = texelFetch(s, ii); - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability SampledBuffer -;CHECK: OpCapability ImageQuery -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %x %s %ii -;CHECK: OpEntryPoint Fragment %main "main" %x %s %ii %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %x "x" - OpName %s "s" - OpName %ii "ii" - OpDecorate %x Location 11 - OpDecorate %s DescriptorSet 3 - OpDecorate %s Binding 7 - OpDecorate %ii Flat - OpDecorate %ii Location 13 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %_ptr_Output_v4float = OpTypePointer Output %v4float - %x = OpVariable %_ptr_Output_v4float Output - %10 = OpTypeImage %float Buffer 0 0 0 1 Unknown - %_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10 - %s = OpVariable %_ptr_UniformConstant_10 UniformConstant - %int = OpTypeInt 32 1 - %_ptr_Input_int = OpTypePointer Input %int - %ii = OpVariable %_ptr_Input_int Input -;CHECK: %uint = OpTypeInt 32 0 -;CHECK: %bool = OpTypeBool -;CHECK: %35 = OpTypeFunction %void %uint %uint %uint %uint %uint -;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %94 = OpConstantNull %v4float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: OpBranch %21 -;CHECK: %21 = OpLabel -;CHECK: OpBranch %20 -;CHECK: %20 = OpLabel -;CHECK: OpBranch %19 -;CHECK: %19 = OpLabel - %13 = OpLoad %10 %s - %17 = OpLoad %int %ii - %18 = OpImageFetch %v4float %13 %17 - OpStore %x %18 -;CHECK-NOT: %18 = OpImageFetch %v4float %13 %17 -;CHECK-NOT: OpStore %x %18 -;CHECK: %23 = OpBitcast %uint %17 -;CHECK: %25 = OpImageQuerySize %uint %13 -;CHECK: %27 = OpULessThan %bool %23 %25 -;CHECK: OpSelectionMerge %29 None -;CHECK: OpBranchConditional %27 %30 %31 -;CHECK: %30 = OpLabel -;CHECK: %32 = OpLoad %10 %s -;CHECK: %33 = OpImageFetch %v4float %32 %17 -;CHECK: OpBranch %29 -;CHECK: %31 = OpLabel -;CHECK: %93 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_32 %uint_6 %uint_0 %23 %25 -;CHECK: OpBranch %29 -;CHECK: %29 = OpLabel -;CHECK: %95 = OpPhi %v4float %33 %30 %94 %31 -;CHECK: OpStore %x %95 - OpReturn - OpFunctionEnd - )" + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, true, true); -} - -TEST_F(InstBindlessTest, SamplerBufferOOBFetch) { - // Texel buffer (samplerbuffer) oob check for ImageFetch - // - // #version 450 - // layout(set=3, binding=7) uniform samplerBuffer s; - // layout(location=11) out vec4 x; - // layout(location=13) in flat int ii; - // - // void main(){ - // x = texelFetch(s, ii); - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability SampledBuffer -;CHECK: OpCapability ImageQuery -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %x %s %ii -;CHECK: OpEntryPoint Fragment %main "main" %x %s %ii %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %x "x" - OpName %s "s" - OpName %ii "ii" - OpDecorate %x Location 11 - OpDecorate %s DescriptorSet 3 - OpDecorate %s Binding 7 - OpDecorate %ii Flat - OpDecorate %ii Location 13 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %_ptr_Output_v4float = OpTypePointer Output %v4float - %x = OpVariable %_ptr_Output_v4float Output - %10 = OpTypeImage %float Buffer 0 0 0 1 Unknown - %11 = OpTypeSampledImage %10 - %_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 - %s = OpVariable %_ptr_UniformConstant_11 UniformConstant - %int = OpTypeInt 32 1 - %_ptr_Input_int = OpTypePointer Input %int - %ii = OpVariable %_ptr_Input_int Input -;CHECK: %uint = OpTypeInt 32 0 -;CHECK: %bool = OpTypeBool -;CHECK: %38 = OpTypeFunction %void %uint %uint %uint %uint %uint -;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %97 = OpConstantNull %v4float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: OpBranch %23 -;CHECK: %23 = OpLabel -;CHECK: OpBranch %22 -;CHECK: %22 = OpLabel -;CHECK: OpBranch %21 -;CHECK: %21 = OpLabel - %14 = OpLoad %11 %s - %18 = OpLoad %int %ii - %19 = OpImage %10 %14 - %20 = OpImageFetch %v4float %19 %18 - OpStore %x %20 -;CHECK-NOT: %20 = OpImageFetch %v4float %19 %18 -;CHECK-NOT: OpStore %x %20 -;CHECK: %25 = OpBitcast %uint %18 -;CHECK: %27 = OpImageQuerySize %uint %19 -;CHECK: %29 = OpULessThan %bool %25 %27 -;CHECK: OpSelectionMerge %31 None -;CHECK: OpBranchConditional %29 %32 %33 -;CHECK: %32 = OpLabel -;CHECK: %34 = OpLoad %11 %s -;CHECK: %35 = OpImage %10 %34 -;CHECK: %36 = OpImageFetch %v4float %35 %18 -;CHECK: OpBranch %31 -;CHECK: %33 = OpLabel -;CHECK: %96 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_34 %uint_6 %uint_0 %25 %27 -;CHECK: OpBranch %31 -;CHECK: %31 = OpLabel -;CHECK: %98 = OpPhi %v4float %36 %32 %97 %33 -;CHECK: OpStore %x %98 - OpReturn - OpFunctionEnd - )" + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, true, true); -} - -TEST_F(InstBindlessTest, SamplerBufferConstructorOOBFetch) { - // Texel buffer (samplerbuffer constructor) oob check for ImageFetch - // - // #version 450 - // layout(set=3, binding=7) uniform textureBuffer tBuf; - // layout(set=3, binding=8) uniform sampler s; - // layout(location=11) out vec4 x; - // layout(location=13) in flat int ii; - // - // void main(){ - // x = texelFetch(samplerBuffer(tBuf, s), ii); - // } - - // clang-format off - const std::string text = R"( - OpCapability Shader - OpCapability SampledBuffer -;CHECK: OpCapability ImageQuery -;CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %x %tBuf %s %ii -;CHECK: OpEntryPoint Fragment %main "main" %x %tBuf %s %ii %inst_bindless_output_buffer %gl_FragCoord - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpName %main "main" - OpName %x "x" - OpName %tBuf "tBuf" - OpName %s "s" - OpName %ii "ii" - OpDecorate %x Location 11 - OpDecorate %tBuf DescriptorSet 3 - OpDecorate %tBuf Binding 7 - OpDecorate %s DescriptorSet 3 - OpDecorate %s Binding 8 - OpDecorate %ii Flat - OpDecorate %ii Location 13 -;CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -;CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v4float = OpTypeVector %float 4 - %_ptr_Output_v4float = OpTypePointer Output %v4float - %x = OpVariable %_ptr_Output_v4float Output - %10 = OpTypeImage %float Buffer 0 0 0 1 Unknown - %_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10 - %tBuf = OpVariable %_ptr_UniformConstant_10 UniformConstant - %14 = OpTypeSampler - %_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 - %s = OpVariable %_ptr_UniformConstant_14 UniformConstant - %18 = OpTypeSampledImage %10 - %int = OpTypeInt 32 1 - %_ptr_Input_int = OpTypePointer Input %int - %ii = OpVariable %_ptr_Input_int Input -;CHECK: %uint = OpTypeInt 32 0 -;CHECK: %bool = OpTypeBool -;CHECK: %44 = OpTypeFunction %void %uint %uint %uint %uint %uint -;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %103 = OpConstantNull %v4float - %main = OpFunction %void None %3 - %5 = OpLabel -;CHECK: OpBranch %28 -;CHECK: %28 = OpLabel -;CHECK: OpBranch %27 -;CHECK: %27 = OpLabel -;CHECK: OpBranch %26 -;CHECK: %26 = OpLabel - %13 = OpLoad %10 %tBuf - %17 = OpLoad %14 %s - %19 = OpSampledImage %18 %13 %17 - %23 = OpLoad %int %ii - %24 = OpImage %10 %19 - %25 = OpImageFetch %v4float %24 %23 - OpStore %x %25 -;CHECK-NOT: %25 = OpImageFetch %v4float %24 %23 -;CHECK-NOT: OpStore %x %25 -;CHECK: %30 = OpBitcast %uint %23 -;CHECK: %32 = OpImageQuerySize %uint %24 -;CHECK: %34 = OpULessThan %bool %30 %32 -;CHECK: OpSelectionMerge %36 None -;CHECK: OpBranchConditional %34 %37 %38 -;CHECK: %37 = OpLabel -;CHECK: %39 = OpLoad %10 %tBuf -;CHECK: %40 = OpSampledImage %18 %39 %17 -;CHECK: %41 = OpImage %10 %40 -;CHECK: %42 = OpImageFetch %v4float %41 %23 -;CHECK: OpBranch %36 -;CHECK: %38 = OpLabel -;CHECK: %102 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_42 %uint_6 %uint_0 %30 %32 -;CHECK: OpBranch %36 -;CHECK: %36 = OpLabel -;CHECK: %104 = OpPhi %v4float %42 %37 %103 %38 -;CHECK: OpStore %x %104 - OpReturn - OpFunctionEnd - )" + kStreamWrite5Frag; - // clang-format on - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch(text, true, 7u, 23u, false, - false, true, true, true); -} - -// TODO(greg-lunarg): Add tests to verify handling of these cases: -// -// Compute shader -// Geometry shader -// Tessellation control shader -// Tessellation eval shader -// OpImage -// SampledImage variable - -} // namespace -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/inst_buff_addr_check_test.cpp b/third_party/spirv-tools/test/opt/inst_buff_addr_check_test.cpp deleted file mode 100644 index 7886ba7ea9..0000000000 --- a/third_party/spirv-tools/test/opt/inst_buff_addr_check_test.cpp +++ /dev/null @@ -1,557 +0,0 @@ -// Copyright (c) 2019-2022 Valve Corporation -// Copyright (c) 2019-2022 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Bindless Check Instrumentation Tests. -// Tests ending with V2 use version 2 record format. - -#include -#include - -#include "test/opt/assembly_builder.h" -#include "test/opt/pass_fixture.h" -#include "test/opt/pass_utils.h" - -namespace spvtools { -namespace opt { -namespace { - -static const std::string kOutputDecorations = R"( -; CHECK: OpDecorate [[output_buffer_type:%inst_buff_addr_OutputBuffer]] Block -; CHECK: OpMemberDecorate [[output_buffer_type]] 0 Offset 0 -; CHECK: OpMemberDecorate [[output_buffer_type]] 1 Offset 4 -; CHECK: OpDecorate [[output_buffer_var:%\w+]] DescriptorSet 7 -; CHECK: OpDecorate [[output_buffer_var]] Binding 0 -)"; - -static const std::string kOutputGlobals = R"( -; CHECK: [[output_buffer_type]] = OpTypeStruct %uint %uint %_runtimearr_uint -; CHECK: [[output_ptr_type:%\w+]] = OpTypePointer StorageBuffer [[output_buffer_type]] -; CHECK: [[output_buffer_var]] = OpVariable [[output_ptr_type]] StorageBuffer -)"; - -static const std::string kStreamWrite4Begin = R"( -; CHECK: {{%\w+}} = OpFunction %void None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_4:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_1 -; CHECK: {{%\w+}} = OpAtomicIAdd %uint {{%\w+}} %uint_4 %uint_0 %uint_10 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpArrayLength %uint [[output_buffer_var]] 2 -; CHECK: {{%\w+}} = OpULessThanEqual %bool {{%\w+}} {{%\w+}} -; CHECK: OpSelectionMerge {{%\w+}} None -; CHECK: OpBranchConditional {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_23 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_2 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_1]] -)"; - -static const std::string kStreamWrite4End = R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_7 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_8 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_3]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_9 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_4]] -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: OpReturn -; CHECK: OpFunctionEnd -)"; - -// clang-format off -static const std::string kStreamWrite4Frag = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpLoad %v4float %gl_FragCoord -; CHECK: {{%\w+}} = OpBitcast %v4uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; - -static const std::string kStreamWrite4Compute = kStreamWrite4Begin + R"( -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpLoad %v3uint %gl_GlobalInvocationID -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 2 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_6 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -)" + kStreamWrite4End; -// clang-format on - -static const std::string kInputDecorations = R"( -; CHECK: OpDecorate [[input_buffer_type:%inst_buff_addr_InputBuffer]] Block -; CHECK: OpMemberDecorate [[input_buffer_type]] 0 Offset 0 -; CHECK: OpDecorate [[input_buffer_var:%\w+]] DescriptorSet 7 -; CHECK: OpDecorate [[input_buffer_var]] Binding 2 -)"; - -static const std::string kInputGlobals = R"( -; CHECK: [[input_buffer_type]] = OpTypeStruct %_runtimearr_ulong -; CHECK: [[input_ptr_type:%\w+]] = OpTypePointer StorageBuffer [[input_buffer_type]] -; CHECK: [[input_buffer_var]] = OpVariable [[input_ptr_type]] StorageBuffer -)"; - -static const std::string kSearchAndTest = R"( -; CHECK: {{%\w+}} = OpFunction %bool None {{%\w+}} -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %ulong -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpPhi %uint %uint_1 {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: OpLoopMerge {{%\w+}} {{%\w+}} None -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_ulong [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %ulong {{%\w+}} -; CHECK: {{%\w+}} = OpUGreaterThan %bool {{%\w+}} [[param_1]] -; CHECK: OpBranchConditional {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpISub %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_ulong [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %ulong {{%\w+}} -; CHECK: {{%\w+}} = OpISub %ulong [[param_1]] {{%\w+}} -; CHECK: {{%\w+}} = OpUConvert %ulong [[param_2]] -; CHECK: {{%\w+}} = OpIAdd %ulong {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_ulong [[input_buffer_var]] %uint_0 %uint_0 -; CHECK: {{%\w+}} = OpLoad %ulong {{%\w+}} -; CHECK: {{%\w+}} = OpUConvert %uint {{%\w+}} -; CHECK: {{%\w+}} = OpISub %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_ulong [[input_buffer_var]] %uint_0 {{%\w+}} -; CHECK: {{%\w+}} = OpLoad %ulong {{%\w+}} -; CHECK: {{%\w+}} = OpULessThanEqual %bool {{%\w+}} {{%\w+}} -; CHECK: OpReturnValue {{%\w+}} -; CHECK: OpFunctionEnd -)"; -// clang-format on - -using InstBuffAddrTest = PassTest<::testing::Test>; - -TEST_F(InstBuffAddrTest, InstPhysicalStorageBufferStore) { - // #version 450 - // #extension GL_EXT_buffer_reference : enable - // - // layout(buffer_reference, buffer_reference_align = 16) buffer bufStruct; - // - // layout(set = 0, binding = 0) uniform ufoo { - // bufStruct data; - // uint offset; - // } u_info; - // - // layout(buffer_reference, std140) buffer bufStruct { - // layout(offset = 0) int a[2]; - // layout(offset = 32) int b; - // }; - // - // void main() { - // u_info.data.b = 0xca7; - // } - - const std::string defs = R"( -OpCapability Shader -OpCapability PhysicalStorageBufferAddresses -; CHECK: OpCapability Int64 -OpExtension "SPV_EXT_physical_storage_buffer" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel PhysicalStorageBuffer64 GLSL450 -OpEntryPoint GLCompute %main "main" -; CHECK: OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID -OpExecutionMode %main LocalSize 1 1 1 -OpSource GLSL 450 -OpSourceExtension "GL_EXT_buffer_reference" -OpName %main "main" -OpName %ufoo "ufoo" -OpMemberName %ufoo 0 "data" -OpMemberName %ufoo 1 "offset" -OpName %bufStruct "bufStruct" -OpMemberName %bufStruct 0 "a" -OpMemberName %bufStruct 1 "b" -OpName %u_info "u_info" -)"; - - // clang-format off - const std::string decorates = R"( -OpMemberDecorate %ufoo 0 Offset 0 -OpMemberDecorate %ufoo 1 Offset 8 -OpDecorate %ufoo Block -OpDecorate %_arr_int_uint_2 ArrayStride 16 -OpMemberDecorate %bufStruct 0 Offset 0 -OpMemberDecorate %bufStruct 1 Offset 32 -OpDecorate %bufStruct Block -OpDecorate %u_info DescriptorSet 0 -OpDecorate %u_info Binding 0 -; CHECK: OpDecorate %_runtimearr_ulong ArrayStride 8 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId -)"; - - const std::string globals = R"( -%void = OpTypeVoid -%3 = OpTypeFunction %void -OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_bufStruct PhysicalStorageBuffer -%uint = OpTypeInt 32 0 -%ufoo = OpTypeStruct %_ptr_PhysicalStorageBuffer_bufStruct %uint -%int = OpTypeInt 32 1 -%uint_2 = OpConstant %uint 2 -%_arr_int_uint_2 = OpTypeArray %int %uint_2 -%bufStruct = OpTypeStruct %_arr_int_uint_2 %int -%_ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer PhysicalStorageBuffer %bufStruct -%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo -%u_info = OpVariable %_ptr_Uniform_ufoo Uniform -%int_0 = OpConstant %int 0 -%_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer Uniform %_ptr_PhysicalStorageBuffer_bufStruct -%int_1 = OpConstant %int 1 -%int_3239 = OpConstant %int 3239 -%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int -; CHECK: %ulong = OpTypeInt 64 0 -; CHECK: %bool = OpTypeBool -; CHECK: %28 = OpTypeFunction %bool %ulong %uint -; CHECK: %_runtimearr_ulong = OpTypeRuntimeArray %ulong -)" + kInputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_ulong = OpTypePointer StorageBuffer %ulong -; CHECK: %70 = OpTypeFunction %void %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input -)"; -// clang-format off - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%17 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 -%18 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %17 -%22 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %18 %int_1 -; CHECK-NOT: %17 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 -; CHECK-NOT: %18 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %17 -; CHECK-NOT: %22 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %18 %int_1 -; CHECK: %20 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 -; CHECK: %21 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %20 -; CHECK: %22 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %21 %int_1 -; CHECK: %24 = OpConvertPtrToU %ulong %22 -; CHECK: %61 = OpFunctionCall %bool %inst_buff_addr_search_and_test %24 %uint_4 -; CHECK: OpSelectionMerge %62 None -; CHECK: OpBranchConditional %61 %63 %64 -; CHECK: %63 = OpLabel -OpStore %22 %int_3239 Aligned 16 -; CHECK: OpStore %22 %int_3239 Aligned 16 -; CHECK: OpBranch %62 -; CHECK: %64 = OpLabel -; CHECK: %65 = OpUConvert %uint %24 -; CHECK: %67 = OpShiftRightLogical %ulong %24 %uint_32 -; CHECK: %68 = OpUConvert %uint %67 -; CHECK: %124 = OpFunctionCall %void %inst_buff_addr_stream_write_4 %uint_48 %uint_2 %65 %68 -; CHECK: OpBranch %62 -; CHECK: %62 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string output_funcs = kSearchAndTest + kStreamWrite4Compute; - - // SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - defs + decorates + globals + main_func + output_funcs, true, 7u, 23u); -} - -TEST_F(InstBuffAddrTest, InstPhysicalStorageBufferLoadAndStore) { - // #version 450 - // #extension GL_EXT_buffer_reference : enable - - // // forward reference - // layout(buffer_reference) buffer blockType; - - // layout(buffer_reference, std430, buffer_reference_align = 16) buffer - // blockType { - // int x; - // blockType next; - // }; - - // layout(std430) buffer rootBlock { - // blockType root; - // } r; - - // void main() - // { - // blockType b = r.root; - // b = b.next; - // b.x = 531; - // } - - const std::string defs = R"( -OpCapability Shader -OpCapability PhysicalStorageBufferAddresses -; CHECK: OpCapability Int64 -OpExtension "SPV_EXT_physical_storage_buffer" -OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel PhysicalStorageBuffer64 GLSL450 -OpEntryPoint GLCompute %main "main" -OpExecutionMode %main LocalSize 1 1 1 -OpSource GLSL 450 -OpSourceExtension "GL_EXT_buffer_reference" -OpName %main "main" -; CHECK: OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID -OpName %blockType "blockType" -OpMemberName %blockType 0 "x" -OpMemberName %blockType 1 "next" -OpName %rootBlock "rootBlock" -OpMemberName %rootBlock 0 "root" -OpName %r "r" -)"; - -// clang-format off - const std::string decorates = R"( -OpMemberDecorate %blockType 0 Offset 0 -OpMemberDecorate %blockType 1 Offset 8 -OpDecorate %blockType Block -OpMemberDecorate %rootBlock 0 Offset 0 -OpDecorate %rootBlock Block -OpDecorate %r DescriptorSet 0 -OpDecorate %r Binding 0 -; CHECK: OpDecorate %_runtimearr_ulong ArrayStride 8 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId -)"; - // clang-format on - - const std::string globals = R"( -%void = OpTypeVoid -%3 = OpTypeFunction %void -OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_blockType PhysicalStorageBuffer -%int = OpTypeInt 32 1 -%blockType = OpTypeStruct %int %_ptr_PhysicalStorageBuffer_blockType -%_ptr_PhysicalStorageBuffer_blockType = OpTypePointer PhysicalStorageBuffer %blockType -%rootBlock = OpTypeStruct %_ptr_PhysicalStorageBuffer_blockType -%_ptr_StorageBuffer_rootBlock = OpTypePointer StorageBuffer %rootBlock -%r = OpVariable %_ptr_StorageBuffer_rootBlock StorageBuffer -%int_0 = OpConstant %int 0 -%_ptr_StorageBuffer__ptr_PhysicalStorageBuffer_blockType = OpTypePointer StorageBuffer %_ptr_PhysicalStorageBuffer_blockType -%int_1 = OpConstant %int 1 -%_ptr_PhysicalStorageBuffer__ptr_PhysicalStorageBuffer_blockType = OpTypePointer PhysicalStorageBuffer %_ptr_PhysicalStorageBuffer_blockType -%int_531 = OpConstant %int 531 -%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int -)" + kInputGlobals + kOutputGlobals; - - const std::string main_func = R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%16 = OpAccessChain %_ptr_StorageBuffer__ptr_PhysicalStorageBuffer_blockType %r %int_0 -%17 = OpLoad %_ptr_PhysicalStorageBuffer_blockType %16 -%21 = OpAccessChain %_ptr_PhysicalStorageBuffer__ptr_PhysicalStorageBuffer_blockType %17 %int_1 -%22 = OpLoad %_ptr_PhysicalStorageBuffer_blockType %21 Aligned 8 -%26 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %22 %int_0 -OpStore %26 %int_531 Aligned 16 -; CHECK-NOT: %22 = OpLoad %_ptr_PhysicalStorageBuffer_blockType %21 Aligned 8 -; CHECK-NOT: %26 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %22 %int_0 -; CHECK: %30 = OpConvertPtrToU %ulong %21 -; CHECK: %67 = OpFunctionCall %bool %inst_buff_addr_search_and_test %30 %uint_8 -; CHECK: OpSelectionMerge %68 None -; CHECK: OpBranchConditional %67 %69 %70 -; CHECK: %69 = OpLabel -; CHECK: %71 = OpLoad %_ptr_PhysicalStorageBuffer_blockType %21 Aligned 8 -; CHECK: OpBranch %68 -; CHECK: %70 = OpLabel -; CHECK: %72 = OpUConvert %uint %30 -; CHECK: %74 = OpShiftRightLogical %ulong %30 %uint_32 -; CHECK: %75 = OpUConvert %uint %74 -; CHECK: %131 = OpFunctionCall %void %inst_buff_addr_stream_write_4 %uint_44 %uint_2 %72 %75 -; CHECK: %133 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_blockType %132 -; CHECK: OpBranch %68 -; CHECK: %68 = OpLabel -; CHECK: %134 = OpPhi %_ptr_PhysicalStorageBuffer_blockType %71 %69 %133 %70 -; CHECK: %26 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %134 %int_0 -; CHECK: %135 = OpConvertPtrToU %ulong %26 -; CHECK: %136 = OpFunctionCall %bool %inst_buff_addr_search_and_test %135 %uint_4 -; CHECK: OpSelectionMerge %137 None -; CHECK: OpBranchConditional %136 %138 %139 -; CHECK: %138 = OpLabel -; CHECK: OpStore %26 %int_531 Aligned 16 -; CHECK: OpBranch %137 -; CHECK: %139 = OpLabel -; CHECK: %140 = OpUConvert %uint %135 -; CHECK: %141 = OpShiftRightLogical %ulong %135 %uint_32 -; CHECK: %142 = OpUConvert %uint %141 -; CHECK: %144 = OpFunctionCall %void %inst_buff_addr_stream_write_4 %uint_46 %uint_2 %140 %142 -; CHECK: OpBranch %137 -; CHECK: %137 = OpLabel -OpReturn -OpFunctionEnd -)"; - - const std::string output_funcs = kSearchAndTest + kStreamWrite4Compute; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - defs + decorates + globals + main_func + output_funcs, true, 7u, 23u); -} - -TEST_F(InstBuffAddrTest, StructLoad) { - // #version 450 - // #extension GL_EXT_buffer_reference : enable - // #extension GL_ARB_gpu_shader_int64 : enable - // struct Test { - // float a; - // }; - // - // layout(buffer_reference, std430, buffer_reference_align = 16) buffer - // TestBuffer { Test test; }; - // - // Test GetTest(uint64_t ptr) { - // return TestBuffer(ptr).test; - // } - // - // void main() { - // GetTest(0xe0000000); - // } - - const std::string defs = - R"( -OpCapability Shader -OpCapability Int64 -OpCapability PhysicalStorageBufferAddresses -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -%1 = OpExtInstImport "GLSL.std.450" -OpMemoryModel PhysicalStorageBuffer64 GLSL450 -OpEntryPoint Fragment %main "main" -; CHECK: OpEntryPoint Fragment %main "main" %inst_buff_addr_input_buffer %inst_buff_addr_output_buffer %gl_FragCoord -OpExecutionMode %main OriginUpperLeft -OpSource GLSL 450 -OpSourceExtension "GL_ARB_gpu_shader_int64" -OpSourceExtension "GL_EXT_buffer_reference" -OpName %main "main" -OpName %Test "Test" -OpMemberName %Test 0 "a" -OpName %Test_0 "Test" -OpMemberName %Test_0 0 "a" -OpName %TestBuffer "TestBuffer" -OpMemberName %TestBuffer 0 "test" -)"; - - // clang-format off - const std::string decorates = R"( -OpMemberDecorate %Test_0 0 Offset 0 -OpMemberDecorate %TestBuffer 0 Offset 0 -OpDecorate %TestBuffer Block -; CHECK: OpDecorate %_runtimearr_ulong ArrayStride 8 -)" + kInputDecorations + R"( -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)"; - - const std::string globals = R"( -%void = OpTypeVoid -%3 = OpTypeFunction %void -%ulong = OpTypeInt 64 0 -%float = OpTypeFloat 32 -%Test = OpTypeStruct %float -OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_TestBuffer PhysicalStorageBuffer -%Test_0 = OpTypeStruct %float -%TestBuffer = OpTypeStruct %Test_0 -%_ptr_PhysicalStorageBuffer_TestBuffer = OpTypePointer PhysicalStorageBuffer %TestBuffer -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 -%_ptr_PhysicalStorageBuffer_Test_0 = OpTypePointer PhysicalStorageBuffer %Test_0 -%ulong_18446744073172680704 = OpConstant %ulong 18446744073172680704 -; CHECK: %47 = OpTypeFunction %bool %ulong %uint -)" + kInputGlobals + R"( -; CHECK: %90 = OpTypeFunction %void %uint %uint %uint %uint -)" + kOutputGlobals + R"( -; CHECK: %143 = OpConstantNull %Test_0 -)"; - // clang-format on - - const std::string main_func = - R"( -%main = OpFunction %void None %3 -%5 = OpLabel -%37 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_TestBuffer %ulong_18446744073172680704 -%38 = OpAccessChain %_ptr_PhysicalStorageBuffer_Test_0 %37 %int_0 -%39 = OpLoad %Test_0 %38 Aligned 16 -; CHECK-NOT: %39 = OpLoad %Test_0 %38 Aligned 16 -; CHECK: %43 = OpConvertPtrToU %ulong %38 -; CHECK: %80 = OpFunctionCall %bool %inst_buff_addr_search_and_test %43 %uint_4 -; CHECK: OpSelectionMerge %81 None -; CHECK: OpBranchConditional %80 %82 %83 -; CHECK: %82 = OpLabel -; CHECK: %84 = OpLoad %Test_0 %38 Aligned 16 -; CHECK: OpBranch %81 -; CHECK: %83 = OpLabel -; CHECK: %85 = OpUConvert %uint %43 -; CHECK: %87 = OpShiftRightLogical %ulong %43 %uint_32 -; CHECK: %88 = OpUConvert %uint %87 -; CHECK: %142 = OpFunctionCall %void %inst_buff_addr_stream_write_4 %uint_37 %uint_2 %85 %88 -; CHECK: OpBranch %81 -; CHECK: %81 = OpLabel -; CHECK: %144 = OpPhi %Test_0 %84 %82 %143 %83 -%40 = OpCopyLogical %Test %39 -; CHECK-NOT: %40 = OpCopyLogical %Test %39 -; CHECK: %40 = OpCopyLogical %Test %144 -OpReturn -OpFunctionEnd -)"; - - const std::string output_funcs = kSearchAndTest + kStreamWrite4Frag; - - SetTargetEnv(SPV_ENV_VULKAN_1_2); - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - defs + decorates + globals + main_func + output_funcs, true); -} - -} // namespace -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp b/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp deleted file mode 100644 index 6a4cbddd10..0000000000 --- a/third_party/spirv-tools/test/opt/inst_debug_printf_test.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) 2020-2022 Valve Corporation -// Copyright (c) 2020-2022 LunarG Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Debug Printf Instrumentation Tests. - -#include -#include - -#include "test/opt/assembly_builder.h" -#include "test/opt/pass_fixture.h" -#include "test/opt/pass_utils.h" - -namespace spvtools { -namespace opt { -namespace { - -static const std::string kOutputDecorations = R"( -; CHECK: OpDecorate [[output_buffer_type:%inst_printf_OutputBuffer]] Block -; CHECK: OpMemberDecorate [[output_buffer_type]] 0 Offset 0 -; CHECK: OpMemberDecorate [[output_buffer_type]] 1 Offset 4 -; CHECK: OpMemberDecorate [[output_buffer_type]] 2 Offset 8 -; CHECK: OpDecorate [[output_buffer_var:%\w+]] DescriptorSet 7 -; CHECK: OpDecorate [[output_buffer_var]] Binding 3 -)"; - -static const std::string kOutputGlobals = R"( -; CHECK: [[output_buffer_type]] = OpTypeStruct %uint %uint %_runtimearr_uint -; CHECK: [[output_ptr_type:%\w+]] = OpTypePointer StorageBuffer [[output_buffer_type]] -; CHECK: [[output_buffer_var]] = OpVariable [[output_ptr_type]] StorageBuffer -)"; - -using InstDebugPrintfTest = PassTest<::testing::Test>; - -TEST_F(InstDebugPrintfTest, V4Float32) { - // SamplerState g_sDefault; - // Texture2D g_tColor; - // - // struct PS_INPUT - // { - // float2 vBaseTexCoord : TEXCOORD0; - // }; - // - // struct PS_OUTPUT - // { - // float4 vDiffuse : SV_Target0; - // }; - // - // PS_OUTPUT MainPs(PS_INPUT i) - // { - // PS_OUTPUT o; - // - // o.vDiffuse.rgba = g_tColor.Sample(g_sDefault, (i.vBaseTexCoord.xy).xy); - // debugPrintfEXT("diffuse: %v4f", o.vDiffuse.rgba); - // return o; - // } - - const std::string defs = - R"(OpCapability Shader -OpExtension "SPV_KHR_non_semantic_info" -%1 = OpExtInstImport "NonSemantic.DebugPrintf" -; CHECK-NOT: OpExtension "SPV_KHR_non_semantic_info" -; CHECK-NOT: %1 = OpExtInstImport "NonSemantic.DebugPrintf" -; CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %2 "MainPs" %3 %4 -; CHECK: OpEntryPoint Fragment %2 "MainPs" %3 %4 %gl_FragCoord -OpExecutionMode %2 OriginUpperLeft -%5 = OpString "Color is %vn" -)"; - - // clang-format off - const std::string decorates = - R"(OpDecorate %6 DescriptorSet 0 -OpDecorate %6 Binding 1 -OpDecorate %7 DescriptorSet 0 -OpDecorate %7 Binding 0 -OpDecorate %3 Location 0 -OpDecorate %4 Location 0 -; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 -)" + kOutputDecorations + R"( -; CHECK: OpDecorate %gl_FragCoord BuiltIn FragCoord -)"; - - const std::string globals = - R"(%void = OpTypeVoid -%9 = OpTypeFunction %void -%float = OpTypeFloat 32 -%v2float = OpTypeVector %float 2 -%v4float = OpTypeVector %float 4 -%13 = OpTypeImage %float 2D 0 0 0 1 Unknown -%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 -%6 = OpVariable %_ptr_UniformConstant_13 UniformConstant -%15 = OpTypeSampler -%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15 -%7 = OpVariable %_ptr_UniformConstant_15 UniformConstant -%17 = OpTypeSampledImage %13 -%_ptr_Input_v2float = OpTypePointer Input %v2float -%3 = OpVariable %_ptr_Input_v2float Input -%_ptr_Output_v4float = OpTypePointer Output %v4float -%4 = OpVariable %_ptr_Output_v4float Output -; CHECK: %uint = OpTypeInt 32 0 -; CHECK: %38 = OpTypeFunction %void %uint %uint %uint %uint %uint %uint -; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint -)" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %bool = OpTypeBool -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -)"; - // clang-format on - - const std::string main = - R"(%2 = OpFunction %void None %9 -%20 = OpLabel -%21 = OpLoad %v2float %3 -%22 = OpLoad %13 %6 -%23 = OpLoad %15 %7 -%24 = OpSampledImage %17 %22 %23 -%25 = OpImageSampleImplicitLod %v4float %24 %21 -%26 = OpExtInst %void %1 1 %5 %25 -; CHECK-NOT: %26 = OpExtInst %void %1 1 %5 %25 -; CHECK: %29 = OpCompositeExtract %float %25 0 -; CHECK: %30 = OpBitcast %uint %29 -; CHECK: %31 = OpCompositeExtract %float %25 1 -; CHECK: %32 = OpBitcast %uint %31 -; CHECK: %33 = OpCompositeExtract %float %25 2 -; CHECK: %34 = OpBitcast %uint %33 -; CHECK: %35 = OpCompositeExtract %float %25 3 -; CHECK: %36 = OpBitcast %uint %35 -; CHECK: %101 = OpFunctionCall %void %inst_printf_stream_write_6 %uint_36 %uint_5 %30 %32 %34 %36 -; CHECK: OpBranch %102 -; CHECK: %102 = OpLabel -OpStore %4 %25 -OpReturn -OpFunctionEnd -)"; - - const std::string output_func = R"( -; CHECK: %inst_printf_stream_write_6 = OpFunction %void None %38 -; CHECK: [[param_1:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_2:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_3:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_4:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_5:%\w+]] = OpFunctionParameter %uint -; CHECK: [[param_6:%\w+]] = OpFunctionParameter %uint -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_1 -; CHECK: {{%\w+}} = OpAtomicIAdd %uint {{%\w+}} %uint_4 %uint_0 %uint_12 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_12 -; CHECK: {{%\w+}} = OpArrayLength %uint %inst_printf_output_buffer 2 -; CHECK: {{%\w+}} = OpULessThanEqual %bool {{%\w+}} {{%\w+}} -; CHECK: OpSelectionMerge {{%\w+}} None -; CHECK: OpBranchConditional {{%\w+}} {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_0 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_12 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_1 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_23 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_2 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_1]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpLoad %v4float %gl_FragCoord -; CHECK: {{%\w+}} = OpBitcast %v4uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} {{%\w+}} -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_7 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_2]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_8 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_3]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_9 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_4]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_10 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_5]] -; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_11 -; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint %inst_printf_output_buffer %uint_2 {{%\w+}} -; CHECK: OpStore {{%\w+}} [[param_6]] -; CHECK: OpBranch {{%\w+}} -; CHECK: {{%\w+}} = OpLabel -; CHECK: OpReturn -; CHECK: OpFunctionEnd -)"; - - SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); - SinglePassRunAndMatch( - defs + decorates + globals + main + output_func, true); -} - -// TODO(greg-lunarg): Add tests to verify handling of these cases: -// -// Compute shader -// Geometry shader -// Tessellation control shader -// Tessellation eval shader -// Vertex shader - -} // namespace -} // namespace opt -} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/instruction_test.cpp b/third_party/spirv-tools/test/opt/instruction_test.cpp index 6ea7fccef2..67961eb696 100644 --- a/third_party/spirv-tools/test/opt/instruction_test.cpp +++ b/third_party/spirv-tools/test/opt/instruction_test.cpp @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/instruction.h" + #include -#include #include #include #include "gmock/gmock.h" -#include "source/opt/instruction.h" #include "source/opt/ir_context.h" #include "spirv-tools/libspirv.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp b/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp index 77624587bf..6f51b087f1 100644 --- a/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp +++ b/third_party/spirv-tools/test/opt/interface_var_sroa_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/invocation_interlock_placement_test.cpp b/third_party/spirv-tools/test/opt/invocation_interlock_placement_test.cpp new file mode 100644 index 0000000000..2c4ff65ebb --- /dev/null +++ b/third_party/spirv-tools/test/opt/invocation_interlock_placement_test.cpp @@ -0,0 +1,613 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "spirv-tools/optimizer.hpp" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using InterlockInvocationPlacementTest = PassTest<::testing::Test>; + +TEST_F(InterlockInvocationPlacementTest, CheckUnchangedIfNotFragment) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + %2 = OpLabel + OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + EXPECT_EQ( + Pass::Status::SuccessWithoutChange, + std::get<1>(SinglePassRunAndDisassemble( + kTest, /* skip_nop= */ false, /* do_validation= */ false))); +} + +TEST_F(InterlockInvocationPlacementTest, CheckUnchangedWithoutCapability) { + const std::string kTest = R"( + OpCapability Shader + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + %2 = OpLabel + OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + EXPECT_EQ( + Pass::Status::SuccessWithoutChange, + std::get<1>(SinglePassRunAndDisassemble( + kTest, /* skip_nop= */ false, /* do_validation= */ false))); +} + +TEST_F(InterlockInvocationPlacementTest, CheckSingleBasicBlock) { + // We're using OpNoLine as a generic standin for any other instruction, to + // test that begin and end aren't moved. + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 +; CHECK: OpLabel + %2 = OpLabel +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckFunctionCallExtractionBegin) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %foo = OpFunction %void None %1 +; CHECK: OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT + %2 = OpLabel + OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpReturn +; CHECK: OpFunctionEnd + OpFunctionEnd + %main = OpFunction %void None %1 +; CHECK: OpLabel + %3 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpFunctionCall + %4 = OpFunctionCall %void %foo +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckFunctionCallExtractionEnd) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %foo = OpFunction %void None %1 +; CHECK: OpLabel +; CHECK-NOT: OpEndInvocationInterlockEXT + %2 = OpLabel + OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn +; CHECK: OpFunctionEnd + OpFunctionEnd + %main = OpFunction %void None %1 +; CHECK: OpLabel + %3 = OpLabel +; CHECK-NEXT: OpFunctionCall + %4 = OpFunctionCall %void %foo +; CHECK-NEXT: OpEndInvocationInterlockEXT +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, + CheckFunctionCallExtractionRepeatedCall) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %foo = OpFunction %void None %1 +; CHECK: OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + %2 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn +; CHECK: OpFunctionEnd + OpFunctionEnd + %main = OpFunction %void None %1 +; CHECK: OpLabel + %3 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpFunctionCall + %4 = OpFunctionCall %void %foo +; CHECK-NEXT: OpFunctionCall + %5 = OpFunctionCall %void %foo +; CHECK-NEXT: OpEndInvocationInterlockEXT +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, + CheckFunctionCallExtractionNestedCall) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %foo = OpFunction %void None %1 +; CHECK: OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + %2 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn +; CHECK: OpFunctionEnd + OpFunctionEnd + %bar = OpFunction %void None %1 +; CHECK: OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + %3 = OpLabel + %4 = OpFunctionCall %void %foo + OpReturn +; CHECK: OpFunctionEnd + OpFunctionEnd + %main = OpFunction %void None %1 +; CHECK: OpLabel + %5 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpFunctionCall + %6 = OpFunctionCall %void %bar +; CHECK-NEXT: OpEndInvocationInterlockEXT +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckLoopExtraction) { + // Tests that any begin or end instructions in a loop are moved outside of the + // loop. + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + %void = OpTypeVoid + %bool = OpTypeBool + %true = OpConstantTrue %bool + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + + %2 = OpLabel +; CHECK: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpBranch %3 + + %3 = OpLabel + OpLoopMerge %3 %4 None +; CHECK: OpBranchConditional +; CHECK-NOT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpBranchConditional %true %4 %5 + + %4 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK: OpBranch + OpBranch %3 + +; CHECK-NEXT: OpLabel + %5 = OpLabel +; CHECK-NEXT: OpEndInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckAddBeginToElse) { + // Test that if there is a begin in a single branch of a conditional, begin + // will be added to the other branch. + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %bool = OpTypeBool + %true = OpConstantTrue %bool + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + + %2 = OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT + OpSelectionMerge %5 None +; CHECK: OpBranchConditional + OpBranchConditional %true %3 %4 + +; CHECK-NEXT: OpLabel + %3 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpBranch + OpBranch %5 + + %4 = OpLabel +; CHECK: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpBranch + OpBranch %5 + +; CHECK-NEXT: OpLabel + %5 = OpLabel + OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckAddEndToElse) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %bool = OpTypeBool + %true = OpConstantTrue %bool + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + + %2 = OpLabel +; CHECK: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpSelectionMerge %5 None +; CHECK: OpBranchConditional + OpBranchConditional %true %3 %4 + +; CHECK-NEXT: OpLabel + %3 = OpLabel + OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpBranch + OpBranch %5 + + %4 = OpLabel +; CHECK: OpEndInvocationInterlockEXT +; CHECK-NEXT: OpBranch + OpBranch %5 + +; CHECK-NEXT: OpLabel + %5 = OpLabel +; CHECK-NOT: OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckSplitIfWithoutElseBegin) { + // Test that if there is a begin in the then branch of a conditional, and no + // else branch, an else branch with a begin will created. + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %bool = OpTypeBool + %true = OpConstantTrue %bool + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + + %2 = OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT + OpSelectionMerge %5 None +; CHECK: OpBranchConditional + OpBranchConditional %true %3 %5 + +; CHECK-NEXT: OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpBranch + +; CHECK-NEXT: OpLabel + %3 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpBranch %5 + +; CHECK: OpLabel + %5 = OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckSplitIfWithoutElseEnd) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %bool = OpTypeBool + %true = OpConstantTrue %bool + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + + %2 = OpLabel + +; CHECK: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpSelectionMerge [[merge:%\d+]] + OpSelectionMerge %5 None +; CHECK-NEXT: OpBranchConditional %true [[then:%\d+]] [[else:%\d+]] + OpBranchConditional %true %3 %5 + +; CHECK-NEXT: [[else]] = OpLabel +; CHECK-NEXT: OpEndInvocationInterlockEXT +; CHECK-NEXT: OpBranch [[merge]] + +; CHECK-NEXT: [[then]] = OpLabel + %3 = OpLabel +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpBranch [[merge]] + OpBranch %5 + +; CHECK-NEXT: [[merge]] = OpLabel + %5 = OpLabel +; CHECK-NEXT: OpReturn + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(InterlockInvocationPlacementTest, CheckSplitSwitch) { + // Test that if there is a begin or end in a single branch of a switch, begin + // or end will be added to all the other branches. + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderSampleInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main SampleInterlockOrderedEXT + OpName %main "main" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %1 = OpTypeFunction %void + %main = OpFunction %void None %1 + +; CHECK: OpLabel + %2 = OpLabel +; CHECK-NEXT: OpSelectionMerge [[merge:%\d+]] + OpSelectionMerge %8 None +; CHECK-NEXT: OpSwitch %uint_1 [[default:%\d+]] 0 [[case_0:%\d+]] 1 [[case_1:%\d+]] 2 [[case_2:%\d+]] + OpSwitch %uint_1 %8 0 %4 1 %5 2 %8 + +; CHECK-NEXT: [[case_2]] = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpBranch [[merge]] + +; CHECK-NEXT: [[default]] = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpBranch [[merge]] + +; CHECK-NEXT: [[case_0]] = OpLabel + %4 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpBranch [[merge]] + OpBranch %8 + +; CHECK-NEXT: [[case_1]] = OpLabel + %5 = OpLabel +; CHECK-NEXT: OpBeginInvocationInterlockEXT +; CHECK-NOT: OpEndInvocationInterlockEXT + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpNoLine + OpNoLine +; CHECK-NEXT: OpBranch [[merge]] + OpBranch %8 + +; CHECK-NEXT: [[merge]] = OpLabel + %8 = OpLabel +; CHECK-NOT: OpBeginInvocationInterlockEXT + OpBeginInvocationInterlockEXT +; CHECK-NEXT: OpEndInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = SinglePassRunAndMatch( + kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/ir_builder.cpp b/third_party/spirv-tools/test/opt/ir_builder.cpp index e04e7815f5..f0cfc1849b 100644 --- a/third_party/spirv-tools/test/opt/ir_builder.cpp +++ b/third_party/spirv-tools/test/opt/ir_builder.cpp @@ -12,18 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "source/opt/ir_builder.h" + #include -#include #include #include "effcee/effcee.h" -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/basic_block.h" #include "source/opt/build_module.h" #include "source/opt/instruction.h" -#include "source/opt/ir_builder.h" #include "source/opt/type_manager.h" #include "spirv-tools/libspirv.hpp" diff --git a/third_party/spirv-tools/test/opt/ir_context_test.cpp b/third_party/spirv-tools/test/opt/ir_context_test.cpp index 86a3f4596e..d499506ea7 100644 --- a/third_party/spirv-tools/test/opt/ir_context_test.cpp +++ b/third_party/spirv-tools/test/opt/ir_context_test.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include "OpenCLDebugInfo100.h" @@ -872,6 +871,7 @@ TEST_F(IRContextTest, AsanErrorTest) { opt::Function* fun = context->cfg()->block(5)->GetParent(); // Computes the CFG analysis opt::DominatorAnalysis* dom = nullptr; + // NOLINTNEXTLINE dom = context->GetDominatorAnalysis(fun); // Computes the dominator analysis, // which depends on the CFG // analysis @@ -1149,6 +1149,349 @@ OpFunctionEnd)"; 20); } +struct TargetEnvCompareTestData { + spv_target_env later_env, earlier_env; +}; + +using TargetEnvCompareTest = ::testing::TestWithParam; + +TEST_P(TargetEnvCompareTest, IsTargetEnvAtLeast) { + const auto& tc = GetParam(); + + std::unique_ptr module(new Module()); + IRContext localContext(tc.later_env, std::move(module), + spvtools::MessageConsumer()); + EXPECT_TRUE(localContext.IsTargetEnvAtLeast(tc.earlier_env)); + + if (tc.earlier_env != tc.later_env) { + std::unique_ptr module(new Module()); + IRContext localContext(tc.earlier_env, std::move(module), + spvtools::MessageConsumer()); + EXPECT_FALSE(localContext.IsTargetEnvAtLeast(tc.later_env)); + } +} + +TEST_F(IRContextTest, ReturnsTrueWhenExtensionIsRemoved) { + const std::string text = R"( + OpCapability Shader + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 1); + + EXPECT_TRUE(ctx->RemoveExtension(kSPV_KHR_shader_clock)); + + EXPECT_FALSE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 0); +} + +TEST_F(IRContextTest, ReturnsFalseWhenExtensionIsNotRemoved) { + const std::string text = R"( + OpCapability Shader + OpExtension "SPV_KHR_device_group" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 1); + + EXPECT_FALSE(ctx->RemoveExtension(kSPV_KHR_shader_clock)); + + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 1); +} + +TEST_F(IRContextTest, RemovesExtensionIfLast) { + const std::string text = R"( + OpCapability Shader + OpExtension "SPV_KHR_device_group" + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 2); + + EXPECT_TRUE(ctx->RemoveExtension(kSPV_KHR_shader_clock)); + + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_FALSE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 1); +} + +TEST_F(IRContextTest, RemovesExtensionIfFirst) { + const std::string text = R"( + OpCapability Shader + OpExtension "SPV_KHR_shader_clock" + OpExtension "SPV_KHR_device_group" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 2); + + EXPECT_TRUE(ctx->RemoveExtension(kSPV_KHR_shader_clock)); + + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_device_group)); + EXPECT_FALSE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 1); +} + +TEST_F(IRContextTest, RemovesMultipleExtensions) { + const std::string text = R"( + OpCapability Shader + OpExtension "SPV_KHR_shader_clock" + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 2); + + EXPECT_TRUE(ctx->RemoveExtension(kSPV_KHR_shader_clock)); + + EXPECT_FALSE(ctx->get_feature_mgr()->HasExtension(kSPV_KHR_shader_clock)); + EXPECT_EQ(std::distance(ctx->module()->extension_begin(), + ctx->module()->extension_end()), + 0); +} + +TEST_F(IRContextTest, ReturnsTrueWhenCapabilityIsRemoved) { + const std::string text = R"( + OpCapability Shader + OpCapability ShaderClockKHR + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::ShaderClockKHR)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 2); + + EXPECT_TRUE(ctx->RemoveCapability(spv::Capability::ShaderClockKHR)); + + EXPECT_FALSE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::ShaderClockKHR)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 1); +} + +TEST_F(IRContextTest, ReturnsFalseWhenCapabilityIsNotRemoved) { + const std::string text = R"( + OpCapability Shader + OpCapability DeviceGroup + OpExtension "SPV_KHR_device_group" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::DeviceGroup)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 2); + + EXPECT_FALSE(ctx->RemoveCapability(spv::Capability::ShaderClockKHR)); + + EXPECT_TRUE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::DeviceGroup)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 2); +} + +TEST_F(IRContextTest, RemovesMultipleCapabilities) { + const std::string text = R"( + OpCapability Shader + OpCapability DeviceGroup + OpCapability DeviceGroup + OpExtension "SPV_KHR_device_group" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %6 = OpTypeFunction %void + %1 = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd)"; + + std::unique_ptr ctx = + BuildModule(SPV_ENV_UNIVERSAL_1_6, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + EXPECT_TRUE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::DeviceGroup)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 3); + + EXPECT_TRUE(ctx->RemoveCapability(spv::Capability::DeviceGroup)); + + EXPECT_FALSE( + ctx->get_feature_mgr()->HasCapability(spv::Capability::DeviceGroup)); + EXPECT_EQ(std::distance(ctx->module()->capability_begin(), + ctx->module()->capability_end()), + 1); +} + +// If new environments are added, then we must update the list of tests. +static_assert(SPV_ENV_VULKAN_1_4 + 1 == SPV_ENV_MAX); +INSTANTIATE_TEST_SUITE_P( + TestCase, TargetEnvCompareTest, + ::testing::Values( + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_5}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_5}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_6}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_0}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_5}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1}, + TargetEnvCompareTestData{SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_5}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_UNIVERSAL_1_6}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_0}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_1}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_2}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_3}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_4}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_5}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_6}, + TargetEnvCompareTestData{SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_3})); + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/ir_loader_test.cpp b/third_party/spirv-tools/test/opt/ir_loader_test.cpp index 45104f4714..769a25dd6c 100644 --- a/third_party/spirv-tools/test/opt/ir_loader_test.cpp +++ b/third_party/spirv-tools/test/opt/ir_loader_test.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp b/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp index 07fb537c2e..b35f3a3f86 100644 --- a/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp +++ b/third_party/spirv-tools/test/opt/local_access_chain_convert_test.cpp @@ -1348,6 +1348,56 @@ OpFunctionEnd true); } +TEST_F(LocalAccessChainConvertTest, VkMemoryModelTest) { + const std::string text = + R"( +; CHECK: OpCapability Shader +; CHECK: OpCapability VulkanMemoryModel +; CHECK: OpExtension "SPV_KHR_vulkan_memory_model" + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpName %main "main" + OpName %a "a" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_float = OpTypePointer Function %float + %float_1 = OpConstant %float 1 +; CHECK: OpFunction +; CHECK-NEXT: OpLabel +; CHECK-NEXT: [[a:%\w+]] = OpVariable +; Make sure the access chains were removed. +; CHECK: [[ld:%\w+]] = OpLoad {{%\w+}} [[a]] +; CHECK: [[ex:%\w+]] = OpCompositeExtract {{%\w+}} [[ld]] 0 +; CHECK: [[ld2:%\w+]] = OpLoad {{%\w+}} [[a]] +; CHECK: [[v:%\w+]] = OpCompositeInsert {{%\w+}} [[ex]] [[ld2]] 0 +; CHECK: OpStore [[a]] [[v]] + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_v4float Function + %13 = OpAccessChain %_ptr_Function_float %a %uint_0 + %14 = OpLoad %float %13 + %17 = OpAccessChain %_ptr_Function_float %a %uint_0 + OpStore %17 %14 + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // Assorted vector and matrix types diff --git a/third_party/spirv-tools/test/opt/local_redundancy_elimination_test.cpp b/third_party/spirv-tools/test/opt/local_redundancy_elimination_test.cpp index 291e1bc258..01f766615a 100644 --- a/third_party/spirv-tools/test/opt/local_redundancy_elimination_test.cpp +++ b/third_party/spirv-tools/test/opt/local_redundancy_elimination_test.cpp @@ -15,9 +15,7 @@ #include #include "gmock/gmock.h" -#include "source/opt/build_module.h" #include "source/opt/value_number_table.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/local_single_block_elim.cpp b/third_party/spirv-tools/test/opt/local_single_block_elim.cpp index 28b8a07d1f..7d19c227f6 100644 --- a/third_party/spirv-tools/test/opt/local_single_block_elim.cpp +++ b/third_party/spirv-tools/test/opt/local_single_block_elim.cpp @@ -1502,6 +1502,49 @@ TEST_F(LocalSingleBlockLoadStoreElimTest, DebugValueTest) { SinglePassRunAndMatch(text, false); } +TEST_F(LocalSingleBlockLoadStoreElimTest, VkMemoryModelTest) { + const std::string text = + R"( +; CHECK: OpCapability Shader +; CHECK: OpCapability VulkanMemoryModel +; CHECK: OpExtension "SPV_KHR_vulkan_memory_model" + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %bool = OpTypeBool + %false = OpConstantFalse %bool +; CHECK: OpFunction +; CHECK-NEXT: OpLabel +; CHECK-NEXT: [[a:%\w+]] = OpVariable +; CHECK-NEXT: [[b:%\w+]] = OpVariable +; CHECK: OpStore [[a]] [[v:%\w+]] +; CHECK-NOT: OpLoad %int [[a]] +; CHECK: OpStore [[b]] [[v]] + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_int Function + %b = OpVariable %_ptr_Function_int Function + OpStore %a %int_0 + %16 = OpLoad %int %a + OpStore %b %16 + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // Other target variable types diff --git a/third_party/spirv-tools/test/opt/local_single_store_elim_test.cpp b/third_party/spirv-tools/test/opt/local_single_store_elim_test.cpp index 8f43a11d41..8fd5c9d2f1 100644 --- a/third_party/spirv-tools/test/opt/local_single_store_elim_test.cpp +++ b/third_party/spirv-tools/test/opt/local_single_store_elim_test.cpp @@ -24,6 +24,56 @@ namespace { using LocalSingleStoreElimTest = PassTest<::testing::Test>; +TEST_F(LocalSingleStoreElimTest, DoSomethingWithExtensions) { + const std::string capabilities_and_extensions = + R"(OpCapability Shader +OpExtension "SPV_EXT_fragment_shader_interlock" +OpExtension "SPV_NV_compute_shader_derivatives" +OpExtension "SPV_KHR_ray_query" +OpExtension "SPV_NV_shader_subgroup_partitioned" +OpExtension "SPV_KHR_ray_tracing" +OpExtension "SPV_EXT_descriptor_indexing" +)"; + + const std::string before = capabilities_and_extensions + + R"(%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main" +OpExecutionMode %2 OriginUpperLeft +OpSource GLSL 140 +%void = OpTypeVoid +%4 = OpTypeFunction %void +%float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%float_0 = OpConstant %float 0 +%2 = OpFunction %void None %4 +%8 = OpLabel +%9 = OpVariable %_ptr_Function_float Function +OpStore %9 %float_0 +%10 = OpLoad %float %9 +OpReturn +OpFunctionEnd +)"; + const std::string after = capabilities_and_extensions + + R"(%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %2 "main" +OpExecutionMode %2 OriginUpperLeft +OpSource GLSL 140 +%void = OpTypeVoid +%4 = OpTypeFunction %void +%float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%float_0 = OpConstant %float 0 +%2 = OpFunction %void None %4 +%8 = OpLabel +%9 = OpVariable %_ptr_Function_float Function +OpStore %9 %float_0 +OpReturn +OpFunctionEnd +)"; + SinglePassRunAndCheck(before, after, true, true); +} TEST_F(LocalSingleStoreElimTest, PositiveAndNegative) { // Single store to v is optimized. Multiple store to // f is not optimized. @@ -1750,6 +1800,58 @@ TEST_F(LocalSingleStoreElimTest, DebugValuesForAllLocalsAndParams) { SinglePassRunAndMatch(text, false); } +TEST_F(LocalSingleStoreElimTest, VkMemoryModelTest) { + const std::string text = + R"( +; CHECK: OpCapability Shader +; CHECK: OpCapability VulkanMemoryModel +; CHECK: OpExtension "SPV_KHR_vulkan_memory_model" + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %bool = OpTypeBool + %false = OpConstantFalse %bool +; CHECK: OpFunction +; CHECK-NEXT: OpLabel +; CHECK-NEXT: [[a:%\w+]] = OpVariable +; CHECK-NEXT: [[b:%\w+]] = OpVariable +; CHECK: OpStore [[a]] [[v:%\w+]] +; CHECK: OpStore [[b]] +; Make sure the load was removed. +; CHECK: OpLabel +; CHECK-NOT: OpLoad %int [[a]] +; CHECK: OpStore [[b]] [[v]] + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_int Function + %b = OpVariable %_ptr_Function_int Function + OpStore %a %int_0 + OpStore %b %int_1 + OpSelectionMerge %15 None + OpBranchConditional %false %14 %15 + %14 = OpLabel + %16 = OpLoad %int %a + OpStore %b %16 + OpBranch %15 + %15 = OpLabel + OpReturn + OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, false); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // Other types diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/CMakeLists.txt b/third_party/spirv-tools/test/opt/loop_optimizations/CMakeLists.txt index e3620787db..6e20f72fe1 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/CMakeLists.txt +++ b/third_party/spirv-tools/test/opt/loop_optimizations/CMakeLists.txt @@ -21,6 +21,7 @@ add_spvtools_unittest(TARGET opt_loops fusion_illegal.cpp fusion_legal.cpp fusion_pass.cpp + hoist_access_chains.cpp hoist_all_loop_types.cpp hoist_double_nested_loops.cpp hoist_from_independent_loops.cpp diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis.cpp index 42d9acba1b..40520f574f 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis.cpp @@ -14,17 +14,11 @@ #include #include -#include -#include #include #include -#include "gmock/gmock.h" -#include "source/opt/iterator.h" #include "source/opt/loop_dependence.h" #include "source/opt/loop_descriptor.h" -#include "source/opt/pass.h" -#include "source/opt/tree_iterator.h" #include "test/opt//assembly_builder.h" #include "test/opt//function_utils.h" #include "test/opt//pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis_helpers.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis_helpers.cpp index aabf478447..620619983a 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis_helpers.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/dependence_analysis_helpers.cpp @@ -13,17 +13,11 @@ // limitations under the License. #include -#include -#include #include -#include "gmock/gmock.h" -#include "source/opt/iterator.h" #include "source/opt/loop_dependence.h" #include "source/opt/loop_descriptor.h" -#include "source/opt/pass.h" #include "source/opt/scalar_analysis.h" -#include "source/opt/tree_iterator.h" #include "test/opt/assembly_builder.h" #include "test/opt/function_utils.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_compatibility.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_compatibility.cpp index cda8576c5d..9acfe8fc9e 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_compatibility.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_compatibility.cpp @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_illegal.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_illegal.cpp index 26d54457d2..bff416b676 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_illegal.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_illegal.cpp @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_legal.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_legal.cpp index 56b0b76f4c..ef7daeeaeb 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/fusion_legal.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/fusion_legal.cpp @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include #include -#include #include #include "effcee/effcee.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/hoist_access_chains.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/hoist_access_chains.cpp new file mode 100644 index 0000000000..0c688b3176 --- /dev/null +++ b/third_party/spirv-tools/test/opt/loop_optimizations/hoist_access_chains.cpp @@ -0,0 +1,157 @@ +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "source/opt/licm_pass.h" +#include "test/opt/pass_fixture.h" + +namespace spvtools { +namespace opt { +namespace { + +using PassClassTest = PassTest<::testing::Test>; + +/* + Tests for the LICM pass to check it handles access chains correctly + + Generated from the following GLSL fragment shader +--eliminate-local-multi-store has also been run on the spv binary +#version 460 +void main() { + for (uint i = 0; i < 123u; ++i) { + vec2 do_not_hoist_store = vec2(0.0f); + float do_not_hoist_access_chain_load = do_not_hoist_store.x; + } +} +*/ + +TEST_F(PassClassTest, HoistAccessChains) { + const std::string before_hoist = R"(OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpSource GLSL 460 +OpName %main "main" +OpName %i "i" +OpName %do_not_hoist_store "do_not_hoist_store" +OpName %do_not_hoist_access_chain_load "do_not_hoist_access_chain_load" +%void = OpTypeVoid +%7 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_0 = OpConstant %uint 0 +%uint_123 = OpConstant %uint 123 +%bool = OpTypeBool +%float = OpTypeFloat 32 +%v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%float_0 = OpConstant %float 0 +%17 = OpConstantComposite %v2float %float_0 %float_0 +%_ptr_Function_float = OpTypePointer Function %float +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%main = OpFunction %void None %7 +%21 = OpLabel +%i = OpVariable %_ptr_Function_uint Function +%do_not_hoist_store = OpVariable %_ptr_Function_v2float Function +%do_not_hoist_access_chain_load = OpVariable %_ptr_Function_float Function +OpStore %i %uint_0 +OpBranch %22 +%22 = OpLabel +OpLoopMerge %23 %24 None +OpBranch %25 +%25 = OpLabel +%26 = OpLoad %uint %i +%27 = OpULessThan %bool %26 %uint_123 +OpBranchConditional %27 %28 %23 +%28 = OpLabel +OpStore %do_not_hoist_store %17 +%29 = OpAccessChain %_ptr_Function_float %do_not_hoist_store %uint_0 +%30 = OpLoad %float %29 +OpStore %do_not_hoist_access_chain_load %30 +OpBranch %24 +%24 = OpLabel +%31 = OpLoad %uint %i +%32 = OpIAdd %uint %31 %int_1 +OpStore %i %32 +OpBranch %22 +%23 = OpLabel +OpReturn +OpFunctionEnd +)"; + + const std::string after_hoist = R"(OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpSource GLSL 460 +OpName %main "main" +OpName %i "i" +OpName %do_not_hoist_store "do_not_hoist_store" +OpName %do_not_hoist_access_chain_load "do_not_hoist_access_chain_load" +%void = OpTypeVoid +%7 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_0 = OpConstant %uint 0 +%uint_123 = OpConstant %uint 123 +%bool = OpTypeBool +%float = OpTypeFloat 32 +%v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%float_0 = OpConstant %float 0 +%17 = OpConstantComposite %v2float %float_0 %float_0 +%_ptr_Function_float = OpTypePointer Function %float +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%main = OpFunction %void None %7 +%21 = OpLabel +%i = OpVariable %_ptr_Function_uint Function +%do_not_hoist_store = OpVariable %_ptr_Function_v2float Function +%do_not_hoist_access_chain_load = OpVariable %_ptr_Function_float Function +OpStore %i %uint_0 +%29 = OpAccessChain %_ptr_Function_float %do_not_hoist_store %uint_0 +OpBranch %22 +%22 = OpLabel +OpLoopMerge %23 %24 None +OpBranch %25 +%25 = OpLabel +%26 = OpLoad %uint %i +%27 = OpULessThan %bool %26 %uint_123 +OpBranchConditional %27 %28 %23 +%28 = OpLabel +OpStore %do_not_hoist_store %17 +%30 = OpLoad %float %29 +OpStore %do_not_hoist_access_chain_load %30 +OpBranch %24 +%24 = OpLabel +%31 = OpLoad %uint %i +%32 = OpIAdd %uint %31 %int_1 +OpStore %i %32 +OpBranch %22 +%23 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndCheck(before_hoist, after_hoist, true); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/lcssa.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/lcssa.cpp index ace6ce1968..32c2f7235a 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/lcssa.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/lcssa.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "effcee/effcee.h" @@ -21,7 +20,6 @@ #include "source/opt/build_module.h" #include "source/opt/loop_descriptor.h" #include "source/opt/loop_utils.h" -#include "source/opt/pass.h" #include "test/opt//assembly_builder.h" #include "test/opt/function_utils.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp index b3f4f440cd..3dd0b93058 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/loop_descriptions.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp index bc3ec39bdf..41e40c3b12 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/loop_fission.cpp @@ -12,15 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/loop_fission.h" + #include -#include #include #include "gmock/gmock.h" -#include "source/opt/loop_fission.h" -#include "source/opt/loop_unroller.h" #include "source/opt/loop_utils.h" -#include "source/opt/pass.h" #include "test/opt/assembly_builder.h" #include "test/opt/function_utils.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/peeling.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/peeling.cpp index 4ff7a5a2e9..34c33074f4 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/peeling.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/peeling.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "effcee/effcee.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/peeling_pass.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/peeling_pass.cpp index 1b5a12d244..ad7fcdc3c6 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/peeling_pass.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/peeling_pass.cpp @@ -17,7 +17,6 @@ #include #include "gmock/gmock.h" -#include "source/opt/ir_builder.h" #include "source/opt/loop_descriptor.h" #include "source/opt/loop_peeling.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_assumptions.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_assumptions.cpp index 159e4a1430..81657a50b3 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_assumptions.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_assumptions.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" diff --git a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp index 299fb2d5c3..b4fd3eaa4d 100644 --- a/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp +++ b/third_party/spirv-tools/test/opt/loop_optimizations/unroll_simple.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "gmock/gmock.h" @@ -511,36 +510,36 @@ OpBranch %24 %24 = OpLabel %35 = OpPhi %8 %10 %23 %34 %26 %s1 = OpExtInst %6 %ext DebugScope %dbg_main -%d10 = OpExtInst %6 %ext DebugLine %file_name %uint_1 %uint_1 %uint_0 %uint_0 +%d10 = OpExtInst %6 %ext DebugLine %src %uint_1 %uint_1 %uint_0 %uint_0 %value0 = OpExtInst %6 %ext DebugValue %dbg_f %35 %null_expr OpLoopMerge %25 %26 Unroll OpBranch %27 %27 = OpLabel %s2 = OpExtInst %6 %ext DebugScope %dbg_main -%d1 = OpExtInst %6 %ext DebugLine %file_name %uint_1 %uint_1 %uint_1 %uint_1 +%d1 = OpExtInst %6 %ext DebugLine %src %uint_1 %uint_1 %uint_1 %uint_1 %29 = OpSLessThan %12 %35 %11 -%d2 = OpExtInst %6 %ext DebugLine %file_name %uint_2 %uint_2 %uint_0 %uint_0 +%d2 = OpExtInst %6 %ext DebugLine %src %uint_2 %uint_2 %uint_0 %uint_0 OpBranchConditional %29 %30 %25 %30 = OpLabel %s3 = OpExtInst %6 %ext DebugScope %bb %decl0 = OpExtInst %6 %ext DebugDeclare %dbg_f %5 %null_expr %decl1 = OpExtInst %6 %ext DebugValue %dbg_i %5 %deref_expr -%d3 = OpExtInst %6 %ext DebugLine %file_name %uint_3 %uint_3 %uint_0 %uint_0 +%d3 = OpExtInst %6 %ext DebugLine %src %uint_3 %uint_3 %uint_0 %uint_0 %32 = OpAccessChain %19 %5 %35 -%d4 = OpExtInst %6 %ext DebugLine %file_name %uint_4 %uint_4 %uint_0 %uint_0 +%d4 = OpExtInst %6 %ext DebugLine %src %uint_4 %uint_4 %uint_0 %uint_0 OpStore %32 %18 -%d5 = OpExtInst %6 %ext DebugLine %file_name %uint_5 %uint_5 %uint_0 %uint_0 +%d5 = OpExtInst %6 %ext DebugLine %src %uint_5 %uint_5 %uint_0 %uint_0 OpBranch %26 %26 = OpLabel %s4 = OpExtInst %6 %ext DebugScope %dbg_main -%d6 = OpExtInst %6 %ext DebugLine %file_name %uint_6 %uint_6 %uint_0 %uint_0 +%d6 = OpExtInst %6 %ext DebugLine %src %uint_6 %uint_6 %uint_0 %uint_0 %34 = OpIAdd %8 %35 %20 %value1 = OpExtInst %6 %ext DebugValue %dbg_f %34 %null_expr -%d7 = OpExtInst %6 %ext DebugLine %file_name %uint_7 %uint_7 %uint_0 %uint_0 +%d7 = OpExtInst %6 %ext DebugLine %src %uint_7 %uint_7 %uint_0 %uint_0 OpBranch %24 %25 = OpLabel %s5 = OpExtInst %6 %ext DebugScope %dbg_main -%d8 = OpExtInst %6 %ext DebugLine %file_name %uint_8 %uint_8 %uint_0 %uint_0 +%d8 = OpExtInst %6 %ext DebugLine %src %uint_8 %uint_8 %uint_0 %uint_0 OpReturn OpFunctionEnd)"; diff --git a/third_party/spirv-tools/test/opt/modify_maximal_reconvergence_test.cpp b/third_party/spirv-tools/test/opt/modify_maximal_reconvergence_test.cpp new file mode 100644 index 0000000000..bef9237cf3 --- /dev/null +++ b/third_party/spirv-tools/test/opt/modify_maximal_reconvergence_test.cpp @@ -0,0 +1,312 @@ +// Copyright (c) 2024 Google LLC +// +// 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 "assembly_builder.h" +#include "pass_fixture.h" +#include "pass_utils.h" + +namespace { + +using namespace spvtools; + +using ModifyMaximalReconvergenceTest = opt::PassTest<::testing::Test>; + +TEST_F(ModifyMaximalReconvergenceTest, AddNoEntryPoint) { + const std::string text = R"( +; CHECK-NOT: OpExtension +OpCapability Kernel +OpCapability Linkage +OpMemoryModel Logical OpenCL +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddSingleEntryPoint) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %main MaximallyReconvergesKHR + +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %main "main" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddExtensionExists) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %main MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %main "main" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddExecutionModeExists) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %main LocalSize 1 1 1 +; CHECK-NEXT: OpExecutionMode %main MaximallyReconvergesKHR +; CHECK-NOT: OpExecutionMode %main MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +OpName %main "main" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddTwoEntryPoints) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %comp MaximallyReconvergesKHR +; CHECK: OpExecutionMode %frag MaximallyReconvergesKHR + +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %comp "main" +OpEntryPoint Fragment %frag "main" +OpExecutionMode %comp LocalSize 1 1 1 +OpExecutionMode %frag OriginUpperLeft +OpName %comp "comp" +OpName %frag "frag" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%comp = OpFunction %void None %void_fn +%entry1 = OpLabel +OpReturn +OpFunctionEnd +%frag = OpFunction %void None %void_fn +%entry2 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddTwoEntryPointsOneFunc) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %comp MaximallyReconvergesKHR +; CHECK-NOT: OpExecutionMode %comp MaximallyReconvergesKHR + +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %comp "main1" +OpEntryPoint GLCompute %comp "main2" +OpExecutionMode %comp LocalSize 1 1 1 +OpName %comp "comp" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%comp = OpFunction %void None %void_fn +%entry1 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, AddTwoEntryPointsOneExecutionMode) { + const std::string text = R"( +; CHECK: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %comp MaximallyReconvergesKHR +; CHECK-NOT: OpExecutionMode %comp MaximallyReconvergesKHR +; CHECK: OpExecutionMode %frag MaximallyReconvergesKHR +; CHECK-NOT: OpExecutionMode %comp MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %comp "main" +OpEntryPoint Fragment %frag "main" +OpExecutionMode %comp LocalSize 1 1 1 +OpExecutionMode %frag OriginUpperLeft +OpExecutionMode %comp MaximallyReconvergesKHR +OpName %comp "comp" +OpName %frag "frag" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%comp = OpFunction %void None %void_fn +%entry1 = OpLabel +OpReturn +OpFunctionEnd +%frag = OpFunction %void None %void_fn +%entry2 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, true); +} + +TEST_F(ModifyMaximalReconvergenceTest, RemoveNoEntryPoint) { + const std::string text = R"(OpCapability Kernel +OpCapability Linkage +OpMemoryModel Logical OpenCL +)"; + + SinglePassRunAndCheck(text, text, false, + true, false); +} + +TEST_F(ModifyMaximalReconvergenceTest, RemoveOnlyExtension) { + const std::string text = R"( +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %main LocalSize 1 1 1 + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %main "main" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, false); +} + +TEST_F(ModifyMaximalReconvergenceTest, RemoveSingleEntryPoint) { + const std::string text = R"( +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %main LocalSize 1 1 1 +; CHECK-NOT: OpExecutionMode %main MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +OpName %main "main" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, false); +} + +TEST_F(ModifyMaximalReconvergenceTest, RemoveTwoEntryPointsOneExecutionMode) { + const std::string text = R"( +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %comp LocalSize 1 1 1 +; CHECK-NEXT: OpExecutionMode %frag OriginUpperLeft +; CHECK-NOT: OpExecutionMode %comp MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %comp "main" +OpEntryPoint Fragment %frag "main" +OpExecutionMode %comp LocalSize 1 1 1 +OpExecutionMode %comp MaximallyReconvergesKHR +OpExecutionMode %frag OriginUpperLeft +OpName %comp "comp" +OpName %frag "frag" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%comp = OpFunction %void None %void_fn +%entry1 = OpLabel +OpReturn +OpFunctionEnd +%frag = OpFunction %void None %void_fn +%entry2 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, false); +} + +TEST_F(ModifyMaximalReconvergenceTest, RemoveTwoEntryPoints) { + const std::string text = R"( +; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence" +; CHECK: OpExecutionMode %comp LocalSize 1 1 1 +; CHECK-NEXT: OpExecutionMode %frag OriginUpperLeft +; CHECK-NOT: OpExecutionMode {{%\w}} MaximallyReconvergesKHR + +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %comp "main" +OpEntryPoint Fragment %frag "main" +OpExecutionMode %comp LocalSize 1 1 1 +OpExecutionMode %comp MaximallyReconvergesKHR +OpExecutionMode %frag OriginUpperLeft +OpExecutionMode %frag MaximallyReconvergesKHR +OpName %comp "comp" +OpName %frag "frag" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%comp = OpFunction %void None %void_fn +%entry1 = OpLabel +OpReturn +OpFunctionEnd +%frag = OpFunction %void None %void_fn +%entry2 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch(text, true, false); +} + +} // namespace diff --git a/third_party/spirv-tools/test/opt/module_test.cpp b/third_party/spirv-tools/test/opt/module_test.cpp index 33dc05f8a1..a93a50b08e 100644 --- a/third_party/spirv-tools/test/opt/module_test.cpp +++ b/third_party/spirv-tools/test/opt/module_test.cpp @@ -12,16 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/module.h" + #include -#include -#include #include #include "gmock/gmock.h" #include "gtest/gtest.h" #include "source/opt/build_module.h" -#include "source/opt/module.h" -#include "source/opt/pass.h" #include "spirv-tools/libspirv.hpp" #include "test/opt/module_utils.h" diff --git a/third_party/spirv-tools/test/opt/module_utils.h b/third_party/spirv-tools/test/opt/module_utils.h index 007f132c25..6859188f02 100644 --- a/third_party/spirv-tools/test/opt/module_utils.h +++ b/third_party/spirv-tools/test/opt/module_utils.h @@ -17,6 +17,7 @@ #include #include "source/opt/module.h" +#include "gtest/gtest.h" namespace spvtest { diff --git a/third_party/spirv-tools/test/opt/opextinst_forward_ref_fixup_pass_test.cpp b/third_party/spirv-tools/test/opt/opextinst_forward_ref_fixup_pass_test.cpp new file mode 100644 index 0000000000..b9ac5d27a8 --- /dev/null +++ b/third_party/spirv-tools/test/opt/opextinst_forward_ref_fixup_pass_test.cpp @@ -0,0 +1,338 @@ +// Copyright (c) 2024 Google LLC +// +// 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-tools/optimizer.hpp" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using OpExtInstForwardRefFixupPassTest = PassTest<::testing::Test>; + +TEST_F(OpExtInstForwardRefFixupPassTest, NoChangeWithougExtendedInstructions) { + const std::string kTest = R"( +; CHECK-NOT: SomeOpcode + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(OpExtInstForwardRefFixupPassTest, NoForwardRef_NoChange) { + const std::string kTest = R"(OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%3 = OpString "/usr/local/google/home/nathangauer/projects/DirectXShaderCompiler/repro.hlsl" +%4 = OpString "// RUN: %dxc -T cs_6_0 %s -E main -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source | FileCheck %s + +[numthreads(1, 1, 1)] +void main() { +} +" +%5 = OpString "main" +%6 = OpString "" +%7 = OpString "3f3d3740" +%8 = OpString " -E main -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source -Qembed_debug" +OpName %main "main" +%void = OpTypeVoid +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%15 = OpTypeFunction %void +%16 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void +%17 = OpExtInst %void %1 DebugSource %3 %4 +%18 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %17 %uint_5 +%19 = OpExtInst %void %1 DebugFunction %5 %16 %17 %uint_4 %uint_1 %18 %6 %uint_3 %uint_4 +%20 = OpExtInst %void %1 DebugEntryPoint %19 %18 %7 %8 +%main = OpFunction %void None %15 +%21 = OpLabel +%22 = OpExtInst %void %1 DebugFunctionDefinition %19 %main +%23 = OpExtInst %void %1 DebugLine %17 %uint_5 %uint_5 %uint_1 %uint_1 +OpReturn +OpFunctionEnd +)"; + SinglePassRunAndCheck( + kTest, kTest, /* skip_nop= */ false); +} + +TEST_F(OpExtInstForwardRefFixupPassTest, + NoForwardRef_ReplaceOpExtInstWithForwardWithOpExtInst) { + const std::string kTest = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + OpExtension "SPV_KHR_relaxed_extended_instruction" +; CHECK-NOT: OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + %3 = OpString "/usr/local/google/home/nathangauer/projects/DirectXShaderCompiler/repro.hlsl" + %4 = OpString "// RUN: %dxc -T cs_6_0 %s -E main -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source | FileCheck %s + +[numthreads(1, 1, 1)] +void main() { +} +" + %5 = OpString "main" + %6 = OpString "" + %7 = OpString "3f3d3740" + %8 = OpString " -E main -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source -Qembed_debug" + OpName %main "main" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %20 = OpTypeFunction %void + %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_3 %void + %12 = OpExtInstWithForwardRefsKHR %void %1 DebugSource %3 %4 + %13 = OpExtInstWithForwardRefsKHR %void %1 DebugCompilationUnit %uint_1 %uint_4 %12 %uint_5 + %17 = OpExtInstWithForwardRefsKHR %void %1 DebugFunction %5 %10 %12 %uint_4 %uint_1 %13 %6 %uint_3 %uint_4 + %18 = OpExtInstWithForwardRefsKHR %void %1 DebugEntryPoint %17 %13 %7 %8 +; CHECK-NOT: {{.*}} = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_3 %void +; CHECK-NOT: {{.*}} = OpExtInstWithForwardRefsKHR %void %1 DebugSource {{.*}} {{.*}} +; CHECK-NOT: {{.*}} = OpExtInstWithForwardRefsKHR %void %1 DebugCompilationUnit %uint_1 %uint_4 {{.*}} %uint_5 +; CHECK-NOT: {{.*}} = OpExtInstWithForwardRefsKHR %void %1 DebugFunction {{.*}} {{.*}} {{.*}} %uint_4 %uint_1 {{.*}} {{.*}} %uint_3 %uint_4 +; CHECK-NOT: {{.*}} = OpExtInstWithForwardRefsKHR %void %1 DebugEntryPoint {{.*}} {{.*}} {{.*}} {{.*}} +; CHECK: {{.*}} = OpExtInst %void %1 DebugTypeFunction %uint_3 %void +; CHECK: {{.*}} = OpExtInst %void %1 DebugSource {{.*}} {{.*}} +; CHECK: {{.*}} = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 {{.*}} %uint_5 +; CHECK: {{.*}} = OpExtInst %void %1 DebugFunction {{.*}} {{.*}} {{.*}} %uint_4 %uint_1 {{.*}} {{.*}} %uint_3 %uint_4 +; CHECK: {{.*}} = OpExtInst %void %1 DebugEntryPoint {{.*}} {{.*}} {{.*}} {{.*}} + %main = OpFunction %void None %20 + %21 = OpLabel + %22 = OpExtInst %void %1 DebugFunctionDefinition %17 %main + %23 = OpExtInst %void %1 DebugLine %12 %uint_5 %uint_5 %uint_1 %uint_1 +; CHECK: {{.*}} = OpExtInst %void %1 DebugFunctionDefinition {{.*}} %main +; CHECK: {{.*}} = OpExtInst %void %1 DebugLine {{.*}} %uint_5 %uint_5 %uint_1 %uint_1 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(OpExtInstForwardRefFixupPassTest, ForwardRefs_NoChange) { + const std::string kTest = R"(OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +OpExtension "SPV_KHR_relaxed_extended_instruction" +%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%3 = OpString "/usr/local/google/home/nathangauer/projects/DirectXShaderCompiler/repro.hlsl" +%4 = OpString "// RUN: %dxc -T cs_6_0 %s -E main -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source | FileCheck %s + +class A { + void foo() { + } +}; + +[numthreads(1, 1, 1)] +void main() { + A a; + a.foo(); +} +" +%5 = OpString "A" +%6 = OpString "A.foo" +%7 = OpString "" +%8 = OpString "this" +%9 = OpString "main" +%10 = OpString "a" +%11 = OpString "d59ae9c2" +%12 = OpString " -E main -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source -Vd -Qembed_debug" +OpName %main "main" +OpName %A "A" +%void = OpTypeVoid +%uint = OpTypeInt 32 0 +%uint_1 = OpConstant %uint 1 +%uint_4 = OpConstant %uint 4 +%uint_5 = OpConstant %uint 5 +%uint_0 = OpConstant %uint 0 +%uint_3 = OpConstant %uint 3 +%uint_7 = OpConstant %uint 7 +%uint_288 = OpConstant %uint 288 +%uint_9 = OpConstant %uint 9 +%uint_13 = OpConstant %uint 13 +%uint_10 = OpConstant %uint 10 +%26 = OpTypeFunction %void +%uint_12 = OpConstant %uint 12 +%A = OpTypeStruct +%_ptr_Function_A = OpTypePointer Function %A +%uint_11 = OpConstant %uint 11 +%30 = OpExtInst %void %1 DebugExpression +%31 = OpExtInst %void %1 DebugSource %3 %4 +%32 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %31 %uint_5 +%33 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeComposite %5 %uint_0 %31 %uint_3 %uint_7 %32 %5 %uint_0 %uint_3 %34 +%35 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void %33 +%34 = OpExtInst %void %1 DebugFunction %6 %35 %31 %uint_4 %uint_3 %33 %7 %uint_3 %uint_4 +%36 = OpExtInst %void %1 DebugLocalVariable %8 %33 %31 %uint_4 %uint_3 %34 %uint_288 %uint_1 +%37 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void +%38 = OpExtInst %void %1 DebugFunction %9 %37 %31 %uint_9 %uint_1 %32 %7 %uint_3 %uint_9 +%39 = OpExtInst %void %1 DebugLexicalBlock %31 %uint_9 %uint_13 %38 +%40 = OpExtInst %void %1 DebugLocalVariable %10 %33 %31 %uint_10 %uint_5 %39 %uint_4 +%41 = OpExtInst %void %1 DebugEntryPoint %38 %32 %11 %12 +%42 = OpExtInst %void %1 DebugInlinedAt %uint_11 %39 +%main = OpFunction %void None %26 +%43 = OpLabel +%44 = OpVariable %_ptr_Function_A Function +%45 = OpExtInst %void %1 DebugFunctionDefinition %38 %main +%57 = OpExtInst %void %1 DebugScope %39 +%47 = OpExtInst %void %1 DebugLine %31 %uint_10 %uint_10 %uint_3 %uint_5 +%48 = OpExtInst %void %1 DebugDeclare %40 %44 %30 +%58 = OpExtInst %void %1 DebugScope %34 %42 +%50 = OpExtInst %void %1 DebugLine %31 %uint_4 %uint_5 %uint_3 %uint_3 +%51 = OpExtInst %void %1 DebugDeclare %36 %44 %30 +%59 = OpExtInst %void %1 DebugNoScope +%53 = OpExtInst %void %1 DebugLine %31 %uint_12 %uint_12 %uint_1 %uint_1 +OpReturn +OpFunctionEnd +)"; + SinglePassRunAndCheck( + kTest, kTest, /* skip_nop= */ false); +} + +TEST_F(OpExtInstForwardRefFixupPassTest, + ForwardRefs_ReplaceOpExtInstWithOpExtInstWithForwardRefs) { + const std::string kTest = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" +; CHECK: OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + %3 = OpString "/usr/local/google/home/nathangauer/projects/DirectXShaderCompiler/repro.hlsl" + %4 = OpString "// RUN: %dxc -T cs_6_0 %s -E main -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source | FileCheck %s + +class A { + void foo() { + } +}; + +[numthreads(1, 1, 1)] +void main() { + A a; + a.foo(); +} +" + %5 = OpString "A" + %6 = OpString "A.foo" + %7 = OpString "" + %8 = OpString "this" + %9 = OpString "main" + %10 = OpString "a" + %11 = OpString "d59ae9c2" + %12 = OpString " -E main -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -fspv-debug=vulkan-with-source -Vd -Qembed_debug" + OpName %main "main" + OpName %A "A" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_7 = OpConstant %uint 7 + %uint_288 = OpConstant %uint 288 + %uint_9 = OpConstant %uint 9 + %uint_13 = OpConstant %uint 13 + %uint_10 = OpConstant %uint 10 + %40 = OpTypeFunction %void + %uint_12 = OpConstant %uint 12 + %A = OpTypeStruct + %_ptr_Function_A = OpTypePointer Function %A + %uint_11 = OpConstant %uint 11 + %15 = OpExtInst %void %1 DebugExpression + %16 = OpExtInst %void %1 DebugSource %3 %4 + %17 = OpExtInst %void %1 DebugCompilationUnit %uint_1 %uint_4 %16 %uint_5 + %21 = OpExtInst %void %1 DebugTypeComposite %5 %uint_0 %16 %uint_3 %uint_7 %17 %5 %uint_0 %uint_3 %25 + %26 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void %21 + %25 = OpExtInst %void %1 DebugFunction %6 %26 %16 %uint_4 %uint_3 %21 %7 %uint_3 %uint_4 + %27 = OpExtInst %void %1 DebugLocalVariable %8 %21 %16 %uint_4 %uint_3 %25 %uint_288 %uint_1 + %29 = OpExtInst %void %1 DebugTypeFunction %uint_3 %void + %30 = OpExtInst %void %1 DebugFunction %9 %29 %16 %uint_9 %uint_1 %17 %7 %uint_3 %uint_9 + %32 = OpExtInst %void %1 DebugLexicalBlock %16 %uint_9 %uint_13 %30 + %34 = OpExtInst %void %1 DebugLocalVariable %10 %21 %16 %uint_10 %uint_5 %32 %uint_4 + %36 = OpExtInst %void %1 DebugEntryPoint %30 %17 %11 %12 + %37 = OpExtInst %void %1 DebugInlinedAt %uint_11 %32 +; CHECK: {{.*}} = OpExtInst %void %1 DebugExpression +; CHECK: {{.*}} = OpExtInst %void %1 DebugSource +; CHECK: {{.*}} = OpExtInst %void %1 DebugCompilationUnit +; CHECK: {{.*}} = OpExtInstWithForwardRefsKHR %void {{.*}} DebugTypeComposite +; CHECK-NOT: {{.*}} = OpExtInst %void {{.*}} DebugTypeComposite +; CHECK: {{.*}} = OpExtInst %void %1 DebugTypeFunction +; CHECK: {{.*}} = OpExtInst %void %1 DebugFunction +; CHECK: {{.*}} = OpExtInst %void %1 DebugLocalVariable +; CHECK: {{.*}} = OpExtInst %void %1 DebugTypeFunction +; CHECK: {{.*}} = OpExtInst %void %1 DebugFunction +; CHECK: {{.*}} = OpExtInst %void %1 DebugLexicalBlock +; CHECK: {{.*}} = OpExtInst %void %1 DebugLocalVariable +; CHECK: {{.*}} = OpExtInst %void %1 DebugEntryPoint +; CHECK: {{.*}} = OpExtInst %void %1 DebugInlinedAt + %main = OpFunction %void None %40 + %43 = OpLabel + %44 = OpVariable %_ptr_Function_A Function + %45 = OpExtInst %void %1 DebugFunctionDefinition %30 %main + %51 = OpExtInst %void %1 DebugScope %32 + %46 = OpExtInst %void %1 DebugLine %16 %uint_10 %uint_10 %uint_3 %uint_5 + %47 = OpExtInst %void %1 DebugDeclare %34 %44 %15 + %52 = OpExtInst %void %1 DebugScope %25 %37 + %48 = OpExtInst %void %1 DebugLine %16 %uint_4 %uint_5 %uint_3 %uint_3 + %49 = OpExtInst %void %1 DebugDeclare %27 %44 %15 + %53 = OpExtInst %void %1 DebugNoScope + %50 = OpExtInst %void %1 DebugLine %16 %uint_12 %uint_12 %uint_1 %uint_1 +; CHECK: {{.*}} = OpExtInst %void %1 DebugFunctionDefinition +; CHECK: {{.*}} = OpExtInst %void %1 DebugScope +; CHECK: {{.*}} = OpExtInst %void %1 DebugLine +; CHECK: {{.*}} = OpExtInst %void %1 DebugDeclare +; CHECK: {{.*}} = OpExtInst %void %1 DebugScope +; CHECK: {{.*}} = OpExtInst %void %1 DebugLine +; CHECK: {{.*}} = OpExtInst %void %1 DebugDeclare +; CHECK: {{.*}} = OpExtInst %void %1 DebugNoScope +; CHECK: {{.*}} = OpExtInst %void %1 DebugLine + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/pass_merge_return_test.cpp b/third_party/spirv-tools/test/opt/pass_merge_return_test.cpp index 04bd5d9b9c..494f2e95f0 100644 --- a/third_party/spirv-tools/test/opt/pass_merge_return_test.cpp +++ b/third_party/spirv-tools/test/opt/pass_merge_return_test.cpp @@ -14,9 +14,7 @@ #include -#include "gmock/gmock.h" #include "spirv-tools/libspirv.hpp" -#include "spirv-tools/optimizer.hpp" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/pass_remove_duplicates_test.cpp b/third_party/spirv-tools/test/opt/pass_remove_duplicates_test.cpp index ac87db17fe..131a6b4bc4 100644 --- a/third_party/spirv-tools/test/opt/pass_remove_duplicates_test.cpp +++ b/third_party/spirv-tools/test/opt/pass_remove_duplicates_test.cpp @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include -#include "gmock/gmock.h" #include "source/opt/build_module.h" #include "source/opt/ir_context.h" #include "source/opt/pass_manager.h" diff --git a/third_party/spirv-tools/test/opt/private_to_local_test.cpp b/third_party/spirv-tools/test/opt/private_to_local_test.cpp index 8b5ec59e22..f7c37c9111 100644 --- a/third_party/spirv-tools/test/opt/private_to_local_test.cpp +++ b/third_party/spirv-tools/test/opt/private_to_local_test.cpp @@ -15,7 +15,6 @@ #include #include "gmock/gmock.h" -#include "source/opt/build_module.h" #include "source/opt/value_number_table.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/propagator_test.cpp b/third_party/spirv-tools/test/opt/propagator_test.cpp index 76211a58f0..0a98cfa8f4 100644 --- a/third_party/spirv-tools/test/opt/propagator_test.cpp +++ b/third_party/spirv-tools/test/opt/propagator_test.cpp @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/propagator.h" + #include #include -#include #include #include "gmock/gmock.h" @@ -22,8 +23,6 @@ #include "source/opt/build_module.h" #include "source/opt/cfg.h" #include "source/opt/ir_context.h" -#include "source/opt/pass.h" -#include "source/opt/propagator.h" namespace spvtools { namespace opt { @@ -185,7 +184,7 @@ TEST_F(PropagatorTest, PropagateThroughPhis) { } } else if (instr->opcode() == spv::Op::OpPhi) { phi_instr = instr; - SSAPropagator::PropStatus retval; + SSAPropagator::PropStatus retval = SSAPropagator::kNotInteresting; for (uint32_t i = 2; i < instr->NumOperands(); i += 2) { uint32_t phi_arg_id = instr->GetSingleWordOperand(i); auto it = values_.find(phi_arg_id); diff --git a/third_party/spirv-tools/test/opt/redundancy_elimination_test.cpp b/third_party/spirv-tools/test/opt/redundancy_elimination_test.cpp index 28eda73eff..eb78497b89 100644 --- a/third_party/spirv-tools/test/opt/redundancy_elimination_test.cpp +++ b/third_party/spirv-tools/test/opt/redundancy_elimination_test.cpp @@ -15,8 +15,6 @@ #include #include "gmock/gmock.h" -#include "source/opt/build_module.h" -#include "source/opt/value_number_table.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/register_liveness.cpp b/third_party/spirv-tools/test/opt/register_liveness.cpp index 7cb210f1e5..3870e2f995 100644 --- a/third_party/spirv-tools/test/opt/register_liveness.cpp +++ b/third_party/spirv-tools/test/opt/register_liveness.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include diff --git a/third_party/spirv-tools/test/opt/relax_float_ops_test.cpp b/third_party/spirv-tools/test/opt/relax_float_ops_test.cpp index b9cb0de097..e486df3001 100644 --- a/third_party/spirv-tools/test/opt/relax_float_ops_test.cpp +++ b/third_party/spirv-tools/test/opt/relax_float_ops_test.cpp @@ -18,7 +18,6 @@ #include #include -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/remove_unused_interface_variables_test.cpp b/third_party/spirv-tools/test/opt/remove_unused_interface_variables_test.cpp index ddf027f1ba..8bb40f7bf9 100644 --- a/third_party/spirv-tools/test/opt/remove_unused_interface_variables_test.cpp +++ b/third_party/spirv-tools/test/opt/remove_unused_interface_variables_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gmock/gmock.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp b/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp index 9ab9eb1148..6018be23e3 100644 --- a/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp +++ b/third_party/spirv-tools/test/opt/replace_desc_array_access_using_var_index_test.cpp @@ -14,8 +14,6 @@ #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/replace_invalid_opc_test.cpp b/third_party/spirv-tools/test/opt/replace_invalid_opc_test.cpp index 1be904b4e4..aee0d6e2f2 100644 --- a/third_party/spirv-tools/test/opt/replace_invalid_opc_test.cpp +++ b/third_party/spirv-tools/test/opt/replace_invalid_opc_test.cpp @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include -#include "gmock/gmock.h" #include "pass_utils.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" @@ -404,6 +402,7 @@ TEST_F(ReplaceInvalidOpcodeTest, BarrierDontReplace) { OpReturn OpFunctionEnd)"; + SetTargetEnv(SPV_ENV_UNIVERSAL_1_2); auto result = SinglePassRunAndDisassemble( text, /* skip_nop = */ true, /* do_validation = */ false); EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result)); @@ -432,9 +431,40 @@ TEST_F(ReplaceInvalidOpcodeTest, BarrierReplace) { OpReturn OpFunctionEnd)"; + SetTargetEnv(SPV_ENV_UNIVERSAL_1_2); SinglePassRunAndMatch(text, false); } +// Since version 1.3 OpControlBarriers are allowed is more shaders. +// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpControlBarrier +TEST_F(ReplaceInvalidOpcodeTest, BarrierDontReplaceV13) { + const std::string text = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%uint_264 = OpConstant %uint 264 + %main = OpFunction %void None %3 + %5 = OpLabel + OpControlBarrier %uint_2 %uint_2 %uint_264 + OpReturn + OpFunctionEnd)"; + + SetTargetEnv(SPV_ENV_UNIVERSAL_1_3); + auto result = SinglePassRunAndDisassemble( + text, /* skip_nop = */ true, /* do_validation = */ false); + EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result)); +} + TEST_F(ReplaceInvalidOpcodeTest, MessageTest) { const std::string text = R"( OpCapability Shader diff --git a/third_party/spirv-tools/test/opt/scalar_analysis.cpp b/third_party/spirv-tools/test/opt/scalar_analysis.cpp index 14f82af68a..4779658d19 100644 --- a/third_party/spirv-tools/test/opt/scalar_analysis.cpp +++ b/third_party/spirv-tools/test/opt/scalar_analysis.cpp @@ -12,17 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/scalar_analysis.h" + #include -#include -#include #include #include "gmock/gmock.h" -#include "source/opt/iterator.h" -#include "source/opt/loop_descriptor.h" #include "source/opt/pass.h" -#include "source/opt/scalar_analysis.h" -#include "source/opt/tree_iterator.h" #include "test/opt/assembly_builder.h" #include "test/opt/function_utils.h" #include "test/opt/pass_fixture.h" diff --git a/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp b/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp index 0c97c80b77..0ba285bb62 100644 --- a/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp +++ b/third_party/spirv-tools/test/opt/scalar_replacement_test.cpp @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "source/opt/scalar_replacement_pass.h" - #include -#include "gmock/gmock.h" +#include "source/opt/scalar_replacement_pass.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -2310,6 +2308,54 @@ TEST_F(ScalarReplacementTest, UndefImageMember) { SinglePassRunAndMatch(text, true); } +TEST_F(ScalarReplacementTest, RestrictPointer) { + // This test makes sure that a variable with the restrict pointer decoration + // is replaced, and that the pointer is applied to the new variable. + const std::string text = R"( +; CHECK: OpDecorate [[new_var:%\w+]] RestrictPointer +; CHECK: [[struct_type:%\w+]] = OpTypeStruct %int +; CHECK: [[ptr_type:%\w+]] = OpTypePointer PhysicalStorageBuffer [[struct_type]] +; CHECK: [[dup_struct_type:%\w+]] = OpTypeStruct %int +; CHECK: {{%\w+}} = OpTypePointer PhysicalStorageBuffer [[dup_struct_type]] +; CHECK: [[var_type:%\w+]] = OpTypePointer Function [[ptr_type]] +; CHECK: [[new_var]] = OpVariable [[var_type]] Function + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + OpMemberDecorate %3 0 Offset 0 + OpDecorate %3 Block + OpMemberDecorate %4 0 Offset 0 + OpDecorate %4 Block + OpDecorate %5 RestrictPointer + %6 = OpTypeVoid + %7 = OpTypeFunction %6 + %8 = OpTypeInt 32 1 + %9 = OpConstant %8 0 + %3 = OpTypeStruct %8 + %10 = OpTypePointer PhysicalStorageBuffer %3 + %11 = OpTypeStruct %10 + %4 = OpTypeStruct %8 + %12 = OpTypePointer PhysicalStorageBuffer %4 + %13 = OpTypePointer Function %11 + %14 = OpTypePointer Function %10 + %15 = OpTypePointer Function %12 + %16 = OpUndef %11 + %2 = OpFunction %6 None %7 + %17 = OpLabel + %5 = OpVariable %13 Function + OpStore %5 %16 + %18 = OpAccessChain %14 %5 %9 + OpReturn + OpFunctionEnd + )"; + + SetTargetEnv(SPV_ENV_UNIVERSAL_1_6); + SinglePassRunAndMatch(text, true); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/simplification_test.cpp b/third_party/spirv-tools/test/opt/simplification_test.cpp index 7727f5673d..7fce289804 100644 --- a/third_party/spirv-tools/test/opt/simplification_test.cpp +++ b/third_party/spirv-tools/test/opt/simplification_test.cpp @@ -16,7 +16,6 @@ #include "gmock/gmock.h" #include "source/opt/simplification_pass.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" namespace spvtools { diff --git a/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp b/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp index dbb889c090..664c986f6e 100644 --- a/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp +++ b/third_party/spirv-tools/test/opt/spread_volatile_semantics_test.cpp @@ -14,7 +14,6 @@ #include -#include "gmock/gmock.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" @@ -307,7 +306,7 @@ OpDecorate %images DescriptorSet 0 OpDecorate %images Binding 1 OpDecorate %images NonWritable -; CHECK: OpEntryPoint RayGenerationNV {{%\w+}} "RayGeneration" [[var:%\w+]] +; CHECK: OpEntryPoint RayGenerationKHR {{%\w+}} "RayGeneration" [[var:%\w+]] ; CHECK: OpDecorate [[var]] BuiltIn SubgroupSize ; CHECK: OpDecorate [[var]] Volatile ; CHECK-NOT: OpDecorate {{%\w+}} Volatile @@ -398,8 +397,8 @@ OpDecorate %images DescriptorSet 0 OpDecorate %images Binding 1 OpDecorate %images NonWritable -; CHECK: OpEntryPoint RayGenerationNV {{%\w+}} "RayGeneration" [[var:%\w+]] -; CHECK: OpEntryPoint ClosestHitNV {{%\w+}} "ClosestHit" [[var]] +; CHECK: OpEntryPoint RayGenerationKHR {{%\w+}} "RayGeneration" [[var:%\w+]] +; CHECK: OpEntryPoint ClosestHitKHR {{%\w+}} "ClosestHit" [[var]] ; CHECK: OpDecorate [[var]] BuiltIn SubgroupSize ; CHECK: OpDecorate [[var]] Volatile ; CHECK-NOT: OpDecorate {{%\w+}} Volatile diff --git a/third_party/spirv-tools/test/opt/strength_reduction_test.cpp b/third_party/spirv-tools/test/opt/strength_reduction_test.cpp index 31d0503605..a37c6c23a8 100644 --- a/third_party/spirv-tools/test/opt/strength_reduction_test.cpp +++ b/third_party/spirv-tools/test/opt/strength_reduction_test.cpp @@ -12,16 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include #include #include #include #include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/struct_cfg_analysis_test.cpp b/third_party/spirv-tools/test/opt/struct_cfg_analysis_test.cpp index e7031cb5ca..9c72cee955 100644 --- a/third_party/spirv-tools/test/opt/struct_cfg_analysis_test.cpp +++ b/third_party/spirv-tools/test/opt/struct_cfg_analysis_test.cpp @@ -17,7 +17,6 @@ #include #include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/struct_packing_test.cpp b/third_party/spirv-tools/test/opt/struct_packing_test.cpp new file mode 100644 index 0000000000..1b8e8d1a08 --- /dev/null +++ b/third_party/spirv-tools/test/opt/struct_packing_test.cpp @@ -0,0 +1,242 @@ +// Copyright (c) 2024 Epic Games, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "source/opt/struct_packing_pass.h" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using StructPackingTest = PassTest<::testing::Test>; + +TEST_F(StructPackingTest, PackSimpleStructStd140) { + // #version 420 + // + // layout(std140, binding = 0) uniform Globals { + // layout(offset = 16) vec3 a_xyz; + // float a_w; + // layout(offset = 128) vec3 b_xyz; + // int b_w; + // }; + // + // void main() {} + const std::string spirv = R"( +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginLowerLeft +OpSource GLSL 420 +OpName %main "main" +OpName %Globals "Globals" +OpMemberName %Globals 0 "a_xyz" +OpMemberName %Globals 1 "a_w" +OpMemberName %Globals 2 "b_xyz" +OpMemberName %Globals 3 "b_w" +OpName %_ "" +; CHECK: OpMemberDecorate %Globals 0 Offset 0 +OpMemberDecorate %Globals 0 Offset 16 +; CHECK: OpMemberDecorate %Globals 1 Offset 12 +OpMemberDecorate %Globals 1 Offset 28 +; CHECK: OpMemberDecorate %Globals 2 Offset 16 +OpMemberDecorate %Globals 2 Offset 128 +; CHECK: OpMemberDecorate %Globals 3 Offset 28 +OpMemberDecorate %Globals 3 Offset 140 +OpDecorate %Globals Block +OpDecorate %_ DescriptorSet 0 +OpDecorate %_ Binding 0 +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v3float = OpTypeVector %float 3 +%int = OpTypeInt 32 1 +%Globals = OpTypeStruct %v3float %float %v3float %int +%_ptr_Uniform_Globals = OpTypePointer Uniform %Globals +%_ = OpVariable %_ptr_Uniform_Globals Uniform +%main = OpFunction %void None %3 +%5 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch( + spirv, true, "Globals", StructPackingPass::PackingRules::Std140); +} + +TEST_F(StructPackingTest, PackSimpleStructWithPaddingStd140) { + // #version 420 + // + // layout(std140, binding = 0) uniform Globals { + // layout(offset = 16) vec3 a_xyz; + // float a_w; + // float b_x_padding_yzw; + // layout(offset = 128) vec3 c_xyz; + // int c_w; + // }; + // + // void main() {} + const std::string spirv = R"( +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginLowerLeft +OpSource GLSL 420 +OpName %main "main" +OpName %Globals "Globals" +OpMemberName %Globals 0 "a_xyz" +OpMemberName %Globals 1 "a_w" +OpMemberName %Globals 2 "b_x_padding_yzw" +OpMemberName %Globals 3 "c_xyz" +OpMemberName %Globals 4 "c_w" +OpName %_ "" +; CHECK: OpMemberDecorate %Globals 0 Offset 0 +OpMemberDecorate %Globals 0 Offset 16 +; CHECK: OpMemberDecorate %Globals 1 Offset 12 +OpMemberDecorate %Globals 1 Offset 28 +; CHECK: OpMemberDecorate %Globals 2 Offset 16 +OpMemberDecorate %Globals 2 Offset 32 +; CHECK: OpMemberDecorate %Globals 3 Offset 32 +OpMemberDecorate %Globals 3 Offset 128 +; CHECK: OpMemberDecorate %Globals 4 Offset 44 +OpMemberDecorate %Globals 4 Offset 140 +OpDecorate %Globals Block +OpDecorate %_ DescriptorSet 0 +OpDecorate %_ Binding 0 +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v3float = OpTypeVector %float 3 +%int = OpTypeInt 32 1 +%Globals = OpTypeStruct %v3float %float %float %v3float %int +%_ptr_Uniform_Globals = OpTypePointer Uniform %Globals +%_ = OpVariable %_ptr_Uniform_Globals Uniform +%main = OpFunction %void None %3 +%5 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch( + spirv, true, "Globals", StructPackingPass::PackingRules::Std140); +} + +TEST_F(StructPackingTest, PackSimpleScalarArrayStd140) { + // #version 420 + // + // layout(std140, binding = 0) uniform Globals { + // layout(offset = 16) float a[2]; + // layout(offset = 128) float b[2]; // Must become offset 32 with std140 + // }; + // + // void main() {} + const std::string spirv = R"( +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginLowerLeft +OpSource GLSL 420 +OpName %main "main" +OpName %Globals "Globals" +OpMemberName %Globals 0 "a" +OpMemberName %Globals 1 "b" +OpName %_ "" +OpDecorate %_arr_float_uint_2 ArrayStride 16 +OpDecorate %_arr_float_uint_2_0 ArrayStride 16 +; CHECK: OpMemberDecorate %Globals 0 Offset 0 +OpMemberDecorate %Globals 0 Offset 16 +; CHECK: OpMemberDecorate %Globals 1 Offset 32 +OpMemberDecorate %Globals 1 Offset 128 +OpDecorate %Globals Block +OpDecorate %_ DescriptorSet 0 +OpDecorate %_ Binding 0 +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%uint = OpTypeInt 32 0 +%uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_arr_float_uint_2_0 = OpTypeArray %float %uint_2 +%Globals = OpTypeStruct %_arr_float_uint_2 %_arr_float_uint_2_0 +%_ptr_Uniform_Globals = OpTypePointer Uniform %Globals +%_ = OpVariable %_ptr_Uniform_Globals Uniform +%main = OpFunction %void None %3 +%5 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch( + spirv, true, "Globals", StructPackingPass::PackingRules::Std140); +} + +TEST_F(StructPackingTest, PackSimpleScalarArrayStd430) { + // #version 430 + // + // layout(std430, binding = 0) buffer Globals { + // layout(offset = 16) float a[2]; + // layout(offset = 128) float b[2]; // Must become offset 8 with std430 + // }; + // + // void main() {} + const std::string spirv = R"( +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginLowerLeft +OpSource GLSL 430 +OpName %main "main" +OpName %Globals "Globals" +OpMemberName %Globals 0 "a" +OpMemberName %Globals 1 "b" +OpName %_ "" +OpDecorate %_arr_float_uint_2 ArrayStride 4 +OpDecorate %_arr_float_uint_2_0 ArrayStride 4 +; CHECK: OpMemberDecorate %Globals 0 Offset 0 +OpMemberDecorate %Globals 0 Offset 16 +; CHECK: OpMemberDecorate %Globals 1 Offset 8 +OpMemberDecorate %Globals 1 Offset 128 +OpDecorate %Globals BufferBlock +OpDecorate %_ DescriptorSet 0 +OpDecorate %_ Binding 0 +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%uint = OpTypeInt 32 0 +%uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_arr_float_uint_2_0 = OpTypeArray %float %uint_2 +%Globals = OpTypeStruct %_arr_float_uint_2 %_arr_float_uint_2_0 +%_ptr_Uniform_Globals = OpTypePointer Uniform %Globals +%_ = OpVariable %_ptr_Uniform_Globals Uniform +%main = OpFunction %void None %3 +%5 = OpLabel +OpReturn +OpFunctionEnd +)"; + + SinglePassRunAndMatch( + spirv, true, "Globals", StructPackingPass::PackingRules::Std430); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/switch_descriptorset_test.cpp b/third_party/spirv-tools/test/opt/switch_descriptorset_test.cpp new file mode 100644 index 0000000000..f26178f829 --- /dev/null +++ b/third_party/spirv-tools/test/opt/switch_descriptorset_test.cpp @@ -0,0 +1,193 @@ +// Copyright (c) 2023 LunarG Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Bindless Check Instrumentation Tests. +// Tests ending with V2 use version 2 record format. + +#include +#include + +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using SwitchDescriptorSetTest = PassTest<::testing::Test>; + +TEST_F(SwitchDescriptorSetTest, Basic) { + // #version 450 + // #extension GL_EXT_buffer_reference : enable + // + // layout(buffer_reference, buffer_reference_align = 16) buffer bufStruct; + // + // layout(set = 7, binding = 7) uniform ufoo { + // bufStruct data; + // uint offset; + // } u_info; + // + // layout(buffer_reference, std140) buffer bufStruct { + // layout(offset = 0) int a[2]; + // layout(offset = 32) int b; + // }; + // + // void main() { + // u_info.data.b = 0xca7; + // } + + const std::string spirv = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +OpExtension "SPV_EXT_physical_storage_buffer" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpSource GLSL 450 +OpSourceExtension "GL_EXT_buffer_reference" +OpName %main "main" +OpName %ufoo "ufoo" +OpMemberName %ufoo 0 "data" +OpMemberName %ufoo 1 "offset" +OpName %bufStruct "bufStruct" +OpMemberName %bufStruct 0 "a" +OpMemberName %bufStruct 1 "b" +OpName %u_info "u_info" +OpMemberDecorate %ufoo 0 Offset 0 +OpMemberDecorate %ufoo 1 Offset 8 +OpDecorate %ufoo Block +OpDecorate %_arr_int_uint_2 ArrayStride 16 +OpMemberDecorate %bufStruct 0 Offset 0 +OpMemberDecorate %bufStruct 1 Offset 32 +OpDecorate %bufStruct Block +OpDecorate %u_info DescriptorSet 7 +;CHECK: OpDecorate %u_info DescriptorSet 31 +OpDecorate %u_info Binding 7 +;CHECK: OpDecorate %u_info Binding 7 +%void = OpTypeVoid +%3 = OpTypeFunction %void +OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_bufStruct PhysicalStorageBuffer +%uint = OpTypeInt 32 0 +%ufoo = OpTypeStruct %_ptr_PhysicalStorageBuffer_bufStruct %uint +%int = OpTypeInt 32 1 +%uint_2 = OpConstant %uint 2 +%_arr_int_uint_2 = OpTypeArray %int %uint_2 +%bufStruct = OpTypeStruct %_arr_int_uint_2 %int +%_ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer PhysicalStorageBuffer %bufStruct +%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo +%u_info = OpVariable %_ptr_Uniform_ufoo Uniform +%int_0 = OpConstant %int 0 +%_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer Uniform %_ptr_PhysicalStorageBuffer_bufStruct +%int_1 = OpConstant %int 1 +%int_3239 = OpConstant %int 3239 +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int +%main = OpFunction %void None %3 +%5 = OpLabel +%17 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 +%18 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %17 +%22 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %18 %int_1 +OpReturn +OpFunctionEnd +)"; + // clang-format off + + SinglePassRunAndMatch(spirv, true, 7, 31); +} + + +// Make sure DescriptorSet decorations that don't match the requested number +// are left unchanged. +TEST_F(SwitchDescriptorSetTest, Unchanged) { + // #version 450 + // #extension GL_EXT_buffer_reference : enable + // + // layout(buffer_reference, buffer_reference_align = 16) buffer bufStruct; + // + // layout(set = 11, binding = 7) uniform ufoo { + // bufStruct data; + // uint offset; + // } u_info; + // + // layout(buffer_reference, std140) buffer bufStruct { + // layout(offset = 0) int a[2]; + // layout(offset = 32) int b; + // }; + // + // void main() { + // u_info.data.b = 0xca7; + // } + + const std::string spirv = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +OpExtension "SPV_EXT_physical_storage_buffer" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpSource GLSL 450 +OpSourceExtension "GL_EXT_buffer_reference" +OpName %main "main" +OpName %ufoo "ufoo" +OpMemberName %ufoo 0 "data" +OpMemberName %ufoo 1 "offset" +OpName %bufStruct "bufStruct" +OpMemberName %bufStruct 0 "a" +OpMemberName %bufStruct 1 "b" +OpName %u_info "u_info" +OpMemberDecorate %ufoo 0 Offset 0 +OpMemberDecorate %ufoo 1 Offset 8 +OpDecorate %ufoo Block +OpDecorate %_arr_int_uint_2 ArrayStride 16 +OpMemberDecorate %bufStruct 0 Offset 0 +OpMemberDecorate %bufStruct 1 Offset 32 +OpDecorate %bufStruct Block +OpDecorate %u_info DescriptorSet 11 +;CHECK: OpDecorate %u_info DescriptorSet 11 +OpDecorate %u_info Binding 7 +;CHECK: OpDecorate %u_info Binding 7 +%void = OpTypeVoid +%3 = OpTypeFunction %void +OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_bufStruct PhysicalStorageBuffer +%uint = OpTypeInt 32 0 +%ufoo = OpTypeStruct %_ptr_PhysicalStorageBuffer_bufStruct %uint +%int = OpTypeInt 32 1 +%uint_2 = OpConstant %uint 2 +%_arr_int_uint_2 = OpTypeArray %int %uint_2 +%bufStruct = OpTypeStruct %_arr_int_uint_2 %int +%_ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer PhysicalStorageBuffer %bufStruct +%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo +%u_info = OpVariable %_ptr_Uniform_ufoo Uniform +%int_0 = OpConstant %int 0 +%_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer Uniform %_ptr_PhysicalStorageBuffer_bufStruct +%int_1 = OpConstant %int 1 +%int_3239 = OpConstant %int 3239 +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int +%main = OpFunction %void None %3 +%5 = OpLabel +%17 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 +%18 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %17 +%22 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %18 %int_1 +OpReturn +OpFunctionEnd +)"; + // clang-format off + + SinglePassRunAndMatch(spirv, true, 7, 31); +} + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/trim_capabilities_pass_test.cpp b/third_party/spirv-tools/test/opt/trim_capabilities_pass_test.cpp new file mode 100644 index 0000000000..1569ad73de --- /dev/null +++ b/third_party/spirv-tools/test/opt/trim_capabilities_pass_test.cpp @@ -0,0 +1,3320 @@ +// Copyright (c) 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include + +#include "spirv-tools/optimizer.hpp" +#include "test/opt/pass_fixture.h" +#include "test/opt/pass_utils.h" + +namespace spvtools { +namespace opt { +namespace { + +using TrimCapabilitiesPassTest = PassTest<::testing::Test>; + +TEST_F(TrimCapabilitiesPassTest, CheckKnownAliasTransformations) { + // Those are expected changes caused by the test process: + // - SPV is assembled. -> capability goes from text to number. + // - SPV is optimized. + // - SPV is disassembled -> capability goes from number to text. + // - CHECK rule compares both text versions. + // Because some capabilities share the same number (aliases), the text + // compared with the CHECK rules depends on which alias is the first on the + // SPIRV-Headers enum. This could change, and we want to easily distinguish + // real failure from alias order change. This test is only here to list known + // alias transformations. If this test breaks, it's not a bug in the + // optimization pass, but just the SPIRV-Headers enum order that has changed. + // If that happens, tests needs to be updated to the correct alias is used in + // the CHECK rule. + const std::string kTest = R"( + OpCapability Linkage + OpCapability StorageUniform16 + OpCapability StorageUniformBufferBlock16 + OpCapability ShaderViewportIndexLayerNV + OpCapability FragmentBarycentricNV + OpCapability ShadingRateNV + OpCapability ShaderNonUniformEXT + OpCapability RuntimeDescriptorArrayEXT + OpCapability InputAttachmentArrayDynamicIndexingEXT + OpCapability UniformTexelBufferArrayDynamicIndexingEXT + OpCapability StorageTexelBufferArrayDynamicIndexingEXT + OpCapability UniformBufferArrayNonUniformIndexingEXT + OpCapability SampledImageArrayNonUniformIndexingEXT + OpCapability StorageBufferArrayNonUniformIndexingEXT + OpCapability StorageImageArrayNonUniformIndexingEXT + OpCapability InputAttachmentArrayNonUniformIndexingEXT + OpCapability UniformTexelBufferArrayNonUniformIndexingEXT + OpCapability StorageTexelBufferArrayNonUniformIndexingEXT + OpCapability VulkanMemoryModelKHR + OpCapability VulkanMemoryModelDeviceScopeKHR + OpCapability PhysicalStorageBufferAddressesEXT + OpCapability DemoteToHelperInvocationEXT + OpCapability DotProductInputAllKHR + OpCapability DotProductInput4x8BitKHR + OpCapability DotProductInput4x8BitPackedKHR + OpCapability DotProductKHR + OpCapability ComputeDerivativeGroupQuadsKHR + OpCapability ComputeDerivativeGroupLinearKHR +; CHECK: OpCapability Linkage +; CHECK-NOT: OpCapability StorageUniform16 +; CHECK-NOT: OpCapability StorageUniformBufferBlock16 +; CHECK-NOT: OpCapability ShaderViewportIndexLayerNV +; CHECK-NOT: OpCapability FragmentBarycentricNV +; CHECK-NOT: OpCapability ShadingRateNV +; CHECK-NOT: OpCapability ShaderNonUniformEXT +; CHECK-NOT: OpCapability RuntimeDescriptorArrayEXT +; CHECK-NOT: OpCapability InputAttachmentArrayDynamicIndexingEXT +; CHECK-NOT: OpCapability UniformTexelBufferArrayDynamicIndexingEXT +; CHECK-NOT: OpCapability StorageTexelBufferArrayDynamicIndexingEXT +; CHECK-NOT: OpCapability UniformBufferArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability SampledImageArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability StorageBufferArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability StorageImageArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability InputAttachmentArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability UniformTexelBufferArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability StorageTexelBufferArrayNonUniformIndexingEXT +; CHECK-NOT: OpCapability VulkanMemoryModelKHR +; CHECK-NOT: OpCapability VulkanMemoryModelDeviceScopeKHR +; CHECK-NOT: OpCapability PhysicalStorageBufferAddressesEXT +; CHECK-NOT: OpCapability DemoteToHelperInvocationEXT +; CHECK-NOT: OpCapability DotProductInputAllKHR +; CHECK-NOT: OpCapability DotProductInput4x8BitKHR +; CHECK-NOT: OpCapability DotProductInput4x8BitPackedKHR +; CHECK-NOT: OpCapability DotProductKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupQuadsKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupLinearKHR +; CHECK: OpCapability UniformAndStorageBuffer16BitAccess +; CHECK: OpCapability StorageBuffer16BitAccess +; CHECK: OpCapability ShaderViewportIndexLayerEXT +; CHECK: OpCapability FragmentBarycentricKHR +; CHECK: OpCapability FragmentDensityEXT +; CHECK: OpCapability ShaderNonUniform +; CHECK: OpCapability RuntimeDescriptorArray +; CHECK: OpCapability InputAttachmentArrayDynamicIndexing +; CHECK: OpCapability UniformTexelBufferArrayDynamicIndexing +; CHECK: OpCapability StorageTexelBufferArrayDynamicIndexing +; CHECK: OpCapability UniformBufferArrayNonUniformIndexing +; CHECK: OpCapability SampledImageArrayNonUniformIndexing +; CHECK: OpCapability StorageBufferArrayNonUniformIndexing +; CHECK: OpCapability StorageImageArrayNonUniformIndexing +; CHECK: OpCapability InputAttachmentArrayNonUniformIndexing +; CHECK: OpCapability UniformTexelBufferArrayNonUniformIndexing +; CHECK: OpCapability StorageTexelBufferArrayNonUniformIndexing +; CHECK: OpCapability VulkanMemoryModel +; CHECK: OpCapability VulkanMemoryModelDeviceScope +; CHECK: OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability DemoteToHelperInvocation +; CHECK: OpCapability DotProductInputAll +; CHECK: OpCapability DotProductInput4x8Bit +; CHECK: OpCapability DotProductInput4x8BitPacked +; CHECK: OpCapability DotProduct + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, LinkagePreventsChanges) { + const std::string kTest = R"( + OpCapability Linkage + OpCapability ClipDistance + OpCapability CullDistance + OpCapability DemoteToHelperInvocation + OpCapability DeviceGroup + OpCapability DrawParameters + OpCapability Float16 + OpCapability Float64 + OpCapability FragmentBarycentricKHR + OpCapability FragmentFullyCoveredEXT + OpCapability FragmentShadingRateKHR + OpCapability GroupNonUniform + OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformBallot + OpCapability GroupNonUniformQuad + OpCapability GroupNonUniformShuffle + OpCapability Image1D + OpCapability ImageBuffer + OpCapability ImageGatherExtended + OpCapability ImageMSArray + OpCapability ImageQuery + OpCapability InputAttachment + OpCapability InputAttachmentArrayNonUniformIndexing + OpCapability Int16 + OpCapability Int64 + OpCapability Int64Atomics + OpCapability Int64ImageEXT + OpCapability MeshShadingNV + OpCapability MinLod + OpCapability MultiView + OpCapability MultiViewport + OpCapability PhysicalStorageBufferAddresses + OpCapability RayQueryKHR + OpCapability RayTracingKHR + OpCapability RayTracingNV + OpCapability RayTraversalPrimitiveCullingKHR + OpCapability RuntimeDescriptorArray + OpCapability SampleMaskPostDepthCoverage + OpCapability SampleRateShading + OpCapability Sampled1D + OpCapability SampledBuffer + OpCapability SampledImageArrayNonUniformIndexing + OpCapability Shader + OpCapability ShaderClockKHR + OpCapability ShaderLayer + OpCapability ShaderNonUniform + OpCapability ShaderViewportIndex + OpCapability ShaderViewportIndexLayerEXT + OpCapability SparseResidency + OpCapability StencilExportEXT + OpCapability StorageImageArrayNonUniformIndexingEXT + OpCapability StorageImageExtendedFormats + OpCapability StorageImageReadWithoutFormat + OpCapability StorageImageWriteWithoutFormat + OpCapability StorageInputOutput16 + OpCapability StoragePushConstant16 + OpCapability StorageTexelBufferArrayNonUniformIndexing + OpCapability StorageUniform16 + OpCapability StorageUniformBufferBlock16 + OpCapability Tessellation + OpCapability UniformTexelBufferArrayNonUniformIndexing + OpCapability VulkanMemoryModel + OpExtension "SPV_EXT_fragment_fully_covered" + OpExtension "SPV_EXT_shader_image_int64" + OpExtension "SPV_EXT_shader_stencil_export" + OpExtension "SPV_EXT_shader_viewport_index_layer" + OpExtension "SPV_KHR_fragment_shader_barycentric" + OpExtension "SPV_KHR_fragment_shading_rate" + OpExtension "SPV_KHR_post_depth_coverage" + OpExtension "SPV_KHR_ray_query" + OpExtension "SPV_KHR_ray_tracing" + OpExtension "SPV_KHR_shader_clock" + OpExtension "SPV_NV_mesh_shader" + OpExtension "SPV_NV_ray_tracing" + OpExtension "SPV_NV_viewport_array2" +; CHECK: OpCapability Linkage +; CHECK: OpCapability ClipDistance +; CHECK: OpCapability CullDistance +; CHECK: OpCapability DemoteToHelperInvocation +; CHECK: OpCapability DeviceGroup +; CHECK: OpCapability DrawParameters +; CHECK: OpCapability Float16 +; CHECK: OpCapability Float64 +; CHECK: OpCapability FragmentBarycentricKHR +; CHECK: OpCapability FragmentFullyCoveredEXT +; CHECK: OpCapability FragmentShadingRateKHR +; CHECK: OpCapability GroupNonUniform +; CHECK: OpCapability GroupNonUniformArithmetic +; CHECK: OpCapability GroupNonUniformBallot +; CHECK: OpCapability GroupNonUniformQuad +; CHECK: OpCapability GroupNonUniformShuffle +; CHECK: OpCapability Image1D +; CHECK: OpCapability ImageBuffer +; CHECK: OpCapability ImageGatherExtended +; CHECK: OpCapability ImageMSArray +; CHECK: OpCapability ImageQuery +; CHECK: OpCapability InputAttachment +; CHECK: OpCapability InputAttachmentArrayNonUniformIndexing +; CHECK: OpCapability Int16 +; CHECK: OpCapability Int64 +; CHECK: OpCapability Int64Atomics +; CHECK: OpCapability Int64ImageEXT +; CHECK: OpCapability MeshShadingNV +; CHECK: OpCapability MinLod +; CHECK: OpCapability MultiView +; CHECK: OpCapability MultiViewport +; CHECK: OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability RayQueryKHR +; CHECK: OpCapability RayTracingKHR +; CHECK: OpCapability RayTracingNV +; CHECK: OpCapability RayTraversalPrimitiveCullingKHR +; CHECK: OpCapability RuntimeDescriptorArray +; CHECK: OpCapability SampleMaskPostDepthCoverage +; CHECK: OpCapability SampleRateShading +; CHECK: OpCapability Sampled1D +; CHECK: OpCapability SampledBuffer +; CHECK: OpCapability SampledImageArrayNonUniformIndexing +; CHECK: OpCapability Shader +; CHECK: OpCapability ShaderClockKHR +; CHECK: OpCapability ShaderLayer +; CHECK: OpCapability ShaderNonUniform +; CHECK: OpCapability ShaderViewportIndex +; CHECK: OpCapability ShaderViewportIndexLayerEXT +; CHECK: OpCapability SparseResidency +; CHECK: OpCapability StencilExportEXT +; CHECK: OpCapability StorageImageArrayNonUniformIndexing +; CHECK: OpCapability StorageImageExtendedFormats +; CHECK: OpCapability StorageImageReadWithoutFormat +; CHECK: OpCapability StorageImageWriteWithoutFormat +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpCapability StoragePushConstant16 +; CHECK: OpCapability StorageTexelBufferArrayNonUniformIndexing +; CHECK: OpCapability Tessellation +; CHECK: OpCapability UniformTexelBufferArrayNonUniformIndex +; CHECK: OpCapability VulkanMemoryModel +; CHECK: OpExtension "SPV_EXT_fragment_fully_covered" +; CHECK: OpExtension "SPV_EXT_shader_image_int64" +; CHECK: OpExtension "SPV_EXT_shader_stencil_export" +; CHECK: OpExtension "SPV_EXT_shader_viewport_index_layer" +; CHECK: OpExtension "SPV_KHR_fragment_shader_barycentric" +; CHECK: OpExtension "SPV_KHR_fragment_shading_rate" +; CHECK: OpExtension "SPV_KHR_post_depth_coverage" +; CHECK: OpExtension "SPV_KHR_ray_query" +; CHECK: OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpExtension "SPV_KHR_shader_clock" +; CHECK: OpExtension "SPV_NV_mesh_shader" +; CHECK: OpExtension "SPV_NV_ray_tracing" +; CHECK: OpExtension "SPV_NV_viewport_array2" + OpMemoryModel Logical Vulkan + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_3); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, KeepShader) { + const std::string kTest = R"( + OpCapability Shader +; CHECK: OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, KeepShaderClockWhenInUse) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Int64 + OpCapability ShaderClockKHR + OpExtension "SPV_KHR_shader_clock" +; CHECK: OpCapability ShaderClockKHR +; CHECK: OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %scope = OpConstant %uint 1 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + %7 = OpReadClockKHR %ulong %scope + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, TrimShaderClockWhenUnused) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Int64 + OpCapability ShaderClockKHR + OpExtension "SPV_KHR_shader_clock" +; CHECK-NOT: OpCapability ShaderClockKHR +; CHECK-NOT: OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, AMDShaderBallotExtensionRemains) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Groups + OpExtension "SPV_AMD_shader_ballot" +; CHECK: OpCapability Groups +; CHECK: OpExtension "SPV_AMD_shader_ballot" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %1 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 + %2 = OpFunction %void None %1 + %3 = OpLabel + %4 = OpGroupIAddNonUniformAMD %uint %uint_0 ExclusiveScan %uint_0 + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, AMDShaderBallotExtensionRemoved) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Groups + OpExtension "SPV_AMD_shader_ballot" +; CHECK-NOT: OpCapability Groups +; CHECK-NOT: OpExtension "SPV_AMD_shader_ballot" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, MinLod_RemovedIfNotUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Sampled1D + OpCapability MinLod +; CHECK-NOT: OpCapability MinLod + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %type_image = OpTypeImage %float Cube 2 0 0 1 Rgba32f + %ptr_type_image = OpTypePointer UniformConstant %type_image + %type_sampler = OpTypeSampler + %ptr_type_sampler = OpTypePointer UniformConstant %type_sampler + %float_0 = OpConstant %float 0 + %float_000 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %image = OpVariable %ptr_type_image UniformConstant + %sampler = OpVariable %ptr_type_sampler UniformConstant + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + %21 = OpLoad %type_image %image + %22 = OpLoad %type_sampler %sampler + %24 = OpSampledImage %type_sampled_image %21 %22 + %25 = OpImageSampleImplicitLod %v4float %24 %float_000 + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, MinLod_RemainsWithOpImageSampleImplicitLod) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Sampled1D + OpCapability MinLod +; CHECK: OpCapability MinLod + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %type_image = OpTypeImage %float Cube 2 0 0 1 Rgba32f + %ptr_type_image = OpTypePointer UniformConstant %type_image + %type_sampler = OpTypeSampler + %ptr_type_sampler = OpTypePointer UniformConstant %type_sampler + %float_0 = OpConstant %float 0 + %float_000 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %image = OpVariable %ptr_type_image UniformConstant + %sampler = OpVariable %ptr_type_sampler UniformConstant + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + %21 = OpLoad %type_image %image + %22 = OpLoad %type_sampler %sampler + %24 = OpSampledImage %type_sampled_image %21 %22 + %25 = OpImageSampleImplicitLod %v4float %24 %float_000 MinLod %float_0 + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + MinLod_RemainsWithOpImageSparseSampleImplicitLod) { + const std::string kTest = R"( + OpCapability Shader + OpCapability SparseResidency + OpCapability ImageGatherExtended + OpCapability MinLod +; CHECK: OpCapability MinLod + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" + OpExecutionMode %2 OriginUpperLeft + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %type_image = OpTypeImage %float 2D 2 0 0 1 Unknown + %ptr_type_image = OpTypePointer UniformConstant %type_image + %type_sampler = OpTypeSampler + %ptr_type_sampler = OpTypePointer UniformConstant %type_sampler +%type_sampled_image = OpTypeSampledImage %type_image + %sparse_struct = OpTypeStruct %uint %v4float + %float_0 = OpConstant %float 0 + %float_00 = OpConstantComposite %v2float %float_0 %float_0 + %float_000 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %image = OpVariable %ptr_type_image UniformConstant + %sampler = OpVariable %ptr_type_sampler UniformConstant + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + %21 = OpLoad %type_image %image + %22 = OpLoad %type_sampler %sampler + %24 = OpSampledImage %type_sampled_image %21 %22 + %25 = OpImageSparseSampleImplicitLod %sparse_struct %24 %float_00 MinLod %float_0 + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, MinLod_DetectsMinLodWithBitmaskImageOperand) { + const std::string kTest = R"( + OpCapability MinLod +; CHECK: OpCapability MinLod + OpCapability Shader + OpCapability SparseResidency + OpCapability ImageGatherExtended + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %1 "main" + OpExecutionMode %1 OriginUpperLeft + %type_sampler = OpTypeSampler + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %v2int = OpTypeVector %int 2 + %v2float = OpTypeVector %float 2 + %v4float = OpTypeVector %float 4 + %ptr_sampler = OpTypePointer UniformConstant %type_sampler + %type_image = OpTypeImage %float 2D 2 0 0 1 Unknown + %ptr_image = OpTypePointer UniformConstant %type_image + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %type_sampled_image = OpTypeSampledImage %type_image + %type_struct = OpTypeStruct %uint %v4float + + %int_1 = OpConstant %int 1 + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %8 = OpConstantComposite %v2float %float_0 %float_0 + %12 = OpConstantComposite %v2int %int_1 %int_1 + + %2 = OpVariable %ptr_sampler UniformConstant + %3 = OpVariable %ptr_image UniformConstant + %27 = OpTypeFunction %void + %1 = OpFunction %void None %27 + %28 = OpLabel + %29 = OpLoad %type_image %3 + %30 = OpLoad %type_sampler %2 + %31 = OpSampledImage %type_sampled_image %29 %30 + %32 = OpImageSparseSampleImplicitLod %type_struct %31 %8 ConstOffset|MinLod %12 %float_0 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointer_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer Input %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointer_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer Input %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerArray_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %array = OpTypeArray %half %uint_1 + %ptr = OpTypePointer Input %array + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerArray_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %array = OpTypeArray %half %uint_1 + %ptr = OpTypePointer Input %array + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerStruct_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Input %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerStruct_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Input %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerStructOfStruct_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %float = OpTypeFloat 32 + %struct = OpTypeStruct %float %half + %parent = OpTypeStruct %float %struct + %ptr = OpTypePointer Input %parent + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerStructOfStruct_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %float = OpTypeFloat 32 + %struct = OpTypeStruct %float %half + %parent = OpTypeStruct %float %struct + %ptr = OpTypePointer Input %parent + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerArrayOfStruct_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %array = OpTypeArray %struct %uint_1 + %ptr = OpTypePointer Input %array + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerArrayOfStruct_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %array = OpTypeArray %struct %uint_1 + %ptr = OpTypePointer Input %array + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerVector_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %vector = OpTypeVector %half 4 + %ptr = OpTypePointer Input %vector + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerVector_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %vector = OpTypeVector %half 4 + %ptr = OpTypePointer Input %vector + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerMatrix_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %vector = OpTypeVector %half 4 + %matrix = OpTypeMatrix %vector 4 + %ptr = OpTypePointer Input %matrix + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithInputPointerMatrix_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %vector = OpTypeVector %half 4 + %matrix = OpTypeMatrix %vector 4 + %ptr = OpTypePointer Input %matrix + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_IsRemovedWithoutInputPointer) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK-NOT: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithOutputPointer_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer Output %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemainsWithOutputPointer_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer Output %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageInputOutput16_RemovedWithoutOutputPointer) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK-NOT: OpCapability StorageInputOutput16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StoragePushConstant16_RemainsSimplePointer_Vulkan1_0) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StoragePushConstant16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StoragePushConstant16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer PushConstant %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StoragePushConstant16_RemainsSimplePointer_Vulkan1_1) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StoragePushConstant16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK: OpCapability StoragePushConstant16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer PushConstant %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, StoragePushConstant16_RemovedSimplePointer) { + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StoragePushConstant16 + OpExtension "SPV_KHR_16bit_storage" +; CHECK-NOT: OpCapability StoragePushConstant16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %ptr = OpTypePointer Function %half + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniformBufferBlock16_RemainsSimplePointer_Vulkan1_0) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpDecorate %struct BufferBlock + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniformBufferBlock16_RemainsSimplePointer_Vulkan1_1) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpDecorate %struct BufferBlock + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniformBufferBlock16_RemovedSimplePointer) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK-NOT: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Function %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniform16_RemovedWithBufferBlockPointer_Vulkan1_0) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + static_assert(spv::Capability::StorageUniform16 == + spv::Capability::UniformAndStorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpCapability UniformAndStorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK-NOT: OpCapability UniformAndStorageBuffer16BitAccess +; `-> StorageUniform16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpDecorate %struct BufferBlock + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniform16_RemovedWithBufferBlockPointer_Vulkan1_1) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + static_assert(spv::Capability::StorageUniform16 == + spv::Capability::UniformAndStorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpCapability UniformAndStorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK-NOT: OpCapability UniformAndStorageBuffer16BitAccess +; `-> StorageUniform16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpDecorate %struct BufferBlock + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniform16_RemovedWithNonBlockUniformPointer_Vulkan1_0) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + static_assert(spv::Capability::StorageUniform16 == + spv::Capability::UniformAndStorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpCapability UniformAndStorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK-NOT: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK: OpCapability UniformAndStorageBuffer16BitAccess +; `-> StorageUniform16 +; CHECK: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_0); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageUniform16_RemovedWithNonBlockUniformPointer_Vulkan1_1) { + // See https://github.com/KhronosGroup/SPIRV-Tools/issues/5354 + static_assert(spv::Capability::StorageUniformBufferBlock16 == + spv::Capability::StorageBuffer16BitAccess); + static_assert(spv::Capability::StorageUniform16 == + spv::Capability::UniformAndStorageBuffer16BitAccess); + + const std::string kTest = R"( + OpCapability Shader + OpCapability Float16 + OpCapability StorageBuffer16BitAccess + OpCapability UniformAndStorageBuffer16BitAccess + OpExtension "SPV_KHR_16bit_storage" + +; CHECK-NOT: OpCapability StorageBuffer16BitAccess +; `-> StorageUniformBufferBlock16 +; CHECK: OpCapability UniformAndStorageBuffer16BitAccess +; `-> StorageUniform16 +; CHECK-NOT: OpExtension "SPV_KHR_16bit_storage" + + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + %void = OpTypeVoid + %half = OpTypeFloat 16 + %struct = OpTypeStruct %half + %ptr = OpTypePointer Uniform %struct + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd + )"; + SetTargetEnv(SPV_ENV_VULKAN_1_1); + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, FragmentShaderInterlock_RemovedIfNotUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK-NOT: OpCapability FragmentShaderPixelInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderSampleInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK-NOT: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderPixelInterlock_RemainsWhenOrderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK: OpCapability FragmentShaderPixelInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderSampleInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main PixelInterlockOrderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderPixelInterlock_RemainsWhenUnorderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK: OpCapability FragmentShaderPixelInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderSampleInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main PixelInterlockUnorderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderSampleInterlock_RemainsWhenOrderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK-NOT: OpCapability FragmentShaderPixelInterlockEXT +; CHECK: OpCapability FragmentShaderSampleInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main SampleInterlockOrderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderSampleInterlock_RemainsWhenUnorderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK-NOT: OpCapability FragmentShaderPixelInterlockEXT +; CHECK: OpCapability FragmentShaderSampleInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main SampleInterlockUnorderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderShadingRateInterlock_RemainsWhenOrderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK-NOT: OpCapability FragmentShaderPixelInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderSampleInterlockEXT +; CHECK: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main ShadingRateInterlockOrderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + FragmentShaderShadingRateInterlock_RemainsWhenUnorderedIsUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability FragmentShaderPixelInterlockEXT + OpCapability FragmentShaderSampleInterlockEXT + OpCapability FragmentShaderShadingRateInterlockEXT + OpExtension "SPV_EXT_fragment_shader_interlock" +; CHECK-NOT: OpCapability FragmentShaderPixelInterlockEXT +; CHECK-NOT: OpCapability FragmentShaderSampleInterlockEXT +; CHECK: OpCapability FragmentShaderShadingRateInterlockEXT +; CHECK: OpExtension "SPV_EXT_fragment_shader_interlock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %main ShadingRateInterlockUnorderedEXT + %void = OpTypeVoid + %1 = OpTypeFunction %void + %2 = OpFunction %void None %1 + %3 = OpLabel + OpBeginInvocationInterlockEXT + OpEndInvocationInterlockEXT + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Int64_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Int64 +; CHECK-NOT: OpCapability Int64 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Int64_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Int64 +; CHECK: OpCapability Int64 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %int = OpTypeInt 64 0 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, RayQueryKHR_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Shader + OpCapability RayQueryKHR + OpExtension "SPV_KHR_ray_query" +; CHECK-NOT: OpCapability RayQueryKHR +; CHECK-NOT: OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %out_var_TEXCOORD1 + OpSource HLSL 660 + OpName %out_var_TEXCOORD1 "out.var.TEXCOORD1" + OpName %main "main" + OpDecorate %out_var_TEXCOORD1 Flat + OpDecorate %out_var_TEXCOORD1 Location 0 + %uint = OpTypeInt 32 0 + %uint_1234 = OpConstant %uint 1234 +%_ptr_Output_uint = OpTypePointer Output %uint + %void = OpTypeVoid + %7 = OpTypeFunction %void +%out_var_TEXCOORD1 = OpVariable %_ptr_Output_uint Output + %main = OpFunction %void None %7 + %8 = OpLabel + OpStore %out_var_TEXCOORD1 %uint_1234 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + RayQueryKHR_RemainsWhenAccelerationStructureIsPresent) { + const std::string kTest = R"( + OpCapability Shader + OpCapability RayQueryKHR + OpExtension "SPV_KHR_ray_query" +; CHECK: OpCapability RayQueryKHR +; CHECK: OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + OpDecorate %var_bvh DescriptorSet 0 + OpDecorate %var_bvh Binding 0 + %bvh = OpTypeAccelerationStructureKHR + %ptr_bvh = OpTypePointer UniformConstant %bvh + %void = OpTypeVoid + %20 = OpTypeFunction %void + %var_bvh = OpVariable %ptr_bvh UniformConstant + %main = OpFunction %void None %20 + %30 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, RayQueryKHR_RemainsWhenRayQueryTypeIsPresent) { + const std::string kTest = R"( + OpCapability Shader + OpCapability RayQueryKHR + OpExtension "SPV_KHR_ray_query" +; CHECK: OpCapability RayQueryKHR +; CHECK: OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %query = OpTypeRayQueryKHR + %void = OpTypeVoid + %20 = OpTypeFunction %void + %ptr_query = OpTypePointer Function %query + %main = OpFunction %void None %20 + %30 = OpLabel + %var_query = OpVariable %ptr_query Function + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, RayQueryKHR_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability RayQueryKHR + OpExtension "SPV_KHR_ray_query" +; CHECK: OpCapability RayQueryKHR +; CHECK: OpExtension "SPV_KHR_ray_query" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + OpDecorate %bvh DescriptorSet 0 + OpDecorate %bvh Binding 0 + OpDecorate %output DescriptorSet 0 + OpDecorate %output Binding 1 + OpDecorate %_runtimearr_float ArrayStride 4 + OpMemberDecorate %type_RWStructuredBuffer_float 0 Offset 0 + OpDecorate %type_RWStructuredBuffer_float BufferBlock + %float = OpTypeFloat 32 + %float_0 = OpConstant %float 0 + %int = OpTypeInt 32 1 + %v3float = OpTypeVector %float 3 + %12 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%accelerationStructureKHR = OpTypeAccelerationStructureKHR +%_ptr_UniformConstant_accelerationStructureKHR = OpTypePointer UniformConstant %accelerationStructureKHR +%_runtimearr_float = OpTypeRuntimeArray %float +%type_RWStructuredBuffer_float = OpTypeStruct %_runtimearr_float +%_ptr_Uniform_type_RWStructuredBuffer_float = OpTypePointer Uniform %type_RWStructuredBuffer_float + %void = OpTypeVoid + %20 = OpTypeFunction %void +%rayQueryKHR = OpTypeRayQueryKHR +%_ptr_Function_rayQueryKHR = OpTypePointer Function %rayQueryKHR + %bool = OpTypeBool +%_ptr_Uniform_float = OpTypePointer Uniform %float + %bvh = OpVariable %_ptr_UniformConstant_accelerationStructureKHR UniformConstant + %output = OpVariable %_ptr_Uniform_type_RWStructuredBuffer_float Uniform + %main = OpFunction %void None %20 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_rayQueryKHR Function + %26 = OpLoad %accelerationStructureKHR %bvh + OpRayQueryInitializeKHR %25 %26 %uint_0 %uint_0 %12 %float_0 %12 %float_0 + %27 = OpRayQueryProceedKHR %bool %25 + %28 = OpRayQueryGetIntersectionTypeKHR %uint %25 %uint_1 + %29 = OpIEqual %bool %28 %uint_1 + OpSelectionMerge %30 None + OpBranchConditional %29 %31 %30 + %31 = OpLabel + %32 = OpAccessChain %_ptr_Uniform_float %output %int_0 %uint_0 + OpStore %32 %float_0 + OpBranch %30 + %30 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + RayTracingKHR_RemainsWithIntersectionExecutionMode) { + const std::string kTest = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint IntersectionKHR %main "main" + OpSource HLSL 660 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %4 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + RayTracingKHR_RemainsWithClosestHitExecutionMode) { + const std::string kTest = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint ClosestHitKHR %main "main" %a + OpSource HLSL 630 + OpName %Payload "Payload" + OpMemberName %Payload 0 "color" + OpName %a "a" + OpName %main "main" + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %Payload = OpTypeStruct %v4float +%ptr_payload = OpTypePointer IncomingRayPayloadKHR %Payload + %void = OpTypeVoid + %8 = OpTypeFunction %void + %a = OpVariable %ptr_payload IncomingRayPayloadKHR + %main = OpFunction %void None %8 + %9 = OpLabel + %10 = OpLoad %Payload %a + OpStore %a %10 + OpReturn + OpFunctionEnd + + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, RayTracingKHR_RemainsWithAnyHitExecutionMode) { + const std::string kTest = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint AnyHitKHR %main "main" %a + OpSource HLSL 630 + OpName %Payload "Payload" + OpMemberName %Payload 0 "color" + OpName %a "a" + OpName %main "main" + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %Payload = OpTypeStruct %v4float +%ptr_payload = OpTypePointer IncomingRayPayloadKHR %Payload + %void = OpTypeVoid + %8 = OpTypeFunction %void + %a = OpVariable %ptr_payload IncomingRayPayloadKHR + %main = OpFunction %void None %8 + %9 = OpLabel + %10 = OpLoad %Payload %a + OpStore %a %10 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, RayTracingKHR_RemainsWithMissExecutionMode) { + const std::string kTest = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint MissKHR %main "main" %a + OpSource HLSL 630 + OpName %Payload "Payload" + OpMemberName %Payload 0 "color" + OpName %a "a" + OpName %main "main" + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %Payload = OpTypeStruct %v4float +%ptr_payload = OpTypePointer IncomingRayPayloadKHR %Payload + %void = OpTypeVoid + %8 = OpTypeFunction %void + %a = OpVariable %ptr_payload IncomingRayPayloadKHR + %main = OpFunction %void None %8 + %9 = OpLabel + %10 = OpLoad %Payload %a + OpStore %a %10 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + RayTracingKHR_RemainsWithRayGenerationExecutionMode) { + const std::string kTest = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint RayGenerationKHR %main "main" + OpSource HLSL 630 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %4 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + RayTracingKHR_RemainsWithCallableExecutionMode) { + const std::string kTest = R"( +; CHECK: OpCapability RayTracingKHR +; CHECK: OpExtension "SPV_KHR_ray_tracing" + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint CallableKHR %main "main" %a + OpSource HLSL 660 + OpName %Payload "Payload" + OpMemberName %Payload 0 "data" + OpName %a "a" + OpName %main "main" + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %Payload = OpTypeStruct %v4float +%ptr_payload = OpTypePointer IncomingCallableDataKHR %Payload + %void = OpTypeVoid + %8 = OpTypeFunction %void + %a = OpVariable %ptr_payload IncomingCallableDataKHR + %main = OpFunction %void None %8 + %9 = OpLabel + %10 = OpLoad %Payload %a + OpStore %a %10 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + ImageMSArray_RemainsIfSampledIs2AndArrayedIs1) { + const std::string kTest = R"( + OpCapability ImageMSArray + ; CHECK: OpCapability ImageMSArray + OpCapability Shader + OpCapability StorageImageMultisample + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v2uint = OpTypeVector %u32 2 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 1 1 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v2uint %uint_1 %uint_2 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 Sample %uint_2 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, ImageMSArray_RemovedIfNotUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability ImageMSArray +; CHECK-NOT: OpCapability ImageMSArray + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %out_var_SV_Target + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 660 + OpName %out_var_SV_Target "out.var.SV_Target" + OpName %main "main" + OpDecorate %out_var_SV_Target Location 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %7 = OpTypeFunction %void +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %7 + %8 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, ImageMSArray_RemovedIfArrayedIsNot1) { + const std::string kTest = R"( + OpCapability ImageMSArray + ; CHECK-NOT: OpCapability ImageMSArray + OpCapability Shader + OpCapability StorageImageMultisample + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v2uint = OpTypeVector %u32 2 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 0 1 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v2uint %uint_1 %uint_2 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 Sample %uint_2 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, ImageMSArray_RemovedIfSampledNot2) { + const std::string kTest = R"( + OpCapability ImageMSArray + ; CHECK-NOT: OpCapability ImageMSArray + OpCapability Shader + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_3 = OpConstant %u32 3 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v3uint = OpTypeVector %u32 3 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 1 0 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Float64_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Float64 +; CHECK-NOT: OpCapability Float64 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Float64_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Float64 +; CHECK: OpCapability Float64 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %float = OpTypeFloat 64 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + ComputeDerivativeGroupQuads_ReamainsWithExecMode) { + const std::string kTest = R"( + OpCapability ComputeDerivativeGroupQuadsKHR + OpCapability ComputeDerivativeGroupLinearKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupLinearKHR +; CHECK: OpCapability ComputeDerivativeGroupQuadsKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupLinearKHR + OpCapability Shader +; CHECK: OpExtension "SPV_NV_compute_shader_derivatives" + OpExtension "SPV_NV_compute_shader_derivatives" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %1 DerivativeGroupQuadsNV + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + ComputeDerivativeGroupLinear_ReamainsWithExecMode) { + const std::string kTest = R"( + OpCapability ComputeDerivativeGroupLinearKHR + OpCapability ComputeDerivativeGroupQuadsKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupQuadsKHR +; CHECK: OpCapability ComputeDerivativeGroupLinearKHR +; CHECK-NOT: OpCapability ComputeDerivativeGroupQuadsKHR + OpCapability Shader +; CHECK: OpExtension "SPV_NV_compute_shader_derivatives" + OpExtension "SPV_NV_compute_shader_derivatives" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + OpExecutionMode %1 DerivativeGroupLinearNV + %void = OpTypeVoid + %float = OpTypeFloat 64 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageReadWithoutFormat_RemovedIfUnused) { + const std::string kTest = R"( + OpCapability StorageImageReadWithoutFormat +; CHECK-NOT: OpCapability StorageImageReadWithoutFormat + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %out_var + OpExecutionMode %PSMain OriginUpperLeft + OpDecorate %out_var Location 0 + %float = OpTypeFloat 32 + %float4 = OpTypeVector %float 4 + %float_0 = OpConstant %float 0 +%float4_0000 = OpConstantComposite %float4 %float_0 %float_0 %float_0 %float_0 + %ptr_float4 = OpTypePointer Output %float4 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %out_var = OpVariable %ptr_float4 Output + %PSMain = OpFunction %void None %9 + %10 = OpLabel + OpStore %out_var %float4_0000 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageReadWithoutFormat_RemovedIfUnusedOpImageFetch) { + const std::string kTest = R"( + OpCapability StorageImageReadWithoutFormat +; CHECK-NOT: OpCapability StorageImageReadWithoutFormat + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %out_var + OpExecutionMode %PSMain OriginUpperLeft + OpDecorate %out_var Location 0 + OpDecorate %texture DescriptorSet 0 + OpDecorate %texture Binding 1 + %float = OpTypeFloat 32 + %float4 = OpTypeVector %float 4 + %int = OpTypeInt 32 1 + %int2 = OpTypeVector %int 2 + %type_image = OpTypeImage %float 2D 2 0 0 1 Unknown + %ptr_image = OpTypePointer UniformConstant %type_image + %int_0 = OpConstant %int 0 + %int2_00 = OpConstantComposite %int2 %int_0 %int_0 + %ptr_float4 = OpTypePointer Output %float4 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %texture = OpVariable %ptr_image UniformConstant + %out_var = OpVariable %ptr_float4 Output + %PSMain = OpFunction %void None %9 + %10 = OpLabel + %11 = OpLoad %type_image %texture + %12 = OpImageFetch %float4 %11 %int2_00 Lod %int_0 + OpStore %out_var %12 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageReadWithoutFormat_RemainsWhenRequiredWithRead) { + const std::string kTest = R"( + OpCapability StorageImageReadWithoutFormat +; CHECK: OpCapability StorageImageReadWithoutFormat + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %out_var + OpExecutionMode %PSMain OriginUpperLeft + OpDecorate %out_var Location 0 + OpDecorate %texture DescriptorSet 0 + OpDecorate %texture Binding 1 + %float = OpTypeFloat 32 + %float4 = OpTypeVector %float 4 + %int = OpTypeInt 32 1 + %int2 = OpTypeVector %int 2 + %type_image = OpTypeImage %float 2D 2 0 0 1 Unknown + %ptr_image = OpTypePointer UniformConstant %type_image + %int_0 = OpConstant %int 0 + %int2_00 = OpConstantComposite %int2 %int_0 %int_0 + %ptr_float4 = OpTypePointer Output %float4 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %texture = OpVariable %ptr_image UniformConstant + %out_var = OpVariable %ptr_float4 Output + %PSMain = OpFunction %void None %9 + %10 = OpLabel + %11 = OpLoad %type_image %texture + %12 = OpImageRead %float4 %11 %int2_00 Lod %int_0 + OpStore %out_var %12 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageReadWithoutFormat_RemainsWhenRequiredWithSparseRead) { + const std::string kTest = R"( + OpCapability StorageImageReadWithoutFormat +; CHECK: OpCapability StorageImageReadWithoutFormat + OpCapability SparseResidency + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" + OpExecutionMode %PSMain OriginUpperLeft + OpDecorate %texture DescriptorSet 0 + OpDecorate %texture Binding 1 + %float = OpTypeFloat 32 + %float4 = OpTypeVector %float 4 + %int = OpTypeInt 32 1 + %int2 = OpTypeVector %int 2 + %type_image = OpTypeImage %float 2D 2 0 0 2 Unknown + %struct = OpTypeStruct %int %float4 + %ptr_image = OpTypePointer UniformConstant %type_image + %int_0 = OpConstant %int 0 + %int2_00 = OpConstantComposite %int2 %int_0 %int_0 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %texture = OpVariable %ptr_image UniformConstant + %PSMain = OpFunction %void None %9 + %10 = OpLabel + %11 = OpLoad %type_image %texture + %12 = OpImageSparseRead %struct %11 %int2_00 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageReadWithoutFormat_RemovedWithReadOnSubpassData) { + const std::string kTest = R"( + OpCapability StorageImageReadWithoutFormat +; CHECK-NOT: OpCapability StorageImageReadWithoutFormat + OpCapability InputAttachment + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %PSMain "PSMain" %out_var + OpExecutionMode %PSMain OriginUpperLeft + OpDecorate %out_var Location 0 + OpDecorate %texture DescriptorSet 0 + OpDecorate %texture Binding 1 + %float = OpTypeFloat 32 + %float4 = OpTypeVector %float 4 + %int = OpTypeInt 32 1 + %int2 = OpTypeVector %int 2 + %type_image = OpTypeImage %float SubpassData 2 0 0 2 Unknown + %ptr_image = OpTypePointer UniformConstant %type_image + %int_0 = OpConstant %int 0 + %int2_00 = OpConstantComposite %int2 %int_0 %int_0 + %ptr_float4 = OpTypePointer Output %float4 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %texture = OpVariable %ptr_image UniformConstant + %out_var = OpVariable %ptr_float4 Output + %PSMain = OpFunction %void None %9 + %10 = OpLabel + %11 = OpLoad %type_image %texture + %12 = OpImageRead %float4 %11 %int2_00 + OpStore %out_var %12 + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageWriteWithoutFormat_RemainsWhenRequiredWithWrite) { + const std::string kTest = R"( + OpCapability StorageImageWriteWithoutFormat +; CHECK: OpCapability StorageImageWriteWithoutFormat + OpCapability Shader + OpCapability StorageImageExtendedFormats + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %id %img + OpExecutionMode %main LocalSize 8 8 8 + OpSource HLSL 670 + OpName %type_image "type.3d.image" + OpName %img "img" + OpName %main "main" + OpDecorate %id BuiltIn GlobalInvocationId + OpDecorate %img DescriptorSet 0 + OpDecorate %img Binding 0 + %float = OpTypeFloat 32 + %float_4 = OpConstant %float 4 + %float_5 = OpConstant %float 5 + %v2float = OpTypeVector %float 2 + %9 = OpConstantComposite %v2float %float_4 %float_5 + %type_image = OpTypeImage %float 3D 2 0 0 2 Unknown + %ptr_img = OpTypePointer UniformConstant %type_image + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %ptr_input = OpTypePointer Input %v3uint + %void = OpTypeVoid + %15 = OpTypeFunction %void + %img = OpVariable %ptr_img UniformConstant + %id = OpVariable %ptr_input Input + %main = OpFunction %void None %15 + %16 = OpLabel + %17 = OpLoad %v3uint %id + %18 = OpLoad %type_image %img + OpImageWrite %18 %17 %9 None + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + StorageImageWriteWithoutFormat_RemovedWithWriteOnKnownFormat) { + const std::string kTest = R"( + OpCapability StorageImageWriteWithoutFormat +; CHECK-NOT: OpCapability StorageImageWriteWithoutFormat + OpCapability Shader + OpCapability StorageImageExtendedFormats + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %id %img + OpExecutionMode %main LocalSize 8 8 8 + OpSource HLSL 670 + OpName %type_image "type.3d.image" + OpName %img "img" + OpName %main "main" + OpDecorate %id BuiltIn GlobalInvocationId + OpDecorate %img DescriptorSet 0 + OpDecorate %img Binding 0 + %float = OpTypeFloat 32 + %float_4 = OpConstant %float 4 + %float_5 = OpConstant %float 5 + %v2float = OpTypeVector %float 2 + %9 = OpConstantComposite %v2float %float_4 %float_5 + %type_image = OpTypeImage %float 3D 2 0 0 2 Rg32f + %ptr_img = OpTypePointer UniformConstant %type_image + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %ptr_input = OpTypePointer Input %v3uint + %void = OpTypeVoid + %15 = OpTypeFunction %void + %img = OpVariable %ptr_img UniformConstant + %id = OpVariable %ptr_input Input + %main = OpFunction %void None %15 + %16 = OpLabel + %17 = OpLoad %v3uint %id + %18 = OpLoad %type_image %img + OpImageWrite %18 %17 %9 None + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, PhysicalStorageBuffer_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability PhysicalStorageBufferAddresses +; CHECK-NOT: OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + PhysicalStorageBuffer_RemainsWithOpTypeForwardPointer) { + const std::string kTest = R"( + OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %int = OpTypeInt 32 0 + %struct = OpTypeStruct %int + OpTypeForwardPointer %ptr PhysicalStorageBuffer + %ptr = OpTypePointer PhysicalStorageBuffer %struct + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + PhysicalStorageBuffer_RemainsWithPhysicalStorageBufferStorage) { + const std::string kTest = R"( + OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %int = OpTypeInt 32 0 + %struct = OpTypeStruct %int + %ptr = OpTypePointer PhysicalStorageBuffer %struct + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + PhysicalStorageBuffer_RemainsWithRestrictDecoration) { + const std::string kTest = R"( + OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + OpDecorate %var RestrictPointer + %void = OpTypeVoid + %int = OpTypeInt 32 0 + %struct = OpTypeStruct %int + %ptr = OpTypePointer Function %struct + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %var = OpVariable %ptr Function + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + PhysicalStorageBuffer_RemainsWithAliasedDecoration) { + const std::string kTest = R"( + OpCapability PhysicalStorageBufferAddresses +; CHECK: OpCapability PhysicalStorageBufferAddresses + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + OpDecorate %var AliasedPointer + %void = OpTypeVoid + %int = OpTypeInt 32 0 + %struct = OpTypeStruct %int + %ptr = OpTypePointer Function %struct + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %var = OpVariable %ptr Function + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, Float16_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Float16 +; CHECK-NOT: OpCapability Float16 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Float16_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Float16 +; CHECK: OpCapability Float16 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %float = OpTypeFloat 16 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, Int16_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Int16 +; CHECK-NOT: OpCapability Int16 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, Int16_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Int16 +; CHECK: OpCapability Int16 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %int = OpTypeInt 16 1 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, UInt16_RemainsWhenUsed) { + const std::string kTest = R"( + OpCapability Int16 +; CHECK: OpCapability Int16 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %uint = OpTypeInt 16 0 + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, + VulkanMemoryModelDeviceScope_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability VulkanMemoryModelDeviceScope +; CHECK-NOT: OpCapability VulkanMemoryModelDeviceScope + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %1 = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + VulkanMemoryModelDeviceScope_RemovedWhenUsedWithGLSL450) { + const std::string kTest = R"( + OpCapability VulkanMemoryModelDeviceScope +; CHECK-NOT: OpCapability VulkanMemoryModelDeviceScope + OpCapability Shader + OpCapability ShaderClockKHR + OpCapability Int64 + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_1 = OpConstant %uint 1 + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %22 = OpReadClockKHR %ulong %uint_1 ; Device Scope + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + VulkanMemoryModelDeviceScope_RemainsWhenUsedWithVulkan) { + const std::string kTest = R"( + OpCapability VulkanMemoryModelDeviceScope +; CHECK: OpCapability VulkanMemoryModelDeviceScope + OpCapability Shader + OpCapability ShaderClockKHR + OpCapability Int64 + OpExtension "SPV_KHR_shader_clock" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_1 = OpConstant %uint 1 + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %22 = OpReadClockKHR %ulong %uint_1 ; Device Scope + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +TEST_F(TrimCapabilitiesPassTest, GroupNonUniform_RemovedWhenUnused) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniform_RemainsGroupNonUniformWhenInUse) { + const std::string kTest = R"( + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK: OpCapability GroupNonUniform + OpCapability Shader + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformElect %bool %scope_subgroup + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformVote_Remains_OpGroupNonUniformAll) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformAll %bool %scope_subgroup %true + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformVote_Remains_OpGroupNonUniformAny) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformAny %bool %scope_subgroup %true + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformArithmetic_Remains_OpGroupNonUniformIAdd_Reduce) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformIAdd %uint %scope_subgroup Reduce %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformArithmetic_Remains_OpGroupNonUniformIAdd_InclusiveScan) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformIAdd %uint %scope_subgroup InclusiveScan %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformArithmetic_Remains_OpGroupNonUniformIAdd_ExclusiveScan) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformIAdd %uint %scope_subgroup ExclusiveScan %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + GroupNonUniformClustered_Remains_OpGroupNonUniformIAdd_ClusteredReduce) { + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = OpGroupNonUniformIAdd %uint %scope_subgroup ClusteredReduce %uint_1 %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +struct SubgroupTestCase { + // The result type of the subgroup instruction. + std::string resultType; + // The opcode of the subgroup instruction. + std::string opcode; + // The actual operand of the subgroup instruction. + std::string operand; +}; + +static const std::vector kSubgroupTestCases{ + // clang-format off + { "uint", "OpGroupNonUniformIAdd", "uint_1" }, + { "float", "OpGroupNonUniformFAdd", "float_1" }, + { "uint", "OpGroupNonUniformIMul", "uint_1" }, + { "float", "OpGroupNonUniformFMul", "float_1" }, + { "int", "OpGroupNonUniformSMin", "int_1" }, + { "uint", "OpGroupNonUniformUMin", "uint_1" }, + { "float", "OpGroupNonUniformFMin", "float_1" }, + { "int", "OpGroupNonUniformSMax", "int_1" }, + { "uint", "OpGroupNonUniformUMax", "uint_1" }, + { "float", "OpGroupNonUniformFMax", "float_1" }, + { "uint", "OpGroupNonUniformBitwiseAnd", "uint_1" }, + { "uint", "OpGroupNonUniformBitwiseOr", "uint_1" }, + { "uint", "OpGroupNonUniformBitwiseXor", "uint_1" }, + { "bool", "OpGroupNonUniformLogicalAnd", "true" }, + { "bool", "OpGroupNonUniformLogicalOr", "true" }, + { "bool", "OpGroupNonUniformLogicalXor", "true" } + // clang-format on +}; + +using TrimCapabilitiesPassTestSubgroupNV_Unsigned = PassTest< + ::testing::TestWithParam>>; +TEST_P(TrimCapabilitiesPassTestSubgroupNV_Unsigned, + GroupNonUniformPartitionedNV_Remains) { + SubgroupTestCase test_case = std::get<0>(GetParam()); + const std::string operation = std::get<1>(GetParam()); + + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %v4uint = OpTypeVector %uint 4 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %uint4_1111 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = )" + test_case.opcode + + " %" + test_case.resultType + " %scope_subgroup " + + operation + " %" + test_case.operand + + R"( %uint4_1111 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +INSTANTIATE_TEST_SUITE_P( + TrimCapabilitiesPassTestSubgroupNV_Unsigned_I, + TrimCapabilitiesPassTestSubgroupNV_Unsigned, + ::testing::Combine(::testing::ValuesIn(kSubgroupTestCases), + ::testing::Values("PartitionedReduceNV", + "PartitionedInclusiveScanNV", + "PartitionedExclusiveScanNV")), + [](const ::testing::TestParamInfo< + TrimCapabilitiesPassTestSubgroupNV_Unsigned::ParamType>& info) { + return std::get<0>(info.param).opcode + "_" + std::get<1>(info.param); + }); + +using TrimCapabilitiesPassTestSubgroupArithmetic_Unsigned = PassTest< + ::testing::TestWithParam>>; +TEST_P(TrimCapabilitiesPassTestSubgroupArithmetic_Unsigned, + GroupNonUniformPartitionedArithmetic_Remains) { + SubgroupTestCase test_case = std::get<0>(GetParam()); + const std::string operation = std::get<1>(GetParam()); + + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK-NOT: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %v4uint = OpTypeVector %uint 4 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %uint4_1111 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = )" + test_case.opcode + + " %" + test_case.resultType + " %scope_subgroup " + + operation + " %" + test_case.operand + R"( %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +INSTANTIATE_TEST_SUITE_P( + TrimCapabilitiesPassTestSubgroupArithmetic_Unsigned_I, + TrimCapabilitiesPassTestSubgroupArithmetic_Unsigned, + ::testing::Combine(::testing::ValuesIn(kSubgroupTestCases), + ::testing::Values("Reduce", "InclusiveScan", + "ExclusiveScan")), + [](const ::testing::TestParamInfo< + TrimCapabilitiesPassTestSubgroupArithmetic_Unsigned::ParamType>& info) { + return std::get<0>(info.param).opcode + "_" + std::get<1>(info.param); + }); + +using TrimCapabilitiesPassTestSubgroupClustered_Unsigned = PassTest< + ::testing::TestWithParam>>; +TEST_P(TrimCapabilitiesPassTestSubgroupClustered_Unsigned, + GroupNonUniformPartitionedClustered_Remains) { + SubgroupTestCase test_case = std::get<0>(GetParam()); + const std::string operation = std::get<1>(GetParam()); + + const std::string kTest = R"( + OpCapability Shader + OpCapability GroupNonUniformVote +; CHECK-NOT: OpCapability GroupNonUniformVote + OpCapability GroupNonUniformArithmetic +; CHECK-NOT: OpCapability GroupNonUniformArithmetic + OpCapability GroupNonUniformClustered +; CHECK: OpCapability GroupNonUniformClustered + OpCapability GroupNonUniformPartitionedNV +; CHECK-NOT: OpCapability GroupNonUniformPartitionedNV + OpCapability GroupNonUniform +; CHECK-NOT: OpCapability GroupNonUniform + OpExtension "SPV_NV_shader_subgroup_partitioned" +; CHECK-NOT: OpExtension "SPV_NV_shader_subgroup_partitioned" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 2 4 + %void = OpTypeVoid + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %v4uint = OpTypeVector %uint 4 + %scope_subgroup = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %uint4_1111 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 + %true = OpConstantTrue %bool + %3 = OpTypeFunction %void + %main = OpFunction %void None %3 + %6 = OpLabel + %7 = )" + test_case.opcode + + " %" + test_case.resultType + " %scope_subgroup " + + operation + " %" + test_case.operand + R"( %uint_1 + OpReturn + OpFunctionEnd; + )"; + const auto result = SinglePassRunAndMatch( + kTest, /* do_validation= */ true); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, InterpolationFunction_RemovedIfNotUsed) { + const std::string kTest = R"( + OpCapability Shader + OpCapability InterpolationFunction +; CHECK-NOT: OpCapability InterpolationFunction + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %out_var_SV_Target + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 660 + OpName %out_var_SV_Target "out.var.SV_Target" + OpName %main "main" + OpDecorate %out_var_SV_Target Location 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %7 = OpTypeFunction %void +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %7 + %8 = OpLabel + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange); +} + +TEST_F(TrimCapabilitiesPassTest, + InterpolationFunction_RemainsWithInterpolateAtCentroid) { + const std::string kTest = R"( + OpCapability Shader + OpCapability InterpolationFunction +; CHECK: OpCapability InterpolationFunction + %std450 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %out_var_SV_Target %gl_PointCoord + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 660 + OpName %out_var_SV_Target "out.var.SV_Target" + OpName %main "main" + OpDecorate %out_var_SV_Target Location 0 + OpDecorate %gl_PointCoord BuiltIn PointCoord + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_ptr_Input_v2float = OpTypePointer Input %v2float + %void = OpTypeVoid + %7 = OpTypeFunction %void +%out_var_SV_Target = OpVariable %_ptr_Output_v4float Output +%gl_PointCoord = OpVariable %_ptr_Input_v2float Input + %main = OpFunction %void None %7 + %8 = OpLabel + %9 = OpExtInst %v4float %std450 InterpolateAtCentroid %gl_PointCoord + OpReturn + OpFunctionEnd + )"; + const auto result = + SinglePassRunAndMatch(kTest, /* skip_nop= */ false); + EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange); +} + +INSTANTIATE_TEST_SUITE_P( + TrimCapabilitiesPassTestSubgroupClustered_Unsigned_I, + TrimCapabilitiesPassTestSubgroupClustered_Unsigned, + ::testing::Combine(::testing::ValuesIn(kSubgroupTestCases), + ::testing::Values("ClusteredReduce")), + [](const ::testing::TestParamInfo< + TrimCapabilitiesPassTestSubgroupClustered_Unsigned::ParamType>& info) { + return std::get<0>(info.param).opcode + "_" + std::get<1>(info.param); + }); + +} // namespace +} // namespace opt +} // namespace spvtools diff --git a/third_party/spirv-tools/test/opt/type_manager_test.cpp b/third_party/spirv-tools/test/opt/type_manager_test.cpp index bc80050c37..0a8e0c7d8e 100644 --- a/third_party/spirv-tools/test/opt/type_manager_test.cpp +++ b/third_party/spirv-tools/test/opt/type_manager_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2016 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,8 +14,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "source/opt/type_manager.h" + #include -#include #include #include @@ -22,7 +25,6 @@ #include "gtest/gtest.h" #include "source/opt/build_module.h" #include "source/opt/instruction.h" -#include "source/opt/type_manager.h" #include "spirv-tools/libspirv.hpp" namespace spvtools { @@ -171,8 +173,16 @@ std::vector> GenerateAllTypes() { types.emplace_back(new NamedBarrier()); types.emplace_back(new AccelerationStructureNV()); types.emplace_back(new CooperativeMatrixNV(f32, 24, 24, 24)); + types.emplace_back(new CooperativeMatrixKHR(f32, 8, 8, 8, 1002)); types.emplace_back(new RayQueryKHR()); types.emplace_back(new HitObjectNV()); + types.emplace_back(new CooperativeVectorNV(f32, 16)); + + // SPV_AMDX_shader_enqueue + types.emplace_back(new NodePayloadArrayAMDX(sts32f32)); + + types.emplace_back(new TensorLayoutNV(1002, 1000)); + types.emplace_back(new TensorViewNV(1002, 1003, {1000, 1001})); return types; } @@ -237,6 +247,8 @@ TEST(TypeManager, TypeStrings) { %arr_long_constant = OpTypeArray %s32 %long_constant %arr_spec_const_op = OpTypeArray %s32 %spec_const_op %cm = OpTypeCooperativeMatrixNV %f64 %id4 %id4 %id4 + %id2 = OpConstant %u32 2 + %cmkhr = OpTypeCooperativeMatrixKHR %f64 %id4 %id4 %id4 %id2 )"; std::vector> type_id_strs = { @@ -275,6 +287,7 @@ TEST(TypeManager, TypeStrings) { {37, "[sint32, id(33), words(0,705032704,1)]"}, {38, "[sint32, id(34), words(2,34)]"}, {39, ""}, + {41, ""}, }; std::unique_ptr context = @@ -938,10 +951,11 @@ OpMemoryModel Logical GLSL450 EXPECT_NE(context, nullptr); std::vector> types = GenerateAllTypes(); - uint32_t id = 1u; + uint32_t id = 0u; for (auto& t : types) { - context->get_type_mgr()->RegisterType(id, *t); + context->get_type_mgr()->RegisterType(++id, *t); EXPECT_EQ(*t, *context->get_type_mgr()->GetType(id)); + EXPECT_EQ(id, context->get_type_mgr()->GetId(t.get())); } types.clear(); @@ -1030,6 +1044,8 @@ TEST(TypeManager, GetTypeInstructionAllTypes) { ; CHECK: [[uint:%\w+]] = OpTypeInt 32 0 ; CHECK: [[input_ptr:%\w+]] = OpTypePointer Input [[uint]] ; CHECK: [[uniform_ptr:%\w+]] = OpTypePointer Uniform [[uint]] +; CHECK: [[uint2:%\w+]] = OpConstant [[uint]] 2 +; CHECK: [[uint8:%\w+]] = OpConstant [[uint]] 8 ; CHECK: [[uint24:%\w+]] = OpConstant [[uint]] 24 ; CHECK: [[uint42:%\w+]] = OpConstant [[uint]] 42 ; CHECK: [[uint100:%\w+]] = OpConstant [[uint]] 100 @@ -1085,6 +1101,7 @@ TEST(TypeManager, GetTypeInstructionAllTypes) { ; CHECK: OpTypeNamedBarrier ; CHECK: OpTypeAccelerationStructureKHR ; CHECK: OpTypeCooperativeMatrixNV [[f32]] [[uint24]] [[uint24]] [[uint24]] +; CHECK: OpTypeCooperativeMatrixKHR [[f32]] [[uint8]] [[uint8]] [[uint8]] [[uint2]] ; CHECK: OpTypeRayQueryKHR ; CHECK: OpTypeHitObjectNV OpCapability Shader @@ -1094,9 +1111,14 @@ OpMemoryModel Logical GLSL450 %uint = OpTypeInt 32 0 %1 = OpTypePointer Input %uint %2 = OpTypePointer Uniform %uint +%1000 = OpConstant %uint 0 +%1001 = OpConstant %uint 1 +%1002 = OpConstant %uint 2 +%8 = OpConstant %uint 8 %24 = OpConstant %uint 24 %42 = OpConstant %uint 42 %100 = OpConstant %uint 100 +%1003 = OpConstantFalse %bool )"; std::unique_ptr context = @@ -1190,6 +1212,39 @@ OpMemoryModel Logical GLSL450 Match(text, context.get()); } +// Structures containing circular type references +// (from https://github.com/KhronosGroup/SPIRV-Tools/issues/5623). +TEST(TypeManager, CircularPointerToStruct) { + const std::string text = R"( + OpCapability VariablePointers + OpCapability PhysicalStorageBufferAddresses + OpCapability Int64 + OpCapability Shader + OpExtension "SPV_KHR_variable_pointers" + OpExtension "SPV_KHR_physical_storage_buffer" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint Fragment %1 "main" + OpExecutionMode %1 OriginUpperLeft + OpExecutionMode %1 DepthReplacing + OpDecorate %1200 ArrayStride 24 + OpMemberDecorate %600 0 Offset 0 + OpMemberDecorate %800 0 Offset 0 + OpMemberDecorate %120 0 Offset 16 + OpTypeForwardPointer %1200 PhysicalStorageBuffer + %600 = OpTypeStruct %1200 + %800 = OpTypeStruct %1200 + %120 = OpTypeStruct %800 + %1200 = OpTypePointer PhysicalStorageBuffer %120 + )"; + + std::unique_ptr context = + BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text, + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + TypeManager manager(nullptr, context.get()); + uint32_t id = manager.FindPointerToType(600, spv::StorageClass::Function); + EXPECT_EQ(id, 1201); +} + } // namespace } // namespace analysis } // namespace opt diff --git a/third_party/spirv-tools/test/opt/types_test.cpp b/third_party/spirv-tools/test/opt/types_test.cpp index 4352b7cf58..4ceeb1400c 100644 --- a/third_party/spirv-tools/test/opt/types_test.cpp +++ b/third_party/spirv-tools/test/opt/types_test.cpp @@ -391,18 +391,13 @@ TEST(Types, IsUniqueType) { case Type::kArray: case Type::kRuntimeArray: case Type::kStruct: + case Type::kPointer: expectation = false; break; default: break; } - EXPECT_EQ(t->IsUniqueType(false), expectation) - << "expected '" << t->str() << "' to be a " - << (expectation ? "" : "non-") << "unique type"; - - // Allowing variables pointers. - if (t->AsPointer()) expectation = false; - EXPECT_EQ(t->IsUniqueType(true), expectation) + EXPECT_EQ(t->IsUniqueType(), expectation) << "expected '" << t->str() << "' to be a " << (expectation ? "" : "non-") << "unique type"; } diff --git a/third_party/spirv-tools/test/opt/upgrade_memory_model_test.cpp b/third_party/spirv-tools/test/opt/upgrade_memory_model_test.cpp index 2cd3c7dfb5..d213b8be0c 100644 --- a/third_party/spirv-tools/test/opt/upgrade_memory_model_test.cpp +++ b/third_party/spirv-tools/test/opt/upgrade_memory_model_test.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include "assembly_builder.h" -#include "gmock/gmock.h" #include "pass_fixture.h" #include "pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/value_table_test.cpp b/third_party/spirv-tools/test/opt/value_table_test.cpp index c760f98598..3d7aaad5b2 100644 --- a/third_party/spirv-tools/test/opt/value_table_test.cpp +++ b/third_party/spirv-tools/test/opt/value_table_test.cpp @@ -17,7 +17,6 @@ #include "gmock/gmock.h" #include "source/opt/build_module.h" #include "source/opt/value_number_table.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" namespace spvtools { diff --git a/third_party/spirv-tools/test/opt/workaround1209_test.cpp b/third_party/spirv-tools/test/opt/workaround1209_test.cpp index 50d3c09151..5b0146b9ba 100644 --- a/third_party/spirv-tools/test/opt/workaround1209_test.cpp +++ b/third_party/spirv-tools/test/opt/workaround1209_test.cpp @@ -12,15 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include #include #include -#include "gmock/gmock.h" -#include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/opt/wrap_opkill_test.cpp b/third_party/spirv-tools/test/opt/wrap_opkill_test.cpp index e40d701f07..efc834cf04 100644 --- a/third_party/spirv-tools/test/opt/wrap_opkill_test.cpp +++ b/third_party/spirv-tools/test/opt/wrap_opkill_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gmock/gmock.h" #include "test/opt/assembly_builder.h" #include "test/opt/pass_fixture.h" #include "test/opt/pass_utils.h" diff --git a/third_party/spirv-tools/test/reduce/CMakeLists.txt b/third_party/spirv-tools/test/reduce/CMakeLists.txt index 121cd4f08a..d3eaa84642 100644 --- a/third_party/spirv-tools/test/reduce/CMakeLists.txt +++ b/third_party/spirv-tools/test/reduce/CMakeLists.txt @@ -31,6 +31,7 @@ add_spvtools_unittest(TARGET reduce structured_construct_to_block_test.cpp structured_loop_to_selection_test.cpp validation_during_reduction_test.cpp + ${spirv-tools_SOURCE_DIR}/tools/io.cpp LIBS SPIRV-Tools-reduce ) diff --git a/third_party/spirv-tools/test/scripts/test_compact_ids.py b/third_party/spirv-tools/test/scripts/test_compact_ids.py index 6ca6e67b2c..b1d53870d7 100644 --- a/third_party/spirv-tools/test/scripts/test_compact_ids.py +++ b/third_party/spirv-tools/test/scripts/test_compact_ids.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2017 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ def print_usage(): template= \ """{script} tests correctness of opt pass tools/opt --compact-ids -USAGE: python {script} [] +USAGE: python3 {script} [] Requires tools/spirv-dis, tools/spirv-as and tools/spirv-opt to be in path (call the script from the SPIRV-Tools build output directory). diff --git a/third_party/spirv-tools/test/target_env_test.cpp b/third_party/spirv-tools/test/target_env_test.cpp index 7917cbfb44..05898df6ab 100644 --- a/third_party/spirv-tools/test/target_env_test.cpp +++ b/third_party/spirv-tools/test/target_env_test.cpp @@ -79,9 +79,16 @@ INSTANTIATE_TEST_SUITE_P( {"spv1.1", true, SPV_ENV_UNIVERSAL_1_1}, {"spv1.2", true, SPV_ENV_UNIVERSAL_1_2}, {"spv1.3", true, SPV_ENV_UNIVERSAL_1_3}, + {"spv1.4", true, SPV_ENV_UNIVERSAL_1_4}, + {"spv1.5", true, SPV_ENV_UNIVERSAL_1_5}, + {"spv1.6", true, SPV_ENV_UNIVERSAL_1_6}, + {"spv1.7", false, SPV_ENV_UNIVERSAL_1_3}, {"vulkan1.0", true, SPV_ENV_VULKAN_1_0}, {"vulkan1.1", true, SPV_ENV_VULKAN_1_1}, {"vulkan1.2", true, SPV_ENV_VULKAN_1_2}, + {"vulkan1.3", true, SPV_ENV_VULKAN_1_3}, + {"vulkan1.4", true, SPV_ENV_VULKAN_1_4}, + {"vulkan1.5", false, SPV_ENV_UNIVERSAL_1_0}, {"opencl2.1", true, SPV_ENV_OPENCL_2_1}, {"opencl2.2", true, SPV_ENV_OPENCL_2_2}, {"opengl4.0", true, SPV_ENV_OPENGL_4_0}, @@ -170,5 +177,61 @@ INSTANTIATE_TEST_SUITE_P( {VK(99, 0), SPV(1, 0), false, SPV_ENV_UNIVERSAL_1_0}, })); -} // namespace +// A test case for parsing the text header of disassembly. +struct ParseEnvInDisassemblyCase { + std::string text; + bool success; // Expect to successfully parse? + spv_target_env env; // The parsed environment, if successful. +}; + +using TargetParseEnvInDisassemblyTest = + ::testing::TestWithParam; + +constexpr spv_target_env kSentinelEnv = SPV_ENV_OPENCL_2_2; + +TEST_P(TargetParseEnvInDisassemblyTest, Samples) { + const std::string& text = GetParam().text; + const std::vector text_vec(text.begin(), text.end()); + spv_target_env got_env = kSentinelEnv; + bool parsed = spvReadEnvironmentFromText(text_vec, &got_env); + EXPECT_EQ(parsed, GetParam().success); + EXPECT_EQ(got_env, GetParam().env) << '"' << text << '"'; +} + +INSTANTIATE_TEST_SUITE_P( + TargetTextParsing, TargetParseEnvInDisassemblyTest, + ValuesIn(std::vector{ + {"; Version: 1.0", true, SPV_ENV_UNIVERSAL_1_0}, + {"; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1}, + {"; Version: 1.2", true, SPV_ENV_UNIVERSAL_1_2}, + {"; Version: 1.3", true, SPV_ENV_UNIVERSAL_1_3}, + {"; Version: 1.4", true, SPV_ENV_UNIVERSAL_1_4}, + {"; Version: 1.5", true, SPV_ENV_UNIVERSAL_1_5}, + {"; Version: 1.6", true, SPV_ENV_UNIVERSAL_1_6}, + {"; Version: 1.7", false, kSentinelEnv}, + {"; Version: 1.8", false, kSentinelEnv}, + {"; Version: 1.9", false, kSentinelEnv}, + {"; Version: 2.0", false, kSentinelEnv}, + + // Check trailing text + {"; Version: 1.1\n", true, SPV_ENV_UNIVERSAL_1_1}, + {"; Version: 1.1\t", true, SPV_ENV_UNIVERSAL_1_1}, + {"; Version: 1.1 ", true, SPV_ENV_UNIVERSAL_1_1}, + {"; Version: 1.1x", true, SPV_ENV_UNIVERSAL_1_1}, + // Not a digit. + {"; Version: 1.10", false, kSentinelEnv}, + + // Unexpected prefix + {";Version: 1.1", false, kSentinelEnv}, + + // Leading spaces + {" \t ; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1}, + // Previous lines + {"; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1}, + {"; -\n; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1}, + + // After a non-header line + {"OpCapability Shader\n; Version: 1.1", false, kSentinelEnv}})); + +} // anonymous namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/test_fixture.h b/third_party/spirv-tools/test/test_fixture.h index 029fc8543b..424f5eebe6 100644 --- a/third_party/spirv-tools/test/test_fixture.h +++ b/third_party/spirv-tools/test/test_fixture.h @@ -111,13 +111,15 @@ class TextToBinaryTestBase : public T { std::string EncodeAndDecodeSuccessfully( const std::string& txt, uint32_t disassemble_options = SPV_BINARY_TO_TEXT_OPTION_NONE, + uint32_t assemble_options = SPV_TEXT_TO_BINARY_OPTION_NONE, spv_target_env env = SPV_ENV_UNIVERSAL_1_0, bool flip_words = false) { DestroyBinary(); DestroyDiagnostic(); ScopedContext context(env); disassemble_options |= SPV_BINARY_TO_TEXT_OPTION_NO_HEADER; - spv_result_t error = spvTextToBinary(context.context, txt.c_str(), - txt.size(), &binary, &diagnostic); + spv_result_t error = + spvTextToBinaryWithOptions(context.context, txt.c_str(), txt.size(), + assemble_options, &binary, &diagnostic); if (error) { spvDiagnosticPrint(diagnostic); spvDiagnosticDestroy(diagnostic); diff --git a/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp b/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp index 826812bf24..edf886f6c3 100644 --- a/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.annotation_test.cpp @@ -55,10 +55,10 @@ TEST_P(OpDecorateSimpleTest, AnySimpleDecoration) { {1, uint32_t(std::get<1>(GetParam()).value())}, std::get<1>(GetParam()).operands()))); // Also check disassembly. - EXPECT_THAT( - EncodeAndDecodeSuccessfully(input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, - std::get<0>(GetParam())), - Eq(input.str())); + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, std::get<0>(GetParam())), + Eq(input.str())); } // Like above, but parameters to the decoration are IDs. @@ -78,10 +78,10 @@ TEST_P(OpDecorateSimpleIdTest, AnySimpleDecoration) { {1, uint32_t(std::get<1>(GetParam()).value())}, std::get<1>(GetParam()).operands()))); // Also check disassembly. - EXPECT_THAT( - EncodeAndDecodeSuccessfully(input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, - std::get<0>(GetParam())), - Eq(input.str())); + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, std::get<0>(GetParam())), + Eq(input.str())); } #define CASE(NAME) spv::Decoration::NAME, #NAME @@ -460,10 +460,10 @@ TEST_P(OpMemberDecorateSimpleTest, AnySimpleDecoration) { {1, 42, uint32_t(std::get<1>(GetParam()).value())}, std::get<1>(GetParam()).operands()))); // Also check disassembly. - EXPECT_THAT( - EncodeAndDecodeSuccessfully(input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, - std::get<0>(GetParam())), - Eq(input.str())); + EXPECT_THAT(EncodeAndDecodeSuccessfully( + input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, std::get<0>(GetParam())), + Eq(input.str())); } #define CASE(NAME) spv::Decoration::NAME, #NAME diff --git a/third_party/spirv-tools/test/text_to_binary.composite_test.cpp b/third_party/spirv-tools/test/text_to_binary.composite_test.cpp index 6ae1cd35d6..2f255ac46e 100644 --- a/third_party/spirv-tools/test/text_to_binary.composite_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.composite_test.cpp @@ -35,7 +35,8 @@ using CompositeRoundTripTest = RoundTripTest; TEST_F(CompositeRoundTripTest, Good) { std::string spirv = "%2 = OpCopyLogical %1 %3\n"; std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4); + spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_TEXT_TO_BINARY_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_4); EXPECT_THAT(disassembly, Eq(spirv)); } diff --git a/third_party/spirv-tools/test/text_to_binary.extension_test.cpp b/third_party/spirv-tools/test/text_to_binary.extension_test.cpp index 6780c7e834..59f2af9e79 100644 --- a/third_party/spirv-tools/test/text_to_binary.extension_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.extension_test.cpp @@ -130,9 +130,10 @@ TEST_P(ExtensionRoundTripTest, Samples) { EXPECT_THAT(CompiledInstructions(ac.input, env), Eq(ac.expected)); // Check round trip through the disassembler. - EXPECT_THAT(EncodeAndDecodeSuccessfully(ac.input, - SPV_BINARY_TO_TEXT_OPTION_NONE, env), - Eq(ac.input)) + EXPECT_THAT( + EncodeAndDecodeSuccessfully(ac.input, SPV_BINARY_TO_TEXT_OPTION_NONE, + SPV_TEXT_TO_BINARY_OPTION_NONE, env), + Eq(ac.input)) << "target env: " << spvTargetEnvDescription(env) << "\n"; } @@ -1198,5 +1199,182 @@ INSTANTIATE_TEST_SUITE_P( {1, 2, 3, 4, 5, 6})}, }))); +// SPV_EXT_shader_tile_image + +INSTANTIATE_TEST_SUITE_P( + SPV_EXT_shader_tile_image, ExtensionRoundTripTest, + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3), + ValuesIn(std::vector{ + {"OpExtension \"SPV_EXT_shader_tile_image\"\n", + MakeInstruction(spv::Op::OpExtension, + MakeVector("SPV_EXT_shader_tile_image"))}, + {"OpCapability TileImageColorReadAccessEXT\n", + MakeInstruction( + spv::Op::OpCapability, + {(uint32_t)spv::Capability::TileImageColorReadAccessEXT})}, + {"OpCapability TileImageDepthReadAccessEXT\n", + MakeInstruction( + spv::Op::OpCapability, + {(uint32_t)spv::Capability::TileImageDepthReadAccessEXT})}, + {"OpCapability TileImageStencilReadAccessEXT\n", + MakeInstruction( + spv::Op::OpCapability, + {(uint32_t)spv::Capability::TileImageStencilReadAccessEXT})}, + {"OpExecutionMode %1 NonCoherentColorAttachmentReadEXT\n", + MakeInstruction(spv::Op::OpExecutionMode, + {1, (uint32_t)spv::ExecutionMode:: + NonCoherentColorAttachmentReadEXT})}, + {"OpExecutionMode %1 NonCoherentDepthAttachmentReadEXT\n", + MakeInstruction(spv::Op::OpExecutionMode, + {1, (uint32_t)spv::ExecutionMode:: + NonCoherentDepthAttachmentReadEXT})}, + {"OpExecutionMode %1 NonCoherentStencilAttachmentReadEXT\n", + MakeInstruction(spv::Op::OpExecutionMode, + {1, (uint32_t)spv::ExecutionMode:: + NonCoherentStencilAttachmentReadEXT})}, + {"%2 = OpColorAttachmentReadEXT %1 %3\n", + MakeInstruction(spv::Op::OpColorAttachmentReadEXT, {1, 2, 3})}, + {"%2 = OpColorAttachmentReadEXT %1 %3 %4\n", + MakeInstruction(spv::Op::OpColorAttachmentReadEXT, {1, 2, 3, 4})}, + {"%2 = OpDepthAttachmentReadEXT %1\n", + MakeInstruction(spv::Op::OpDepthAttachmentReadEXT, {1, 2})}, + {"%2 = OpDepthAttachmentReadEXT %1 %3\n", + MakeInstruction(spv::Op::OpDepthAttachmentReadEXT, {1, 2, 3})}, + {"%2 = OpStencilAttachmentReadEXT %1\n", + MakeInstruction(spv::Op::OpStencilAttachmentReadEXT, {1, 2})}, + {"%2 = OpStencilAttachmentReadEXT %1 %3\n", + MakeInstruction(spv::Op::OpStencilAttachmentReadEXT, {1, 2, 3})}, + }))); + +// SPV_KHR_maximal_reconvergence + +INSTANTIATE_TEST_SUITE_P( + SPV_KHR_maximal_reconvergence, ExtensionRoundTripTest, + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3), + ValuesIn(std::vector{ + {"OpExtension \"SPV_KHR_maximal_reconvergence\"\n", + MakeInstruction(spv::Op::OpExtension, + MakeVector("SPV_KHR_maximal_reconvergence"))}, + {"OpExecutionMode %1 MaximallyReconvergesKHR\n", + MakeInstruction( + spv::Op::OpExecutionMode, + {1, (uint32_t)spv::ExecutionMode::MaximallyReconvergesKHR})}, + }))); + +// SPV_KHR_float_controls2 + +INSTANTIATE_TEST_SUITE_P( + SPV_KHR_float_controls2, ExtensionRoundTripTest, + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3), + ValuesIn(std::vector{ + {"OpExtension \"SPV_KHR_float_controls2\"\n", + MakeInstruction(spv::Op::OpExtension, + MakeVector("SPV_KHR_float_controls2"))}, + {"OpCapability FloatControls2\n", + MakeInstruction(spv::Op::OpCapability, + {(uint32_t)spv::Capability::FloatControls2})}, + {"OpExecutionMode %1 FPFastMathDefault %2 %3\n", + // The operands are: target type, flags constant + MakeInstruction( + spv::Op::OpExecutionMode, + {1, (uint32_t)spv::ExecutionMode::FPFastMathDefault, 2, 3})}, + {"OpDecorate %1 FPFastMathMode AllowContract\n", + MakeInstruction( + spv::Op::OpDecorate, + {1, (uint32_t)spv::Decoration::FPFastMathMode, + (uint32_t)spv::FPFastMathModeMask::AllowContract})}, + {"OpDecorate %1 FPFastMathMode AllowReassoc\n", + MakeInstruction( + spv::Op::OpDecorate, + {1, (uint32_t)spv::Decoration::FPFastMathMode, + (uint32_t)spv::FPFastMathModeMask::AllowReassoc})}, + {"OpDecorate %1 FPFastMathMode AllowTransform\n", + MakeInstruction( + spv::Op::OpDecorate, + {1, (uint32_t)spv::Decoration::FPFastMathMode, + (uint32_t)spv::FPFastMathModeMask::AllowTransform})}, + }))); + +// SPV_EXT_replicated_composites + +INSTANTIATE_TEST_SUITE_P( + SPV_EXT_replicated_composites, ExtensionRoundTripTest, + Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, + SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, + SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1), + ValuesIn(std::vector{ + {"OpExtension \"SPV_EXT_replicated_composites\"\n", + MakeInstruction(spv::Op::OpExtension, + MakeVector("SPV_EXT_replicated_composites"))}, + {"OpCapability ReplicatedCompositesEXT\n", + MakeInstruction( + spv::Op::OpCapability, + {(uint32_t)spv::Capability::ReplicatedCompositesEXT})}, + {"%2 = OpConstantCompositeReplicateEXT %1 %3\n", + MakeInstruction(spv::Op::OpConstantCompositeReplicateEXT, + {1, 2, 3})}, + {"%2 = OpSpecConstantCompositeReplicateEXT %1 %3\n", + MakeInstruction(spv::Op::OpSpecConstantCompositeReplicateEXT, + {1, 2, 3})}, + {"%2 = OpCompositeConstructReplicateEXT %1 %3\n", + MakeInstruction(spv::Op::OpCompositeConstructReplicateEXT, + {1, 2, 3})}, + }))); + +// SPV_KHR_untyped_pointers +INSTANTIATE_TEST_SUITE_P( + SPV_KHR_untyped_pointers, ExtensionRoundTripTest, + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2), + ValuesIn(std::vector{ + {"OpExtension \"SPV_KHR_untyped_pointers\"\n", + MakeInstruction(spv::Op::OpExtension, + MakeVector("SPV_KHR_untyped_pointers"))}, + {"OpCapability UntypedPointersKHR\n", + MakeInstruction(spv::Op::OpCapability, + {(int)spv::Capability::UntypedPointersKHR})}, + {"OpCapability UntypedPointersKHR\n", + MakeInstruction(spv::Op::OpCapability, {4473})}, + {"%1 = OpTypeUntypedPointerKHR Workgroup\n", + MakeInstruction(spv::Op::OpTypeUntypedPointerKHR, + {1, int(spv::StorageClass::Workgroup)})}, + {"%2 = OpUntypedVariableKHR %1 Workgroup %3\n", + MakeInstruction(spv::Op::OpUntypedVariableKHR, + {1, 2, int(spv::StorageClass::Workgroup), 3})}, + {"%2 = OpUntypedVariableKHR %1 Workgroup %3 %4\n", + MakeInstruction(spv::Op::OpUntypedVariableKHR, + {1, 2, int(spv::StorageClass::Workgroup), 3, 4})}, + {"%2 = OpUntypedAccessChainKHR %1 %3 %4\n", + MakeInstruction(spv::Op::OpUntypedAccessChainKHR, {1, 2, 3, 4})}, + {"%2 = OpUntypedAccessChainKHR %1 %3 %4 %5 %6 %7\n", + MakeInstruction(spv::Op::OpUntypedAccessChainKHR, + {1, 2, 3, 4, 5, 6, 7})}, + {"%2 = OpUntypedInBoundsAccessChainKHR %1 %3 %4\n", + MakeInstruction(spv::Op::OpUntypedInBoundsAccessChainKHR, + {1, 2, 3, 4})}, + {"%2 = OpUntypedInBoundsAccessChainKHR %1 %3 %4 %5 %6 %7\n", + MakeInstruction(spv::Op::OpUntypedInBoundsAccessChainKHR, + {1, 2, 3, 4, 5, 6, 7})}, + {"%2 = OpUntypedPtrAccessChainKHR %1 %3 %4 %5\n", + MakeInstruction(spv::Op::OpUntypedPtrAccessChainKHR, + {1, 2, 3, 4, 5})}, + {"%2 = OpUntypedPtrAccessChainKHR %1 %3 %4 %5 %6 %7\n", + MakeInstruction(spv::Op::OpUntypedPtrAccessChainKHR, + {1, 2, 3, 4, 5, 6, 7})}, + {"%2 = OpUntypedInBoundsPtrAccessChainKHR %1 %3 %4 %5\n", + MakeInstruction(spv::Op::OpUntypedInBoundsPtrAccessChainKHR, + {1, 2, 3, 4, 5})}, + {"%2 = OpUntypedInBoundsPtrAccessChainKHR %1 %3 %4 %5 %6 %7\n", + MakeInstruction(spv::Op::OpUntypedInBoundsPtrAccessChainKHR, + {1, 2, 3, 4, 5, 6, 7})}, + }))); + } // namespace } // namespace spvtools diff --git a/third_party/spirv-tools/test/text_to_binary.memory_test.cpp b/third_party/spirv-tools/test/text_to_binary.memory_test.cpp index 629ab661bf..43523d18a5 100644 --- a/third_party/spirv-tools/test/text_to_binary.memory_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.memory_test.cpp @@ -107,7 +107,8 @@ TEST_F(MemoryRoundTripTest, OpPtrEqualGood) { EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4), Eq(MakeInstruction(spv::Op::OpPtrEqual, {1, 2, 3, 4}))); std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4); + spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_TEXT_TO_BINARY_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_4); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -124,7 +125,8 @@ TEST_F(MemoryRoundTripTest, OpPtrNotEqualGood) { EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4), Eq(MakeInstruction(spv::Op::OpPtrNotEqual, {1, 2, 3, 4}))); std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4); + spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_TEXT_TO_BINARY_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_4); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -141,7 +143,8 @@ TEST_F(MemoryRoundTripTest, OpPtrDiffGood) { EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4), Eq(MakeInstruction(spv::Op::OpPtrDiff, {1, 2, 3, 4}))); std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4); + spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_TEXT_TO_BINARY_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_4); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -151,7 +154,8 @@ TEST_F(MemoryRoundTripTest, OpPtrDiffV13Good) { // write tests. std::string spirv = "%2 = OpPtrDiff %1 %3 %4\n"; std::string disassembly = EncodeAndDecodeSuccessfully( - spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4); + spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_TEXT_TO_BINARY_OPTION_NONE, + SPV_ENV_UNIVERSAL_1_4); } // OpCopyMemory @@ -160,8 +164,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryNoMemAccessGood) { std::string spirv = "OpCopyMemory %1 %2\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -182,8 +185,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNoneGood) { std::string spirv = "OpCopyMemory %1 %2 None\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 0}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -191,8 +193,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVolatileGood) { std::string spirv = "OpCopyMemory %1 %2 Volatile\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -200,8 +201,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAligned8Good) { std::string spirv = "OpCopyMemory %1 %2 Aligned 8\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 2, 8}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -209,8 +209,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNontemporalGood) { std::string spirv = "OpCopyMemory %1 %2 Nontemporal\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -218,8 +217,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAvGood) { std::string spirv = "OpCopyMemory %1 %2 MakePointerAvailable %3\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 8, 3}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -227,8 +225,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVisGood) { std::string spirv = "OpCopyMemory %1 %2 MakePointerVisible %3\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 16, 3}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -236,8 +233,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNonPrivateGood) { std::string spirv = "OpCopyMemory %1 %2 NonPrivatePointer\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 32}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -248,8 +244,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessMixedGood) { "MakePointerVisible|NonPrivatePointer 16 %3 %4\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 63, 16, 3, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -258,8 +253,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessV13Good) { // Note: This will assemble but should not validate for SPIR-V 1.3 EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_3), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -267,8 +261,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessV14Good) { std::string spirv = "OpCopyMemory %1 %2 Volatile Volatile\n"; EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -280,8 +273,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessMixedV14Good) { EXPECT_THAT( CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 21, 3, 42, 16, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -291,8 +283,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedNoMemAccessGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -313,8 +304,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNoneGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3 None\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 0}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -322,8 +312,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVolatileGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3 Volatile\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -331,8 +320,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAligned8Good) { std::string spirv = "OpCopyMemorySized %1 %2 %3 Aligned 8\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 2, 8}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -340,8 +328,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNontemporalGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3 Nontemporal\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -349,8 +336,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAvGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3 MakePointerAvailable %4\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 8, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -359,8 +345,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVisGood) { EXPECT_THAT( CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 16, 4}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -368,8 +353,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNonPrivateGood) { std::string spirv = "OpCopyMemorySized %1 %2 %3 NonPrivatePointer\n"; EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 32}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -381,8 +365,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessMixedGood) { EXPECT_THAT( CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 63, 16, 4, 5}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -391,8 +374,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessV13Good) { // Note: This will assemble but should not validate for SPIR-V 1.3 EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_3), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -400,8 +382,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessV14Good) { std::string spirv = "OpCopyMemorySized %1 %2 %3 Volatile Volatile\n"; EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1, 1}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } @@ -413,8 +394,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessMixedV14Good) { EXPECT_THAT(CompiledInstructions(spirv), Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 21, 4, 42, 16, 5}))); - std::string disassembly = - EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE); + std::string disassembly = EncodeAndDecodeSuccessfully(spirv); EXPECT_THAT(disassembly, Eq(spirv)); } diff --git a/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp b/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp index 2a41d427d9..ef899a2756 100644 --- a/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.pipe_storage_test.cpp @@ -41,7 +41,7 @@ TEST_F(OpTypePipeStorageTest, ArgumentCount) { Eq(MakeInstruction(spv::Op::OpTypePipeStorage, {1}))); EXPECT_THAT(CompileFailure("%res = OpTypePipeStorage %1 %2 %3 %4 %5", SPV_ENV_UNIVERSAL_1_1), - Eq("'=' expected after result id.")); + Eq("'=' expected after result id but found '%2'.")); } using OpConstantPipeStorageTest = spvtest::TextToBinaryTest; @@ -72,7 +72,7 @@ TEST_F(OpConstantPipeStorageTest, ArgumentCount) { Eq(MakeInstruction(spv::Op::OpConstantPipeStorage, {1, 2, 3, 4, 5}))); EXPECT_THAT(CompileFailure("%1 = OpConstantPipeStorage %2 3 4 5 %6 %7", SPV_ENV_UNIVERSAL_1_1), - Eq("'=' expected after result id.")); + Eq("'=' expected after result id but found '%7'.")); } TEST_F(OpConstantPipeStorageTest, ArgumentTypes) { @@ -118,7 +118,7 @@ TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentCount) { Eq(MakeInstruction(spv::Op::OpCreatePipeFromPipeStorage, {1, 2, 3}))); EXPECT_THAT(CompileFailure("%1 = OpCreatePipeFromPipeStorage %2 %3 %4 %5", SPV_ENV_UNIVERSAL_1_1), - Eq("'=' expected after result id.")); + Eq("'=' expected after result id but found '%5'.")); } TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentTypes) { diff --git a/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp b/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp index 241600eeb3..770f298bc6 100644 --- a/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp +++ b/third_party/spirv-tools/test/text_to_binary.type_declaration_test.cpp @@ -59,6 +59,7 @@ INSTANTIATE_TEST_SUITE_P( CASE(Rect), CASE(Buffer), CASE(SubpassData), + CASE(TileImageDataEXT), })); #undef CASE // clang-format on @@ -221,6 +222,7 @@ TEST_F(OpTypeForwardPointerTest, ValidStorageClass) { CASE(AtomicCounter); CASE(Image); CASE(StorageBuffer); + CASE(TileImageEXT); } #undef CASE diff --git a/third_party/spirv-tools/test/to_string_test.cpp b/third_party/spirv-tools/test/to_string_test.cpp new file mode 100644 index 0000000000..5973318e53 --- /dev/null +++ b/third_party/spirv-tools/test/to_string_test.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2024 Google LLC +// +// 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 "source/to_string.h" + +#include "gmock/gmock.h" + +namespace { + +TEST(ToString, Uint32) { + EXPECT_EQ(spvtools::to_string(0u), "0"); + EXPECT_EQ(spvtools::to_string(1u), "1"); + EXPECT_EQ(spvtools::to_string(1234567890u), "1234567890"); + EXPECT_EQ(spvtools::to_string(0xffffffffu), "4294967295"); +} + +} // namespace diff --git a/third_party/spirv-tools/test/tools/CMakeLists.txt b/third_party/spirv-tools/test/tools/CMakeLists.txt index 99f9780c55..37fe2b9786 100644 --- a/third_party/spirv-tools/test/tools/CMakeLists.txt +++ b/third_party/spirv-tools/test/tools/CMakeLists.txt @@ -13,9 +13,19 @@ # limitations under the License. add_test(NAME spirv-tools_expect_unittests - COMMAND ${PYTHON_EXECUTABLE} -m unittest expect_unittest.py + COMMAND Python3::Interpreter -m unittest expect_unittest.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_test(NAME spirv-tools_spirv_test_framework_unittests - COMMAND ${PYTHON_EXECUTABLE} -m unittest spirv_test_framework_unittest.py + COMMAND Python3::Interpreter -m unittest spirv_test_framework_unittest.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +add_spvtools_unittest( + TARGET spirv_unit_test_tools_util + SRCS flags_test.cpp ${spirv-tools_SOURCE_DIR}/tools/util/flags.cpp + LIBS ${SPIRV_TOOLS_FULL_VISIBILITY} + DEFINES TESTING=1) + add_subdirectory(opt) +if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Android")) + add_subdirectory(objdump) +endif () diff --git a/third_party/spirv-tools/test/tools/flags_test.cpp b/third_party/spirv-tools/test/tools/flags_test.cpp new file mode 100644 index 0000000000..43db99676a --- /dev/null +++ b/third_party/spirv-tools/test/tools/flags_test.cpp @@ -0,0 +1,415 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 "tools/util/flags.h" + +#include "gmock/gmock.h" + +#ifdef UTIL_FLAGS_FLAG +#undef UTIL_FLAGS_FLAG +#define UTIL_FLAGS_FLAG(Type, Prefix, Name, Default, Required, IsShort) \ + flags::Flag Name(Default); \ + flags::FlagRegistration Name##_registration(Name, Prefix #Name, Required, \ + IsShort) +#else +#error \ + "UTIL_FLAGS_FLAG is not defined. Either flags.h is not included of the flag name changed." +#endif + +class FlagTest : public ::testing::Test { + protected: + void SetUp() override { flags::FlagList::reset(); } +}; + +TEST_F(FlagTest, NoFlags) { + const char* argv[] = {"binary", nullptr}; + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, DashIsPositional) { + const char* argv[] = {"binary", "-", nullptr}; + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(flags::positional_arguments.size(), 1); + EXPECT_EQ(flags::positional_arguments[0], "-"); +} + +TEST_F(FlagTest, Positional) { + const char* argv[] = {"binary", "A", "BCD", nullptr}; + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(flags::positional_arguments.size(), 2); + EXPECT_EQ(flags::positional_arguments[0], "A"); + EXPECT_EQ(flags::positional_arguments[1], "BCD"); +} + +TEST_F(FlagTest, MissingRequired) { + FLAG_SHORT_bool(g, false, true); + + const char* argv[] = {"binary", nullptr}; + EXPECT_FALSE(flags::Parse(argv)); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, BooleanShortValue) { + FLAG_SHORT_bool(g, false, false); + const char* argv[] = {"binary", "-g", nullptr}; + EXPECT_FALSE(g.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(g.value()); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, BooleanShortDefaultValue) { + FLAG_SHORT_bool(g, true, false); + const char* argv[] = {"binary", nullptr}; + EXPECT_TRUE(g.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(g.value()); +} + +TEST_F(FlagTest, BooleanLongValueNotParsed) { + FLAG_SHORT_bool(g, false, false); + const char* argv[] = {"binary", "-g", "false", nullptr}; + EXPECT_FALSE(g.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(g.value()); + EXPECT_EQ(flags::positional_arguments.size(), 1); + EXPECT_EQ(flags::positional_arguments[0], "false"); +} + +TEST_F(FlagTest, BooleanLongSplitNotParsed) { + FLAG_LONG_bool(foo, false, false); + const char* argv[] = {"binary", "--foo", "true", nullptr}; + EXPECT_FALSE(foo.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(foo.value()); + EXPECT_EQ(flags::positional_arguments.size(), 1); + EXPECT_EQ(flags::positional_arguments[0], "true"); +} + +TEST_F(FlagTest, BooleanLongExplicitTrue) { + FLAG_LONG_bool(foo, false, false); + const char* argv[] = {"binary", "--foo=true", nullptr}; + EXPECT_FALSE(foo.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(foo.value()); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, BooleanLongExplicitFalse) { + FLAG_LONG_bool(foo, false, false); + const char* argv[] = {"binary", "--foo=false", nullptr}; + EXPECT_FALSE(foo.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_FALSE(foo.value()); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, BooleanLongDefaultValue) { + FLAG_LONG_bool(foo, true, false); + const char* argv[] = {"binary", nullptr}; + EXPECT_TRUE(foo.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_TRUE(foo.value()); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, BooleanLongDefaultValueCancelled) { + FLAG_LONG_bool(foo, true, false); + const char* argv[] = {"binary", "--foo=false", nullptr}; + EXPECT_TRUE(foo.value()); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_FALSE(foo.value()); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringFlagDefaultValue) { + FLAG_SHORT_string(f, "default", false); + const char* argv[] = {"binary", nullptr}; + EXPECT_EQ(f.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(f.value(), "default"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringFlagShortMissingString) { + FLAG_SHORT_string(f, "default", false); + const char* argv[] = {"binary", "-f", nullptr}; + EXPECT_EQ(f.value(), "default"); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, StringFlagDefault) { + FLAG_SHORT_string(f, "default", false); + const char* argv[] = {"binary", nullptr}; + EXPECT_EQ(f.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(f.value(), "default"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringFlagSet) { + FLAG_SHORT_string(f, "default", false); + const char* argv[] = {"binary", "-f", "toto", nullptr}; + EXPECT_EQ(f.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(f.value(), "toto"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringLongFlagSetSplit) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--foo", "toto", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), "toto"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringLongFlagSetUnified) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--foo=toto", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), "toto"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, StringLongFlagSetEmpty) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--foo=", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), ""); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, AllPositionalAfterDoubleDash) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--", "--foo=toto", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), "default"); + EXPECT_EQ(flags::positional_arguments.size(), 1); + EXPECT_EQ(flags::positional_arguments[0], "--foo=toto"); +} + +TEST_F(FlagTest, NothingAfterDoubleDash) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), "default"); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, FlagDoubleSetNotAllowed) { + FLAG_LONG_string(foo, "default", false); + const char* argv[] = {"binary", "--foo=abc", "--foo=def", nullptr}; + EXPECT_EQ(foo.value(), "default"); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, MultipleFlags) { + FLAG_LONG_string(foo, "default foo", false); + FLAG_LONG_string(bar, "default_bar", false); + const char* argv[] = {"binary", "--foo", "abc", "--bar=def", nullptr}; + EXPECT_EQ(foo.value(), "default foo"); + EXPECT_EQ(bar.value(), "default_bar"); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(foo.value(), "abc"); + EXPECT_EQ(bar.value(), "def"); +} + +TEST_F(FlagTest, MixedStringAndBool) { + FLAG_LONG_string(foo, "default foo", false); + FLAG_LONG_string(bar, "default_bar", false); + FLAG_SHORT_bool(g, false, false); + const char* argv[] = {"binary", "--foo", "abc", "-g", "--bar=def", nullptr}; + EXPECT_EQ(foo.value(), "default foo"); + EXPECT_EQ(bar.value(), "default_bar"); + EXPECT_FALSE(g.value()); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(foo.value(), "abc"); + EXPECT_EQ(bar.value(), "def"); + EXPECT_TRUE(g.value()); +} + +TEST_F(FlagTest, UintFlagDefaultValue) { + FLAG_SHORT_uint(f, 18, false); + const char* argv[] = {"binary", nullptr}; + EXPECT_EQ(f.value(), 18); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(f.value(), 18); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, UintFlagShortMissingValue) { + FLAG_SHORT_uint(f, 19, false); + const char* argv[] = {"binary", "-f", nullptr}; + EXPECT_EQ(f.value(), 19); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintFlagSet) { + FLAG_SHORT_uint(f, 20, false); + const char* argv[] = {"binary", "-f", "21", nullptr}; + EXPECT_EQ(f.value(), 20); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(f.value(), 21); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, UintLongFlagSetSplit) { + FLAG_LONG_uint(foo, 22, false); + const char* argv[] = {"binary", "--foo", "23", nullptr}; + EXPECT_EQ(foo.value(), 22); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), 23); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, UintLongFlagSetUnified) { + FLAG_LONG_uint(foo, 24, false); + const char* argv[] = {"binary", "--foo=25", nullptr}; + EXPECT_EQ(foo.value(), 24); + + EXPECT_TRUE(flags::Parse(argv)); + + EXPECT_EQ(foo.value(), 25); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, UintLongFlagSetEmptyIsWrong) { + FLAG_LONG_uint(foo, 26, false); + const char* argv[] = {"binary", "--foo=", nullptr}; + EXPECT_EQ(foo.value(), 26); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagSetNegativeFails) { + FLAG_LONG_uint(foo, 26, false); + const char* argv[] = {"binary", "--foo=-2", nullptr}; + EXPECT_EQ(foo.value(), 26); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagSetOverflowFails) { + FLAG_LONG_uint(foo, 27, false); + const char* argv[] = { + "binary", "--foo=99999999999999999999999999999999999999999999999999999", + nullptr}; + EXPECT_EQ(foo.value(), 27); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagSetInvalidCharTrailing) { + FLAG_LONG_uint(foo, 28, false); + const char* argv[] = {"binary", "--foo=12A", nullptr}; + EXPECT_EQ(foo.value(), 28); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagSetSpaces) { + FLAG_LONG_uint(foo, 29, false); + const char* argv[] = {"binary", "--foo= 12", nullptr}; + EXPECT_EQ(foo.value(), 29); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(foo.value(), 12); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} + +TEST_F(FlagTest, UintLongFlagSpacesOnly) { + FLAG_LONG_uint(foo, 30, false); + const char* argv[] = {"binary", "--foo= ", nullptr}; + EXPECT_EQ(foo.value(), 30); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagSplitNumber) { + FLAG_LONG_uint(foo, 31, false); + const char* argv[] = {"binary", "--foo= 2 2", nullptr}; + EXPECT_EQ(foo.value(), 31); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagHex) { + FLAG_LONG_uint(foo, 32, false); + const char* argv[] = {"binary", "--foo=0xA", nullptr}; + EXPECT_EQ(foo.value(), 32); + + EXPECT_FALSE(flags::Parse(argv)); +} + +TEST_F(FlagTest, UintLongFlagZeros) { + FLAG_LONG_uint(foo, 33, false); + const char* argv[] = {"binary", "--foo=0000", nullptr}; + EXPECT_EQ(foo.value(), 33); + + EXPECT_TRUE(flags::Parse(argv)); + EXPECT_EQ(foo.value(), 0); + EXPECT_EQ(flags::positional_arguments.size(), 0); +} diff --git a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/continuous.cfg b/third_party/spirv-tools/test/tools/objdump/CMakeLists.txt similarity index 53% rename from third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/continuous.cfg rename to third_party/spirv-tools/test/tools/objdump/CMakeLists.txt index f72cf0593d..46fae21a00 100644 --- a/third_party/spirv-tools/kokoro/windows-msvc-2015-release-bazel/continuous.cfg +++ b/third_party/spirv-tools/test/tools/objdump/CMakeLists.txt @@ -1,10 +1,10 @@ -# Copyright (c) 2019 Google LLC. +# Copyright (c) 2023 Google LLC. # # 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 +# 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, @@ -12,5 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Continuous build configuration. -build_file: "SPIRV-Tools/kokoro/windows-msvc-2015-release-bazel/build.bat" +add_spvtools_unittest( + TARGET spirv_unit_test_tools_objdump + SRCS + extract_source_test.cpp + ${spirv-tools_SOURCE_DIR}/tools/util/flags.cpp + ${spirv-tools_SOURCE_DIR}/tools/util/cli_consumer.cpp + ${spirv-tools_SOURCE_DIR}/tools/objdump/extract_source.cpp + LIBS ${SPIRV_TOOLS_FULL_VISIBILITY} SPIRV-Tools-opt + DEFINES TESTING=1) diff --git a/third_party/spirv-tools/test/tools/objdump/extract_source_test.cpp b/third_party/spirv-tools/test/tools/objdump/extract_source_test.cpp new file mode 100644 index 0000000000..0b81caa483 --- /dev/null +++ b/third_party/spirv-tools/test/tools/objdump/extract_source_test.cpp @@ -0,0 +1,265 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 "tools/objdump/extract_source.h" + +#include + +#include + +#include "source/opt/build_module.h" +#include "source/opt/ir_context.h" +#include "spirv-tools/libspirv.hpp" +#include "tools/util/cli_consumer.h" + +namespace { + +constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +std::pair> ExtractSource( + const std::string& spv_source) { + std::unique_ptr ctx = spvtools::BuildModule( + kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, spv_source, + spvtools::SpirvTools::kDefaultAssembleOption | + SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + std::vector binary; + ctx->module()->ToBinary(&binary, /* skip_nop = */ false); + std::unordered_map output; + bool result = ExtractSourceFromModule(binary, &output); + return std::make_pair(result, std::move(output)); +} + +} // namespace + +TEST(ExtractSourceTest, no_debug) { + std::string source = R"( + OpCapability Shader + OpCapability Linkage + OpMemoryModel Logical GLSL450 + %void = OpTypeVoid + %2 = OpTypeFunction %void + %bool = OpTypeBool + %4 = OpUndef %bool + %5 = OpFunction %void None %2 + %6 = OpLabel + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 0); +} + +TEST(ExtractSourceTest, SimpleSource) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 "[numthreads(1, 1, 1)] void compute_1(){ }" + OpName %1 "compute_1" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 1 41 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == + "[numthreads(1, 1, 1)] void compute_1(){ }"); +} + +TEST(ExtractSourceTest, SourceContinued) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 "[numthreads(1, 1, 1)] " + OpSourceContinued "void compute_1(){ }" + OpName %1 "compute_1" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 1 41 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == + "[numthreads(1, 1, 1)] void compute_1(){ }"); +} + +TEST(ExtractSourceTest, OnlyFilename) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 + OpName %1 "compute_1" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 1 41 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == ""); +} + +TEST(ExtractSourceTest, MultipleFiles) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute1.hlsl" + %3 = OpString "compute2.hlsl" + OpSource HLSL 660 %2 "some instruction" + OpSource HLSL 660 %3 "some other instruction" + OpName %1 "compute_1" + %4 = OpTypeVoid + %5 = OpTypeFunction %4 + %1 = OpFunction %4 None %5 + %6 = OpLabel + OpLine %2 1 41 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 2); + ASSERT_TRUE(result["compute1.hlsl"] == "some instruction"); + ASSERT_TRUE(result["compute2.hlsl"] == "some other instruction"); +} + +TEST(ExtractSourceTest, MultilineCode) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 "[numthreads(1, 1, 1)] +void compute_1() { +} +" + OpName %1 "compute_1" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 3 1 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == + "[numthreads(1, 1, 1)]\nvoid compute_1() {\n}\n"); +} + +TEST(ExtractSourceTest, EmptyFilename) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute_1" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "" + OpSource HLSL 660 %2 "void compute(){}" + OpName %1 "compute_1" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 3 1 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["unnamed-0.hlsl"] == "void compute(){}"); +} + +TEST(ExtractSourceTest, EscapeEscaped) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 "// check \" escape removed" + OpName %1 "compute" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 6 1 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == "// check \" escape removed"); +} + +TEST(ExtractSourceTest, OpSourceWithNoSource) { + std::string source = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %1 "compute" + OpExecutionMode %1 LocalSize 1 1 1 + %2 = OpString "compute.hlsl" + OpSource HLSL 660 %2 + OpName %1 "compute" + %3 = OpTypeVoid + %4 = OpTypeFunction %3 + %1 = OpFunction %3 None %4 + %5 = OpLabel + OpLine %2 6 1 + OpReturn + OpFunctionEnd + )"; + + auto[success, result] = ExtractSource(source); + ASSERT_TRUE(success); + ASSERT_TRUE(result.size() == 1); + ASSERT_TRUE(result["compute.hlsl"] == ""); +} diff --git a/third_party/spirv-tools/test/tools/opt/CMakeLists.txt b/third_party/spirv-tools/test/tools/opt/CMakeLists.txt index 21aa247f1f..966ffbb56d 100644 --- a/third_party/spirv-tools/test/tools/opt/CMakeLists.txt +++ b/third_party/spirv-tools/test/tools/opt/CMakeLists.txt @@ -13,9 +13,9 @@ # limitations under the License. if(NOT ${SPIRV_SKIP_TESTS}) - if(${PYTHONINTERP_FOUND}) + if(${Python3_Interpreter_FOUND}) add_test(NAME spirv_opt_cli_tools_tests - COMMAND ${PYTHON_EXECUTABLE} + COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/../spirv_test_framework.py $ $ $ --test-dir ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/third_party/spirv-tools/test/unit_spirv.h b/third_party/spirv-tools/test/unit_spirv.h index bc9857e69f..9e7074cb33 100644 --- a/third_party/spirv-tools/test/unit_spirv.h +++ b/third_party/spirv-tools/test/unit_spirv.h @@ -202,9 +202,8 @@ inline std::vector AllTargetEnvironments() { // Returns the capabilities in a CapabilitySet as an ordered vector. inline std::vector ElementsIn( const spvtools::CapabilitySet& capabilities) { - std::vector result; - capabilities.ForEach([&result](spv::Capability c) { result.push_back(c); }); - return result; + return std::vector(capabilities.cbegin(), + capabilities.cend()); } } // namespace spvtest diff --git a/third_party/spirv-tools/test/util/bitutils_test.cpp b/third_party/spirv-tools/test/util/bitutils_test.cpp index 3be7ed2691..aea789766a 100644 --- a/third_party/spirv-tools/test/util/bitutils_test.cpp +++ b/third_party/spirv-tools/test/util/bitutils_test.cpp @@ -188,6 +188,46 @@ TEST(BitUtilsTest, IsBitSetAtPositionAll) { EXPECT_TRUE(IsBitAtPositionSet(max_u64, i)); } } + +struct ExtendedValueTestCase { + uint32_t input; + uint32_t bit_width; + uint32_t expected_result; +}; + +using SignExtendedValueTest = ::testing::TestWithParam; + +TEST_P(SignExtendedValueTest, SignExtendValue) { + const auto& tc = GetParam(); + auto result = SignExtendValue(tc.input, tc.bit_width); + EXPECT_EQ(result, tc.expected_result); +} +INSTANTIATE_TEST_SUITE_P( + SignExtendValue, SignExtendedValueTest, + ::testing::Values(ExtendedValueTestCase{1, 1, 0xFFFFFFFF}, + ExtendedValueTestCase{1, 2, 0x1}, + ExtendedValueTestCase{2, 1, 0x0}, + ExtendedValueTestCase{0x8, 4, 0xFFFFFFF8}, + ExtendedValueTestCase{0x8765, 16, 0xFFFF8765}, + ExtendedValueTestCase{0x7765, 16, 0x7765}, + ExtendedValueTestCase{0xDEADBEEF, 32, 0xDEADBEEF})); + +using ZeroExtendedValueTest = ::testing::TestWithParam; + +TEST_P(ZeroExtendedValueTest, ZeroExtendValue) { + const auto& tc = GetParam(); + auto result = ZeroExtendValue(tc.input, tc.bit_width); + EXPECT_EQ(result, tc.expected_result); +} + +INSTANTIATE_TEST_SUITE_P( + ZeroExtendValue, ZeroExtendedValueTest, + ::testing::Values(ExtendedValueTestCase{1, 1, 0x1}, + ExtendedValueTestCase{1, 2, 0x1}, + ExtendedValueTestCase{2, 1, 0x0}, + ExtendedValueTestCase{0x8, 4, 0x8}, + ExtendedValueTestCase{0xFF8765, 16, 0x8765}, + ExtendedValueTestCase{0xDEADBEEF, 32, 0xDEADBEEF})); } // namespace } // namespace utils } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/CMakeLists.txt b/third_party/spirv-tools/test/val/CMakeLists.txt index 62d93bddc1..9d6f6ea6a9 100644 --- a/third_party/spirv-tools/test/val/CMakeLists.txt +++ b/third_party/spirv-tools/test/val/CMakeLists.txt @@ -46,6 +46,7 @@ add_spvtools_unittest(TARGET val_abcde val_extension_spv_khr_bit_instructions_test.cpp val_extension_spv_khr_terminate_invocation_test.cpp val_extension_spv_khr_subgroup_rotate_test.cpp + val_extension_spv_nv_raw_access_chains.cpp val_ext_inst_test.cpp val_ext_inst_debug_test.cpp ${VAL_TEST_COMMON_SRCS} diff --git a/third_party/spirv-tools/test/val/val_annotation_test.cpp b/third_party/spirv-tools/test/val/val_annotation_test.cpp index bb30de0a90..e4a947499c 100644 --- a/third_party/spirv-tools/test/val/val_annotation_test.cpp +++ b/third_party/spirv-tools/test/val/val_annotation_test.cpp @@ -18,7 +18,6 @@ #include #include "gmock/gmock.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_code_generator.h" #include "test/val/val_fixtures.h" @@ -66,6 +65,214 @@ OpDecorate %var BuiltIn WorkgroupSize EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(DecorationTest, FPFastMathModeInvalidMask) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode !524288 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Invalid floating-point fast math mode operand")); +} + +TEST_F(DecorationTest, FPFastMathModeAllowTransformMissingAllowContract) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode AllowTransform|AllowReassoc +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("AllowReassoc and AllowContract must be specified when " + "AllowTransform is specified")); +} + +TEST_F(DecorationTest, FPFastMathModeAllowTransformMissingAllowReassoc) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode AllowTransform|AllowContract +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("AllowReassoc and AllowContract must be specified when " + "AllowTransform is specified")); +} + +TEST_F(DecorationTest, FPFastMathModeAllowTransformMissingContractAndReassoc) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode AllowTransform +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("AllowReassoc and AllowContract must be specified when " + "AllowTransform is specified")); +} + +TEST_F(DecorationTest, FPFastMathModeAndNoContraction) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode None +OpDecorate %add NoContraction +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "FPFastMathMode and NoContraction cannot decorate the same target")); +} + +TEST_F(DecorationTest, FPFastMathModeAndNoContraction2) { + const std::string text = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add NoContraction +OpDecorate %add FPFastMathMode None +%void = OpTypeVoid +%float = OpTypeFloat 32 +%undef = OpUndef %float +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%add = OpFAdd %float %undef %undef +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "FPFastMathMode and NoContraction cannot decorate the same target")); +} + +TEST_F(DecorationTest, RestrictOnUntypedPointer) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpCapability SampleRateShading +OpCapability TransformFeedback +OpCapability GeometryStreams +OpCapability Tessellation +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpDecorate %param Restrict +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void = OpTypeVoid +%f_ty = OpTypeFunction %void %ptr +%f = OpFunction %void None %f_ty +%param = OpFunctionParameter %ptr +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(DecorationTest, ArrayStrideUntypedPointerKHR) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpDecorate %ptr ArrayStride 4 +%ptr = OpTypeUntypedPointerKHR StorageBuffer +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + using MemberOnlyDecorations = spvtest::ValidateBase; TEST_P(MemberOnlyDecorations, MemberDecoration) { diff --git a/third_party/spirv-tools/test/val/val_arithmetics_test.cpp b/third_party/spirv-tools/test/val/val_arithmetics_test.cpp index 631375efb6..42f4ce7d4a 100644 --- a/third_party/spirv-tools/test/val/val_arithmetics_test.cpp +++ b/third_party/spirv-tools/test/val/val_arithmetics_test.cpp @@ -1280,14 +1280,14 @@ TEST_F(ValidateArithmetics, CoopMatMatrixTimesScalarMismatchFail) { TEST_F(ValidateArithmetics, CoopMatScopeFail) { const std::string types = R"( -%workgroup = OpConstant %u32 2 +%device = OpConstant %u32 1 -%mat16x16_wg = OpTypeCooperativeMatrixNV %f16 %workgroup %u32_16 %u32_16 -%f16matwg_16x16_1 = OpConstantComposite %mat16x16_wg %f16_1 +%mat16x16_dv = OpTypeCooperativeMatrixNV %f16 %device %u32_16 %u32_16 +%f16matdv_16x16_1 = OpConstantComposite %mat16x16_dv %f16_1 )"; const std::string body = R"( -%val1 = OpCooperativeMatrixMulAddNV %mat16x16 %f16mat_16x4_1 %f16mat_4x16_1 %f16matwg_16x16_1 +%val1 = OpCooperativeMatrixMulAddNV %mat16x16 %f16mat_16x4_1 %f16mat_4x16_1 %f16matdv_16x16_1 )"; CompileSuccessfully(GenerateCoopMatCode(types, body).c_str()); @@ -1318,7 +1318,7 @@ TEST_F(ValidateArithmetics, CoopMatComponentTypeNotScalarNumeric) { CompileSuccessfully(GenerateCoopMatCode(types, "").c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("OpTypeCooperativeMatrixNV Component Type " + HasSubstr("OpTypeCooperativeMatrix Component Type " "'4[%bool]' is not a scalar numerical type.")); } @@ -1331,7 +1331,7 @@ TEST_F(ValidateArithmetics, CoopMatScopeNotConstantInt) { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("OpTypeCooperativeMatrixNV Scope '17[%float_1]' is not a " + HasSubstr("OpTypeCooperativeMatrix Scope '17[%float_1]' is not a " "constant instruction with scalar integer type.")); } @@ -1344,7 +1344,7 @@ TEST_F(ValidateArithmetics, CoopMatRowsNotConstantInt) { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("OpTypeCooperativeMatrixNV Rows '17[%float_1]' is not a " + HasSubstr("OpTypeCooperativeMatrix Rows '17[%float_1]' is not a " "constant instruction with scalar integer type.")); } @@ -1357,7 +1357,7 @@ TEST_F(ValidateArithmetics, CoopMatColumnsNotConstantInt) { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("OpTypeCooperativeMatrixNV Cols '17[%float_1]' is not a " + HasSubstr("OpTypeCooperativeMatrix Cols '17[%float_1]' is not a " "constant instruction with scalar integer type.")); } @@ -1469,6 +1469,549 @@ TEST_F(ValidateArithmetics, SMulExtendedResultTypeMembersNotIdentical) { "SMulExtended")); } +std::string GenerateCoopMatKHRCode(const std::string& extra_types, + const std::string& main_body) { + const std::string prefix = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpCapability CooperativeMatrixReductionsNV +OpCapability CooperativeMatrixPerElementOperationsNV +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_NV_cooperative_matrix2" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_16 = OpConstant %u32 16 +%u32_4 = OpConstant %u32 4 +%subgroup = OpConstant %u32 3 +%useA = OpConstant %u32 0 +%useB = OpConstant %u32 1 +%useC = OpConstant %u32 2 + +%f16matA = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_16 %useA +%u32matA = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_16 %u32_16 %useA +%s32matA = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_16 %u32_16 %useA + +%f16matB = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_16 %useB +%u32matB = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_16 %u32_16 %useB +%s32matB = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_16 %u32_16 %useB + +%f16matC = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_16 %useC +%f32matC = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_16 %u32_16 %useC +%u32matC = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_16 %u32_16 %useC +%s32matC = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_16 %u32_16 %useC + +%f16_1 = OpConstant %f16 1 +%f32_1 = OpConstant %f32 1 +%u32_1 = OpConstant %u32 1 +%s32_1 = OpConstant %s32 1 + +%f16mat_A_1 = OpConstantComposite %f16matA %f16_1 +%u32mat_A_1 = OpConstantComposite %u32matA %u32_1 +%s32mat_A_1 = OpConstantComposite %s32matA %s32_1 + +%f16mat_B_1 = OpConstantComposite %f16matB %f16_1 +%u32mat_B_1 = OpConstantComposite %u32matB %u32_1 +%s32mat_B_1 = OpConstantComposite %s32matB %s32_1 + +%f16mat_C_1 = OpConstantComposite %f16matC %f16_1 +%u32mat_C_1 = OpConstantComposite %u32matC %u32_1 +%s32mat_C_1 = OpConstantComposite %s32matC %s32_1 + +)"; + + const std::string func_begin = R"( +%main = OpFunction %void None %func +%main_entry = OpLabel)"; + + const std::string suffix = R"( +OpReturn +OpFunctionEnd)"; + + return prefix + extra_types + func_begin + main_body + suffix; +} + +TEST_F(ValidateArithmetics, CoopMatKHRSuccess) { + const std::string body = R"( +%val1 = OpFAdd %f16matA %f16mat_A_1 %f16mat_A_1 +%val2 = OpFSub %f16matA %f16mat_A_1 %f16mat_A_1 +%val3 = OpFMul %f16matA %f16mat_A_1 %f16mat_A_1 +%val4 = OpFDiv %f16matA %f16mat_A_1 %f16mat_A_1 +%val5 = OpFNegate %f16matA %f16mat_A_1 +%val6 = OpIAdd %u32matA %u32mat_A_1 %u32mat_A_1 +%val7 = OpISub %u32matA %u32mat_A_1 %u32mat_A_1 +%val8 = OpUDiv %u32matA %u32mat_A_1 %u32mat_A_1 +%val9 = OpIAdd %s32matA %s32mat_A_1 %s32mat_A_1 +%val10 = OpISub %s32matA %s32mat_A_1 %s32mat_A_1 +%val11 = OpSDiv %s32matA %s32mat_A_1 %s32mat_A_1 +%val12 = OpSNegate %s32matA %s32mat_A_1 +%val13 = OpMatrixTimesScalar %f16matA %f16mat_A_1 %f16_1 +%val14 = OpMatrixTimesScalar %u32matA %u32mat_A_1 %u32_1 +%val15 = OpMatrixTimesScalar %s32matA %s32mat_A_1 %s32_1 +%val16 = OpCooperativeMatrixMulAddKHR %f32matC %f16mat_A_1 %f16mat_B_1 %f16mat_C_1 +%val17 = OpCooperativeMatrixMulAddKHR %s32matC %s32mat_A_1 %s32mat_B_1 %s32mat_C_1 + MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR|MatrixCSignedComponentsKHR|MatrixResultSignedComponentsKHR +%val18 = OpCooperativeMatrixMulAddKHR %u32matC %u32mat_A_1 %u32mat_B_1 %u32mat_C_1 +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode("", body).c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateArithmetics, CoopMatMatrixKHRTimesScalarMismatchFail) { + const std::string body = R"( +%val1 = OpMatrixTimesScalar %f16matA %f16mat_A_1 %f32_1 +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode("", body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected scalar operand type to be equal to the component " + "type of the matrix operand: MatrixTimesScalar")); +} + +TEST_F(ValidateArithmetics, CoopMatKHRScopeFail) { + const std::string types = R"( +%device = OpConstant %u32 1 +%mat16x16_dv = OpTypeCooperativeMatrixKHR %f16 %device %u32_16 %u32_16 %useC +%f16matdv_16x16_1 = OpConstantComposite %mat16x16_dv %f16_1 +)"; + + const std::string body = R"( +%val1 = OpFAdd %f16matA %f16matdv_16x16_1 %f16mat_A_1 +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected scopes of Matrix and Result Type to be identical")); +} + +TEST_F(ValidateArithmetics, CoopMatKHRDimFail) { + const std::string types = R"( +%mat16x4 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_4 %useC +%mat16x4_C_1 = OpConstantComposite %mat16x4 %f16_1 +)"; + + const std::string body = R"( +%val1 = OpCooperativeMatrixMulAddKHR %mat16x4 %f16mat_A_1 %f16mat_B_1 %mat16x4_C_1 +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cooperative matrix 'N' mismatch: CooperativeMatrixMulAddKHR")); +} + +TEST_F(ValidateArithmetics, CoopMat2ReduceSuccess) { + const std::string extra_types = R"( + +%f16matC8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %useC +%f16matC16x8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_8 %useC +%f16matC8x16 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_16 %useC + +%functy = OpTypeFunction %f16 %f16 %f16 +%reducefunc = OpFunction %f16 None %functy +%x = OpFunctionParameter %f16 +%y = OpFunctionParameter %f16 +%entry2 = OpLabel +%sum = OpFAdd %f16 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC8 %f16mat_C_1 2x2 %reducefunc +%val2 = OpCooperativeMatrixReduceNV %f16matC16x8 %f16mat_C_1 Row %reducefunc +%val3 = OpCooperativeMatrixReduceNV %f16matC8x16 %f16mat_C_1 Column %reducefunc +%val4 = OpCooperativeMatrixReduceNV %f16matC %f16mat_C_1 Row|Column %reducefunc +%val5 = OpCooperativeMatrixReduceNV %f16matC8 %f16mat_C_1 Row|Column %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateArithmetics, CoopMat2Reduce2x2DimFail) { + const std::string extra_types = R"( + +%functy = OpTypeFunction %f16 %f16 %f16 +%reducefunc = OpFunction %f16 None %functy +%x = OpFunctionParameter %f16 +%y = OpFunctionParameter %f16 +%entry2 = OpLabel +%sum = OpFAdd %f16 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC %f16mat_C_1 2x2 %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("For Reduce2x2, result rows/cols must be half of " + "matrix rows/cols: CooperativeMatrixReduceNV")); +} + +TEST_F(ValidateArithmetics, CoopMat2ReduceRowDimFail) { + const std::string extra_types = R"( + +%f16matC8x16 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_16 %useC + +%functy = OpTypeFunction %f16 %f16 %f16 +%reducefunc = OpFunction %f16 None %functy +%x = OpFunctionParameter %f16 +%y = OpFunctionParameter %f16 +%entry2 = OpLabel +%sum = OpFAdd %f16 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC8x16 %f16mat_C_1 Row %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("For ReduceRow, result rows must match matrix rows: " + "CooperativeMatrixReduceNV")); +} + +TEST_F(ValidateArithmetics, CoopMat2ReduceColDimFail) { + const std::string extra_types = R"( + +%f16matC16x8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_8 %useC + +%functy = OpTypeFunction %f16 %f16 %f16 +%reducefunc = OpFunction %f16 None %functy +%x = OpFunctionParameter %f16 +%y = OpFunctionParameter %f16 +%entry2 = OpLabel +%sum = OpFAdd %f16 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC16x8 %f16mat_C_1 Column %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("For ReduceColumn, result cols must match matrix cols: " + "CooperativeMatrixReduceNV")); +} + +TEST_F(ValidateArithmetics, CoopMat2ReduceMaskFail) { + const std::string extra_types = R"( + +%f16matC8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %useC + +%functy = OpTypeFunction %f16 %f16 %f16 +%reducefunc = OpFunction %f16 None %functy +%x = OpFunctionParameter %f16 +%y = OpFunctionParameter %f16 +%entry2 = OpLabel +%sum = OpFAdd %f16 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC8 %f16mat_C_1 Row|Column|2x2 %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Reduce 2x2 must not be used with Row/Column: " + "CooperativeMatrixReduceNV")); +} + +TEST_F(ValidateArithmetics, CoopMat2ReduceFuncTypeFail) { + const std::string extra_types = R"( + +%functy = OpTypeFunction %f32 %f32 %f32 +%reducefunc = OpFunction %f32 None %functy +%x = OpFunctionParameter %f32 +%y = OpFunctionParameter %f32 +%entry2 = OpLabel +%sum = OpFAdd %f32 %x %y +OpReturnValue %sum +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixReduceNV %f16matC %f16mat_C_1 Row|Column %reducefunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("CombineFunc return type and parameters must match " + "matrix component type: CooperativeMatrixReduceNV")); +} + +TEST_F(ValidateArithmetics, CoopMat2PerElementOpSuccess) { + const std::string extra_types = R"( + +%functy = OpTypeFunction %f16 %u32 %u32 %f16 +%functy2 = OpTypeFunction %f16 %u32 %u32 %f16 %u32 + +%elemfunc = OpFunction %f16 None %functy +%row = OpFunctionParameter %u32 +%col = OpFunctionParameter %u32 +%el = OpFunctionParameter %f16 +%entry2 = OpLabel +OpReturnValue %el +OpFunctionEnd + +%elemfunc2 = OpFunction %f16 None %functy2 +%row2 = OpFunctionParameter %u32 +%col2 = OpFunctionParameter %u32 +%el2 = OpFunctionParameter %f16 +%x = OpFunctionParameter %u32 +%entry3 = OpLabel +OpReturnValue %el2 +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixPerElementOpNV %f16matC %f16mat_C_1 %elemfunc +%val2 = OpCooperativeMatrixPerElementOpNV %f16matC %f16mat_C_1 %elemfunc2 %f16_1 +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateArithmetics, CoopMat2PerElementOpElemTyFail) { + const std::string extra_types = R"( + +%functy = OpTypeFunction %f32 %u32 %u32 %f32 + +%elemfunc = OpFunction %f32 None %functy +%row = OpFunctionParameter %u32 +%col = OpFunctionParameter %u32 +%el = OpFunctionParameter %f32 +%entry2 = OpLabel +OpReturnValue %el +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixPerElementOpNV %f16matC %f16mat_C_1 %elemfunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must match matrix component type")); +} + +TEST_F(ValidateArithmetics, CoopMat2PerElementOpRowTyFail) { + const std::string extra_types = R"( + +%functy = OpTypeFunction %f16 %f16 %u32 %f16 + +%elemfunc = OpFunction %f16 None %functy +%row = OpFunctionParameter %f16 +%col = OpFunctionParameter %u32 +%el = OpFunctionParameter %f16 +%entry2 = OpLabel +OpReturnValue %el +OpFunctionEnd + + )"; + const std::string body = R"( +%val1 = OpCooperativeMatrixPerElementOpNV %f16matC %f16mat_C_1 %elemfunc +)"; + + CompileSuccessfully(GenerateCoopMatKHRCode(extra_types, body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be a 32-bit integer")); +} + +std::string GenerateCoopVecCode(const std::string& extra_types, + const std::string& main_body) { + const std::string prefix = + R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_EXT_replicated_composites" +%ext_inst = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_16 = OpConstant %u32 16 +%u32_4 = OpConstant %u32 4 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_8 +%f16vec4 = OpTypeCooperativeVectorNV %f16 %u32_4 +%u32vec = OpTypeCooperativeVectorNV %u32 %u32_8 +%s32vec = OpTypeCooperativeVectorNV %s32 %u32_8 + +%f16_1 = OpConstant %f16 1 +%f32_1 = OpConstant %f32 1 +%u32_1 = OpConstant %u32 1 +%s32_1 = OpConstant %s32 1 + +%f16vec4_1 = OpConstantComposite %f16vec4 %f16_1 %f16_1 %f16_1 %f16_1 +%f16vec_1 = OpConstantComposite %f16vec %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 +%u32vec_1 = OpConstantComposite %u32vec %u32_1 %u32_1 %u32_1 %u32_1 %u32_1 %u32_1 %u32_1 %u32_1 +%s32vec_1 = OpConstantComposite %s32vec %s32_1 %s32_1 %s32_1 %s32_1 %s32_1 %s32_1 %s32_1 %s32_1 + +%u32_c1 = OpSpecConstant %u32 1 +%u32_c2 = OpSpecConstant %u32 2 + +%f16vecc = OpTypeCooperativeVectorNV %f16 %u32_c1 +%f16vecc_1 = OpConstantCompositeReplicateEXT %f16vecc %f16_1 +)"; + + const std::string func_begin = + R"( +%main = OpFunction %void None %func +%main_entry = OpLabel)"; + + const std::string suffix = + R"( +OpReturn +OpFunctionEnd)"; + + return prefix + extra_types + func_begin + main_body + suffix; +} + +TEST_F(ValidateArithmetics, CoopVecSuccess) { + const std::string body = R"( +%val1 = OpFAdd %f16vec %f16vec_1 %f16vec_1 +%val2 = OpFSub %f16vec %f16vec_1 %f16vec_1 +%val3 = OpFDiv %f16vec %f16vec_1 %f16vec_1 +%val4 = OpFNegate %f16vec %f16vec_1 +%val5 = OpIAdd %u32vec %u32vec_1 %u32vec_1 +%val6 = OpISub %u32vec %u32vec_1 %u32vec_1 +%val7 = OpUDiv %u32vec %u32vec_1 %u32vec_1 +%val8 = OpIAdd %s32vec %s32vec_1 %s32vec_1 +%val9 = OpISub %s32vec %s32vec_1 %s32vec_1 +%val10 = OpSDiv %s32vec %s32vec_1 %s32vec_1 +%val11 = OpSNegate %s32vec %s32vec_1 +%val12 = OpVectorTimesScalar %f16vec %f16vec_1 %f16_1 +%val13 = OpExtInst %f16vec %ext_inst FMin %f16vec_1 %f16vec_1 +%val14 = OpExtInst %f16vec %ext_inst FMax %f16vec_1 %f16vec_1 +%val15 = OpExtInst %f16vec %ext_inst FClamp %f16vec_1 %f16vec_1 %f16vec_1 +%val16 = OpExtInst %f16vec %ext_inst NClamp %f16vec_1 %f16vec_1 %f16vec_1 +%val17 = OpExtInst %f16vec %ext_inst Step %f16vec_1 %f16vec_1 +%val18 = OpExtInst %f16vec %ext_inst Exp %f16vec_1 +%val19 = OpExtInst %f16vec %ext_inst Log %f16vec_1 +%val20 = OpExtInst %f16vec %ext_inst Tanh %f16vec_1 +%val21 = OpExtInst %f16vec %ext_inst Atan %f16vec_1 +%val22 = OpExtInst %f16vec %ext_inst Fma %f16vec_1 %f16vec_1 %f16vec_1 +%val23 = OpExtInst %u32vec %ext_inst UMin %u32vec_1 %u32vec_1 +%val24 = OpExtInst %u32vec %ext_inst UMax %u32vec_1 %u32vec_1 +%val25 = OpExtInst %u32vec %ext_inst UClamp %u32vec_1 %u32vec_1 %u32vec_1 +%val26 = OpExtInst %s32vec %ext_inst SMin %s32vec_1 %s32vec_1 +%val27 = OpExtInst %s32vec %ext_inst SMax %s32vec_1 %s32vec_1 +%val28 = OpExtInst %s32vec %ext_inst SClamp %s32vec_1 %s32vec_1 %s32vec_1 +%val29 = OpShiftRightLogical %u32vec %u32vec_1 %u32vec_1 +%val30 = OpShiftRightArithmetic %u32vec %u32vec_1 %u32vec_1 +%val31 = OpShiftLeftLogical %u32vec %u32vec_1 %u32vec_1 +%val32 = OpBitwiseOr %u32vec %u32vec_1 %u32vec_1 +%val33 = OpBitwiseXor %u32vec %u32vec_1 %u32vec_1 +%val34 = OpBitwiseAnd %u32vec %u32vec_1 %u32vec_1 +%val35 = OpNot %u32vec %u32vec_1 +)"; + + CompileSuccessfully(GenerateCoopVecCode("", body).c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateArithmetics, CoopVecFMulPass) { + const std::string body = R"( +%val1 = OpFMul %f16vec %f16vec_1 %f16vec_1 +)"; + + CompileSuccessfully(GenerateCoopVecCode("", body).c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateArithmetics, CoopVecVectorTimesScalarMismatchFail) { + const std::string body = R"( +%val1 = OpVectorTimesScalar %f16vec %f16vec_1 %f32_1 +)"; + + CompileSuccessfully(GenerateCoopVecCode("", body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected scalar operand type to be equal to the component " + "type of the vector operand: VectorTimesScalar")); +} + +TEST_F(ValidateArithmetics, CoopVecDimFail) { + const std::string body = R"( +%val1 = OpFMul %f16vec %f16vec_1 %f16vec4_1 +)"; + + CompileSuccessfully(GenerateCoopVecCode("", body).c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected number of components to be identical")); +} + +TEST_F(ValidateArithmetics, CoopVecComponentTypeNotScalarNumeric) { + const std::string types = R"( +%bad = OpTypeCooperativeVectorNV %bool %u32_8 +)"; + + CompileSuccessfully(GenerateCoopVecCode(types, "").c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpTypeCooperativeVectorNV Component Type " + "'5[%bool]' is not a scalar numerical type.")); +} + +TEST_F(ValidateArithmetics, CoopVecDimNotConstantInt) { + const std::string types = R"( +%bad = OpTypeCooperativeVectorNV %f16 %f32_1 +)"; + + CompileSuccessfully(GenerateCoopVecCode(types, "").c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpTypeCooperativeVectorNV component count " + "'19[%float_1]' is not a constant integer type")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_atomics_test.cpp b/third_party/spirv-tools/test/val/val_atomics_test.cpp index b266ad6665..1cec51eb8e 100644 --- a/third_party/spirv-tools/test/val/val_atomics_test.cpp +++ b/third_party/spirv-tools/test/val/val_atomics_test.cpp @@ -318,7 +318,8 @@ TEST_F(ValidateAtomics, AtomicAddFloatVulkan) { EXPECT_THAT( getDiagnosticString(), HasSubstr("Opcode AtomicFAddEXT requires one of these capabilities: " - "AtomicFloat32AddEXT AtomicFloat64AddEXT AtomicFloat16AddEXT")); + "AtomicFloat16VectorNV AtomicFloat32AddEXT AtomicFloat64AddEXT " + "AtomicFloat16AddEXT")); } TEST_F(ValidateAtomics, AtomicMinFloatVulkan) { @@ -331,7 +332,8 @@ TEST_F(ValidateAtomics, AtomicMinFloatVulkan) { EXPECT_THAT( getDiagnosticString(), HasSubstr("Opcode AtomicFMinEXT requires one of these capabilities: " - "AtomicFloat32MinMaxEXT AtomicFloat64MinMaxEXT AtomicFloat16MinMaxEXT")); + "AtomicFloat16VectorNV AtomicFloat32MinMaxEXT " + "AtomicFloat64MinMaxEXT AtomicFloat16MinMaxEXT")); } TEST_F(ValidateAtomics, AtomicMaxFloatVulkan) { @@ -343,8 +345,10 @@ TEST_F(ValidateAtomics, AtomicMaxFloatVulkan) { ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("Opcode AtomicFMaxEXT requires one of these capabilities: " - "AtomicFloat32MinMaxEXT AtomicFloat64MinMaxEXT AtomicFloat16MinMaxEXT")); + HasSubstr( + "Opcode AtomicFMaxEXT requires one of these capabilities: " + "AtomicFloat16VectorNV AtomicFloat32MinMaxEXT AtomicFloat64MinMaxEXT " + "AtomicFloat16MinMaxEXT")); } TEST_F(ValidateAtomics, AtomicAddFloatVulkanWrongType1) { @@ -1138,9 +1142,8 @@ OpAtomicStore %f32_1 %device %relaxed %f32_1 CompileSuccessfully(GenerateKernelCode(body)); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr("AtomicStore: expected Pointer to be of type OpTypePointer")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("AtomicStore: expected Pointer to be a pointer type")); } TEST_F(ValidateAtomics, AtomicStoreWrongPointerDataType) { @@ -1603,7 +1606,7 @@ TEST_F(ValidateAtomics, AtomicFlagTestAndSetNotPointer) { ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("AtomicFlagTestAndSet: " - "expected Pointer to be of type OpTypePointer")); + "expected Pointer to be a pointer type")); } TEST_F(ValidateAtomics, AtomicFlagTestAndSetNotIntPointer) { @@ -1677,7 +1680,7 @@ OpAtomicFlagClear %u32_1 %device %relaxed ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("AtomicFlagClear: " - "expected Pointer to be of type OpTypePointer")); + "expected Pointer to be a pointer type")); } TEST_F(ValidateAtomics, AtomicFlagClearNotIntPointer) { @@ -2713,6 +2716,255 @@ TEST_F(ValidateAtomics, IIncrementBadPointerDataType) { "value of type Result Type")); } +TEST_F(ValidateAtomics, AtomicFloat16VectorSuccess) { + const std::string definitions = R"( +%f16 = OpTypeFloat 16 +%f16vec2 = OpTypeVector %f16 2 +%f16vec4 = OpTypeVector %f16 4 + +%f16_1 = OpConstant %f16 1 +%f16vec2_1 = OpConstantComposite %f16vec2 %f16_1 %f16_1 +%f16vec4_1 = OpConstantComposite %f16vec4 %f16_1 %f16_1 %f16_1 %f16_1 + +%f16vec2_ptr = OpTypePointer Workgroup %f16vec2 +%f16vec4_ptr = OpTypePointer Workgroup %f16vec4 +%f16vec2_var = OpVariable %f16vec2_ptr Workgroup +%f16vec4_var = OpVariable %f16vec4_ptr Workgroup +)"; + + const std::string body = R"( +%val3 = OpAtomicFMinEXT %f16vec2 %f16vec2_var %device %relaxed %f16vec2_1 +%val4 = OpAtomicFMaxEXT %f16vec2 %f16vec2_var %device %relaxed %f16vec2_1 +%val8 = OpAtomicFAddEXT %f16vec2 %f16vec2_var %device %relaxed %f16vec2_1 +%val9 = OpAtomicExchange %f16vec2 %f16vec2_var %device %relaxed %f16vec2_1 + +%val11 = OpAtomicFMinEXT %f16vec4 %f16vec4_var %device %relaxed %f16vec4_1 +%val12 = OpAtomicFMaxEXT %f16vec4 %f16vec4_var %device %relaxed %f16vec4_1 +%val18 = OpAtomicFAddEXT %f16vec4 %f16vec4_var %device %relaxed %f16vec4_1 +%val19 = OpAtomicExchange %f16vec4 %f16vec4_var %device %relaxed %f16vec4_1 + +)"; + + CompileSuccessfully(GenerateShaderComputeCode( + body, + "OpCapability Float16\n" + "OpCapability AtomicFloat16VectorNV\n" + "OpExtension \"SPV_NV_shader_atomic_fp16_vector\"\n", + definitions), + SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +static constexpr char Float16Vector3Defs[] = R"( +%f16 = OpTypeFloat 16 +%f16vec3 = OpTypeVector %f16 3 + +%f16_1 = OpConstant %f16 1 +%f16vec3_1 = OpConstantComposite %f16vec3 %f16_1 %f16_1 %f16_1 + +%f16vec3_ptr = OpTypePointer Workgroup %f16vec3 +%f16vec3_var = OpVariable %f16vec3_ptr Workgroup +)"; + +TEST_F(ValidateAtomics, AtomicFloat16Vector3MinFail) { + const std::string definitions = Float16Vector3Defs; + + const std::string body = R"( +%val11 = OpAtomicFMinEXT %f16vec3 %f16vec3_var %device %relaxed %f16vec3_1 +)"; + + CompileSuccessfully(GenerateShaderComputeCode( + body, + "OpCapability Float16\n" + "OpCapability AtomicFloat16VectorNV\n" + "OpExtension \"SPV_NV_shader_atomic_fp16_vector\"\n", + definitions), + SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("AtomicFMinEXT: expected Result Type to be float scalar type")); +} + +TEST_F(ValidateAtomics, AtomicFloat16Vector3MaxFail) { + const std::string definitions = Float16Vector3Defs; + + const std::string body = R"( +%val12 = OpAtomicFMaxEXT %f16vec3 %f16vec3_var %device %relaxed %f16vec3_1 +)"; + + CompileSuccessfully(GenerateShaderComputeCode( + body, + "OpCapability Float16\n" + "OpCapability AtomicFloat16VectorNV\n" + "OpExtension \"SPV_NV_shader_atomic_fp16_vector\"\n", + definitions), + SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("AtomicFMaxEXT: expected Result Type to be float scalar type")); +} + +TEST_F(ValidateAtomics, AtomicFloat16Vector3AddFail) { + const std::string definitions = Float16Vector3Defs; + + const std::string body = R"( +%val18 = OpAtomicFAddEXT %f16vec3 %f16vec3_var %device %relaxed %f16vec3_1 +)"; + + CompileSuccessfully(GenerateShaderComputeCode( + body, + "OpCapability Float16\n" + "OpCapability AtomicFloat16VectorNV\n" + "OpExtension \"SPV_NV_shader_atomic_fp16_vector\"\n", + definitions), + SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("AtomicFAddEXT: expected Result Type to be float scalar type")); +} + +TEST_F(ValidateAtomics, AtomicFloat16Vector3ExchangeFail) { + const std::string definitions = Float16Vector3Defs; + + const std::string body = R"( +%val19 = OpAtomicExchange %f16vec3 %f16vec3_var %device %relaxed %f16vec3_1 +)"; + + CompileSuccessfully(GenerateShaderComputeCode( + body, + "OpCapability Float16\n" + "OpCapability AtomicFloat16VectorNV\n" + "OpExtension \"SPV_NV_shader_atomic_fp16_vector\"\n", + definitions), + SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("AtomicExchange: expected Result Type to be integer or " + "float scalar type")); +} + +TEST_F(ValidateAtomics, AtomicLoadUntypedPointer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpAtomicLoad %int %var %int_1 %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateAtomics, AtomicStoreUntypedPointer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpAtomicStore %var %int_1 %int_0 %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateAtomics, AtomicExchangeUntypedPointer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%ex = OpAtomicExchange %int %var %int_1 %int_0 %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateAtomics, AtomicFlagClearUntypedPointer) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical OpenCL +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpAtomicFlagClear %var %int_1 %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Untyped pointers are not supported by atomic flag instructions")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_barriers_test.cpp b/third_party/spirv-tools/test/val/val_barriers_test.cpp index c86cdc1382..ba8ac7d46b 100644 --- a/third_party/spirv-tools/test/val/val_barriers_test.cpp +++ b/third_party/spirv-tools/test/val/val_barriers_test.cpp @@ -361,7 +361,7 @@ OpControlBarrier %subgroup %subgroup %none CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-06997")); + AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-07951")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -410,7 +410,7 @@ OpControlBarrier %subgroup %cross_device %none TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupNonComputeMemoryFailure) { const std::string body = R"( -OpControlBarrier %subgroup %workgroup %acquire +OpControlBarrier %subgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); @@ -427,7 +427,7 @@ OpControlBarrier %subgroup %workgroup %acquire TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupNonComputeExecutionFailure) { const std::string body = R"( -OpControlBarrier %workgroup %subgroup %acquire +OpControlBarrier %workgroup %subgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); @@ -442,7 +442,7 @@ OpControlBarrier %workgroup %subgroup %acquire TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupComputeSuccess) { const std::string body = R"( -OpControlBarrier %workgroup %workgroup %acquire +OpControlBarrier %workgroup %workgroup %acquire_uniform_workgroup )"; CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_1); @@ -451,7 +451,7 @@ OpControlBarrier %workgroup %workgroup %acquire TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupNonComputeSuccess) { const std::string body = R"( -OpControlBarrier %subgroup %subgroup %acquire +OpControlBarrier %subgroup %subgroup %acquire_uniform_workgroup )"; CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); @@ -495,15 +495,15 @@ OpControlBarrier %device %device %acquire_and_release_uniform "AcquireRelease or SequentiallyConsistent")); } -// TODO(atgoo@github.com): the corresponding check fails Vulkan CTS, -// reenable once fixed. -TEST_F(ValidateBarriers, DISABLED_OpControlBarrierVulkanSubgroupStorageClass) { +TEST_F(ValidateBarriers, OpControlBarrierVulkanSubgroupStorageClass) { const std::string body = R"( OpControlBarrier %workgroup %device %acquire_release_subgroup )"; CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpControlBarrier-04650")); EXPECT_THAT( getDiagnosticString(), HasSubstr( @@ -513,7 +513,7 @@ OpControlBarrier %workgroup %device %acquire_release_subgroup TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionFragment1p1) { const std::string body = R"( -OpControlBarrier %subgroup %subgroup %acquire_release_subgroup +OpControlBarrier %subgroup %subgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), @@ -523,7 +523,7 @@ OpControlBarrier %subgroup %subgroup %acquire_release_subgroup TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionFragment1p1) { const std::string body = R"( -OpControlBarrier %workgroup %workgroup %acquire_release +OpControlBarrier %workgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), @@ -541,7 +541,7 @@ OpControlBarrier %workgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionFragment1p0) { const std::string body = R"( -OpControlBarrier %subgroup %workgroup %acquire_release +OpControlBarrier %subgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), @@ -556,7 +556,7 @@ OpControlBarrier %subgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionVertex1p1) { const std::string body = R"( -OpControlBarrier %subgroup %subgroup %acquire_release_subgroup +OpControlBarrier %subgroup %subgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), @@ -566,7 +566,7 @@ OpControlBarrier %subgroup %subgroup %acquire_release_subgroup TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionVertex1p1) { const std::string body = R"( -OpControlBarrier %workgroup %workgroup %acquire_release +OpControlBarrier %workgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), @@ -584,7 +584,7 @@ OpControlBarrier %workgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionVertex1p0) { const std::string body = R"( -OpControlBarrier %subgroup %workgroup %acquire_release +OpControlBarrier %subgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), @@ -599,7 +599,7 @@ OpControlBarrier %subgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionGeometry1p1) { const std::string body = R"( -OpControlBarrier %subgroup %subgroup %acquire_release_subgroup +OpControlBarrier %subgroup %subgroup %acquire_release_workgroup )"; CompileSuccessfully( @@ -610,7 +610,7 @@ OpControlBarrier %subgroup %subgroup %acquire_release_subgroup TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionGeometry1p1) { const std::string body = R"( -OpControlBarrier %workgroup %workgroup %acquire_release +OpControlBarrier %workgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully( @@ -629,7 +629,7 @@ OpControlBarrier %workgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionGeometry1p0) { const std::string body = R"( -OpControlBarrier %subgroup %workgroup %acquire_release +OpControlBarrier %subgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully( @@ -646,7 +646,7 @@ OpControlBarrier %subgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionTessellationEvaluation1p1) { const std::string body = R"( -OpControlBarrier %subgroup %subgroup %acquire_release_subgroup +OpControlBarrier %subgroup %subgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", @@ -658,7 +658,7 @@ OpControlBarrier %subgroup %subgroup %acquire_release_subgroup TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionTessellationEvaluation1p1) { const std::string body = R"( -OpControlBarrier %workgroup %workgroup %acquire_release +OpControlBarrier %workgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", @@ -678,7 +678,7 @@ OpControlBarrier %workgroup %workgroup %acquire_release TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionTessellationEvaluation1p0) { const std::string body = R"( -OpControlBarrier %subgroup %workgroup %acquire_release +OpControlBarrier %subgroup %workgroup %acquire_release_workgroup )"; CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", @@ -775,7 +775,7 @@ OpMemoryBarrier %subgroup %acquire_release_uniform_workgroup CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), - AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-06997")); + AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-07951")); EXPECT_THAT( getDiagnosticString(), HasSubstr( diff --git a/third_party/spirv-tools/test/val/val_bitwise_test.cpp b/third_party/spirv-tools/test/val/val_bitwise_test.cpp index bebaa84fc2..b849e7b778 100644 --- a/third_party/spirv-tools/test/val/val_bitwise_test.cpp +++ b/third_party/spirv-tools/test/val/val_bitwise_test.cpp @@ -643,6 +643,32 @@ TEST_F(ValidateBitwise, OpBitCountNot32Vulkan) { HasSubstr("Expected 32-bit int type for Base operand: BitCount")); } +TEST_F(ValidateBitwise, OpBitCountPointer) { + const std::string body = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr_int = OpTypePointer Function %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_int Function +%count = OpBitCount %int %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Expected int scalar or vector type for Base operand: BitCount")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_builtins_test.cpp b/third_party/spirv-tools/test/val/val_builtins_test.cpp index 4f9fc97631..ee9b68d70d 100644 --- a/third_party/spirv-tools/test/val/val_builtins_test.cpp +++ b/third_party/spirv-tools/test/val/val_builtins_test.cpp @@ -3947,7 +3947,8 @@ INSTANTIATE_TEST_SUITE_P( Values(TestResult( SPV_ERROR_INVALID_DATA, "Vulkan spec allows BuiltIn PrimitiveShadingRateKHR to be used " - "only with Vertex, Geometry, or MeshNV execution models.")))); + "only with Vertex, Geometry, MeshNV or MeshEXT execution " + "models.")))); INSTANTIATE_TEST_SUITE_P( PrimitiveShadingRateInvalidStorageClass, @@ -4261,6 +4262,1227 @@ INSTANTIATE_TEST_SUITE_P( Values(TestResult(SPV_ERROR_INVALID_DATA, "needs to be a 3-component 32-bit float vector")))); +std::string GenerateMeshShadingCode(const std::string& built_in, + const std::string& execution_mode, + const std::string& body, + const std::string& declarations = "") { + std::ostringstream ss; + ss << R"( +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +OpMemoryModel Logical GLSL450 +OpEntryPoint MeshEXT %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main OutputVertices 1 +OpExecutionMode %main OutputPrimitivesEXT 16 +)"; + ss << "OpExecutionMode %main " << execution_mode << "\n"; + ss << "OpDecorate %var BuiltIn " << built_in << "\n"; + + ss << R"( +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%int = OpTypeInt 32 1 +%uint = OpTypeInt 32 0 +%v2uint = OpTypeVector %uint 2 +%v3uint = OpTypeVector %uint 3 + +%int_0 = OpConstant %int 0 +%uint_16 = OpConstant %uint 16 +)"; + + ss << declarations; + + ss << R"( +%main = OpFunction %void None %func +%main_entry = OpLabel +)"; + + ss << body; + + ss << R"( +OpReturn +OpFunctionEnd)"; + return ss.str(); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTSuccess) { + const std::string declarations = R"( +%array = OpTypeArray %v3uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %v3uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", + "OutputTrianglesEXT", body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, + VulkanPrimitiveTriangleIndicesEXTInvalidExecutionMode) { + const std::string declarations = R"( +%array = OpTypeArray %v3uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %v3uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", "OutputPoints", + body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07054")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTStorageClass) { + const std::string declarations = R"( +%array = OpTypeArray %v3uint %uint_16 +%array_ptr = OpTypePointer Input %array +%var = OpVariable %array_ptr Input +%ptr = OpTypePointer Input %v3uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", + "OutputTrianglesEXT", body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07055")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTVectorSize) { + const std::string declarations = R"( +%array = OpTypeArray %v2uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %v2uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", + "OutputTrianglesEXT", body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07056")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTNonArray) { + const std::string declarations = R"( +%ptr = OpTypePointer Output %v3uint +%var = OpVariable %ptr Output +)"; + const std::string body = R"( +%load = OpLoad %v3uint %var +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", + "OutputTrianglesEXT", body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07056")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTSuccess) { + const std::string declarations = R"( +%array = OpTypeArray %v2uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %v2uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTInvalidExecutionMode) { + const std::string declarations = R"( + %array = OpTypeArray %v2uint %uint_16 + %array_ptr = OpTypePointer Output %array + %var = OpVariable %array_ptr Output + %ptr = OpTypePointer Output %v2uint + )"; + const std::string body = R"( + %access = OpAccessChain %ptr %var %int_0 + )"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputPoints", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTStorageClass) { + const std::string declarations = R"( +%array = OpTypeArray %v2uint %uint_16 +%array_ptr = OpTypePointer Input %array +%var = OpVariable %array_ptr Input +%ptr = OpTypePointer Input %v2uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07049")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTType) { + const std::string declarations = R"( +%array = OpTypeArray %v3uint %uint_16 +%array_ptr = OpTypePointer Input %array +%var = OpVariable %array_ptr Input +%ptr = OpTypePointer Input %v3uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07050")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTSuccess) { + const std::string declarations = R"( +%array = OpTypeArray %uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTInvalidExecutionMode) { + const std::string declarations = R"( + %array = OpTypeArray %uint %uint_16 + %array_ptr = OpTypePointer Output %array + %var = OpVariable %array_ptr Output + %ptr = OpTypePointer Output %uint + )"; + const std::string body = R"( + %access = OpAccessChain %ptr %var %int_0 + )"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputTrianglesNV", + body, declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTStorageClass) { + const std::string declarations = R"( +%array = OpTypeArray %uint %uint_16 +%array_ptr = OpTypePointer Input %array +%var = OpVariable %array_ptr Input +%ptr = OpTypePointer Input %uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07043")); +} + +TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTType) { + const std::string declarations = R"( +%array = OpTypeArray %v3uint %uint_16 +%array_ptr = OpTypePointer Output %array +%var = OpVariable %array_ptr Output +%ptr = OpTypePointer Output %v3uint +)"; + const std::string body = R"( +%access = OpAccessChain %ptr %var %int_0 +)"; + + CompileSuccessfully( + GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body, + declarations) + .c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07044")); +} + +TEST_F(ValidateBuiltIns, VulkanBuiltinPrimtiveIDWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpCapability Shader + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_PrimitiveID + OpExecutionMode %MainMesh OutputPrimitivesNV 1 + OpExecutionMode %MainMesh OutputVertices 3 + OpExecutionMode %MainMesh OutputTrianglesNV + OpExecutionMode %MainMesh LocalSize 1 1 1 + OpSource Slang 1 + OpName %MainMesh "MainMesh" + OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId + OpDecorate %gl_PrimitiveID PerPrimitiveNV + %void = OpTypeVoid + %9 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %uint_1 = OpConstant %uint 1 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %int_3 = OpConstant %int 3 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %uint_0 = OpConstant %uint 0 + %v3float = OpTypeVector %float 3 +%_ptr_Output_v3float = OpTypePointer Output %v3float + %v3uint = OpTypeVector %uint 3 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_int = OpTypePointer Output %int +%_arr_int_int_1 = OpTypeArray %int %int_1 +%_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1 +%gl_PrimitiveID = OpVariable %_ptr_Output__arr_int_int_1 Output + %MainMesh = OpFunction %void None %9 + %25 = OpLabel + OpSetMeshOutputsEXT %uint_3 %uint_1 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimtiveIDWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpCapability Shader + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_PrimitiveID + OpExecutionMode %MainMesh OutputPrimitivesNV 1 + OpExecutionMode %MainMesh OutputVertices 3 + OpExecutionMode %MainMesh OutputTrianglesNV + OpExecutionMode %MainMesh LocalSize 1 1 1 + OpSource Slang 1 + OpName %MainMesh "MainMesh" + OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId +%void = OpTypeVoid + %9 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%int_3 = OpConstant %int 3 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%uint_0 = OpConstant %uint 0 +%v3float = OpTypeVector %float 3 +%_ptr_Output_v3float = OpTypePointer Output %v3float +%v3uint = OpTypeVector %uint 3 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_int = OpTypePointer Output %int +%_arr_int_int_1 = OpTypeArray %int %int_1 +%_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1 +%gl_PrimitiveID = OpVariable %_ptr_Output__arr_int_int_1 Output +%MainMesh = OpFunction %void None %9 + %25 = OpLabel + OpSetMeshOutputsEXT %uint_3 %uint_1 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveId-PrimitiveId-07040")); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpCapability Shader + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_Layer + OpExecutionMode %MainMesh OutputPrimitivesNV 1 + OpExecutionMode %MainMesh OutputVertices 3 + OpExecutionMode %MainMesh OutputTrianglesNV + OpExecutionMode %MainMesh LocalSize 1 1 1 + OpSource Slang 1 + OpName %MainMesh "MainMesh" + OpDecorate %gl_Layer BuiltIn Layer + %void = OpTypeVoid + %9 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 + %float = OpTypeFloat 32 + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %int_3 = OpConstant %int 3 +%uint_0 = OpConstant %uint 0 +%v3float = OpTypeVector %float 3 +%_ptr_Output_v3float = OpTypePointer Output %v3float +%v3uint = OpTypeVector %uint 3 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_int = OpTypePointer Output %int +%_arr_int_int_1 = OpTypeArray %int %int_1 +%_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1 +%gl_Layer = OpVariable %_ptr_Output__arr_int_int_1 Output +%MainMesh = OpFunction %void None %9 + %25 = OpLabel + OpSetMeshOutputsEXT %uint_3 %uint_1 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-07039")); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpCapability Shader + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_ViewportIndex + OpExecutionMode %MainMesh OutputPrimitivesNV 1 + OpExecutionMode %MainMesh OutputVertices 3 + OpExecutionMode %MainMesh OutputTrianglesNV + OpExecutionMode %MainMesh LocalSize 1 1 1 + OpSource Slang 1 + OpName %MainMesh "MainMesh" + OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex +%void = OpTypeVoid +%9 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 1 +%int_1 = OpConstant %int 1 +%int_3 = OpConstant %int 3 +%uint_0 = OpConstant %uint 0 +%v3float = OpTypeVector %float 3 +%_ptr_Output_v3float = OpTypePointer Output %v3float +%v3uint = OpTypeVector %uint 3 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_int = OpTypePointer Output %int +%_arr_int_int_1 = OpTypeArray %int %int_1 +%_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1 +%gl_ViewportIndex = OpVariable %_ptr_Output__arr_int_int_1 Output +%MainMesh = OpFunction %void None %9 +%25 = OpLabel + OpSetMeshOutputsEXT %uint_3 %uint_1 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-ViewportIndex-ViewportIndex-07060")); +} + +TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitivePointIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputPoints + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT" + OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%_arr_uint_uint_32 = OpTypeArray %uint %uint_32 +%_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32 +%gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%_ptr_Output_uint = OpTypePointer Output %uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0 + OpStore %15 %uint_0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveLineIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputLinesEXT + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT" + OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%v2uint = OpTypeVector %uint 2 +%uint_32 = OpConstant %uint 32 +%_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32 +%_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32 +%gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 + %15 = OpConstantComposite %v2uint %uint_0 %uint_0 +%_ptr_Output_v2uint = OpTypePointer Output %v2uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0 + OpStore %17 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitiveLineIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputPoints + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT" + OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%v2uint = OpTypeVector %uint 2 +%uint_32 = OpConstant %uint 32 +%_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32 +%_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32 +%gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 + %15 = OpConstantComposite %v2uint %uint_0 %uint_0 +%_ptr_Output_v2uint = OpTypePointer Output %v2uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0 + OpStore %17 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048")); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitivePointIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT" + OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%_arr_uint_uint_32 = OpTypeArray %uint %uint_32 +%_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32 +%gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%_ptr_Output_uint = OpTypePointer Output %uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0 + OpStore %15 %uint_0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042")); +} + +TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveTriangleIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT" + OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT +%void = OpTypeVoid +%7 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32 +%_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32 +%gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %7 +%18 = OpLabel +%19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0 + OpStore %19 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitiveTriangleIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputPoints + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT" + OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT +%void = OpTypeVoid +%7 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32 +%_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32 +%gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %7 +%18 = OpLabel +%19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0 + OpStore %19 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07054")); +} + +TEST_F(ValidateBuiltIns, BadVulkanPrimitivePointIndicesArraySizeMeshEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 16 + OpExecutionMode %main OutputPoints + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT" + OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%_arr_uint_uint_32 = OpTypeArray %uint %uint_32 +%_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32 +%gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%_ptr_Output_uint = OpTypePointer Output %uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 +%5 = OpLabel +%15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0 + OpStore %15 %uint_0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07046")); +} + +TEST_F(ValidateBuiltIns, BadVulkanPrimitiveLineIndicesArraySizeMeshEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 16 + OpExecutionMode %main OutputLinesEXT + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT" + OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%v2uint = OpTypeVector %uint 2 +%uint_32 = OpConstant %uint 32 +%_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32 +%_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32 +%gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%15 = OpConstantComposite %v2uint %uint_0 %uint_0 +%_ptr_Output_v2uint = OpTypePointer Output %v2uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 + %5 = OpLabel +%17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0 + OpStore %17 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07052")); +} + +TEST_F(ValidateBuiltIns, BadVulkanPrimitiveTriangleIndicesArraySizeMeshEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 16 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT" + OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT +%void = OpTypeVoid +%7 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32 +%_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32 +%gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0 +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %7 +%18 = OpLabel +%19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0 + OpStore %19 %15 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveTriangleIndicesEXT-" + "PrimitiveTriangleIndicesEXT-07058")); +} + +TEST_F(ValidateBuiltIns, BadExecModelVulkanPrimitivePointIndicesEXT) { + const std::string text = R"( + OpCapability MeshShadingNV + OpCapability MeshShadingEXT + OpExtension "SPV_NV_mesh_shader" + OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshNV %main "main" %gl_PrimitivePointIndicesEXT + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputPoints + OpSource GLSL 460 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT" + OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%_arr_uint_uint_32 = OpTypeArray %uint %uint_32 +%_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32 +%gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%uint_0 = OpConstant %uint 0 +%_ptr_Output_uint = OpTypePointer Output %uint +%v3uint = OpTypeVector %uint 3 +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 +%5 = OpLabel +%15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0 + OpStore %15 %uint_0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07041")); +} + +TEST_F(ValidateBuiltIns, VulkanBuiltinCullPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT" + OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT" + OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT" + OpDecorate %gl_MeshPerPrimitiveEXT Block + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%int = OpTypeInt 32 1 +%bool = OpTypeBool +%gl_MeshPerPrimitiveEXT = OpTypeStruct %bool +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output +%main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTType) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT" + OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT" + OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT" + OpDecorate %gl_MeshPerPrimitiveEXT Block + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%int = OpTypeInt 32 1 +%bool = OpTypeBool +%gl_MeshPerPrimitiveEXT = OpTypeStruct %int +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output +%main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036")); +} + +TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTStorageClass) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT" + OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT" + OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT" + OpDecorate %gl_MeshPerPrimitiveEXT Block + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%int = OpTypeInt 32 1 +%bool = OpTypeBool +%gl_MeshPerPrimitiveEXT = OpTypeStruct %bool +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Input %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Input +%main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07035")); +} + +TEST_F(ValidateBuiltIns, BadBuiltinCullPrimitiveEXTWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT" + OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT" + OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT" + OpDecorate %gl_MeshPerPrimitiveEXT Block + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%int = OpTypeInt 32 1 +%bool = OpTypeBool +%gl_MeshPerPrimitiveEXT = OpTypeStruct %bool +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output +%main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07038")); +} + +TEST_F(ValidateBuiltIns, BadBuiltinPrimitiveShadingRateWithPerPrimitiveEXT) { + const std::string text = R"( + OpCapability FragmentShadingRateKHR + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpExtension "SPV_KHR_fragment_shading_rate" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT" + OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_PrimitiveShadingRateKHR" + OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT" + OpDecorate %gl_MeshPerPrimitiveEXT Block + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveShadingRateKHR +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%int = OpTypeInt 32 1 +%bool = OpTypeBool +%gl_MeshPerPrimitiveEXT = OpTypeStruct %int +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output +%main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-07059")); +} + +TEST_F(ValidateBuiltIns, BadExecModelVulkanCullPrimitiveEXT) { + const std::string text = R"( + OpCapability MeshShadingNV + OpCapability MeshShadingEXT + OpExtension "SPV_NV_mesh_shader" + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshNV %main "main" %gl_MeshPrimitivesEXT + OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesNV 32 + OpExecutionMode %main OutputTrianglesNV + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT + OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT + OpDecorate %gl_MeshPerPrimitiveEXT Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%uint_32 = OpConstant %uint 32 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 + %bool = OpTypeBool + %int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%gl_MeshPerPrimitiveEXT = OpTypeStruct %bool +%_ptr_Output_bool = OpTypePointer Output %bool +%_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32 +%_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32 +%gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpAccessChain %_ptr_Output_bool %gl_MeshPrimitivesEXT %int_0 %int_0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07034")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_cfg_test.cpp b/third_party/spirv-tools/test/val/val_cfg_test.cpp index 561e817e74..ae2e45bb62 100644 --- a/third_party/spirv-tools/test/val/val_cfg_test.cpp +++ b/third_party/spirv-tools/test/val/val_cfg_test.cpp @@ -16,14 +16,12 @@ #include #include -#include #include #include #include #include #include "gmock/gmock.h" -#include "source/diagnostic.h" #include "source/spirv_target_env.h" #include "source/val/validate.h" #include "test/test_fixture.h" @@ -2064,6 +2062,106 @@ OpFunctionEnd ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateCFG, OpSwitchTargetCannotBeOuterLoopMergeBlock) { + std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 + +%1 = OpTypeVoid +%2 = OpTypeFunction %1 +%3 = OpTypeBool +%4 = OpUndef %3 +%5 = OpTypeInt 32 0 +%6 = OpConstant %5 0 + +%7 = OpFunction %1 None %2 + +%8 = OpLabel +OpBranch %9 + +%9 = OpLabel +OpLoopMerge %10 %11 None +OpBranch %12 + +%12 = OpLabel +OpSelectionMerge %13 None +OpSwitch %6 %13 0 %10 1 %14 + +%14 = OpLabel +OpBranch %13 + +%13 = OpLabel +OpBranch %11 + +%11 = OpLabel +OpBranch %9 + +%10 = OpLabel +OpReturn + +OpFunctionEnd +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Switch header '12[%12]' does not structurally dominate its case construct '10[%10]'\n" + " %12 = OpLabel")); +} + +TEST_F(ValidateCFG, OpSwitchTargetCannotBeOuterLoopContinueBlock) { + std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 + +%1 = OpTypeVoid +%2 = OpTypeFunction %1 +%3 = OpTypeBool +%4 = OpUndef %3 +%5 = OpTypeInt 32 0 +%6 = OpConstant %5 0 + +%7 = OpFunction %1 None %2 + +%8 = OpLabel +OpBranch %9 + +%9 = OpLabel +OpLoopMerge %10 %11 None +OpBranch %12 + +%12 = OpLabel +OpSelectionMerge %13 None +OpSwitch %6 %13 0 %11 1 %14 + +%14 = OpLabel +OpBranch %13 + +%13 = OpLabel +OpBranch %11 + +%11 = OpLabel +OpBranch %9 + +%10 = OpLabel +OpReturn + +OpFunctionEnd +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Switch header '12[%12]' does not structurally dominate its case construct '11[%11]'\n" + " %12 = OpLabel")); +} + TEST_F(ValidateCFG, WrongOperandList) { std::string text = R"( OpCapability Shader @@ -3446,6 +3544,37 @@ OpFunctionEnd EXPECT_THAT(getDiagnosticString(), HasSubstr("Selection must be structured")); } +TEST_F(ValidateCFG, LoopConditionalBranchWithoutExitBad) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%bool = OpTypeBool +%undef = OpUndef %bool +%func = OpFunction %void None %void_fn +%entry = OpLabel +OpBranch %loop +%loop = OpLabel +OpLoopMerge %exit %continue None +OpBranchConditional %undef %then %else +%then = OpLabel +OpBranch %continue +%else = OpLabel +OpBranch %exit +%continue = OpLabel +OpBranch %loop +%exit = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Selection must be structured")); +} + TEST_F(ValidateCFG, MissingMergeSwitchBad) { const std::string text = R"( OpCapability Shader @@ -4674,6 +4803,444 @@ TEST_F(ValidateCFG, BadSwitch) { "via a structured exit")); } +TEST_F(ValidateCFG, + MaximalReconvergenceBranchConditionalSameTargetNotInCallTree) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +OpBranchConditional %cond %func_exit %func_exit +%func_exit = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateCFG, MaximalReconvergenceBranchConditionalSameTargetInCallTree) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +OpBranchConditional %cond %func_exit %func_exit +%func_exit = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In entry points using the MaximallyReconvergesKHR " + "execution mode, True " + "Label and False Label must be different labels")); +} + +TEST_F(ValidateCFG, MaximalReconvergenceEarlyReconvergenceNotInCallTree) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +OpSelectionMerge %func_exit None +OpBranchConditional %cond %then %else +%then = OpLabel +OpBranch %merge +%else = OpLabel +OpBranch %merge +%merge = OpLabel +OpBranch %func_exit +%func_exit = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceEarlyReconvergenceInCallTree) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +OpSelectionMerge %func_exit None +OpBranchConditional %cond %then %else +%then = OpLabel +OpBranch %merge +%else = OpLabel +OpBranch %merge +%merge = OpLabel +OpBranch %func_exit +%func_exit = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "In entry points using the MaximallyReconvergesKHR execution mode, " + "this basic block must not have multiple unique predecessors")); +} + +TEST_F(ValidateCFG, MaximalReconvergenceLoopMultiplePredsOk) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpBranch %loop +%loop = OpLabel +OpLoopMerge %merge %loop None +OpBranchConditional %cond %loop %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceLoopMultiplePredsOk2) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpBranch %loop +%loop = OpLabel +OpLoopMerge %merge %cont None +OpBranch %body +%body = OpLabel +OpBranch %cont +%cont = OpLabel +OpBranchConditional %cond %loop %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceSelectionMergeMultiplePredsOk) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpSelectionMerge %merge None +OpBranchConditional %cond %then %else +%then = OpLabel +OpBranch %merge +%else = OpLabel +OpBranch %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceSelectionMergeMultiplePredsOk2) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +OpName %merge "merge" +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpSelectionMerge %merge None +OpBranchConditional %cond %then %else +%then = OpLabel +OpBranch %merge +%else = OpLabel +OpBranch %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceLoopMergeMultiplePredsOk) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpBranch %loop +%loop = OpLabel +OpLoopMerge %merge %continue None +OpBranchConditional %cond %merge %continue +%continue = OpLabel +OpBranchConditional %cond %loop %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, MaximalReconvergenceCaseFallthroughMultiplePredsOk) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_maximal_reconvergence" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%bool = OpTypeBool +%cond = OpUndef %bool +%int = OpTypeInt 32 0 +%val = OpUndef %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%main_entry = OpLabel +OpSelectionMerge %merge None +OpSwitch %val %merge 0 %case1 1 %case2 +%case1 = OpLabel +OpBranch %case2 +%case2 = OpLabel +OpBranch %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, StructurallyUnreachableContinuePredecessor) { + const std::string text = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpSource ESSL 310 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %int_n7 = OpConstant %int -7 + %bool = OpTypeBool + %main = OpFunction %void None %3 + %8 = OpLabel + OpBranch %9 + %9 = OpLabel + %10 = OpPhi %int %int_1 %8 %int_n7 %15 + %12 = OpSGreaterThan %bool %10 %int_n7 + OpLoopMerge %13 %15 None + OpBranchConditional %12 %14 %13 + %14 = OpLabel + OpBranch %15 + %15 = OpLabel + OpBranch %9 + %17 = OpLabel + OpBranch %15 + %13 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, FullyLoopPrecedingSwitchToContinue) { + const std::string text = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %bool = OpTypeBool + %true = OpConstantTrue %bool + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %main = OpFunction %void None %3 + %4 = OpLabel + OpBranch %7 + %7 = OpLabel + OpLoopMerge %8 %6 None + OpBranch %5 + %5 = OpLabel + OpSelectionMerge %9 None + OpBranchConditional %true %10 %9 + %10 = OpLabel + OpSelectionMerge %16 None + OpSwitch %int_0 %13 + %13 = OpLabel + OpBranch %19 + %19 = OpLabel + OpLoopMerge %20 %18 None + OpBranch %17 + %17 = OpLabel + OpReturn + %18 = OpLabel + OpBranch %19 + %20 = OpLabel + OpSelectionMerge %23 None + OpSwitch %int_1 %21 + %21 = OpLabel + OpBranch %6 + %23 = OpLabel + OpBranch %16 + %16 = OpLabel + OpBranch %9 + %9 = OpLabel + OpBranch %6 + %6 = OpLabel + OpBranch %7 + %8 = OpLabel + OpUnreachable + OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateCFG, CaseBreak) { + const std::string text = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpName %main "main" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%bool = OpTypeBool +%true = OpConstantTrue %bool +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%main = OpFunction %void None %3 +%4 = OpLabel +OpSelectionMerge %merge None +OpSwitch %int_1 %case 2 %merge +%case = OpLabel +OpBranch %merge +%merge = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_composites_test.cpp b/third_party/spirv-tools/test/val/val_composites_test.cpp index 0fd1ed6527..460ae5873a 100644 --- a/third_party/spirv-tools/test/val/val_composites_test.cpp +++ b/third_party/spirv-tools/test/val/val_composites_test.cpp @@ -1486,8 +1486,7 @@ OpFunctionEnd } TEST_F(ValidateComposites, CoopMatConstantCompositeMismatchFail) { - const std::string body = - R"( + const std::string body = R"( OpCapability Shader OpCapability Float16 OpCapability CooperativeMatrixNV @@ -1525,8 +1524,7 @@ OpFunctionEnd)"; } TEST_F(ValidateComposites, CoopMatCompositeConstructMismatchFail) { - const std::string body = - R"( + const std::string body = R"( OpCapability Shader OpCapability Float16 OpCapability CooperativeMatrixNV @@ -1562,6 +1560,86 @@ OpFunctionEnd)"; HasSubstr("Expected Constituent type to be equal to the component type")); } +TEST_F(ValidateComposites, CoopMatKHRConstantCompositeMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_16 %useA + +%f32_1 = OpConstant %f32 1 + +%f16mat_1 = OpConstantComposite %f16mat %f32_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpConstantComposite Constituent '12[%float_1]' type " + "does not match the Result Type '11[%11]'s component type.")); +} + +TEST_F(ValidateComposites, CoopMatKHRCompositeConstructMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_16 %useA + +%f32_1 = OpConstant %f32 1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%f16mat_1 = OpCompositeConstruct %f16mat %f32_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected Constituent type to be equal to the component type")); +} + TEST_F(ValidateComposites, ExtractDynamicLabelIndex) { const std::string spirv = R"( OpCapability Shader @@ -2024,6 +2102,196 @@ TEST_F(ValidateComposites, CopyObjectVoid) { HasSubstr("OpCopyObject cannot have void result type")); } +TEST_F(ValidateComposites, CoopVecConstantCompositePass) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_16 + +%f16_1 = OpConstant %f16 1 + +%f16vec_1 = OpConstantComposite %f16vec %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateComposites, CoopVecConstantCompositeMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_16 + +%f32_1 = OpConstant %f32 1 + +%f16vec_1 = OpConstantComposite %f16vec %f32_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpConstantComposite Constituent count does not match " + "Result Type '11[%11]'s vector component count")); +} + +TEST_F(ValidateComposites, CoopVecCompositeConstructPass) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_16 + +%f16_1 = OpConstant %f16 1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%f16vec_1 = OpCompositeConstruct %f16vec %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateComposites, CoopVecCompositeConstructMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_16 + +%f32_1 = OpConstant %f32 1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%f16vec_1 = OpCompositeConstruct %f16vec %f32_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected Constituents to be scalars or vectors of the " + "same type as Result Type components")); +} + +TEST_F(ValidateComposites, CoopVecInsertExtractDynamicPass) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 + +%u32_1 = OpConstant %u32 1 +%u32_16 = OpConstant %u32 16 +%useA = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_16 + +%f16_1 = OpConstant %f16 1 +%f16vec_1 = OpConstantComposite %f16vec %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%insert = OpVectorInsertDynamic %f16vec %f16vec_1 %f16_1 %u32_1 +%extract = OpVectorExtractDynamic %f16 %insert %u32_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_constants_test.cpp b/third_party/spirv-tools/test/val/val_constants_test.cpp index 301539d98f..47278777dc 100644 --- a/third_party/spirv-tools/test/val/val_constants_test.cpp +++ b/third_party/spirv-tools/test/val/val_constants_test.cpp @@ -478,6 +478,22 @@ OpName %ptr "ptr" "a null value")); } +TEST_F(ValidateConstant, VectorMismatchedConstituents) { + std::string spirv = kShaderPreamble kBasicTypes R"( +%int = OpTypeInt 32 1 +%int_0 = OpConstantNull %int +%const_vector = OpConstantComposite %uint2 %uint_0 %int_0 +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpConstantComposite Constituent '13[%13]'s type " + "does not match Result Type '3[%v2uint]'s vector element type")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_conversion_test.cpp b/third_party/spirv-tools/test/val/val_conversion_test.cpp index 1f8c4265b2..69d4045341 100644 --- a/third_party/spirv-tools/test/val/val_conversion_test.cpp +++ b/third_party/spirv-tools/test/val/val_conversion_test.cpp @@ -1149,8 +1149,7 @@ OpFunctionEnd)"; } TEST_F(ValidateConversion, CoopMatConversionShapesMismatchPass) { - const std::string body = - R"( + const std::string body = R"( OpCapability Shader OpCapability Float16 OpCapability Int16 @@ -1191,6 +1190,179 @@ OpFunctionEnd)"; ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateConversion, CoopMatKHRConversionSuccess) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A +%f32mat = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_A +%u16mat = OpTypeCooperativeMatrixKHR %u16 %subgroup %u32_8 %u32_8 %use_A +%u32mat = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_8 %u32_8 %use_A +%s16mat = OpTypeCooperativeMatrixKHR %s16 %subgroup %u32_8 %u32_8 %use_A +%s32mat = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_8 %u32_8 %use_A + +%f16_1 = OpConstant %f16 1 +%f32_1 = OpConstant %f32 1 +%u16_1 = OpConstant %u16 1 +%u32_1 = OpConstant %u32 1 +%s16_1 = OpConstant %s16 1 +%s32_1 = OpConstant %s32 1 + +%f16mat_1 = OpConstantComposite %f16mat %f16_1 +%f32mat_1 = OpConstantComposite %f32mat %f32_1 +%u16mat_1 = OpConstantComposite %u16mat %u16_1 +%u32mat_1 = OpConstantComposite %u32mat %u32_1 +%s16mat_1 = OpConstantComposite %s16mat %s16_1 +%s32mat_1 = OpConstantComposite %s32mat %s32_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val11 = OpConvertFToU %u16mat %f16mat_1 +%val12 = OpConvertFToU %u32mat %f16mat_1 +%val13 = OpConvertFToS %s16mat %f16mat_1 +%val14 = OpConvertFToS %s32mat %f16mat_1 +%val15 = OpFConvert %f32mat %f16mat_1 + +%val21 = OpConvertFToU %u16mat %f32mat_1 +%val22 = OpConvertFToU %u32mat %f32mat_1 +%val23 = OpConvertFToS %s16mat %f32mat_1 +%val24 = OpConvertFToS %s32mat %f32mat_1 +%val25 = OpFConvert %f16mat %f32mat_1 + +%val31 = OpConvertUToF %f16mat %u16mat_1 +%val32 = OpConvertUToF %f32mat %u16mat_1 +%val33 = OpUConvert %u32mat %u16mat_1 +%val34 = OpSConvert %s32mat %u16mat_1 + +%val41 = OpConvertSToF %f16mat %s16mat_1 +%val42 = OpConvertSToF %f32mat %s16mat_1 +%val43 = OpUConvert %u32mat %s16mat_1 +%val44 = OpSConvert %s32mat %s16mat_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateConversion, CoopMatKHRConversionUseMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_4 = OpConstant %u32 4 +%subgroup = OpConstant %u32 3 +%use_A = OpConstant %u32 0 +%use_B = OpConstant %u32 1 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A +%f32mat = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_B + +%f16_1 = OpConstant %f16 1 + +%f16mat_1 = OpConstantComposite %f16mat %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val1 = OpFConvert %f32mat %f16mat_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected Use of Matrix type and Result Type to be identical")); +} + +TEST_F(ValidateConversion, CoopMatKHRConversionScopeMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_4 = OpConstant %u32 4 +%subgroup = OpConstant %u32 3 +%device = OpConstant %u32 1 +%use_A = OpConstant %u32 0 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A +%f32mat = OpTypeCooperativeMatrixKHR %f32 %device %u32_8 %u32_8 %use_A + +%f16_1 = OpConstant %f16 1 + +%f16mat_1 = OpConstantComposite %f16mat %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val1 = OpFConvert %f32mat %f16mat_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Expected scopes of Matrix and Result Type to be identical")); +} + TEST_F(ValidateConversion, BitcastSuccess) { const std::string body = R"( %ptr = OpVariable %f32ptr_func Function @@ -1768,6 +1940,64 @@ OpExtension "SPV_KHR_ray_query" "uint vector as input")); } +TEST_F(ValidateConversion, BitcastUntypedPointerInput) { + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%cast = OpBitcast %int %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateConversion, BitcastUntypedPointerOutput) { + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%cast = OpBitcast %ptr %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + using ValidateSmallConversions = spvtest::ValidateBase; CodeGenerator GetSmallConversionsCodeGenerator() { @@ -1910,6 +2140,319 @@ INSTANTIATE_TEST_SUITE_P(SmallConversionInstructions, ValidateSmallConversions, "%inst = OpBitcast %short %ld_half", "%inst = OpBitcast %short2 %ld_half2")); +TEST_F(ValidateConversion, CoopMat2ConversionSuccess) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixConversionsNV +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_NV_cooperative_matrix2" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_16 = OpConstant %u32 16 +%use_A = OpConstant %u32 0 +%use_B = OpConstant %u32 1 +%use_Acc = OpConstant %u32 2 +%subgroup = OpConstant %u32 3 + +%f16matA = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A +%f32matA = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_A +%u16matA = OpTypeCooperativeMatrixKHR %u16 %subgroup %u32_8 %u32_8 %use_A +%u32matA = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_8 %u32_8 %use_A +%s16matA = OpTypeCooperativeMatrixKHR %s16 %subgroup %u32_8 %u32_8 %use_A +%s32matA = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_8 %u32_8 %use_A + +%f16matB = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_B +%f32matB = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_B +%u16matB = OpTypeCooperativeMatrixKHR %u16 %subgroup %u32_8 %u32_8 %use_B +%u32matB = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_8 %u32_8 %use_B +%s16matB = OpTypeCooperativeMatrixKHR %s16 %subgroup %u32_8 %u32_8 %use_B +%s32matB = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_8 %u32_8 %use_B + +%f16matAcc = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_Acc +%f32matAcc = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_Acc +%u16matAcc = OpTypeCooperativeMatrixKHR %u16 %subgroup %u32_8 %u32_8 %use_Acc +%u32matAcc = OpTypeCooperativeMatrixKHR %u32 %subgroup %u32_8 %u32_8 %use_Acc +%s16matAcc = OpTypeCooperativeMatrixKHR %s16 %subgroup %u32_8 %u32_8 %use_Acc +%s32matAcc = OpTypeCooperativeMatrixKHR %s32 %subgroup %u32_8 %u32_8 %use_Acc + +%f16matAcc16x8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_8 %use_Acc +%f16matB8x16 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_16 %use_B + +%f16_1 = OpConstant %f16 1 +%f32_1 = OpConstant %f32 1 +%u16_1 = OpConstant %u16 1 +%u32_1 = OpConstant %u32 1 +%s16_1 = OpConstant %s16 1 +%s32_1 = OpConstant %s32 1 + +%f16matAcc_1 = OpConstantComposite %f16matAcc %f16_1 +%f32matAcc_1 = OpConstantComposite %f32matAcc %f32_1 +%u16matAcc_1 = OpConstantComposite %u16matAcc %u16_1 +%u32matAcc_1 = OpConstantComposite %u32matAcc %u32_1 +%s16matAcc_1 = OpConstantComposite %s16matAcc %s16_1 +%s32matAcc_1 = OpConstantComposite %s32matAcc %s32_1 + +%f16matAcc16x8_1 = OpConstantComposite %f16matAcc16x8 %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val11A = OpConvertFToU %u16matA %f16matAcc_1 +%val12A = OpConvertFToU %u32matA %f16matAcc_1 +%val13A = OpConvertFToS %s16matA %f16matAcc_1 +%val14A = OpConvertFToS %s32matA %f16matAcc_1 +%val15A = OpFConvert %f32matA %f16matAcc_1 + +%val11B = OpConvertFToU %u16matB %f16matAcc_1 +%val12B = OpConvertFToU %u32matB %f16matAcc_1 +%val13B = OpConvertFToS %s16matB %f16matAcc_1 +%val14B = OpConvertFToS %s32matB %f16matAcc_1 +%val15B = OpFConvert %f32matB %f16matAcc_1 + +%val21A = OpConvertFToU %u16matA %f32matAcc_1 +%val22A = OpConvertFToU %u32matA %f32matAcc_1 +%val23A = OpConvertFToS %s16matA %f32matAcc_1 +%val24A = OpConvertFToS %s32matA %f32matAcc_1 +%val25A = OpFConvert %f16matA %f32matAcc_1 + +%val21B = OpConvertFToU %u16matB %f32matAcc_1 +%val22B = OpConvertFToU %u32matB %f32matAcc_1 +%val23B = OpConvertFToS %s16matB %f32matAcc_1 +%val24B = OpConvertFToS %s32matB %f32matAcc_1 +%val25B = OpFConvert %f16matB %f32matAcc_1 + +%val31A = OpConvertUToF %f16matA %u16matAcc_1 +%val32A = OpConvertUToF %f32matA %u16matAcc_1 +%val33A = OpUConvert %u32matA %u16matAcc_1 +%val34A = OpSConvert %s32matA %u16matAcc_1 + +%val31B = OpConvertUToF %f16matB %u16matAcc_1 +%val32B = OpConvertUToF %f32matB %u16matAcc_1 +%val33B = OpUConvert %u32matB %u16matAcc_1 +%val34B = OpSConvert %s32matB %u16matAcc_1 + +%val41A = OpConvertSToF %f16matA %s16matAcc_1 +%val42A = OpConvertSToF %f32matA %s16matAcc_1 +%val43A = OpUConvert %u32matA %s16matAcc_1 +%val44A = OpSConvert %s32matA %s16matAcc_1 + +%val41B = OpConvertSToF %f16matB %s16matAcc_1 +%val42B = OpConvertSToF %f32matB %s16matAcc_1 +%val43B = OpUConvert %u32matB %s16matAcc_1 +%val44B = OpSConvert %s32matB %s16matAcc_1 + +%val51A = OpCooperativeMatrixConvertNV %f16matA %f16matAcc_1 +%val52A = OpCooperativeMatrixConvertNV %f32matA %f32matAcc_1 +%val53A = OpCooperativeMatrixConvertNV %u16matA %u16matAcc_1 +%val54A = OpCooperativeMatrixConvertNV %s16matA %s16matAcc_1 + +%val51B = OpCooperativeMatrixConvertNV %f16matB %f16matAcc_1 +%val52B = OpCooperativeMatrixConvertNV %f32matB %f32matAcc_1 +%val53B = OpCooperativeMatrixConvertNV %u16matB %u16matAcc_1 +%val54B = OpCooperativeMatrixConvertNV %s16matB %s16matAcc_1 + +%val61B = OpCooperativeMatrixTransposeNV %f16matB %f16matAcc_1 +%val62B = OpCooperativeMatrixTransposeNV %f32matB %f32matAcc_1 +%val63B = OpCooperativeMatrixTransposeNV %u16matB %u16matAcc_1 +%val64B = OpCooperativeMatrixTransposeNV %s16matB %s16matAcc_1 + +%val71B = OpCooperativeMatrixTransposeNV %f16matB8x16 %f16matAcc16x8_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateConversion, CoopMat2TransposeShapeFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixConversionsNV +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_NV_cooperative_matrix2" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 + +%u32_8 = OpConstant %u32 8 +%u32_16 = OpConstant %u32 16 +%use_B = OpConstant %u32 1 +%use_Acc = OpConstant %u32 2 +%subgroup = OpConstant %u32 3 + +%f16matAcc16x8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_8 %use_Acc +%f16matB16x8 = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_16 %u32_8 %use_B + +%f16_1 = OpConstant %f16 1 + +%f16matAcc16x8_1 = OpConstantComposite %f16matAcc16x8 %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val71B = OpCooperativeMatrixTransposeNV %f16matB16x8 %f16matAcc16x8_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected rows of Matrix type and Result Type to be " + "swapped with columns")); +} + +TEST_F(ValidateConversion, CoopVecConversionSuccess) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeVectorNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_EXT_replicated_composites" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_8 +%f32vec = OpTypeCooperativeVectorNV %f32 %u32_8 +%u16vec = OpTypeCooperativeVectorNV %u16 %u32_8 +%u32vec = OpTypeCooperativeVectorNV %u32 %u32_8 +%s16vec = OpTypeCooperativeVectorNV %s16 %u32_8 +%s32vec = OpTypeCooperativeVectorNV %s32 %u32_8 + +%f16_1 = OpConstant %f16 1 +%f32_1 = OpConstant %f32 1 +%u16_1 = OpConstant %u16 1 +%u32_1 = OpConstant %u32 1 +%s16_1 = OpConstant %s16 1 +%s32_1 = OpConstant %s32 1 + +%f16vec_1 = OpConstantCompositeReplicateEXT %f16vec %f16_1 +%f32vec_1 = OpConstantCompositeReplicateEXT %f32vec %f32_1 +%u16vec_1 = OpConstantCompositeReplicateEXT %u16vec %u16_1 +%u32vec_1 = OpConstantCompositeReplicateEXT %u32vec %u32_1 +%s16vec_1 = OpConstantCompositeReplicateEXT %s16vec %s16_1 +%s32vec_1 = OpConstantCompositeReplicateEXT %s32vec %s32_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val11 = OpConvertFToU %u16vec %f16vec_1 +%val12 = OpConvertFToU %u32vec %f16vec_1 +%val13 = OpConvertFToS %s16vec %f16vec_1 +%val14 = OpConvertFToS %s32vec %f16vec_1 +%val15 = OpFConvert %f32vec %f16vec_1 + +%val21 = OpConvertFToU %u16vec %f32vec_1 +%val22 = OpConvertFToU %u32vec %f32vec_1 +%val23 = OpConvertFToS %s16vec %f32vec_1 +%val24 = OpConvertFToS %s32vec %f32vec_1 +%val25 = OpFConvert %f16vec %f32vec_1 + +%val31 = OpConvertUToF %f16vec %u16vec_1 +%val32 = OpConvertUToF %f32vec %u16vec_1 +%val33 = OpUConvert %u32vec %u16vec_1 +%val34 = OpSConvert %s32vec %u16vec_1 + +%val41 = OpConvertSToF %f16vec %s16vec_1 +%val42 = OpConvertSToF %f32vec %s16vec_1 +%val43 = OpUConvert %u32vec %s16vec_1 +%val44 = OpSConvert %s32vec %s16vec_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateConversion, CoopVecConversionDimMismatchFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeVectorNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_EXT_replicated_composites" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u16 = OpTypeInt 16 0 +%u32 = OpTypeInt 32 0 +%s16 = OpTypeInt 16 1 +%s32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%u32_4 = OpConstant %u32 4 +%subgroup = OpConstant %u32 3 +%use_A = OpConstant %u32 0 +%use_B = OpConstant %u32 1 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_8 +%f32vec = OpTypeCooperativeVectorNV %f32 %u32_4 + +%f16_1 = OpConstant %f16 1 + +%f16vec_1 = OpConstantCompositeReplicateEXT %f16vec %f16_1 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%val1 = OpFConvert %f32vec %f16vec_1 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected number of components to be identical")); +} } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_data_test.cpp b/third_party/spirv-tools/test/val/val_data_test.cpp index 6a7f243f6b..349e5e9ef2 100644 --- a/third_party/spirv-tools/test/val/val_data_test.cpp +++ b/third_party/spirv-tools/test/val/val_data_test.cpp @@ -14,7 +14,6 @@ // Validation tests for Data Rules. -#include #include #include diff --git a/third_party/spirv-tools/test/val/val_decoration_test.cpp b/third_party/spirv-tools/test/val/val_decoration_test.cpp index 04d373a75f..a15558b930 100644 --- a/third_party/spirv-tools/test/val/val_decoration_test.cpp +++ b/third_party/spirv-tools/test/val/val_decoration_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2017 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +21,6 @@ #include "gmock/gmock.h" #include "source/val/decoration.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_code_generator.h" #include "test/val/val_fixtures.h" @@ -2075,6 +2076,68 @@ TEST_F(ValidateDecorations, BlockCantAppearWithinABufferblockBad) { "another Block or BufferBlock.")); } +TEST_F(ValidateDecorations, BlockCannotAppearWithinBlockArray) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %main "main" +OpMemberDecorate %outer 0 Offset 0 +OpMemberDecorate %outer 1 Offset 4 +OpMemberDecorate %outer 2 Offset 20 +OpDecorate %outer Block +OpMemberDecorate %inner 0 Offset 0 +OpDecorate %inner Block +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%inner = OpTypeStruct %int +%array = OpTypeArray %inner %int_4 +%outer = OpTypeStruct %int %array %int +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("rules: A Block or BufferBlock cannot be nested within " + "another Block or BufferBlock.")); +} + +TEST_F(ValidateDecorations, BlockCannotAppearWithinBlockMultiArray) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %main "main" +OpMemberDecorate %outer 0 Offset 0 +OpMemberDecorate %outer 1 Offset 4 +OpDecorate %outer Block +OpMemberDecorate %inner 0 Offset 0 +OpDecorate %inner Block +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%inner = OpTypeStruct %int +%array1 = OpTypeArray %inner %int_4 +%array2 = OpTypeArray %array1 %int_4 +%outer = OpTypeStruct %int %array2 +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("rules: A Block or BufferBlock cannot be nested within " + "another Block or BufferBlock.")); +} + TEST_F(ValidateDecorations, BlockLayoutForbidsTightScalarVec3PackingBad) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 std::string spirv = R"( @@ -3210,6 +3273,48 @@ TEST_F(ValidateDecorations, "statically used per shader entry point.")); } +TEST_F(ValidateDecorations, + VulkanMultiplePushConstantsSingleEntryPointInterfaceBad) { + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %func1 "func1" %pc1 %pc2 + OpDecorate %struct Block + OpMemberDecorate %struct 0 Offset 0 + %void = OpTypeVoid + %voidfn = OpTypeFunction %void + %float = OpTypeFloat 32 + %int = OpTypeInt 32 0 + %int_0 = OpConstant %int 0 + %struct = OpTypeStruct %float + %ptr = OpTypePointer PushConstant %struct +%ptr_float = OpTypePointer PushConstant %float + %pc1 = OpVariable %ptr PushConstant + %pc2 = OpVariable %ptr PushConstant + %func1 = OpFunction %void None %voidfn + %label1 = OpLabel + %access1 = OpAccessChain %ptr_float %pc1 %int_0 + %load1 = OpLoad %float %access1 + OpReturn + OpFunctionEnd + %func2 = OpFunction %void None %voidfn + %label2 = OpLabel + %access2 = OpAccessChain %ptr_float %pc2 %int_0 + %load2 = OpLoad %float %access2 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpVariable-06673")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Entry-point has more than one variable with the " + "PushConstant storage class in the interface")); +} + TEST_F(ValidateDecorations, VulkanUniformMissingDescriptorSetBad) { std::string spirv = R"( OpCapability Shader @@ -5281,6 +5386,37 @@ OpFunctionEnd "rules: member 1 at offset 1 is not aligned to 4")); } +TEST_F(ValidateDecorations, VulkanStructWithoutDecorationWithRuntimeArray) { + std::string str = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %func "func" + OpExecutionMode %func OriginUpperLeft + OpDecorate %array_t ArrayStride 4 + OpMemberDecorate %struct_t 0 Offset 0 + OpMemberDecorate %struct_t 1 Offset 4 + %uint_t = OpTypeInt 32 0 + %array_t = OpTypeRuntimeArray %uint_t + %struct_t = OpTypeStruct %uint_t %array_t +%struct_ptr = OpTypePointer StorageBuffer %struct_t + %2 = OpVariable %struct_ptr StorageBuffer + %void = OpTypeVoid + %func_t = OpTypeFunction %void + %func = OpFunction %void None %func_t + %1 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(str.c_str(), SPV_ENV_VULKAN_1_1); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeRuntimeArray-04680")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Vulkan, OpTypeStruct containing an OpTypeRuntimeArray " + "must be decorated with Block or BufferBlock.")); +} + TEST_F(ValidateDecorations, EmptyStructAtNonZeroOffsetGood) { const std::string spirv = R"( OpCapability Shader @@ -6107,34 +6243,6 @@ OpFunctionEnd ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } -TEST_F(ValidateDecorations, PSBAliasedRestrictPointerMissing) { - const std::string body = R"( -OpCapability PhysicalStorageBufferAddresses -OpCapability Int64 -OpCapability Shader -OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64 GLSL450 -OpEntryPoint Fragment %main "main" -OpExecutionMode %main OriginUpperLeft -%uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBuffer %uint64 -%pptr_f = OpTypePointer Function %ptr -%void = OpTypeVoid -%voidfn = OpTypeFunction %void -%main = OpFunction %void None %voidfn -%entry = OpLabel -%val1 = OpVariable %pptr_f Function -OpReturn -OpFunctionEnd -)"; - - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected AliasedPointer or RestrictPointer for " - "PhysicalStorageBuffer pointer")); -} - TEST_F(ValidateDecorations, PSBAliasedRestrictPointerBoth) { const std::string body = R"( OpCapability PhysicalStorageBufferAddresses @@ -6161,8 +6269,8 @@ OpFunctionEnd CompileSuccessfully(body.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("can't specify both AliasedPointer and RestrictPointer " - "for PhysicalStorageBuffer pointer")); + HasSubstr("decorated with both AliasedPointer and " + "RestrictPointer is not allowed")); } TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamSuccess) { @@ -6195,38 +6303,6 @@ OpFunctionEnd ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } -TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamMissing) { - const std::string body = R"( -OpCapability PhysicalStorageBufferAddresses -OpCapability Int64 -OpCapability Shader -OpExtension "SPV_EXT_physical_storage_buffer" -OpMemoryModel PhysicalStorageBuffer64 GLSL450 -OpEntryPoint Fragment %main "main" -OpExecutionMode %main OriginUpperLeft -%uint64 = OpTypeInt 64 0 -%ptr = OpTypePointer PhysicalStorageBuffer %uint64 -%void = OpTypeVoid -%voidfn = OpTypeFunction %void -%fnptr = OpTypeFunction %void %ptr -%main = OpFunction %void None %voidfn -%entry = OpLabel -OpReturn -OpFunctionEnd -%fn = OpFunction %void None %fnptr -%fparam = OpFunctionParameter %ptr -%lab = OpLabel -OpReturn -OpFunctionEnd -)"; - - CompileSuccessfully(body.c_str()); - ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected Aliased or Restrict for " - "PhysicalStorageBuffer pointer")); -} - TEST_F(ValidateDecorations, PSBAliasedRestrictFunctionParamBoth) { const std::string body = R"( OpCapability PhysicalStorageBufferAddresses @@ -6256,9 +6332,9 @@ OpFunctionEnd CompileSuccessfully(body.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("can't specify both Aliased and Restrict for " - "PhysicalStorageBuffer pointer")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("decorated with both Aliased and Restrict is not allowed")); } TEST_F(ValidateDecorations, PSBFPRoundingModeSuccess) { @@ -7973,6 +8049,7 @@ TEST_F(ValidateDecorations, WorkgroupBlockVariableWith16BitType) { OpCapability Shader OpCapability Float16 OpCapability Int16 + OpCapability WorkgroupMemoryExplicitLayoutKHR OpCapability WorkgroupMemoryExplicitLayout16BitAccessKHR OpExtension "SPV_KHR_workgroup_memory_explicit_layout" OpMemoryModel Logical GLSL450 @@ -8235,6 +8312,37 @@ TEST_F(ValidateDecorations, WorkgroupSingleBlockVariableBadLayout) { "member 0 at offset 1 is not aligned to 4")); } +TEST_F(ValidateDecorations, WorkgroupBlockNoCapability) { + std::string spirv = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %_ + OpExecutionMode %main LocalSize 1 1 1 + OpMemberDecorate %struct 0 Offset 0 + OpMemberDecorate %struct 1 Offset 4 + OpDecorate %struct Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %struct = OpTypeStruct %int %int +%ptr_workgroup = OpTypePointer Workgroup %struct + %_ = OpVariable %ptr_workgroup Workgroup + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Workgroup Storage Class variables can't be decorated with Block " + "unless declaring the WorkgroupMemoryExplicitLayoutKHR capability")); +} + TEST_F(ValidateDecorations, BadMatrixStrideUniform) { const std::string spirv = R"( OpCapability Shader @@ -9222,6 +9330,1373 @@ OpFunctionEnd EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); } +TEST_F(ValidateDecorations, PhysicalStorageBufferWithOffset) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Int64 +OpCapability PhysicalStorageBufferAddresses +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" %pc +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %pc_block Block +OpMemberDecorate %pc_block 0 Offset 0 +OpMemberDecorate %pssbo_struct 0 Offset 0 +%void = OpTypeVoid +%long = OpTypeInt 64 0 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%pc_block = OpTypeStruct %long +%pc_block_ptr = OpTypePointer PushConstant %pc_block +%pc_long_ptr = OpTypePointer PushConstant %long +%pc = OpVariable %pc_block_ptr PushConstant +%pssbo_struct = OpTypeStruct %float +%pssbo_ptr = OpTypePointer PhysicalStorageBuffer %pssbo_struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%pc_gep = OpAccessChain %pc_long_ptr %pc %int_0 +%addr = OpLoad %long %pc_gep +%ptr = OpConvertUToPtr %pssbo_ptr %addr +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateDecorations, UntypedVariableDuplicateInterface) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var %var +OpName %var "var" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Non-unique OpEntryPoint interface '2[%var]' is disallowed")); +} + +TEST_F(ValidateDecorations, PhysicalStorageBufferMissingOffset) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Int64 +OpCapability PhysicalStorageBufferAddresses +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" %pc +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %pc_block Block +OpMemberDecorate %pc_block 0 Offset 0 +%void = OpTypeVoid +%long = OpTypeInt 64 0 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%pc_block = OpTypeStruct %long +%pc_block_ptr = OpTypePointer PushConstant %pc_block +%pc_long_ptr = OpTypePointer PushConstant %long +%pc = OpVariable %pc_block_ptr PushConstant +%pssbo_struct = OpTypeStruct %float +%pssbo_ptr = OpTypePointer PhysicalStorageBuffer %pssbo_struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%pc_gep = OpAccessChain %pc_long_ptr %pc %int_0 +%addr = OpLoad %long %pc_gep +%ptr = OpConvertUToPtr %pssbo_ptr %addr +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("decorated as Block for variable in PhysicalStorageBuffer " + "storage class must follow relaxed storage buffer layout " + "rules: member 0 is missing an Offset decoration")); +} + +TEST_F(ValidateDecorations, PhysicalStorageBufferMissingArrayStride) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Int64 +OpCapability PhysicalStorageBufferAddresses +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" %pc +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %pc_block Block +OpMemberDecorate %pc_block 0 Offset 0 +%void = OpTypeVoid +%long = OpTypeInt 64 0 +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_4 = OpConstant %int 4 +%pc_block = OpTypeStruct %long +%pc_block_ptr = OpTypePointer PushConstant %pc_block +%pc_long_ptr = OpTypePointer PushConstant %long +%pc = OpVariable %pc_block_ptr PushConstant +%pssbo_array = OpTypeArray %float %int_4 +%pssbo_ptr = OpTypePointer PhysicalStorageBuffer %pssbo_array +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%pc_gep = OpAccessChain %pc_long_ptr %pc %int_0 +%addr = OpLoad %long %pc_gep +%ptr = OpConvertUToPtr %pssbo_ptr %addr +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "decorated as Block for variable in PhysicalStorageBuffer storage " + "class must follow relaxed storage buffer layout rules: member 0 " + "contains an array with stride 0, but with an element size of 4")); +} + +TEST_F(ValidateDecorations, MatrixArrayMissingMajorness) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 MatrixStride 16 +OpDecorate %array ArrayStride 32 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%block = OpTypeStruct %array +%ptr = OpTypePointer Uniform %block +%var = OpVariable %ptr Uniform +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "must be explicitly laid out with RowMajor or ColMajor decorations")); +} + +TEST_F(ValidateDecorations, MatrixArrayMissingStride) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 ColMajor +OpDecorate %array ArrayStride 32 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%block = OpTypeStruct %array +%ptr = OpTypePointer Uniform %block +%var = OpVariable %ptr Uniform +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("must be explicitly laid out with MatrixStride decorations")); +} + +TEST_F(ValidateDecorations, MatrixArrayBadStride) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 ColMajor +OpMemberDecorate %block 0 MatrixStride 8 +OpDecorate %array ArrayStride 32 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%block = OpTypeStruct %array +%ptr = OpTypePointer Uniform %block +%var = OpVariable %ptr Uniform +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("is a matrix with stride 8 not satisfying alignment to 16")); +} + +TEST_F(ValidateDecorations, MatrixArrayArrayMissingMajorness) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 MatrixStride 16 +OpDecorate %array ArrayStride 32 +OpDecorate %rta ArrayStride 64 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%rta = OpTypeRuntimeArray %array +%block = OpTypeStruct %rta +%ptr = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "must be explicitly laid out with RowMajor or ColMajor decorations")); +} + +TEST_F(ValidateDecorations, MatrixArrayArrayMissingStride) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 ColMajor +OpDecorate %array ArrayStride 32 +OpDecorate %rta ArrayStride 64 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%rta = OpTypeRuntimeArray %array +%block = OpTypeStruct %rta +%ptr = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("must be explicitly laid out with MatrixStride decorations")); +} + +TEST_F(ValidateDecorations, MatrixArrayArrayBadStride) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpMemberDecorate %block 0 ColMajor +OpMemberDecorate %block 0 MatrixStride 8 +OpDecorate %array ArrayStride 32 +OpDecorate %a ArrayStride 64 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%int_2 = OpConstant %int 2 +%vec = OpTypeVector %float 2 +%mat = OpTypeMatrix %vec 2 +%array = OpTypeArray %mat %int_2 +%a = OpTypeArray %array %int_2 +%block = OpTypeStruct %a +%ptr = OpTypePointer Uniform %block +%var = OpVariable %ptr Uniform +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("is a matrix with stride 8 not satisfying alignment to 16")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsInputVertex) { + const std::string body = R"( + OpCapability Shader + OpCapability DrawParameters + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %gl_BaseInstance1 %gl_BaseInstance2 + 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_BaseInstance1 BuiltIn BaseInstance + OpDecorate %gl_BaseInstance2 BuiltIn BaseInstance + %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 + %float_0 = OpConstant %float 0 + %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_ptr_Input_int = OpTypePointer Input %int +%gl_BaseInstance1 = OpVariable %_ptr_Input_int Input +%gl_BaseInstance2 = OpVariable %_ptr_Input_int Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %20 = OpLoad %int %gl_BaseInstance1 + %21 = OpConvertSToF %float %20 + %22 = OpVectorTimesScalar %v4float %17 %21 + %24 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %24 %22 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpEntryPoint contains duplicate input variables with " + "BaseInstance builtin")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09658")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsInputMesh) { + const std::string body = R"( + OpCapability DrawParameters + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_DrawID_1 %gl_DrawID_2 + OpExecutionMode %main LocalSize 1 1 1 + OpExecutionMode %main OutputVertices 32 + OpExecutionMode %main OutputPrimitivesEXT 32 + OpExecutionMode %main OutputTrianglesEXT + OpDecorate %gl_DrawID_1 BuiltIn DrawIndex + OpDecorate %gl_DrawID_2 BuiltIn DrawIndex + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int + %gl_DrawID_1 = OpVariable %_ptr_Input_int Input + %gl_DrawID_2 = OpVariable %_ptr_Input_int Input + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + %9 = OpLoad %int %gl_DrawID_1 + %11 = OpBitcast %uint %9 + %12 = OpLoad %int %gl_DrawID_2 + %13 = OpBitcast %uint %12 + OpSetMeshOutputsEXT %11 %13 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpEntryPoint contains duplicate input variables with " + "DrawIndex builtin")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09658")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsInputCompute) { + const std::string body = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %_ %gl_WorkGroupID_1 %gl_WorkGroupID_2 + OpExecutionMode %main LocalSize 1 1 1 + OpMemberDecorate %Buffers 0 Offset 0 + OpDecorate %Buffers Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + OpDecorate %gl_WorkGroupID_1 BuiltIn WorkgroupId + OpDecorate %gl_WorkGroupID_2 BuiltIn WorkgroupId + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %Buffers = OpTypeStruct %v3uint +%_ptr_StorageBuffer_Buffers = OpTypePointer StorageBuffer %Buffers + %_ = OpVariable %_ptr_StorageBuffer_Buffers StorageBuffer + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_WorkGroupID_1 = OpVariable %_ptr_Input_v3uint Input +%gl_WorkGroupID_2 = OpVariable %_ptr_Input_v3uint Input +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpLoad %v3uint %gl_WorkGroupID_1 + %16 = OpLoad %v3uint %gl_WorkGroupID_2 + %17 = OpIAdd %v3uint %15 %16 + %19 = OpAccessChain %_ptr_StorageBuffer_v3uint %_ %int_0 + OpStore %19 %17 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpEntryPoint contains duplicate input variables with " + "WorkgroupId builtin")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09658")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsOutputFragment) { + const std::string body = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragDepth_1 %gl_FragDepth_2 + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main DepthReplacing + OpDecorate %gl_FragDepth_1 BuiltIn FragDepth + OpDecorate %gl_FragDepth_2 BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth_1 = OpVariable %_ptr_Output_float Output +%gl_FragDepth_2 = OpVariable %_ptr_Output_float Output + %float_1 = OpConstant %float 1 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %gl_FragDepth_1 %float_1 + %10 = OpLoad %float %gl_FragDepth_1 + %11 = OpFAdd %float %10 %float_1 + OpStore %gl_FragDepth_2 %11 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpEntryPoint contains duplicate output variables with " + "FragDepth builtin")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09659")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsRayTmaxKHR) { + const std::string body = R"( + OpCapability RayTracingKHR + OpExtension "SPV_KHR_ray_tracing" + OpMemoryModel Logical GLSL450 + OpEntryPoint AnyHitKHR %main "main" %gl_RayTmaxEXT %gl_HitTEXT %incomingPayload + OpDecorate %gl_RayTmaxEXT BuiltIn RayTmaxKHR + OpDecorate %gl_HitTEXT BuiltIn RayTmaxKHR + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Input_float = OpTypePointer Input %float +%gl_RayTmaxEXT = OpVariable %_ptr_Input_float Input + %gl_HitTEXT = OpVariable %_ptr_Input_float Input + %v4float = OpTypeVector %float 4 +%_ptr_IncomingRayPayloadKHR_v4float = OpTypePointer IncomingRayPayloadKHR %v4float +%incomingPayload = OpVariable %_ptr_IncomingRayPayloadKHR_v4float IncomingRayPayloadKHR + %main = OpFunction %void None %3 + %5 = OpLabel + %a = OpVariable %_ptr_Function_float Function + %b = OpVariable %_ptr_Function_float Function + %11 = OpLoad %float %gl_RayTmaxEXT + OpStore %a %11 + %14 = OpLoad %float %gl_HitTEXT + OpStore %b %14 + %18 = OpLoad %float %a + %19 = OpLoad %float %b + %22 = OpCompositeConstruct %v4float %18 %18 %19 %19 + OpStore %incomingPayload %22 + OpTerminateRayKHR + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpEntryPoint contains duplicate input variables with RayTmax")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09658")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsBlock) { + const std::string body = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %var + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn Position + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float %v4float +%_ptr_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %var = OpVariable %_ptr_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %float_0 = OpConstant %float 0 + %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 + %ptr_vec4 = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %ptr_vec4 %var %int_0 + OpStore %19 %17 + %22 = OpAccessChain %ptr_vec4 %var %int_1 + OpStore %22 %17 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpEntryPoint contains duplicate output variables with Position")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09659")); +} + +TEST_F(ValidateDecorations, MultipleBuiltinsBlockMixed) { + const std::string body = R"( + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %var %position + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpDecorate %gl_PerVertex Block + OpDecorate %position BuiltIn Position + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%gl_PerVertex = OpTypeStruct %v4float +%_ptr_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %var = OpVariable %_ptr_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %float_0 = OpConstant %float 0 + %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 + %ptr_vec4 = OpTypePointer Output %v4float + %position = OpVariable %ptr_vec4 Output + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %ptr_vec4 %var %int_0 + OpStore %19 %17 + OpStore %position %17 + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpEntryPoint contains duplicate output variables with Position")); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-09659")); +} + +TEST_F(ValidateDecorations, UntypedVariableWorkgroupRequiresStruct) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Untyped workgroup variables in shaders must be block " + "decorated structs")); +} + +TEST_F(ValidateDecorations, UntypedVariableWorkgroupRequiresBlockStruct) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Untyped workgroup variables in shaders must be block " + "decorated")); +} + +TEST_F(ValidateDecorations, UntypedVariableStorageBufferMissingBlock) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %struct "struct" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("StorageBuffer id '2' is missing Block decoration")); +} + +TEST_F(ValidateDecorations, UntypedVariableUniformMissingBlock) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %struct "struct" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Uniform +%var = OpUntypedVariableKHR %ptr Uniform %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Uniform id '2' is missing Block or BufferBlock decoration")); +} + +TEST_F(ValidateDecorations, UntypedVariablePushConstantMissingBlock) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %struct "struct" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR PushConstant +%var = OpUntypedVariableKHR %ptr PushConstant %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("PushConstant id '2' is missing Block decoration")); +} + +using UntypedVariableSetAndBinding = spvtest::ValidateBase; + +TEST_P(UntypedVariableSetAndBinding, MissingSet) { + const auto sc = GetParam(); + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %var "var" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var Binding 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR )" + + sc + R"( +%var = OpUntypedVariableKHR %ptr )" + sc + R"( %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %struct %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr(sc + " id '2' is missing DescriptorSet decoration")); +} + +TEST_P(UntypedVariableSetAndBinding, MissingBinding) { + const auto sc = GetParam(); + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %var "var" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var DescriptorSet 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR )" + + sc + R"( +%var = OpUntypedVariableKHR %ptr )" + sc + R"( %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %struct %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr(sc + " id '2' is missing Binding decoration")); +} + +INSTANTIATE_TEST_SUITE_P(ValidateUntypedVariableSetAndBinding, + UntypedVariableSetAndBinding, + Values("StorageBuffer", "Uniform")); + +using UntypedPointerLayout = + spvtest::ValidateBase>; + +TEST_P(UntypedPointerLayout, BadOffset) { + const auto sc = std::get<0>(GetParam()); + const auto op = std::get<1>(GetParam()); + const std::string set = (sc == "StorageBuffer" || sc == "Uniform" + ? R"(OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +)" + : R"()"); + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpName %var "var" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpMemberDecorate %struct 1 Offset 4 +)" + set + R"(OpMemberDecorate %test_type 0 Offset 0 +OpMemberDecorate %test_type 1 Offset 1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%struct = OpTypeStruct %int %int +%test_type = OpTypeStruct %int %int +%test_val = OpConstantNull %test_type +%ptr = OpTypeUntypedPointerKHR )" + + sc + R"( +%var = OpUntypedVariableKHR %ptr )" + sc + R"( %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +)" + op + R"( +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + const bool read_only = sc == "Uniform" || sc == "PushConstant"; + if (!read_only || op.find("OpStore") == std::string::npos) { + EXPECT_THAT(getDiagnosticString(), + HasSubstr("member 1 at offset 1 is not aligned to")); + } +} + +TEST_P(UntypedPointerLayout, BadStride) { + const auto sc = std::get<0>(GetParam()); + const auto op = std::get<1>(GetParam()); + const std::string set = (sc == "StorageBuffer" || sc == "Uniform" + ? R"(OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +)" + : R"()"); + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpName %var "var" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpMemberDecorate %struct 1 Offset 4 +)" + set + R"(OpDecorate %test_type ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_4 = OpConstant %int 4 +%int4 = OpTypeVector %int 4 +%test_type = OpTypeArray %int4 %int_4 +%test_val = OpConstantNull %test_type +%struct = OpTypeStruct %int %int +%ptr = OpTypeUntypedPointerKHR )" + + sc + R"( +%var = OpUntypedVariableKHR %ptr )" + sc + R"( %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +)" + op + R"( +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + const bool read_only = sc == "Uniform" || sc == "PushConstant"; + if (!read_only || op.find("OpStore") == std::string::npos) { + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("array with stride 4 not satisfying alignment to 16")); + } +} + +INSTANTIATE_TEST_SUITE_P( + ValidateUntypedPointerLayout, UntypedPointerLayout, + Combine(Values("StorageBuffer", "Uniform", "PushConstant", "Workgroup"), + Values("%gep = OpUntypedAccessChainKHR %ptr %test_type %var %int_0", + "%gep = OpUntypedInBoundsAccessChainKHR %ptr %test_type " + "%var %int_0", + "%gep = OpUntypedPtrAccessChainKHR %ptr %test_type %var " + "%int_0 %int_0", + "%ld = OpLoad %test_type %var", "OpStore %var %test_val"))); + +TEST_F(ValidateDecorations, UntypedArrayLengthMissingOffset) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%struct = OpTypeStruct %array +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%len = OpUntypedArrayLengthKHR %int %struct %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("member 0 is missing an Offset decoration")); +} + +TEST_F(ValidateDecorations, ComponentMultipleArrays) { + const std::string spirv = R"( + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %main "main" %_ %FOO %FOO0 + OpExecutionMode %main Triangles + OpExecutionMode %main SpacingEqual + OpExecutionMode %main VertexOrderCcw + OpSource GLSL 460 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + 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 %FOO "FOO" + 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 %FOO Component 2 + OpDecorate %FOO Location 1 + OpDecorate %FOO0 Location 1 + OpDecorate %FOO0 Component 0 + %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 + %v2float = OpTypeVector %float 2 + %uint_2 = OpConstant %uint 2 +%_arr_v2float_uint_2 = OpTypeArray %v2float %uint_2 + %uint_32 = OpConstant %uint 32 +%_arr__arr_v2float_uint_2_uint_32 = OpTypeArray %_arr_v2float_uint_2 %uint_32 +%_ptr_Input__arr__arr_v2float_uint_2_uint_32 = OpTypePointer Input %_arr__arr_v2float_uint_2_uint_32 + %FOO = OpVariable %_ptr_Input__arr__arr_v2float_uint_2_uint_32 Input + %FOO0 = OpVariable %_ptr_Input__arr__arr_v2float_uint_2_uint_32 Input +%_ptr_Input_v2float = OpTypePointer Input %v2float + %int_1 = OpConstant %int 1 + %uint_0 = OpConstant %uint 0 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %24 = OpAccessChain %_ptr_Input_v2float %FOO %int_0 %int_0 + %25 = OpLoad %v2float %24 + %27 = OpAccessChain %_ptr_Input_v2float %FOO0 %int_1 %int_1 + %28 = OpLoad %v2float %27 + %29 = OpFAdd %v2float %25 %28 + %32 = OpAccessChain %_ptr_Output_float %_ %int_0 %uint_0 + %33 = OpCompositeExtract %float %29 0 + OpStore %32 %33 + %34 = OpAccessChain %_ptr_Output_float %_ %int_0 %uint_1 + %35 = OpCompositeExtract %float %29 1 + OpStore %34 %35 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +const std::string kNodeShaderPrelude = R"( +OpCapability Shader +OpCapability ShaderEnqueueAMDX +OpExtension "SPV_AMDX_shader_enqueue" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpEntryPoint GLCompute %other "other" +)"; + +const std::string kNodeShaderPostlude = R"( +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%node0 = OpConstantStringAMDX "node0" +%node1 = OpConstantStringAMDX "node1" +%node2 = OpConstantStringAMDX "node2" +%S = OpTypeStruct +%_payloadarr_S = OpTypeNodePayloadArrayAMDX %S +%_payloadarr_S_0 = OpTypeNodePayloadArrayAMDX %S +%bool = OpTypeBool +%true = OpConstantTrue %bool +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%other = OpFunction %void None %void_fn +%entry0 = OpLabel +OpReturn +OpFunctionEnd +)"; + +TEST_F(ValidateDecorations, NodeShader) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); +} + +TEST_F(ValidateDecorations, NodeShaderDecoratePayloadNodeName) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorate %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorate %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Decorations taking ID parameters may not be used with OpDecorate")); +} + +TEST_F(ValidateDecorations, NodeShaderDecoratePayloadNodeBaseIndex) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorate %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Decorations taking ID parameters may not be used with OpDecorate")); +} + +TEST_F(ValidateDecorations, NodeShaderDecoratePayloadNodeArraySize) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorate %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Decorations taking ID parameters may not be used with OpDecorate")); +} + +TEST_F(ValidateDecorations, NodeShaderDecorateNodeSharesPayloadLimitsWith) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorate %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Decorations taking ID parameters may not be used with OpDecorate")); +} + +TEST_F(ValidateDecorations, BlockArrayWithStride) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %array ArrayStride 4 +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%struct = OpTypeStruct %int +%array = OpTypeArray %struct %int_4 +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Array containing a Block or BufferBlock must not be " + "decorated with ArrayStride")); +} + +TEST_F(ValidateDecorations, BufferBlockRuntimeArrayWithStride) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +OpDecorate %struct BufferBlock +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %array ArrayStride 4 +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%array = OpTypeRuntimeArray %struct +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Array containing a Block or BufferBlock must not be " + "decorated with ArrayStride")); +} + +TEST_F(ValidateDecorations, BlockArrayWithoutStride) { + const std::string spirv = R"( +OpCapability Shader +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%struct = OpTypeStruct %int +%array = OpTypeArray %struct %int_4 +%ptr = OpTypePointer StorageBuffer %array +%var = OpVariable %ptr StorageBuffer +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +TEST_F(ValidateDecorations, BlockArrayWithoutStrideUntypedAccessChain) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%struct = OpTypeStruct %int +%array = OpTypeArray %struct %int_4 +%void = OpTypeVoid +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %array +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpUntypedAccessChainKHR %ptr %array %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_derivatives_test.cpp b/third_party/spirv-tools/test/val/val_derivatives_test.cpp index e605f3a032..6ddafe493e 100644 --- a/third_party/spirv-tools/test/val/val_derivatives_test.cpp +++ b/third_party/spirv-tools/test/val/val_derivatives_test.cpp @@ -156,8 +156,8 @@ TEST_F(ValidateDerivatives, OpDPdxWrongExecutionModel) { CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Derivative instructions require Fragment or GLCompute " - "execution model: DPdx")); + HasSubstr("Derivative instructions require Fragment, GLCompute, " + "MeshEXT or TaskEXT execution model: DPdx")); } TEST_F(ValidateDerivatives, NoExecutionModeGLCompute) { @@ -181,8 +181,9 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Derivative instructions require " - "DerivativeGroupQuadsNV or DerivativeGroupLinearNV " - "execution mode for GLCompute execution model")); + "DerivativeGroupQuadsKHR or DerivativeGroupLinearKHR " + "execution mode for GLCompute, MeshEXT or TaskEXT " + "execution model")); } using ValidateHalfDerivatives = spvtest::ValidateBase; diff --git a/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp b/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp index 554e78b082..445be08a5b 100644 --- a/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp +++ b/third_party/spirv-tools/test/val/val_ext_inst_debug_test.cpp @@ -21,6 +21,7 @@ #include #include "gmock/gmock.h" +#include "spirv-tools/libspirv.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -84,6 +85,15 @@ using ValidateVulkan100DebugInfoDebugValue = spvtest::ValidateBase>; using ValidateVulkan100DebugInfo = spvtest::ValidateBase; +const static std::string shader_extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + +const static std::string opencl_extension = R"( +%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" +)"; + std::string GenerateShaderCodeForDebugInfo( const std::string& op_string_instructions, const std::string& op_const_instructions, @@ -118,6 +128,7 @@ OpCapability Int64 ss << "OpExecutionMode %main OriginUpperLeft\n"; } + ss << "%main_name = OpString \"main\"\n"; ss << op_string_instructions; ss << R"( @@ -181,6 +192,9 @@ OpCapability Int64 %u32_1 = OpConstant %u32 1 %u32_2 = OpConstant %u32 2 %u32_3 = OpConstant %u32 3 +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 %s32_0 = OpConstant %s32 0 %s32_1 = OpConstant %s32 1 @@ -308,12 +322,8 @@ TEST_F(ValidateOpenCL100DebugInfo, UseDebugInstructionOutOfFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -327,12 +337,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugSourceInFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst, - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", "", dbg_inst, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -352,13 +358,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugSourceInFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst, - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", "", dbg_inst, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -373,8 +374,6 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %int_name = OpString "int" %foo_name = OpString "foo" )"; @@ -384,7 +383,7 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 Signed %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src 1 1 %main_info FlagIsLocal %expr = OpExtInst %void %DbgExt DebugExpression )"; @@ -392,14 +391,10 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { const std::string body = R"( %foo = OpVariable %u32_ptr_function Function %foo_val = OpLoad %u32 %foo -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header + GetParam(), body, extension, "Vertex")); + src, "", dbg_inst_header + GetParam(), body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " @@ -412,8 +407,6 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %int_name = OpString "int" %foo_name = OpString "foo" )"; @@ -423,7 +416,7 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_1 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %expr = OpExtInst %void %DbgExt DebugExpression )"; @@ -432,20 +425,10 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %foo = OpVariable %u32_ptr_function Function %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main %foo_val = OpLoad %u32 %foo -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header + GetParam(), body, extension, "Vertex")); + src, "", dbg_inst_header + GetParam(), body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " @@ -465,27 +448,21 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionForwardReference) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -494,8 +471,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( @@ -503,19 +478,15 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %dbgNone +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %dbgNone )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -528,8 +499,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) { } " %float_name = OpString "float" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -542,20 +511,16 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %foo = OpVariable %f32_ptr_function Function -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -575,12 +540,8 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -613,14 +574,10 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %VS_OUTPUT_color_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_color_name %v4float_info %dbg_src 3 3 %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -652,14 +609,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("forward referenced IDs have not been defined")); @@ -753,12 +706,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnit) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -773,12 +722,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnitFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %src HLSL )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Source must be a result id of " @@ -796,18 +741,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugCompilationUnitFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %src %u32_5 )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, dbg_inst, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Source must be a result id of " @@ -833,14 +768,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailName) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %int_32 %int_32 Float -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Name must be a result id of " @@ -856,27 +787,16 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailName) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %u32_32 %u32_32 %u32_3 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Name must be a result id of " @@ -902,14 +822,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailSize) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name Float -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Size must be a result id of " @@ -925,33 +841,47 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailSize) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name %u32_3 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Size must be a result id of " "OpConstant")); } +TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailFlags) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%f32_32 = OpConstant %f32 32 +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_3 %u32_3 %f32_32 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("expected operand Flags must be a result id of 32-bit " + "unsigned OpConstant")); +} + TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) { const std::string src = R"( %src = OpString "simple.hlsl" @@ -972,14 +902,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %float_info Function FlagIsLocal -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1003,18 +929,14 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointerFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %dbg_src Function FlagIsLocal -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected operand Base Type must be a result id of " - "DebugTypeBasic")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("expected operand Base Type is not a valid debug type")); } TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) { @@ -1037,14 +959,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info ConstType -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1068,18 +986,14 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifierFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit ConstType -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected operand Base Type must be a result id of " - "DebugTypeBasic")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("expected operand Base Type is not a valid debug type")); } TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { const std::string src = R"( @@ -1090,12 +1004,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1103,15 +1011,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1124,12 +1027,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1137,19 +1034,14 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("expected operand Base Type must be a result id of " - "DebugTypeBasic")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("expected operand Base Type is not a valid debug type")); } TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) { @@ -1168,14 +1060,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %int_32 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1185,7 +1073,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) { %code = OpString "main() {}" %float_name = OpString "float" %int_name = OpString "int" -%main_name = OpString "main" %foo_name = OpString "foo" )"; @@ -1202,14 +1089,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src 1 1 %main_info FlagIsLocal %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1229,14 +1112,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailBaseType) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %int_32 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type is not a valid debug " @@ -1259,14 +1138,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCount) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1291,14 +1166,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1323,14 +1194,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1344,7 +1211,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -%main_name = OpString "main" %foo_name = OpString "foo" )"; @@ -1360,14 +1226,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 1 %main_info FlagIsLocal %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1381,12 +1243,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1394,15 +1250,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_32 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1412,15 +1263,11 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) { %code = OpString "main() {}" %float_name = OpString "float" %uint_name = OpString "uint" -%main_name = OpString "main" %foo_name = OpString "foo" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_6 = OpConstant %u32 6 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1432,15 +1279,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1449,12 +1291,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1462,15 +1298,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %u32_32 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type is not a valid debug " @@ -1482,12 +1313,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1495,15 +1320,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1517,12 +1337,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1530,15 +1344,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1552,12 +1361,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1565,15 +1368,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1582,15 +1380,11 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -%main_name = OpString "main" %foo_name = OpString "foo" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_6 = OpConstant %u32 6 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1601,15 +1395,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1634,14 +1423,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVector) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1661,14 +1446,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1691,14 +1472,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1721,14 +1498,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentFive) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 5 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1740,12 +1513,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1753,15 +1520,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1770,12 +1532,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1783,15 +1539,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1803,12 +1554,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1816,15 +1561,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be positive " @@ -1836,12 +1576,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1849,15 +1583,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_5 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be positive " @@ -1872,9 +1601,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1884,15 +1610,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_4 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1904,9 +1625,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1916,15 +1634,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %dbg_src %u32_4 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Vector Type must be a result id of " @@ -1939,9 +1652,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1951,15 +1661,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %dbg_src %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Vector Count must be a result id of " @@ -1974,9 +1679,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1986,15 +1688,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_0 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Vector Count must be positive " @@ -2009,9 +1706,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -2021,15 +1715,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_5 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Vector Count must be positive " @@ -2053,14 +1742,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypedef) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src 1 1 %comp_unit -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2086,12 +1771,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugTypedef, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypedef )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + @@ -2117,12 +1798,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2130,15 +1805,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2148,12 +1818,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -2166,13 +1830,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypedef )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + @@ -2200,8 +1859,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunction) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2217,14 +1874,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunction) { %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %float_info %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void %float_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2232,8 +1885,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2246,14 +1897,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %dbg_src %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2264,8 +1911,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailParam) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2278,14 +1923,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailParam) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %void -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2296,15 +1937,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2315,15 +1948,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) { %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %float_info %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void %float_info %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2331,15 +1959,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2347,15 +1967,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %dbg_src %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2366,15 +1981,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2382,15 +1989,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %void -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2417,14 +2019,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeEnum) { %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2450,12 +2048,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugTypeEnum, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2496,12 +2090,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2512,15 +2100,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) { %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2530,12 +2113,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -2548,13 +2125,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2604,8 +2176,6 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -2621,17 +2191,13 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2650,8 +2216,6 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -2672,17 +2236,13 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + " must be ")); @@ -2746,12 +2306,8 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); if (!param.second.empty()) { EXPECT_THAT(getDiagnosticString(), @@ -2805,12 +2361,8 @@ struct foo : VS_OUTPUT {}; %child = OpExtInst %void %DbgExt DebugTypeInheritance )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2849,14 +2401,9 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2868,15 +2415,10 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_128 %u32_3 %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %foo_name %u32_0 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2895,14 +2437,9 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2918,13 +2455,8 @@ main() {} %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + " must be ")); @@ -2971,9 +2503,6 @@ main() {} )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2987,13 +2516,8 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); if (!param.second.empty()) { EXPECT_THAT(getDiagnosticString(), @@ -3033,23 +2557,17 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionDeclaration) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)"; +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3061,8 +2579,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugFunction, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const auto& param = GetParam(); @@ -3072,16 +2588,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic %main_info = OpExtInst %void %DbgExt DebugFunction )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3091,25 +2603,25 @@ INSTANTIATE_TEST_SUITE_P( AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugFunction, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic 13 %main)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic 13 %main)", "Linkage Name"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %void)", + R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %void)", "Function"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main %dbg_src)", + R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %dbg_src)", "Declaration"), })); @@ -3121,8 +2633,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugFunctionDeclaration, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const auto& param = GetParam(); @@ -3135,12 +2645,8 @@ main() {} %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3151,16 +2657,16 @@ INSTANTIATE_TEST_SUITE_P( ValidateOpenCL100DebugInfoDebugFunctionDeclaration, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_name FlagIsPublic)", + R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic)", @@ -3175,13 +2681,9 @@ TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDeclaration) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3190,17 +2692,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13 )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3212,13 +2709,9 @@ TEST_P(ValidateVulkan100DebugInfoDebugFunction, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3230,17 +2723,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %main_info = OpExtInst %void %DbgExt DebugFunction )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3250,22 +2738,22 @@ INSTANTIATE_TEST_SUITE_P( AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugFunction, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3 %u32_13)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3 %u32_13)", "Linkage Name"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13 %dbg_src)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13 %dbg_src)", "Declaration"), })); @@ -3277,13 +2765,9 @@ TEST_P(ValidateVulkan100DebugInfoDebugFunctionDeclaration, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3298,13 +2782,8 @@ main() {} %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3315,27 +2794,54 @@ INSTANTIATE_TEST_SUITE_P( ValidateVulkan100DebugInfoDebugFunctionDeclaration, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_linkage_name %u32_3)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3)", "Linkage Name"), })); +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionType) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +%uint_name = OpString "uint" +)"; + + const std::string constants = R"( +%u32_6 = OpConstant %u32 6 +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%uint_info = OpExtInst %void %DbgExt DebugTypeBasic %uint_name %u32_32 %u32_6 %u32_0 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %uint_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunction: expected operand Type must be a result " + "id of DebugTypeFunction")); +} + TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" )"; const std::string dbg_inst_header = R"( @@ -3343,12 +2849,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 1 1 %comp_unit %main_name)"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3356,7 +2858,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" )"; const auto& param = GetParam(); @@ -3368,12 +2869,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) { %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3400,14 +2897,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailScope) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -3425,14 +2918,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailInlinedAt) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At")); } @@ -3441,27 +2930,16 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLexicalBlock) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src %u32_1 %u32_1 %comp_unit %main_name -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3469,12 +2947,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const auto& param = GetParam(); @@ -3486,13 +2958,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) { %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3512,11 +2979,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "void main() {}" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( @@ -3526,15 +2988,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -3543,11 +3000,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "void main() {}" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( @@ -3557,15 +3009,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At")); } @@ -3587,14 +3034,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugLocalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3620,12 +3063,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLocalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugLocalVariable )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3657,10 +3096,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -3668,15 +3104,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3689,10 +3120,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -3705,13 +3133,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugLocalVariable )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3757,14 +3180,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugDeclare) { const std::string body = R"( %foo = OpVariable %f32_ptr_function Function %decl = OpExtInst %void %DbgExt DebugDeclare %foo_info %foo %null_expr -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3859,12 +3278,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugDeclare, Fail) { %decl = OpExtInst %void %DbgExt DebugDeclare )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, ss.str(), extension, "Vertex")); + src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3887,10 +3302,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -3899,11 +3311,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) { %null_expr = OpExtInst %void %DbgExt DebugExpression %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -3912,7 +3319,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3994,10 +3401,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4006,11 +3410,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const auto& param = GetParam(); @@ -4022,7 +3421,7 @@ OpExtension "SPV_KHR_non_semantic_info" << param.first; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, ss.str(), extension, "Vertex")); + src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4043,12 +3442,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugExpression) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1 )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4058,12 +3453,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugExpressionFail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4078,13 +3469,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpression) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1 )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4094,13 +3480,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpressionFail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4132,14 +3513,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4169,14 +3546,10 @@ main() {} %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4189,7 +3562,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4206,14 +3578,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4226,7 +3594,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4241,14 +3608,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Target must be DebugTypeComposite or " @@ -4264,7 +3627,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4281,14 +3643,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4306,12 +3664,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4322,15 +3674,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4344,12 +3691,6 @@ main() {} %ty_name = OpString "Texture" %t_name = OpString "T" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4361,15 +3702,10 @@ main() {} %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4382,13 +3718,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4400,15 +3729,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4421,13 +3745,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4437,15 +3754,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Target must be DebugTypeComposite or " @@ -4461,13 +3773,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4478,15 +3783,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4512,14 +3812,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4542,14 +3838,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableStaticMember) { %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Class %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsPublic %a %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src 0 0 %t %u32_0 %int_32 FlagIsPublic %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate %a -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4571,14 +3863,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableDebugInfoNone) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %dbgNone FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4599,14 +3887,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableConst) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4632,12 +3916,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugGlobalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugGlobalVariable )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4672,12 +3952,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4685,15 +3959,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4703,12 +3972,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4718,15 +3981,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) { %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src %u32_0 %u32_0 %u32_0 %u32_32 %u32_3 %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3 %a %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %t %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4736,12 +3994,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4750,15 +4002,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %dbgNone %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4768,12 +4015,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4781,15 +4022,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4799,12 +4035,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -4817,13 +4047,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugGlobalVariable )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4857,29 +4082,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAt) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4888,29 +4107,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %inlined_at )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -4920,29 +4133,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail2) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %main_info )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined")); } @@ -4952,14 +4159,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4969,11 +4168,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -4981,7 +4175,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4990,14 +4184,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5007,11 +4193,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %inlined_at %inlined_at -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5019,7 +4200,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -5029,14 +4210,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5046,11 +4219,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %main_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5058,7 +4226,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined")); } @@ -5087,14 +4255,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugValue) { const std::string body = R"( %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %int_3 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5126,14 +4290,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugValueWithVariableIndex) { const std::string body = R"( %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %len_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5164,12 +4324,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugValue, Fail) { %decl = OpExtInst %void %DbgExt DebugValue )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, ss.str(), extension, "Vertex")); + src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -5192,10 +4348,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValue) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5205,11 +4358,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValue) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5217,7 +4365,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5232,10 +4380,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5247,11 +4392,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) { %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0 %len_info = OpExtInst %void %DbgExt DebugLocalVariable %len_name %int_info %dbg_src %u32_0 %u32_0 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5259,7 +4399,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5272,10 +4412,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5285,11 +4422,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const auto& param = GetParam(); @@ -5300,7 +4432,7 @@ OpExtension "SPV_KHR_non_semantic_info" << param.first; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, ss.str(), extension, "Vertex")); + src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -5475,6 +4607,446 @@ TEST_F(ValidateVulkan100DebugInfo, VulkanDebugInfoSample) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailFunction) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_type_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: expected operand Function " + "must be a result id of DebugFunction")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main_name +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: expected operand Definition " + "must be a result id of OpFunction")); +} + +// TODO - Need to track in function scope +TEST_F(ValidateVulkan100DebugInfo, DISABLED_DebugFunctionDefinitionDuplicate) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info1 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%main_info2 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def1 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info1 %main +%main_def2 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info2 %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: Was used multiple times in " + "single function block")); +} + +// TODO - Need to track in function scope +TEST_F(ValidateVulkan100DebugInfo, + DISABLED_DebugFunctionDefinitionDuplicateReference) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %foo +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: Was referenced a " + "DebugFunction that was already referenced before")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionWrongDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: operand Definition must " + "point to the OpFunction it is inside")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionNonEntryBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string constants = R"( +%false = OpConstantFalse %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +OpSelectionMerge %merge_block None +OpBranchConditional %false %second_block %merge_block +%second_block = OpLabel +OpReturn +%merge_block = OpLabel +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: must be in the entry basic " + "block of the function")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionMultiFunctions) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %foo +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLine) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +%line2 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +%no_line = OpExtInst %void %DbgExt DebugNoLine +%line3 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugNoLineOutOfBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%no_line = OpExtInst %void %DbgExt DebugNoLine +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("debug info extension must appear in a function body")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineOutOfBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%line = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("debug info extension must appear in a function body")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineSource) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +%int_name = OpString "int" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0 +)"; + + const std::string body = R"( +%line = OpExtInst %void %DbgExt DebugLine %int_info %u32_2 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Source must be a result " + "id of DebugSource")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineFloat) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %f32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineInt64) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u64_1 %u64_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineSpecConstant) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%spec_int = OpSpecConstant %u32 2 +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %spec_int %u32_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineLineEndSmaller) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_2 %u32_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("DebugLine: operand Line End (1) is less than Line Start (2)")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmaller) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_1 %u32_1 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: operand Column End (0) is less than Column " + "Start (1) when Line Start equals Line End")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmallerMultiline) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_1 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_ext_inst_test.cpp b/third_party/spirv-tools/test/val/val_ext_inst_test.cpp index e685acde5d..23fd3aacf4 100644 --- a/third_party/spirv-tools/test/val/val_ext_inst_test.cpp +++ b/third_party/spirv-tools/test/val/val_ext_inst_test.cpp @@ -447,6 +447,7 @@ OpCapability Matrix %u8arr_uniform_constant = OpVariable %u8arr_ptr_uniform_constant UniformConstant %u8_ptr_uniform_constant = OpTypePointer UniformConstant %u8 %u8_ptr_generic = OpTypePointer Generic %u8 +%u8_ptr_input = OpTypePointer Input %u8 %main = OpFunction %void None %func %main_entry = OpLabel @@ -5269,6 +5270,26 @@ TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotUniformConstStorageClass) { "be UniformConstant")); } +TEST_F(ValidateExtInst, + OpenCLStdPrintfFormatWithExtensionNotAllowedStorageClass) { + const std::string body = R"( +%format_const = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0 +%format = OpBitcast %u8_ptr_input %format_const +%val1 = OpExtInst %u32 %extinst printf %format %u32_0 %u32_1 +)"; + + const std::string extension = R"( +OpExtension "SPV_EXT_relaxed_printf_string_address_space" +)"; + + CompileSuccessfully(GenerateKernelCode(body, extension)); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpenCL.std printf: expected Format storage class to " + "be UniformConstant, Crossworkgroup, Workgroup, " + "Function, or Generic")); +} + TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotU8Pointer) { const std::string body = R"( %format = OpAccessChain %u32_ptr_uniform_constant %u32vec8_uniform_constant %u32_0 @@ -6239,6 +6260,197 @@ OpFunctionEnd HasSubstr("Name must match an entry-point for Kernel")); } +TEST_F(ValidateClspvReflection, KernelArgumentsVersionGood) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_1 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateClspvReflection, KernelArgumentsVersionBad) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.4" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_1 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Version 4 of the Kernel instruction can only have 2 " + "additional operands")); +} + +TEST_F(ValidateClspvReflection, KernelNumArgumentsNotInt) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %float_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("NumArguments must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelNumArgumentsNotConstant) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%null = OpConstantNull %int +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %null +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("NumArguments must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelFlagsNotInt) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %float_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Flags must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelFlagsNotConstant) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%null = OpConstantNull %int +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %null +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Flags must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelAttributesNotString) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %int_0 %int_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Attributes must be an OpString")); +} + using ArgumentBasics = spvtest::ValidateBase>; @@ -6254,7 +6466,11 @@ INSTANTIATE_TEST_SUITE_P( std::make_pair("ArgumentSampledImage", "%int_0 %int_0"), std::make_pair("ArgumentStorageImage", "%int_0 %int_0"), std::make_pair("ArgumentSampler", "%int_0 %int_0"), - std::make_pair("ArgumentWorkgroup", "%int_0 %int_0")})); + std::make_pair("ArgumentWorkgroup", "%int_0 %int_0"), + std::make_pair("ArgumentPointerPushConstant", "%int_0 %int_4"), + std::make_pair("ArgumentPointerUniform", "%int_0 %int_0 %int_0 %int_4"), + std::make_pair("ArgumentStorageTexelBuffer", "%int_0 %int_0"), + std::make_pair("ArgumentUniformTexelBuffer", "%int_0 %int_0")})); TEST_P(ArgumentBasics, KernelNotAnExtendedInstruction) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6262,7 +6478,7 @@ TEST_P(ArgumentBasics, KernelNotAnExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6291,8 +6507,8 @@ TEST_P(ArgumentBasics, KernelFromDifferentImport) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" -%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6323,7 +6539,7 @@ TEST_P(ArgumentBasics, KernelWrongExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6353,7 +6569,7 @@ TEST_P(ArgumentBasics, ArgumentInfo) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6383,7 +6599,7 @@ TEST_P(ArgumentBasics, ArgumentInfoNotAnExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6414,8 +6630,8 @@ TEST_P(ArgumentBasics, ArgumentInfoFromDifferentImport) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" -%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6659,7 +6875,269 @@ INSTANTIATE_TEST_SUITE_P( std::make_pair( "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %float_0", "Z"), std::make_pair( - "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %null", "Z")})); + "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %null", "Z"), + std::make_pair("SpecConstantSubgroupMaxSize %float_0", "Size"), + std::make_pair("SpecConstantSubgroupMaxSize %null", "Size"), + std::make_pair( + "ArgumentPointerPushConstant %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentPointerPushConstant %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentPointerPushConstant %decl %int_0 %float_0 %int_0", + "Offset"), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %null %int_0", + "Offset"), + std::make_pair( + "ArgumentPointerPushConstant %decl %int_0 %int_0 %float_0", "Size"), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ArgumentPointerUniform %decl %float_0 %int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair( + "ArgumentPointerUniform %decl %null %int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %float_0 %int_0 %data", + "DescriptorSet"), + std::make_pair("ProgramScopeVariablesStorageBuffer %null %int_0 %data", + "DescriptorSet"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %int_0 %float_0 %data", + "Binding"), + std::make_pair("ProgramScopeVariablesStorageBuffer %int_0 %null %data", + "Binding"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %float_0 %int_0 %int_4", + "ObjectOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %null %int_0 %int_4", + "ObjectOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %float_0 %int_4", + "PointerOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %null %int_4", + "PointerOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %float_0", + "PointerSize"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %null", + "PointerSize"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl " + "%float_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %null " + "%int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%float_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%null %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %float_0 " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %null " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %float_0 " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %null " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentStorageTexelBuffer %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %int_0 %float_0 %int_0", + "DescriptorSet"), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %null %int_0", + "DescriptorSet"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %int_0 %int_0 %float_0", + "Binding"), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %int_0 %null", + "Binding"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentUniformTexelBuffer %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %int_0 %float_0 %int_0", + "DescriptorSet"), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %null %int_0", + "DescriptorSet"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %int_0 %int_0 %float_0", + "Binding"), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %int_0 %null", + "Binding"), + std::make_pair("ConstantDataPointerPushConstant %float_0 %int_4 %data", + "Offset"), + std::make_pair("ConstantDataPointerPushConstant %null %int_4 %data", + "Offset"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %float_0 %data", + "Size"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %null %data", + "Size"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %float_0 %int_4 %data", + "Offset"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %null %int_4 %data", + "Offset"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %float_0 %data", + "Size"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %null %data", + "Size"), + std::make_pair("PrintfInfo %float_0 %data %int_0 %int_0 %int_0", + "PrintfID"), + std::make_pair("PrintfInfo %null %data %int_0 %int_0 %int_0", + "PrintfID"), + std::make_pair("PrintfInfo %int_0 %data %float_0 %int_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %null %int_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %float_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %null %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %int_0 %null", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %int_0 %float_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %float_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %null", "ArgumentSizes"), + std::make_pair("PrintfBufferStorageBuffer %float_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("PrintfBufferStorageBuffer %null %int_0 %int_4", + "DescriptorSet"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %float_0 %int_4", + "Binding"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %null %int_4", + "Binding"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %float_0", + "Size"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %null", "Size"), + std::make_pair("PrintfBufferPointerPushConstant %float_0 %int_0 %int_4", + "Offset"), + std::make_pair("PrintfBufferPointerPushConstant %null %int_0 %int_4", + "Offset"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %float_0 %int_4", + "Size"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %null %int_4", + "Size"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %float_0", + "BufferSize"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %null", + "BufferSize")})); TEST_P(Uint32Constant, Invalid) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6667,7 +7145,7 @@ TEST_P(Uint32Constant, Invalid) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6705,7 +7183,15 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector>{ std::make_pair("ConstantDataStorageBuffer %int_0 %int_0 %int_0", "Data"), - std::make_pair("ConstantDataUniform %int_0 %int_0 %int_0", "Data")})); + std::make_pair("ConstantDataUniform %int_0 %int_0 %int_0", "Data"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %int_0 %int_0 %int_0", "Data"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %int_0 %int_0", + "Data"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %int_0 %int_0", + "Data"), + std::make_pair("PrintfInfo %int_0 %int_0", "FormatString")})); TEST_P(StringOperand, Invalid) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6713,7 +7199,7 @@ TEST_P(StringOperand, Invalid) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6741,6 +7227,348 @@ OpFunctionEnd EXPECT_THAT(getDiagnosticString(), HasSubstr(name + " must be an OpString")); } +using VersionCheck = spvtest::ValidateBase>; + +INSTANTIATE_TEST_SUITE_P( + ValidateClspvReflectionVersionCheck, VersionCheck, + ::testing::ValuesIn(std::vector>{ + std::make_pair("ArgumentStorageBuffer %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentUniform %decl %int_0 %int_0 %int_0", 1), + std::make_pair( + "ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 %int_0 %int_0", + 1), + std::make_pair( + "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentPodPushConstant %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentSampledImage %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentStorageImage %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentSampler %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentWorkgroup %decl %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantWorkgroupSize %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantGlobalOffset %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantWorkDim %int_0", 1), + std::make_pair("PushConstantGlobalOffset %int_0 %int_0", 1), + std::make_pair("PushConstantEnqueuedLocalSize %int_0 %int_0", 1), + std::make_pair("PushConstantGlobalSize %int_0 %int_0", 1), + std::make_pair("PushConstantRegionOffset %int_0 %int_0", 1), + std::make_pair("PushConstantNumWorkgroups %int_0 %int_0", 1), + std::make_pair("PushConstantRegionGroupOffset %int_0 %int_0", 1), + std::make_pair("ConstantDataStorageBuffer %int_0 %int_0 %data", 1), + std::make_pair("ConstantDataUniform %int_0 %int_0 %data", 1), + std::make_pair("LiteralSampler %int_0 %int_0 %int_0", 1), + std::make_pair( + "PropertyRequiredWorkgroupSize %decl %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantSubgroupMaxSize %int_0", 2), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %int_0 %int_0", + 3), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ProgramScopeVariablesStorageBuffer %int_0 %int_0 %data", + 3), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %int_0", 3), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %int_0 %int_0", + 4), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %int_0 %int_0", + 4), + std::make_pair("ConstantDataPointerPushConstant %int_0 %int_0 %data", + 5), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %int_0 %data", 5), + std::make_pair("PrintfInfo %int_0 %data", 5), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %int_0", 5), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %int_0", + 5)})); + +TEST_P(VersionCheck, V1) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 1) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 1")); + } +} + +TEST_P(VersionCheck, V2) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 2) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 2")); + } +} + +TEST_P(VersionCheck, V3) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.3" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 3) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 3")); + } +} + +TEST_P(VersionCheck, V4) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.4" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 4) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 4")); + } +} + +TEST_P(VersionCheck, V5) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 5) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 1")); + } +} + +TEST_F(ValidateExtInst, OpExtInstWithForwardNotAllowedSemantic) { + const std::string body = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + %extinst = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + %3 = OpString "sample" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %f32 = OpTypeFloat 32 + %uint_0 = OpConstant %uint 0 + %f32_0 = OpConstant %f32 0 + %f32_1 = OpConstant %f32 1 + %7 = OpTypeFunction %void + %8 = OpExtInst %void %1 DebugSource %3 %3 + %9 = OpExtInst %void %1 DebugCompilationUnit %uint_0 %uint_0 %8 %uint_0 + %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_0 %11 + %12 = OpExtInstWithForwardRefsKHR %void %1 DebugFunction %3 %10 %8 %uint_0 %uint_0 %11 %3 %uint_0 %uint_0 + %11 = OpExtInst %void %1 DebugTypeComposite %3 %uint_0 %8 %uint_0 %uint_0 %9 %3 %uint_0 %uint_0 %12 + %2 = OpFunction %void None %7 + %13 = OpLabel + %18 = OpExtInstWithForwardRefsKHR %f32 %extinst FMin %f32_0 %19 + %19 = OpExtInst %f32 %extinst FMin %f32_0 %f32_1 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "OpExtInstWithForwardRefsKHR is only allowed with non-semantic " + "instructions.\n" + " %18 = OpExtInstWithForwardRefsKHR %float %2 FMin %float_0 %19\n")); +} + +TEST_F(ValidateExtInst, OpExtInstRequiresNonSemanticBefore16) { + const std::string body = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + %extinst = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + %3 = OpString "sample" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %7 = OpTypeFunction %void + %8 = OpExtInst %void %1 DebugSource %3 %3 + %9 = OpExtInst %void %1 DebugCompilationUnit %uint_0 %uint_0 %8 %uint_0 + %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_0 %11 + %12 = OpExtInstWithForwardRefsKHR %void %1 DebugFunction %3 %10 %8 %uint_0 %uint_0 %11 %3 %uint_0 %uint_0 + %11 = OpExtInst %void %1 DebugTypeComposite %3 %uint_0 %8 %uint_0 %uint_0 %9 %3 %uint_0 %uint_0 %12 + %2 = OpFunction %void None %7 + %13 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body); + ASSERT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("ExtInstWithForwardRefsKHR requires one of the following " + "extensions: SPV_KHR_relaxed_extended_instruction \n" + " %11 = OpExtInstWithForwardRefsKHR %void %1 " + "DebugTypeFunction %uint_0 %12\n")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_bit_instructions_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_bit_instructions_test.cpp index 0e926716f7..d23b9b6fa3 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_bit_instructions_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_bit_instructions_test.cpp @@ -18,10 +18,7 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" -#include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_expect_assume_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_expect_assume_test.cpp index 6ece15d18e..85a484aa7e 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_expect_assume_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_expect_assume_test.cpp @@ -18,10 +18,7 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" -#include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_integer_dot_product_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_integer_dot_product_test.cpp index e0e6896c90..5b3a309612 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_integer_dot_product_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_integer_dot_product_test.cpp @@ -14,15 +14,12 @@ // limitations under the License. #include -#include #include #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" #include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -131,7 +128,7 @@ std::string AssemblyForCase(const Case& c) { %char_0 = OpConstant %char 0 %char_1 = OpConstant %char 1 - %v4uchar_0 = OpConstantComposite %v4uchar %uchar_0 %uint_0 %uchar_0 %uchar_0 + %v4uchar_0 = OpConstantComposite %v4uchar %uchar_0 %uchar_0 %uchar_0 %uchar_0 %v4uchar_1 = OpConstantComposite %v4uchar %uchar_1 %uchar_1 %uchar_1 %uchar_1 %v4char_0 = OpConstantComposite %v4char %char_0 %char_0 %char_0 %char_0 %v4char_1 = OpConstantComposite %v4char %char_1 %char_1 %char_1 %char_1 diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_linkonce_odr_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_linkonce_odr_test.cpp index ac15558bef..ed3fb8a1c2 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_linkonce_odr_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_linkonce_odr_test.cpp @@ -18,10 +18,7 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" -#include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow.cpp new file mode 100644 index 0000000000..f528cb9eef --- /dev/null +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow.cpp @@ -0,0 +1,110 @@ +// Copyright (c) 2021 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Tests for OpExtension validator rules. + +#include +#include + +#include "gmock/gmock.h" +#include "source/enum_string_mapping.h" +#include "source/extensions.h" +#include "source/spirv_target_env.h" +#include "test/test_fixture.h" +#include "test/unit_spirv.h" +#include "test/val/val_fixtures.h" + +namespace spvtools { +namespace val { +namespace { + +using ::testing::HasSubstr; +using ::testing::Values; +using ::testing::ValuesIn; + +using ValidateSpvKHRSubgroupUniformControlFlow = spvtest::ValidateBase; + +TEST_F(ValidateSpvKHRSubgroupUniformControlFlow, Valid) { + const std::string str = R"( + OpCapability Shader + OpExtension "SPV_KHR_subgroup_uniform_control_flow" + OpMemoryModel Logical Simple + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpExecutionMode %main SubgroupUniformControlFlowKHR + + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + + %main = OpFunction %void None %void_fn + %entry = OpLabel + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateSpvKHRSubgroupUniformControlFlow, RequiresExtension) { + const std::string str = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpExecutionMode %main SubgroupUniformControlFlowKHR + + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + + %main = OpFunction %void None %void_fn + %entry = OpLabel + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("2nd operand of ExecutionMode: operand " + "SubgroupUniformControlFlowKHR(4421) " + "requires one of these extensions: " + "SPV_KHR_subgroup_uniform_control_flow")); +} + +TEST_F(ValidateSpvKHRSubgroupUniformControlFlow, RequiresShaderCapability) { + const std::string str = R"( + OpCapability Kernel + OpCapability Addresses + OpExtension "SPV_KHR_subgroup_uniform_control_flow" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %main "main" + OpExecutionMode %main SubgroupUniformControlFlowKHR + + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + + %main = OpFunction %void None %void_fn + %entry = OpLabel + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Operand 2 of ExecutionMode requires one of these " + "capabilities: Shader")); +} + +} // namespace +} // namespace val +} // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow_test.cpp index f528cb9eef..80d57533da 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_subgroup_uniform_control_flow_test.cpp @@ -18,10 +18,7 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" -#include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" diff --git a/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation_test.cpp b/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation_test.cpp index 8d92414901..4d3e4d6af7 100644 --- a/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation_test.cpp +++ b/third_party/spirv-tools/test/val/val_extension_spv_khr_terminate_invocation_test.cpp @@ -18,10 +18,7 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" -#include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" diff --git a/third_party/spirv-tools/test/val/val_extension_spv_nv_raw_access_chains.cpp b/third_party/spirv-tools/test/val/val_extension_spv_nv_raw_access_chains.cpp new file mode 100644 index 0000000000..f06d7cd4b5 --- /dev/null +++ b/third_party/spirv-tools/test/val/val_extension_spv_nv_raw_access_chains.cpp @@ -0,0 +1,510 @@ +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "gmock/gmock.h" +#include "source/spirv_target_env.h" +#include "test/unit_spirv.h" +#include "test/val/val_fixtures.h" + +namespace spvtools { +namespace val { +namespace { + +using ::testing::HasSubstr; + +using ValidateSpvNVRawAccessChains = spvtest::ValidateBase; + +TEST_F(ValidateSpvNVRawAccessChains, Valid) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateSpvNVRawAccessChains, NoCapability) { + const std::string str = R"( + OpCapability Shader + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("requires one of these capabilities: RawAccessChainsNV")); +} + +TEST_F(ValidateSpvNVRawAccessChains, NoExtension) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("requires one of these extensions: SPV_NV_raw_access_chains")); +} + +TEST_F(ValidateSpvNVRawAccessChains, ReturnTypeNotPointer) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %int %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must be OpTypePointer. Found OpTypeInt")); +} + +TEST_F(ValidateSpvNVRawAccessChains, Workgroup) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer Workgroup %intStruct + %ssbo = OpVariable %intStructPtr Workgroup + %intPtr = OpTypePointer Workgroup %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must point to a storage class of")); +} + +TEST_F(ValidateSpvNVRawAccessChains, ReturnTypeArray) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %int_1 = OpConstant %int 1 + %intArray = OpTypeArray %int %int_1 + %intArrayPtr = OpTypePointer StorageBuffer %intArray + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intArrayPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerComponentNV + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must not point to")); +} + +TEST_F(ValidateSpvNVRawAccessChains, VariableStride) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %stride = OpIAdd %int %int_0 %int_0 + %rawChain = OpRawAccessChainNV %intPtr %ssbo %stride %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be OpConstant")); +} + +TEST_F(ValidateSpvNVRawAccessChains, RobustnessPerElementZeroStride) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_0 %int_0 %int_0 RobustnessPerElementNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Stride must not be zero when per-element robustness is used")); +} + +TEST_F(ValidateSpvNVRawAccessChains, BothRobustness) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %int_0 RobustnessPerElementNV|RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Per-component robustness and per-element robustness " + "are mutually exclusive")); +} + +TEST_F(ValidateSpvNVRawAccessChains, StrideFloat) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %float_16 = OpConstant %float 16 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %float_16 %int_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be OpTypeInt")); +} + +TEST_F(ValidateSpvNVRawAccessChains, IndexType) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpCapability Int64 + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %long = OpTypeInt 64 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + %long_0 = OpConstant %long 0 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %long_0 %int_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("The integer width of Index")); +} + +TEST_F(ValidateSpvNVRawAccessChains, OffsetType) { + const std::string str = R"( + OpCapability Shader + OpCapability RawAccessChainsNV + OpCapability Int64 + OpExtension "SPV_KHR_storage_buffer_storage_class" + OpExtension "SPV_NV_raw_access_chains" + OpMemoryModel Logical GLSL450 + + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + + OpDecorate %intStruct Block + OpMemberDecorate %intStruct 0 Offset 0 + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + + %int = OpTypeInt 32 1 + %long = OpTypeInt 64 1 + %void = OpTypeVoid + %mainFunctionType = OpTypeFunction %void + %intStruct = OpTypeStruct %int + %intStructPtr = OpTypePointer StorageBuffer %intStruct + %ssbo = OpVariable %intStructPtr StorageBuffer + %intPtr = OpTypePointer StorageBuffer %int + + %int_0 = OpConstant %int 0 + %int_16 = OpConstant %int 16 + %long_0 = OpConstant %long 0 + + %main = OpFunction %void None %mainFunctionType + %label = OpLabel + %rawChain = OpRawAccessChainNV %intPtr %ssbo %int_16 %int_0 %long_0 RobustnessPerComponentNV + %unused = OpLoad %int %rawChain + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("The integer width of Offset")); +} + +} // namespace +} // namespace val +} // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_extensions_test.cpp b/third_party/spirv-tools/test/val/val_extensions_test.cpp index 491a80853a..bc8e9728ae 100644 --- a/third_party/spirv-tools/test/val/val_extensions_test.cpp +++ b/third_party/spirv-tools/test/val/val_extensions_test.cpp @@ -18,10 +18,8 @@ #include #include "gmock/gmock.h" -#include "source/enum_string_mapping.h" #include "source/extensions.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -63,7 +61,8 @@ INSTANTIATE_TEST_SUITE_P( "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_fragment_mask", "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", "SPV_NV_shader_subgroup_partitioned", "SPV_EXT_descriptor_indexing", - "SPV_KHR_terminate_invocation")); + "SPV_KHR_terminate_invocation", + "SPV_KHR_relaxed_extended_instruction")); INSTANTIATE_TEST_SUITE_P(FailSilently, ValidateUnknownExtensions, Values("ERROR_unknown_extension", "SPV_KHR_", @@ -133,6 +132,214 @@ TEST_F(ValidateExtensionCapabilities, DeclCapabilityFailure) { EXPECT_THAT(getDiagnosticString(), HasSubstr("SPV_KHR_device_group")); } +TEST_F(ValidateExtensionCapabilities, + DeclCapabilityFailureBlockMatchWIndowSAD) { + const std::string str = R"( + OpCapability Shader + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %v_texcoord %fragColor %target_samp %ref_samp + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_QCOM_image_processing" + OpSourceExtension "GL_QCOM_image_processing2" + OpName %main "main" + OpName %tgt_coords "tgt_coords" + OpName %v_texcoord "v_texcoord" + OpName %ref_coords "ref_coords" + OpName %blockSize "blockSize" + OpName %fragColor "fragColor" + OpName %target_samp "target_samp" + OpName %ref_samp "ref_samp" + OpDecorate %v_texcoord Location 0 + OpDecorate %fragColor Location 0 + OpDecorate %target_samp DescriptorSet 0 + OpDecorate %target_samp Binding 4 + OpDecorate %ref_samp DescriptorSet 0 + OpDecorate %ref_samp Binding 5 + OpDecorate %target_samp BlockMatchTextureQCOM + OpDecorate %target_samp BlockMatchSamplerQCOM + OpDecorate %ref_samp BlockMatchTextureQCOM + OpDecorate %ref_samp BlockMatchSamplerQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %v_texcoord = OpVariable %_ptr_Input_v4float Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %39 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %fragColor = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown + %43 = OpTypeSampledImage %42 +%_ptr_UniformConstant_43 = OpTypePointer UniformConstant %43 +%target_samp = OpVariable %_ptr_UniformConstant_43 UniformConstant + %ref_samp = OpVariable %_ptr_UniformConstant_43 UniformConstant + %main = OpFunction %void None %3 + %5 = OpLabel + %tgt_coords = OpVariable %_ptr_Function_v2uint Function + %ref_coords = OpVariable %_ptr_Function_v2uint Function + %blockSize = OpVariable %_ptr_Function_v2uint Function + %16 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_0 + %17 = OpLoad %float %16 + %18 = OpConvertFToU %uint %17 + %20 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0 + OpStore %20 %18 + %22 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_1 + %23 = OpLoad %float %22 + %24 = OpConvertFToU %uint %23 + %25 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0 + OpStore %25 %24 + %28 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_2 + %29 = OpLoad %float %28 + %30 = OpConvertFToU %uint %29 + %31 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_0 + OpStore %31 %30 + %33 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_3 + %34 = OpLoad %float %33 + %35 = OpConvertFToU %uint %34 + %36 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_1 + OpStore %36 %35 + OpStore %blockSize %39 + %46 = OpLoad %43 %target_samp + %47 = OpLoad %v2uint %tgt_coords + %49 = OpLoad %43 %ref_samp + %50 = OpLoad %v2uint %ref_coords + %51 = OpLoad %v2uint %blockSize + %52 = OpImageBlockMatchWindowSADQCOM %v4float %46 %47 %49 %50 %51 + OpStore %fragColor %52 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + ASSERT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("2nd operand of Decorate")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires one of these extensions")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("SPV_QCOM_image_processing")); +} + +TEST_F(ValidateExtensionCapabilities, + DeclCapabilityFailureBlockMatchWIndowSSD) { + const std::string str = R"( + OpCapability Shader + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %v_texcoord %fragColor %tex2D_src1 %samp %tex2D_src2 + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_QCOM_image_processing" + OpSourceExtension "GL_QCOM_image_processing2" + OpName %main "main" + OpName %tgt_coords "tgt_coords" + OpName %v_texcoord "v_texcoord" + OpName %ref_coords "ref_coords" + OpName %blockSize "blockSize" + OpName %fragColor "fragColor" + OpName %tex2D_src1 "tex2D_src1" + OpName %samp "samp" + OpName %tex2D_src2 "tex2D_src2" + OpDecorate %v_texcoord Location 0 + OpDecorate %fragColor Location 0 + OpDecorate %tex2D_src1 DescriptorSet 0 + OpDecorate %tex2D_src1 Binding 1 + OpDecorate %samp DescriptorSet 0 + OpDecorate %samp Binding 3 + OpDecorate %tex2D_src2 DescriptorSet 0 + OpDecorate %tex2D_src2 Binding 2 + OpDecorate %tex2D_src1 BlockMatchTextureQCOM + OpDecorate %samp BlockMatchSamplerQCOM + OpDecorate %tex2D_src2 BlockMatchTextureQCOM + OpDecorate %samp BlockMatchSamplerQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %v_texcoord = OpVariable %_ptr_Input_v4float Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %39 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %fragColor = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %tex2D_src1 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %samp = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %tex2D_src2 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %main = OpFunction %void None %3 + %5 = OpLabel + %tgt_coords = OpVariable %_ptr_Function_v2uint Function + %ref_coords = OpVariable %_ptr_Function_v2uint Function + %blockSize = OpVariable %_ptr_Function_v2uint Function + %16 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_0 + %17 = OpLoad %float %16 + %18 = OpConvertFToU %uint %17 + %20 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0 + OpStore %20 %18 + %22 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_1 + %23 = OpLoad %float %22 + %24 = OpConvertFToU %uint %23 + %25 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0 + OpStore %25 %24 + %28 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_2 + %29 = OpLoad %float %28 + %30 = OpConvertFToU %uint %29 + %31 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_0 + OpStore %31 %30 + %33 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_3 + %34 = OpLoad %float %33 + %35 = OpConvertFToU %uint %34 + %36 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_1 + OpStore %36 %35 + OpStore %blockSize %39 + %45 = OpLoad %42 %tex2D_src1 + %49 = OpLoad %46 %samp + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %tgt_coords + %54 = OpLoad %42 %tex2D_src2 + %55 = OpLoad %46 %samp + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %ref_coords + %58 = OpLoad %v2uint %blockSize + %59 = OpImageBlockMatchWindowSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %fragColor %59 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str()); + ASSERT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("2nd operand of Decorate")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires one of these extensions")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("SPV_QCOM_image_processing")); +} + using ValidateAMDShaderBallotCapabilities = spvtest::ValidateBase; // Returns a vector of strings for the prefix of a SPIR-V assembly shader @@ -344,6 +551,44 @@ INSTANTIATE_TEST_SUITE_P( })); // clang-format on +using ValidateRelaxedExtendedInstructionExt = spvtest::ValidateBase; + +TEST_F(ValidateRelaxedExtendedInstructionExt, RequiresExtension) { + const std::string str = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + %3 = OpString "sample" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %7 = OpTypeFunction %void + %8 = OpExtInst %void %1 DebugSource %3 %3 + %9 = OpExtInst %void %1 DebugCompilationUnit %uint_0 %uint_0 %8 %uint_0 + %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_0 %11 + %12 = OpExtInstWithForwardRefsKHR %void %1 DebugFunction %3 %10 %8 %uint_0 %uint_0 %11 %3 %uint_0 %uint_0 + %11 = OpExtInst %void %1 DebugTypeComposite %3 %uint_0 %8 %uint_0 %uint_0 %9 %3 %uint_0 %uint_0 %12 + %2 = OpFunction %void None %7 + %13 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(str.c_str()); + EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "ExtInstWithForwardRefsKHR requires one of the following extensions:" + " SPV_KHR_relaxed_extended_instruction \n" + " %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction " + "%uint_0 " + "%11\n")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_fixtures.h b/third_party/spirv-tools/test/val/val_fixtures.h index 98d8d32a99..db9d0452e1 100644 --- a/third_party/spirv-tools/test/val/val_fixtures.h +++ b/third_party/spirv-tools/test/val/val_fixtures.h @@ -76,6 +76,8 @@ class ValidateBase : public ::testing::Test, diagnostic_ = nullptr; } + void SetAssembleOptions(uint32_t options) { assemble_options_ = options; } + std::string getDiagnosticString(); spv_position_t getErrorPosition(); spv_validator_options getValidatorOptions(); @@ -84,6 +86,7 @@ class ValidateBase : public ::testing::Test, spv_diagnostic diagnostic_; spv_validator_options options_; std::unique_ptr vstate_; + uint32_t assemble_options_ = SPV_TEXT_TO_BINARY_OPTION_NONE; }; template @@ -132,8 +135,9 @@ void ValidateBase::CompileSuccessfully(std::string code, DestroyBinary(); spv_diagnostic diagnostic = nullptr; ScopedContext context(env); - auto status = spvTextToBinary(context.context, code.c_str(), code.size(), - &binary_, &diagnostic); + auto status = + spvTextToBinaryWithOptions(context.context, code.c_str(), code.size(), + assemble_options_, &binary_, &diagnostic); EXPECT_EQ(SPV_SUCCESS, status) << "ERROR: " << diagnostic->error << "\nSPIR-V could not be compiled into binary:\n" diff --git a/third_party/spirv-tools/test/val/val_function_test.cpp b/third_party/spirv-tools/test/val/val_function_test.cpp index e7d5cd7e04..119edd3e6c 100644 --- a/third_party/spirv-tools/test/val/val_function_test.cpp +++ b/third_party/spirv-tools/test/val/val_function_test.cpp @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include "gmock/gmock.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -838,6 +836,113 @@ TEST_F(ValidateFunctionCall, LogicallyMismatchedPointersArraySize) { HasSubstr("type does not match Function ")); } +TEST_F(ValidateFunctionCall, UntypedPointerParameterMismatch) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %var "var" +OpName %ptr2 "ptr2" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypeUntypedPointerKHR Private +%ptr2 = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private %int +%void_fn = OpTypeFunction %void +%ptr_fn = OpTypeFunction %void %ptr2 +%foo = OpFunction %void None %ptr_fn +%param = OpFunctionParameter %ptr2 +%first = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %foo %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpFunctionCall Argument '2[%var]'s type does not " + "match Function '3[%ptr2]'s parameter type")); +} + +TEST_F(ValidateFunctionCall, UntypedPointerParameterGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %var "var" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private %int +%void_fn = OpTypeFunction %void +%ptr_fn = OpTypeFunction %void %ptr +%foo = OpFunction %void None %ptr_fn +%param = OpFunctionParameter %ptr +%first = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %foo %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateFunctionCall, + UntypedPointerParameterNotMemoryObjectDeclaration) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %var "var" +OpName %gep "gep" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private %int +%void_fn = OpTypeFunction %void +%ptr_fn = OpTypeFunction %void %ptr +%foo = OpFunction %void None %ptr_fn +%param = OpFunctionParameter %ptr +%first = OpLabel +OpReturn +OpFunctionEnd +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpUntypedAccessChainKHR %ptr %struct %var %int_0 +%call = OpFunctionCall %void %foo %gep +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Pointer operand '3[%gep]' must be a memory object declaration")); +} + INSTANTIATE_TEST_SUITE_P(StorageClass, ValidateFunctionCall, Values("UniformConstant", "Input", "Uniform", "Output", "Workgroup", "Private", "Function", diff --git a/third_party/spirv-tools/test/val/val_id_test.cpp b/third_party/spirv-tools/test/val/val_id_test.cpp index 3666f38b0d..b4c9d78a8f 100644 --- a/third_party/spirv-tools/test/val/val_id_test.cpp +++ b/third_party/spirv-tools/test/val/val_id_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2015-2016 The Khronos Group Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -578,9 +580,8 @@ TEST_P(ValidateIdWithMessage, OpEntryPointInterfaceIsNotVariableTypeBad) { CompileSuccessfully(spirv); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr(make_message( - "Interfaces passed to OpEntryPoint must be of type " - "OpTypeVariable. Found OpTypePointer."))); + HasSubstr("Interfaces passed to OpEntryPoint must be variables. " + "Found OpTypePointer.")); } TEST_P(ValidateIdWithMessage, OpEntryPointInterfaceStorageClassBad) { @@ -1056,7 +1057,7 @@ TEST_P(ValidateIdWithMessage, OpTypeArrayLengthNull) { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(make_message("OpTypeArray Length '2[%2]' default " - "value must be at least 1."))); + "value must be at least 1: found 0"))); } TEST_P(ValidateIdWithMessage, OpTypeArrayLengthSpecConst) { @@ -1167,6 +1168,160 @@ TEST_P(ValidateIdWithMessage, OpTypePointerBad) { "type."))); } +TEST_P(ValidateIdWithMessage, OpTypePointerCanHaveUntypedPointer) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability Linkage +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical OpenCL +%ptr = OpTypeUntypedPointerKHR Workgroup +%ptr2 = OpTypePointer Private %ptr +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerWorkgroupGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%ptr = OpTypeUntypedPointerKHR Workgroup +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_P(ValidateIdWithMessage, + OpTypeUntypedPointerWorkgroupMissingExplicitLayout) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%ptr = OpTypeUntypedPointerKHR Workgroup +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Workgroup storage class untyped pointers in Vulkan require " + "WorkgroupMemoryExplicitLayoutKHR be declared")); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerWorkgroupGoodAll) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%ptr = OpTypeUntypedPointerKHR Workgroup +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerStorageBufferGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%ptr = OpTypeUntypedPointerKHR StorageBuffer +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerUniformGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%ptr = OpTypeUntypedPointerKHR Uniform +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerPushConstantGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%ptr = OpTypeUntypedPointerKHR PushConstant +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerCrossWorkgroupGood) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical OpenCL +%ptr = OpTypeUntypedPointerKHR CrossWorkgroup +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateIdWithMessage, OpTypeUntypedPointerVulkanInvalidStorageClass) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%ptr = OpTypeUntypedPointerKHR Private +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In Vulkan, untyped pointers can only be used in an " + "explicitly laid out storage class")); +} + TEST_P(ValidateIdWithMessage, OpTypeFunctionGood) { std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid @@ -2270,9 +2425,8 @@ OpFunctionEnd CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr(make_message( - "OpVariable Initializer '8[%8]' is not a constant " - "or module-scope variable"))); + HasSubstr("Variable Initializer '8[%8]' is not a constant " + "or module-scope variable")); } TEST_P(ValidateIdWithMessage, OpVariableInitializerIsModuleVarGood) { @@ -2317,7 +2471,8 @@ OpFunctionEnd "be used with non-externally visible shader Storage Classes: " "Workgroup, CrossWorkgroup, Private, Function, Input, Output, " "RayPayloadKHR, IncomingRayPayloadKHR, HitAttributeKHR, " - "CallableDataKHR, or IncomingCallableDataKHR"))); + "CallableDataKHR, IncomingCallableDataKHR, NodePayloadAMDX, or " + "UniformConstant"))); } TEST_P(ValidateIdWithMessage, OpVariableContainsBoolPrivateGood) { @@ -2339,6 +2494,25 @@ OpFunctionEnd EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_P(ValidateIdWithMessage, OpVariableContainsBoolUniformConstantGood) { + std::string spirv = kGLSL450MemoryModel + R"( +%bool = OpTypeBool +%int = OpTypeInt 32 0 +%block = OpTypeStruct %bool %int +%_ptr_UniformConstant_block = OpTypePointer UniformConstant %block +%var = OpVariable %_ptr_UniformConstant_block UniformConstant +%void = OpTypeVoid +%fnty = OpTypeFunction %void +%main = OpFunction %void None %fnty +%entry = OpLabel +%load = OpLoad %block %var +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(spirv.c_str()); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + TEST_P(ValidateIdWithMessage, OpVariableContainsBoolPointerGood) { std::string spirv = kGLSL450MemoryModel + R"( %bool = OpTypeBool @@ -4146,12 +4320,11 @@ TEST_P(AccessChainInstructionTest, AccessChainStructIndexNotConstantBad) { OpReturn OpFunctionEnd )"; - const std::string expected_err = - "The passed to " + instr + - " to index into a structure must be an OpConstant."; CompileSuccessfully(spirv); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), HasSubstr(expected_err)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("The passed to " + instr)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("into a structure must be an OpConstant")); } // Invalid: Indexing up to a vec4 granularity, but result type expected float. @@ -4205,8 +4378,8 @@ TEST_P(AccessChainInstructionTest, AccessChainStructIndexOutOfBoundBad) { OpReturn OpFunctionEnd )"; - const std::string expected_err = "Index is out of bounds: " + instr + - " can not find index 3 into the structure " + const std::string expected_err = "is out of bounds: " + instr + + " cannot find index 3 into the structure " " '25[%_struct_25]'. This structure " "has 3 members. Largest valid index is 2."; CompileSuccessfully(spirv); @@ -6385,9 +6558,10 @@ OpMemoryModel Logical VulkanKHR %7 = OpConstant %2 2 %8 = OpConstant %2 5 %9 = OpTypeFunction %1 +%12 = OpConstant %2 4 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 NonPrivatePointerKHR|MakePointerAvailableKHR %7 +OpCopyMemorySized %4 %6 %12 NonPrivatePointerKHR|MakePointerAvailableKHR %7 OpReturn OpFunctionEnd )"; @@ -6412,10 +6586,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Uniform %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 NonPrivatePointerKHR|MakePointerVisibleKHR %8 +OpCopyMemorySized %4 %6 %12 NonPrivatePointerKHR|MakePointerVisibleKHR %8 OpReturn OpFunctionEnd )"; @@ -6441,10 +6616,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Uniform %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 NonPrivatePointerKHR|MakePointerAvailableKHR|MakePointerVisibleKHR %7 %8 +OpCopyMemorySized %4 %6 %12 NonPrivatePointerKHR|MakePointerAvailableKHR|MakePointerVisibleKHR %7 %8 OpReturn OpFunctionEnd )"; @@ -6470,10 +6646,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Uniform %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 MakePointerAvailableKHR %7 +OpCopyMemorySized %4 %6 %12 MakePointerAvailableKHR %7 OpReturn OpFunctionEnd )"; @@ -6503,10 +6680,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Uniform %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 MakePointerVisibleKHR %8 +OpCopyMemorySized %4 %6 %12 MakePointerVisibleKHR %8 OpReturn OpFunctionEnd )"; @@ -6536,10 +6714,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Uniform %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 NonPrivatePointerKHR +OpCopyMemorySized %4 %6 %12 NonPrivatePointerKHR OpReturn OpFunctionEnd )"; @@ -6570,10 +6749,11 @@ OpMemoryModel Logical VulkanKHR %6 = OpVariable %5 Input %7 = OpConstant %2 2 %8 = OpConstant %2 5 +%12 = OpConstant %2 4 %9 = OpTypeFunction %1 %10 = OpFunction %1 None %9 %11 = OpLabel -OpCopyMemorySized %4 %6 %7 NonPrivatePointerKHR +OpCopyMemorySized %4 %6 %12 NonPrivatePointerKHR OpReturn OpFunctionEnd )"; @@ -6888,6 +7068,114 @@ TEST_P(ValidateIdWithMessage, NVBindlessSamplerInStruct) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); } +TEST_P(ValidateIdWithMessage, + OpExtInstWithForwardRefsKHRDisallowedNoForwardRef) { + std::string spirv = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + %void = OpTypeVoid +%main_type = OpTypeFunction %void + %4 = OpExtInstWithForwardRefsKHR %void %1 DebugInfoNone + %main = OpFunction %void None %main_type + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr(make_message("Opcode OpExtInstWithForwardRefsKHR must have at " + "least one forward declared ID."))); +} + +TEST_P(ValidateIdWithMessage, OpExtInstNoForwardRef) { + std::string spirv = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + %void = OpTypeVoid +%main_type = OpTypeFunction %void + %4 = OpExtInst %void %1 DebugInfoNone + %main = OpFunction %void None %main_type + %5 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + +TEST_P(ValidateIdWithMessage, + OpExtInstWithForwardRefsKHRAllowedForwardReferenceInNonSemantic) { + std::string spirv = R"( + OpCapability Shader + OpExtension "SPV_KHR_non_semantic_info" + OpExtension "SPV_KHR_relaxed_extended_instruction" + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + %3 = OpString "sample" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %7 = OpTypeFunction %void + %8 = OpExtInst %void %1 DebugSource %3 %3 + %9 = OpExtInst %void %1 DebugCompilationUnit %uint_0 %uint_0 %8 %uint_0 + %10 = OpExtInstWithForwardRefsKHR %void %1 DebugTypeFunction %uint_0 %11 + %12 = OpExtInstWithForwardRefsKHR %void %1 DebugFunction %3 %10 %8 %uint_0 %uint_0 %11 %3 %uint_0 %uint_0 + %11 = OpExtInst %void %1 DebugTypeComposite %3 %uint_0 %8 %uint_0 %uint_0 %9 %3 %uint_0 %uint_0 %12 + %2 = OpFunction %void None %7 + %13 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + +TEST_P(ValidateIdWithMessage, OpExtInstNoForwardDeclAllowed) { + std::string spirv = R"( + OpCapability Shader + %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" + OpExecutionMode %2 LocalSize 1 1 1 + %3 = OpString "sample" + %void = OpTypeVoid + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %7 = OpTypeFunction %void + %8 = OpExtInst %void %1 DebugSource %3 %3 + %9 = OpExtInst %void %1 DebugCompilationUnit %uint_0 %uint_0 %8 %uint_0 + %10 = OpExtInst %void %1 DebugTypeFunction %uint_0 %11 + %12 = OpExtInst %void %1 DebugFunction %3 %10 %8 %uint_0 %uint_0 %11 %3 %uint_0 %uint_0 + %11 = OpExtInst %void %1 DebugTypeComposite %3 %uint_0 %8 %uint_0 %uint_0 %9 %3 %uint_0 %uint_0 %12 + %2 = OpFunction %void None %7 + %13 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr(make_message("ID '11[%11]' has not been defined"))); +} + INSTANTIATE_TEST_SUITE_P(, ValidateIdWithMessage, ::testing::Bool()); } // namespace diff --git a/third_party/spirv-tools/test/val/val_image_test.cpp b/third_party/spirv-tools/test/val/val_image_test.cpp index a97ef7cb39..2a86c91061 100644 --- a/third_party/spirv-tools/test/val/val_image_test.cpp +++ b/third_party/spirv-tools/test/val/val_image_test.cpp @@ -20,6 +20,7 @@ #include #include "gmock/gmock.h" +#include "spirv-tools/libspirv.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -356,7 +357,8 @@ OpFunctionEnd)"; std::string GenerateKernelCode( const std::string& body, - const std::string& capabilities_and_extensions = "") { + const std::string& capabilities_and_extensions = "", + const std::string& declarations = "") { std::ostringstream ss; ss << R"( OpCapability Addresses @@ -436,7 +438,11 @@ OpMemoryModel Physical32 OpenCL %type_sampler = OpTypeSampler %ptr_sampler = OpTypePointer UniformConstant %type_sampler %uniform_sampler = OpVariable %ptr_sampler UniformConstant +)"; + ss << declarations; + + ss << R"( %main = OpFunction %void None %func %main_entry = OpLabel )"; @@ -480,10 +486,10 @@ OpCapability Int64 OpCapability Float64 )"; - ss << capabilities_and_extensions; if (!include_entry_point) { - ss << "OpCapability Linkage"; + ss << "OpCapability Linkage\n"; } + ss << capabilities_and_extensions; ss << R"( OpMemoryModel Logical GLSL450 @@ -781,6 +787,294 @@ TEST_F(ValidateImage, TypeImageWrongArrayForSubpassDataVulkan) { HasSubstr("Dim SubpassData requires Arrayed to be 0")); } +TEST_F(ValidateImage, TypeImageDimRectVulkan) { + const std::string code = GetShaderHeader("OpCapability InputAttachment\n") + + R"( +%img_type = OpTypeImage %f32 Rect 0 1 0 2 Unknown +)" + TrivialMain(); + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, + ValidateInstructions(SPV_ENV_VULKAN_1_0)); + // Can't actually hit VUID-StandaloneSpirv-OpTypeImage-09638 + EXPECT_THAT( + getDiagnosticString(), + AnyVUID("TypeImage requires one of these capabilities: SampledRect")); +} + +TEST_F(ValidateImage, TypeImageWrongSampledTypeForTileImageDataEXT) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %void TileImageDataEXT 0 0 0 2 Unknown +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Dim TileImageDataEXT requires Sampled Type to be not OpTypeVoid")); +} + +TEST_F(ValidateImage, TypeImageWrongSampledForTileImageDataEXT) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %f32 TileImageDataEXT 0 0 0 1 Unknown +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim TileImageDataEXT requires Sampled to be 2")); +} + +TEST_F(ValidateImage, TypeImageWrongFormatForTileImageDataEXT) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Rgba32f +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim TileImageDataEXT requires format Unknown")); +} + +TEST_F(ValidateImage, TypeImageWrongDepthForTileImageDataEXT) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %f32 TileImageDataEXT 1 0 0 2 Unknown +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim TileImageDataEXT requires Depth to be 0")); +} + +TEST_F(ValidateImage, TypeImageWrongArrayedForTileImageDataEXT) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %f32 TileImageDataEXT 0 1 0 2 Unknown +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Dim TileImageDataEXT requires Arrayed to be 0")); +} + +TEST_F(ValidateImage, TypeSampledImage_TileImageDataEXT_Error) { + const std::string code = GetShaderHeader( + "OpCapability TileImageColorReadAccessEXT\n" + "OpExtension \"SPV_EXT_shader_tile_image\"\n", + false) + + R"( +%img_type = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%simg_type = OpTypeSampledImage %img_type +)"; + + CompileSuccessfully(code.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Sampled image type requires an image type with " + "\"Sampled\" operand set to 0 or 1")); +} + +TEST_F(ValidateImage, ImageTexelPointerImageDimTileImageDataEXTBad) { + const std::string body = R"( +%texel_ptr = OpImageTexelPointer %ptr_Image_u32 %tile_image_u32_tid_0002 %u32_0 %u32_0 +%sum = OpAtomicIAdd %u32 %texel_ptr %u32_1 %u32_0 %u32_1 +)"; + const std::string decl = R"( +%type_image_u32_tid_0002 = OpTypeImage %u32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_u32_tid_0002 = OpTypePointer TileImageEXT %type_image_u32_tid_0002 +%tile_image_u32_tid_0002 = OpVariable %ptr_image_u32_tid_0002 TileImageEXT +)"; + + const std::string extra = R"( +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment", "", + SPV_ENV_UNIVERSAL_1_5, "GLSL450", decl) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Image Dim TileImageDataEXT cannot be used with " + "OpImageTexelPointer")); +} + +TEST_F(ValidateImage, ReadTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +%res1 = OpImageRead %f32vec4 %img %u32vec2_01 +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability StorageImageReadWithoutFormat +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment", "", + SPV_ENV_UNIVERSAL_1_5, "GLSL450", decl) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Image Dim TileImageDataEXT cannot be used with ImageRead")); +} + +TEST_F(ValidateImage, WriteTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +OpImageWrite %img %u32vec2_01 %f32vec4_0000 +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment", "", + SPV_ENV_UNIVERSAL_1_5, "GLSL450", decl) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Image 'Dim' cannot be TileImageDataEXT")); +} + +TEST_F(ValidateImage, QueryFormatTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +%res1 = OpImageQueryFormat %u32 %img +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateKernelCode(body, extra, decl).c_str()); + + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Image 'Dim' cannot be TileImageDataEXT")); +} + +TEST_F(ValidateImage, QueryOrderTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +%res1 = OpImageQueryOrder %u32 %img +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateKernelCode(body, extra, decl).c_str()); + + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Image 'Dim' cannot be TileImageDataEXT")); +} + +TEST_F(ValidateImage, SparseFetchTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +%res1 = OpImageSparseFetch %struct_u32_f32vec4 %img %u32vec2_01 +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability StorageImageReadWithoutFormat +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment", "", + SPV_ENV_UNIVERSAL_1_5, "GLSL450", decl) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected Image 'Sampled' parameter to be 1")); +} + +TEST_F(ValidateImage, SparseReadTileImageDataEXT) { + const std::string body = R"( +%img = OpLoad %type_image_f32_tid_0002 %uniform_image_f32_tid_0002 +%res1 = OpImageSparseRead %struct_u32_f32vec4 %img %u32vec2_01 +)"; + + const std::string decl = R"( +%type_image_f32_tid_0002 = OpTypeImage %f32 TileImageDataEXT 0 0 0 2 Unknown +%ptr_image_f32_tid_0002 = OpTypePointer UniformConstant %type_image_f32_tid_0002 +%uniform_image_f32_tid_0002 = OpVariable %ptr_image_f32_tid_0002 UniformConstant +)"; + + const std::string extra = R"( +OpCapability StorageImageReadWithoutFormat +OpCapability TileImageColorReadAccessEXT +OpExtension "SPV_EXT_shader_tile_image" +)"; + + CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment", "", + SPV_ENV_UNIVERSAL_1_5, "GLSL450", decl) + .c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image Dim TileImageDataEXT cannot be used with ImageSparseRead")); +} + TEST_F(ValidateImage, TypeImage_OpenCL_Sampled0_OK) { const std::string code = GetKernelHeader() + R"( %img_type = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly @@ -1087,7 +1381,7 @@ TEST_F(ValidateImage, ImageTexelPointerResultTypeNotPointer) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Result Type to be OpTypePointer")); + HasSubstr("Expected Result Type to be a pointer")); } TEST_F(ValidateImage, ImageTexelPointerResultTypeNotImageClass) { @@ -1099,7 +1393,7 @@ TEST_F(ValidateImage, ImageTexelPointerResultTypeNotImageClass) { CompileSuccessfully(GenerateShaderCode(body).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Result Type to be OpTypePointer whose " + HasSubstr("Expected Result Type to be a pointer whose " "Storage Class operand is Image")); } @@ -1113,7 +1407,7 @@ TEST_F(ValidateImage, ImageTexelPointerResultTypeNotNumericNorVoid) { ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("Expected Result Type to be OpTypePointer whose Type operand " + HasSubstr("Expected Result Type to be a pointer whose Type operand " "must be a scalar numerical type or OpTypeVoid")); } @@ -1851,13 +2145,26 @@ TEST_F(ValidateImage, SampleImplicitLodVulkanOffsetWrongSize) { CompileSuccessfully( GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT(getDiagnosticString(), - AnyVUID("VUID-StandaloneSpirv-Offset-04663")); + EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-RuntimeSpirv-Offset-10213")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Image Operand Offset can only be used with " "OpImage*Gather operations")); } +TEST_F(ValidateImage, SampleImplicitLodVulkanOffsetMaintenance8) { + const std::string body = R"( +%img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001 +%sampler = OpLoad %type_sampler %uniform_sampler +%simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler +%res4 = OpImageSampleImplicitLod %f32vec4 %simg %f32vec4_0000 Offset %s32vec2_01 +)"; + + CompileSuccessfully( + GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str()); + spvValidatorOptionsSetAllowOffsetTextureOperand(getValidatorOptions(), true); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + TEST_F(ValidateImage, SampleImplicitLodVulkanOffsetWrongBeforeLegalization) { const std::string body = R"( %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001 @@ -1899,8 +2206,6 @@ TEST_F(ValidateImage, SampleImplicitLodVulkanMoreThanOneOffset) { CompileSuccessfully( GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT(getDiagnosticString(), - AnyVUID("VUID-StandaloneSpirv-Offset-04662")); EXPECT_THAT( getDiagnosticString(), HasSubstr("Image Operands Offset, ConstOffset, ConstOffsets, Offsets " @@ -4160,7 +4465,7 @@ TEST_F(ValidateImage, QuerySizeNotImage) { const std::string body = R"( %img = OpLoad %type_image_f32_2d_0011 %uniform_image_f32_2d_0011 %sampler = OpLoad %type_sampler %uniform_sampler -%simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler +%simg = OpSampledImage %type_sampled_image_f32_2d_0011 %img %sampler %res1 = OpImageQuerySize %u32vec2 %sampler )"; @@ -4174,7 +4479,7 @@ TEST_F(ValidateImage, QuerySizeSampledImageDirectly) { const std::string body = R"( %img = OpLoad %type_image_f32_2d_0011 %uniform_image_f32_2d_0011 %sampler = OpLoad %type_sampler %uniform_sampler -%simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler +%simg = OpSampledImage %type_sampled_image_f32_2d_0011 %img %sampler %res1 = OpImageQuerySize %u32vec2 %simg )"; @@ -4489,7 +4794,8 @@ TEST_F(ValidateImage, QueryLodWrongExecutionModel) { EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpImageQueryLod requires Fragment or GLCompute execution model")); + "OpImageQueryLod requires Fragment, GLCompute, MeshEXT or TaskEXT " + "execution model")); } TEST_F(ValidateImage, QueryLodWrongExecutionModelWithFunc) { @@ -4510,7 +4816,8 @@ OpFunctionEnd EXPECT_THAT( getDiagnosticString(), HasSubstr( - "OpImageQueryLod requires Fragment or GLCompute execution model")); + "OpImageQueryLod requires Fragment, GLCompute, MeshEXT or TaskEXT " + "execution model")); } TEST_F(ValidateImage, QueryLodComputeShaderDerivatives) { @@ -4522,12 +4829,12 @@ TEST_F(ValidateImage, QueryLodComputeShaderDerivatives) { )"; const std::string extra = R"( -OpCapability ComputeDerivativeGroupLinearNV -OpExtension "SPV_NV_compute_shader_derivatives" +OpCapability ComputeDerivativeGroupLinearKHR +OpExtension "SPV_KHR_compute_shader_derivatives" )"; const std::string mode = R"( OpExecutionMode %main LocalSize 8 8 1 -OpExecutionMode %main DerivativeGroupLinearNV +OpExecutionMode %main DerivativeGroupLinearKHR )"; CompileSuccessfully( GenerateShaderCode(body, extra, "GLCompute", mode).c_str()); @@ -4639,8 +4946,8 @@ TEST_F(ValidateImage, QueryLodComputeShaderDerivativesMissingMode) { )"; const std::string extra = R"( -OpCapability ComputeDerivativeGroupLinearNV -OpExtension "SPV_NV_compute_shader_derivatives" +OpCapability ComputeDerivativeGroupLinearKHR +OpExtension "SPV_KHR_compute_shader_derivatives" )"; const std::string mode = R"( OpExecutionMode %main LocalSize 8 8 1 @@ -4649,9 +4956,9 @@ OpExecutionMode %main LocalSize 8 8 1 GenerateShaderCode(body, extra, "GLCompute", mode).c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("OpImageQueryLod requires DerivativeGroupQuadsNV or " - "DerivativeGroupLinearNV execution mode for GLCompute " - "execution model")); + HasSubstr("OpImageQueryLod requires DerivativeGroupQuadsKHR or " + "DerivativeGroupLinearKHR execution mode for " + "GLCompute, MeshEXT or TaskEXT execution model")); } TEST_F(ValidateImage, ImplicitLodWrongExecutionModel) { @@ -4665,8 +4972,8 @@ TEST_F(ValidateImage, ImplicitLodWrongExecutionModel) { CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str()); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("ImplicitLod instructions require Fragment or " - "GLCompute execution model")); + HasSubstr("ImplicitLod instructions require Fragment, " + "GLCompute, MeshEXT or TaskEXT execution model")); } TEST_F(ValidateImage, ImplicitLodComputeShaderDerivatives) { @@ -4678,12 +4985,12 @@ TEST_F(ValidateImage, ImplicitLodComputeShaderDerivatives) { )"; const std::string extra = R"( -OpCapability ComputeDerivativeGroupLinearNV -OpExtension "SPV_NV_compute_shader_derivatives" +OpCapability ComputeDerivativeGroupLinearKHR +OpExtension "SPV_KHR_compute_shader_derivatives" )"; const std::string mode = R"( OpExecutionMode %main LocalSize 8 8 1 -OpExecutionMode %main DerivativeGroupLinearNV +OpExecutionMode %main DerivativeGroupLinearKHR )"; CompileSuccessfully( GenerateShaderCode(body, extra, "GLCompute", mode).c_str()); @@ -4699,8 +5006,8 @@ TEST_F(ValidateImage, ImplicitLodComputeShaderDerivativesMissingMode) { )"; const std::string extra = R"( -OpCapability ComputeDerivativeGroupLinearNV -OpExtension "SPV_NV_compute_shader_derivatives" +OpCapability ComputeDerivativeGroupLinearKHR +OpExtension "SPV_KHR_compute_shader_derivatives" )"; const std::string mode = R"( OpExecutionMode %main LocalSize 8 8 1 @@ -4710,9 +5017,9 @@ OpExecutionMode %main LocalSize 8 8 1 ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), - HasSubstr("ImplicitLod instructions require DerivativeGroupQuadsNV or " - "DerivativeGroupLinearNV execution mode for GLCompute " - "execution model")); + HasSubstr("ImplicitLod instructions require DerivativeGroupQuadsKHR or " + "DerivativeGroupLinearKHR execution mode for GLCompute, " + "MeshEXT or TaskEXT execution model")); } TEST_F(ValidateImage, ReadSubpassDataWrongExecutionModel) { @@ -5576,10 +5883,12 @@ TEST_F(ValidateImage, SignExtendV13Bad) { %res1 = OpImageRead %u32vec4 %img %u32vec2_01 SignExtend )"; - EXPECT_THAT(CompileFailure(GenerateShaderCode(body, "", "Fragment", "", - SPV_ENV_UNIVERSAL_1_3), - SPV_ENV_UNIVERSAL_1_3, SPV_ERROR_WRONG_VERSION), - HasSubstr("Invalid image operand 'SignExtend'")); + CompileSuccessfully( + GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_UNIVERSAL_1_3)); + ASSERT_EQ(SPV_ERROR_WRONG_VERSION, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("SignExtend(4096) requires SPIR-V version 1.4 or later")); } TEST_F(ValidateImage, ZeroExtendV13Bad) { @@ -5588,10 +5897,12 @@ TEST_F(ValidateImage, ZeroExtendV13Bad) { %res1 = OpImageRead %u32vec4 %img %u32vec2_01 ZeroExtend )"; - EXPECT_THAT(CompileFailure(GenerateShaderCode(body, "", "Fragment", "", - SPV_ENV_UNIVERSAL_1_3), - SPV_ENV_UNIVERSAL_1_3, SPV_ERROR_WRONG_VERSION), - HasSubstr("Invalid image operand 'ZeroExtend'")); + CompileSuccessfully( + GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_UNIVERSAL_1_3)); + ASSERT_EQ(SPV_ERROR_WRONG_VERSION, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("ZeroExtend(8192) requires SPIR-V version 1.4 or later")); } TEST_F(ValidateImage, SignExtendScalarUIntTexelV14Good) { @@ -6013,7 +6324,7 @@ TEST_F(ValidateImage, ImageTexelPointer64ResultTypeNotPointer) { .c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Result Type to be OpTypePointer")); + HasSubstr("Expected Result Type to be a pointer")); } TEST_F(ValidateImage, ImageTexelPointer64ResultTypeNotImageClass) { @@ -6029,7 +6340,7 @@ TEST_F(ValidateImage, ImageTexelPointer64ResultTypeNotImageClass) { .c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Expected Result Type to be OpTypePointer whose " + HasSubstr("Expected Result Type to be a pointer whose " "Storage Class operand is Image")); } @@ -6210,8 +6521,9 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("ImplicitLod instructions require " - "DerivativeGroupQuadsNV or DerivativeGroupLinearNV " - "execution mode for GLCompute execution model")); + "DerivativeGroupQuadsKHR or DerivativeGroupLinearKHR " + "execution mode for GLCompute, MeshEXT or TaskEXT " + "execution model")); } TEST_F(ValidateImage, TypeSampledImageNotBufferPost1p6) { @@ -6397,6 +6709,4208 @@ TEST_F(ValidateImage, NVBindlessInvalidAddressingMode) { HasSubstr("OpSamplerImageAddressingModeNV bitwidth should be 64 or 32")); } +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADNoDecorationA) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADNoDecorationB) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADNoDecorationC) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADNoDecorationD) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDNoDecorationA) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDNoDecorationB) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDNoDecorationC) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDNoDecorationD) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingSampleWeightedNoDecorationA) { + std::string text = R"( + OpCapability Shader + OpCapability TextureSampleWeightedQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 %7 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 Location 0 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 0 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %13 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 + %4 = OpVariable %_ptr_UniformConstant_13 UniformConstant + %15 = OpTypeSampler +%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15 + %5 = OpVariable %_ptr_UniformConstant_15 UniformConstant + %17 = OpTypeSampledImage %13 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %6 = OpVariable %_ptr_Input_v4float Input + %v2float = OpTypeVector %float 2 + %20 = OpTypeImage %float 2D 0 1 0 1 Unknown +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %7 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %22 = OpTypeSampledImage %20 +%_ptr_UniformConstant_17 = OpTypePointer UniformConstant %17 + %2 = OpFunction %void None %9 + %24 = OpLabel + %25 = OpLoad %13 %4 + %26 = OpLoad %15 %5 + %27 = OpSampledImage %17 %25 %26 + %28 = OpLoad %v4float %6 + %29 = OpVectorShuffle %v2float %28 %28 0 1 + %30 = OpLoad %20 %7 + %31 = OpLoad %15 %5 + %32 = OpSampledImage %22 %30 %31 + %33 = OpImageSampleWeightedQCOM %v4float %27 %29 %32 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration WeightTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingSampleWeightedNoDecorationB) { + std::string text = R"( + OpCapability Shader + OpCapability TextureSampleWeightedQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %12 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 + %14 = OpTypeSampler +%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 + %16 = OpTypeSampledImage %12 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %4 = OpVariable %_ptr_Input_v4float Input + %v2float = OpTypeVector %float 2 + %19 = OpTypeImage %float 2D 0 1 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %21 = OpTypeSampledImage %19 +%_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16 + %5 = OpVariable %_ptr_UniformConstant_16 UniformConstant +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %6 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpLoad %16 %5 + %26 = OpLoad %v4float %4 + %27 = OpVectorShuffle %v2float %26 %26 0 1 + %28 = OpLoad %21 %6 + %29 = OpImageSampleWeightedQCOM %v4float %25 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration WeightTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchWindowSADInvalidUseA) { + std::string text = R"( +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 79 +; Schema: 0 + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADInvalidUseB) { + std::string text = R"( +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 79 +; Schema: 0 + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADInvalidUseC) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSADInvalidUseD) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDInvalidUseA) { + std::string text = R"( +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 79 +; Schema: 0 + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDInvalidUseB) { + std::string text = R"( +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 79 +; Schema: 0 + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDInvalidUseC) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingBlockMatchSSDInvalidUseD) { + std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingSampleWeightedInvalidUseA) { + std::string text = R"( + OpCapability Shader + OpCapability TextureSampleWeightedQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %6 WeightTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %12 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 + %14 = OpTypeSampledImage %12 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %4 = OpVariable %_ptr_Input_v4float Input + %v2float = OpTypeVector %float 2 + %17 = OpTypeImage %float 2D 0 1 0 1 Unknown +%_ptr_UniformConstant_17 = OpTypePointer UniformConstant %17 + %19 = OpTypeSampledImage %17 +%_ptr_UniformConstant_14 = OpTypePointer UniformConstant %14 + %5 = OpVariable %_ptr_UniformConstant_14 UniformConstant +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %v3float = OpTypeVector %float 3 + %2 = OpFunction %void None %8 + %23 = OpLabel + %24 = OpLoad %v4float %4 + %25 = OpVectorShuffle %v2float %24 %24 0 1 + %26 = OpLoad %14 %5 + %27 = OpLoad %v4float %4 + %28 = OpVectorShuffle %v2float %27 %27 0 1 + %29 = OpLoad %19 %6 + %30 = OpImageSampleWeightedQCOM %v4float %26 %28 %29 + OpStore %3 %30 + %31 = OpLoad %19 %6 + %32 = OpLoad %v4float %4 + %33 = OpVectorShuffle %v3float %32 %32 0 1 0 + %34 = OpCompositeExtract %float %33 0 + %35 = OpCompositeExtract %float %33 1 + %36 = OpCompositeExtract %float %33 2 + %37 = OpCompositeConstruct %v3float %34 %35 %36 + %38 = OpImageSampleImplicitLod %v4float %31 %37 + OpStore %3 %38 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessingSampleWeightedInvalidUseB) { + std::string text = R"( + OpCapability Shader + OpCapability TextureSampleWeightedQCOM + OpExtension "SPV_QCOM_image_processing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 %7 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 3 + OpDecorate %4 Location 0 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 0 + OpDecorate %7 WeightTextureQCOM + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %13 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 + %5 = OpVariable %_ptr_UniformConstant_13 UniformConstant + %15 = OpTypeSampler +%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15 + %6 = OpVariable %_ptr_UniformConstant_15 UniformConstant + %17 = OpTypeSampledImage %13 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %4 = OpVariable %_ptr_Input_v4float Input + %v2float = OpTypeVector %float 2 + %20 = OpTypeImage %float 2D 0 1 0 1 Unknown +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %7 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %22 = OpTypeSampledImage %20 + %v3float = OpTypeVector %float 3 + %2 = OpFunction %void None %9 + %24 = OpLabel + %25 = OpLoad %13 %5 + %26 = OpLoad %15 %6 + %27 = OpSampledImage %17 %25 %26 + %28 = OpLoad %v4float %4 + %29 = OpVectorShuffle %v2float %28 %28 0 1 + %30 = OpLoad %20 %7 + %31 = OpLoad %15 %6 + %32 = OpSampledImage %22 %30 %31 + %33 = OpImageSampleWeightedQCOM %v4float %27 %29 %32 + OpStore %3 %33 + %34 = OpLoad %20 %7 + %35 = OpLoad %15 %6 + %36 = OpSampledImage %22 %34 %35 + %37 = OpLoad %v4float %4 + %38 = OpVectorShuffle %v3float %37 %37 0 1 0 + %39 = OpCompositeExtract %float %38 0 + %40 = OpCompositeExtract %float %38 1 + %41 = OpCompositeExtract %float %38 2 + %42 = OpCompositeConstruct %v3float %39 %40 %41 + %43 = OpImageSampleImplicitLod %v4float %36 %42 + OpStore %3 %43 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorTargetIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorTargetIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorRefIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorRefIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorTargetNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorTargetNIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorRefNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADNoDecorRefNIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorTargetIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorTargetIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorRefIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchSamplerQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorRefIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchWindowSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorTargetNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorTargetNIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorRefNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDNoDecorRefNIS) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %4 BlockMatchSamplerQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchWindowSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchSamplerQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADNoDecorTargetIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchGatherSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADNoDecorRefIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchGatherSADQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADNoDecorTargetNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchGatherSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADNoDecorRefNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchGatherSADQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDNoDecorTargetIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchGatherSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDNoDecorRefIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 4 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 5 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown + %19 = OpTypeSampledImage %18 +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %7 + %22 = OpLabel + %23 = OpVariable %_ptr_Function_v2uint Function + %24 = OpLoad %19 %4 + %25 = OpLoad %v2uint %23 + %26 = OpLoad %19 %5 + %27 = OpLoad %v2uint %23 + %28 = OpLoad %v2uint %23 + %29 = OpImageBlockMatchGatherSSDQCOM %v4float %24 %25 %26 %27 %28 + OpStore %3 %29 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDNoDecorTargetNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchGatherSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDNoDecorRefNIT) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 1 + OpDecorate %4 BlockMatchTextureQCOM + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 3 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_Function_uint = OpTypePointer Function %uint +%uint_4 = OpConstant %uint 4 + %17 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %3 = OpVariable %_ptr_Output_v4float Output + %19 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %4 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %21 = OpTypeSampler +%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21 + %5 = OpVariable %_ptr_UniformConstant_21 UniformConstant + %23 = OpTypeSampledImage %19 + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + %26 = OpLoad %19 %4 + %27 = OpLoad %21 %5 + %28 = OpSampledImage %23 %26 %27 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %19 %6 + %31 = OpLoad %21 %5 + %32 = OpSampledImage %23 %30 %31 + %33 = OpImageBlockMatchGatherSSDQCOM %v4float %28 %29 %32 %29 %29 + OpStore %3 %33 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Missing decoration BlockMatchTextureQCOM")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchWindowSADInvalidUseTargetI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchWindowSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADInvalidUseRefI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchWindowSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchWindowSADInvalidUseTargetNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %103 BlockMatchSamplerQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchWindowSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSADInvalidUseRefNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %103 BlockMatchSamplerQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchWindowSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchWindowSSDInvalidUseTargetI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchWindowSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDInvalidUseRefI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %5 BlockMatchSamplerQCOM + OpDecorate %6 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchSamplerQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchWindowSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchWindowSSDInvalidUseTargetNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %103 BlockMatchSamplerQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchWindowSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchWindowSSDInvalidUseRefNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %103 BlockMatchSamplerQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchWindowSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchGatherSADInvalidUseTargetI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchGatherSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADInvalidUseRefI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchGatherSADQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchGatherSADInvalidUseTargetNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchGatherSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSADInvalidUseRefNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchGatherSADQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchGatherSSDInvalidUseTargetI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchGatherSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %5 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDInvalidUseRefI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %2 "main" %3 %4 %5 %6 + OpExecutionMode %2 OriginUpperLeft + OpDecorate %3 Location 0 + OpDecorate %4 Location 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 4 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 5 + OpDecorate %5 BlockMatchTextureQCOM + OpDecorate %6 BlockMatchTextureQCOM + %void = OpTypeVoid + %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %3 = OpVariable %_ptr_Input_v4float Input + %uint_4 = OpConstant %uint 4 + %16 = OpConstantComposite %v2uint %uint_4 %uint_4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpVariable %_ptr_Output_v4float Output + %18 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18 + %20 = OpTypeSampledImage %18 +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 + %5 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_20 UniformConstant + %v2float = OpTypeVector %float 2 + %23 = OpTypeImage %float 2D 0 1 0 1 Unknown + %2 = OpFunction %void None %8 + %24 = OpLabel + %25 = OpVariable %_ptr_Function_v2uint Function + OpStore %25 %16 + %26 = OpLoad %20 %5 + %27 = OpLoad %v2uint %25 + %28 = OpLoad %20 %6 + %29 = OpLoad %v2uint %25 + %30 = OpLoad %v2uint %25 + %31 = OpImageBlockMatchGatherSSDQCOM %v4float %26 %27 %28 %29 %30 + OpStore %4 %31 + %32 = OpLoad %20 %6 + %33 = OpLoad %v4float %3 + %34 = OpVectorShuffle %v2float %33 %33 0 2 + %35 = OpImageSampleImplicitLod %v4float %32 %34 + OpStore %4 %35 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, + QCOMImageProcessing2BlockMatchGatherSSDInvalidUseTargetNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchGatherSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %102 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDInvalidUseRefNI) { + const std::string text = R"( + OpCapability Shader + OpCapability TextureBlockMatchQCOM + OpCapability TextureBlockMatch2QCOM + OpExtension "SPV_QCOM_image_processing" + OpExtension "SPV_QCOM_image_processing2" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %100 %101 %102 %103 %104 + OpExecutionMode %main OriginUpperLeft + OpDecorate %100 Location 0 + OpDecorate %101 Location 0 + OpDecorate %102 DescriptorSet 0 + OpDecorate %102 Binding 1 + OpDecorate %103 DescriptorSet 0 + OpDecorate %103 Binding 3 + OpDecorate %104 DescriptorSet 0 + OpDecorate %104 Binding 2 + OpDecorate %102 BlockMatchTextureQCOM + OpDecorate %104 BlockMatchTextureQCOM + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %100 = OpVariable %_ptr_Input_v4float Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %101 = OpVariable %_ptr_Output_v4float Output + %42 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %102 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %46 = OpTypeSampler +%_ptr_UniformConstant_46 = OpTypePointer UniformConstant %46 + %103 = OpVariable %_ptr_UniformConstant_46 UniformConstant + %50 = OpTypeSampledImage %42 + %104 = OpVariable %_ptr_UniformConstant_42 UniformConstant + %v2float = OpTypeVector %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpVariable %_ptr_Function_v2uint Function + %45 = OpLoad %42 %102 + %49 = OpLoad %46 %103 + %51 = OpSampledImage %50 %45 %49 + %52 = OpLoad %v2uint %15 + %54 = OpLoad %42 %104 + %55 = OpLoad %46 %103 + %56 = OpSampledImage %50 %54 %55 + %57 = OpLoad %v2uint %15 + %58 = OpLoad %v2uint %15 + %59 = OpImageBlockMatchGatherSSDQCOM %v4float %51 %52 %56 %57 %58 + OpStore %101 %59 + %69 = OpLoad %42 %104 + %70 = OpLoad %46 %103 + %71 = OpSampledImage %50 %69 %70 + %73 = OpLoad %v4float %100 + %74 = OpVectorShuffle %v2float %73 %73 0 0 + %75 = OpImageSampleImplicitLod %v4float %71 %74 + OpStore %101 %75 + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Illegal use of QCOM image processing decorated texture")); +} + +TEST_F(ValidateImage, ImageMSArray_ArrayedSampledTypeRequiresCapability) { + const std::string code = R"( + OpCapability Shader + OpCapability StorageImageMultisample + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v2uint = OpTypeVector %u32 2 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 1 1 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v2uint %uint_1 %uint_2 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 Sample %uint_2 + OpReturn + OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Capability ImageMSArray is required to access storage image")); +} + +TEST_F(ValidateImage, ImageMSArray_SampledTypeDoesNotRequireCapability) { + const std::string code = R"( + OpCapability Shader + OpCapability StorageImageMultisample + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v2uint = OpTypeVector %u32 2 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 0 1 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v2uint %uint_1 %uint_2 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 Sample %uint_2 + OpReturn + OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(env)); + EXPECT_THAT(getDiagnosticString(), Eq("")); +} + +TEST_F(ValidateImage, ImageMSArray_ArrayedTypeDoesNotRequireCapability) { + const std::string code = R"( + OpCapability Shader + OpCapability StorageImageReadWithoutFormat + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpDecorate %var_image DescriptorSet 0 + OpDecorate %var_image Binding 1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %f32 = OpTypeFloat 32 + %u32 = OpTypeInt 32 0 + %uint_3 = OpConstant %u32 3 + %uint_2 = OpConstant %u32 2 + %uint_1 = OpConstant %u32 1 + %v3uint = OpTypeVector %u32 3 + %v4float = OpTypeVector %f32 4 + %image = OpTypeImage %f32 2D 2 1 0 2 Unknown +%ptr_image = OpTypePointer UniformConstant %image + %10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3 +%var_image = OpVariable %ptr_image UniformConstant + %main = OpFunction %void None %func + %main_lab = OpLabel + %18 = OpLoad %image %var_image + %19 = OpImageRead %v4float %18 %10 + OpReturn + OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(env)); + EXPECT_THAT(getDiagnosticString(), Eq("")); +} + +TEST_F(ValidateImage, SampledImageTypeDepthMismatch) { + const std::string code = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %im_var DescriptorSet 0 +OpDecorate %im_var Binding 0 +OpDecorate %s_var DescriptorSet 1 +OpDecorate %s_var Binding 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 1 Unknown +%im2_ty = OpTypeImage %float 2D 1 0 0 1 Unknown +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(env)); +} + +TEST_F(ValidateImage, SampledImageTypeArrayedMismatch) { + const std::string code = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %im_var DescriptorSet 0 +OpDecorate %im_var Binding 0 +OpDecorate %s_var DescriptorSet 1 +OpDecorate %s_var Binding 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 1 Unknown +%im2_ty = OpTypeImage %float 2D 0 1 0 1 Unknown +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image operands must match result image operands except for depth")); +} + +TEST_F(ValidateImage, SampledImageTypeMultisampledMismatch) { + const std::string code = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %im_var DescriptorSet 0 +OpDecorate %im_var Binding 0 +OpDecorate %s_var DescriptorSet 1 +OpDecorate %s_var Binding 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 1 Unknown +%im2_ty = OpTypeImage %float 2D 0 0 1 1 Unknown +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_VULKAN_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image operands must match result image operands except for depth")); +} + +TEST_F(ValidateImage, SampledImageTypeSampledMismatch) { + const std::string code = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %im_var DescriptorSet 0 +OpDecorate %im_var Binding 0 +OpDecorate %s_var DescriptorSet 1 +OpDecorate %s_var Binding 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 1 Unknown +%im2_ty = OpTypeImage %float 2D 0 0 0 0 Unknown +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_UNIVERSAL_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image operands must match result image operands except for depth")); +} + +TEST_F(ValidateImage, SampledImageTypeFormatMismatch) { + const std::string code = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %im_var DescriptorSet 0 +OpDecorate %im_var Binding 0 +OpDecorate %s_var DescriptorSet 1 +OpDecorate %s_var Binding 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 1 Unknown +%im2_ty = OpTypeImage %float 2D 0 0 0 1 R32f +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_UNIVERSAL_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image operands must match result image operands except for depth")); +} + +TEST_F(ValidateImage, SampledImageTypeAccessQualifierMismatch) { + const std::string code = R"( +OpCapability Kernel +OpCapability Linkage +OpMemoryModel Logical OpenCL +%void = OpTypeVoid +%float = OpTypeFloat 32 +%im1_ty = OpTypeImage %float 2D 0 0 0 0 Unknown ReadWrite +%im2_ty = OpTypeImage %float 2D 0 0 0 0 Unknown ReadOnly +%s_ty = OpTypeSampler +%s_im_ty = OpTypeSampledImage %im2_ty +%ptr_im = OpTypePointer UniformConstant %im1_ty +%ptr_s = OpTypePointer UniformConstant %s_ty +%im_var = OpVariable %ptr_im UniformConstant +%s_var = OpVariable %ptr_s UniformConstant +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%im_ld = OpLoad %im1_ty %im_var +%s_ld = OpLoad %s_ty %s_var +%sampled_image = OpSampledImage %s_im_ty %im_ld %s_ld +OpReturn +OpFunctionEnd +)"; + + const spv_target_env env = SPV_ENV_UNIVERSAL_1_0; + CompileSuccessfully(code, env); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Image operands must match result image operands except for depth")); +} + +TEST_F(ValidateImage, ImageTexelPointerNotAPointer) { + const std::string code = R"( + OpCapability ClipDistance + OpMemoryModel Logical Simple + %void = OpTypeVoid + %57 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%int_538976288 = OpConstant %int 538976288 +%int_538976288_0 = OpConstant %int 538976288 + %8224 = OpFunction %void None %57 + %65312 = OpLabel + %2097184 = OpImageTexelPointer %void %int_538976288 %int_538976288 %int_538976288_0 + OpUnreachable + OpFunctionEnd +)"; + + CompileSuccessfully(code); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Expected Result Type to be a pointer")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_interfaces_test.cpp b/third_party/spirv-tools/test/val/val_interfaces_test.cpp index 1756528729..50f45573f7 100644 --- a/third_party/spirv-tools/test/val/val_interfaces_test.cpp +++ b/third_party/spirv-tools/test/val/val_interfaces_test.cpp @@ -419,9 +419,10 @@ OpFunctionEnd )"; CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); - EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("Variable has conflicting location decorations")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("decorated with Location multiple times is not allowed")); } TEST_F(ValidateInterfacesTest, VulkanLocationsVariableAndMemberAssigned) { @@ -505,9 +506,10 @@ OpFunctionEnd )"; CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); - EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("Member index 1 has conflicting location assignments")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("decorated with Location multiple times is not allowed")); } TEST_F(ValidateInterfacesTest, VulkanLocationsMissingAssignmentStructMember) { @@ -583,6 +585,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 0")); @@ -611,12 +615,80 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08722")); EXPECT_THAT( getDiagnosticString(), HasSubstr("Entry-point has conflicting output location assignment " "at location 1")); } +TEST_F(ValidateInterfacesTest, VulkanPatchAndNonPatchOverlap) { + const std::string text = R"( + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %a %b + OpExecutionMode %main OutputVertices 4 + OpDecorate %a Location 0 + OpDecorate %b Patch + OpDecorate %b Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %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 + %a = OpVariable %_ptr_Output__arr_float_uint_4 Output +%_ptr_Output_float = OpTypePointer Output %float + %b = OpVariable %_ptr_Output_float Output + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateInterfacesTest, VulkanPatchOverlap) { + const std::string text = R"( + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %a %b %c + OpExecutionMode %main OutputVertices 4 + OpDecorate %a Location 0 + OpDecorate %b Patch + OpDecorate %b Location 6 + OpDecorate %c Patch + OpDecorate %c Location 6 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %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 + %a = OpVariable %_ptr_Output__arr_float_uint_4 Output +%_ptr_Output_float = OpTypePointer Output %float + %b = OpVariable %_ptr_Output_float Output + %c = OpVariable %_ptr_Output_float Output + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd + )"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08722")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Entry-point has conflicting output location " + "assignment at location 6, component 0")); +} + TEST_F(ValidateInterfacesTest, VulkanLocationsSameLocationInputAndOutputNoConflict) { const std::string text = R"( @@ -698,6 +770,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1")); @@ -731,6 +805,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1")); @@ -761,6 +837,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1")); @@ -791,6 +869,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 2")); @@ -821,6 +901,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 3")); @@ -853,6 +935,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1")); @@ -885,6 +969,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 5")); @@ -917,6 +1003,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 7")); @@ -949,6 +1037,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1")); @@ -981,6 +1071,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 3")); @@ -1015,6 +1107,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 15")); @@ -1074,6 +1168,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08721")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting input location assignment " "at location 1, component 1")); @@ -1129,9 +1225,10 @@ OpFunctionEnd )"; CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); - EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("Variable has conflicting component decorations")); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("decorated with Component multiple times is not allowed")); } TEST_F(ValidateInterfacesTest, @@ -1158,10 +1255,10 @@ OpFunctionEnd )"; CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); - EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT( getDiagnosticString(), - HasSubstr("Member index 0 has conflicting component assignments")); + HasSubstr("decorated with Component multiple times is not allowed")); } TEST_F(ValidateInterfacesTest, VulkanLocationsVariableConflictOutputIndex1) { @@ -1189,6 +1286,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08722")); EXPECT_THAT( getDiagnosticString(), HasSubstr("Entry-point has conflicting output location assignment " @@ -1358,6 +1457,8 @@ OpFunctionEnd CompileSuccessfully(text, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpEntryPoint-08722")); EXPECT_THAT(getDiagnosticString(), HasSubstr("Entry-point has conflicting output location " "assignment at location 1, component 1")); @@ -1538,6 +1639,174 @@ OpFunctionEnd "Interface struct has no Block decoration but has BuiltIn members.")); } +TEST_F(ValidateInterfacesTest, InvalidLocationTypePointer) { + const std::string text = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Vertex %1 "Aiqn0" %2 %3 + OpDecorate %2 Location 0 + %void = OpTypeVoid + %5 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Private_void = OpTypePointer Private %void + %uint = OpTypeInt 32 0 +%uint_4278132784 = OpConstant %uint 4278132784 +%_arr__ptr_Private_void_uint_4278132784 = OpTypeArray %_ptr_Private_void %uint_4278132784 +%_ptr_Output__arr__ptr_Private_void_uint_4278132784 = OpTypePointer Output %_arr__ptr_Private_void_uint_4278132784 + %2 = OpVariable %_ptr_Output__arr__ptr_Private_void_uint_4278132784 Output +%_ptr_Output__ptr_Private_void = OpTypePointer Output %_ptr_Private_void + %3 = OpVariable %_ptr_Output__arr__ptr_Private_void_uint_4278132784 Output + %1 = OpFunction %void None %5 + %15 = OpLabel + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Invalid type to assign a location")); +} + +TEST_F(ValidateInterfacesTest, ValidLocationTypePhysicalStorageBufferPointer) { + const std::string text = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Vertex %main "main" %var +OpDecorate %var Location 0 +OpDecorate %var RestrictPointer +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypePointer PhysicalStorageBuffer %int +%ptr2 = OpTypePointer Input %ptr +%var = OpVariable %ptr2 Input +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateInterfacesTest, UntypedVariableInputMissing) { + const std::string text = R"( +OpCapability Kernel +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpName %var "var" +OpDecorate %var BuiltIn LocalInvocationId +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%ptr = OpTypeUntypedPointerKHR Input +%var = OpUntypedVariableKHR %ptr Input %int3 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %int3 %var +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Interface variable id <2> is used by entry point " + "'main' id <1>, but is not listed as an interface")); +} + +TEST_F(ValidateInterfacesTest, UntypedVariableWorkgroupMissingSpv1p4) { + const std::string text = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %var "var" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %int %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Interface variable id <2> is used by entry point " + "'main' id <1>, but is not listed as an interface")); +} + +TEST_F(ValidateInterfacesTest, UntypedIdMatchesInputVulkan1p3) { + const std::string text = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %var +OpExecutionMode %main OriginUpperLeft +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %1 Block +OpMemberDecorate %1 0 Offset 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%1 = OpTypeStruct %float ; this id matches Input storage class +%ptr = OpTypeUntypedPointerKHR Uniform +%var = OpUntypedVariableKHR %ptr Uniform %1 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateInterfacesTest, UntypedIdMatchesPushConstantVulkan1p3) { + const std::string text = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" %var +OpExecutionMode %main OriginUpperLeft +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %9 Block +OpMemberDecorate %9 0 Offset 0 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%9 = OpTypeStruct %float ; this id matches PushConstant storage class +%ptr = OpTypeUntypedPointerKHR Uniform +%var = OpUntypedVariableKHR %ptr Uniform %9 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_layout_test.cpp b/third_party/spirv-tools/test/val/val_layout_test.cpp index 8cca96f59e..e809abf812 100644 --- a/third_party/spirv-tools/test/val/val_layout_test.cpp +++ b/third_party/spirv-tools/test/val/val_layout_test.cpp @@ -14,9 +14,7 @@ // Validation tests for Logical Layout -#include #include -#include #include #include #include @@ -57,13 +55,6 @@ struct Range { bool inverse_; }; -template -spv_result_t InvalidSet(int order) { - for (spv_result_t val : {T(true)(order)...}) - if (val != SPV_SUCCESS) return val; - return SPV_SUCCESS; -} - // SPIRV source used to test the logical layout const std::vector& getInstructions() { // clang-format off diff --git a/third_party/spirv-tools/test/val/val_limits_test.cpp b/third_party/spirv-tools/test/val/val_limits_test.cpp index 364d514edc..66a6ff7f77 100644 --- a/third_party/spirv-tools/test/val/val_limits_test.cpp +++ b/third_party/spirv-tools/test/val/val_limits_test.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "gmock/gmock.h" #include "test/unit_spirv.h" diff --git a/third_party/spirv-tools/test/val/val_memory_test.cpp b/third_party/spirv-tools/test/val/val_memory_test.cpp index d0735dca13..8855b0ef6d 100644 --- a/third_party/spirv-tools/test/val/val_memory_test.cpp +++ b/third_party/spirv-tools/test/val/val_memory_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2018 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,12 +25,14 @@ #include "test/val/val_fixtures.h" // For pretty-printing tuples with spv_target_env. -std::ostream& operator<<(std::ostream& stream, spv_target_env target) -{ +std::ostream& operator<<(std::ostream& stream, spv_target_env target) { switch (target) { - case SPV_ENV_UNIVERSAL_1_3: return stream << "SPV_ENV_UNIVERSAL_1_3"; - case SPV_ENV_UNIVERSAL_1_4: return stream << "SPV_ENV_UNIVERSAL_1_4"; - default: return stream << (unsigned)target; + case SPV_ENV_UNIVERSAL_1_3: + return stream << "SPV_ENV_UNIVERSAL_1_3"; + case SPV_ENV_UNIVERSAL_1_4: + return stream << "SPV_ENV_UNIVERSAL_1_4"; + default: + return stream << (unsigned)target; } } @@ -350,12 +354,8 @@ OpFunctionEnd )"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); - EXPECT_THAT( - getDiagnosticString(), - HasSubstr( - "From SPIR-V spec, section 3.32.8 on OpVariable:\n" - "Its Storage Class operand must be the same as the Storage Class " - "operand of the result type.")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Storage class must match result type storage class")); } TEST_F(ValidateMemory, MatchingStorageClassesGood) { @@ -786,7 +786,7 @@ TEST_F(ValidateMemory, ArrayLenIndexNotLastMember) { EXPECT_THAT( getDiagnosticString(), HasSubstr( - "The array member in OpArrayLength '11[%11]' must be an the " + "The array member in OpArrayLength '11[%11]' must be the " "last member of the struct.\n %11 = OpArrayLength %uint %10 0\n")); } @@ -1463,6 +1463,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %int_ptr_ssbo = OpTypePointer StorageBuffer %int %var1 = OpVariable %int_ptr_ssbo StorageBuffer @@ -1470,7 +1471,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device MakePointerAvailableKHR|NonPrivatePointerKHR %device +OpCopyMemorySized %var1 %var2 %int_4 MakePointerAvailableKHR|NonPrivatePointerKHR %device OpReturn OpFunctionEnd )"; @@ -1494,6 +1495,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %workgroup = OpConstant %int 1 %int_ptr_ssbo = OpTypePointer StorageBuffer %int @@ -1502,7 +1504,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %device %workgroup +OpCopyMemorySized %var1 %var2 %int_4 Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %device %workgroup OpReturn OpFunctionEnd )"; @@ -1526,6 +1528,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %workgroup = OpConstant %int 1 %int_ptr_ssbo = OpTypePointer StorageBuffer %int @@ -1534,7 +1537,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %workgroup %device +OpCopyMemorySized %var1 %var2 %int_4 Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %workgroup %device OpReturn OpFunctionEnd )"; @@ -1559,6 +1562,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %int_ptr_ssbo = OpTypePointer StorageBuffer %int %var1 = OpVariable %int_ptr_ssbo StorageBuffer @@ -1566,7 +1570,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device MakePointerAvailableKHR|NonPrivatePointerKHR %device +OpCopyMemorySized %var1 %var2 %int_4 MakePointerAvailableKHR|NonPrivatePointerKHR %device OpReturn OpFunctionEnd )"; @@ -1586,6 +1590,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %workgroup = OpConstant %int 2 %int_ptr_ssbo = OpTypePointer StorageBuffer %int @@ -1594,7 +1599,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %device %workgroup +OpCopyMemorySized %var1 %var2 %int_4 Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %device %workgroup OpReturn OpFunctionEnd )"; @@ -1614,6 +1619,7 @@ OpExtension "SPV_KHR_vulkan_memory_model" OpMemoryModel Logical VulkanKHR %void = OpTypeVoid %int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 %device = OpConstant %int 1 %workgroup = OpConstant %int 2 %int_ptr_ssbo = OpTypePointer StorageBuffer %int @@ -1622,7 +1628,7 @@ OpMemoryModel Logical VulkanKHR %voidfn = OpTypeFunction %void %func = OpFunction %void None %voidfn %entry = OpLabel -OpCopyMemorySized %var1 %var2 %device Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %workgroup %device +OpCopyMemorySized %var1 %var2 %int_4 Aligned|MakePointerVisibleKHR|MakePointerAvailableKHR|NonPrivatePointerKHR 4 %workgroup %device OpReturn OpFunctionEnd )"; @@ -2346,6 +2352,448 @@ OpFunctionEnd)"; EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } +std::string GenCoopMatLoadStoreShaderKHR(const std::string& storeMemoryAccess, + const std::string& loadMemoryAccess, + unsigned layout = 0, + bool useSpecConstantLayout = false, + bool useStoreStride = true, + bool useLoadStride = true) { + std::string s = R"( +OpCapability Shader +OpCapability GroupNonUniform +OpCapability VulkanMemoryModelKHR +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_KHR_cooperative_matrix" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical VulkanKHR +OpEntryPoint GLCompute %4 "main" %11 %21 +OpExecutionMode %4 LocalSize 1 1 1 +OpDecorate %11 BuiltIn SubgroupId +OpDecorate %21 BuiltIn WorkgroupId +OpDecorate %74 ArrayStride 4 +OpMemberDecorate %75 0 Offset 0 +OpDecorate %75 Block +OpDecorate %77 DescriptorSet 0 +OpDecorate %77 Binding 0 +OpDecorate %92 ArrayStride 4 +OpMemberDecorate %93 0 Offset 0 +OpDecorate %93 Block +OpDecorate %95 DescriptorSet 0 +OpDecorate %95 Binding 1 +OpDecorate %102 ArrayStride 4 +OpMemberDecorate %103 0 Offset 0 +OpDecorate %103 Block +OpDecorate %105 DescriptorSet 0 +OpDecorate %105 Binding 2 +OpDecorate %117 ArrayStride 4 +OpMemberDecorate %118 0 Offset 0 +OpDecorate %118 Block +OpDecorate %120 DescriptorSet 0 +OpDecorate %120 Binding 3 +OpDecorate %123 SpecId 2 +OpDecorate %124 SpecId 3 +OpDecorate %125 SpecId 4 +OpDecorate %126 SpecId 5 +OpDecorate %127 SpecId 0 +OpDecorate %128 SpecId 1 +OpDecorate %129 BuiltIn WorkgroupSize +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeInt 32 0 +%7 = OpTypeVector %6 2 +%8 = OpTypePointer Function %7 +%10 = OpTypePointer Input %6 +%11 = OpVariable %10 Input +%13 = OpConstant %6 2 +%19 = OpTypeVector %6 3 +%20 = OpTypePointer Input %19 +%21 = OpVariable %20 Input +%27 = OpConstantComposite %7 %13 %13 +%31 = OpTypePointer Function %6 +%33 = OpConstant %6 1024 +%34 = OpConstant %6 1 +%38 = OpConstant %6 8 +%uint_0 = OpConstant %6 0 +)"; + if (useSpecConstantLayout) { + s += "%layout = OpSpecConstant %6 " + std::to_string(layout); + } else { + s += "%layout = OpConstant %6 " + std::to_string(layout); + } + s += R"( +%68 = OpTypeFloat 32 +%69 = OpConstant %6 16 +%70 = OpConstant %6 3 +%71 = OpTypeCooperativeMatrixKHR %68 %70 %69 %38 %uint_0 +%72 = OpTypePointer Function %71 +%74 = OpTypeRuntimeArray %68 +%75 = OpTypeStruct %74 +%76 = OpTypePointer StorageBuffer %75 +%77 = OpVariable %76 StorageBuffer +%78 = OpTypeInt 32 1 +%79 = OpConstant %78 0 +%81 = OpConstant %6 5 +%82 = OpTypePointer StorageBuffer %68 +%stride = OpConstant %6 64 +%88 = OpTypePointer Private %71 +%89 = OpVariable %88 Private +%92 = OpTypeRuntimeArray %68 +%93 = OpTypeStruct %92 +%94 = OpTypePointer StorageBuffer %93 +%95 = OpVariable %94 StorageBuffer +%99 = OpVariable %88 Private +%102 = OpTypeRuntimeArray %68 +%103 = OpTypeStruct %102 +%104 = OpTypePointer StorageBuffer %103 +%105 = OpVariable %104 StorageBuffer +%109 = OpVariable %88 Private +%111 = OpVariable %88 Private +%112 = OpSpecConstantOp %6 CooperativeMatrixLengthKHR %71 +%113 = OpSpecConstantOp %78 IAdd %112 %79 +%117 = OpTypeRuntimeArray %68 +%118 = OpTypeStruct %117 +%119 = OpTypePointer StorageBuffer %118 +%120 = OpVariable %119 StorageBuffer +%123 = OpSpecConstant %78 1 +%124 = OpSpecConstant %78 1 +%125 = OpSpecConstant %78 1 +%126 = OpSpecConstant %78 1 +%127 = OpSpecConstant %6 1 +%128 = OpSpecConstant %6 1 +%129 = OpSpecConstantComposite %19 %127 %128 %34 +%4 = OpFunction %2 None %3 +%5 = OpLabel +%9 = OpVariable %8 Function +%18 = OpVariable %8 Function +%32 = OpVariable %31 Function +%44 = OpVariable %31 Function +%52 = OpVariable %31 Function +%60 = OpVariable %31 Function +%73 = OpVariable %72 Function +%91 = OpVariable %72 Function +%101 = OpVariable %72 Function +%12 = OpLoad %6 %11 +%14 = OpUMod %6 %12 %13 +%15 = OpLoad %6 %11 +%16 = OpUDiv %6 %15 %13 +%17 = OpCompositeConstruct %7 %14 %16 +OpStore %9 %17 +%22 = OpLoad %19 %21 +%23 = OpVectorShuffle %7 %22 %22 0 1 +%24 = OpCompositeExtract %6 %23 0 +%25 = OpCompositeExtract %6 %23 1 +%26 = OpCompositeConstruct %7 %24 %25 +%28 = OpIMul %7 %26 %27 +%29 = OpLoad %7 %9 +%30 = OpIAdd %7 %28 %29 +OpStore %18 %30 +%35 = OpAccessChain %31 %18 %34 +%36 = OpLoad %6 %35 +%37 = OpIMul %6 %33 %36 +%40 = OpAccessChain %31 %18 %uint_0 +%41 = OpLoad %6 %40 +%42 = OpIMul %6 %38 %41 +%43 = OpIAdd %6 %37 %42 +OpStore %32 %43 +%45 = OpAccessChain %31 %18 %34 +%46 = OpLoad %6 %45 +%47 = OpIMul %6 %33 %46 +%48 = OpAccessChain %31 %18 %uint_0 +%49 = OpLoad %6 %48 +%50 = OpIMul %6 %38 %49 +%51 = OpIAdd %6 %47 %50 +OpStore %44 %51 +%53 = OpAccessChain %31 %18 %34 +%54 = OpLoad %6 %53 +%55 = OpIMul %6 %33 %54 +%56 = OpAccessChain %31 %18 %uint_0 +%57 = OpLoad %6 %56 +%58 = OpIMul %6 %38 %57 +%59 = OpIAdd %6 %55 %58 +OpStore %52 %59 +%61 = OpAccessChain %31 %18 %34 +%62 = OpLoad %6 %61 +%63 = OpIMul %6 %33 %62 +%64 = OpAccessChain %31 %18 %uint_0 +%65 = OpLoad %6 %64 +%66 = OpIMul %6 %38 %65 +%67 = OpIAdd %6 %63 %66 +OpStore %60 %67 +%80 = OpLoad %6 %32 +%83 = OpAccessChain %82 %77 %79 %80 +)"; + if (useLoadStride) { + s += "%87 = OpCooperativeMatrixLoadKHR %71 %83 %layout %stride " + + loadMemoryAccess + " %81"; + } else { + s += "%87 = OpCooperativeMatrixLoadKHR %71 %83 %layout"; + } + s += R"( +OpStore %73 %87 +%90 = OpLoad %71 %73 +OpStore %89 %90 +%96 = OpLoad %6 %44 +%97 = OpAccessChain %82 %95 %79 %96 +%98 = OpCooperativeMatrixLoadKHR %71 %97 %layout %stride MakePointerVisibleKHR|NonPrivatePointerKHR %81 +OpStore %91 %98 +%100 = OpLoad %71 %91 +OpStore %99 %100 +%106 = OpLoad %6 %52 +%107 = OpAccessChain %82 %105 %79 %106 +%108 = OpCooperativeMatrixLoadKHR %71 %107 %layout %stride MakePointerVisibleKHR|NonPrivatePointerKHR %81 +OpStore %101 %108 +%110 = OpLoad %71 %101 +OpStore %109 %110 +%114 = OpConvertSToF %68 %113 +%115 = OpCompositeConstruct %71 %114 +OpStore %111 %115 +%116 = OpLoad %71 %111 +%121 = OpLoad %6 %60 +%122 = OpAccessChain %82 %120 %79 %121 +)"; + if (useStoreStride) { + s += "OpCooperativeMatrixStoreKHR %122 %116 %layout %stride " + + storeMemoryAccess + " %81"; + } else { + s += "OpCooperativeMatrixStoreKHR %122 %116 %layout"; + } + s += R"( +OpReturn +OpFunctionEnd +)"; + + return s; +} + +TEST_F(ValidateMemory, CoopMatKHRLoadStoreSuccess) { + std::string spirv = GenCoopMatLoadStoreShaderKHR( + "MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); +} + +struct StrideMissingCase { + unsigned layout; + bool useLoadStride; + bool useStoreStride; +}; + +using ValidateCoopMatrixStrideMissing = + spvtest::ValidateBase; + +INSTANTIATE_TEST_SUITE_P( + CoopMatrixStrideMissing, ValidateCoopMatrixStrideMissing, + Values( + StrideMissingCase{(unsigned)spv::CooperativeMatrixLayout::RowMajorKHR, + false, true}, + StrideMissingCase{(unsigned)spv::CooperativeMatrixLayout::RowMajorKHR, + true, false}, + StrideMissingCase{ + (unsigned)spv::CooperativeMatrixLayout::ColumnMajorKHR, false, + true}, + StrideMissingCase{ + (unsigned)spv::CooperativeMatrixLayout::ColumnMajorKHR, true, + false})); + +TEST_P(ValidateCoopMatrixStrideMissing, CoopMatKHRLoadStrideMissingFail) { + const StrideMissingCase& param = GetParam(); + std::string spirv = GenCoopMatLoadStoreShaderKHR( + "MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR", param.layout, + false /*useSpecConstantLayout*/, param.useStoreStride, + param.useLoadStride); + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("MemoryLayout " + std::to_string(param.layout) + + " requires a Stride")); +} + +TEST_F(ValidateMemory, CoopMatKHRMemoryLayoutFromSpecConstantSuccess) { + std::string spirv = GenCoopMatLoadStoreShaderKHR( + "MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR", + (unsigned)spv::CooperativeMatrixLayout::RowMajorKHR, + true /*useSpecConstantLayout*/); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); +} + +TEST_F(ValidateMemory, CoopMatKHRStoreMemoryAccessFail) { + std::string spirv = GenCoopMatLoadStoreShaderKHR( + "MakePointerVisibleKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("MakePointerVisibleKHR cannot be used with OpStore")); +} + +TEST_F(ValidateMemory, CoopMatKHRLoadMemoryAccessFail) { + std::string spirv = GenCoopMatLoadStoreShaderKHR( + "MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerAvailableKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("MakePointerAvailableKHR cannot be used with OpLoad")); +} + +TEST_F(ValidateMemory, CoopMatKHRInvalidStorageClassFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A + +%str = OpTypeStruct %f16mat +%str_ptr = OpTypePointer Workgroup %str +%sh = OpVariable %str_ptr Workgroup + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Cooperative matrix types (or types containing them) can only be " + "allocated in Function or Private storage classes or as function " + "parameters")); +} + +TEST_F(ValidateMemory, CoopMatMatrixKHRLengthResultTypeBad) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 +%i32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%1 = OpCooperativeMatrixLengthKHR %i32 %f16mat + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The Result Type of OpCooperativeMatrixLengthKHR " + "'12[%12]' must be OpTypeInt with width 32 and signedness 0")); +} + +TEST_F(ValidateMemory, CoopMatMatrixKHRLengthOperandTypeBad) { + const std::string body = + R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 +%i32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%1 = OpCooperativeMatrixLengthKHR %u32 %u32 + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The type in OpCooperativeMatrixLengthKHR '5[%uint]' " + "must be OpTypeCooperativeMatrixKHR")); +} + +TEST_F(ValidateMemory, CoopMatMatrixKHRLengthGood) { + const std::string body = + R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 +%i32 = OpTypeInt 32 1 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %subgroup %u32_8 %u32_8 %use_A + +%main = OpFunction %void None %func +%main_entry = OpLabel + +%1 = OpCooperativeMatrixLengthKHR %u32 %f16mat + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + TEST_F(ValidateMemory, VulkanRTAOutsideOfStructBad) { std::string spirv = R"( OpCapability Shader @@ -2475,6 +2923,7 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft +OpDecorate %struct_t Block %uint_t = OpTypeInt 32 0 %array_t = OpTypeRuntimeArray %uint_t %struct_t = OpTypeStruct %array_t @@ -2498,7 +2947,7 @@ OpFunctionEnd "For Vulkan, OpTypeStruct variables containing OpTypeRuntimeArray " "must have storage class of StorageBuffer, PhysicalStorageBuffer, or " "Uniform.\n %6 = " - "OpVariable %_ptr_Workgroup__struct_4 Workgroup\n")); + "OpVariable %_ptr_Workgroup__struct_2 Workgroup\n")); } TEST_F(ValidateMemory, VulkanRTAInsideStorageBufferStructWithoutBlockBad) { @@ -2507,6 +2956,7 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft +OpDecorate %struct_t BufferBlock %uint_t = OpTypeInt 32 0 %array_t = OpTypeRuntimeArray %uint_t %struct_t = OpTypeStruct %array_t @@ -2529,7 +2979,7 @@ OpFunctionEnd "OpTypeRuntimeArray must be decorated with Block if it " "has storage class StorageBuffer or " "PhysicalStorageBuffer.\n %6 = OpVariable " - "%_ptr_StorageBuffer__struct_4 StorageBuffer\n")); + "%_ptr_StorageBuffer__struct_2 StorageBuffer\n")); } TEST_F(ValidateMemory, VulkanRTAInsideUniformStructGood) { @@ -2564,6 +3014,7 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft +OpDecorate %struct_t Block %uint_t = OpTypeInt 32 0 %array_t = OpTypeRuntimeArray %uint_t %struct_t = OpTypeStruct %array_t @@ -2585,7 +3036,7 @@ OpFunctionEnd HasSubstr("For Vulkan, an OpTypeStruct variable containing an " "OpTypeRuntimeArray must be decorated with BufferBlock " "if it has storage class Uniform.\n %6 = OpVariable " - "%_ptr_Uniform__struct_4 Uniform\n")); + "%_ptr_Uniform__struct_2 Uniform\n")); } TEST_F(ValidateMemory, VulkanRTAInsideRTABad) { @@ -2663,7 +3114,6 @@ OpExtension "SPV_EXT_descriptor_indexing" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft -OpDecorate %array_t ArrayStride 4 OpMemberDecorate %struct_t 0 Offset 0 OpDecorate %struct_t Block %uint_t = OpTypeInt 32 0 @@ -2909,7 +3359,6 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft OpDecorate %inner_array_t ArrayStride 4 -OpDecorate %array_t ArrayStride 4 OpMemberDecorate %struct_t 0 Offset 0 OpDecorate %struct_t Block %uint_t = OpTypeInt 32 0 @@ -2939,7 +3388,6 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %func "func" OpExecutionMode %func OriginUpperLeft OpDecorate %inner_array_t ArrayStride 4 -OpDecorate %array_t ArrayStride 4 OpMemberDecorate %struct_t 0 Offset 0 OpDecorate %struct_t Block %uint_t = OpTypeInt 32 0 @@ -3482,8 +3930,159 @@ OpMemoryModel Logical GLSL450 CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); EXPECT_THAT(getDiagnosticString(), - HasSubstr("Initializer type must match the type pointed to by " - "the Result Type")); + HasSubstr("Initializer type must match the data type")); +} + +TEST_F(ValidateMemory, StoreToImage) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%img = OpTypeImage %int 2D 2 0 0 2 R32i +%ptr_img = OpTypePointer Function %img +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_img Function +%value = OpLoad %img %var +OpStore %var %value +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06924")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR")); +} + +TEST_F(ValidateMemory, StoreToImageArray) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%img = OpTypeImage %int 2D 2 0 0 2 R32i +%arr_size = OpConstant %int 5 +%i = OpConstant %int 2 +%arr_img = OpTypeArray %img %arr_size +%ptr_img = OpTypePointer Function %img +%ptr_arr_img = OpTypePointer Function %arr_img +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_arr_img Function +%value = OpLoad %arr_img %var +OpStore %var %value +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06924")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR")); +} + +TEST_F(ValidateMemory, StoreToSampler) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%smp = OpTypeSampler +%ptr_smp = OpTypePointer Function %smp +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_smp Function +%value = OpLoad %smp %var +OpStore %var %value +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06924")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR")); +} + +TEST_F(ValidateMemory, StoreToSampledImage) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%img = OpTypeImage %int 2D 2 0 0 1 R32i +%samp_img = OpTypeSampledImage %img +%ptr_samp_img = OpTypePointer Function %samp_img +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_samp_img Function +%value = OpLoad %samp_img %var +OpStore %var %value +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06924")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR")); +} + +TEST_F(ValidateMemory, StoreToAccelarationStructureKHR) { + const std::string spirv = R"( +OpCapability Shader +OpCapability RayQueryKHR +OpExtension "SPV_KHR_ray_query" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%void = OpTypeVoid +%as = OpTypeAccelerationStructureKHR +%ptr_as = OpTypePointer Function %as +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%var = OpVariable %ptr_as Function +%value = OpLoad %as %var +OpStore %var %value +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-OpTypeImage-06924")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Cannot store to OpTypeImage, OpTypeSampler, " + "OpTypeSampledImage, or OpTypeAccelerationStructureKHR")); } TEST_F(ValidateMemory, StoreToUniformBlock) { @@ -3762,9 +4361,8 @@ OpFunctionEnd HasSubstr("In the Vulkan environment, cannot store to Uniform Blocks")); } -using ValidateSizedVariable = - spvtest::ValidateBase>; +using ValidateSizedVariable = spvtest::ValidateBase< + std::tuple>; CodeGenerator GetSizedVariableCodeGenerator(bool is_8bit, bool buffer_block) { CodeGenerator generator; @@ -3774,7 +4372,8 @@ CodeGenerator GetSizedVariableCodeGenerator(bool is_8bit, bool buffer_block) { "\"SPV_KHR_8bit_storage\"\n"; generator.memory_model_ = "OpMemoryModel Logical GLSL450\n"; if (is_8bit) { - generator.before_types_ = "OpMemberDecorate %char_buffer_block 0 Offset 0\n"; + generator.before_types_ = + "OpMemberDecorate %char_buffer_block 0 Offset 0\n"; if (buffer_block) generator.before_types_ += "OpDecorate %char_buffer_block BufferBlock\n"; @@ -4712,6 +5311,128 @@ OpFunctionEnd EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateMemory, UntypedVariableGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private %int %int_0 +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, UntypedVariableNoDataType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, UntypedVariableNoDataTypeFunction) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Function +%var = OpUntypedVariableKHR %ptr Function +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Data type must be specified for Function, " + "Private, and Workgroup storage classes")); +} + +TEST_F(ValidateMemory, UntypedVariableNoDataTypePrivate) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Data type must be specified for Function, " + "Private, and Workgroup storage classes")); +} + +TEST_F(ValidateMemory, UntypedVariableNoDataTypeWorkgroup) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Data type must be specified for Function, " + "Private, and Workgroup storage classes")); +} + +TEST_F(ValidateMemory, UntypedVariableNoDataTypeVulkan) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Vulkan requires that data type be specified")); +} + TEST_F(ValidateMemory, PtrAccessChainArrayStrideBad) { const std::string spirv = R"( OpCapability Shader @@ -4930,6 +5651,2651 @@ TEST_F(ValidateMemory, VulkanPtrAccessChainWorkgroupNoArrayStrideSuccess) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); } +TEST_F(ValidateMemory, AccessChainNegativeStructIndex32) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 1 +%_struct_4 = OpTypeStruct %int %int %int +%_ptr_Function__struct_4 = OpTypePointer Function %_struct_4 +%_ptr_Function_int = OpTypePointer Function %int +%int_n224 = OpConstant %int -224 +%fn = OpFunction %void Inline %void_fn +%entry = OpLabel +%var = OpVariable %_ptr_Function__struct_4 Function +%gep = OpInBoundsAccessChain %_ptr_Function_int %var %int_n224 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("is out of bounds")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("cannot find index -224")); +} + +TEST_F(ValidateMemory, AccessChainNegativeStructIndex64) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability Int64 +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 1 +%long = OpTypeInt 64 1 +%_struct_4 = OpTypeStruct %int %int %int +%_ptr_Function__struct_4 = OpTypePointer Function %_struct_4 +%_ptr_Function_int = OpTypePointer Function %int +%long_n224 = OpConstant %long -224 +%fn = OpFunction %void Inline %void_fn +%entry = OpLabel +%var = OpVariable %_ptr_Function__struct_4 Function +%gep = OpInBoundsAccessChain %_ptr_Function_int %var %long_n224 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("is out of bounds")); + EXPECT_THAT(getDiagnosticString(), HasSubstr("cannot find index -224")); +} + +TEST_F(ValidateMemory, UntypedVariableFunctionOutsideFunction) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Function +%var = OpUntypedVariableKHR %ptr Function %int +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Variables can not have a function[7] storage class " + "outside of a function")); +} + +TEST_F(ValidateMemory, UntypedVariableBadResultType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %int Workgroup %int +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Result type must be an untyped pointer")); +} + +TEST_F(ValidateMemory, UntypedVariableBadDataType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %int_0 +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Data type must be a type instruction")); +} + +TEST_F(ValidateMemory, UntypedVariableBadStorageClass) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability GenericPointer +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical OpenCL +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Generic +%var = OpUntypedVariableKHR %ptr Generic %int +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_BINARY, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Variable storage class cannot be Generic")); +} + +TEST_F(ValidateMemory, UntypedVariableMismatchedStorageClass) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Private %int +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Storage class must match result type storage class")); +} + +TEST_F(ValidateMemory, UntypedVariableBadInitializer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%int = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%ptr = OpTypeUntypedPointerKHR Private +%var = OpUntypedVariableKHR %ptr Private %int %float_0 +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Initializer type must match the data type")); +} + +TEST_F(ValidateMemory, AccessChainBaseUntypedPointer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %var "var" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%ptr_ssbo_int = OpTypePointer StorageBuffer %int +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_ssbo_int %var %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("The Base '2[%var]' in OpAccessChain " + "instruction must be a pointer")); +} + +using ValidateMemoryUntypedAccessChain = spvtest::ValidateBase; + +TEST_P(ValidateMemoryUntypedAccessChain, GoodTypedPointerBase) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %block %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateMemoryUntypedAccessChain, GoodUntypedPointerBase) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %block %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(ValidateMemoryUntypedAccessChain, ResultTypedPointer) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %gep "gep" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%ptr_int = OpTypePointer StorageBuffer %int +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr_int %block %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("The Result Type of " + opcode + + " '2[%gep]' must be OpTypeUntypedPointer")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, BaseTypeNotAType) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %gep "gep" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %int_0 %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Base type must be a non-pointer type")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, BaseTypedPointer) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %gep "gep" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %ptr_ssbo %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Base type must be a non-pointer type")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, BaseUntypedPointer) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %gep "gep" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %ptr %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Base type must be a non-pointer type")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, BaseNotAPointer) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %int_0 "int_0" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_ssbo = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_ssbo StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %int %int_0 )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("The Base '2[%int_0]' in " + opcode + + " instruction must be a pointer")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, StorageClassMismatch) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %int_0 "int_0" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_wg = OpTypePointer Workgroup %block +%var = OpVariable %ptr_wg Workgroup +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %block %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The result pointer storage class and base pointer storage " + "class in " + + opcode + " do not match")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, NonCompositeBase) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %int_0 "int_0" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_wg = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_wg StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %int %var )" + + extra_param + R"( %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr(opcode + " reached non-composite type while indexes " + "still remain to be traversed")); +} + +TEST_P(ValidateMemoryUntypedAccessChain, TooManyIndices) { + const std::string opcode = GetParam(); + const bool ptr = opcode == "OpUntypedPtrAccessChainKHR" || + opcode == "OpUntypedInBoundsPtrAccessChainKHR"; + const std::string extra_param = ptr ? "%int_0" : ""; + + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability VariablePointers +OpExtension "SPV_KHR_variable_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpName %int_0 "int_0" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%block = OpTypeStruct %int +%ptr_wg = OpTypePointer StorageBuffer %block +%var = OpVariable %ptr_wg StorageBuffer +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = )" + opcode + R"( %ptr %block %var )" + + extra_param + R"( %int_0 %int_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr(opcode + " reached non-composite type while indexes " + "still remain to be traversed")); +} + +INSTANTIATE_TEST_SUITE_P( + ValidateUntypedAccessChains, ValidateMemoryUntypedAccessChain, + Values("OpUntypedAccessChainKHR", "OpUntypedInBoundsAccessChainKHR", + "OpUntypedPtrAccessChainKHR", "OpUntypedInBoundsPtrAccessChainKHR")); + +TEST_F(ValidateMemory, LoadUntypedPointerGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%load = OpLoad %float %var +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, StoreUntypedPointerGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpStore %var %float_0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, CopyMemoryUntypedPointerSourceGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var1 %var2 +OpName %var1 "var1" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var1 = OpUntypedVariableKHR %ptr Workgroup %struct +%ptr_wg = OpTypePointer Workgroup %int +%var2 = OpVariable %ptr_wg Workgroup +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemory %var2 %var1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, CopyMemoryUntypedPointerTargetGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var1 %var2 +OpName %var1 "var1" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var1 = OpUntypedVariableKHR %ptr Workgroup %struct +%ptr_wg = OpTypePointer Workgroup %int +%var2 = OpVariable %ptr_wg Workgroup +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemory %var1 %var2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, CopyMemoryUntypedPointerTargetAndSourceBad) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var1 %var2 +OpName %var1 "var1" +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var1 = OpUntypedVariableKHR %ptr Workgroup %struct +%var2 = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemory %var1 %var2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("One of Source or Target must be a typed pointer")); +} + +TEST_F(ValidateMemory, CopyMemorySizedUntypedPointersGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %v1 %v2 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_4 = OpConstant %int 4 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%v1 = OpUntypedVariableKHR %ptr Workgroup %struct +%v2 = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemorySized %v2 %v1 %int_4 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, CopyMemorySizedUntypedPointersSizeBad1) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability StorageBuffer16BitAccess +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var_wg %var_ssbo +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%short = OpTypeInt 16 0 +%int_2 = OpConstant %int 2 +%struct = OpTypeStruct %int +%ptr_ssbo = OpTypeUntypedPointerKHR StorageBuffer +%ptr_wg = OpTypeUntypedPointerKHR Workgroup +%var_ssbo = OpUntypedVariableKHR %ptr_ssbo StorageBuffer %struct +%var_wg = OpUntypedVariableKHR %ptr_wg Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemorySized %var_ssbo %var_wg %int_2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 4")); +} + +TEST_F(ValidateMemory, CopyMemorySizedUntypedPointersSizeBad2) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability StorageBuffer16BitAccess +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var_ssbo %var_wg +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%short = OpTypeInt 16 0 +%int_2 = OpConstant %int 2 +%struct = OpTypeStruct %int +%ptr_ssbo = OpTypeUntypedPointerKHR StorageBuffer +%ptr_wg = OpTypeUntypedPointerKHR Workgroup +%var_ssbo = OpUntypedVariableKHR %ptr_ssbo StorageBuffer %struct +%var_wg = OpUntypedVariableKHR %ptr_wg Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemorySized %var_wg %var_ssbo %int_2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 4")); +} + +TEST_F(ValidateMemory, CopyMemorySizedUntypedPointersSizeBad3) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Int16 +OpCapability UntypedPointersKHR +OpCapability StorageBuffer8BitAccess +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_8bit_storage" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var_ssbo %var_wg +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%short = OpTypeInt 16 0 +%int_1 = OpConstant %int 1 +%struct = OpTypeStruct %int +%ptr_ssbo = OpTypeUntypedPointerKHR StorageBuffer +%ptr_wg = OpTypeUntypedPointerKHR Workgroup +%var_ssbo = OpUntypedVariableKHR %ptr_ssbo StorageBuffer %struct +%var_wg = OpUntypedVariableKHR %ptr_wg Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemorySized %var_ssbo %var_wg %int_1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 2")); +} + +TEST_F(ValidateMemory, CopyMemorySizedUntypedPointersSizeBad4) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Int16 +OpCapability UntypedPointersKHR +OpCapability StorageBuffer8BitAccess +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_8bit_storage" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var_ssbo %var_wg +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%short = OpTypeInt 16 0 +%int_1 = OpConstant %int 1 +%struct = OpTypeStruct %int +%ptr_ssbo = OpTypeUntypedPointerKHR StorageBuffer +%ptr_wg = OpTypeUntypedPointerKHR Workgroup +%var_ssbo = OpUntypedVariableKHR %ptr_ssbo StorageBuffer %struct +%var_wg = OpUntypedVariableKHR %ptr_wg Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpCopyMemorySized %var_wg %var_ssbo %int_1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 2")); +} + +TEST_F(ValidateMemory, PtrEqualUntypedPointersGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %v1 %v2 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%bool = OpTypeBool +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%v1 = OpUntypedVariableKHR %ptr Workgroup %struct +%v2 = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%res = OpPtrEqual %bool %v1 %v2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, PtrNotEqualUntypedPointersGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %v1 %v2 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%bool = OpTypeBool +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%v1 = OpUntypedVariableKHR %ptr Workgroup %struct +%v2 = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%res = OpPtrNotEqual %bool %v1 %v2 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, PtrDiffUntypedPointersGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %v1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%v1 = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%res = OpPtrDiff %int %v1 %v1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateMemory, UntypedVariableVulkanPushConstantGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR PushConstant +%var = OpUntypedVariableKHR %ptr PushConstant %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +TEST_F(ValidateMemory, UntypedVariableVulkanStorageBufferGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +TEST_F(ValidateMemory, UntypedVariableVulkanUniformGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Uniform +%var = OpUntypedVariableKHR %ptr Uniform %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +TEST_F(ValidateMemory, UntypedVariableVulkanWorkgroupGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%struct = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR Workgroup +%var = OpUntypedVariableKHR %ptr Workgroup %struct +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1_SPIRV_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); +} + +TEST_F(ValidateMemory, UntypedPointerAsVariableType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Linkage +OpCapability VariablePointers +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%float = OpTypeFloat 32 +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%priv_ptr = OpTypePointer Private %ptr +%var = OpVariable %priv_ptr Private +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateMemory, UntypedArrayLengthGood) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %int %block %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateMemory, UntypedArrayLengthBadResultType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%float = OpTypeFloat 32 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %float %block %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must be OpTypeInt with width 32 and signedness 0")); +} + +TEST_F(ValidateMemory, UntypedArrayLengthBadPointer) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%typed_ptr = OpTypePointer StorageBuffer %block +%var = OpVariable %typed_ptr StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %int %block %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Pointer must be an untyped pointer")); +} + +TEST_F(ValidateMemory, UntypedArrayLengtBadStruct) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %int %int %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), HasSubstr("to an OpTypeStruct")); +} + +TEST_F(ValidateMemory, UntypedArrayLengthLastMemberNotArray) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %int +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %int %block %var 0 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must be an OpTypeRuntimeArray")); +} + +TEST_F(ValidateMemory, UntypedArrayLengthBadIndex) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%array = OpTypeRuntimeArray %int +%block = OpTypeStruct %array +%ptr = OpTypeUntypedPointerKHR StorageBuffer +%var = OpUntypedVariableKHR %ptr StorageBuffer %block +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%length = OpUntypedArrayLengthKHR %int %block %var 1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must be the last member of the struct")); +} + +TEST_F(ValidateMemory, UntypedCooperativeMatrixLoad) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability CooperativeMatrixKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_cooperative_matrix" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%untyped = OpTypeUntypedPointerKHR StorageBuffer +%float = OpTypeFloat 32 +%array = OpTypeRuntimeArray %float +%block = OpTypeStruct %array +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%rows = OpSpecConstant %int 1 +%cols = OpSpecConstant %int 1 +%matrix_a = OpConstant %int 1 +%stride = OpConstant %int 42 +%matrix = OpTypeCooperativeMatrixKHR %float %subgroup %rows %cols %matrix_a +%var = OpUntypedVariableKHR %untyped StorageBuffer %block +%main = OpFunction %void None %void_fn +%entry = OpLabel +%ld = OpCooperativeMatrixLoadKHR %matrix %var %int_0 %stride +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateMemory, UntypedCooperativeMatrixLoad2) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability CooperativeMatrixKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_cooperative_matrix" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%untyped = OpTypeUntypedPointerKHR StorageBuffer +%float = OpTypeFloat 32 +%array = OpTypeRuntimeArray %float +%block = OpTypeStruct %array +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%rows = OpSpecConstant %int 1 +%cols = OpSpecConstant %int 1 +%matrix_a = OpConstant %int 1 +%stride = OpConstant %int 42 +%matrix = OpTypeCooperativeMatrixKHR %float %subgroup %rows %cols %matrix_a +%var = OpUntypedVariableKHR %untyped StorageBuffer %block +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpUntypedAccessChainKHR %untyped %block %var %int_0 %int_0 +%ld = OpCooperativeMatrixLoadKHR %matrix %gep %int_0 %stride +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateMemory, UntypedCooperativeMatrixStore) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability CooperativeMatrixKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_cooperative_matrix" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %main "main" %var1 %var2 +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var1 DescriptorSet 0 +OpDecorate %var1 Binding 0 +OpDecorate %var2 DescriptorSet 0 +OpDecorate %var2 Binding 1 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%untyped = OpTypeUntypedPointerKHR StorageBuffer +%float = OpTypeFloat 32 +%array = OpTypeRuntimeArray %float +%block = OpTypeStruct %array +%ptr = OpTypePointer StorageBuffer %block +%ptr_float = OpTypePointer StorageBuffer %float +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%rows = OpSpecConstant %int 1 +%cols = OpSpecConstant %int 1 +%matrix_a = OpConstant %int 1 +%stride = OpConstant %int 42 +%matrix = OpTypeCooperativeMatrixKHR %float %subgroup %rows %cols %matrix_a +%var1 = OpVariable %ptr StorageBuffer +%var2 = OpUntypedVariableKHR %untyped StorageBuffer %block +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_float %var1 %int_0 %int_0 +%ld = OpCooperativeMatrixLoadKHR %matrix %gep %int_0 %stride +OpCooperativeMatrixStoreKHR %var2 %ld %int_0 %stride +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +TEST_F(ValidateMemory, UntypedCooperativeMatrixStore2) { + const std::string spirv = R"( +OpCapability Shader +OpCapability UntypedPointersKHR +OpCapability CooperativeMatrixKHR +OpCapability VulkanMemoryModel +OpExtension "SPV_KHR_untyped_pointers" +OpExtension "SPV_KHR_cooperative_matrix" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %main "main" %var1 %var2 +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var1 DescriptorSet 0 +OpDecorate %var1 Binding 0 +OpDecorate %var2 DescriptorSet 0 +OpDecorate %var2 Binding 1 +OpDecorate %block Block +OpMemberDecorate %block 0 Offset 0 +OpDecorate %array ArrayStride 4 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%untyped = OpTypeUntypedPointerKHR StorageBuffer +%float = OpTypeFloat 32 +%array = OpTypeRuntimeArray %float +%block = OpTypeStruct %array +%ptr = OpTypePointer StorageBuffer %block +%ptr_float = OpTypePointer StorageBuffer %float +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%rows = OpSpecConstant %int 1 +%cols = OpSpecConstant %int 1 +%matrix_a = OpConstant %int 1 +%stride = OpConstant %int 42 +%matrix = OpTypeCooperativeMatrixKHR %float %subgroup %rows %cols %matrix_a +%var1 = OpVariable %ptr StorageBuffer +%var2 = OpUntypedVariableKHR %untyped StorageBuffer %block +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_float %var1 %int_0 %int_0 +%ld = OpCooperativeMatrixLoadKHR %matrix %gep %int_0 %stride +%gep2 = OpUntypedAccessChainKHR %untyped %block %var2 %int_0 %int_0 +OpCooperativeMatrixStoreKHR %gep2 %ld %int_0 %stride +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + +std::string GenCoopMat2Shader(const std::string& extra_types, + const std::string& main_body, + const std::string& after_main = "", + const std::string& extra_decorations = "") { + const std::string prefix = R"( +OpCapability Shader +OpCapability Float16 +OpCapability PhysicalStorageBufferAddresses +OpCapability VulkanMemoryModel +OpCapability CooperativeMatrixKHR +OpCapability TensorAddressingNV +OpCapability CooperativeMatrixTensorAddressingNV +OpCapability CooperativeMatrixBlockLoadsNV +OpExtension "SPV_KHR_physical_storage_buffer" +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_NV_tensor_addressing" +OpExtension "SPV_NV_cooperative_matrix2" +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical VulkanKHR +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 + +OpDecorate %f16_arr ArrayStride 2 +OpDecorate %46 Block +OpMemberDecorate %46 0 Offset 0 +OpDecorate %48 Binding 0 +OpDecorate %48 DescriptorSet 0 +OpDecorate %psb Restrict +)" + extra_decorations + R"( +%void = OpTypeVoid +%bool = OpTypeBool +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%f32 = OpTypeFloat 32 +%u32 = OpTypeInt 32 0 +%s32 = OpTypeInt 32 1 + +%s32_0 = OpConstant %s32 0 +%f16_0 = OpConstant %f16 0 +%u32_2 = OpConstant %u32 2 +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%workgroup = OpConstant %u32 2 +%subgroup = OpConstant %u32 3 + +%f16_arr = OpTypeRuntimeArray %f16 +%46 = OpTypeStruct %f16_arr +%47 = OpTypePointer StorageBuffer %46 +%48 = OpVariable %47 StorageBuffer +%51 = OpTypePointer StorageBuffer %f16_arr +%psbptr = OpTypePointer PhysicalStorageBuffer %f16_arr + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %workgroup %u32_8 %u32_8 %use_A +%f32mat = OpTypeCooperativeMatrixKHR %f32 %subgroup %u32_8 %u32_8 %use_A + +%arr2 = OpTypeArray %u32 %u32_2 +%functy = OpTypeFunction %f16 %psbptr %arr2 %arr2 +)"; + + const std::string decode_func = + R"( +%decodefunc = OpFunction %f16 None %functy +%psb = OpFunctionParameter %psbptr +%c0 = OpFunctionParameter %arr2 +%c1 = OpFunctionParameter %arr2 +%entry2 = OpLabel +OpReturnValue %f16_0 +OpFunctionEnd +)"; + + const std::string func_begin = + R"( +%main = OpFunction %void None %func +%main_entry = OpLabel + +%array_ptr = OpAccessChain %51 %48 %s32_0 +)"; + + const std::string suffix = + R"( +OpReturn +OpFunctionEnd)"; + + return prefix + extra_types + func_begin + main_body + suffix + decode_func + + after_main; +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutAndViewSuccess) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutInvalidDimFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 6 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be between 1 and 5")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutInvalidClampFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 6 + %dim = OpConstant %u32 2 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("must be a valid TensorClampMode")); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewInvalidDimFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 6 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be between 1 and 5")); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewInvalidPermutationFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p1 + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Permutation values don't form a valid permutation")); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewInvalidPermutation2Fail) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Incorrect number of permutation values.")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutBlockSizePass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetBlockSizeNV %layout %tl %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutBlockSizeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetBlockSizeNV %layout %tl %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutDimensionPass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetDimensionNV %layout %tl %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutDimensionFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetDimensionNV %layout %tl %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutStridePass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetStrideNV %layout %tl %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutStrideFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetStrideNV %layout %tl %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutSlicePass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSliceNV %layout %tl %b %b %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutSliceFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSliceNV %layout %tl %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorLayoutSetClampValuePass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 3 + %b = OpConstant %u32 1 + %layout = OpTypeTensorLayoutNV %dim %clamp + )", + R"( + %tl = OpCreateTensorLayoutNV %layout + %tl2 = OpTensorLayoutSetClampValueNV %layout %tl %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewDimensionPass) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %hasdim = OpConstantFalse %bool + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %p2 = OpConstant %u32 2 + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p2 + %b = OpConstant %u32 1 + )", + R"( + %tv = OpCreateTensorViewNV %view + %tv2 = OpTensorViewSetDimensionNV %view %tv %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewDimensionFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %hasdim = OpConstantFalse %bool + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %p2 = OpConstant %u32 2 + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p2 + %b = OpConstant %u32 1 + )", + R"( + %tv = OpCreateTensorViewNV %view + %tv2 = OpTensorViewSetDimensionNV %view %tv %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewStridePass) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %hasdim = OpConstantFalse %bool + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %p2 = OpConstant %u32 2 + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p2 + %b = OpConstant %u32 1 + )", + R"( + %tv = OpCreateTensorViewNV %view + %tv2 = OpTensorViewSetStrideNV %view %tv %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewStrideFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %hasdim = OpConstantFalse %bool + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %p2 = OpConstant %u32 2 + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p2 + %b = OpConstant %u32 1 + )", + R"( + %tv = OpCreateTensorViewNV %view + %tv2 = OpTensorViewSetStrideNV %view %tv %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("unexpected number of operands")); +} + +TEST_F(ValidateMemory, CoopMat2TensorViewClipPass) { + std::string spirv = GenCoopMat2Shader( + R"( + %dim = OpConstant %u32 3 + %hasdim = OpConstantFalse %bool + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %p2 = OpConstant %u32 2 + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 %p2 + %b = OpConstant %u32 1 + )", + R"( + %tv = OpCreateTensorViewNV %view + %tv2 = OpTensorViewSetClipNV %view %tv %b %b %b %b + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2LoadStoreTensorPass) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + %mat = OpUndef %f16mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None None + %mat3 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl Aligned 4 None + %mat4 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None TensorView %tv + %mat5 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None DecodeFunc %decodefunc + %mat6 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None TensorView|DecodeFunc %tv %decodefunc + %mat7 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl Aligned 4 TensorView|DecodeFunc %tv %decodefunc + OpCooperativeMatrixStoreTensorNV %array_ptr %mat %tl None None + OpCooperativeMatrixStoreTensorNV %array_ptr %mat %tl Aligned 4 None + OpCooperativeMatrixStoreTensorNV %array_ptr %mat %tl None TensorView %tv + OpCooperativeMatrixStoreTensorNV %array_ptr %mat %tl Aligned 4 TensorView %tv + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMemory, CoopMat2LoadTensorWrongLayoutTypeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + %mat = OpUndef %f16mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tv None None + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("does not have a tensor layout type")); +} + +TEST_F(ValidateMemory, CoopMat2LoadTensorWrongObjectTypeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + %mat = OpUndef %f32mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None None + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("type does not match Result Type")); +} + +TEST_F(ValidateMemory, CoopMat2LoadTensorDecodeFuncTypeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + )", + R"( + %mat = OpUndef %f32mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f32mat %array_ptr %mat %tl None DecodeFunc %decodefunc + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("return type must match matrix component type")); +} + +TEST_F(ValidateMemory, CoopMat2LoadTensorDecodeFuncArrayTypeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %u32_3 = OpConstant %u32 3 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + %arr3 = OpTypeArray %u32 %u32_3 + %functy2 = OpTypeFunction %f16 %psbptr %arr3 %arr3 + )", + R"( + %mat = OpUndef %f16mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None DecodeFunc %decodefunc2 + )", + R"( + %decodefunc2 = OpFunction %f16 None %functy2 + %psb2 = OpFunctionParameter %psbptr + %c02 = OpFunctionParameter %arr3 + %c12 = OpFunctionParameter %arr3 + %entry3 = OpLabel + OpReturnValue %f16_0 + OpFunctionEnd + )", + R"( + OpDecorate %psb2 Restrict + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("dimension equal to the tensor dimension")); +} + +TEST_F(ValidateMemory, CoopMat2LoadTensorDecodeFuncPointerTypeFail) { + std::string spirv = GenCoopMat2Shader( + R"( + %clamp = OpConstant %u32 0 + %dim = OpConstant %u32 2 + %p0 = OpConstant %u32 0 + %p1 = OpConstant %u32 1 + %hasdim = OpConstantFalse %bool + %layout = OpTypeTensorLayoutNV %dim %clamp + %view = OpTypeTensorViewNV %dim %hasdim %p0 %p1 + %sbptr = OpTypePointer StorageBuffer %f16_arr + %functy2 = OpTypeFunction %f16 %sbptr %arr2 %arr2 + )", + R"( + %mat = OpUndef %f16mat + %tl = OpCreateTensorLayoutNV %layout + %tv = OpCreateTensorViewNV %view + %mat2 = OpCooperativeMatrixLoadTensorNV %f16mat %array_ptr %mat %tl None DecodeFunc %decodefunc2 + )", + R"( + %decodefunc2 = OpFunction %f16 None %functy2 + %sb = OpFunctionParameter %sbptr + %c02 = OpFunctionParameter %arr2 + %c12 = OpFunctionParameter %arr2 + %entry3 = OpLabel + OpReturnValue %f16_0 + OpFunctionEnd + )"); + + CompileSuccessfully(spirv.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("first parameter must be pointer to PhysicalStorageBuffer")); +} + +TEST_F(ValidateMemory, PtrAccessChainNodePayloadArray) { + const std::string spirv = R"( +OpCapability Shader +OpCapability ShaderEnqueueAMDX +OpExtension "SPV_AMDX_shader_enqueue" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %input +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%node0 = OpConstantStringAMDX "node0" +%node1 = OpConstantStringAMDX "node1" +%node2 = OpConstantStringAMDX "node2" +%S = OpTypeStruct %uint +%_payloadarr_S = OpTypeNodePayloadArrayAMDX %S +%_ptr_NodePayloadAMDX__payloadarr_S = OpTypePointer NodePayloadAMDX %_payloadarr_S +%_ptr_NodePayloadAMDX_uint = OpTypePointer NodePayloadAMDX %uint +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%input = OpVariable %_ptr_NodePayloadAMDX__payloadarr_S NodePayloadAMDX +%main = OpFunction %void None %void_fn +%entry = OpLabel +%x = OpAccessChain %_ptr_NodePayloadAMDX_uint %input %uint_0 %uint_0 +OpReturn +OpFunctionEnd +)"; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_4; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); +} + +std::string GenCoopVecLoadStoreShader(const std::string& storeMemoryAccess, + const std::string& loadMemoryAccess) { + std::string s = R"( +OpCapability Shader +OpCapability Float16 +OpCapability StorageBuffer16BitAccess +OpCapability VulkanMemoryModel +OpCapability CooperativeVectorNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_EXT_replicated_composites" +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_NV_cooperative_vector" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %4 "main" %48 %73 +OpExecutionMode %4 LocalSize 1 1 1 + +OpDecorate %45 ArrayStride 2 +OpDecorate %46 Block +OpMemberDecorate %46 0 Offset 0 +OpDecorate %48 Binding 0 +OpDecorate %48 DescriptorSet 0 + +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeInt 32 0 +%49 = OpTypeInt 32 1 +%41 = OpTypeFloat 16 + +%14 = OpConstant %6 1 +%50 = OpConstant %49 0 +%82 = OpConstant %6 5 + +%42 = OpTypeCooperativeVectorNV %41 %14 +%43 = OpTypePointer Function %42 + +%45 = OpTypeRuntimeArray %41 +%46 = OpTypeStruct %45 +%47 = OpTypePointer StorageBuffer %46 +%48 = OpVariable %47 StorageBuffer +%51 = OpTypePointer StorageBuffer %45 + +%57 = OpTypePointer Private %42 +%73 = OpVariable %57 Private + +%4 = OpFunction %2 None %3 +%5 = OpLabel +%52 = OpAccessChain %51 %48 %50 +%56 = OpCooperativeVectorLoadNV %42 %52 %50 )" + + loadMemoryAccess + R"( %82 +%77 = OpLoad %42 %73 +OpCooperativeVectorStoreNV %52 %50 %77 )" + storeMemoryAccess + R"( %82 +OpReturn +OpFunctionEnd +)"; + + return s; +} + +TEST_F(ValidateMemory, CoopVecLoadStoreSuccess) { + std::string spirv = + GenCoopVecLoadStoreShader("MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); +} + +TEST_F(ValidateMemory, CoopVecStoreMemoryAccessFail) { + std::string spirv = + GenCoopVecLoadStoreShader("MakePointerVisibleKHR|NonPrivatePointerKHR", + "MakePointerVisibleKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("MakePointerVisibleKHR cannot be used with OpStore")); +} + +TEST_F(ValidateMemory, CoopVecLoadMemoryAccessFail) { + std::string spirv = + GenCoopVecLoadStoreShader("MakePointerAvailableKHR|NonPrivatePointerKHR", + "MakePointerAvailableKHR|NonPrivatePointerKHR"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("MakePointerAvailableKHR cannot be used with OpLoad")); +} + +TEST_F(ValidateMemory, CoopVecInvalidStorageClassFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability CooperativeVectorNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_NV_cooperative_vector" +OpExtension "SPV_EXT_replicated_composites" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 + +%u32_8 = OpConstant %u32 8 +%use_A = OpConstant %u32 0 +%subgroup = OpConstant %u32 3 + +%f16vec = OpTypeCooperativeVectorNV %f16 %u32_8 + +%str = OpTypeStruct %f16vec +%str_ptr = OpTypePointer Workgroup %str +%sh = OpVariable %str_ptr Workgroup + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str()); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Cooperative vector types (or types containing them) can only be " + "allocated in Function or Private storage classes or as function " + "parameters")); +} + +std::string GenCoopVecShader(const std::string& extra_types, + const std::string& main_body) { + const std::string prefix = + R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int64 +OpCapability StorageBuffer16BitAccess +OpCapability VulkanMemoryModel +OpCapability CooperativeVectorNV +OpCapability CooperativeVectorTrainingNV +OpCapability ReplicatedCompositesEXT +OpExtension "SPV_EXT_replicated_composites" +OpExtension "SPV_KHR_vulkan_memory_model" +OpExtension "SPV_NV_cooperative_vector" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical Vulkan +OpEntryPoint GLCompute %main "main" %48 %73 +OpExecutionMode %main LocalSize 1 1 1 + +OpDecorate %f16_arr ArrayStride 2 +OpDecorate %46 Block +OpMemberDecorate %46 0 Offset 0 +OpDecorate %48 Binding 0 +OpDecorate %48 DescriptorSet 0 + +%void = OpTypeVoid +%func = OpTypeFunction %void +%u32 = OpTypeInt 32 0 +%s32 = OpTypeInt 32 1 +%f16 = OpTypeFloat 16 +%bool = OpTypeBool + +%false = OpConstantFalse %bool +%u32_4 = OpConstant %u32 4 +%u32_8 = OpConstant %u32 8 +%s32_0 = OpConstant %s32 0 +%f16_0 = OpConstant %f16 0 + +%f16vec4 = OpTypeCooperativeVectorNV %f16 %u32_4 +%f16vec8 = OpTypeCooperativeVectorNV %f16 %u32_8 + +%f16_arr = OpTypeRuntimeArray %f16 +%46 = OpTypeStruct %f16_arr +%47 = OpTypePointer StorageBuffer %46 +%48 = OpVariable %47 StorageBuffer +%51 = OpTypePointer StorageBuffer %f16_arr + +%57 = OpTypePointer Private %f16vec4 +%73 = OpVariable %57 Private +%u32ptr = OpTypePointer Function %u32 + +%input4 = OpConstantCompositeReplicateEXT %f16vec4 %f16_0 +%input8 = OpConstantCompositeReplicateEXT %f16vec8 %f16_0 +%interp = OpConstant %u32 0 +%offset = OpConstant %u32 0 + +)"; + + const std::string func_begin = + R"( +%main = OpFunction %void None %func +%main_entry = OpLabel +%u32var = OpVariable %u32ptr Function +%array_ptr = OpAccessChain %51 %48 %s32_0 +)"; + + const std::string suffix = + R"( +OpReturn +OpFunctionEnd)"; + + return prefix + extra_types + func_begin + main_body + suffix; +} + +TEST_F(ValidateMemory, CoopVecMatMulSuccess) { + std::string spirv = GenCoopVecShader("", + R"( +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false +%result1 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input8 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_8 %s32_0 %false +%result2 = OpCooperativeVectorMatrixMulAddNV %f16vec8 %input4 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_8 %u32_4 %s32_0 %false +%result3 = OpCooperativeVectorMatrixMulNV %f16vec4 %input4 %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false +%result4 = OpCooperativeVectorMatrixMulNV %f16vec4 %input8 %interp %array_ptr %offset %interp %u32_4 %u32_8 %s32_0 %false +%result5 = OpCooperativeVectorMatrixMulNV %f16vec8 %input4 %interp %array_ptr %offset %interp %u32_8 %u32_4 %s32_0 %false + +OpCooperativeVectorReduceSumAccumulateNV %array_ptr %offset %input4 +OpCooperativeVectorOuterProductAccumulateNV %array_ptr %offset %input4 %input8 %interp %interp + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); +} + +TEST_F(ValidateMemory, CoopVecMatMulKMismatchFail) { + std::string spirv = GenCoopVecShader(R"()", + R"( +%result1 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input8 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV input number of " + "components 8 does not match K 4")); +} + +TEST_F(ValidateMemory, CoopVecMatMulPackedKMismatchPass) { + std::string spirv = GenCoopVecShader( + R"( +%packed = OpConstant %u32 1000491001 + )", + R"( +%result1 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input8 %packed %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); +} + +TEST_F(ValidateMemory, CoopVecMatMulMMismatchFail) { + std::string spirv = GenCoopVecShader(R"()", + R"( +%result1 = OpCooperativeVectorMatrixMulAddNV %f16vec8 %input8 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_8 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV result type number " + "of components 8 does not match M 4")); +} + +TEST_F(ValidateMemory, CoopVecMatMulTransposeTypeFail) { + std::string spirv = GenCoopVecShader(R"()", + R"( +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %interp %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %s32_0 + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV Transpose " + "'16[%int_0]' is not a scalar boolean")); +} + +TEST_F(ValidateMemory, CoopVecMatMulInputInterpretationNotConstantFail) { + std::string spirv = GenCoopVecShader( + R"( + )", + R"( +%u32val = OpLoad %u32 %u32var +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %u32val %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV InputInterpretation " + " '31[%31]' is not a constant instruction")); +} + +TEST_F(ValidateMemory, CoopVecMatMulMatrixInterpretationNotConstantFail) { + std::string spirv = GenCoopVecShader( + R"( + )", + R"( +%u32val = OpLoad %u32 %u32var +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %interp %array_ptr %offset %u32val %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV MatrixInterpretation " + "'31[%31]' is not a constant instruction")); +} + +TEST_F(ValidateMemory, CoopVecMatMulBiasInterpretationNotConstantFail) { + std::string spirv = GenCoopVecShader( + R"( + )", + R"( +%u32val = OpLoad %u32 %u32var +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %interp %array_ptr %offset %interp %array_ptr %offset %u32val %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV BiasInterpretation " + " '31[%31]' is not a constant instruction")); +} + +TEST_F(ValidateMemory, CoopVecMatMulInputInterpretationNotInt32Fail) { + std::string spirv = GenCoopVecShader( + R"( + )", + R"( +%result0 = OpCooperativeVectorMatrixMulAddNV %f16vec4 %input4 %false %array_ptr %offset %interp %array_ptr %offset %interp %u32_4 %u32_4 %s32_0 %false + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorMatrixMulAddNV InputInterpretation " + "type '12[%bool]' is not a 32 bit integer")); +} + +TEST_F(ValidateMemory, CoopVecOuterProductABMismatchFail) { + std::string spirv = GenCoopVecShader( + R"( +%f32 = OpTypeFloat 32 +%f32vec8 = OpTypeCooperativeVectorNV %f32 %u32_8 +%f32_0 = OpConstant %f32 0 +%input8f32 = OpConstantCompositeReplicateEXT %f32vec8 %f32_0 + )", + R"( +OpCooperativeVectorOuterProductAccumulateNV %array_ptr %offset %input4 %input8f32 %interp %interp + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpCooperativeVectorOuterProductAccumulateNV A and B component " + "types '11[%half]' and '28[%float]' do not match")); +} + +TEST_F(ValidateMemory, CoopVecOuterProductInt32OffsetFail) { + std::string spirv = GenCoopVecShader( + R"( +%u64 = OpTypeInt 64 0 +%u64_0 = OpConstant %u64 0 + )", + R"( +OpCooperativeVectorOuterProductAccumulateNV %array_ptr %u64_0 %input4 %input8 %interp %interp + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorOuterProductAccumulateNV Offset " + "type '28[%ulong]' is not a 32 bit integer")); +} + +TEST_F(ValidateMemory, CoopVecOuterProductInt32MatrixStrideFail) { + std::string spirv = GenCoopVecShader( + R"( +%u64 = OpTypeInt 64 0 +%u64_0 = OpConstant %u64 0 + )", + R"( +OpCooperativeVectorOuterProductAccumulateNV %array_ptr %offset %input4 %input8 %interp %interp %u64_0 + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpCooperativeVectorOuterProductAccumulateNV MatrixStride type " + " '28[%ulong]' is not a 32 bit integer")); +} + +TEST_F(ValidateMemory, CoopVecOuterProductVectorTypeFail) { + std::string spirv = GenCoopVecShader( + R"( +%f16v4 = OpTypeVector %f16 4 +%f16c = OpConstantCompositeReplicateEXT %f16v4 %f16_0 + )", + R"( +OpCooperativeVectorOuterProductAccumulateNV %array_ptr %offset %f16c %input8 %interp %interp + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorOuterProductAccumulateNV A type " + " '28[%v4half]' is not a cooperative vector type")); +} + +TEST_F(ValidateMemory, CoopVecReduceSumInt32OffsetFail) { + std::string spirv = GenCoopVecShader( + R"( +%u64 = OpTypeInt 64 0 +%u64_0 = OpConstant %u64 0 + )", + R"( +OpCooperativeVectorReduceSumAccumulateNV %array_ptr %u64_0 %input4 + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorReduceSumAccumulateNV Offset type " + " '28[%ulong]' is not a 32 bit integer")); +} + +TEST_F(ValidateMemory, CoopVecReduceSumVectorTypeFail) { + std::string spirv = GenCoopVecShader( + R"( +%f16v4 = OpTypeVector %f16 4 +%f16c = OpConstantCompositeReplicateEXT %f16v4 %f16_0 + )", + R"( +OpCooperativeVectorReduceSumAccumulateNV %array_ptr %offset %f16c + )"); + + CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_1_SPIRV_1_4); + ASSERT_EQ(SPV_ERROR_INVALID_ID, + ValidateInstructions(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpCooperativeVectorReduceSumAccumulateNV V type " + "'28[%v4half]' is not a cooperative vector type.")); +} } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_mesh_shading_test.cpp b/third_party/spirv-tools/test/val/val_mesh_shading_test.cpp index ce6999dcb6..75937194d4 100644 --- a/third_party/spirv-tools/test/val/val_mesh_shading_test.cpp +++ b/third_party/spirv-tools/test/val/val_mesh_shading_test.cpp @@ -14,7 +14,6 @@ // Tests instructions from SPV_EXT_mesh_shader -#include #include #include "gmock/gmock.h" @@ -468,6 +467,79 @@ TEST_F(ValidateMeshShading, TaskPayloadWorkgroupBadExecutionModel) { "TaskEXT and MeshKHR execution model")); } +TEST_F(ValidateMeshShading, BadMultipleTaskPayloadWorkgroupEXT) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint TaskEXT %main "main" %payload %payload1 + %void = OpTypeVoid + %func = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_TaskPayloadWorkgroupEXT = OpTypePointer TaskPayloadWorkgroupEXT %uint + %payload = OpVariable %_ptr_TaskPayloadWorkgroupEXT TaskPayloadWorkgroupEXT + %payload1 = OpVariable %_ptr_TaskPayloadWorkgroupEXT TaskPayloadWorkgroupEXT + %main = OpFunction %void None %func + %label = OpLabel + %load = OpLoad %uint %payload + OpReturn + OpFunctionEnd +)"; + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("There can be at most one OpVariable with storage " + "class TaskPayloadWorkgroupEXT associated with " + "an OpEntryPoint")); +} + +TEST_F(ValidateMeshShading, TaskPayloadWorkgroupTaskExtExecutionModel) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint TaskEXT %main "main" %payload + %void = OpTypeVoid + %func = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_TaskPayloadWorkgroupEXT = OpTypePointer TaskPayloadWorkgroupEXT %uint + %payload = OpVariable %_ptr_TaskPayloadWorkgroupEXT TaskPayloadWorkgroupEXT + %main = OpFunction %void None %func + %label = OpLabel + %load = OpLoad %uint %payload + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + +TEST_F(ValidateMeshShading, TaskPayloadWorkgroupMeshExtExecutionModel) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %payload + OpExecutionMode %main OutputVertices 1 + OpExecutionMode %main OutputPrimitivesEXT 1 + OpExecutionMode %main OutputTrianglesEXT + %void = OpTypeVoid + %func = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_TaskPayloadWorkgroupEXT = OpTypePointer TaskPayloadWorkgroupEXT %uint + %payload = OpVariable %_ptr_TaskPayloadWorkgroupEXT TaskPayloadWorkgroupEXT + %main = OpFunction %void None %func + %label = OpLabel + %load = OpLoad %uint %payload + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + TEST_F(ValidateMeshShading, OpSetMeshOutputsBadVertexCount) { const std::string body = R"( OpCapability MeshShadingEXT @@ -599,6 +671,317 @@ TEST_F(ValidateMeshShading, OpEmitMeshTasksZeroSuccess) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); } +TEST_F(ValidateMeshShading, BadPerPrimitiveEXTStorageClassInMeshEXT) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationID %blk %triangleNormal + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesNV 32 + OpExecutionMode %main OutputTrianglesNV + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %iid "iid" + OpName %gl_LocalInvocationID "gl_LocalInvocationID" + OpName %myblock "myblock" + OpMemberName %myblock 0 "f" + OpName %blk "blk" + OpName %triangleNormal "triangleNormal" + OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId + OpMemberDecorate %myblock 0 PerPrimitiveEXT + OpDecorate %myblock Block + OpDecorate %blk Location 0 + OpDecorate %triangleNormal PerPrimitiveEXT + OpDecorate %triangleNormal Location 0 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint + %float = OpTypeFloat 32 + %myblock = OpTypeStruct %float + %uint_32 = OpConstant %uint 32 +%_arr_myblock_uint_32 = OpTypeArray %myblock %uint_32 +%_ptr_Output__arr_myblock_uint_32 = OpTypePointer Output %_arr_myblock_uint_32 + %blk = OpVariable %_ptr_Output__arr_myblock_uint_32 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_11 = OpConstant %float 11 +%_ptr_Output_float = OpTypePointer Output %float + %v3float = OpTypeVector %float 3 +%_arr_v3float_uint_32 = OpTypeArray %v3float %uint_32 +%_ptr_Output__arr_v3float_uint_32 = OpTypePointer Input %_arr_v3float_uint_32 +%triangleNormal = OpVariable %_ptr_Output__arr_v3float_uint_32 Input + %33 = OpConstantComposite %v3float %float_11 %float_11 %float_11 +%_ptr_Output_v3float = OpTypePointer Output %v3float + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %iid = OpVariable %_ptr_Function_uint Function + %14 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0 + %15 = OpLoad %uint %14 + OpStore %iid %15 + %22 = OpLoad %uint %iid + %27 = OpAccessChain %_ptr_Output_float %blk %22 %int_0 + OpStore %27 %float_11 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("PerPrimitiveEXT decoration must be applied only to " + "variables in the Output Storage Class in the Storage " + "Class in the MeshEXT Execution Model.")); +} + +TEST_F(ValidateMeshShading, VulkanPerPrimitiveEXTStorageClassInMeshEXT) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationID %blk %triangleNormal + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesNV 32 + OpExecutionMode %main OutputTrianglesNV + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %iid "iid" + OpName %gl_LocalInvocationID "gl_LocalInvocationID" + OpName %myblock "myblock" + OpMemberName %myblock 0 "f" + OpName %blk "blk" + OpName %triangleNormal "triangleNormal" + OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId + OpMemberDecorate %myblock 0 PerPrimitiveEXT + OpDecorate %myblock Block + OpDecorate %blk Location 0 + OpDecorate %triangleNormal PerPrimitiveEXT + OpDecorate %triangleNormal Location 0 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid + %3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint +%v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input +%uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%float = OpTypeFloat 32 +%myblock = OpTypeStruct %float +%uint_32 = OpConstant %uint 32 +%_arr_myblock_uint_32 = OpTypeArray %myblock %uint_32 +%_ptr_Output__arr_myblock_uint_32 = OpTypePointer Output %_arr_myblock_uint_32 +%blk = OpVariable %_ptr_Output__arr_myblock_uint_32 Output +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 +%float_11 = OpConstant %float 11 +%_ptr_Output_float = OpTypePointer Output %float +%v3float = OpTypeVector %float 3 +%_arr_v3float_uint_32 = OpTypeArray %v3float %uint_32 +%_ptr_Output__arr_v3float_uint_32 = OpTypePointer Input %_arr_v3float_uint_32 +%triangleNormal = OpVariable %_ptr_Output__arr_v3float_uint_32 Input +%33 = OpConstantComposite %v3float %float_11 %float_11 %float_11 +%_ptr_Output_v3float = OpTypePointer Output %v3float +%uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 +%main = OpFunction %void None %3 + %5 = OpLabel +%iid = OpVariable %_ptr_Function_uint Function +%14 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0 +%15 = OpLoad %uint %14 + OpStore %iid %15 +%22 = OpLoad %uint %iid +%27 = OpAccessChain %_ptr_Output_float %blk %22 %int_0 + OpStore %27 %float_11 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-PrimitiveId-PrimitiveId-04336")); +} + +TEST_F(ValidateMeshShading, BadPerPrimitiveEXTStorageClassInFrag) { + const std::string body = R"( + OpCapability Shader + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %triangleNormal + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %triangleNormal "triangleNormal" + OpDecorate %triangleNormal PerPrimitiveNV + OpDecorate %triangleNormal Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 +%_arr_v3float_uint_3 = OpTypeArray %v3float %uint_3 +%_ptr_Input__arr_v3float_uint_3 = OpTypePointer Output %_arr_v3float_uint_3 +%triangleNormal = OpVariable %_ptr_Input__arr_v3float_uint_3 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_v3float = OpTypePointer Input %v3float + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpAccessChain %_ptr_Input_v3float %triangleNormal %int_0 + %19 = OpLoad %v3float %18 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("PerPrimitiveEXT decoration must be applied only to " + "variables in the Input Storage Class in the Fragment " + "Execution Model.")); +} + +TEST_F(ValidateMeshShading, PerPrimitiveEXTStorageClassInFrag) { + const std::string body = R"( + OpCapability Shader + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %res3 %triangleNormal + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %res3 "res3" + OpName %triangleNormal "triangleNormal" + OpDecorate %res3 Location 0 + OpDecorate %triangleNormal PerPrimitiveNV + OpDecorate %triangleNormal Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %_ptr_Output_v3float = OpTypePointer Output %v3float + %res3 = OpVariable %_ptr_Output_v3float Output + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %_arr_v3float_uint_3 = OpTypeArray %v3float %uint_3 + %_ptr_Input__arr_v3float_uint_3 = OpTypePointer Input %_arr_v3float_uint_3 + %triangleNormal = OpVariable %_ptr_Input__arr_v3float_uint_3 Input + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %_ptr_Input_v3float = OpTypePointer Input %v3float + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpAccessChain %_ptr_Input_v3float %triangleNormal %int_0 + %19 = OpLoad %v3float %18 + OpStore %res3 %19 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + +TEST_F(ValidateMeshShading, PerPrimitiveEXTStorageClassInMeshEXT) { + const std::string body = R"( + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationID %blk %triangleNormal + OpExecutionMode %main LocalSize 32 1 1 + OpExecutionMode %main OutputVertices 81 + OpExecutionMode %main OutputPrimitivesNV 32 + OpExecutionMode %main OutputTrianglesNV + OpSource GLSL 450 + OpSourceExtension "GL_EXT_mesh_shader" + OpName %main "main" + OpName %iid "iid" + OpName %gl_LocalInvocationID "gl_LocalInvocationID" + OpName %myblock "myblock" + OpMemberName %myblock 0 "f" + OpName %blk "blk" + OpName %triangleNormal "triangleNormal" + OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId + OpMemberDecorate %myblock 0 PerPrimitiveNV + OpDecorate %myblock Block + OpDecorate %blk Location 0 + OpDecorate %triangleNormal PerPrimitiveNV + OpDecorate %triangleNormal Location 0 + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_Function_uint = OpTypePointer Function %uint + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint + %float = OpTypeFloat 32 + %myblock = OpTypeStruct %float + %uint_32 = OpConstant %uint 32 +%_arr_myblock_uint_32 = OpTypeArray %myblock %uint_32 +%_ptr_Output__arr_myblock_uint_32 = OpTypePointer Output %_arr_myblock_uint_32 + %blk = OpVariable %_ptr_Output__arr_myblock_uint_32 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_11 = OpConstant %float 11 +%_ptr_Output_float = OpTypePointer Output %float + %v3float = OpTypeVector %float 3 +%_arr_v3float_uint_32 = OpTypeArray %v3float %uint_32 +%_ptr_Output__arr_v3float_uint_32 = OpTypePointer Output %_arr_v3float_uint_32 +%triangleNormal = OpVariable %_ptr_Output__arr_v3float_uint_32 Output + %33 = OpConstantComposite %v3float %float_11 %float_11 %float_11 +%_ptr_Output_v3float = OpTypePointer Output %v3float + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %iid = OpVariable %_ptr_Function_uint Function + %14 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0 + %15 = OpLoad %uint %14 + OpStore %iid %15 + %22 = OpLoad %uint %iid + %27 = OpAccessChain %_ptr_Output_float %blk %22 %int_0 + OpStore %27 %float_11 + %32 = OpLoad %uint %iid + %35 = OpAccessChain %_ptr_Output_v3float %triangleNormal %32 + OpStore %35 %33 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_misc_test.cpp b/third_party/spirv-tools/test/val/val_misc_test.cpp index b0e46bf95c..2188e037c4 100644 --- a/third_party/spirv-tools/test/val/val_misc_test.cpp +++ b/third_party/spirv-tools/test/val/val_misc_test.cpp @@ -84,7 +84,28 @@ OpMemoryModel Logical GLSL450 HasSubstr("Cannot create undefined values with 8- or 16-bit types")); } -const std::string ShaderClockSpriv = R"( +TEST_F(ValidateMisc, SizeOfValid) { + const std::string spirv = R"( + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %f "f" + %void = OpTypeVoid + %i32 = OpTypeInt 32 0 + %ptr = OpTypePointer CrossWorkgroup %i32 + %fnTy = OpTypeFunction %void + %f = OpFunction %void None %fnTy + %entry = OpLabel + %s = OpSizeOf %i32 %ptr + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_1); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); +} + +const std::string ShaderClockSpirv = R"( OpCapability Shader OpCapability Int64 OpCapability ShaderClockKHR @@ -103,7 +124,7 @@ OpName %time1 "time1" )"; TEST_F(ValidateMisc, ShaderClockInt64) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 %_ptr_Function_uint = OpTypePointer Function %uint @@ -123,7 +144,7 @@ OpFunctionEnd)"; } TEST_F(ValidateMisc, ShaderClockVec2) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %_ptr_Function_ulong = OpTypePointer Function %ulong @@ -145,7 +166,7 @@ OpFunctionEnd)"; } TEST_F(ValidateMisc, ShaderClockInvalidScopeValue) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %uint = OpTypeInt 32 0 @@ -166,7 +187,7 @@ OpFunctionEnd)"; } TEST_F(ValidateMisc, ShaderClockSubgroupScope) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %uint = OpTypeInt 32 0 @@ -186,7 +207,7 @@ OpFunctionEnd)"; } TEST_F(ValidateMisc, ShaderClockDeviceScope) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %uint = OpTypeInt 32 0 @@ -206,7 +227,7 @@ OpFunctionEnd)"; } TEST_F(ValidateMisc, ShaderClockWorkgroupScope) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %uint = OpTypeInt 32 0 @@ -222,13 +243,13 @@ OpReturn OpFunctionEnd)"; CompileSuccessfully(spirv); - EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); EXPECT_THAT(getDiagnosticString(), HasSubstr("Scope must be Subgroup or Device")); } TEST_F(ValidateMisc, VulkanShaderClockWorkgroupScope) { - const std::string spirv = ShaderClockSpriv + R"( + const std::string spirv = ShaderClockSpirv + R"( %3 = OpTypeFunction %void %ulong = OpTypeInt 64 0 %uint = OpTypeInt 32 0 @@ -251,6 +272,59 @@ OpFunctionEnd)"; HasSubstr("Scope must be Subgroup or Device")); } +std::string GenKernelClockSpirv(const std::string& scope) { + const std::string s = R"( +OpCapability Kernel +OpCapability Addresses +OpCapability Int64 +OpCapability ShaderClockKHR +OpExtension "SPV_KHR_shader_clock" +OpMemoryModel Physical32 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionMode %main ContractionOff +OpSource OpenCL_C 200000 +OpName %main "main" +OpName %time1 "time1" +%void = OpTypeVoid +%3 = OpTypeFunction %void +%ulong = OpTypeInt 64 0 +%uint = OpTypeInt 32 0 +%_ptr_Function_ulong = OpTypePointer Function %ulong +%scope = OpConstant %uint )" + + scope + R"( +%main = OpFunction %void None %3 +%5 = OpLabel +%time1 = OpVariable %_ptr_Function_ulong Function +%11 = OpReadClockKHR %ulong %scope +OpStore %time1 %11 +OpReturn +OpFunctionEnd +)"; + return s; +} + +TEST_F(ValidateMisc, KernelClockScopeDevice) { + CompileSuccessfully(GenKernelClockSpirv("1"), SPV_ENV_OPENCL_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_1_2)); +} + +TEST_F(ValidateMisc, KernelClockScopeWorkgroup) { + CompileSuccessfully(GenKernelClockSpirv("2"), SPV_ENV_OPENCL_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_1_2)); +} + +TEST_F(ValidateMisc, KernelClockScopeSubgroup) { + CompileSuccessfully(GenKernelClockSpirv("3"), SPV_ENV_OPENCL_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_1_2)); +} + +TEST_F(ValidateMisc, KernelClockScopeInvalid) { + CompileSuccessfully(GenKernelClockSpirv("0"), SPV_ENV_OPENCL_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_OPENCL_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Scope must be Subgroup, Workgroup, or Device")); +} + TEST_F(ValidateMisc, UndefVoid) { const std::string spirv = R"( OpCapability Shader @@ -297,6 +371,77 @@ OpEntryPoint Vertex %func "shader" EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for target environment")); } + +TEST_F(ValidateMisc, CoopMat2WorkgroupLocalSizeIdPass) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main LocalSizeId %u32_16 %u32_16 %u32_16 +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%use_Acc = OpConstant %u32 2 +%workgroup = OpConstant %u32 2 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %workgroup %u32_16 %u32_16 %use_Acc + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateMisc, CoopMat2WorkgroupLocalSizeIdConstantNotDeclaredYetFail) { + const std::string body = R"( +OpCapability Shader +OpCapability Float16 +OpCapability Int16 +OpCapability CooperativeMatrixKHR +OpExtension "SPV_KHR_cooperative_matrix" +OpExtension "SPV_KHR_vulkan_memory_model" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main LocalSizeId %u32_16 %u32_8 %u32_16 +%void = OpTypeVoid +%func = OpTypeFunction %void +%bool = OpTypeBool +%f16 = OpTypeFloat 16 +%u32 = OpTypeInt 32 0 + +%u32_16 = OpConstant %u32 16 +%use_Acc = OpConstant %u32 2 +%workgroup = OpConstant %u32 2 + +%f16mat = OpTypeCooperativeMatrixKHR %f16 %workgroup %u32_16 %u32_16 %use_Acc +%u32_8 = OpConstant %u32 8 + +%main = OpFunction %void None %func +%main_entry = OpLabel + +OpReturn +OpFunctionEnd)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpTypeCooperativeMatrixKHR with ScopeWorkgroup used " + "before LocalSizeId constant value")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_modes_test.cpp b/third_party/spirv-tools/test/val/val_modes_test.cpp index 689f0baa93..256ab43c4b 100644 --- a/third_party/spirv-tools/test/val/val_modes_test.cpp +++ b/third_party/spirv-tools/test/val/val_modes_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2018 Google LLC. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +20,6 @@ #include "gmock/gmock.h" #include "source/spirv_target_env.h" -#include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -89,6 +90,99 @@ OpDecorate %int3_1 BuiltIn WorkgroupSize EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); } +TEST_F(ValidateMode, GLComputeZeroWorkgroupSize) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpDecorate %int3_1 BuiltIn WorkgroupSize +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "WorkgroupSize decorations must not have a static product of zero")); +} + +TEST_F(ValidateMode, GLComputeZeroSpecWorkgroupSize) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpDecorate %int3_1 BuiltIn WorkgroupSize +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%int_0 = OpSpecConstant %int 0 +%int_1 = OpConstant %int 1 +%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMode, GLComputeZeroSpecCompositeWorkgroupSize) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpDecorate %int3_1 BuiltIn WorkgroupSize +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%int_0 = OpSpecConstant %int 0 +%int_1 = OpSpecConstant %int 1 +%int3_1 = OpSpecConstantComposite %int3 %int_1 %int_0 %int_0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateMode, KernelZeroWorkgroupSizeConstant) { + const std::string spirv = R"( +OpCapability Addresses +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical32 OpenCL +OpEntryPoint Kernel %main "main" +OpDecorate %int3_1 BuiltIn WorkgroupSize +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), HasSubstr("must be a variable")); +} + +TEST_F(ValidateMode, KernelZeroWorkgroupSizeVariable) { + const std::string spirv = R"( +OpCapability Addresses +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical32 OpenCL +OpEntryPoint Kernel %main "main" +OpDecorate %var BuiltIn WorkgroupSize +%int = OpTypeInt 32 0 +%int3 = OpTypeVector %int 3 +%ptr = OpTypePointer Input %int3 +%var = OpVariable %ptr Input +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + TEST_F(ValidateMode, GLComputeVulkanLocalSize) { const std::string spirv = R"( OpCapability Shader @@ -102,6 +196,38 @@ OpExecutionMode %main LocalSize 1 1 1 EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); } +TEST_F(ValidateMode, GLComputeZeroLocalSize) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Local Size execution mode must not have a product of zero")); +} + +TEST_F(ValidateMode, KernelZeroLocalSize) { + const std::string spirv = R"( +OpCapability Addresses +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical32 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionMode %main LocalSize 1 1 0 +)" + kVoidFunction; + + CompileSuccessfully(spirv); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Local Size execution mode must not have a product of zero")); +} + TEST_F(ValidateMode, GLComputeVulkanLocalSizeIdBad) { const std::string spirv = R"( OpCapability Shader @@ -136,6 +262,95 @@ OpExecutionModeId %main LocalSizeId %int_1 %int_1 %int_1 EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); } +TEST_F(ValidateMode, GLComputeZeroLocalSizeId) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1 +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%int_0 = OpConstant %int 0 +)" + kVoidFunction; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Local Size Id execution mode must not have a product of zero")); +} + +TEST_F(ValidateMode, GLComputeZeroSpecLocalSizeId) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1 +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%int_0 = OpSpecConstant %int 0 +)" + kVoidFunction; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(env)); +} + +TEST_F(ValidateMode, KernelZeroLocalSizeId) { + const std::string spirv = R"( +OpCapability Addresses +OpCapability Linkage +OpCapability Kernel +OpMemoryModel Physical32 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1 +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%int_0 = OpConstant %int 0 +)" + kVoidFunction; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Local Size Id execution mode must not have a product of zero")); +} + +// https://github.com/KhronosGroup/SPIRV-Tools/issues/5939 +TEST_F(ValidateMode, KernelZeroLocalSize64) { + const std::string spirv = R"( + OpCapability Kernel + OpCapability Addresses + OpCapability Int64 + OpCapability Linkage + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %test "test" %__spirv_BuiltInWorkgroupSize + OpExecutionMode %test ContractionOff + OpDecorate %__spirv_BuiltInWorkgroupSize Constant + OpDecorate %__spirv_BuiltInWorkgroupSize LinkageAttributes "__spirv_BuiltInWorkgroupSize" Import + OpDecorate %__spirv_BuiltInWorkgroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %8 = OpTypeFunction %void +%__spirv_BuiltInWorkgroupSize = OpVariable %_ptr_Input_v3ulong Input + %test = OpFunction %void None %8 + %entry = OpLabel + %11 = OpLoad %v3ulong %__spirv_BuiltInWorkgroupSize Aligned 1 + %12 = OpCompositeExtract %ulong %11 0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + TEST_F(ValidateMode, FragmentOriginLowerLeftVulkan) { const std::string spirv = R"( OpCapability Shader @@ -579,6 +794,11 @@ TEST_P(ValidateModeExecution, ExecutionMode) { sstr << "OpCapability Kernel\n"; if (env == SPV_ENV_UNIVERSAL_1_3) { sstr << "OpCapability SubgroupDispatch\n"; + } else if (env == SPV_ENV_UNIVERSAL_1_5) { + sstr << "OpCapability TileImageColorReadAccessEXT\n"; + sstr << "OpCapability TileImageDepthReadAccessEXT\n"; + sstr << "OpCapability TileImageStencilReadAccessEXT\n"; + sstr << "OpExtension \"SPV_EXT_shader_tile_image\"\n"; } } sstr << "OpMemoryModel Logical GLSL450\n"; @@ -702,6 +922,27 @@ INSTANTIATE_TEST_SUITE_P( "DepthLess", "DepthUnchanged"), Values(SPV_ENV_UNIVERSAL_1_0))); +INSTANTIATE_TEST_SUITE_P(ValidateModeFragmentOnlyGoodSpv15, + ValidateModeExecution, + Combine(Values(SPV_SUCCESS), Values(""), + Values("Fragment"), + Values("NonCoherentColorAttachmentReadEXT", + "NonCoherentDepthAttachmentReadEXT", + "NonCoherentStencilAttachmentReadEXT"), + Values(SPV_ENV_UNIVERSAL_1_5))); + +INSTANTIATE_TEST_SUITE_P( + ValidateModeFragmentOnlyBadSpv15, ValidateModeExecution, + Combine(Values(SPV_ERROR_INVALID_DATA), + Values("Execution mode can only be used with the Fragment " + "execution model."), + Values("Geometry", "TessellationControl", "TessellationEvaluation", + "GLCompute", "Vertex", "Kernel"), + Values("NonCoherentColorAttachmentReadEXT", + "NonCoherentDepthAttachmentReadEXT", + "NonCoherentStencilAttachmentReadEXT"), + Values(SPV_ENV_UNIVERSAL_1_5))); + INSTANTIATE_TEST_SUITE_P(ValidateModeKernelOnlyGoodSpv13, ValidateModeExecution, Combine(Values(SPV_SUCCESS), Values(""), Values("Kernel"), @@ -789,6 +1030,109 @@ OpExecutionMode %main OutputPoints EXPECT_THAT(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateModeExecution, MeshEXTOutputVertices) { + const std::string spirv = R"( +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint MeshEXT %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main OutputVertices 3 +OpExecutionMode %main OutputPrimitivesNV 1 +OpExecutionMode %main OutputTrianglesNV +OpSource GLSL 460 +OpSourceExtension "GL_EXT_mesh_shader" +OpName %main "main" +OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 +%main = OpFunction %void None %3 +%5 = OpLabel +OpSetMeshOutputsEXT %uint_3 %uint_1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4); + EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateModeExecution, VulkanBadMeshEXTOutputVertices) { + const std::string spirv = R"( +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint MeshEXT %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main OutputVertices 0 +OpExecutionMode %main OutputPrimitivesNV 1 +OpExecutionMode %main OutputTrianglesNV +OpSource GLSL 460 +OpSourceExtension "GL_EXT_mesh_shader" +OpName %main "main" +OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 +%main = OpFunction %void None %3 +%5 = OpLabel +OpSetMeshOutputsEXT %uint_3 %uint_1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-MeshEXT-07330")); +} + +TEST_F(ValidateModeExecution, VulkanBadMeshEXTOutputOutputPrimitivesEXT) { + const std::string spirv = R"( +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint MeshEXT %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main OutputVertices 1 +OpExecutionMode %main OutputPrimitivesNV 0 +OpExecutionMode %main OutputTrianglesNV +OpSource GLSL 460 +OpSourceExtension "GL_EXT_mesh_shader" +OpName %main "main" +OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize +%void = OpTypeVoid +%3 = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%uint_3 = OpConstant %uint 3 +%uint_1 = OpConstant %uint 1 +%v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 +%main = OpFunction %void None %3 +%5 = OpLabel +OpSetMeshOutputsEXT %uint_3 %uint_1 +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-MeshEXT-07331")); +} + TEST_F(ValidateModeExecution, MeshNVOutputVertices) { const std::string spirv = R"( OpCapability Shader @@ -1002,6 +1346,162 @@ OpExecutionModeId %main LocalSizeId %int_1 %int_1 %int_1 "constant instructions.")); } +using AllowMultipleExecutionModes = spvtest::ValidateBase; + +TEST_P(AllowMultipleExecutionModes, DifferentOperand) { + const std::string mode = GetParam(); + const std::string spirv = R"( +OpCapability Shader +OpCapability DenormPreserve +OpCapability DenormFlushToZero +OpCapability SignedZeroInfNanPreserve +OpCapability RoundingModeRTE +OpCapability RoundingModeRTZ +OpExtension "SPV_KHR_float_controls" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main )" + mode + + R"( 16 +OpExecutionMode %main )" + mode + + R"( 32 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_P(AllowMultipleExecutionModes, SameOperand) { + const std::string mode = GetParam(); + const std::string spirv = R"( +OpCapability Shader +OpCapability DenormPreserve +OpCapability DenormFlushToZero +OpCapability SignedZeroInfNanPreserve +OpCapability RoundingModeRTE +OpCapability RoundingModeRTZ +OpExtension "SPV_KHR_float_controls" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main )" + mode + + R"( 32 +OpExecutionMode %main )" + mode + + R"( 32 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("execution mode must not be specified multiple times " + "for the same entry point and operands")); +} + +INSTANTIATE_TEST_SUITE_P(MultipleFloatControlsExecModes, + AllowMultipleExecutionModes, + Values("DenormPreserve", "DenormFlushToZero", + "SignedZeroInfNanPreserve", "RoundingModeRTE", + "RoundingModeRTZ")); + +using MultipleExecModes = spvtest::ValidateBase; + +TEST_P(MultipleExecModes, DuplicateMode) { + const std::string mode = GetParam(); + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +OpExecutionMode %main )" + mode + + R"( +OpExecutionMode %main )" + mode + + R"( +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("execution mode must not be specified multiple times " + "per entry point")); +} + +INSTANTIATE_TEST_SUITE_P(MultipleFragmentExecMode, MultipleExecModes, + Values("DepthReplacing", "DepthGreater", "DepthLess", + "DepthUnchanged")); + +TEST_F(ValidateMode, FloatControls2FPFastMathDefaultSameOperand) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %none +OpExecutionModeId %main FPFastMathDefault %float %none +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%none = OpConstant %int 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_2)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("execution mode must not be specified multiple times " + "for the same entry point and operands")); +} + +TEST_F(ValidateMode, FloatControls2FPFastMathDefaultDifferentOperand) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Float16 +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %none +OpExecutionModeId %main FPFastMathDefault %half %none +%void = OpTypeVoid +%float = OpTypeFloat 32 +%int = OpTypeInt 32 0 +%none = OpConstant %int 0 +%half = OpTypeFloat 16 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_2)); +} + TEST_F(ValidateMode, FragmentShaderInterlockVertexBad) { const std::string spirv = R"( OpCapability Shader @@ -1101,7 +1601,6 @@ OpFunctionEnd EXPECT_THAT(SPV_SUCCESS, ValidateInstructions()); } - TEST_F(ValidateMode, FragmentShaderStencilRefFrontTooManyModesBad) { const std::string spirv = R"( OpCapability Shader @@ -1281,6 +1780,962 @@ OpFunctionEnd EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); } +TEST_F(ValidateMode, MaximalReconvergenceRequiresExtension) { + const std::string spirv = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main MaximallyReconvergesKHR +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("(6023) requires one of these extensions: " + "SPV_KHR_maximal_reconvergence ")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNotExecutionModeId) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionMode %main FPFastMathDefault %int_0 %int_0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand " + "is an execution mode that takes no Extra Operands, or " + "takes Extra Operands that are not id operands")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNotAType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %int_0 %int_0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "The Target Type operand must be a floating-point scalar type")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNotAFloatType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %int %int_0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "The Target Type operand must be a floating-point scalar type")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNotAFloatScalarType) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float2 %int_0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float2 = OpTypeVector %float 2 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "The Target Type operand must be a floating-point scalar type")); +} + +TEST_F(ValidateMode, FPFastMathDefaultSpecConstant) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %int_0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpSpecConstant %int 0 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("The Fast Math Default operand must be a " + "non-specialization constant")); +} + +TEST_F(ValidateMode, FPFastMathDefaultInvalidMask) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 524288 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The Fast Math Default operand is an invalid bitmask value")); +} + +TEST_F(ValidateMode, FPFastMathDefaultContainsFast) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 16 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("The Fast Math Default operand must not include Fast")); +} + +TEST_F(ValidateMode, FPFastMathDefaultAllowTransformMissingAllowReassoc) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 327680 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The Fast Math Default operand must include AllowContract and " + "AllowReassoc when AllowTransform is specified")); +} + +TEST_F(ValidateMode, FPFastMathDefaultAllowTransformMissingAllowContract) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 393216 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The Fast Math Default operand must include AllowContract and " + "AllowReassoc when AllowTransform is specified")); +} + +TEST_F(ValidateMode, FPFastMathDefaultAllowTransformMissingContractAndReassoc) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 262144 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("The Fast Math Default operand must include AllowContract and " + "AllowReassoc when AllowTransform is specified")); +} + +TEST_F(ValidateMode, FPFastMathDefaultSignedZeroInfNanPreserve) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpCapability SignedZeroInfNanPreserve +OpExtension "SPV_KHR_float_controls2" +OpExtension "SPV_KHR_float_controls" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionMode %main LocalSize 1 1 1 +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main SignedZeroInfNanPreserve 32 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("FPFastMathDefault and SignedZeroInfNanPreserve execution " + "modes cannot be applied to the same entry point")); +} + +TEST_F(ValidateMode, FPFastMathDefaultConractionOff) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability Addresses +OpCapability FloatControls2 +OpCapability SignedZeroInfNanPreserve +OpExtension "SPV_KHR_float_controls2" +OpExtension "SPV_KHR_float_controls" +OpMemoryModel Physical64 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main ContractionOff +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("FPFastMathDefault and ContractionOff execution modes " + "cannot be applied to the same entry point")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNoContractionNotInCallTree) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add NoContraction +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %zero %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateMode, FPFastMathDefaultNoContractionInCallTree) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add NoContraction +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %zero %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("NoContraction cannot be used by an entry point with " + "the FPFastMathDefault execution mode")); +} + +TEST_F(ValidateMode, FPFastMathDefaultNoContractionInCallTree2) { + const std::string spirv = R"( +OpCapability Shader +OpCapability Kernel +OpCapability Addresses +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Physical64 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpDecorate %const NoContraction +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%const = OpSpecConstantOp %float FAdd %zero %zero +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %const %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("NoContraction cannot be used by an entry point with " + "the FPFastMathDefault execution mode")); +} + +TEST_F(ValidateMode, FPFastMathDefaultFastMathFastNotInCallTree) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode Fast +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %zero %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); +} + +TEST_F(ValidateMode, FPFastMathDefaultFastMathFastInCallTree) { + const std::string spirv = R"( +OpCapability Shader +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %add FPFastMathMode Fast +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %zero %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("FPFastMathMode Fast cannot be used by an entry point " + "with the FPFastMathDefault execution mode")); +} + +TEST_F(ValidateMode, FPFastMathDefaultFastMathFastInCallTree2) { + const std::string spirv = R"( +OpCapability Kernel +OpCapability Addresses +OpCapability FloatControls2 +OpExtension "SPV_KHR_float_controls2" +OpMemoryModel Physical64 OpenCL +OpEntryPoint Kernel %main "main" +OpExecutionModeId %main FPFastMathDefault %float %constant +OpDecorate %const FPFastMathMode Fast +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%constant = OpConstant %int 0 +%float = OpTypeFloat 32 +%zero = OpConstant %float 0 +%const = OpSpecConstantOp %float FAdd %zero %zero +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%call = OpFunctionCall %void %func +OpReturn +OpFunctionEnd +%func = OpFunction %void None %void_fn +%func_entry = OpLabel +%add = OpFAdd %float %const %zero +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("FPFastMathMode Fast cannot be used by an entry point " + "with the FPFastMathDefault execution mode")); +} + +TEST_F(ValidateMode, FragmentShaderRequireFullQuadsKHR) { + const std::string spirv = R"( +OpCapability Shader +OpCapability GroupNonUniform +OpCapability GroupNonUniformVote +OpCapability GroupNonUniformBallot +OpCapability QuadControlKHR +OpExtension "SPV_KHR_quad_control" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %4 "main" +OpExecutionMode %4 OriginUpperLeft +OpExecutionMode %4 RequireFullQuadsKHR +OpDecorate %17 Location 0 +OpDecorate %31 BuiltIn HelperInvocation +OpDecorate %40 Location 0 +OpDecorate %44 DescriptorSet 0 +OpDecorate %44 Binding 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeInt 32 0 +%7 = OpTypeVector %6 4 +%8 = OpTypePointer Function %7 +%10 = OpTypeBool +%11 = OpConstantTrue %10 +%12 = OpConstant %6 7 +%14 = OpTypeFloat 32 +%15 = OpTypeVector %14 4 +%16 = OpTypePointer Output %15 +%17 = OpVariable %16 Output +%18 = OpConstant %14 1 +%19 = OpConstant %14 0 +%20 = OpConstantComposite %15 %18 %19 %19 %18 +%23 = OpConstant %6 4 +%27 = OpConstant %6 1 +%28 = OpTypePointer Output %14 +%30 = OpTypePointer Input %10 +%31 = OpVariable %30 Input +%36 = OpConstant %6 2 +%38 = OpTypeVector %14 2 +%39 = OpTypePointer Input %38 +%40 = OpVariable %39 Input +%41 = OpTypeImage %14 2D 0 0 0 1 Unknown +%42 = OpTypeSampledImage %41 +%43 = OpTypePointer UniformConstant %42 +%44 = OpVariable %43 UniformConstant +%4 = OpFunction %2 None %3 +%5 = OpLabel +%9 = OpVariable %8 Function +%13 = OpGroupNonUniformBallot %7 %12 %11 +OpStore %9 %13 +OpStore %17 %20 +%21 = OpLoad %7 %9 +%22 = OpGroupNonUniformBallotBitCount %6 %12 Reduce %21 +%24 = OpIEqual %10 %22 %23 +OpSelectionMerge %26 None +OpBranchConditional %24 %25 %26 +%25 = OpLabel +%29 = OpAccessChain %28 %17 %27 +OpStore %29 %18 +OpBranch %26 +%26 = OpLabel +%32 = OpLoad %10 %31 +%33 = OpGroupNonUniformAny %10 %12 %32 +OpSelectionMerge %35 None +OpBranchConditional %33 %34 %35 +%34 = OpLabel +%37 = OpAccessChain %28 %17 %36 +OpStore %37 %18 +OpBranch %35 +%35 = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Execution mode can only be used with the Fragment execution model")); +} + +TEST_F(ValidateMode, FragmentShaderQuadDerivativesKHR) { + const std::string spirv = R"( +OpCapability Shader +OpCapability GroupNonUniform +OpCapability GroupNonUniformVote +OpCapability QuadControlKHR +OpExtension "SPV_KHR_quad_control" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %4 "main" +OpExecutionMode %4 OriginUpperLeft +OpExecutionMode %4 QuadDerivativesKHR +OpDecorate %12 BuiltIn FragCoord +OpDecorate %41 Location 0 +OpDecorate %45 DescriptorSet 0 +OpDecorate %45 Binding 0 +OpDecorate %49 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFunction %2 +%6 = OpTypeBool +%7 = OpTypePointer Function %6 +%9 = OpTypeFloat 32 +%10 = OpTypeVector %9 4 +%11 = OpTypePointer Input %10 +%12 = OpVariable %11 Input +%13 = OpTypeInt 32 0 +%14 = OpConstant %13 1 +%15 = OpTypePointer Input %9 +%18 = OpConstant %9 8.5 +%21 = OpConstant %9 0.100000001 +%25 = OpConstant %13 0 +%28 = OpConstant %9 3.5 +%30 = OpConstant %9 6 +%36 = OpConstant %13 7 +%40 = OpTypePointer Output %10 +%41 = OpVariable %40 Output +%42 = OpTypeImage %9 2D 0 0 0 1 Unknown +%43 = OpTypeSampledImage %42 +%44 = OpTypePointer UniformConstant %43 +%45 = OpVariable %44 UniformConstant +%47 = OpTypeVector %9 2 +%48 = OpTypePointer Input %47 +%49 = OpVariable %48 Input +%53 = OpConstant %9 0.899999976 +%54 = OpConstant %9 0.200000003 +%55 = OpConstant %9 1 +%56 = OpConstantComposite %10 %53 %54 %54 %55 +%4 = OpFunction %2 None %3 +%5 = OpLabel +%8 = OpVariable %7 Function +%16 = OpAccessChain %15 %12 %14 +%17 = OpLoad %9 %16 +%19 = OpFSub %9 %17 %18 +%20 = OpExtInst %9 %1 FAbs %19 +%22 = OpFOrdLessThan %6 %20 %21 +OpSelectionMerge %24 None +OpBranchConditional %22 %23 %24 +%23 = OpLabel +%26 = OpAccessChain %15 %12 %25 +%27 = OpLoad %9 %26 +%29 = OpFSub %9 %27 %28 +%31 = OpFMod %9 %29 %30 +%33 = OpFOrdLessThan %6 %31 %21 +OpBranch %24 +%24 = OpLabel +%34 = OpPhi %6 %22 %5 %33 %23 +OpStore %8 %34 +%35 = OpLoad %6 %8 +%37 = OpGroupNonUniformAny %6 %36 %35 +OpSelectionMerge %39 None +OpBranchConditional %37 %38 %52 +%38 = OpLabel +%46 = OpLoad %43 %45 +%50 = OpLoad %47 %49 +%51 = OpImageSampleImplicitLod %10 %46 %50 +OpStore %41 %51 +OpBranch %39 +%52 = OpLabel +OpStore %41 %56 +OpBranch %39 +%39 = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "Execution mode can only be used with the Fragment execution model")); +} + +const std::string kNodeShaderPrelude = R"( +OpCapability Shader +OpCapability ShaderEnqueueAMDX +OpExtension "SPV_AMDX_shader_enqueue" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" +OpEntryPoint GLCompute %other "other" +)"; + +const std::string kNodeShaderPostlude = R"( +%uint = OpTypeInt 32 0 +%uint_0 = OpConstant %uint 0 +%uint_1 = OpConstant %uint 1 +%node0 = OpConstantStringAMDX "node0" +%node1 = OpConstantStringAMDX "node1" +%node2 = OpConstantStringAMDX "node2" +%S = OpTypeStruct +%_payloadarr_S = OpTypeNodePayloadArrayAMDX %S +%_payloadarr_S_0 = OpTypeNodePayloadArrayAMDX %S +%bool = OpTypeBool +%true = OpConstantTrue %bool +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%other = OpFunction %void None %void_fn +%entry0 = OpLabel +OpReturn +OpFunctionEnd +)"; + +TEST_F(ValidateMode, NodeShader) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env)); +} + +TEST_F(ValidateMode, NodeShaderModeShaderIndex) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionMode %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionMode %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + +TEST_F(ValidateMode, NodeShaderModeIsApiEntry) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionMode %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + +TEST_F(ValidateMode, NodeShaderModeMaxNodeRecursion) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionMode %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + +TEST_F(ValidateMode, NodeShaderModeMaxNumWorkgroups) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionMode %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + +TEST_F(ValidateMode, NodeShaderModeStaticNumWorkgroups) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionModeId %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionMode %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + +TEST_F(ValidateMode, NodeShaderModeSharesInputWith) { + const std::string spirv = kNodeShaderPrelude + R"( +OpExecutionModeId %main ShaderIndexAMDX %uint_0 +OpExecutionModeId %main IsApiEntryAMDX %true +OpExecutionModeId %main MaxNodeRecursionAMDX %uint_1 +OpExecutionModeId %main MaxNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpExecutionMode %main SharesInputWithAMDX %node0 %uint_0 +OpExecutionModeId %other ShaderIndexAMDX %uint_0 +OpExecutionModeId %other StaticNumWorkgroupsAMDX %uint_1 %uint_1 %uint_1 +OpDecorateId %_payloadarr_S PayloadNodeNameAMDX %node1 +OpDecorateId %_payloadarr_S_0 PayloadNodeNameAMDX %node2 +OpDecorateId %_payloadarr_S PayloadNodeBaseIndexAMDX %uint_0 +OpDecorateId %_payloadarr_S PayloadNodeArraySizeAMDX %uint_1 +OpDecorateId %_payloadarr_S NodeSharesPayloadLimitsWithAMDX %_payloadarr_S_0 +)" + kNodeShaderPostlude; + + spv_target_env env = SPV_ENV_UNIVERSAL_1_3; + CompileSuccessfully(spirv, env); + EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("OpExecutionMode is only valid when the Mode operand is an " + "execution mode that takes no Extra Operands, or takes Extra " + "Operands that are not id operands")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_non_uniform_test.cpp b/third_party/spirv-tools/test/val/val_non_uniform_test.cpp index af571d3a9f..530676d5e4 100644 --- a/third_party/spirv-tools/test/val/val_non_uniform_test.cpp +++ b/third_party/spirv-tools/test/val/val_non_uniform_test.cpp @@ -44,6 +44,10 @@ OpCapability GroupNonUniformShuffleRelative OpCapability GroupNonUniformArithmetic OpCapability GroupNonUniformClustered OpCapability GroupNonUniformQuad +OpCapability GroupNonUniformPartitionedNV +OpCapability QuadControlKHR +OpExtension "SPV_NV_shader_subgroup_partitioned" +OpExtension "SPV_KHR_quad_control" )"; ss << capabilities_and_extensions; @@ -62,16 +66,27 @@ OpCapability GroupNonUniformQuad %float = OpTypeFloat 32 %u32vec4 = OpTypeVector %u32 4 %u32vec3 = OpTypeVector %u32 3 +%v2bool = OpTypeVector %bool 2 +%v4float = OpTypeVector %float 4 +%struct = OpTypeStruct %int +%v4int = OpTypeVector %int 4 %true = OpConstantTrue %bool %false = OpConstantFalse %bool %u32_0 = OpConstant %u32 0 +%int_0 = OpConstant %int 0 %float_0 = OpConstant %float 0 %u32vec4_null = OpConstantComposite %u32vec4 %u32_0 %u32_0 %u32_0 %u32_0 %u32vec3_null = OpConstantComposite %u32vec3 %u32_0 %u32_0 %u32_0 +%v2bool_false = OpConstantNull %v2bool +%v4float_null = OpConstantNull %v4float +%struct_null = OpConstantNull %struct +%v4int_null = OpConstantComposite %v4int %int_0 %int_0 %int_0 %int_0 + +%u32_undef = OpUndef %u32 %cross_device = OpConstant %u32 0 %device = OpConstant %u32 1 @@ -122,6 +137,32 @@ std::string ConvertScope(spv::Scope scope) { } } +std::string ConvertMatch(const std::string& type) { + if (type == "%bool") { + return "%true"; + } else if (type == "%u32") { + return "%u32_0"; + } else if (type == "%int") { + return "%int_0"; + } else if (type == "%float") { + return "%float_0"; + } else if (type == "%u32vec4") { + return "%u32vec4_null"; + } else if (type == "%u32vec3") { + return "%u32vec3_null"; + } else if (type == "%v2bool") { + return "%v2bool_false"; + } else if (type == "%v4float") { + return "%v4float_null"; + } else if (type == "%struct") { + return "%struct_null"; + } else if (type == "%v4int") { + return "%v4int_null"; + } + + return "INVALID"; +} + TEST_P(GroupNonUniform, Vulkan1p1) { std::string opcode = std::get<0>(GetParam()); std::string type = std::get<1>(GetParam()); @@ -129,10 +170,20 @@ TEST_P(GroupNonUniform, Vulkan1p1) { std::string args = std::get<3>(GetParam()); std::string error = std::get<4>(GetParam()); + const std::string match = "match_res"; + size_t pos = std::string::npos; + while ((pos = args.find(match)) != std::string::npos) { + const std::string replace = ConvertMatch(type); + args = args.substr(0, pos) + replace + args.substr(pos + match.size()); + } + std::ostringstream sstr; sstr << "%result = " << opcode << " "; sstr << type << " "; - sstr << ConvertScope(execution_scope) << " "; + if (opcode != "OpGroupNonUniformQuadAllKHR" && + opcode != "OpGroupNonUniformQuadAnyKHR") { + sstr << ConvertScope(execution_scope) << " "; + } sstr << args << "\n"; CompileSuccessfully(GenerateShaderCode(sstr.str()), SPV_ENV_VULKAN_1_1); @@ -162,10 +213,20 @@ TEST_P(GroupNonUniform, Spirv1p3) { std::string args = std::get<3>(GetParam()); std::string error = std::get<4>(GetParam()); + const std::string match = "match_res"; + size_t pos = std::string::npos; + while ((pos = args.find(match)) != std::string::npos) { + const std::string replace = ConvertMatch(type); + args = args.substr(0, pos) + replace + args.substr(pos + match.size()); + } + std::ostringstream sstr; sstr << "%result = " << opcode << " "; sstr << type << " "; - sstr << ConvertScope(execution_scope) << " "; + if (opcode != "OpGroupNonUniformQuadAllKHR" && + opcode != "OpGroupNonUniformQuadAnyKHR") { + sstr << ConvertScope(execution_scope) << " "; + } sstr << args << "\n"; CompileSuccessfully(GenerateShaderCode(sstr.str()), SPV_ENV_UNIVERSAL_1_3); @@ -292,6 +353,542 @@ INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotBitCountBadValue, GroupNonUniform, Values("Expected Value to be a vector of four " "components of integer type scalar"))); +INSTANTIATE_TEST_SUITE_P(GroupNonUniformElectGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformElect"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values(""), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformElectBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformElect"), + Values("%void", "%u32", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct"), + Values(spv::Scope::Subgroup), Values(""), + Values("Result must be a boolean scalar type"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformAnyAllGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformAny", + "OpGroupNonUniformAll"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true", "%false"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformAnyAllBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformAny", "OpGroupNonUniformAll"), + Values("%void", "%u32", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct"), + Values(spv::Scope::Subgroup), Values("%true"), + Values("Result must be a boolean scalar type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformAnyAllBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformAny", "OpGroupNonUniformAll"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%u32_0", "%int_0", "%float_0", "%u32vec4_null", + "%u32vec3_null", "%v2bool_false", "%v4float_null", + "%struct_null"), + Values("Predicate must be a boolean scalar type"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformAllEqualGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformAllEqual"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true", "%false"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformAllEqualBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformAllEqual"), + Values("%void", "%u32", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct"), + Values(spv::Scope::Subgroup), Values("%true"), + Values("Result must be a boolean scalar type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformAllEqualBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformAllEqual"), Values("%bool"), + Values(spv::Scope::Subgroup), Values("%struct_null"), + Values("Value must be a scalar or vector of integer, " + "floating-point, or boolean type"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBroadcastGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcast", + "OpGroupNonUniformQuadBroadcast", + "OpGroupNonUniformQuadSwap"), + Values("%bool", "%u32", "%int", "%float", + "%u32vec4", "%u32vec3", "%v2bool", + "%v4float", "%v4int"), + Values(spv::Scope::Subgroup), + Values("match_res %u32_0"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBroadcastShuffleBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcast", "OpGroupNonUniformShuffle", + "OpGroupNonUniformShuffleXor", "OpGroupNonUniformShuffleUp", + "OpGroupNonUniformShuffleDown", + "OpGroupNonUniformQuadBroadcast", + "OpGroupNonUniformQuadSwap"), + Values("%void", "%struct"), Values(spv::Scope::Subgroup), + Values("%u32_0 %u32_0"), + Values("Result must be a scalar or vector of integer, " + "floating-point, or boolean type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBroadcastShuffleBadOperand1, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcast", "OpGroupNonUniformShuffle", + "OpGroupNonUniformShuffleXor", "OpGroupNonUniformShuffleUp", + "OpGroupNonUniformShuffleDown", + "OpGroupNonUniformQuadBroadcast", + "OpGroupNonUniformQuadSwap"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%u32_0 %u32_0", "%int_0 %u32_0", "%float_0 %u32_0", + "%u32vec4_null %u32_0", "%u32vec3_null %u32_0", + "%v2bool_false %u32_0", "%v4float_null %u32_0", + "%struct_null %u32_0", "%v4int_null %u32_0"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBroadcastShuffleBadOperand2, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcast", "OpGroupNonUniformShuffle", + "OpGroupNonUniformShuffleXor", "OpGroupNonUniformShuffleUp", + "OpGroupNonUniformShuffleDown", + "OpGroupNonUniformQuadBroadcast", + "OpGroupNonUniformQuadSwap"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true %true", "%true %int_0", "%true %float_0", + "%true %u32vec4_null", "%true %u32vec3_null", + "%true %v4float_null", "%true %v2bool_false", + "%true %struct_null", "%true %v4int_null"), + Values("must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBroadcastShuffleOperand2NotConstant, + GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcast", + "OpGroupNonUniformQuadBroadcast", + "OpGroupNonUniformQuadSwap"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true %u32_undef"), + Values("must be a constant instruction"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBroadcastFirstGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcastFirst"), + Values("%bool", "%u32", "%int", "%float", + "%u32vec4", "%u32vec3", "%v2bool", + "%v4float", "%v4int"), + Values(spv::Scope::Subgroup), + Values("match_res"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBroadcasFirsttBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcastFirst"), + Values("%void", "%struct"), Values(spv::Scope::Subgroup), + Values("%u32_0"), + Values("Result must be a scalar or vector of integer, " + "floating-point, or boolean type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBroadcastBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformBroadcastFirst"), Values("%bool"), + Values(spv::Scope::Subgroup), + Values("%u32_0", "%int_0", "%float_0", "%u32vec4_null", + "%u32vec3_null", "%v2bool_false", "%v4float_null", + "%struct_null", "%v4int_null"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallot"), + Values("%u32vec4"), + Values(spv::Scope::Subgroup), + Values("%true", "%false"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallot"), + Values("%void", "%bool", "%u32", "%int", "%float", "%u32vec3", + "%v2bool", "%v4float", "%struct", "%v4int"), + Values(spv::Scope::Subgroup), Values("%true", "%false"), + Values("Result must be a 4-component unsigned integer vector"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallot"), + Values("%u32vec4"), + Values(spv::Scope::Subgroup), + Values("%u32_0", "%int_0", "%float_0", + "%u32vec4_null", "%u32vec3_null", + "%v2bool_false", "%v4float_null", + "%struct_null", "%v4int_null"), + Values("Predicate must be a boolean scalar"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformInverseBallotGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformInverseBallot"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%u32vec4_null"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformInverseBallotBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformInverseBallot"), + Values("%void", "%u32", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct", "%v4int"), + Values(spv::Scope::Subgroup), Values("%u32vec4_null"), + Values("Result must be a boolean scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformInverseBallotBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformInverseBallot"), Values("%bool"), + Values(spv::Scope::Subgroup), + Values("%true", "%false", "%u32_0", "%int_0", "%float_0", + "%u32vec3_null", "%v2bool_false", "%v4float_null", + "%struct_null", "%v4int_null"), + Values("Value must be a 4-component unsigned integer vector"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotBitExtractGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotBitExtract"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%u32vec4_null %u32_0"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotBitExtractBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotBitExtract"), + Values("%void", "%u32", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct", "%v4int"), + Values(spv::Scope::Subgroup), Values("%u32vec4_null %u32_0"), + Values("Result must be a boolean scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotBitExtractBadOperand1, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotBitExtract"), Values("%bool"), + Values(spv::Scope::Subgroup), + Values("%true %u32_0", "%false %u32_0", "%u32_0 %u32_0", + "%int_0 %u32_0", "%float_0 %u32_0", "%u32vec3_null %u32_0", + "%v2bool_false %u32_0", "%v4float_null %u32_0", + "%struct_null %u32_0", "%v4int_null %u32_0"), + Values("Value must be a 4-component unsigned integer vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotBitExtractBadOperand2, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotBitExtract"), Values("%bool"), + Values(spv::Scope::Subgroup), + Values("%u32vec4_null %true", "%u32vec4_null %false", + "%u32vec4_null %int_0", "%u32vec4_null %float_0", + "%u32vec4_null %u32vec3_null", "%u32vec4_null %v2bool_false", + "%u32vec4_null %v4float_null", "%u32vec4_null %struct_null", + "%u32vec4_null %v4int_null"), + Values("Id must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotFindGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotFindLSB", + "OpGroupNonUniformBallotFindMSB"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("%u32vec4_null"), Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotFindBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotFindLSB", + "OpGroupNonUniformBallotFindMSB"), + Values("%void", "%bool", "%int", "%float", "%u32vec4", "%u32vec3", + "%v2bool", "%v4float", "%struct", "%v4int"), + Values(spv::Scope::Subgroup), Values("%u32vec4_null"), + Values("Result must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBallotFindBadOperand, GroupNonUniform, + Combine(Values("OpGroupNonUniformBallotFindLSB", + "OpGroupNonUniformBallotFindMSB"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("%true", "%false", "%u32_0", "%int_0", "%float_0", + "%u32vec3_null", "%v2bool_false", "%v4float_null", + "%struct_null", "%v4int_null"), + Values("Value must be a 4-component unsigned integer vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformSMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32", "%int", "%u32vec4", "%u32vec3", "%v4int"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0", + "PartitionedReduceNV match_res %u32vec4_null", + "PartitionedInclusiveScanNV match_res %u32vec4_null", + "PartitionedExclusiveScanNV match_res %v4int_null"), + Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformSMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%bool", "%float", "%v4float", "%struct"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values("Result must be an integer scalar or vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticBadValue, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformSMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%int", "%u32vec4", "%u32vec3", "%v4int"), + Values(spv::Scope::Subgroup), + Values("Reduce %u32_0", "InclusiveScan %u32_0", + "ExclusiveScan %u32_0", "ClusteredReduce %u32_0 %u32_0"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticMissingClusterSize, GroupNonUniform, + Combine( + Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformUMin", + "OpGroupNonUniformSMax", "OpGroupNonUniformUMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res"), + Values( + "ClusterSize must be present when Operation is ClusteredReduce"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticMissingBallot, GroupNonUniform, + Combine( + Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformUMin", + "OpGroupNonUniformSMax", "OpGroupNonUniformUMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("PartitionedReduceNV match_res", + "PartitionedInclusiveScanNV match_res", + "PartitionedExclusiveScanNV match_res"), + Values("Ballot must be present when Operation is PartitionedReduceNV, " + "PartitionedInclusiveScanNV, or PartitionedExclusiveScanNV"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticBadClusterSizeType, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformUMin", + "OpGroupNonUniformSMax", "OpGroupNonUniformUMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %true", + "ClusteredReduce match_res %false", + "ClusteredReduce match_res %int_0", + "ClusteredReduce match_res %float_0", + "ClusteredReduce match_res %u32vec4_null", + "ClusteredReduce match_res %u32vec3_null", + "ClusteredReduce match_res %v2bool_false", + "ClusteredReduce match_res %v4float_null", + "ClusteredReduce match_res %struct_null", + "ClusteredReduce match_res %v4int_null"), + Values("ClusterSize must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticBadBallotType, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformUMin", + "OpGroupNonUniformSMax", "OpGroupNonUniformUMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("PartitionedReduceNV match_res %true", + "PartitionedReduceNV match_res %false", + "PartitionedReduceNV match_res %int_0", + "PartitionedReduceNV match_res %float_0", + "PartitionedReduceNV match_res %u32_0", + "PartitionedReduceNV match_res %u32vec3_null", + "PartitionedReduceNV match_res %v2bool_false", + "PartitionedReduceNV match_res %v4float_null", + "PartitionedReduceNV match_res %struct_null"), + Values("Ballot must be a 4-component integer vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformIntegerArithmeticClusterSizeNotConstant, GroupNonUniform, + Combine(Values("OpGroupNonUniformIAdd", "OpGroupNonUniformIMul", + "OpGroupNonUniformSMin", "OpGroupNonUniformUMin", + "OpGroupNonUniformSMax", "OpGroupNonUniformUMax", + "OpGroupNonUniformBitwiseAnd", "OpGroupNonUniformBitwiseOr", + "OpGroupNonUniformBitwiseXor"), + Values("%u32"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %u32_undef"), + Values("ClusterSize must be a constant instruction"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformUnsignedIntegerArithmeticGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformUMin", "OpGroupNonUniformUMax"), + Values("%u32", "%u32vec4", "%u32vec3"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformUnsignedIntegerArithmeticBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformUMin", "OpGroupNonUniformUMax"), + Values("%bool", "%int", "%float", "%v4float", "%struct", "%v4int"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values("Result must be an unsigned integer scalar or vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformUnsignedIntegerArithmeticBadValue, GroupNonUniform, + Combine(Values("OpGroupNonUniformUMin", "OpGroupNonUniformUMax"), + Values("%u32vec4", "%u32vec3"), Values(spv::Scope::Subgroup), + Values("Reduce %u32_0", "InclusiveScan %u32_0", + "ExclusiveScan %u32_0", "ClusteredReduce %u32_0 %u32_0"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%float", "%v4float"), Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%bool", "%u32", "%int", "%u32vec4", "%u32vec3", "%struct", + "%v4int"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values("Result must be a floating-point scalar or vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticBadValue, GroupNonUniform, + Combine(Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%v4float"), Values(spv::Scope::Subgroup), + Values("Reduce %float_0", "InclusiveScan %float_0", + "ExclusiveScan %float_0", "ClusteredReduce %float_0 %u32_0"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticMissingClusterSize, GroupNonUniform, + Combine( + Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%float"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res"), + Values( + "ClusterSize must be present when Operation is ClusteredReduce"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticBadClusterSizeType, GroupNonUniform, + Combine(Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%float"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %true", + "ClusteredReduce match_res %false", + "ClusteredReduce match_res %int_0", + "ClusteredReduce match_res %float_0", + "ClusteredReduce match_res %u32vec4_null", + "ClusteredReduce match_res %u32vec3_null", + "ClusteredReduce match_res %v2bool_false", + "ClusteredReduce match_res %v4float_null", + "ClusteredReduce match_res %struct_null", + "ClusteredReduce match_res %v4int_null"), + Values("ClusterSize must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformFloatArithmeticClusterSizeNotConstant, GroupNonUniform, + Combine(Values("OpGroupNonUniformFAdd", "OpGroupNonUniformFMul", + "OpGroupNonUniformFMin", "OpGroupNonUniformFMax"), + Values("%float"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %u32_undef"), + Values("ClusterSize must be a constant instruction"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticGood, GroupNonUniform, + Combine(Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%bool", "%v2bool"), Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values(""))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticBadResultType, GroupNonUniform, + Combine(Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%u32", "%int", "%float", "%u32vec4", "%u32vec3", "%struct", + "%v4float", "%v4int"), + Values(spv::Scope::Subgroup), + Values("Reduce match_res", "InclusiveScan match_res", + "ExclusiveScan match_res", + "ClusteredReduce match_res %u32_0"), + Values("Result must be a boolean scalar or vector"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticBadValue, GroupNonUniform, + Combine(Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%v2bool"), Values(spv::Scope::Subgroup), + Values("Reduce %true", "InclusiveScan %true", + "ExclusiveScan %false", "ClusteredReduce %false %u32_0"), + Values("The type of Value must match the Result type"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticMissingClusterSize, GroupNonUniform, + Combine( + Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res"), + Values( + "ClusterSize must be present when Operation is ClusteredReduce"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticBadClusterSizeType, GroupNonUniform, + Combine(Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %true", + "ClusteredReduce match_res %false", + "ClusteredReduce match_res %int_0", + "ClusteredReduce match_res %float_0", + "ClusteredReduce match_res %u32vec4_null", + "ClusteredReduce match_res %u32vec3_null", + "ClusteredReduce match_res %v2bool_false", + "ClusteredReduce match_res %v4float_null", + "ClusteredReduce match_res %struct_null", + "ClusteredReduce match_res %v4int_null"), + Values("ClusterSize must be an unsigned integer scalar"))); + +INSTANTIATE_TEST_SUITE_P( + GroupNonUniformBooleanArithmeticClusterSizeNotConstant, GroupNonUniform, + Combine(Values("OpGroupNonUniformLogicalAnd", "OpGroupNonUniformLogicalOr", + "OpGroupNonUniformLogicalXor"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("ClusteredReduce match_res %u32_undef"), + Values("ClusterSize must be a constant instruction"))); + +// Subgroup scope is not actual parameter, but used for test expectations, +INSTANTIATE_TEST_SUITE_P(GroupNonUniformQuadAllKHR, GroupNonUniform, + Combine(Values("OpGroupNonUniformQuadAllKHR"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true"), Values(""))); + +// Subgroup scope is not actual parameter, but used for test expectations, +INSTANTIATE_TEST_SUITE_P(GroupNonUniformQuadAnyKHR, GroupNonUniform, + Combine(Values("OpGroupNonUniformQuadAnyKHR"), + Values("%bool"), Values(spv::Scope::Subgroup), + Values("%true"), Values(""))); + TEST_F(ValidateGroupNonUniform, VulkanGroupNonUniformBallotBitCountOperation) { std::string test = R"( OpCapability Shader @@ -327,6 +924,146 @@ OpFunctionEnd "be only: Reduce, InclusiveScan, or ExclusiveScan.")); } +TEST_F(ValidateGroupNonUniform, BroadcastNonConstantSpv1p4) { + const std::string text = R"( +OpCapability Shader +OpCapability GroupNonUniformBallot +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%struct = OpTypeStruct %int +%ptr_struct = OpTypePointer StorageBuffer %struct +%ptr_int = OpTypePointer StorageBuffer %int +%var = OpVariable %ptr_struct StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_int %var %int_0 +%ld = OpLoad %int %gep +%broadcast = OpGroupNonUniformBroadcast %int %subgroup %int_0 %ld +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Before SPIR-V 1.5, Id must be a constant instruction")); +} + +TEST_F(ValidateGroupNonUniform, BroadcastNonConstantSpv1p5) { + const std::string text = R"( +OpCapability Shader +OpCapability GroupNonUniformBallot +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%struct = OpTypeStruct %int +%ptr_struct = OpTypePointer StorageBuffer %struct +%ptr_int = OpTypePointer StorageBuffer %int +%var = OpVariable %ptr_struct StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_int %var %int_0 +%ld = OpLoad %int %gep +%broadcast = OpGroupNonUniformBroadcast %int %subgroup %int_0 %ld +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + +TEST_F(ValidateGroupNonUniform, QuadBroadcastNonConstantSpv1p4) { + const std::string text = R"( +OpCapability Shader +OpCapability GroupNonUniformQuad +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%struct = OpTypeStruct %int +%ptr_struct = OpTypePointer StorageBuffer %struct +%ptr_int = OpTypePointer StorageBuffer %int +%var = OpVariable %ptr_struct StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_int %var %int_0 +%ld = OpLoad %int %gep +%broadcast = OpGroupNonUniformQuadBroadcast %int %subgroup %int_0 %ld +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_4); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Before SPIR-V 1.5, Index must be a constant instruction")); +} + +TEST_F(ValidateGroupNonUniform, QuadBroadcastNonConstantSpv1p5) { + const std::string text = R"( +OpCapability Shader +OpCapability GroupNonUniformQuad +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %main "main" %var +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %var DescriptorSet 0 +OpDecorate %var Binding 0 +OpDecorate %struct Block +OpMemberDecorate %struct 0 Offset 0 +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%subgroup = OpConstant %int 3 +%struct = OpTypeStruct %int +%ptr_struct = OpTypePointer StorageBuffer %struct +%ptr_int = OpTypePointer StorageBuffer %int +%var = OpVariable %ptr_struct StorageBuffer +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +%gep = OpAccessChain %ptr_int %var %int_0 +%ld = OpLoad %int %gep +%broadcast = OpGroupNonUniformQuadBroadcast %int %subgroup %int_0 %ld +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_ray_query_test.cpp b/third_party/spirv-tools/test/val/val_ray_query_test.cpp index e0eb067589..ed6cce7d03 100644 --- a/third_party/spirv-tools/test/val/val_ray_query_test.cpp +++ b/third_party/spirv-tools/test/val/val_ray_query_test.cpp @@ -30,20 +30,23 @@ using ::testing::Values; using ValidateRayQuery = spvtest::ValidateBase; -std::string GenerateShaderCode( - const std::string& body, - const std::string& capabilities_and_extensions = "", - const std::string& declarations = "") { +std::string GenerateShaderCode(const std::string& body, + const std::string& capabilities = "", + const std::string& extensions = "", + const std::string& declarations = "") { std::ostringstream ss; ss << R"( OpCapability Shader OpCapability Int64 OpCapability Float64 OpCapability RayQueryKHR + )"; + ss << capabilities; + ss << R"( OpExtension "SPV_KHR_ray_query" )"; - ss << capabilities_and_extensions; + ss << extensions; ss << R"( OpMemoryModel Logical GLSL450 @@ -83,12 +86,15 @@ OpDecorate %top_level_as Binding 0 %u32_0 = OpConstant %u32 0 %u64_0 = OpConstant %u64 0 +%u32_2 = OpConstant %u32 2 +%arr2v3 = OpTypeArray %f32vec3 %u32_2 +%arr2f3 = OpTypeArray %f32 %u32_2 + %u32vec3_0 = OpConstantComposite %u32vec3 %u32_0 %u32_0 %u32_0 %f32vec3_0 = OpConstantComposite %f32vec3 %f32_0 %f32_0 %f32_0 %f32vec4_0 = OpConstantComposite %f32vec4 %f32_0 %f32_0 %f32_0 %f32_0 -%ptr_rq = OpTypePointer Private %type_rq -%ray_query = OpVariable %ptr_rq Private +%ptr_rq = OpTypePointer Function %type_rq %ptr_as = OpTypePointer UniformConstant %type_as %top_level_as = OpVariable %ptr_as UniformConstant @@ -103,6 +109,7 @@ OpDecorate %top_level_as Binding 0 ss << R"( %main = OpFunction %void None %func %main_entry = OpLabel +%ray_query = OpVariable %ptr_rq Function )"; ss << body; @@ -398,7 +405,7 @@ OpFunctionEnd OpRayQueryInitializeKHR %rq_param %as_2 %u32_0 %u32_0 %f32vec3_0 %f32_0 %f32vec3_0 %f32_0 )"; - CompileSuccessfully(GenerateShaderCode(body, "", declaration).c_str()); + CompileSuccessfully(GenerateShaderCode(body, "", "", declaration).c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -626,6 +633,78 @@ TEST_F(ValidateRayQuery, RayQueryArraySuccess) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateRayQuery, ClusterASNV) { + const std::string cap = R"( + OpCapability RayTracingClusterAccelerationStructureNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_cluster_acceleration_structure" + )"; + + const std::string body = R"( + %clusterid = OpRayQueryGetClusterIdNV %s32 %ray_query %s32_0 +)"; + + CompileSuccessfully(GenerateShaderCode(body, cap, ext).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +using RayQueryLSSNVCommon = spvtest::ValidateBase; + +std::string RayQueryLSSNVResultType(std::string opcode, bool valid) { + if (opcode.compare("OpRayQueryGetIntersectionLSSPositionsNV") == 0) + return valid ? "%arr2v3" : "%f64"; + + if (opcode.compare("OpRayQueryGetIntersectionLSSRadiiNV") == 0) + return valid ? "%arr2f3" : "%f64"; + + if (opcode.compare("OpRayQueryGetIntersectionSphereRadiusNV") == 0 || + opcode.compare("OpRayQueryGetIntersectionLSSHitValueNV") == 0) { + return valid ? "%f32" : "%f64"; + } + + if (opcode.compare("OpRayQueryGetIntersectionSpherePositionNV") == 0) { + return valid ? "%f32vec3" : "%f64"; + } + + if (opcode.compare("OpRayQueryIsSphereHitNV") == 0 || + opcode.compare("OpRayQueryIsLSSHitNV") == 0) { + return valid ? "%bool" : "%f64"; + } + + return ""; +} + +TEST_P(RayQueryLSSNVCommon, Success) { + const std::string cap = R"( + OpCapability RayTracingSpheresGeometryNV + OpCapability RayTracingLinearSweptSpheresGeometryNV + )"; + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + std::string opcode = GetParam(); + std::ostringstream ss; + ss << "%result = "; + ss << " " << opcode << " "; + ss << RayQueryLSSNVResultType(opcode, true); + ss << " %ray_query "; + ss << " %s32_0 "; + CompileSuccessfully(GenerateShaderCode(ss.str(), cap, ext).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +INSTANTIATE_TEST_SUITE_P(ValidateRayQueryLSSNVCommon, RayQueryLSSNVCommon, + Values("OpRayQueryGetIntersectionSpherePositionNV", + "OpRayQueryGetIntersectionLSSPositionsNV", + "OpRayQueryGetIntersectionSphereRadiusNV", + "OpRayQueryGetIntersectionLSSRadiiNV", + "OpRayQueryGetIntersectionLSSHitValueNV", + "OpRayQueryIsSphereHitNV", + "OpRayQueryIsLSSHitNV")); } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_ray_tracing_reorder_test.cpp b/third_party/spirv-tools/test/val/val_ray_tracing_reorder_test.cpp index 6038c38376..a41af80c91 100644 --- a/third_party/spirv-tools/test/val/val_ray_tracing_reorder_test.cpp +++ b/third_party/spirv-tools/test/val/val_ray_tracing_reorder_test.cpp @@ -30,13 +30,21 @@ using ::testing::Values; using ValidateRayTracingReorderNV = spvtest::ValidateBase; std::string GenerateReorderThreadCode(const std::string& body = "", - const std::string& declarations = "") { + const std::string& declarations = "", + const std::string& extensions = "", + const std::string& capabilities = "") { std::ostringstream ss; ss << R"( OpCapability RayTracingKHR OpCapability ShaderInvocationReorderNV + )"; + ss << capabilities; + ss << R"( OpExtension "SPV_KHR_ray_tracing" OpExtension "SPV_NV_shader_invocation_reorder" + )"; + ss << extensions; + ss << R"( %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint RayGenerationNV %main "main" %hObj @@ -593,6 +601,196 @@ TEST_F(ValidateRayTracingReorderNV, EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); } +TEST_F(ValidateRayTracingReorderNV, ClusterASNV) { + const std::string cap = R"( + OpCapability RayTracingClusterAccelerationStructureNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_cluster_acceleration_structure" + )"; + + const std::string declarations = R"( + %int = OpTypeInt 32 1 + %_ptr_Function_int = OpTypePointer Function %int + )"; + + const std::string body = R"( + %id = OpVariable %_ptr_Function_int Function + %12 = OpHitObjectGetClusterIdNV %int %hObj + OpStore %id %12 + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSGetSpherePositionNV) { + const std::string cap = R"( + OpCapability RayTracingSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %_ptr_Function_v3float = OpTypePointer Function %v3float + )"; + + const std::string body = R"( + %pos = OpVariable %_ptr_Function_v3float Function + %result = OpHitObjectGetSpherePositionNV %v3float %hObj + OpStore %pos %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSGetLSSPositionsNV) { + const std::string cap = R"( + OpCapability RayTracingSpheresGeometryNV + OpCapability RayTracingLinearSweptSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %v3float = OpTypeVector %float 3 + %uint_2 = OpConstant %uint 2 + %arr = OpTypeArray %v3float %uint_2 + %_ptr_Function_v3float = OpTypePointer Function %arr + )"; + + const std::string body = R"( + %lsspos = OpVariable %_ptr_Function_v3float Function + %result = OpHitObjectGetLSSPositionsNV %arr %hObj + OpStore %lsspos %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSGetSphereRadiusNV) { + const std::string cap = R"( + OpCapability RayTracingSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %float = OpTypeFloat 32 + %_ptr_Function_float = OpTypePointer Function %float + )"; + + const std::string body = R"( + %rad = OpVariable %_ptr_Function_float Function + %result = OpHitObjectGetSphereRadiusNV %float %hObj + OpStore %rad %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSGetLSSRadiiNV) { + const std::string cap = R"( + OpCapability RayTracingLinearSweptSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %arr = OpTypeArray %float %uint_2 + %_ptr_Function_float = OpTypePointer Function %arr + )"; + + const std::string body = R"( + %rad = OpVariable %_ptr_Function_float Function + %result = OpHitObjectGetLSSRadiiNV %arr %hObj + OpStore %rad %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSIsSphereHitNV) { + const std::string cap = R"( + OpCapability RayTracingSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %bool = OpTypeBool + %_ptr_Function_bool = OpTypePointer Function %bool + )"; + + const std::string body = R"( + %ishit = OpVariable %_ptr_Function_bool Function + %result = OpHitObjectIsSphereHitNV %bool %hObj + OpStore %ishit %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} + +TEST_F(ValidateRayTracingReorderNV, LSSIsLSSHitNV) { + const std::string cap = R"( + OpCapability RayTracingLinearSweptSpheresGeometryNV + )"; + + const std::string ext = R"( + OpExtension "SPV_NV_linear_swept_spheres" + )"; + + const std::string declarations = R"( + %bool = OpTypeBool + %_ptr_Function_bool = OpTypePointer Function %bool + )"; + + const std::string body = R"( + %ishit = OpVariable %_ptr_Function_bool Function + %result = OpHitObjectIsLSSHitNV %bool %hObj + OpStore %ishit %result + )"; + + CompileSuccessfully( + GenerateReorderThreadCode(body, declarations, ext, cap).c_str(), + SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2)); +} } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_ray_tracing_test.cpp b/third_party/spirv-tools/test/val/val_ray_tracing_test.cpp index 58b9356cef..60f2f89117 100644 --- a/third_party/spirv-tools/test/val/val_ray_tracing_test.cpp +++ b/third_party/spirv-tools/test/val/val_ray_tracing_test.cpp @@ -578,6 +578,95 @@ OpTraceRayKHR %as %uint_1 %uint_1 %uint_1 %uint_1 %uint_1 %v3composite %float_0 "IncomingRayPayloadKHR")); } +TEST_F(ValidateRayTracing, InterfaceIncomingRayPayload) { + const std::string body = R"( +OpCapability RayTracingKHR +OpExtension "SPV_KHR_ray_tracing" +OpMemoryModel Logical GLSL450 +OpEntryPoint CallableKHR %main "main" %inData1 %inData2 +OpName %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%int = OpTypeInt 32 1 +%inData_ptr = OpTypePointer IncomingRayPayloadKHR %int +%inData1 = OpVariable %inData_ptr IncomingRayPayloadKHR +%inData2 = OpVariable %inData_ptr IncomingRayPayloadKHR +%main = OpFunction %void None %func +%label = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-IncomingRayPayloadKHR-04700")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Entry-point has more than one variable with the " + "IncomingRayPayloadKHR storage class in the interface")); +} + +TEST_F(ValidateRayTracing, InterfaceHitAttribute) { + const std::string body = R"( +OpCapability RayTracingKHR +OpExtension "SPV_KHR_ray_tracing" +OpMemoryModel Logical GLSL450 +OpEntryPoint CallableKHR %main "main" %inData1 %inData2 +OpName %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%int = OpTypeInt 32 1 +%inData_ptr = OpTypePointer HitAttributeKHR %int +%inData1 = OpVariable %inData_ptr HitAttributeKHR +%inData2 = OpVariable %inData_ptr HitAttributeKHR +%main = OpFunction %void None %func +%label = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-HitAttributeKHR-04702")); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Entry-point has more than one variable with the " + "HitAttributeKHR storage class in the interface")); +} + +TEST_F(ValidateRayTracing, InterfaceIncomingCallableData) { + const std::string body = R"( +OpCapability RayTracingKHR +OpExtension "SPV_KHR_ray_tracing" +OpMemoryModel Logical GLSL450 +OpEntryPoint CallableKHR %main "main" %inData1 %inData2 +OpName %main "main" +%void = OpTypeVoid +%func = OpTypeFunction %void +%int = OpTypeInt 32 1 +%inData_ptr = OpTypePointer IncomingCallableDataKHR %int +%inData1 = OpVariable %inData_ptr IncomingCallableDataKHR +%inData2 = OpVariable %inData_ptr IncomingCallableDataKHR +%main = OpFunction %void None %func +%label = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(body.c_str(), SPV_ENV_VULKAN_1_2); + EXPECT_EQ(SPV_ERROR_INVALID_DATA, + ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_2)); + EXPECT_THAT(getDiagnosticString(), + AnyVUID("VUID-StandaloneSpirv-IncomingCallableDataKHR-04706")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("Entry-point has more than one variable with the " + "IncomingCallableDataKHR storage class in the interface")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_state_test.cpp b/third_party/spirv-tools/test/val/val_state_test.cpp index 4097a1feb8..51064abd41 100644 --- a/third_party/spirv-tools/test/val/val_state_test.cpp +++ b/third_party/spirv-tools/test/val/val_state_test.cpp @@ -18,14 +18,10 @@ #include #include "gtest/gtest.h" -#include "source/latest_version_spirv_header.h" - #include "source/enum_set.h" #include "source/extensions.h" +#include "source/latest_version_spirv_header.h" #include "source/spirv_validator_options.h" -#include "source/val/construct.h" -#include "source/val/function.h" -#include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { diff --git a/third_party/spirv-tools/test/val/val_storage_test.cpp b/third_party/spirv-tools/test/val/val_storage_test.cpp index 8693e8036e..d4170e6dc7 100644 --- a/third_party/spirv-tools/test/val/val_storage_test.cpp +++ b/third_party/spirv-tools/test/val/val_storage_test.cpp @@ -28,8 +28,6 @@ namespace { using ::testing::HasSubstr; using ::testing::Values; using ValidateStorage = spvtest::ValidateBase; -using ValidateStorageClass = - spvtest::ValidateBase>; using ValidateStorageExecutionModel = spvtest::ValidateBase; TEST_F(ValidateStorage, FunctionStorageInsideFunction) { @@ -167,7 +165,7 @@ TEST_F(ValidateStorage, GenericVariableOutsideFunction) { CompileSuccessfully(str); ASSERT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("OpVariable storage class cannot be Generic")); + HasSubstr("Variable storage class cannot be Generic")); } TEST_F(ValidateStorage, GenericVariableInsideFunction) { @@ -189,7 +187,7 @@ TEST_F(ValidateStorage, GenericVariableInsideFunction) { CompileSuccessfully(str); EXPECT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), - HasSubstr("OpVariable storage class cannot be Generic")); + HasSubstr("Variable storage class cannot be Generic")); } TEST_F(ValidateStorage, RelaxedLogicalPointerFunctionParam) { diff --git a/third_party/spirv-tools/test/val/val_type_unique_test.cpp b/third_party/spirv-tools/test/val/val_type_unique_test.cpp index 31ad3a6597..289e341858 100644 --- a/third_party/spirv-tools/test/val/val_type_unique_test.cpp +++ b/third_party/spirv-tools/test/val/val_type_unique_test.cpp @@ -1,4 +1,6 @@ // Copyright (c) 2017 Google Inc. +// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights +// reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -270,6 +272,46 @@ OpMemoryModel Logical GLSL450 Not(HasSubstr(GetErrorString(spv::Op::OpTypePointer)))); } +TEST_F(ValidateTypeUnique, DuplicateUntypedPointer) { + std::string str = R"( +OpCapability Shader +OpCapability Linkage +OpCapability UntypedPointersKHR +OpCapability WorkgroupMemoryExplicitLayoutKHR +OpExtension "SPV_KHR_workgroup_memory_explicit_layout" +OpExtension "SPV_KHR_untyped_pointers" +OpMemoryModel Logical GLSL450 +%u32 = OpTypeInt 32 0 +%ptr1 = OpTypeUntypedPointerKHR Workgroup +%ptr2 = OpTypeUntypedPointerKHR Workgroup +)"; + + CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_4); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + +TEST_F(ValidateTypeUnique, DuplicateNodePayloadArrayType) { + std::string str = R"( +OpCapability Shader +OpCapability ShaderEnqueueAMDX +OpCapability Linkage +OpExtension "SPV_AMDX_shader_enqueue" +OpMemoryModel Logical GLSL450 +%floatt = OpTypeFloat 32 +%struct = OpTypeStruct %floatt +%npat1 = OpTypeNodePayloadArrayAMDX %struct +%npat2 = OpTypeNodePayloadArrayAMDX %struct +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_4); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_4)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/third_party/spirv-tools/test/val/val_version_test.cpp b/third_party/spirv-tools/test/val/val_version_test.cpp index 6b7c4fe840..743567c34f 100644 --- a/third_party/spirv-tools/test/val/val_version_test.cpp +++ b/third_party/spirv-tools/test/val/val_version_test.cpp @@ -79,6 +79,7 @@ std::string version(spv_target_env env) { return "1.5"; case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_VULKAN_1_3: + case SPV_ENV_VULKAN_1_4: return "1.6"; default: return "0"; @@ -117,6 +118,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4,vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), @@ -135,6 +137,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -153,6 +156,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -171,6 +175,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -189,6 +194,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -207,6 +213,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -225,6 +232,7 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -248,6 +256,7 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), @@ -266,6 +275,7 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -284,6 +294,7 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -302,6 +313,7 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -320,11 +332,33 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) + std::make_tuple(SPV_ENV_VULKAN_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + // Assembling for Vulkan 1.4 produces SPIR-V 1.6 + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), + // Vulkan 1.3 accepts SPIR-V 1.6 + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_VULKAN_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_4, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); diff --git a/third_party/spirv-tools/tools/CMakeLists.txt b/third_party/spirv-tools/tools/CMakeLists.txt index 86d0bc46a0..a6736ca3ca 100644 --- a/third_party/spirv-tools/tools/CMakeLists.txt +++ b/third_party/spirv-tools/tools/CMakeLists.txt @@ -39,36 +39,73 @@ function(add_spvtools_tool) set_property(TARGET ${ARG_TARGET} PROPERTY FOLDER "SPIRV-Tools executables") endfunction() +set(COMMON_TOOLS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/util/flags.cpp") + if (NOT ${SPIRV_SKIP_EXECUTABLES}) - add_spvtools_tool(TARGET spirv-as SRCS as/as.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_tool(TARGET spirv-diff SRCS diff/diff.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-diff SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_tool(TARGET spirv-dis SRCS dis/dis.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_tool(TARGET spirv-val SRCS val/val.cpp util/cli_consumer.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_tool(TARGET spirv-opt SRCS opt/opt.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-diff SRCS ${COMMON_TOOLS_SRCS} diff/diff.cpp util/cli_consumer.cpp io.cpp LIBS SPIRV-Tools-diff SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-dis SRCS ${COMMON_TOOLS_SRCS} dis/dis.cpp io.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-val SRCS ${COMMON_TOOLS_SRCS} val/val.cpp util/cli_consumer.cpp io.cpp LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-opt SRCS ${COMMON_TOOLS_SRCS} opt/opt.cpp util/cli_consumer.cpp io.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")) # iOS does not allow std::system calls which spirv-reduce requires - add_spvtools_tool(TARGET spirv-reduce SRCS reduce/reduce.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-reduce ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-reduce SRCS ${COMMON_TOOLS_SRCS} reduce/reduce.cpp util/cli_consumer.cpp io.cpp LIBS SPIRV-Tools-reduce ${SPIRV_TOOLS_FULL_VISIBILITY}) endif() - add_spvtools_tool(TARGET spirv-link SRCS link/linker.cpp LIBS SPIRV-Tools-link ${SPIRV_TOOLS_FULL_VISIBILITY}) - add_spvtools_tool(TARGET spirv-lint SRCS lint/lint.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-lint SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-link SRCS ${COMMON_TOOLS_SRCS} link/linker.cpp io.cpp LIBS SPIRV-Tools-link ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-lint SRCS ${COMMON_TOOLS_SRCS} lint/lint.cpp util/cli_consumer.cpp io.cpp LIBS SPIRV-Tools-lint SPIRV-Tools-opt ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-as + SRCS as/as.cpp + io.cpp + ${COMMON_TOOLS_SRCS} + LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) + target_include_directories(spirv-as PRIVATE ${spirv-tools_SOURCE_DIR} + ${SPIRV_HEADER_INCLUDE_DIR}) add_spvtools_tool(TARGET spirv-cfg SRCS cfg/cfg.cpp cfg/bin_to_dot.h cfg/bin_to_dot.cpp + io.cpp + ${COMMON_TOOLS_SRCS} LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) target_include_directories(spirv-cfg PRIVATE ${spirv-tools_SOURCE_DIR} ${SPIRV_HEADER_INCLUDE_DIR}) set(SPIRV_INSTALL_TARGETS spirv-as spirv-dis spirv-val spirv-opt spirv-cfg spirv-link spirv-lint) + + if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Android")) + add_spvtools_tool(TARGET spirv-objdump + SRCS objdump/objdump.cpp + objdump/extract_source.cpp + util/cli_consumer.cpp + io.cpp + ${COMMON_TOOLS_SRCS} + LIBS ${SPIRV_TOOLS_FULL_VISIBILITY}) + target_include_directories(spirv-objdump PRIVATE ${spirv-tools_SOURCE_DIR} + ${SPIRV_HEADER_INCLUDE_DIR}) + set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-objdump) + endif() + if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")) set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-reduce) endif() if(SPIRV_BUILD_FUZZER) - add_spvtools_tool(TARGET spirv-fuzz SRCS fuzz/fuzz.cpp util/cli_consumer.cpp LIBS SPIRV-Tools-fuzz ${SPIRV_TOOLS_FULL_VISIBILITY}) + add_spvtools_tool(TARGET spirv-fuzz SRCS fuzz/fuzz.cpp util/cli_consumer.cpp io.cpp LIBS SPIRV-Tools-fuzz ${SPIRV_TOOLS_FULL_VISIBILITY}) set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-fuzz) endif(SPIRV_BUILD_FUZZER) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS ${SPIRV_INSTALL_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS ${SPIRV_INSTALL_TARGETS} EXPORT SPIRV-Tools-toolsTargets) + export(EXPORT SPIRV-Tools-toolsTargets FILE SPIRV-Tools-toolsTargets.cmake) + + spvtools_config_package_dir(SPIRV-Tools-tools PACKAGE_DIR) + install(EXPORT SPIRV-Tools-toolsTargets FILE SPIRV-Tools-toolsTargets.cmake + DESTINATION ${PACKAGE_DIR}) + + file(WRITE ${CMAKE_BINARY_DIR}/SPIRV-Tools-toolsConfig.cmake + "include(CMakeFindDependencyMacro)\n" + "find_dependency(${SPIRV_TOOLS})\n" + "include(\${CMAKE_CURRENT_LIST_DIR}/SPIRV-Tools-toolsTargets.cmake)\n" + ) + + install(FILES ${CMAKE_BINARY_DIR}/SPIRV-Tools-toolsConfig.cmake DESTINATION ${PACKAGE_DIR}) endif(ENABLE_SPIRV_TOOLS_INSTALL) endif() diff --git a/third_party/spirv-tools/tools/as/as.cpp b/third_party/spirv-tools/tools/as/as.cpp index 506b058562..8e821701de 100644 --- a/third_party/spirv-tools/tools/as/as.cpp +++ b/third_party/spirv-tools/tools/as/as.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include #include @@ -19,11 +20,11 @@ #include "source/spirv_target_env.h" #include "spirv-tools/libspirv.h" #include "tools/io.h" +#include "tools/util/flags.h" -void print_usage(char* argv0) { - std::string target_env_list = spvTargetEnvList(19, 80); - printf( - R"(%s - Create a SPIR-V binary module from SPIR-V assembly text +constexpr auto kDefaultTarget = SPV_ENV_UNIVERSAL_1_6; +static const std::string kHelpText = + R"(%s - Create a SPIR-V binary module from SPIR-V assembly text Usage: %s [options] [] @@ -42,94 +43,69 @@ Options: Numeric IDs in the binary will have the same values as in the source. Non-numeric IDs are allocated by filling in the gaps, starting with 1 and going up. - --target-env {%s} + --target-env %s Use specified environment. -)", - argv0, argv0, target_env_list.c_str()); -} +)"; -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +// clang-format off +// flag name= default_value= required= +FLAG_SHORT_bool( h, false, false); +FLAG_LONG_bool( help, false, false); +FLAG_LONG_bool( version, false, false); +FLAG_LONG_bool( preserve_numeric_ids, false, false); +FLAG_SHORT_string(o, "", false); +FLAG_LONG_string( target_env, "", false); +// clang-format on -int main(int argc, char** argv) { - const char* inFile = nullptr; - const char* outFile = nullptr; - uint32_t options = 0; - spv_target_env target_env = kDefaultEnvironment; - for (int argi = 1; argi < argc; ++argi) { - if ('-' == argv[argi][0]) { - switch (argv[argi][1]) { - case 'h': { - print_usage(argv[0]); - return 0; - } - case 'o': { - if (!outFile && argi + 1 < argc) { - outFile = argv[++argi]; - } else { - print_usage(argv[0]); - return 1; - } - } break; - case 0: { - // Setting a filename of "-" to indicate stdin. - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } break; - case '-': { - // Long options - if (0 == strcmp(argv[argi], "--version")) { - printf("%s\n", spvSoftwareVersionDetailsString()); - printf("Target: %s\n", - spvTargetEnvDescription(kDefaultEnvironment)); - return 0; - } else if (0 == strcmp(argv[argi], "--help")) { - print_usage(argv[0]); - return 0; - } else if (0 == strcmp(argv[argi], "--preserve-numeric-ids")) { - options |= SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS; - } else if (0 == strcmp(argv[argi], "--target-env")) { - if (argi + 1 < argc) { - const auto env_str = argv[++argi]; - if (!spvParseTargetEnv(env_str, &target_env)) { - fprintf(stderr, "error: Unrecognized target env: %s\n", - env_str); - return 1; - } - } else { - fprintf(stderr, "error: Missing argument to --target-env\n"); - return 1; - } - } else { - fprintf(stderr, "error: Unrecognized option: %s\n\n", argv[argi]); - print_usage(argv[0]); - return 1; - } - } break; - default: - fprintf(stderr, "error: Unrecognized option: %s\n\n", argv[argi]); - print_usage(argv[0]); - return 1; - } - } else { - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } +int main(int, const char** argv) { + if (!flags::Parse(argv)) { + return 1; } - if (!outFile) { + if (flags::h.value() || flags::help.value()) { + const std::string target_env_list = spvTargetEnvList(19, 80); + printf(kHelpText.c_str(), argv[0], argv[0], target_env_list.c_str()); + return 0; + } + + if (flags::version.value()) { + printf("%s\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", spvTargetEnvDescription(kDefaultTarget)); + return 0; + } + + std::string outFile = flags::o.value(); + if (outFile.empty()) { outFile = "out.spv"; } + uint32_t options = 0; + if (flags::preserve_numeric_ids.value()) { + options |= SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS; + } + + if (flags::positional_arguments.size() != 1) { + fprintf(stderr, "error: exactly one input file must be specified.\n"); + return 1; + } + std::string inFile = flags::positional_arguments[0]; + std::vector contents; - if (!ReadTextFile(inFile, &contents)) return 1; + if (!ReadTextFile(inFile.c_str(), &contents)) return 1; + + // Can only deduce target after the file has been read + spv_target_env target_env; + if (flags::target_env.value().empty()) { + if (!spvReadEnvironmentFromText(contents, &target_env)) { + // Revert to default version since deduction failed + target_env = kDefaultTarget; + } + } else if (!spvParseTargetEnv(flags::target_env.value().c_str(), + &target_env)) { + fprintf(stderr, "error: Unrecognized target env: %s\n", + flags::target_env.value().c_str()); + return 1; + } spv_binary binary; spv_diagnostic diagnostic = nullptr; @@ -143,7 +119,8 @@ int main(int argc, char** argv) { return error; } - if (!WriteFile(outFile, "wb", binary->code, binary->wordCount)) { + if (!WriteFile(outFile.c_str(), "wb", binary->code, + binary->wordCount)) { spvBinaryDestroy(binary); return 1; } diff --git a/third_party/spirv-tools/tools/cfg/cfg.cpp b/third_party/spirv-tools/tools/cfg/cfg.cpp index 5380c21ecd..2c68904227 100644 --- a/third_party/spirv-tools/tools/cfg/cfg.cpp +++ b/third_party/spirv-tools/tools/cfg/cfg.cpp @@ -21,11 +21,11 @@ #include "spirv-tools/libspirv.h" #include "tools/cfg/bin_to_dot.h" #include "tools/io.h" +#include "tools/util/flags.h" -// Prints a program usage message to stdout. -static void print_usage(const char* argv0) { - printf( - R"(%s - Show the control flow graph in GraphiViz "dot" form. EXPERIMENTAL +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +static const std::string kHelpText = + R"(%s - Show the control flow graph in GraphiViz "dot" form. EXPERIMENTAL Usage: %s [options] [] @@ -40,71 +40,42 @@ Options: -o Set the output filename. Output goes to standard output if this option is not specified, or if the filename is "-". -)", - argv0, argv0); -} +)"; -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +// clang-format off +FLAG_SHORT_bool( h, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( help, /* default_value= */ false, /* required= */false); +FLAG_LONG_bool( version, /* default_value= */ false, /* required= */ false); +FLAG_SHORT_string(o, /* default_value= */ "", /* required= */ false); +// clang-format on -int main(int argc, char** argv) { - const char* inFile = nullptr; - const char* outFile = nullptr; // Stays nullptr if printing to stdout. - - for (int argi = 1; argi < argc; ++argi) { - if ('-' == argv[argi][0]) { - switch (argv[argi][1]) { - case 'h': - print_usage(argv[0]); - return 0; - case 'o': { - if (!outFile && argi + 1 < argc) { - outFile = argv[++argi]; - } else { - print_usage(argv[0]); - return 1; - } - } break; - case '-': { - // Long options - if (0 == strcmp(argv[argi], "--help")) { - print_usage(argv[0]); - return 0; - } - if (0 == strcmp(argv[argi], "--version")) { - printf("%s EXPERIMENTAL\n", spvSoftwareVersionDetailsString()); - printf("Target: %s\n", - spvTargetEnvDescription(kDefaultEnvironment)); - return 0; - } - print_usage(argv[0]); - return 1; - } - case 0: { - // Setting a filename of "-" to indicate stdin. - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } break; - default: - print_usage(argv[0]); - return 1; - } - } else { - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } +int main(int, const char** argv) { + if (!flags::Parse(argv)) { + return 1; } + if (flags::h.value() || flags::help.value()) { + printf(kHelpText.c_str(), argv[0], argv[0]); + return 0; + } + + if (flags::version.value()) { + printf("%s EXPERIMENTAL\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", spvTargetEnvDescription(kDefaultEnvironment)); + return 0; + } + + if (flags::positional_arguments.size() != 1) { + fprintf(stderr, "error: exactly one input file must be specified.\n"); + return 1; + } + + std::string inFile = flags::positional_arguments[0]; + std::string outFile = flags::o.value(); + // Read the input binary. std::vector contents; - if (!ReadBinaryFile(inFile, &contents)) return 1; + if (!ReadBinaryFile(inFile.c_str(), &contents)) return 1; spv_context context = spvContextCreate(kDefaultEnvironment); spv_diagnostic diagnostic = nullptr; @@ -118,7 +89,8 @@ int main(int argc, char** argv) { return error; } std::string str = ss.str(); - WriteFile(outFile, "w", str.data(), str.size()); + WriteFile(outFile.empty() ? nullptr : outFile.c_str(), "w", str.data(), + str.size()); spvDiagnosticDestroy(diagnostic); spvContextDestroy(context); diff --git a/third_party/spirv-tools/tools/diff/diff.cpp b/third_party/spirv-tools/tools/diff/diff.cpp index d3cad04b11..d60edb2e13 100644 --- a/third_party/spirv-tools/tools/diff/diff.cpp +++ b/third_party/spirv-tools/tools/diff/diff.cpp @@ -17,14 +17,25 @@ #endif #include "source/diff/diff.h" - #include "source/opt/build_module.h" #include "source/opt/ir_context.h" #include "spirv-tools/libspirv.hpp" #include "tools/io.h" #include "tools/util/cli_consumer.h" +#include "tools/util/flags.h" -static void print_usage(char* argv0) { +namespace { + +constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +constexpr bool kColorIsPossible = +#if SPIRV_COLOR_TERMINAL + true; +#else + false; +#endif + +void print_usage(const char* argv0) { printf(R"(%s - Compare two SPIR-V files Usage: %s @@ -38,11 +49,12 @@ logical transformation from src to dst, in src's id-space. -h, --help Print this help. --version Display diff version information. - --color Force color output. The default when printing to a terminal. - Overrides a previous --no-color option. - --no-color Don't print in color. Overrides a previous --color option. - The default when output goes to something other than a - terminal (e.g. a pipe, or a shell redirection). + --color Force color output. The default when printing to a terminal. + If both --color and --no-color is present, --no-color prevails. + --no-color Don't print in color. The default when output goes to + something other than a terminal (e.g. a pipe, or a shell + redirection). + If both --color and --no-color is present, --no-color prevails. --no-indent Don't indent instructions. @@ -58,9 +70,7 @@ logical transformation from src to dst, in src's id-space. argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; - -static bool is_assembly(const char* path) { +bool is_assembly(const char* path) { const char* suffix = strrchr(path, '.'); if (suffix == nullptr) { return false; @@ -69,10 +79,10 @@ static bool is_assembly(const char* path) { return strcmp(suffix, ".spvasm") == 0; } -static std::unique_ptr load_module(const char* path) { +std::unique_ptr load_module(const char* path) { if (is_assembly(path)) { std::vector contents; - if (!ReadTextFile(path, &contents)) return {}; + if (!ReadTextFile(path, &contents)) return {}; return spvtools::BuildModule( kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, @@ -82,108 +92,69 @@ static std::unique_ptr load_module(const char* path) { } std::vector contents; - if (!ReadBinaryFile(path, &contents)) return {}; + if (!ReadBinaryFile(path, &contents)) return {}; return spvtools::BuildModule(kDefaultEnvironment, spvtools::utils::CLIMessageConsumer, contents.data(), contents.size()); } -int main(int argc, char** argv) { - const char* src_file = nullptr; - const char* dst_file = nullptr; - bool color_is_possible = -#if SPIRV_COLOR_TERMINAL - true; -#else - false; -#endif - bool force_color = false; - bool force_no_color = false; - bool allow_indent = true; - bool no_header = false; - bool dump_id_map = false; - bool ignore_set_binding = false; - bool ignore_location = false; +} // namespace - for (int argi = 1; argi < argc; ++argi) { - if ('-' == argv[argi][0]) { - switch (argv[argi][1]) { - case 'h': - print_usage(argv[0]); - return 0; - case '-': { - // Long options - if (strcmp(argv[argi], "--no-color") == 0) { - force_no_color = true; - force_color = false; - } else if (strcmp(argv[argi], "--color") == 0) { - force_no_color = false; - force_color = true; - } else if (strcmp(argv[argi], "--no-indent") == 0) { - allow_indent = false; - } else if (strcmp(argv[argi], "--no-header") == 0) { - no_header = true; - } else if (strcmp(argv[argi], "--with-id-map") == 0) { - dump_id_map = true; - } else if (strcmp(argv[argi], "--ignore-set-binding") == 0) { - ignore_set_binding = true; - } else if (strcmp(argv[argi], "--ignore-location") == 0) { - ignore_location = true; - } else if (strcmp(argv[argi], "--help") == 0) { - print_usage(argv[0]); - return 0; - } else if (strcmp(argv[argi], "--version") == 0) { - printf("%s\n", spvSoftwareVersionDetailsString()); - printf("Target: %s\n", - spvTargetEnvDescription(kDefaultEnvironment)); - return 0; - } else { - print_usage(argv[0]); - return 1; - } - } break; - default: - print_usage(argv[0]); - return 1; - } - } else { - if (src_file == nullptr) { - src_file = argv[argi]; - } else if (dst_file == nullptr) { - dst_file = argv[argi]; - } else { - fprintf(stderr, "error: More than two input files specified\n"); - return 1; - } - } - } +// clang-format off +FLAG_SHORT_bool(h, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( help, /* default_value= */ false, /* required= */false); +FLAG_LONG_bool( version, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( color, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( no_color, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( no_indent, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( no_header, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( with_id_map, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( ignore_set_binding, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( ignore_location, /* default_value= */ false, /* required= */ false); +// clang-format on - if (src_file == nullptr || dst_file == nullptr) { - print_usage(argv[0]); +int main(int, const char* argv[]) { + if (!flags::Parse(argv)) { return 1; } - spvtools::diff::Options options; - - if (allow_indent) options.indent = true; - if (no_header) options.no_header = true; - if (dump_id_map) options.dump_id_map = true; - if (ignore_set_binding) options.ignore_set_binding = true; - if (ignore_location) options.ignore_location = true; - - if (color_is_possible && !force_no_color) { - bool output_is_tty = true; -#if defined(_POSIX_VERSION) - output_is_tty = isatty(fileno(stdout)); -#endif - if (output_is_tty || force_color) { - options.color_output = true; - } + if (flags::h.value() || flags::help.value()) { + print_usage(argv[0]); + return 0; } - std::unique_ptr src = load_module(src_file); - std::unique_ptr dst = load_module(dst_file); + if (flags::version.value()) { + printf("%s\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", spvTargetEnvDescription(kDefaultEnvironment)); + return 0; + } + + if (flags::positional_arguments.size() != 2) { + fprintf(stderr, "error: two input files required.\n"); + return 1; + } + +#if defined(_POSIX_VERSION) + const bool output_is_tty = isatty(fileno(stdout)); +#else + const bool output_is_tty = true; +#endif + + const std::string& src_file = flags::positional_arguments[0]; + const std::string& dst_file = flags::positional_arguments[1]; + + spvtools::diff::Options options; + options.color_output = (output_is_tty || flags::color.value()) && + !flags::no_color.value() && kColorIsPossible; + options.indent = !flags::no_indent.value(); + options.no_header = flags::no_header.value(); + options.dump_id_map = flags::with_id_map.value(); + options.ignore_set_binding = flags::ignore_set_binding.value(); + options.ignore_location = flags::ignore_location.value(); + + std::unique_ptr src = load_module(src_file.c_str()); + std::unique_ptr dst = load_module(dst_file.c_str()); if (!src) { fprintf(stderr, "error: Loading src file\n"); diff --git a/third_party/spirv-tools/tools/dis/dis.cpp b/third_party/spirv-tools/tools/dis/dis.cpp index 64380db06f..c294d039ce 100644 --- a/third_party/spirv-tools/tools/dis/dis.cpp +++ b/third_party/spirv-tools/tools/dis/dis.cpp @@ -24,49 +24,95 @@ #include "spirv-tools/libspirv.h" #include "tools/io.h" +#include "tools/util/flags.h" -static void print_usage(char* argv0) { - printf( - R"(%s - Disassemble a SPIR-V binary module +static const std::string kHelpText = R"(%s - Disassemble a SPIR-V binary module Usage: %s [options] [] The SPIR-V binary is read from . If no file is specified, or if the filename is "-", then the binary is read from standard input. +A text-based hex stream is also accepted as binary input, which should either +consist of 32-bit words or 8-bit bytes. The 0x or x prefix is optional, but +should be consistently present in the stream. + Options: - -h, --help Print this help. - --version Display disassembler version information. + -h, --help Print this help. + --version Display disassembler version information. - -o Set the output filename. - Output goes to standard output if this option is - not specified, or if the filename is "-". + -o Set the output filename. + Output goes to standard output if this option is + not specified, or if the filename is "-". - --color Force color output. The default when printing to a terminal. - Overrides a previous --no-color option. - --no-color Don't print in color. Overrides a previous --color option. - The default when output goes to something other than a - terminal (e.g. a file, a pipe, or a shell redirection). + --color Force color output. The default when printing to a terminal. + Overrides a previous --no-color option. + --no-color Don't print in color. Overrides a previous --color option. + The default when output goes to something other than a + terminal (e.g. a file, a pipe, or a shell redirection). - --no-indent Don't indent instructions. + --no-indent Don't indent instructions. - --no-header Don't output the header as leading comments. + --no-header Don't output the header as leading comments. - --raw-id Show raw Id values instead of friendly names. + --raw-id Show raw Id values instead of friendly names. - --offsets Show byte offsets for each instruction. + --nested-indent Indentation is adjusted to indicate nesting in structured + control flow. - --comment Add comments to make reading easier -)", - argv0, argv0); -} + --reorder-blocks Reorder blocks to match the structured control flow of SPIR-V. + With this option, the order of instructions will no longer + match the input binary, but the result will be more readable. + + --offsets Show byte offsets for each instruction. + + --comment Add comments to make reading easier +)"; + +// clang-format off +FLAG_SHORT_bool (h, /* default_value= */ false, /* required= */ false); +FLAG_SHORT_string(o, /* default_value= */ "-", /* required= */ false); +FLAG_LONG_bool (help, /* default_value= */ false, /* required= */false); +FLAG_LONG_bool (version, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (color, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (no_color, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (no_indent, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (no_header, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (raw_id, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (nested_indent, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (reorder_blocks, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (offsets, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool (comment, /* default_value= */ false, /* required= */ false); +// clang-format on static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; -int main(int argc, char** argv) { - const char* inFile = nullptr; - const char* outFile = nullptr; +int main(int, const char** argv) { + if (!flags::Parse(argv)) { + return 1; + } + + if (flags::h.value() || flags::help.value()) { + printf(kHelpText.c_str(), argv[0], argv[0]); + return 0; + } + + if (flags::version.value()) { + printf("%s\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", spvTargetEnvDescription(kDefaultEnvironment)); + return 0; + } + + if (flags::positional_arguments.size() > 1) { + fprintf(stderr, "error: more than one input file specified.\n"); + return 1; + } + + const std::string inFile = flags::positional_arguments.size() == 0 + ? "-" + : flags::positional_arguments[0]; + const std::string outFile = flags::o.value(); bool color_is_possible = #if SPIRV_COLOR_TERMINAL @@ -74,105 +120,36 @@ int main(int argc, char** argv) { #else false; #endif - bool force_color = false; - bool force_no_color = false; - - bool allow_indent = true; - bool show_byte_offsets = false; - bool no_header = false; - bool friendly_names = true; - bool comments = false; - - for (int argi = 1; argi < argc; ++argi) { - if ('-' == argv[argi][0]) { - switch (argv[argi][1]) { - case 'h': - print_usage(argv[0]); - return 0; - case 'o': { - if (!outFile && argi + 1 < argc) { - outFile = argv[++argi]; - } else { - print_usage(argv[0]); - return 1; - } - } break; - case '-': { - // Long options - if (0 == strcmp(argv[argi], "--no-color")) { - force_no_color = true; - force_color = false; - } else if (0 == strcmp(argv[argi], "--color")) { - force_no_color = false; - force_color = true; - } else if (0 == strcmp(argv[argi], "--comment")) { - comments = true; - } else if (0 == strcmp(argv[argi], "--no-indent")) { - allow_indent = false; - } else if (0 == strcmp(argv[argi], "--offsets")) { - show_byte_offsets = true; - } else if (0 == strcmp(argv[argi], "--no-header")) { - no_header = true; - } else if (0 == strcmp(argv[argi], "--raw-id")) { - friendly_names = false; - } else if (0 == strcmp(argv[argi], "--help")) { - print_usage(argv[0]); - return 0; - } else if (0 == strcmp(argv[argi], "--version")) { - printf("%s\n", spvSoftwareVersionDetailsString()); - printf("Target: %s\n", - spvTargetEnvDescription(kDefaultEnvironment)); - return 0; - } else { - print_usage(argv[0]); - return 1; - } - } break; - case 0: { - // Setting a filename of "-" to indicate stdin. - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } break; - default: - print_usage(argv[0]); - return 1; - } - } else { - if (!inFile) { - inFile = argv[argi]; - } else { - fprintf(stderr, "error: More than one input file specified\n"); - return 1; - } - } - } uint32_t options = SPV_BINARY_TO_TEXT_OPTION_NONE; - if (allow_indent) options |= SPV_BINARY_TO_TEXT_OPTION_INDENT; + if (!flags::no_indent.value()) options |= SPV_BINARY_TO_TEXT_OPTION_INDENT; - if (show_byte_offsets) options |= SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET; + if (flags::offsets.value()) + options |= SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET; - if (no_header) options |= SPV_BINARY_TO_TEXT_OPTION_NO_HEADER; + if (flags::no_header.value()) options |= SPV_BINARY_TO_TEXT_OPTION_NO_HEADER; - if (friendly_names) options |= SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES; + if (!flags::raw_id.value()) + options |= SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES; - if (comments) options |= SPV_BINARY_TO_TEXT_OPTION_COMMENT; + if (flags::nested_indent.value()) + options |= SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT; - if (!outFile || (0 == strcmp("-", outFile))) { + if (flags::reorder_blocks.value()) + options |= SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS; + + if (flags::comment.value()) options |= SPV_BINARY_TO_TEXT_OPTION_COMMENT; + + if (flags::o.value() == "-") { // Print to standard output. options |= SPV_BINARY_TO_TEXT_OPTION_PRINT; - - if (color_is_possible && !force_no_color) { + if (color_is_possible && !flags::no_color.value()) { bool output_is_tty = true; #if defined(_POSIX_VERSION) output_is_tty = isatty(fileno(stdout)); #endif - if (output_is_tty || force_color) { + if (output_is_tty || flags::color.value()) { options |= SPV_BINARY_TO_TEXT_OPTION_COLOR; } } @@ -180,7 +157,7 @@ int main(int argc, char** argv) { // Read the input binary. std::vector contents; - if (!ReadBinaryFile(inFile, &contents)) return 1; + if (!ReadBinaryFile(inFile.c_str(), &contents)) return 1; // If printing to standard output, then spvBinaryToText should // do the printing. In particular, colour printing on Windows is @@ -205,7 +182,7 @@ int main(int argc, char** argv) { } if (!print_to_stdout) { - if (!WriteFile(outFile, "w", text->str, text->length)) { + if (!WriteFile(outFile.c_str(), "w", text->str, text->length)) { spvTextDestroy(text); return 1; } diff --git a/third_party/spirv-tools/tools/fuzz/fuzz.cpp b/third_party/spirv-tools/tools/fuzz/fuzz.cpp index ca6633a6ce..391d338981 100644 --- a/third_party/spirv-tools/tools/fuzz/fuzz.cpp +++ b/third_party/spirv-tools/tools/fuzz/fuzz.cpp @@ -41,12 +41,6 @@ namespace { enum class FuzzingTarget { kSpirv, kWgsl }; -// Check that the std::system function can actually be used. -bool CheckExecuteCommand() { - int res = std::system(nullptr); - return res != 0; -} - // Execute a command using the shell. // Returns true if and only if the command's exit status was 0. bool ExecuteCommand(const std::string& command) { @@ -590,8 +584,7 @@ bool Fuzz(const spv_target_env& target_env, [donor_filename, message_consumer, target_env]() -> std::unique_ptr { std::vector donor_binary; - if (!ReadBinaryFile(donor_filename.c_str(), - &donor_binary)) { + if (!ReadBinaryFile(donor_filename.c_str(), &donor_binary)) { return nullptr; } return spvtools::BuildModule(target_env, message_consumer, @@ -679,7 +672,7 @@ void DumpTransformationsJson( const spvtools::fuzz::protobufs::TransformationSequence& transformations, const char* filename) { std::string json_string; - auto json_options = google::protobuf::util::JsonOptions(); + auto json_options = google::protobuf::util::JsonPrintOptions(); json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations, &json_string, json_options); @@ -718,7 +711,7 @@ int main(int argc, const char** argv) { } std::vector binary_in; - if (!ReadBinaryFile(in_binary_file.c_str(), &binary_in)) { + if (!ReadBinaryFile(in_binary_file.c_str(), &binary_in)) { return 1; } @@ -770,11 +763,6 @@ int main(int argc, const char** argv) { } break; case FuzzActions::SHRINK: { - if (!CheckExecuteCommand()) { - std::cerr << "could not find shell interpreter for executing a command" - << std::endl; - return 1; - } if (!Shrink(target_env, fuzzer_options, validator_options, binary_in, initial_facts, shrink_transformations_file, shrink_temp_file_prefix, interestingness_test, &binary_out, @@ -812,7 +800,7 @@ int main(int argc, const char** argv) { } std::string json_string; - auto json_options = google::protobuf::util::JsonOptions(); + auto json_options = google::protobuf::util::JsonPrintOptions(); json_options.add_whitespace = true; auto json_generation_status = google::protobuf::util::MessageToJsonString( transformations_applied, &json_string, json_options); diff --git a/third_party/spirv-tools/tools/io.cpp b/third_party/spirv-tools/tools/io.cpp new file mode 100644 index 0000000000..9c7d21f723 --- /dev/null +++ b/third_party/spirv-tools/tools/io.cpp @@ -0,0 +1,476 @@ +// Copyright (c) 2024 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "io.h" + +#include +#include +#include + +#if defined(SPIRV_WINDOWS) +#include +#include + +#define SET_STDIN_TO_BINARY_MODE() _setmode(_fileno(stdin), O_BINARY); +#define SET_STDIN_TO_TEXT_MODE() _setmode(_fileno(stdin), O_TEXT); +#define SET_STDOUT_TO_BINARY_MODE() _setmode(_fileno(stdout), O_BINARY); +#define SET_STDOUT_TO_TEXT_MODE() _setmode(_fileno(stdout), O_TEXT); +#define SET_STDOUT_MODE(mode) _setmode(_fileno(stdout), mode); +#else +#define SET_STDIN_TO_BINARY_MODE() +#define SET_STDIN_TO_TEXT_MODE() +#define SET_STDOUT_TO_BINARY_MODE() 0 +#define SET_STDOUT_TO_TEXT_MODE() 0 +#define SET_STDOUT_MODE(mode) +#endif + +namespace { +// Appends the contents of the |file| to |data|, assuming each element in the +// file is of type |T|. +template +void ReadFile(FILE* file, std::vector* data) { + if (file == nullptr) return; + + const int buf_size = 4096 / sizeof(T); + T buf[buf_size]; + while (size_t len = fread(buf, sizeof(T), buf_size, file)) { + data->insert(data->end(), buf, buf + len); + } +} + +// Returns true if |file| has encountered an error opening the file or reading +// from it. If there was an error, writes an error message to standard error. +bool WasFileCorrectlyRead(FILE* file, const char* filename) { + if (file == nullptr) { + fprintf(stderr, "error: file does not exist '%s'\n", filename); + return false; + } + + if (ftell(file) == -1L) { + if (ferror(file)) { + fprintf(stderr, "error: error reading file '%s'\n", filename); + return false; + } + } + return true; +} + +// Ensure the file contained an exact number of elements, whose size is given in +// |alignment|. +bool WasFileSizeAligned(const char* filename, size_t read_size, + size_t alignment) { + assert(alignment != 1); + if ((read_size % alignment) != 0) { + fprintf(stderr, + "error: file size should be a multiple of %zd; file '%s' corrupt\n", + alignment, filename); + return false; + } + return true; +} + +// Different formats the hex is expected to be in. +enum class HexMode { + // 0x07230203, ... + Words, + // 0x07, 0x23, 0x02, 0x03, ... + BytesBigEndian, + // 0x03, 0x02, 0x23, 0x07, ... + BytesLittleEndian, + // 07 23 02 03 ... + StreamBigEndian, + // 03 02 23 07 ... + StreamLittleEndian, +}; + +// Whether a character should be skipped as whitespace / separator / +// end-of-file. +bool IsSpace(char c) { return isspace(c) || c == ',' || c == '\0'; } + +bool IsHexStream(const std::vector& stream) { + for (char c : stream) { + if (IsSpace(c)) { + continue; + } + + // Every possible case of a SPIR-V hex stream starts with either '0' or 'x' + // (see |HexMode| values). Make a decision upon inspecting the first + // non-space character. + return c == '0' || c == 'x' || c == 'X'; + } + + return false; +} + +bool MatchIgnoreCase(const char* token, const char* expect, size_t len) { + for (size_t i = 0; i < len; ++i) { + if (tolower(token[i]) != tolower(expect[i])) { + return false; + } + } + + return true; +} + +// Helper class to tokenize a hex stream +class HexTokenizer { + public: + HexTokenizer(const char* filename, const std::vector& stream, + std::vector* data) + : filename_(filename), stream_(stream), data_(data) { + DetermineMode(); + } + + bool Parse() { + while (current_ < stream_.size() && !encountered_error_) { + data_->push_back(GetNextWord()); + + // Make sure trailing space does not lead to parse error by skipping it + // and exiting the loop. + SkipSpace(); + } + + return !encountered_error_; + } + + private: + void ParseError(const char* reason) { + if (!encountered_error_) { + fprintf(stderr, + "error: hex stream parse error at character %zu: %s in '%s'\n", + current_, reason, filename_); + encountered_error_ = true; + } + } + + // Skip whitespace until the next non-whitespace non-comma character. + void SkipSpace() { + while (current_ < stream_.size()) { + char c = stream_[current_]; + if (!IsSpace(c)) { + return; + } + + ++current_; + } + } + + // Skip the 0x or x at the beginning of a hex value. + void Skip0x() { + // The first character must be 0 or x. + const char first = Next(); + if (first != '0' && first != 'x' && first != 'X') { + ParseError("expected 0x or x"); + } else if (first == '0') { + const char second = Next(); + if (second != 'x' && second != 'X') { + ParseError("expected 0x"); + } + } + } + + // Consume the next character. + char Next() { return current_ < stream_.size() ? stream_[current_++] : '\0'; } + + // Determine how to read the hex stream based on the first token. + void DetermineMode() { + SkipSpace(); + + // Read 11 bytes, that is the size of the biggest token (10) + one more. + char first_token[11]; + for (uint32_t i = 0; i < 11; ++i) { + first_token[i] = Next(); + } + + // Table of how to match the first token with a mode. + struct { + const char* expect; + bool must_have_delimiter; + HexMode mode; + } parse_info[] = { + {"0x07230203", true, HexMode::Words}, + {"0x7230203", true, HexMode::Words}, + {"x07230203", true, HexMode::Words}, + {"x7230203", true, HexMode::Words}, + + {"0x07", true, HexMode::BytesBigEndian}, + {"0x7", true, HexMode::BytesBigEndian}, + {"x07", true, HexMode::BytesBigEndian}, + {"x7", true, HexMode::BytesBigEndian}, + + {"0x03", true, HexMode::BytesLittleEndian}, + {"0x3", true, HexMode::BytesLittleEndian}, + {"x03", true, HexMode::BytesLittleEndian}, + {"x3", true, HexMode::BytesLittleEndian}, + + {"07", false, HexMode::StreamBigEndian}, + {"03", false, HexMode::StreamLittleEndian}, + }; + + // Check to see if any of the possible first tokens are matched. If not, + // this is not a recognized hex stream. + encountered_error_ = true; + for (const auto& info : parse_info) { + const size_t expect_len = strlen(info.expect); + const bool matches_expect = + MatchIgnoreCase(first_token, info.expect, expect_len); + const bool satisfies_delimeter = + !info.must_have_delimiter || IsSpace(first_token[expect_len]); + if (matches_expect && satisfies_delimeter) { + mode_ = info.mode; + encountered_error_ = false; + break; + } + } + + if (encountered_error_) { + fprintf(stderr, + "error: hex format detected, but pattern '%.11s' is not " + "recognized '%s'\n", + first_token, filename_); + } + + // Reset the position to restart parsing with the determined mode. + current_ = 0; + } + + // Consume up to |max_len| characters and put them in |token_chars|. A + // delimiter is expected. The resulting string is NUL-terminated. + void NextN(char token_chars[9], size_t max_len) { + assert(max_len < 9); + + for (size_t i = 0; i <= max_len; ++i) { + char c = Next(); + if (IsSpace(c)) { + token_chars[i] = '\0'; + return; + } + + token_chars[i] = c; + if (!isxdigit(c)) { + ParseError("encountered non-hex character"); + } + } + + // If space is not reached before the maximum number of characters where + // consumed, that's an error. + ParseError("expected delimiter (space or comma)"); + token_chars[max_len] = '\0'; + } + + // Consume one hex digit. + char NextHexDigit() { + char c = Next(); + if (!isxdigit(c)) { + ParseError("encountered non-hex character"); + } + return c; + } + + // Extract a token out of the stream. It could be either a word or a byte, + // based on |mode_|. + uint32_t GetNextToken() { + SkipSpace(); + + // The longest token can be 8 chars (for |HexMode::Words|), add one for + // '\0'. + char token_chars[9]; + + switch (mode_) { + case HexMode::Words: + case HexMode::BytesBigEndian: + case HexMode::BytesLittleEndian: + // Start with 0x, followed by up to 8 (for Word) or 2 (for Byte*) + // digits. + Skip0x(); + NextN(token_chars, mode_ == HexMode::Words ? 8 : 2); + break; + case HexMode::StreamBigEndian: + case HexMode::StreamLittleEndian: + // Always expected to see two consecutive hex digits. + token_chars[0] = NextHexDigit(); + token_chars[1] = NextHexDigit(); + token_chars[2] = '\0'; + break; + } + + if (encountered_error_) { + return 0; + } + + // Parse the hex value that was just read. + return static_cast(strtol(token_chars, nullptr, 16)); + } + + // Construct a word out of tokens + uint32_t GetNextWord() { + if (mode_ == HexMode::Words) { + return GetNextToken(); + } + + uint32_t tokens[4] = { + GetNextToken(), + GetNextToken(), + GetNextToken(), + GetNextToken(), + }; + + switch (mode_) { + case HexMode::BytesBigEndian: + case HexMode::StreamBigEndian: + return tokens[0] << 24 | tokens[1] << 16 | tokens[2] << 8 | tokens[3]; + case HexMode::BytesLittleEndian: + case HexMode::StreamLittleEndian: + return tokens[3] << 24 | tokens[2] << 16 | tokens[1] << 8 | tokens[0]; + default: + assert(false); + return 0; + } + } + + const char* filename_; + const std::vector& stream_; + std::vector* data_; + + HexMode mode_ = HexMode::Words; + size_t current_ = 0; + bool encountered_error_ = false; +}; +} // namespace + +bool ReadBinaryFile(const char* filename, std::vector* data) { + assert(data->empty()); + + const bool use_file = filename && strcmp("-", filename); + FILE* fp = nullptr; + if (use_file) { + fp = fopen(filename, "rb"); + } else { + SET_STDIN_TO_BINARY_MODE(); + fp = stdin; + } + + // Read into a char vector first. If this is a hex stream, it needs to be + // processed as such. + std::vector data_raw; + ReadFile(fp, &data_raw); + bool succeeded = WasFileCorrectlyRead(fp, filename); + if (use_file && fp) fclose(fp); + + if (!succeeded) { + return false; + } + + if (IsHexStream(data_raw)) { + // If a hex stream, parse it and fill |data|. + HexTokenizer tokenizer(filename, data_raw, data); + succeeded = tokenizer.Parse(); + } else { + // If not a hex stream, convert it to uint32_t via memcpy. + succeeded = WasFileSizeAligned(filename, data_raw.size(), sizeof(uint32_t)); + if (succeeded) { + data->resize(data_raw.size() / sizeof(uint32_t), 0); + memcpy(data->data(), data_raw.data(), data_raw.size()); + } + } + + return succeeded; +} + +bool ConvertHexToBinary(const std::vector& stream, + std::vector* data) { + HexTokenizer tokenizer("", stream, data); + return tokenizer.Parse(); +} + +bool ReadTextFile(const char* filename, std::vector* data) { + assert(data->empty()); + + const bool use_file = filename && strcmp("-", filename); + FILE* fp = nullptr; + if (use_file) { + fp = fopen(filename, "r"); + } else { + SET_STDIN_TO_TEXT_MODE(); + fp = stdin; + } + + ReadFile(fp, data); + bool succeeded = WasFileCorrectlyRead(fp, filename); + if (use_file && fp) fclose(fp); + return succeeded; +} + +namespace { +// A class to create and manage a file for outputting data. +class OutputFile { + public: + // Opens |filename| in the given mode. If |filename| is nullptr, the empty + // string or "-", stdout will be set to the given mode. + OutputFile(const char* filename, const char* mode) : old_mode_(0) { + const bool use_stdout = + !filename || (filename[0] == '-' && filename[1] == '\0'); + if (use_stdout) { + if (strchr(mode, 'b')) { + old_mode_ = SET_STDOUT_TO_BINARY_MODE(); + } else { + old_mode_ = SET_STDOUT_TO_TEXT_MODE(); + } + fp_ = stdout; + } else { + fp_ = fopen(filename, mode); + } + } + + ~OutputFile() { + if (fp_ == stdout) { + fflush(stdout); + SET_STDOUT_MODE(old_mode_); + } else if (fp_ != nullptr) { + fclose(fp_); + } + } + + // Returns a file handle to the file. + FILE* GetFileHandle() const { return fp_; } + + private: + FILE* fp_; + int old_mode_; +}; +} // namespace + +template +bool WriteFile(const char* filename, const char* mode, const T* data, + size_t count) { + OutputFile file(filename, mode); + FILE* fp = file.GetFileHandle(); + if (fp == nullptr) { + fprintf(stderr, "error: could not open file '%s'\n", filename); + return false; + } + + size_t written = fwrite(data, sizeof(T), count, fp); + if (count != written) { + fprintf(stderr, "error: could not write to file '%s'\n", filename); + return false; + } + + return true; +} + +template bool WriteFile(const char* filename, const char* mode, + const uint32_t* data, size_t count); +template bool WriteFile(const char* filename, const char* mode, + const char* data, size_t count); diff --git a/third_party/spirv-tools/tools/io.h b/third_party/spirv-tools/tools/io.h index 9dc834edfb..536009d531 100644 --- a/third_party/spirv-tools/tools/io.h +++ b/third_party/spirv-tools/tools/io.h @@ -20,144 +20,39 @@ #include #include -#if defined(SPIRV_WINDOWS) -#include -#include - -#define SET_STDIN_TO_BINARY_MODE() _setmode(_fileno(stdin), O_BINARY); -#define SET_STDIN_TO_TEXT_MODE() _setmode(_fileno(stdin), O_TEXT); -#define SET_STDOUT_TO_BINARY_MODE() _setmode(_fileno(stdout), O_BINARY); -#define SET_STDOUT_TO_TEXT_MODE() _setmode(_fileno(stdout), O_TEXT); -#define SET_STDOUT_MODE(mode) _setmode(_fileno(stdout), mode); -#else -#define SET_STDIN_TO_BINARY_MODE() -#define SET_STDIN_TO_TEXT_MODE() -#define SET_STDOUT_TO_BINARY_MODE() 0 -#define SET_STDOUT_TO_TEXT_MODE() 0 -#define SET_STDOUT_MODE(mode) -#endif - -// Appends the contents of the |file| to |data|, assuming each element in the -// file is of type |T|. -template -void ReadFile(FILE* file, std::vector* data) { - if (file == nullptr) return; - - const int buf_size = 1024; - T buf[buf_size]; - while (size_t len = fread(buf, sizeof(T), buf_size, file)) { - data->insert(data->end(), buf, buf + len); - } -} - -// Returns true if |file| has encountered an error opening the file or reading -// the file as a series of element of type |T|. If there was an error, writes an -// error message to standard error. -template -bool WasFileCorrectlyRead(FILE* file, const char* filename) { - if (file == nullptr) { - fprintf(stderr, "error: file does not exist '%s'\n", filename); - return false; - } - - if (ftell(file) == -1L) { - if (ferror(file)) { - fprintf(stderr, "error: error reading file '%s'\n", filename); - return false; - } - } else { - if (sizeof(T) != 1 && (ftell(file) % sizeof(T))) { - fprintf( - stderr, - "error: file size should be a multiple of %zd; file '%s' corrupt\n", - sizeof(T), filename); - return false; - } - } - return true; -} - -// Appends the contents of the file named |filename| to |data|, assuming -// each element in the file is of type |T|. The file is opened as a binary file -// If |filename| is nullptr or "-", reads from the standard input, but +// Sets the contents of the file named |filename| in |data|, assuming each +// element in the file is of type |uint32_t|. The file is opened as a binary +// file. If |filename| is nullptr or "-", reads from the standard input, but // reopened as a binary file. If any error occurs, writes error messages to // standard error and returns false. -template -bool ReadBinaryFile(const char* filename, std::vector* data) { - const bool use_file = filename && strcmp("-", filename); - FILE* fp = nullptr; - if (use_file) { - fp = fopen(filename, "rb"); - } else { - SET_STDIN_TO_BINARY_MODE(); - fp = stdin; - } +// +// If the given input is detected to be in ascii hex, it is converted to binary +// automatically. In that case, the shape of the input data is determined based +// on the representation of the magic number: +// +// * "[0]x[0]7230203": Every following "0x..." represents a word. +// * "[0]x[0]7[,] [0]x23...": Every following "0x..." represents a byte, stored +// in big-endian order +// * "[0]x[0]3[,] [0]x[0]2...": Every following "0x..." represents a byte, +// stored in little-endian order +// * "07[, ]23...": Every following "XY" represents a byte, stored in +// big-endian order +// * "03[, ]02...": Every following "XY" represents a byte, stored in +// little-endian order +bool ReadBinaryFile(const char* filename, std::vector* data); - ReadFile(fp, data); - bool succeeded = WasFileCorrectlyRead(fp, filename); - if (use_file && fp) fclose(fp); - return succeeded; -} +// The hex->binary logic of |ReadBinaryFile| applied to a pre-loaded stream of +// bytes. Used by tests to avoid having to call |ReadBinaryFile| with temp +// files. Returns false in case of parse errors. +bool ConvertHexToBinary(const std::vector& stream, + std::vector* data); -// Appends the contents of the file named |filename| to |data|, assuming -// each element in the file is of type |T|. The file is opened as a text file -// If |filename| is nullptr or "-", reads from the standard input, but -// reopened as a text file. If any error occurs, writes error messages to -// standard error and returns false. -template -bool ReadTextFile(const char* filename, std::vector* data) { - const bool use_file = filename && strcmp("-", filename); - FILE* fp = nullptr; - if (use_file) { - fp = fopen(filename, "r"); - } else { - SET_STDIN_TO_TEXT_MODE(); - fp = stdin; - } - - ReadFile(fp, data); - bool succeeded = WasFileCorrectlyRead(fp, filename); - if (use_file && fp) fclose(fp); - return succeeded; -} - -namespace { -// A class to create and manage a file for outputting data. -class OutputFile { - public: - // Opens |filename| in the given mode. If |filename| is nullptr, the empty - // string or "-", stdout will be set to the given mode. - OutputFile(const char* filename, const char* mode) { - const bool use_stdout = - !filename || (filename[0] == '-' && filename[1] == '\0'); - if (use_stdout) { - if (strchr(mode, 'b')) { - old_mode_ = SET_STDOUT_TO_BINARY_MODE(); - } else { - old_mode_ = SET_STDOUT_TO_TEXT_MODE(); - } - fp_ = stdout; - } else { - fp_ = fopen(filename, mode); - } - } - - ~OutputFile() { - if (fp_ == stdout) { - SET_STDOUT_MODE(old_mode_); - } else if (fp_ != nullptr) { - fclose(fp_); - } - } - - // Returns a file handle to the file. - FILE* GetFileHandle() const { return fp_; } - - private: - FILE* fp_; - int old_mode_; -}; -} // namespace +// Sets the contents of the file named |filename| in |data|, assuming each +// element in the file is of type |char|. The file is opened as a text file. If +// |filename| is nullptr or "-", reads from the standard input, but reopened as +// a text file. If any error occurs, writes error messages to standard error and +// returns false. +bool ReadTextFile(const char* filename, std::vector* data); // Writes the given |data| into the file named as |filename| using the given // |mode|, assuming |data| is an array of |count| elements of type |T|. If @@ -165,21 +60,6 @@ class OutputFile { // returns false and outputs error message to standard error. template bool WriteFile(const char* filename, const char* mode, const T* data, - size_t count) { - OutputFile file(filename, mode); - FILE* fp = file.GetFileHandle(); - if (fp == nullptr) { - fprintf(stderr, "error: could not open file '%s'\n", filename); - return false; - } - - size_t written = fwrite(data, sizeof(T), count, fp); - if (count != written) { - fprintf(stderr, "error: could not write to file '%s'\n", filename); - return false; - } - - return true; -} + size_t count); #endif // TOOLS_IO_H_ diff --git a/third_party/spirv-tools/tools/link/linker.cpp b/third_party/spirv-tools/tools/link/linker.cpp index bdddeb899e..2f47dd4bb1 100644 --- a/third_party/spirv-tools/tools/link/linker.cpp +++ b/third_party/spirv-tools/tools/link/linker.cpp @@ -14,6 +14,7 @@ #include "spirv-tools/linker.hpp" +#include #include #include #include @@ -22,10 +23,11 @@ #include "source/table.h" #include "spirv-tools/libspirv.hpp" #include "tools/io.h" +#include "tools/util/flags.h" namespace { -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +constexpr auto kDefaultEnvironment = "spv1.6"; void print_usage(const char* program) { std::string target_env_list = spvTargetEnvList(16, 80); @@ -46,6 +48,10 @@ Options (in lexicographical order): --allow-partial-linkage Allow partial linkage by accepting imported symbols to be unresolved. + --allow-pointer-mismatch + Allow pointer function parameters to mismatch the target link + target. This is useful to workaround lost correct parameter type + information due to LLVM's opaque pointers. --create-library Link the binaries into a library, keeping all exported symbols. -h, --help @@ -57,6 +63,13 @@ Options (in lexicographical order): NOTE: The SPIR-V version used by the linked binary module depends only on the version of the inputs, and is not affected by this option. + --use-highest-version + Upgrade the output SPIR-V version to the highest of the input + files, instead of requiring all of them to have the same + version. + NOTE: If one of the older input files uses an instruction that + is deprecated in the highest SPIR-V version, the output will + be invalid. --verify-ids Verify that IDs in the resulting modules are truly unique. --version @@ -67,65 +80,62 @@ Options (in lexicographical order): } // namespace -int main(int argc, char** argv) { - std::vector inFiles; - const char* outFile = nullptr; - spv_target_env target_env = kDefaultEnvironment; - spvtools::LinkerOptions options; +// clang-format off +FLAG_SHORT_bool( h, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( help, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( version, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( verify_ids, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( create_library, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( allow_partial_linkage, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( allow_pointer_mismatch, /* default_value= */ false, /* required= */ false); +FLAG_SHORT_string(o, /* default_value= */ "", /* required= */ false); +FLAG_LONG_string( target_env, /* default_value= */ kDefaultEnvironment, /* required= */ false); +FLAG_LONG_bool( use_highest_version, /* default_value= */ false, /* required= */ false); +// clang-format on - for (int argi = 1; argi < argc; ++argi) { - const char* cur_arg = argv[argi]; - if ('-' == cur_arg[0]) { - if (0 == strcmp(cur_arg, "-o")) { - if (argi + 1 < argc) { - if (!outFile) { - outFile = argv[++argi]; - } else { - fprintf(stderr, "error: More than one output file specified\n"); - return 1; - } - } else { - fprintf(stderr, "error: Missing argument to %s\n", cur_arg); - return 1; - } - } else if (0 == strcmp(cur_arg, "--allow-partial-linkage")) { - options.SetAllowPartialLinkage(true); - } else if (0 == strcmp(cur_arg, "--create-library")) { - options.SetCreateLibrary(true); - } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) { - print_usage(argv[0]); - return 0; - } else if (0 == strcmp(cur_arg, "--target-env")) { - if (argi + 1 < argc) { - const auto env_str = argv[++argi]; - if (!spvParseTargetEnv(env_str, &target_env)) { - fprintf(stderr, "error: Unrecognized target env: %s\n", env_str); - return 1; - } - } else { - fprintf(stderr, "error: Missing argument to --target-env\n"); - return 1; - } - } else if (0 == strcmp(cur_arg, "--verify-ids")) { - options.SetVerifyIds(true); - } else if (0 == strcmp(cur_arg, "--version")) { - printf("%s\n", spvSoftwareVersionDetailsString()); - printf("Target: %s\n", spvTargetEnvDescription(target_env)); - return 0; - } else { - fprintf(stderr, "error: Unrecognized option: %s\n\n", argv[argi]); - print_usage(argv[0]); - return 1; - } - } else { - inFiles.push_back(cur_arg); +int main(int, const char* argv[]) { + if (!flags::Parse(argv)) { + return 1; + } + + if (flags::h.value() || flags::help.value()) { + print_usage(argv[0]); + return 0; + } + + if (flags::version.value()) { + spv_target_env target_env; + bool success = spvParseTargetEnv(kDefaultEnvironment, &target_env); + assert(success && "Default environment should always parse."); + if (!success) { + fprintf(stderr, + "error: invalid default target environment. Please report this " + "issue."); + return 1; } + printf("%s\n", spvSoftwareVersionDetailsString()); + printf("Target: %s\n", spvTargetEnvDescription(target_env)); + return 0; } - if (!outFile) { - outFile = "out.spv"; + spv_target_env target_env; + if (!spvParseTargetEnv(flags::target_env.value().c_str(), &target_env)) { + fprintf(stderr, "error: Unrecognized target env: %s\n", + flags::target_env.value().c_str()); + return 1; } + const std::string outFile = + flags::o.value().empty() ? "out.spv" : flags::o.value(); + const std::vector& inFiles = flags::positional_arguments; + + spvtools::LinkerOptions options; + options.SetAllowPartialLinkage(flags::allow_partial_linkage.value()); + options.SetAllowPtrTypeMismatch(flags::allow_pointer_mismatch.value()); + options.SetCreateLibrary(flags::create_library.value()); + options.SetVerifyIds(flags::verify_ids.value()); + options.SetUseHighestVersion(flags::use_highest_version.value()); + if (inFiles.empty()) { fprintf(stderr, "error: No input file specified\n"); return 1; @@ -133,7 +143,7 @@ int main(int argc, char** argv) { std::vector> contents(inFiles.size()); for (size_t i = 0u; i < inFiles.size(); ++i) { - if (!ReadBinaryFile(inFiles[i], &contents[i])) return 1; + if (!ReadBinaryFile(inFiles[i].c_str(), &contents[i])) return 1; } const spvtools::MessageConsumer consumer = [](spv_message_level_t level, @@ -165,7 +175,7 @@ int main(int argc, char** argv) { spv_result_t status = Link(context, contents, &linkingResult, options); if (status != SPV_SUCCESS && status != SPV_WARNING) return 1; - if (!WriteFile(outFile, "wb", linkingResult.data(), + if (!WriteFile(outFile.c_str(), "wb", linkingResult.data(), linkingResult.size())) return 1; diff --git a/third_party/spirv-tools/tools/lint/lint.cpp b/third_party/spirv-tools/tools/lint/lint.cpp index d37df830f1..00c6cd2048 100644 --- a/third_party/spirv-tools/tools/lint/lint.cpp +++ b/third_party/spirv-tools/tools/lint/lint.cpp @@ -18,58 +18,57 @@ #include "spirv-tools/linter.hpp" #include "tools/io.h" #include "tools/util/cli_consumer.h" - -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +#include "tools/util/flags.h" namespace { -// Status and actions to perform after parsing command-line arguments. -enum LintActions { LINT_CONTINUE, LINT_STOP }; -struct LintStatus { - LintActions action; - int code; -}; +constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; +constexpr auto kHelpTextFmt = + R"(%s - Lint a SPIR-V binary module. -// Parses command-line flags. |argc| contains the number of command-line flags. -// |argv| points to an array of strings holding the flags. -// -// On return, this function stores the name of the input program in |in_file|. -// The return value indicates whether optimization should continue and a status -// code indicating an error or success. -LintStatus ParseFlags(int argc, const char** argv, const char** in_file) { - // TODO (dongja): actually parse flags, etc. - if (argc != 2) { - spvtools::Error(spvtools::utils::CLIMessageConsumer, nullptr, {}, - "expected exactly one argument: in_file"); - return {LINT_STOP, 1}; - } +Usage: %s [options] - *in_file = argv[1]; +Options: + + -h, --help Print this help. + --version Display assembler version information. +)"; - return {LINT_CONTINUE, 0}; -} } // namespace -int main(int argc, const char** argv) { - const char* in_file = nullptr; +// clang-format off +FLAG_SHORT_bool( h, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( help, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( version, /* default_value= */ false, /* required= */ false); +// clang-format on - spv_target_env target_env = kDefaultEnvironment; - - spvtools::Linter linter(target_env); - linter.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); - - LintStatus status = ParseFlags(argc, argv, &in_file); - - if (status.action == LINT_STOP) { - return status.code; - } - - std::vector binary; - if (!ReadBinaryFile(in_file, &binary)) { +int main(int, const char** argv) { + if (!flags::Parse(argv)) { return 1; } - bool ok = linter.Run(binary.data(), binary.size()); + if (flags::h.value() || flags::help.value()) { + printf(kHelpTextFmt, argv[0], argv[0]); + return 0; + } - return ok ? 0 : 1; + if (flags::version.value()) { + printf("%s\n", spvSoftwareVersionDetailsString()); + return 0; + } + + if (flags::positional_arguments.size() != 1) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, nullptr, {}, + "expected exactly one input file."); + return 1; + } + + spvtools::Linter linter(kDefaultEnvironment); + linter.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); + std::vector binary; + if (!ReadBinaryFile(flags::positional_arguments[0].c_str(), &binary)) { + return 1; + } + + return linter.Run(binary.data(), binary.size()) ? 0 : 1; } diff --git a/third_party/spirv-tools/tools/objdump/extract_source.cpp b/third_party/spirv-tools/tools/objdump/extract_source.cpp new file mode 100644 index 0000000000..02959525c6 --- /dev/null +++ b/third_party/spirv-tools/tools/objdump/extract_source.cpp @@ -0,0 +1,213 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 "extract_source.h" + +#include +#include +#include +#include + +#include "source/opt/log.h" +#include "spirv-tools/libspirv.hpp" +#include "spirv/unified1/spirv.hpp" +#include "tools/util/cli_consumer.h" + +namespace { + +constexpr auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; + +// Extract a string literal from a given range. +// Copies all the characters from `begin` to the first '\0' it encounters, while +// removing escape patterns. +// Not finding a '\0' before reaching `end` fails the extraction. +// +// Returns `true` if the extraction succeeded. +// `output` value is undefined if false is returned. +spv_result_t ExtractStringLiteral(const spv_position_t& loc, const char* begin, + const char* end, std::string* output) { + size_t sourceLength = std::distance(begin, end); + std::string escapedString; + escapedString.resize(sourceLength); + + size_t writeIndex = 0; + size_t readIndex = 0; + for (; readIndex < sourceLength; writeIndex++, readIndex++) { + const char read = begin[readIndex]; + if (read == '\0') { + escapedString.resize(writeIndex); + output->append(escapedString); + return SPV_SUCCESS; + } + + if (read == '\\') { + ++readIndex; + } + escapedString[writeIndex] = begin[readIndex]; + } + + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, + "Missing NULL terminator for literal string."); + return SPV_ERROR_INVALID_BINARY; +} + +spv_result_t extractOpString(const spv_position_t& loc, + const spv_parsed_instruction_t& instruction, + std::string* output) { + assert(output != nullptr); + assert(instruction.opcode == spv::Op::OpString); + if (instruction.num_operands != 2) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, + "Missing operands for OpString."); + return SPV_ERROR_INVALID_BINARY; + } + + const auto& operand = instruction.operands[1]; + const char* stringBegin = + reinterpret_cast(instruction.words + operand.offset); + const char* stringEnd = reinterpret_cast( + instruction.words + operand.offset + operand.num_words); + return ExtractStringLiteral(loc, stringBegin, stringEnd, output); +} + +spv_result_t extractOpSourceContinued( + const spv_position_t& loc, const spv_parsed_instruction_t& instruction, + std::string* output) { + assert(output != nullptr); + assert(instruction.opcode == spv::Op::OpSourceContinued); + if (instruction.num_operands != 1) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, + "Missing operands for OpSourceContinued."); + return SPV_ERROR_INVALID_BINARY; + } + + const auto& operand = instruction.operands[0]; + const char* stringBegin = + reinterpret_cast(instruction.words + operand.offset); + const char* stringEnd = reinterpret_cast( + instruction.words + operand.offset + operand.num_words); + return ExtractStringLiteral(loc, stringBegin, stringEnd, output); +} + +spv_result_t extractOpSource(const spv_position_t& loc, + const spv_parsed_instruction_t& instruction, + spv::Id* filename, std::string* code) { + assert(filename != nullptr && code != nullptr); + assert(instruction.opcode == spv::Op::OpSource); + // OpCode [ Source Language | Version | File (optional) | Source (optional) ] + if (instruction.num_words < 3) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, + "Missing operands for OpSource."); + return SPV_ERROR_INVALID_BINARY; + } + + *filename = 0; + *code = ""; + if (instruction.num_words < 4) { + return SPV_SUCCESS; + } + *filename = instruction.words[3]; + + if (instruction.num_words < 5) { + return SPV_SUCCESS; + } + + const char* stringBegin = + reinterpret_cast(instruction.words + 4); + const char* stringEnd = + reinterpret_cast(instruction.words + instruction.num_words); + return ExtractStringLiteral(loc, stringBegin, stringEnd, code); +} + +} // namespace + +bool ExtractSourceFromModule( + const std::vector& binary, + std::unordered_map* output) { + auto context = spvtools::SpirvTools(kDefaultEnvironment); + context.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); + + // There is nothing valuable in the header. + spvtools::HeaderParser headerParser = [](const spv_endianness_t, + const spv_parsed_header_t&) { + return SPV_SUCCESS; + }; + + std::unordered_map stringMap; + std::vector> sources; + spv::Op lastOpcode = spv::Op::OpMax; + size_t instructionIndex = 0; + + spvtools::InstructionParser instructionParser = + [&stringMap, &sources, &lastOpcode, + &instructionIndex](const spv_parsed_instruction_t& instruction) { + const spv_position_t loc = {0, 0, instructionIndex + 1}; + spv_result_t result = SPV_SUCCESS; + + if (instruction.opcode == spv::Op::OpString) { + std::string content; + result = extractOpString(loc, instruction, &content); + if (result == SPV_SUCCESS) { + stringMap.emplace(instruction.result_id, std::move(content)); + } + } else if (instruction.opcode == spv::Op::OpSource) { + spv::Id filenameId; + std::string code; + result = extractOpSource(loc, instruction, &filenameId, &code); + if (result == SPV_SUCCESS) { + sources.emplace_back(std::make_pair(filenameId, std::move(code))); + } + } else if (instruction.opcode == spv::Op::OpSourceContinued) { + if (lastOpcode != spv::Op::OpSource) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, + "OpSourceContinued MUST follow an OpSource."); + return SPV_ERROR_INVALID_BINARY; + } + + assert(sources.size() > 0); + result = extractOpSourceContinued(loc, instruction, + &sources.back().second); + } + + ++instructionIndex; + lastOpcode = static_cast(instruction.opcode); + return result; + }; + + if (!context.Parse(binary, headerParser, instructionParser)) { + return false; + } + + std::string defaultName = "unnamed-"; + size_t unnamedCount = 0; + for (auto & [ id, code ] : sources) { + std::string filename; + const auto it = stringMap.find(id); + if (it == stringMap.cend() || it->second.empty()) { + filename = "unnamed-" + std::to_string(unnamedCount) + ".hlsl"; + ++unnamedCount; + } else { + filename = it->second; + } + + if (output->count(filename) != 0) { + spvtools::Error(spvtools::utils::CLIMessageConsumer, "", {}, + "Source file name conflict."); + return false; + } + output->insert({filename, code}); + } + + return true; +} diff --git a/third_party/spirv-tools/tools/objdump/extract_source.h b/third_party/spirv-tools/tools/objdump/extract_source.h new file mode 100644 index 0000000000..3e5ecfa958 --- /dev/null +++ b/third_party/spirv-tools/tools/objdump/extract_source.h @@ -0,0 +1,39 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ +#define INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ + +#include +#include +#include +#include + +// Parse a SPIR-V module, and extracts all HLSL source code from it. +// This function doesn't lift the SPIR-V code, but only relies on debug symbols. +// This means if the compiler didn't include some files, they won't show up. +// +// Returns a map of extracted from it. +// - `binary`: a vector containing the whole SPIR-V binary to extract source +// from. +// - `output`: mapping, mapping each filename +// (if defined) to its code. +// +// Returns `true` if the extraction succeeded, `false` otherwise. +// `output` value is undefined if `false` is returned. +bool ExtractSourceFromModule( + const std::vector& binary, + std::unordered_map* output); + +#endif // INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ diff --git a/third_party/spirv-tools/tools/objdump/objdump.cpp b/third_party/spirv-tools/tools/objdump/objdump.cpp new file mode 100644 index 0000000000..79181b0acd --- /dev/null +++ b/third_party/spirv-tools/tools/objdump/objdump.cpp @@ -0,0 +1,174 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 +#include + +#include "extract_source.h" +#include "source/opt/log.h" +#include "tools/io.h" +#include "tools/util/cli_consumer.h" +#include "tools/util/flags.h" + +namespace { + +constexpr auto kHelpTextFmt = + R"(%s - Dumps information from a SPIR-V binary. + +Usage: %s [options] + +one of the following switches must be given: + --source Extract source files obtained from debug symbols, output to stdout. + --entrypoint Extracts the entrypoint name of the module, output to stdout. + --compiler-cmd Extracts the command line used to compile this module, output to stdout. + + +General options: + -h, --help Print this help. + --version Display assembler version information. + -f,--force Allow output file overwrite. + +Source dump options: + --list Do not extract source code, only print filenames to stdout. + --outdir Where shall the exrtacted HLSL/HLSL files be written to? + File written to stdout if '-' is given. Default is `-`. +)"; + +// Removes trailing '/' from `input`. +// A behavior difference has been observed between libc++ implementations. +// Fixing path to prevent this edge case to be reached. +// (https://github.com/llvm/llvm-project/issues/60634) +std::string fixPathForLLVM(std::string input) { + while (!input.empty() && input.back() == '/') input.resize(input.size() - 1); + return input; +} + +// Write each HLSL file described in `sources` in a file in `outdirPath`. +// Doesn't ovewrite existing files, unless `overwrite` is set to true. The +// created HLSL file's filename is the path's filename obtained from `sources`. +// Returns true if all files could be written. False otherwise. +bool OutputSourceFiles( + const std::unordered_map& sources, + const std::string& outdirPath, bool overwrite) { + std::filesystem::path outdir(fixPathForLLVM(outdirPath)); + if (!std::filesystem::is_directory(outdir)) { + if (!std::filesystem::create_directories(outdir)) { + std::cerr << "error: could not create output directory " << outdir + << std::endl; + return false; + } + } + + for (const auto & [ filepath, code ] : sources) { + if (code.empty()) { + std::cout << "Ignoring source for " << filepath + << ": no code source in debug infos." << std::endl; + continue; + } + + std::filesystem::path old_path(filepath); + std::filesystem::path new_path = outdir / old_path.filename(); + + if (!overwrite && std::filesystem::exists(new_path)) { + std::cerr << "file " << filepath + << " already exists, aborting (use --overwrite to allow it)." + << std::endl; + return false; + } + + std::cout << "Exporting " << new_path << std::endl; + if (!WriteFile(new_path.string().c_str(), "w", code.c_str(), + code.size())) { + return false; + } + } + return true; +} + +} // namespace + +// clang-format off +FLAG_SHORT_bool( h, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( help, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( version, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( source, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( entrypoint, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( compiler_cmd, /* default_value= */ false, /* required= */ false); +FLAG_SHORT_bool( f, /* default_value= */ false, /* required= */ false); +FLAG_LONG_bool( force, /* default_value= */ false, /* required= */ false); +FLAG_LONG_string( outdir, /* default_value= */ "-", /* required= */ false); +FLAG_LONG_bool( list, /* default_value= */ false, /* required= */ false); +// clang-format on + +int main(int, const char** argv) { + if (!flags::Parse(argv)) { + return 1; + } + if (flags::h.value() || flags::help.value()) { + printf(kHelpTextFmt, argv[0], argv[0]); + return 0; + } + if (flags::version.value()) { + printf("%s\n", spvSoftwareVersionDetailsString()); + return 0; + } + + if (flags::positional_arguments.size() != 1) { + std::cerr << "Expected exactly one input file." << std::endl; + return 1; + } + if (flags::entrypoint.value() || flags::compiler_cmd.value()) { + std::cerr << "Unimplemented flags." << std::endl; + return 1; + } + + std::vector binary; + if (!ReadBinaryFile(flags::positional_arguments[0].c_str(), &binary)) { + return 1; + } + + if (flags::source.value()) { + std::unordered_map sourceCode; + if (!ExtractSourceFromModule(binary, &sourceCode)) { + return 1; + } + + if (flags::list.value()) { + for (const auto & [ filename, source ] : sourceCode) { + printf("%s\n", filename.c_str()); + } + return 0; + } + + const bool outputToConsole = flags::outdir.value() == "-"; + + if (outputToConsole) { + for (const auto & [ filename, source ] : sourceCode) { + std::cout << filename << ":" << std::endl + << source << std::endl + << std::endl; + } + return 0; + } + + const std::filesystem::path outdirPath(flags::outdir.value()); + if (!OutputSourceFiles(sourceCode, outdirPath.string(), + flags::force.value())) { + return 1; + } + } + + // FIXME: implement logic. + return 0; +} diff --git a/third_party/spirv-tools/tools/opt/opt.cpp b/third_party/spirv-tools/tools/opt/opt.cpp index ce2103ca8a..07a57252d4 100644 --- a/third_party/spirv-tools/tools/opt/opt.cpp +++ b/third_party/spirv-tools/tools/opt/opt.cpp @@ -181,6 +181,14 @@ Options (in lexicographical order):)", must be in OpAccessChain instructions with a literal index for the first index.)"); printf(R"( + --descriptor-composite-scalar-replacement + Same as descriptor-scalar-replacement, but only impacts composite/structs. + For details, see --descriptor-scalar-replacement help.)"); + printf(R"( + --descriptor-array-scalar-replacement + Same as descriptor-scalar-replacement, but only impacts arrays. + For details, see --descriptor-scalar-replacement help.)"); + printf(R"( --eliminate-dead-branches Convert conditional branches with constant condition to the indicated unconditional branch. Delete all resulting dead @@ -335,6 +343,12 @@ Options (in lexicographical order):)", These conditions are guaranteed to be met after running dead-branch elimination.)"); printf(R"( + --modify-maximal-reconvergence=[add|remove] + Add or remove the MaximallyReconvergesKHR execution mode to all + entry points in the module. + Note: when adding the execution mode, no attempt is made to + determine if any ray tracing repack instructions are used.)"); + printf(R"( --loop-unswitch Hoists loop-invariant conditionals out of loops by duplicating the loop on each branch of the conditional and adjusting each @@ -392,6 +406,11 @@ Options (in lexicographical order):)", Ensure that the optimizer preserves all bindings declared within the module, even when those bindings are unused.)"); printf(R"( + --preserve-interface + Ensure that input and output variables are not removed from the + shader, even if they are unused. Note that this option applies to + all passes that will be run regardless of the order of the flags.)"); + printf(R"( --preserve-spec-constants Ensure that the optimizer preserves all specialization constants declared within the module, even when those constants are unused.)"); @@ -496,6 +515,14 @@ Options (in lexicographical order):)", covers reflection information defined by SPV_GOOGLE_hlsl_functionality1 and SPV_KHR_non_semantic_info)"); printf(R"( + --struct-packing=name:rule + Re-assign layout offsets to a given struct according to + its packing rules.)"); + printf(R"( + --switch-descriptorset=: + Switch any DescriptoSet decorations using the value to + the new value .)"); + printf(R"( --target-env= Set the target environment. Without this flag the target environment defaults to spv1.5. must be one of @@ -510,6 +537,10 @@ Options (in lexicographical order):)", USR/SYS time are returned by getrusage() and can have a small error.)"); printf(R"( + --trim-capabilities + Remove unnecessary capabilities and extensions declared within the + module.)"); + printf(R"( --upgrade-memory-model Upgrades the Logical GLSL450 memory model to Logical VulkanKHR. Transforms memory, image, atomic and barrier operations to conform @@ -697,6 +728,7 @@ OptStatus ParseFlags(int argc, const char** argv, spvtools::ValidatorOptions* validator_options, spvtools::OptimizerOptions* optimizer_options) { std::vector pass_flags; + bool preserve_interface = true; for (int argi = 1; argi < argc; ++argi) { const char* cur_arg = argv[argi]; if ('-' == cur_arg[0]) { @@ -786,6 +818,8 @@ OptStatus ParseFlags(int argc, const char** argv, validator_options->SetSkipBlockLayout(true); } else if (0 == strcmp(cur_arg, "--relax-struct-store")) { validator_options->SetRelaxStructStore(true); + } else if (0 == strcmp(cur_arg, "--preserve-interface")) { + preserve_interface = true; } else { // Some passes used to accept the form '--pass arg', canonicalize them // to '--pass=arg'. @@ -808,7 +842,7 @@ OptStatus ParseFlags(int argc, const char** argv, } } - if (!optimizer->RegisterPassesFromFlags(pass_flags)) { + if (!optimizer->RegisterPassesFromFlags(pass_flags, preserve_interface)) { return {OPT_STOP, 1}; } @@ -842,7 +876,7 @@ int main(int argc, const char** argv) { } std::vector binary; - if (!ReadBinaryFile(in_file, &binary)) { + if (!ReadBinaryFile(in_file, &binary)) { return 1; } diff --git a/third_party/spirv-tools/tools/reduce/reduce.cpp b/third_party/spirv-tools/tools/reduce/reduce.cpp index 37600543a8..143779989e 100644 --- a/third_party/spirv-tools/tools/reduce/reduce.cpp +++ b/third_party/spirv-tools/tools/reduce/reduce.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -29,12 +30,6 @@ namespace { -// Check that the std::system function can actually be used. -bool CheckExecuteCommand() { - int res = std::system(nullptr); - return res != 0; -} - // Execute a command using the shell. // Returns true if and only if the command's exit status was 0. bool ExecuteCommand(const std::string& command) { @@ -282,12 +277,6 @@ int main(int argc, const char** argv) { return status.code; } - if (!CheckExecuteCommand()) { - std::cerr << "could not find shell interpreter for executing a command" - << std::endl; - return 2; - } - spvtools::reduce::Reducer reducer(target_env); std::stringstream joined; @@ -318,7 +307,7 @@ int main(int argc, const char** argv) { reducer.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); std::vector binary_in; - if (!ReadBinaryFile(in_binary_file.c_str(), &binary_in)) { + if (!ReadBinaryFile(in_binary_file.c_str(), &binary_in)) { return 1; } diff --git a/third_party/spirv-tools/tools/sva/package.json b/third_party/spirv-tools/tools/sva/package.json index 3072d4cc86..cd6ea67bfb 100644 --- a/third_party/spirv-tools/tools/sva/package.json +++ b/third_party/spirv-tools/tools/sva/package.json @@ -15,11 +15,11 @@ "bundle": "rollup -c" }, "devDependencies": { - "chai": "^4.2.0", - "eslint": "^6.3.0", + "chai": "^4.3.7", + "eslint": "^8.41.0", "esm": "^3.2.25", - "mocha": "^6.2.0", - "rollup": "^1.21.4", - "serve": "^11.1.0" + "mocha": "^10.2.0", + "rollup": "^3.29.5", + "serve": "^14.2.0" } } diff --git a/third_party/spirv-tools/tools/sva/src/spirv.data.js b/third_party/spirv-tools/tools/sva/src/spirv.data.js index ba969d86b3..67c0966cdc 100644 --- a/third_party/spirv-tools/tools/sva/src/spirv.data.js +++ b/third_party/spirv-tools/tools/sva/src/spirv.data.js @@ -4376,6 +4376,9 @@ export default { "ShaderClockKHR": { "value": 5055 }, + "QuadControlKHR": { + "value": 5087 + }, "FragmentFullyCoveredEXT": { "value": 5265 }, diff --git a/third_party/spirv-tools/tools/sva/yarn.lock b/third_party/spirv-tools/tools/sva/yarn.lock index e7b735e0e6..38788e2bde 100644 --- a/third_party/spirv-tools/tools/sva/yarn.lock +++ b/third_party/spirv-tools/tools/sva/yarn.lock @@ -2,158 +2,206 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d" - integrity sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw== +"@eslint-community/eslint-utils@^4.2.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== dependencies: - "@babel/highlight" "^7.0.0" + eslint-visitor-keys "^3.3.0" -"@babel/highlight@^7.0.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" - integrity sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ== +"@eslint-community/regexpp@^4.4.0": + version "4.5.1" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" + integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== + +"@eslint/eslintrc@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.3.tgz#4910db5505f4d503f27774bf356e3704818a0331" + integrity sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ== dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^4.0.0" + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.5.2" + globals "^13.19.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" -"@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== +"@eslint/js@8.41.0": + version "8.41.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.41.0.tgz#080321c3b68253522f7646b55b577dd99d2950b3" + integrity sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA== -"@types/node@^12.7.5": - version "12.7.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f" - integrity sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w== +"@humanwhocodes/config-array@^0.11.8": + version "0.11.8" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" + integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== + dependencies: + "@humanwhocodes/object-schema" "^1.2.1" + debug "^4.1.1" + minimatch "^3.0.5" -"@zeit/schemas@2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@zeit/schemas/-/schemas-2.6.0.tgz#004e8e553b4cd53d538bd38eac7bcbf58a867fe3" - integrity sha512-uUrgZ8AxS+Lio0fZKAipJjAh415JyrOZowliZAzmnJSsf7piVL5w+G0+gFJ0KSu3QRhvui/7zuvpLz03YjXAhg== +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/object-schema@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.8": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@zeit/schemas@2.29.0": + version "2.29.0" + resolved "https://registry.yarnpkg.com/@zeit/schemas/-/schemas-2.29.0.tgz#a59ae6ebfdf4ddc66a876872dd736baa58b6696c" + integrity sha512-g5QiLIfbg3pLuYUJPlisNKY+epQJTcMDsOnVNkscrDP1oi7vmJnzOANYJI/1pZcVJ6umUkBv3aFtlg1UvUHGzA== accepts@~1.3.5: - version "1.3.7" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" - integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== dependencies: - mime-types "~2.1.24" - negotiator "0.6.2" + mime-types "~2.1.34" + negotiator "0.6.3" -acorn-jsx@^5.0.2: +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn@^8.8.0: + version "8.8.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" + integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== + +ajv@8.11.0: + version "8.11.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f" + integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" + +ajv@^6.10.0, ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-align@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.1.tgz#0cdf12e111ace773a86e9a1fad1225c43cb19a59" + integrity sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w== + dependencies: + string-width "^4.1.0" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arch@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/arch/-/arch-2.2.0.tgz#1bc47818f305764f23ab3306b0bfc086c5a29d11" + integrity sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ== + +arg@5.0.2: version "5.0.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.2.tgz#84b68ea44b373c4f8686023a551f61a21b7c4a4f" - integrity sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw== + resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" + integrity sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg== -acorn@^7.0.0: - version "7.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" - integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== - -ajv@6.5.3: - version "6.5.3" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.3.tgz#71a569d189ecf4f4f321224fecb166f071dd90f9" - integrity sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg== - dependencies: - fast-deep-equal "^2.0.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^6.10.0, ajv@^6.10.2: - version "6.10.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" - integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw== - dependencies: - fast-deep-equal "^2.0.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-align@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" - integrity sha1-w2rsy6VjuJzrVW82kPCx2eNUf38= - dependencies: - string-width "^2.0.0" - -ansi-colors@3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" - integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== - -ansi-escapes@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" - integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= - -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== - -ansi-styles@^3.2.0, ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -arch@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/arch/-/arch-2.1.1.tgz#8f5c2731aa35a30929221bb0640eed65175ec84e" - integrity sha512-BLM56aPo9vLLFVa8+/+pJLnrZ7QGGTVHWsCwieAWT9o9K8UeGaQbzZbGoabWLOo2ksBCztoXdqBZBplqLDDCSg== - -arg@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arg/-/arg-2.0.0.tgz#c06e7ff69ab05b3a4a03ebe0407fac4cba657545" - integrity sha512-XxNTUzKnz1ctK3ZIcI2XUPlD96wbHP2nGqkPKpvk/HNRlPveYrXIVSTk9m3LcqOgDPg3B1nMvdV/K8wZd7PG4w== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== - balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -boxen@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" - integrity sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw== +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +boxen@7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-7.0.0.tgz#9e5f8c26e716793fc96edcf7cf754cdf5e3fbf32" + integrity sha512-j//dBVuyacJbvW+tvZ9HuH03fZ46QcaKvvhZickZqtB271DxJ7SNRSNxrV/dZX0085m7hISRZWbzWlJvx/rHSg== dependencies: - ansi-align "^2.0.0" - camelcase "^4.0.0" - chalk "^2.0.1" - cli-boxes "^1.0.0" - string-width "^2.0.0" - term-size "^1.2.0" - widest-line "^2.0.0" + ansi-align "^3.0.1" + camelcase "^7.0.0" + chalk "^5.0.1" + cli-boxes "^3.0.0" + string-width "^5.1.2" + type-fest "^2.13.0" + widest-line "^4.0.1" + wrap-ansi "^8.0.1" brace-expansion@^1.1.7: version "1.1.11" @@ -163,6 +211,20 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@~3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + browser-stdout@1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" @@ -171,163 +233,154 @@ browser-stdout@1.3.1: bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" - integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= + integrity sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw== callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +camelcase@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-7.0.1.tgz#f02e50af9fd7782bc8b88a3558c32fd3a388f048" + integrity sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw== -chai@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" - integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw== +chai@^4.3.7: + version "4.3.7" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51" + integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A== dependencies: assertion-error "^1.1.0" check-error "^1.0.2" - deep-eql "^3.0.1" + deep-eql "^4.1.2" get-func-name "^2.0.0" - pathval "^1.1.0" + loupe "^2.3.1" + pathval "^1.1.1" type-detect "^4.0.5" -chalk@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" - integrity sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ== +chalk-template@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/chalk-template/-/chalk-template-0.4.0.tgz#692c034d0ed62436b9062c1707fadcd0f753204b" + integrity sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg== dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" + chalk "^4.1.2" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== +chalk@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== + +chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" + ansi-styles "^4.1.0" + supports-color "^7.1.0" -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== +chalk@^5.0.1: + version "5.2.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.2.0.tgz#249623b7d66869c673699fb66d65723e54dfcfb3" + integrity sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA== check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" - integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== -cli-boxes@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" - integrity sha1-T6kXw+WclKAEzWH47lCdplFocUM= - -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" - integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU= +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== dependencies: - restore-cursor "^2.0.0" + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" -cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= +cli-boxes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-3.0.0.tgz#71a10c716feeba005e4504f36329ef0b17cf3145" + integrity sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g== -clipboardy@1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-1.2.3.tgz#0526361bf78724c1f20be248d428e365433c07ef" - integrity sha512-2WNImOvCRe6r63Gk9pShfkwXsVtKCroMAevIbiae021mS850UkWPbevxsBz3tnvjZIEGvlwaqCPsw+4ulzNgJA== +clipboardy@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-3.0.0.tgz#f3876247404d334c9ed01b6f269c11d09a5e3092" + integrity sha512-Su+uU5sr1jkUy1sGRpLKjKrvEOVXgSgiSInwa/qeID6aJ07yh+5NWc3h2QfjHjBnfX4LhtFcuAWKUsJ3r+fjbg== dependencies: - arch "^2.1.0" - execa "^0.8.0" + arch "^2.2.0" + execa "^5.1.1" + is-wsl "^2.2.0" -cliui@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" - integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== dependencies: - string-width "^2.1.1" - strip-ansi "^4.0.0" - wrap-ansi "^2.0.0" + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== dependencies: - color-name "1.1.3" + color-name "~1.1.4" -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -compressible@~2.0.14: - version "2.0.17" - resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.17.tgz#6e8c108a16ad58384a977f3a482ca20bff2f38c1" - integrity sha512-BGHeLCK1GV7j1bSmQQAi26X+GgWcTjLr/0tzSvMCl3LH1w1IJ4PFSPoV5316b30cneTziC+B1a+3OjoSUcQYmw== +compressible@~2.0.16: + version "2.0.18" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" + integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== dependencies: - mime-db ">= 1.40.0 < 2" + mime-db ">= 1.43.0 < 2" -compression@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.3.tgz#27e0e176aaf260f7f2c2813c3e440adb9f1993db" - integrity sha512-HSjyBG5N1Nnz7tF2+O7A9XUhyjru71/fwgNb7oIsEVHR0WShfs2tIS/EySLgiTe98aOK18YDlMXpzjCXY/n9mg== +compression@1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f" + integrity sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ== dependencies: accepts "~1.3.5" bytes "3.0.0" - compressible "~2.0.14" + compressible "~2.0.16" debug "2.6.9" - on-headers "~1.0.1" + on-headers "~1.0.2" safe-buffer "5.1.2" vary "~1.1.2" concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== content-disposition@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" - integrity sha1-DPaLud318r55YcOoUXjLhdunjLQ= + integrity sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA== -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= +cross-spawn@^7.0.2, cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -cross-spawn@^6.0.0, cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" debug@2.6.9: version "2.6.9" @@ -336,29 +389,22 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@3.2.6: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== +debug@4.3.4, debug@^4.1.1, debug@^4.3.2: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: - ms "^2.1.1" + ms "2.1.2" -debug@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -deep-eql@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" - integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== +deep-eql@^4.1.2: + version "4.1.3" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d" + integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw== dependencies: type-detect "^4.0.0" @@ -367,22 +413,15 @@ deep-extend@^0.6.0: resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= +deep-is@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -define-properties@^1.1.2, define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -diff@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" - integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== doctrine@^3.0.0: version "3.0.0" @@ -391,319 +430,254 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== -end-of-stream@^1.1.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" - integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-scope@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.0.tgz#f21ebdafda02352f103634b96dd47d9f81ca117b" + integrity sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw== dependencies: - once "^1.4.0" + esrecurse "^4.3.0" + estraverse "^5.2.0" -es-abstract@^1.5.1: - version "1.14.2" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.14.2.tgz#7ce108fad83068c8783c3cdf62e504e084d8c497" - integrity sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg== +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" + integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== + +eslint@^8.41.0: + version "8.41.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.41.0.tgz#3062ca73363b4714b16dbc1e60f035e6134b6f1c" + integrity sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q== dependencies: - es-to-primitive "^1.2.0" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.0" - is-callable "^1.1.4" - is-regex "^1.0.4" - object-inspect "^1.6.0" - object-keys "^1.1.1" - string.prototype.trimleft "^2.0.0" - string.prototype.trimright "^2.0.0" - -es-to-primitive@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" - integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-scope@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" - integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw== - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-utils@^1.4.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.2.tgz#166a5180ef6ab7eb462f162fd0e6f2463d7309ab" - integrity sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q== - dependencies: - eslint-visitor-keys "^1.0.0" - -eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" - integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== - -eslint@^6.3.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.4.0.tgz#5aa9227c3fbe921982b2eda94ba0d7fae858611a" - integrity sha512-WTVEzK3lSFoXUovDHEbkJqCVPEPwbhCq4trDktNI6ygs7aO41d4cDT0JFAT5MivzZeVLWlg7vHL+bgrQv/t3vA== - dependencies: - "@babel/code-frame" "^7.0.0" + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.4.0" + "@eslint/eslintrc" "^2.0.3" + "@eslint/js" "8.41.0" + "@humanwhocodes/config-array" "^0.11.8" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" - debug "^4.0.1" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.2" - eslint-visitor-keys "^1.1.0" - espree "^6.1.1" - esquery "^1.0.1" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.0" + eslint-visitor-keys "^3.4.1" + espree "^9.5.2" + esquery "^1.4.2" esutils "^2.0.2" - file-entry-cache "^5.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" - globals "^11.7.0" - ignore "^4.0.6" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^6.4.1" is-glob "^4.0.0" - js-yaml "^3.13.1" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" - minimatch "^3.0.4" - mkdirp "^0.5.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.8.2" - progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" - table "^5.2.3" + optionator "^0.9.1" + strip-ansi "^6.0.1" + strip-json-comments "^3.1.0" text-table "^0.2.0" - v8-compile-cache "^2.0.3" esm@^3.2.25: version "3.2.25" resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== -espree@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.1.tgz#7f80e5f7257fc47db450022d723e356daeb1e5de" - integrity sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ== +espree@^9.5.2: + version "9.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.2.tgz#e994e7dc33a082a7a82dceaf12883a829353215b" + integrity sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw== dependencies: - acorn "^7.0.0" - acorn-jsx "^5.0.2" - eslint-visitor-keys "^1.1.0" + acorn "^8.8.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esquery@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" - integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== +esquery@^1.4.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== dependencies: - estraverse "^4.0.0" + estraverse "^5.1.0" -esrecurse@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" - integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== - dependencies: - estraverse "^4.1.0" - -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: +esrecurse@^4.3.0: version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= +execa@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" -execa@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" - integrity sha1-2NdrvBtVIX7RkP1t1J08d07PyNo= - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -execa@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" - integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== - dependencies: - cross-spawn "^6.0.0" - get-stream "^4.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - -fast-deep-equal@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" - integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@~2.0.4: +fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fast-url-parser@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/fast-url-parser/-/fast-url-parser-1.1.3.tgz#f4af3ea9f34d8a271cf58ad2b3759f431f0b318d" - integrity sha1-9K8+qfNNiicc9YrSs3WfQx8LMY0= + integrity sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ== dependencies: punycode "^1.3.2" -figures@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" - integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI= +fastq@^1.6.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== dependencies: - escape-string-regexp "^1.0.5" + reusify "^1.0.4" -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== dependencies: - flat-cache "^2.0.1" + flat-cache "^3.0.4" -find-up@3.0.0, find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: - locate-path "^3.0.0" + to-regex-range "^5.0.1" -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== +find-up@5.0.0, find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" + locate-path "^6.0.0" + path-exists "^4.0.0" -flat@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" - integrity sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw== +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== dependencies: - is-buffer "~2.0.3" + flatted "^3.1.0" + rimraf "^3.0.2" -flatted@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" - integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatted@^3.1.0: + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= - -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== - -get-caller-file@^2.0.1: +get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-func-name@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" - integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + version "2.0.2" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" + integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== -get-stream@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== +glob-parent@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== dependencies: - pump "^3.0.0" + is-glob "^4.0.3" -glob-parent@^5.0.0: +glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@7.1.3: - version "7.1.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" - integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -713,65 +687,53 @@ glob@7.1.3: path-is-absolute "^1.0.0" glob@^7.1.3: - version "7.1.4" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" - integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.1.1" once "^1.3.0" path-is-absolute "^1.0.0" -globals@^11.7.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -growl@1.10.5: - version "1.10.5" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" - integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" - integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= - -has@^1.0.1, has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== +globals@^13.19.0: + version "13.20.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" + integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ== dependencies: - function-bind "^1.1.1" + type-fest "^0.20.2" + +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== he@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -iconv-lite@^0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== +ignore@^5.2.0: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== -import-fresh@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.1.0.tgz#6d33fa1dcef6df930fae003446f33415af905118" - integrity sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ== +import-fresh@^3.0.0, import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== dependencies: parent-module "^1.0.0" resolve-from "^4.0.0" @@ -779,12 +741,12 @@ import-fresh@^3.0.0: imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" @@ -795,193 +757,147 @@ inherits@2: integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== ini@~1.3.0: - version "1.3.7" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84" - integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ== + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -inquirer@^6.4.1: - version "6.5.2" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca" - integrity sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ== +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: - ansi-escapes "^3.2.0" - chalk "^2.4.2" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^2.0.0" - lodash "^4.17.12" - mute-stream "0.0.7" - run-async "^2.2.0" - rxjs "^6.4.0" - string-width "^2.1.0" - strip-ansi "^5.1.0" - through "^2.3.6" + binary-extensions "^2.0.0" -invert-kv@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" - integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== - -is-buffer@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" - integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw== - -is-callable@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" - integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== - -is-date-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" - integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= +is-docker@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= - dependencies: - number-is-nan "^1.0.0" +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - -is-glob@^4.0.0, is-glob@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: is-extglob "^2.1.1" -is-promise@^2.1.0: +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + +is-plain-obj@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= +is-port-reachable@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-port-reachable/-/is-port-reachable-4.0.0.tgz#dac044091ef15319c8ab2f34604d8794181f8c2d" + integrity sha512-9UoipoxYmSk6Xy7QFgRv2HDyaysmgSG75TFQs6S+3pDM7ZhKTF/bskZV+0UlABHzKjNVhPjYCLfeZUEg1wXxig== + +is-stream@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" + integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +is-wsl@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== dependencies: - has "^1.0.1" - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - -is-symbol@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38" - integrity sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw== - dependencies: - has-symbols "^1.0.0" + is-docker "^2.0.0" isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@3.13.1, js-yaml@^3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@4.1.0, js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: - argparse "^1.0.7" - esprima "^4.0.0" + argparse "^2.0.1" json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== -lcid@^2.0.0: +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +loupe@^2.3.1: + version "2.3.6" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" + integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA== + dependencies: + get-func-name "^2.0.0" + +merge-stream@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" - integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== - dependencies: - invert-kv "^2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - -lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log-symbols@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" - integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== - dependencies: - chalk "^2.0.1" - -lru-cache@^4.0.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -map-age-cleaner@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - -mem@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178" - integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w== - dependencies: - map-age-cleaner "^0.1.1" - mimic-fn "^2.0.0" - p-is-promise "^2.0.0" - -mime-db@1.40.0: - version "1.40.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32" - integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA== - -"mime-db@>= 1.40.0 < 2": - version "1.41.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.41.0.tgz#9110408e1f6aa1b34aef51f2c9df3caddf46b6a0" - integrity sha512-B5gxBI+2K431XW8C2rcc/lhppbuji67nf9v39eH8pkWoZDxnAL0PxdpH32KYRScniF8qDHBDlI+ipgg5WrCUYw== +mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== mime-db@~1.33.0: version "1.33.0" @@ -995,237 +911,150 @@ mime-types@2.1.18: dependencies: mime-db "~1.33.0" -mime-types@~2.1.24: - version "2.1.24" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81" - integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ== +mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: - mime-db "1.40.0" + mime-db "1.52.0" -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - -mimic-fn@^2.0.0: +mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -minimatch@3.0.4, minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== +minimatch@3.1.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: brace-expansion "^1.1.7" -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -mkdirp@0.5.1, mkdirp@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= +mocha@^10.2.0: + version "10.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8" + integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg== dependencies: - minimist "0.0.8" - -mocha@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.2.0.tgz#f896b642843445d1bb8bca60eabd9206b8916e56" - integrity sha512-qwfFgY+7EKAAUAdv7VYMZQknI7YJSGesxHyhn6qD52DV8UcSZs5XwCifcZGMVIE4a5fbmhvbotxC0DLQ0oKohQ== - dependencies: - ansi-colors "3.2.3" + ansi-colors "4.1.1" browser-stdout "1.3.1" - debug "3.2.6" - diff "3.5.0" - escape-string-regexp "1.0.5" - find-up "3.0.0" - glob "7.1.3" - growl "1.10.5" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" he "1.2.0" - js-yaml "3.13.1" - log-symbols "2.2.0" - minimatch "3.0.4" - mkdirp "0.5.1" - ms "2.1.1" - node-environment-flags "1.0.5" - object.assign "4.1.0" - strip-json-comments "2.0.1" - supports-color "6.0.0" - which "1.3.1" - wide-align "1.1.3" - yargs "13.2.2" - yargs-parser "13.0.0" - yargs-unparser "1.5.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + nanoid "3.3.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== -ms@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - -ms@^2.1.1: +ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -mute-stream@0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" - integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nanoid@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" + integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -negotiator@0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -node-environment-flags@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a" - integrity sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ== +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== dependencies: - object.getownpropertydescriptors "^2.0.3" - semver "^5.7.0" + path-key "^3.0.0" -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= - -object-inspect@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b" - integrity sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ== - -object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - -object.getownpropertydescriptors@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" - integrity sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY= - dependencies: - define-properties "^1.1.2" - es-abstract "^1.5.1" - -on-headers@~1.0.1: +on-headers@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== -once@^1.3.0, once@^1.3.1, once@^1.4.0: +once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ= +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== dependencies: - mimic-fn "^1.0.0" + mimic-fn "^2.1.0" -optionator@^0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" - integrity sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q= +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.4" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - wordwrap "~1.0.0" + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" -os-locale@^3.0.0, os-locale@^3.1.0: +p-limit@^3.0.2: version "3.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" - integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: - execa "^1.0.0" - lcid "^2.0.0" - mem "^4.0.0" + yocto-queue "^0.1.0" -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" - integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-is-promise@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" - integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== - -p-limit@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.1.tgz#aa07a788cc3151c939b5131f63570f0dd2009537" - integrity sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg== +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== dependencies: - p-try "^2.0.0" - -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== - dependencies: - p-limit "^2.0.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + p-limit "^3.0.2" parent-module@^1.0.0: version "1.0.1" @@ -1234,73 +1063,72 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-is-inside@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= + integrity sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w== -path-key@^2.0.0, path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= +path-key@^3.0.0, path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-to-regexp@2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.2.1.tgz#90b617025a16381a879bc82a38d4e8bdeb2bcf45" - integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ== +path-to-regexp@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-3.3.0.tgz#f7f31d32e8518c2660862b644414b6d5c63a611b" + integrity sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw== -pathval@^1.1.0: +pathval@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== punycode@^1.3.2: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= + integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" range-parser@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" - integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= + integrity sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A== rc@^1.0.1, rc@^1.1.6: version "1.2.8" @@ -1312,10 +1140,12 @@ rc@^1.0.1, rc@^1.1.6: minimist "^1.2.0" strip-json-comments "~2.0.1" -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" registry-auth-token@3.3.2: version "3.3.2" @@ -1328,451 +1158,317 @@ registry-auth-token@3.3.2: registry-url@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" - integrity sha1-PU74cPc93h138M+aOBQyRE4XSUI= + integrity sha512-ZbgR5aZEdf4UKZVBPYIgaglBmSF2Hi94s2PcIHhRGFjKYu+chjJdYfHn4rt3hB6eCKLJ8giVIIfgMa1ehDfZKA== dependencies: rc "^1.0.1" require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== +require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" - integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368= - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: glob "^7.1.3" -rollup@^1.21.4: - version "1.21.4" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.21.4.tgz#00a41a30f90095db890301b226cbe2918e4cf54d" - integrity sha512-Pl512XVCmVzgcBz5h/3Li4oTaoDcmpuFZ+kdhS/wLreALz//WuDAMfomD3QEYl84NkDu6Z6wV9twlcREb4qQsw== - dependencies: - "@types/estree" "0.0.39" - "@types/node" "^12.7.5" - acorn "^7.0.0" +rollup@^3.29.5: + version "3.29.5" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54" + integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w== + optionalDependencies: + fsevents "~2.3.2" -run-async@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" - integrity sha1-A3GrSuC91yDUFm19/aZP96RFpsA= +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== dependencies: - is-promise "^2.1.0" - -rxjs@^6.4.0: - version "6.5.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a" - integrity sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA== - dependencies: - tslib "^1.9.0" + queue-microtask "^1.2.2" safe-buffer@5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.0.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" - integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== +safe-buffer@^5.0.1, safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" -semver@^5.5.0, semver@^5.7.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^6.1.2: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -serve-handler@6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/serve-handler/-/serve-handler-6.1.0.tgz#f1606dc6ff8f9029a1ee042c11dfe7903a5cb92e" - integrity sha512-63N075Tn3PsFYcu0NVV7tb367UbiW3gnC+/50ohL4oqOhAG6bmbaWqiRcXQgbzqc0ALBjSAzg7VTfa0Qw4E3hA== +serve-handler@6.1.5: + version "6.1.5" + resolved "https://registry.yarnpkg.com/serve-handler/-/serve-handler-6.1.5.tgz#a4a0964f5c55c7e37a02a633232b6f0d6f068375" + integrity sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg== dependencies: bytes "3.0.0" content-disposition "0.5.2" fast-url-parser "1.1.3" mime-types "2.1.18" - minimatch "3.0.4" + minimatch "3.1.2" path-is-inside "1.0.2" - path-to-regexp "2.2.1" + path-to-regexp "3.3.0" range-parser "1.2.0" -serve@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/serve/-/serve-11.1.0.tgz#1bfe2f4a08d0130cbf44711cdb7996cb742172e0" - integrity sha512-+4wpDtOSS+4ZLyDWMxThutA3iOTawX2+yDovOI8cjOUOmemyvNlHyFAsezBlSgbZKTYChI3tzA1Mh0z6XZ62qA== +serve@^14.2.0: + version "14.2.0" + resolved "https://registry.yarnpkg.com/serve/-/serve-14.2.0.tgz#3d768e88fa13ad8644f2393599189707176e66b8" + integrity sha512-+HOw/XK1bW8tw5iBilBz/mJLWRzM8XM6MPxL4J/dKzdxq1vfdEWSwhaR7/yS8EJp5wzvP92p1qirysJvnEtjXg== dependencies: - "@zeit/schemas" "2.6.0" - ajv "6.5.3" - arg "2.0.0" - boxen "1.3.0" - chalk "2.4.1" - clipboardy "1.2.3" - compression "1.7.3" - serve-handler "6.1.0" - update-check "1.5.2" + "@zeit/schemas" "2.29.0" + ajv "8.11.0" + arg "5.0.2" + boxen "7.0.0" + chalk "5.0.1" + chalk-template "0.4.0" + clipboardy "3.0.0" + compression "1.7.4" + is-port-reachable "4.0.0" + serve-handler "6.1.5" + update-check "1.5.4" -set-blocking@^2.0.0: +shebang-command@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== dependencies: - shebang-regex "^1.0.0" + shebang-regex "^3.0.0" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +signal-exit@^3.0.3: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" + ansi-regex "^5.0.1" -string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" + ansi-regex "^6.0.1" -string.prototype.trimleft@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz#6cc47f0d7eb8d62b0f3701611715a3954591d634" - integrity sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw== - dependencies: - define-properties "^1.1.3" - function-bind "^1.1.1" +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== -string.prototype.trimright@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz#669d164be9df9b6f7559fa8e89945b168a5a6c58" - integrity sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg== - dependencies: - define-properties "^1.1.3" - function-bind "^1.1.1" +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= - dependencies: - ansi-regex "^3.0.0" - -strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= - -strip-json-comments@2.0.1, strip-json-comments@~2.0.1: +strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== -strip-json-comments@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" - integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== - -supports-color@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" - integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== dependencies: - has-flag "^3.0.0" + has-flag "^4.0.0" -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== dependencies: - has-flag "^3.0.0" - -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== - dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" - -term-size@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" - integrity sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk= - dependencies: - execa "^0.7.0" + has-flag "^4.0.0" text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - os-tmpdir "~1.0.2" + is-number "^7.0.0" -tslib@^1.9.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" - integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== dependencies: - prelude-ls "~1.1.2" + prelude-ls "^1.2.1" type-detect@^4.0.0, type-detect@^4.0.5: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -update-check@1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/update-check/-/update-check-1.5.2.tgz#2fe09f725c543440b3d7dabe8971f2d5caaedc28" - integrity sha512-1TrmYLuLj/5ZovwUS7fFd1jMH3NnFDN1y1A8dboedIDt7zs/zJMo6TwwlhYKkSeEwzleeiSBV5/3c9ufAQWDaQ== +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + +type-fest@^2.13.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b" + integrity sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA== + +update-check@1.5.4: + version "1.5.4" + resolved "https://registry.yarnpkg.com/update-check/-/update-check-1.5.4.tgz#5b508e259558f1ad7dbc8b4b0457d4c9d28c8743" + integrity sha512-5YHsflzHP4t1G+8WGPlvKbJEbAJGCgw+Em+dGR1KmBUbr1J36SJBqlHLjR7oob7sco5hWHGQVcr9B2poIVDDTQ== dependencies: registry-auth-token "3.3.2" registry-url "3.1.0" uri-js@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== dependencies: punycode "^2.1.0" -v8-compile-cache@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" - integrity sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g== - vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@1.3.1, which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" -wide-align@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== +widest-line@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-4.0.1.tgz#a0fc673aaba1ea6f0a0d35b3c2795c9a9cc2ebf2" + integrity sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig== dependencies: - string-width "^1.0.2 || 2" + string-width "^5.0.1" -widest-line@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.1.tgz#7438764730ec7ef4381ce4df82fb98a53142a3fc" - integrity sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA== +word-wrap@^1.2.3: + version "1.2.4" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f" + integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA== + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== dependencies: - string-width "^2.1.1" + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" -wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= - -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= +wrap-ansi@^8.0.1: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== dependencies: - mkdirp "^0.5.1" + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" -"y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== - -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= - -yargs-parser@13.0.0: - version "13.0.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.0.0.tgz#3fc44f3e76a8bdb1cc3602e860108602e5ccde8b" - integrity sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw== +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^11.1.1: - version "11.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" - integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^13.0.0: - version "13.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0" - integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-unparser@1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.5.0.tgz#f2bb2a7e83cbc87bb95c8e572828a06c9add6e0d" - integrity sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw== - dependencies: - flat "^4.1.0" - lodash "^4.17.11" - yargs "^12.0.5" - -yargs@13.2.2: - version "13.2.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.2.tgz#0c101f580ae95cea7f39d927e7770e3fdc97f993" - integrity sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA== - dependencies: - cliui "^4.0.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" - os-locale "^3.1.0" + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^13.0.0" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" -yargs@^12.0.5: - version "12.0.5" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" - integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== - dependencies: - cliui "^4.0.0" - decamelize "^1.2.0" - find-up "^3.0.0" - get-caller-file "^1.0.1" - os-locale "^3.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1 || ^4.0.0" - yargs-parser "^11.1.1" +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/third_party/spirv-tools/tools/util/flags.cpp b/third_party/spirv-tools/tools/util/flags.cpp new file mode 100644 index 0000000000..6198e4ba28 --- /dev/null +++ b/third_party/spirv-tools/tools/util/flags.cpp @@ -0,0 +1,243 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 "flags.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace flags { + +std::vector positional_arguments; + +namespace { + +using token_t = const char*; +using token_iterator_t = token_t*; + +// Extracts the flag name from a potential token. +// This function only looks for a '=', to split the flag name from the value for +// long-form flags. Returns the name of the flag, prefixed with the hyphen(s). +inline std::string get_flag_name(const std::string& flag, bool is_short_flag) { + if (is_short_flag) { + return flag; + } + + size_t equal_index = flag.find('='); + if (equal_index == std::string::npos) { + return flag; + } + return flag.substr(0, equal_index); +} + +// Parse a boolean flag. Returns `true` if the parsing succeeded, `false` +// otherwise. +bool parse_bool_flag(Flag& flag, bool is_short_flag, + const std::string& token) { + if (is_short_flag) { + flag.value() = true; + return true; + } + + const std::string raw_flag(token); + size_t equal_index = raw_flag.find('='); + if (equal_index == std::string::npos) { + flag.value() = true; + return true; + } + + const std::string value = raw_flag.substr(equal_index + 1); + if (value == "true") { + flag.value() = true; + return true; + } + + if (value == "false") { + flag.value() = false; + return true; + } + + return false; +} + +// Parse a uint32_t flag value. +bool parse_flag_value(Flag& flag, const std::string& value) { + std::regex unsigned_pattern("^ *[0-9]+ *$"); + if (!std::regex_match(value, unsigned_pattern)) { + std::cerr << "'" << value << "' is not a unsigned number." << std::endl; + return false; + } + + errno = 0; + char* end_ptr = nullptr; + const uint64_t number = strtoull(value.c_str(), &end_ptr, 10); + if (end_ptr == nullptr || end_ptr != value.c_str() + value.size() || + errno == EINVAL) { + std::cerr << "'" << value << "' is not a unsigned number." << std::endl; + return false; + } + + if (errno == ERANGE || number > static_cast(UINT32_MAX)) { + std::cerr << "'" << value << "' cannot be represented as a 32bit unsigned." + << std::endl; + return false; + } + + flag.value() = static_cast(number); + return true; +} + +// "Parse" a string flag value (assigns it, cannot fail). +bool parse_flag_value(Flag& flag, const std::string& value) { + flag.value() = value; + return true; +} + +// Parse a potential multi-token flag. Moves the iterator to the last flag's +// token if it's a multi-token flag. Returns `true` if the parsing succeeded. +// The iterator is moved to the last parsed token. +template +bool parse_flag(Flag& flag, bool is_short_flag, const char*** iterator) { + const std::string raw_flag(**iterator); + std::string raw_value; + const size_t equal_index = raw_flag.find('='); + + if (is_short_flag || equal_index == std::string::npos) { + if ((*iterator)[1] == nullptr) { + return false; + } + + // This is a bi-token flag. Moving iterator to the last parsed token. + raw_value = (*iterator)[1]; + *iterator += 1; + } else { + // This is a mono-token flag, no need to move the iterator. + raw_value = raw_flag.substr(equal_index + 1); + } + + return parse_flag_value(flag, raw_value); +} + +} // namespace + +// This is the function to expand if you want to support a new type. +bool FlagList::parse_flag_info(FlagInfo& info, token_iterator_t* iterator) { + bool success = false; + + std::visit( + [&](auto&& item) { + using T = std::decay_t; + if constexpr (std::is_same_v>) { + success = parse_bool_flag(item.get(), info.is_short, **iterator); + } else if constexpr (std::is_same_v>) { + success = parse_flag(item.get(), info.is_short, iterator); + } else if constexpr (std::is_same_v>) { + success = parse_flag(item.get(), info.is_short, iterator); + } else { + static_assert(always_false_v, "Unsupported flag type."); + } + }, + info.flag); + + return success; +} + +bool FlagList::parse(token_t* argv) { + flags::positional_arguments.clear(); + std::unordered_set parsed_flags; + + bool ignore_flags = false; + for (const char** it = argv + 1; *it != nullptr; it++) { + if (ignore_flags) { + flags::positional_arguments.emplace_back(*it); + continue; + } + + // '--' alone is used to mark the end of the flags. + if (std::strcmp(*it, "--") == 0) { + ignore_flags = true; + continue; + } + + // '-' alone is not a flag, but often used to say 'stdin'. + if (std::strcmp(*it, "-") == 0) { + flags::positional_arguments.emplace_back(*it); + continue; + } + + const std::string raw_flag(*it); + if (raw_flag.size() == 0) { + continue; + } + + if (raw_flag[0] != '-') { + flags::positional_arguments.emplace_back(*it); + continue; + } + + // Only case left: flags (long and shorts). + if (raw_flag.size() < 2) { + std::cerr << "Unknown flag " << raw_flag << std::endl; + return false; + } + const bool is_short_flag = std::strncmp(*it, "--", 2) != 0; + const std::string flag_name = get_flag_name(raw_flag, is_short_flag); + + auto needle = std::find_if( + get_flags().begin(), get_flags().end(), + [&flag_name](const auto& item) { return item.name == flag_name; }); + if (needle == get_flags().end()) { + std::cerr << "Unknown flag " << flag_name << std::endl; + return false; + } + + if (parsed_flags.count(&*needle) != 0) { + std::cerr << "The flag " << flag_name << " was specified multiple times." + << std::endl; + return false; + } + parsed_flags.insert(&*needle); + + if (!parse_flag_info(*needle, &it)) { + std::cerr << "Invalid usage for flag " << flag_name << std::endl; + return false; + } + } + + // Check that we parsed all required flags. + for (const auto& flag : get_flags()) { + if (!flag.required) { + continue; + } + + if (parsed_flags.count(&flag) == 0) { + std::cerr << "Missing required flag " << flag.name << std::endl; + return false; + } + } + + return true; +} + +// Just the public wrapper around the parse function. +bool Parse(const char** argv) { return FlagList::parse(argv); } + +} // namespace flags diff --git a/third_party/spirv-tools/tools/util/flags.h b/third_party/spirv-tools/tools/util/flags.h new file mode 100644 index 0000000000..20bb3693ba --- /dev/null +++ b/third_party/spirv-tools/tools/util/flags.h @@ -0,0 +1,262 @@ +// Copyright (c) 2023 Google LLC. +// +// 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 INCLUDE_SPIRV_TOOLS_UTIL_FLAGS_HPP_ +#define INCLUDE_SPIRV_TOOLS_UTIL_FLAGS_HPP_ + +#include + +#include +#include +#include +#include + +// This file provides some utils to define a command-line interface with +// required and optional flags. +// - Flag order is not checked. +// - Currently supported flag types: BOOLEAN, STRING +// - As with most nix tools, using '--' in the command-line means all following +// tokens will be considered positional +// arguments. +// Example: binary -g -- -g --some-other-flag +// - the first `-g` is a flag. +// - the second `-g` is not a flag. +// - `--some-other-flag` is not a flag. +// - Both long-form and short-form flags are supported, but boolean flags don't +// support split boolean literals (short and long form). +// Example: +// -g : allowed, sets g to true. +// --my-flag : allowed, sets --my-flag to true. +// --my-flag=true : allowed, sets --my-flag to true. +// --my-flag true : NOT allowed. +// -g true : NOT allowed. +// --my-flag=TRUE : NOT allowed. +// +// - This implementation also supports string flags: +// -o myfile.spv : allowed, sets -o to `myfile.spv`. +// --output=myfile.spv : allowed, sets --output to `myfile.spv`. +// --output myfile.spv : allowd, sets --output to `myfile.spv`. +// +// Note: then second token is NOT checked for hyphens. +// --output -file.spv +// flag name: `output` +// flag value: `-file.spv` +// +// - This implementation generates flag at compile time. Meaning flag names +// must be valid C++ identifiers. +// However, flags are usually using hyphens for word separation. Hence +// renaming is done behind the scenes. Example: +// // Declaring a long-form flag. +// FLAG_LONG_bool(my_flag, [...]) +// +// -> in the code: flags::my_flag.value() +// -> command-line: --my-flag +// +// - The only additional lexing done is around '='. Otherwise token list is +// processed as received in the Parse() +// function. +// Lexing the '=' sign: +// - This is only done when parsing a long-form flag name. +// - the first '=' found is considered a marker for long-form, splitting +// the token into 2. +// Example: --option=value=abc -> [--option, value=abc] +// +// In most cases, you want to define some flags, parse them, and query them. +// Here is a small code sample: +// +// ```c +// // Defines a '-h' boolean flag for help printing, optional. +// FLAG_SHORT_bool(h, /*default=*/ false, "Print the help.", false); +// // Defines a '--my-flag' string flag, required. +// FLAG_LONG_string(my_flag, /*default=*/ "", "A magic flag!", true); +// +// int main(int argc, const char** argv) { +// if (!flags::Parse(argv)) { +// return -1; +// } +// +// if (flags::h.value()) { +// printf("usage: my-bin --my-flag=\n"); +// return 0; +// } +// +// printf("flag value: %s\n", flags::my_flag.value().c_str()); +// for (const std::string& arg : flags::positional_arguments) { +// printf("arg: %s\n", arg.c_str()); +// } +// return 0; +// } +// ```c + +// Those macros can be used to define flags. +// - They should be used in the global scope. +// - Underscores in the flag variable name are replaced with hyphens ('-'). +// +// Example: +// FLAG_SHORT_bool(my_flag, false, "some help", false); +// - in the code: flags::my_flag +// - command line: --my-flag=true +// +#define FLAG_LONG_string(Name, Default, Required) \ + UTIL_FLAGS_FLAG_LONG(std::string, Name, Default, Required) +#define FLAG_LONG_bool(Name, Default, Required) \ + UTIL_FLAGS_FLAG_LONG(bool, Name, Default, Required) +#define FLAG_LONG_uint(Name, Default, Required) \ + UTIL_FLAGS_FLAG_LONG(uint32_t, Name, Default, Required) + +#define FLAG_SHORT_string(Name, Default, Required) \ + UTIL_FLAGS_FLAG_SHORT(std::string, Name, Default, Required) +#define FLAG_SHORT_bool(Name, Default, Required) \ + UTIL_FLAGS_FLAG_SHORT(bool, Name, Default, Required) +#define FLAG_SHORT_uint(Name, Default, Required) \ + UTIL_FLAGS_FLAG_SHORT(uint32_t, Name, Default, Required) + +namespace flags { + +// Parse the command-line arguments, checking flags, and separating positional +// arguments from flags. +// +// * argv: the argv array received in the main function. This utility expects +// the last pointer to +// be NULL, as it should if coming from the main() function. +// +// Returns `true` if the parsing succeeds, `false` otherwise. +bool Parse(const char** argv); + +} // namespace flags + +// ===================== BEGIN NON-PUBLIC SECTION ============================= +// All the code below belongs to the implementation, and there is no guaranteed +// around the API stability. Please do not use it directly. + +// Defines the static variable holding the flag, allowing access like +// flags::my_flag. +// By creating the FlagRegistration object, the flag can be added to +// the global list. +// The final `extern` definition is ONLY useful for clang-format: +// - if the macro doesn't ends with a semicolon, clang-format goes wild. +// - cannot disable clang-format for those macros on clang < 16. +// (https://github.com/llvm/llvm-project/issues/54522) +// - cannot allow trailing semi (-Wextra-semi). +#define UTIL_FLAGS_FLAG(Type, Prefix, Name, Default, Required, IsShort) \ + namespace flags { \ + Flag Name(Default); \ + namespace { \ + static FlagRegistration Name##_registration(Name, Prefix #Name, Required, \ + IsShort); \ + } \ + } \ + extern flags::Flag flags::Name + +#define UTIL_FLAGS_FLAG_LONG(Type, Name, Default, Required) \ + UTIL_FLAGS_FLAG(Type, "--", Name, Default, Required, false) +#define UTIL_FLAGS_FLAG_SHORT(Type, Name, Default, Required) \ + UTIL_FLAGS_FLAG(Type, "-", Name, Default, Required, true) + +namespace flags { + +// Just a wrapper around the flag value. +template +struct Flag { + public: + Flag(T&& default_value) : value_(default_value) {} + Flag(Flag&& other) = delete; + Flag(const Flag& other) = delete; + + const T& value() const { return value_; } + T& value() { return value_; } + + private: + T value_; +}; + +// To add support for new flag-types, this needs to be extended, and the visitor +// below. +using FlagType = std::variant>, + std::reference_wrapper>, + std::reference_wrapper>>; + +template +inline constexpr bool always_false_v = false; + +extern std::vector positional_arguments; + +// Static class keeping track of the flags/arguments values. +class FlagList { + struct FlagInfo { + FlagInfo(FlagType&& flag_, std::string&& name_, bool required_, + bool is_short_) + : flag(std::move(flag_)), + name(std::move(name_)), + required(required_), + is_short(is_short_) {} + + FlagType flag; + std::string name; + bool required; + bool is_short; + }; + + public: + template + static void register_flag(Flag& flag, std::string&& name, bool required, + bool is_short) { + get_flags().emplace_back(flag, std::move(name), required, is_short); + } + + static bool parse(const char** argv); + +#ifdef TESTING + // Flags are supposed to be constant for the whole app execution, hence the + // static storage. Gtest doesn't fork before running a test, meaning we have + // to manually clear the context at teardown. + static void reset() { + get_flags().clear(); + positional_arguments.clear(); + } +#endif + + private: + static std::vector& get_flags() { + static std::vector flags; + return flags; + } + + static bool parse_flag_info(FlagInfo& info, const char*** iterator); + static void print_usage(const char* binary_name, + const std::string& usage_format); +}; + +template +struct FlagRegistration { + FlagRegistration(Flag& flag, std::string&& name, bool required, + bool is_short) { + std::string fixed_name = name; + for (auto& c : fixed_name) { + if (c == '_') { + c = '-'; + } + } + + FlagList::register_flag(flag, std::move(fixed_name), required, is_short); + } +}; + +// Explicit deduction guide to avoid `-Wctad-maybe-unsupported`. +template +FlagRegistration(Flag&, std::string&&, bool, bool) -> FlagRegistration; + +} // namespace flags + +#endif // INCLUDE_SPIRV_TOOLS_UTIL_FLAGS_HPP_ diff --git a/third_party/spirv-tools/tools/val/val.cpp b/third_party/spirv-tools/tools/val/val.cpp index 880ce46b3a..3dbc7f4a52 100644 --- a/third_party/spirv-tools/tools/val/val.cpp +++ b/third_party/spirv-tools/tools/val/val.cpp @@ -66,6 +66,8 @@ Options: members. --allow-localsizeid Allow use of the LocalSizeId decoration where it would otherwise not be allowed by the target environment. + --allow-offset-texture-operand Allow use of the Offset texture operands where it would otherwise not + be allowed by the target environment. --before-hlsl-legalization Allows code patterns that are intended to be fixed by spirv-opt's legalization passes. --version Display validator version information. @@ -111,7 +113,7 @@ int main(int argc, char** argv) { printf("%s\n", spvSoftwareVersionDetailsString()); printf( "Targets:\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n " - "%s\n %s\n %s\n %s\n", + "%s\n %s\n %s\n %s %s\n", spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_0), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_2), @@ -124,7 +126,8 @@ int main(int argc, char** argv) { spvTargetEnvDescription(SPV_ENV_VULKAN_1_1), spvTargetEnvDescription(SPV_ENV_VULKAN_1_1_SPIRV_1_4), spvTargetEnvDescription(SPV_ENV_VULKAN_1_2), - spvTargetEnvDescription(SPV_ENV_VULKAN_1_3)); + spvTargetEnvDescription(SPV_ENV_VULKAN_1_3), + spvTargetEnvDescription(SPV_ENV_VULKAN_1_4)); continue_processing = false; return_code = 0; } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) { @@ -160,6 +163,8 @@ int main(int argc, char** argv) { options.SetSkipBlockLayout(true); } else if (0 == strcmp(cur_arg, "--allow-localsizeid")) { options.SetAllowLocalSizeId(true); + } else if (0 == strcmp(cur_arg, "--allow-offset-texture-operand")) { + options.SetAllowOffsetTextureOperand(true); } else if (0 == strcmp(cur_arg, "--relax-struct-store")) { options.SetRelaxStructStore(true); } else if (0 == cur_arg[1]) { @@ -193,7 +198,7 @@ int main(int argc, char** argv) { } std::vector contents; - if (!ReadBinaryFile(inFile, &contents)) return 1; + if (!ReadBinaryFile(inFile, &contents)) return 1; spvtools::SpirvTools tools(target_env); tools.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); diff --git a/third_party/spirv-tools/utils/check_code_format.sh b/third_party/spirv-tools/utils/check_code_format.sh index 7994740226..da5e019859 100755 --- a/third_party/spirv-tools/utils/check_code_format.sh +++ b/third_party/spirv-tools/utils/check_code_format.sh @@ -18,7 +18,7 @@ # # This script assumes to be invoked at the project root directory. -BASE_BRANCH=${1:-master} +BASE_BRANCH=${1:-main} FILES_TO_CHECK=$(git diff --name-only ${BASE_BRANCH} | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$") diff --git a/third_party/spirv-tools/utils/check_copyright.py b/third_party/spirv-tools/utils/check_copyright.py index aa647af58b..c477ece9af 100755 --- a/third_party/spirv-tools/utils/check_copyright.py +++ b/third_party/spirv-tools/utils/check_copyright.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # coding=utf-8 # Copyright (c) 2016 Google Inc. # @@ -41,8 +41,11 @@ AUTHORS = ['The Khronos Group Inc.', 'Alastair F. Donaldson', 'Mostafa Ashraf', 'Shiyu Liu', - 'ZHOU He'] -CURRENT_YEAR = 2022 + 'ZHOU He', + 'Nintendo', + 'Epic Games, Inc.', + 'NVIDIA Corporation'] +CURRENT_YEAR = 2023 FIRST_YEAR = 2014 FINAL_YEAR = CURRENT_YEAR + 5 diff --git a/third_party/spirv-tools/utils/check_symbol_exports.py b/third_party/spirv-tools/utils/check_symbol_exports.py index 7795d72bc9..e44294fe8b 100755 --- a/third_party/spirv-tools/utils/check_symbol_exports.py +++ b/third_party/spirv-tools/utils/check_symbol_exports.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2017 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -67,7 +67,7 @@ def check_library(library): # by the protobuf compiler: # - AddDescriptors_spvtoolsfuzz_2eproto() # - InitDefaults_spvtoolsfuzz_2eproto() - symbol_allowlist_pattern = re.compile(r'_Z[0-9]+(InitDefaults|AddDescriptors)_spvtoolsfuzz_2eprotov') + symbol_allowlist_pattern = re.compile(r'_Z[0-9]+.*spvtoolsfuzz_2eproto.*') symbol_is_new_or_delete = re.compile(r'^(_Zna|_Znw|_Zdl|_Zda)') # Compilaion for Arm has various thunks for constructors, destructors, vtables. diff --git a/third_party/spirv-tools/utils/fixup_fuzz_result.py b/third_party/spirv-tools/utils/fixup_fuzz_result.py index 9fe54a3cc4..5b14a7db9b 100755 --- a/third_party/spirv-tools/utils/fixup_fuzz_result.py +++ b/third_party/spirv-tools/utils/fixup_fuzz_result.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2018 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/third_party/spirv-tools/utils/generate_changelog.py b/third_party/spirv-tools/utils/generate_changelog.py new file mode 100644 index 0000000000..348bc50a6a --- /dev/null +++ b/third_party/spirv-tools/utils/generate_changelog.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2023 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Args: +# Updates an output file with changelog from the given CHANGES file and tag. +# - search for first line matching in file +# - search for the next line with a tag +# - writes all the lines in between those 2 tags into + +import errno +import os +import os.path +import re +import subprocess +import logging +import sys + +# Regex to match the SPIR-V version tag. +# Example of matching tags: +# - v2020.1 +# - v2020.1-dev +# - v2020.1.rc1 +VERSION_REGEX = re.compile(r'^(v\d+\.\d+) +[0-9]+-[0-9]+-[0-9]+$') + +def mkdir_p(directory): + """Make the directory, and all its ancestors as required. Any of the + directories are allowed to already exist.""" + + if directory == "": + # We're being asked to make the current directory. + return + + try: + os.makedirs(directory) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(directory): + pass + else: + raise + +def main(): + FORMAT = '%(asctime)s %(message)s' + logging.basicConfig(format="[%(asctime)s][%(levelname)-8s] %(message)s", datefmt="%H:%M:%S") + if len(sys.argv) != 4: + logging.error("usage: {} ".format(sys.argv[0])) + sys.exit(1) + + changes_path = sys.argv[1] + start_tag = sys.argv[2] + output_file_path = sys.argv[3] + + changelog = [] + has_found_start = False + with open(changes_path, "r") as file: + for line in file.readlines(): + m = VERSION_REGEX.match(line) + if m: + print(m.groups()[0]) + print(start_tag) + if has_found_start: + break; + if start_tag == m.groups()[0]: + has_found_start = True + continue + + if has_found_start: + changelog.append(line) + + if not has_found_start: + logging.error("No tag matching {} found.".format(start_tag)) + sys.exit(1) + + content = "".join(changelog) + if os.path.isfile(output_file_path): + with open(output_file_path, 'r') as f: + if content == f.read(): + sys.exit(0) + + mkdir_p(os.path.dirname(output_file_path)) + with open(output_file_path, 'w') as f: + f.write(content) + sys.exit(0) + +if __name__ == '__main__': + main() diff --git a/third_party/spirv-tools/utils/generate_grammar_tables.py b/third_party/spirv-tools/utils/generate_grammar_tables.py index 6b7167b86a..f5fcfe520b 100755 --- a/third_party/spirv-tools/utils/generate_grammar_tables.py +++ b/third_party/spirv-tools/utils/generate_grammar_tables.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,6 +31,7 @@ SPV_AMD_gpu_shader_half_float SPV_AMD_gpu_shader_int16 SPV_AMD_shader_trinary_minmax SPV_KHR_non_semantic_info +SPV_EXT_relaxed_printf_string_address_space """ OUTPUT_LANGUAGE = 'c' @@ -69,6 +70,39 @@ def convert_max_required_version(version): return '0xffffffffu' return 'SPV_SPIRV_VERSION_WORD({})'.format(version.replace('.', ',')) +def get_alias_array_name(aliases): + """Returns the name of the array containing all the given aliases. + + Arguments: + - aliases: a sequence of alias names + """ + if not aliases: + return 'nullptr'; + return '{}_aliases_{}'.format(PYGEN_VARIABLE_PREFIX, ''.join(aliases)) + +def compose_alias_list(aliases): + """Returns a string containing a braced list of aliases. + + Arguments: + - aliases: a sequence of alias names + + Returns: + a string containing the braced list of char* named by aliases. + """ + return '{' + ', '.join([('"{}"').format(a) for a in aliases]) + '}' + +def generate_aliases_arrays(aliases): + """Returns the arrays of aliases + + Arguments: + - aliases: a sequence of sequence of alias names + """ + aliases = sorted(set([tuple(a) for a in aliases if a])) + arrays = [ + 'static const char* {}[] = {};'.format( + get_alias_array_name(a), compose_alias_list(a)) + for a in aliases] + return '\n'.join(arrays) def compose_capability_list(caps): """Returns a string containing a braced list of capabilities as enums. @@ -223,11 +257,12 @@ class InstInitializer(object): """Instances holds a SPIR-V instruction suitable for printing as the initializer for spv_opcode_desc_t.""" - def __init__(self, opname, caps, exts, operands, version, lastVersion): + def __init__(self, opname, aliases, caps, exts, operands, version, lastVersion): """Initialization. Arguments: - opname: opcode name (with the 'Op' prefix) + - aliases: a sequence of aliases for the name of this opcode - caps: a sequence of capability names required by this opcode - exts: a sequence of names of extensions enabling this enumerant - operands: a sequence of (operand-kind, operand-quantifier) tuples @@ -237,6 +272,8 @@ class InstInitializer(object): assert opname.startswith('Op') self.opname = opname[2:] # Remove the "Op" prefix. + self.num_aliases = len(aliases); + self.aliases_mask = get_alias_array_name(aliases) self.num_caps = len(caps) self.caps_mask = get_capability_array_name(caps) self.num_exts = len(exts) @@ -271,6 +308,7 @@ class InstInitializer(object): base_str = 'spv::Op::Op' template = ['{{"{opname}"', base_str + '{opname}', + '{num_aliases}', '{aliases_mask}', '{num_caps}', '{caps_mask}', '{num_operands}', '{{{operands}}}', '{def_result_id}', '{ref_type_id}', @@ -278,6 +316,8 @@ class InstInitializer(object): '{min_version}', '{max_version}}}'] return ', '.join(template).format( opname=self.opname, + num_aliases=self.num_aliases, + aliases_mask=self.aliases_mask, num_caps=self.num_caps, caps_mask=self.caps_mask, num_operands=len(self.operands), @@ -335,6 +375,7 @@ def generate_instruction(inst, is_ext_inst): """ opname = inst.get('opname') opcode = inst.get('opcode') + aliases = inst.get('aliases', []) caps = inst.get('capabilities', []) exts = inst.get('extensions', []) operands = inst.get('operands', {}) @@ -347,7 +388,7 @@ def generate_instruction(inst, is_ext_inst): if is_ext_inst: return str(ExtInstInitializer(opname, opcode, caps, operands)) else: - return str(InstInitializer(opname, caps, exts, operands, min_version, max_version)) + return str(InstInitializer(opname, aliases, caps, exts, operands, min_version, max_version)) def generate_instruction_table(inst_table): @@ -363,6 +404,8 @@ def generate_instruction_table(inst_table): """ inst_table = sorted(inst_table, key=lambda k: (k['opcode'], k['opname'])) + aliases_arrays = generate_aliases_arrays( + [inst.get('aliases', []) for inst in inst_table]) caps_arrays = generate_capability_arrays( [inst.get('capabilities', []) for inst in inst_table]) exts_arrays = generate_extension_arrays( @@ -372,7 +415,7 @@ def generate_instruction_table(inst_table): insts = ['static const spv_opcode_desc_t kOpcodeTableEntries[] = {{\n' ' {}\n}};'.format(',\n '.join(insts))] - return '{}\n\n{}\n\n{}'.format(caps_arrays, exts_arrays, '\n'.join(insts)) + return '{}\n\n{}\n\n{}\n\n{}'.format(aliases_arrays, caps_arrays, exts_arrays, '\n'.join(insts)) def generate_extended_instruction_table(json_grammar, set_name, operand_kind_prefix=""): @@ -404,12 +447,13 @@ def generate_extended_instruction_table(json_grammar, set_name, operand_kind_pre class EnumerantInitializer(object): """Prints an enumerant as the initializer for spv_operand_desc_t.""" - def __init__(self, enumerant, value, caps, exts, parameters, version, lastVersion): + def __init__(self, enumerant, value, aliases, caps, exts, parameters, version, lastVersion): """Initialization. Arguments: - enumerant: enumerant name - value: enumerant value + - aliases: a sequence of aliased capability names - caps: a sequence of capability names required by this enumerant - exts: a sequence of names of extensions enabling this enumerant - parameters: a sequence of (operand-kind, operand-quantifier) tuples @@ -418,6 +462,8 @@ class EnumerantInitializer(object): """ self.enumerant = enumerant self.value = value + self.num_aliases = len(aliases) + self.aliases = get_alias_array_name(aliases) self.num_caps = len(caps) self.caps = get_capability_array_name(caps) self.num_exts = len(exts) @@ -427,13 +473,17 @@ class EnumerantInitializer(object): self.lastVersion = convert_max_required_version(lastVersion) def __str__(self): - template = ['{{"{enumerant}"', '{value}', '{num_caps}', - '{caps}', '{num_exts}', '{exts}', + template = ['{{"{enumerant}"', '{value}', + '{num_aliases}', '{aliases}', + '{num_caps}', '{caps}', + '{num_exts}', '{exts}', '{{{parameters}}}', '{min_version}', '{max_version}}}'] return ', '.join(template).format( enumerant=self.enumerant, value=self.value, + num_aliases=self.num_aliases, + aliases=self.aliases, num_caps=self.num_caps, caps=self.caps, num_exts=self.num_exts, @@ -455,6 +505,7 @@ def generate_enum_operand_kind_entry(entry, extension_map): """ enumerant = entry.get('enumerant') value = entry.get('value') + aliases = entry.get('aliases', []) caps = entry.get('capabilities', []) if value in extension_map: exts = extension_map[value] @@ -470,7 +521,7 @@ def generate_enum_operand_kind_entry(entry, extension_map): assert value is not None return str(EnumerantInitializer( - enumerant, value, caps, exts, params, version, max_version)) + enumerant, value, aliases, caps, exts, params, version, max_version)) def generate_enum_operand_kind(enum, synthetic_exts_list): @@ -512,6 +563,10 @@ def generate_enum_operand_kind(enum, synthetic_exts_list): name = '{}_{}Entries'.format(PYGEN_VARIABLE_PREFIX, kind) entries = [' {}'.format(generate_enum_operand_kind_entry(e, extension_map)) for e in entries] + if len(entries) == 0: + # Insert a dummy entry. Otherwise the array is empty and compilation + # will fail in MSVC. + entries = [' {"place holder", 0, 0, nullptr, 0, nullptr, 0, nullptr, {}, SPV_SPIRV_VERSION_WORD(999,0), 0}'] template = ['static const spv_operand_desc_t {name}[] = {{', '{entries}', '}};'] @@ -527,6 +582,11 @@ def generate_operand_kind_table(enums): # We only need to output info tables for those operand kinds that are enums. enums = [e for e in enums if e.get('category') in ['ValueEnum', 'BitEnum']] + aliases = [entry.get('aliases', []) + for enum in enums + for entry in enum.get('enumerants', [])] + aliases_arrays = generate_aliases_arrays(aliases) + caps = [entry.get('capabilities', []) for enum in enums for entry in enum.get('enumerants', [])] @@ -540,7 +600,7 @@ def generate_operand_kind_table(enums): # We have a few operand kinds that require their optional counterpart to # exist in the operand info table. - optional_enums = ['ImageOperands', 'AccessQualifier', 'MemoryAccess', 'PackedVectorFormat'] + optional_enums = ['ImageOperands', 'AccessQualifier', 'MemoryAccess', 'PackedVectorFormat', 'CooperativeMatrixOperands', 'MatrixMultiplyAccumulateOperands', 'RawAccessChainOperands', 'FPEncoding'] optional_enums = [e for e in enums if e[0] in optional_enums] enums.extend(optional_enums) @@ -561,7 +621,7 @@ def generate_operand_kind_table(enums): table = '\n'.join(template).format( p=PYGEN_VARIABLE_PREFIX, enums=',\n'.join(table_entries)) - return '\n\n'.join((caps_arrays,) + (exts_arrays,) + enum_entries + (table,)) + return '\n\n'.join((aliases_arrays,) + (caps_arrays,) + (exts_arrays,) + enum_entries + (table,)) def get_extension_list(instructions, operand_kinds): diff --git a/third_party/spirv-tools/utils/generate_language_headers.py b/third_party/spirv-tools/utils/generate_language_headers.py index 83fa99e1f7..18a8d5ea01 100755 --- a/third_party/spirv-tools/utils/generate_language_headers.py +++ b/third_party/spirv-tools/utils/generate_language_headers.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2017 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/third_party/spirv-tools/utils/generate_registry_tables.py b/third_party/spirv-tools/utils/generate_registry_tables.py index 28152ef3eb..2564f357bf 100755 --- a/third_party/spirv-tools/utils/generate_registry_tables.py +++ b/third_party/spirv-tools/utils/generate_registry_tables.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,8 +15,10 @@ """Generates the vendor tool table from the SPIR-V XML registry.""" import errno +import io import os.path -import xml.etree.ElementTree +import platform +from xml.etree.ElementTree import XML, XMLParser, TreeBuilder def mkdir_p(directory): @@ -78,8 +80,16 @@ def main(): help='output file for SPIR-V generators table') args = parser.parse_args() - with open(args.xml) as xml_in: - registry = xml.etree.ElementTree.fromstring(xml_in.read()) + with io.open(args.xml, encoding='utf-8') as xml_in: + # Python3 default str to UTF-8. But Python2.7 (in case of NDK build, + # don't be fooled by the shebang) is returning a unicode string. + # So depending of the version, we need to make sure the correct + # encoding is used. + content = xml_in.read() + if platform.python_version_tuple()[0] == '2': + content = content.encode('utf-8') + parser = XMLParser(target=TreeBuilder(), encoding='utf-8') + registry = XML(content, parser=parser) mkdir_p(os.path.dirname(args.generator_output)) with open(args.generator_output, 'w') as f: diff --git a/third_party/spirv-tools/utils/git-sync-deps b/third_party/spirv-tools/utils/git-sync-deps index 7a7e606ff1..21bf2bc743 100755 --- a/third_party/spirv-tools/utils/git-sync-deps +++ b/third_party/spirv-tools/utils/git-sync-deps @@ -28,10 +28,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Parse a DEPS file and git checkout all of the dependencies. +""" -Args: - An optional list of deps_os values. - +EXTRA_HELP = """ Environment Variables: GIT_EXECUTABLE: path to "git" binary; if unset, will look for one of ['git', 'git.exe', 'git.bat'] in your default path. @@ -52,6 +51,7 @@ Git Config: """ +import argparse import os import re import subprocess @@ -59,12 +59,14 @@ import sys import threading from builtins import bytes - def git_executable(): """Find the git executable. Returns: - A string suitable for passing to subprocess functions, or None. + A triple: + A string suitable for passing to subprocess functions, or None. + The major version number + The minor version number """ envgit = os.environ.get('GIT_EXECUTABLE') searchlist = ['git', 'git.exe', 'git.bat'] @@ -72,30 +74,36 @@ def git_executable(): searchlist.insert(0, envgit) with open(os.devnull, 'w') as devnull: for git in searchlist: + major=None + minor=None try: - subprocess.call([git, '--version'], stdout=devnull) + version_info = subprocess.check_output([git, '--version']).decode('utf-8') + match = re.search(r"^git version (\d+)\.(\d+)",version_info) + print("Using {}".format(version_info)) + if match: + major = int(match.group(1)) + minor = int(match.group(2)) + else: + continue except (OSError,): continue - return git - return None + return (git,major,minor) + return (None,0,0) DEFAULT_DEPS_PATH = os.path.normpath( os.path.join(os.path.dirname(__file__), os.pardir, 'DEPS')) +def get_deps_os_str(deps_file): + parsed_deps = parse_file_to_dict(deps_file) + parts = [] + if 'deps_os' in parsed_deps: + for deps_os in parsed_deps['deps_os']: + parts.append(' [{}]]'.format(deps_os)) + return "\n".join(parts) -def usage(deps_file_path = None): - sys.stderr.write( - 'Usage: run to grab dependencies, with optional platform support:\n') - sys.stderr.write(' %s %s' % (sys.executable, __file__)) - if deps_file_path: - parsed_deps = parse_file_to_dict(deps_file_path) - if 'deps_os' in parsed_deps: - for deps_os in parsed_deps['deps_os']: - sys.stderr.write(' [%s]' % deps_os) - sys.stderr.write('\n\n') - sys.stderr.write(__doc__) - +def looks_like_raw_commit(commit): + return re.match('^[a-f0-9]{40}$', commit) is not None def git_repository_sync_is_disabled(git, directory): try: @@ -125,14 +133,14 @@ def is_git_toplevel(git, directory): def status(directory, checkoutable): def truncate(s, length): - return s if len(s) <= length else s[:(length - 3)] + '...' + return s if len(s) <= length else '...' + s[-(length - 3):] dlen = 36 directory = truncate(directory, dlen) checkoutable = truncate(checkoutable, 40) sys.stdout.write('%-*s @ %s\n' % (dlen, directory, checkoutable)) -def git_checkout_to_directory(git, repo, checkoutable, directory, verbose): +def git_checkout_to_directory(git, repo, checkoutable, directory, verbose, treeless): """Checkout (and clone if needed) a Git repository. Args: @@ -147,13 +155,22 @@ def git_checkout_to_directory(git, repo, checkoutable, directory, verbose): directory (string) the path into which the repository should be checked out. - verbose (boolean) + verbose (boolean): emit status info to stdout + + treeless (boolean): when true, clone without any trees. Raises an exception if any calls to git fail. """ if not os.path.isdir(directory): + # Use blobless or treeless checkouts for faster downloads. + # This defers some work to checkout time. + # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + filter = ['--filter=tree:0'] if treeless else ['--filter=blob:none'] + # If the thing to check out looks like a tag (and not like a commit), + # then limit the checkout to that branch. + branch = [] if looks_like_raw_commit(checkoutable) else ['--branch={}'.format(checkoutable)] subprocess.check_call( - [git, 'clone', '--quiet', repo, directory]) + [git, 'clone', '--quiet', '--single-branch'] + filter + branch + [repo, directory]) if not is_git_toplevel(git, directory): # if the directory exists, but isn't a git repo, you will modify @@ -200,7 +217,7 @@ def parse_file_to_dict(path): return dictionary -def git_sync_deps(deps_file_path, command_line_os_requests, verbose): +def git_sync_deps(deps_file_path, command_line_os_requests, verbose, treeless): """Grab dependencies, with optional platform support. Args: @@ -210,11 +227,20 @@ def git_sync_deps(deps_file_path, command_line_os_requests, verbose): List of strings that should each be a key in the deps_os dictionary in the DEPS file. + verbose (boolean): emit status info to stdout + + treeless (boolean): when true, clone as treeless instead of blobless + Raises git Exceptions. """ - git = git_executable() + (git,git_major,git_minor) = git_executable() assert git + # --filter=tree:0 is available in git 2.20 and later + if (git_major,git_minor) < (2,20): + print("disabling --treeless: git is older than v2.20") + treeless = False + deps_file_directory = os.path.dirname(deps_file_path) deps_file = parse_file_to_dict(deps_file_path) dependencies = deps_file['deps'].copy() @@ -241,7 +267,7 @@ def git_sync_deps(deps_file_path, command_line_os_requests, verbose): relative_directory = os.path.join(deps_file_directory, directory) list_of_arg_lists.append( - (git, repo, checkoutable, relative_directory, verbose)) + (git, repo, checkoutable, relative_directory, verbose, treeless)) multithread(git_checkout_to_directory, list_of_arg_lists) @@ -264,17 +290,47 @@ def multithread(function, list_of_arg_lists): def main(argv): - deps_file_path = os.environ.get('GIT_SYNC_DEPS_PATH', DEFAULT_DEPS_PATH) - verbose = not bool(os.environ.get('GIT_SYNC_DEPS_QUIET', False)) + argparser = argparse.ArgumentParser( + prog = "git-sync-deps", + description = "Checkout git-based dependencies as specified by the DEPS file", + add_help=False # Because we want to print deps_os with -h option + ) + argparser.add_argument("--help", "-h", + action='store_true', + help="show this help message and exit") + argparser.add_argument("--deps", + default = os.environ.get('GIT_SYNC_DEPS_PATH', DEFAULT_DEPS_PATH), + help="location of the the DEPS file") + argparser.add_argument("--verbose", + default=not bool(os.environ.get('GIT_SYNC_DEPS_QUIET', False)), + action='store_true', + help="be verbose: print status messages") + argparser.add_argument("--treeless", + default=False, + action='store_true', + help=""" + Clone repos without trees (--filter=tree:0). + This is the fastest option for a build machine, + when you only need a single commit. + Defers getting objects until checking out a commit. - if '--help' in argv or '-h' in argv: - usage(deps_file_path) - return 1 + The default is to clone with trees but without blobs. - git_sync_deps(deps_file_path, argv, verbose) - # subprocess.check_call( - # [sys.executable, - # os.path.join(os.path.dirname(deps_file_path), 'bin', 'fetch-gn')]) + Only takes effect if using git 2.20 or later. + + See https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + """) + argparser.add_argument("os_requests",nargs="*", + help="OS requests, as keys in the deps_os dictionariy in the DEPS file") + + args = argparser.parse_args() + if args.help: + print(argparser.format_help()) + print(EXTRA_HELP) + print(get_deps_os_str(args.deps)) + return 0 + + git_sync_deps(args.deps, args.os_requests, args.verbose, args.treeless) return 0 diff --git a/third_party/spirv-tools/utils/roll_deps.sh b/third_party/spirv-tools/utils/roll_deps.sh index 20c061fd86..a62ebe9bc5 100755 --- a/third_party/spirv-tools/utils/roll_deps.sh +++ b/third_party/spirv-tools/utils/roll_deps.sh @@ -20,14 +20,21 @@ set -eo pipefail -effcee_dir="external/effcee/" -effcee_trunk="origin/main" -googletest_dir="external/googletest/" -googletest_trunk="origin/main" -re2_dir="external/re2/" -re2_trunk="origin/main" -spirv_headers_dir="external/spirv-headers/" -spirv_headers_trunk="origin/master" +function ExitIfIsInterestingError() { + local return_code=$1 + if [[ ${return_code} -ne 0 && ${return_code} -ne 2 ]]; then + exit ${return_code} + fi + return 0 +} + + +declare -A dependency_to_branch_map +dependency_to_branch_map["external/abseil_cpp"]="origin/master" +dependency_to_branch_map["external/effcee/"]="origin/main" +dependency_to_branch_map["external/googletest/"]="origin/main" +dependency_to_branch_map["external/re2/"]="origin/main" +dependency_to_branch_map["external/spirv-headers/"]="origin/main" # This script assumes it's parent directory is the repo root. repo_path=$(dirname "$0")/.. @@ -44,10 +51,10 @@ echo "*** Ignore messages about running 'git cl upload' ***" old_head=$(git rev-parse HEAD) set +e -roll-dep --ignore-dirty-tree --roll-to="${effcee_trunk}" "${effcee_dir}" -roll-dep --ignore-dirty-tree --roll-to="${googletest_trunk}" "${googletest_dir}" -roll-dep --ignore-dirty-tree --roll-to="${re2_trunk}" "${re2_dir}" -roll-dep --ignore-dirty-tree --roll-to="${spirv_headers_trunk}" "${spirv_headers_dir}" - -git rebase --interactive "${old_head}" +for dep in ${!dependency_to_branch_map[@]}; do + branch=${dependency_to_branch_map[$dep]} + echo "Rolling $dep" + roll-dep --ignore-dirty-tree --roll-to="${branch}" "${dep}" + ExitIfIsInterestingError $? +done diff --git a/third_party/spirv-tools/utils/update_build_version.py b/third_party/spirv-tools/utils/update_build_version.py index 2a1ca60051..9115cab1e9 100755 --- a/third_party/spirv-tools/utils/update_build_version.py +++ b/third_party/spirv-tools/utils/update_build_version.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016 Google Inc. # @@ -24,9 +24,10 @@ # - The software version deduced from the given CHANGES file. # - A longer string with the project name, the software version number, and # git commit information for the CHANGES file's directory. The commit -# information is the output of "git describe" if that succeeds, or "git -# rev-parse HEAD" if that succeeds, or otherwise a message containing the -# phrase "unknown hash". +# information is the content of the FORCED_BUILD_VERSION_DESCRIPTION +# environement variable is it exists, else the output of "git describe" if +# that succeeds, or "git rev-parse HEAD" if that succeeds, or otherwise a +# message containing the phrase "unknown hash". # The string contents are escaped as necessary. import datetime @@ -35,9 +36,13 @@ import os import os.path import re import subprocess +import logging import sys import time +# Format of the output generated by this script. Example: +# "v2023.1", "SPIRV-Tools v2023.1 0fc5526f2b01a0cc89192c10cf8bef77f1007a62, 2023-01-18T14:51:49" +OUTPUT_FORMAT = '"{version_tag}", "SPIRV-Tools {version_tag} {description}"\n' def mkdir_p(directory): """Make the directory, and all its ancestors as required. Any of the @@ -55,31 +60,36 @@ def mkdir_p(directory): else: raise - def command_output(cmd, directory): """Runs a command in a directory and returns its standard output stream. - Captures the standard error stream. - - Raises a RuntimeError if the command fails to launch or otherwise fails. + Returns (False, None) if the command fails to launch or otherwise fails. """ - p = subprocess.Popen(cmd, - cwd=directory, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stdout, _) = p.communicate() - if p.returncode != 0: - raise RuntimeError('Failed to run %s in %s' % (cmd, directory)) - return stdout - + try: + # Set shell=True on Windows so that Chromium's git.bat can be found when + # 'git' is invoked. + p = subprocess.Popen(cmd, + cwd=directory, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=os.name == 'nt') + (stdout, _) = p.communicate() + if p.returncode != 0: + return False, None + except Exception as e: + return False, None + return p.returncode == 0, stdout def deduce_software_version(changes_file): - """Returns a software version number parsed from the given CHANGES file. + """Returns a tuple (success, software version number) parsed from the + given CHANGES file. - The CHANGES file describes most recent versions first. + Success is set to True if the software version could be deduced. + Software version is undefined if success if False. + Function expects the CHANGES file to describes most recent versions first. """ - # Match the first well-formed version-and-date line. + # Match the first well-formed version-and-date line # Allow trailing whitespace in the checked-out source code has # unexpected carriage returns on a linefeed-only system such as # Linux. @@ -88,60 +98,73 @@ def deduce_software_version(changes_file): for line in f.readlines(): match = pattern.match(line) if match: - return match.group(1) - raise Exception('No version number found in {}'.format(changes_file)) + return True, match.group(1) + return False, None -def describe(directory): +def describe(repo_path): """Returns a string describing the current Git HEAD version as descriptively as possible. Runs 'git describe', or alternately 'git rev-parse HEAD', in directory. If successful, returns the output; otherwise returns 'unknown hash, '.""" - try: - # decode() is needed here for Python3 compatibility. In Python2, - # str and bytes are the same type, but not in Python3. - # Popen.communicate() returns a bytes instance, which needs to be - # decoded into text data first in Python3. And this decode() won't - # hurt Python2. - return command_output(['git', 'describe'], directory).rstrip().decode() - except: - try: - return command_output( - ['git', 'rev-parse', 'HEAD'], directory).rstrip().decode() - except: - # This is the fallback case where git gives us no information, - # e.g. because the source tree might not be in a git tree. - # In this case, usually use a timestamp. However, to ensure - # reproducible builds, allow the builder to override the wall - # clock time with environment variable SOURCE_DATE_EPOCH - # containing a (presumably) fixed timestamp. - timestamp = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) - formatted = datetime.datetime.utcfromtimestamp(timestamp).isoformat() - return 'unknown hash, {}'.format(formatted) + # if we're in a git repository, attempt to extract version info + success, output = command_output(["git", "rev-parse", "--show-toplevel"], repo_path) + if success: + success, output = command_output(["git", "describe", "--tags", "--match=v*", "--long"], repo_path) + if not success: + success, output = command_output(["git", "rev-parse", "HEAD"], repo_path) + + if success: + # decode() is needed here for Python3 compatibility. In Python2, + # str and bytes are the same type, but not in Python3. + # Popen.communicate() returns a bytes instance, which needs to be + # decoded into text data first in Python3. And this decode() won't + # hurt Python2. + return output.rstrip().decode() + + # This is the fallback case where git gives us no information, + # e.g. because the source tree might not be in a git tree or + # git is not available on the system. + # In this case, usually use a timestamp. However, to ensure + # reproducible builds, allow the builder to override the wall + # clock time with environment variable SOURCE_DATE_EPOCH + # containing a (presumably) fixed timestamp. + timestamp = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + iso_date = datetime.datetime.fromtimestamp(timestamp, datetime.timezone.utc).isoformat() + return "unknown hash, {}".format(iso_date) def main(): + FORMAT = '%(asctime)s %(message)s' + logging.basicConfig(format="[%(asctime)s][%(levelname)-8s] %(message)s", datefmt="%H:%M:%S") if len(sys.argv) != 3: - print('usage: {} '.format(sys.argv[0])) + logging.error("usage: {} ".format(sys.argv[0])) sys.exit(1) - output_file = sys.argv[2] - mkdir_p(os.path.dirname(output_file)) + changes_file_path = os.path.realpath(sys.argv[1]) + output_file_path = sys.argv[2] - software_version = deduce_software_version(sys.argv[1]) - directory = os.path.dirname(sys.argv[1]) - new_content = '"{}", "SPIRV-Tools {} {}"\n'.format( - software_version, software_version, - describe(directory).replace('"', '\\"')) + success, version = deduce_software_version(changes_file_path) + if not success: + logging.error("Could not deduce latest release version from {}.".format(changes_file_path)) + sys.exit(1) - if os.path.isfile(output_file): - with open(output_file, 'r') as f: - if new_content == f.read(): - return + repo_path = os.path.dirname(changes_file_path) + description = os.getenv("FORCED_BUILD_VERSION_DESCRIPTION", describe(repo_path)) + content = OUTPUT_FORMAT.format(version_tag=version, description=description) - with open(output_file, 'w') as f: - f.write(new_content) + # Escape file content. + content.replace('"', '\\"') + + if os.path.isfile(output_file_path): + with open(output_file_path, 'r') as f: + if content == f.read(): + return + + mkdir_p(os.path.dirname(output_file_path)) + with open(output_file_path, 'w') as f: + f.write(content) if __name__ == '__main__': main() diff --git a/third_party/spirv-tools/utils/vim/README.md b/third_party/spirv-tools/utils/vim/README.md new file mode 100644 index 0000000000..a73977efc3 --- /dev/null +++ b/third_party/spirv-tools/utils/vim/README.md @@ -0,0 +1,87 @@ +# Neovim configuration guide for SPIR-V disassembly files + +This directory holds instructions to configure Neovim for SPIR-V assembly files (`.spvasm`) + +At the end, Neovim should support: +* Syntax highlighting +* Jump to definition +* Find all references +* Symbol renaming +* Operand hover information +* Formatting +* Completion suggestions for all Opcodes and Ids + +While the instructions here are specifically for Neovim, they should translate easily to vim. + +## Dependencies + +In order to build and install the Visual Studio Code language server extension, you will need to install and have on your `PATH` the following dependencies: +* [`golang 1.16+`](https://golang.org/) + +## File type detection + +Neovim's default config location is typically `~/.config/nvim` so the rest of the instructions assume that but it will need to be changed if your system is different. + +Tell neovim that `*.spvasm` files should be treated as `spvasm` filetype +```bash +echo "au BufRead,BufNewFile *.spvasm set filetype=spvasm" > ~/.config/nvim/ftdetect/spvasm.vim +``` + +## Syntax Highlighting + +### Generate the syntax highlighting file +```bash +cd +mkdir -p build && cd build +# Any platform is fine, ninja is used an as example +cmake -G Ninja .. +ninja spirv-tools-vimsyntax +``` + +### Copy the syntax file +```bash +cp spvasm.vim ~/.config/nvim/syntax/spvasm.vim +``` + +## Language Server + +### Building the LSP (masOS / Linux) + +Run `build_lsp.sh` +Copy `spirvls` and `spirv.json` to a location in `$PATH` + +```bash +cd /utils/vscode +./build_lsp.sh +sudo cp spirvls/* /usr/local/bin/ +``` + +### Building the LSP (Windows) + +TODO + +### Configuring Neovim + +Configuration will depend a lot on your installed plugins but assuming you are using [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) the following should be sufficient. + +```lua +local lspconfig = require 'lspconfig' +local configs = require 'lspconfig.configs' + +if not configs.spvasm then + configs.spvasm = { + default_config = { + cmd = { 'spirvls' }, + filetypes = { 'spvasm' }, + root_dir = function(fname) + return '.' + end, + settings = {}, + }, + } +end + +lspconfig.spvasm.setup { + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), +} +``` diff --git a/third_party/spirv-tools/utils/generate_vim_syntax.py b/third_party/spirv-tools/utils/vim/generate_syntax.py similarity index 96% rename from third_party/spirv-tools/utils/generate_vim_syntax.py rename to third_party/spirv-tools/utils/vim/generate_syntax.py index da7e99ba77..1d156a0cde 100755 --- a/third_party/spirv-tools/utils/generate_vim_syntax.py +++ b/third_party/spirv-tools/utils/vim/generate_syntax.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -161,11 +161,17 @@ def main(): print('\n" Core instructions') for inst in core["instructions"]: EmitAsStatement(inst['opname']) + aliases = inst.get('aliases', []) + for alias in aliases: + EmitAsStatement(alias) print('\n" Core operand enums') for operand_kind in core["operand_kinds"]: if 'enumerants' in operand_kind: for e in operand_kind['enumerants']: EmitAsEnumerant(e['enumerant']) + aliases = e.get('aliases', []) + for a in aliases: + EmitAsEnumerant(a) if args.extinst_glsl_grammar is not None: print('\n" GLSL.std.450 extended instructions') diff --git a/third_party/spirv-tools/utils/vscode/README.md b/third_party/spirv-tools/utils/vscode/README.md index d7aa2b4132..9cf82b16f7 100644 --- a/third_party/spirv-tools/utils/vscode/README.md +++ b/third_party/spirv-tools/utils/vscode/README.md @@ -9,6 +9,7 @@ The extension supports: * Symbol renaming * Operand hover information * Formatting +* Completion suggestions for all Opcodes and Ids ## Dependencies @@ -18,8 +19,8 @@ In order to build and install the Visual Studio Code language server extension, ## Installing (macOS / Linux) -Run `install.sh` +Run `install_vscode.sh` ## Installing (Windows) -Run `install.bat` +Run `install_vscode.bat` diff --git a/third_party/spirv-tools/utils/vscode/build_lsp.sh b/third_party/spirv-tools/utils/vscode/build_lsp.sh new file mode 100755 index 0000000000..dc92cc8bf2 --- /dev/null +++ b/third_party/spirv-tools/utils/vscode/build_lsp.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright (c) 2019 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +ROOT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +pushd ${ROOT_PATH} + go run ./src/tools/gen-grammar.go --cache ./cache --template ./spirv.json.tmpl --out ./spirv.json + go run ./src/tools/gen-grammar.go --cache ./cache --template ./src/schema/schema.go.tmpl --out ./src/schema/schema.go + + mkdir -p ./spirvls + cp ./spirv.json ./spirvls + + go build -o ./spirvls/spirvls ./src/langsvr.go +popd diff --git a/third_party/spirv-tools/utils/vscode/install.bat b/third_party/spirv-tools/utils/vscode/install_vscode.bat similarity index 100% rename from third_party/spirv-tools/utils/vscode/install.bat rename to third_party/spirv-tools/utils/vscode/install_vscode.bat diff --git a/third_party/spirv-tools/utils/vscode/install.sh b/third_party/spirv-tools/utils/vscode/install_vscode.sh similarity index 100% rename from third_party/spirv-tools/utils/vscode/install.sh rename to third_party/spirv-tools/utils/vscode/install_vscode.sh diff --git a/third_party/spirv-tools/utils/vscode/spirv.json b/third_party/spirv-tools/utils/vscode/spirv.json index 2e88296e0b..4ab2529d30 100644 --- a/third_party/spirv-tools/utils/vscode/spirv.json +++ b/third_party/spirv-tools/utils/vscode/spirv.json @@ -12,6 +12,8 @@ { "include": "#BitEnum_MemoryAccess" }, { "include": "#BitEnum_KernelProfilingInfo" }, { "include": "#BitEnum_RayFlags" }, + { "include": "#BitEnum_FragmentShadingRate" }, + { "include": "#BitEnum_RawAccessChainOperands" }, { "include": "#ValueEnum_SourceLanguage" }, { "include": "#ValueEnum_ExecutionModel" }, { "include": "#ValueEnum_AddressingModel" }, @@ -25,8 +27,13 @@ { "include": "#ValueEnum_ImageChannelOrder" }, { "include": "#ValueEnum_ImageChannelDataType" }, { "include": "#ValueEnum_FPRoundingMode" }, + { "include": "#ValueEnum_FPDenormMode" }, + { "include": "#ValueEnum_QuantizationModes" }, + { "include": "#ValueEnum_FPOperationMode" }, + { "include": "#ValueEnum_OverflowModes" }, { "include": "#ValueEnum_LinkageType" }, { "include": "#ValueEnum_AccessQualifier" }, + { "include": "#ValueEnum_HostAccessQualifier" }, { "include": "#ValueEnum_FunctionParameterAttribute" }, { "include": "#ValueEnum_Decoration" }, { "include": "#ValueEnum_BuiltIn" }, @@ -37,6 +44,17 @@ { "include": "#ValueEnum_RayQueryIntersection" }, { "include": "#ValueEnum_RayQueryCommittedIntersectionType" }, { "include": "#ValueEnum_RayQueryCandidateIntersectionType" }, + { "include": "#ValueEnum_PackedVectorFormat" }, + { "include": "#BitEnum_CooperativeMatrixOperands" }, + { "include": "#ValueEnum_CooperativeMatrixLayout" }, + { "include": "#ValueEnum_CooperativeMatrixUse" }, + { "include": "#BitEnum_CooperativeMatrixReduce" }, + { "include": "#ValueEnum_TensorClampMode" }, + { "include": "#BitEnum_TensorAddressingOperands" }, + { "include": "#ValueEnum_InitializationModeQualifier" }, + { "include": "#ValueEnum_LoadCacheControl" }, + { "include": "#ValueEnum_StoreCacheControl" }, + { "include": "#ValueEnum_NamedMaximumNumberOfRegisters" }, { "include": "#BitEnum_DebugInfoFlags" }, { "include": "#ValueEnum_DebugBaseTypeAttributeEncoding" }, { "include": "#ValueEnum_DebugCompositeType" }, @@ -53,11 +71,11 @@ ], "repository": { "BitEnum_ImageOperands": { - "match": "\\b(None|Bias|Lod|Grad|ConstOffset|Offset|ConstOffsets|Sample|MinLod|MakeTexelAvailable|MakeTexelAvailableKHR|MakeTexelVisible|MakeTexelVisibleKHR|NonPrivateTexel|NonPrivateTexelKHR|VolatileTexel|VolatileTexelKHR|SignExtend|ZeroExtend)\\b", + "match": "\\b(None|Bias|Lod|Grad|ConstOffset|Offset|ConstOffsets|Sample|MinLod|MakeTexelAvailable|MakeTexelVisible|NonPrivateTexel|VolatileTexel|SignExtend|ZeroExtend|Nontemporal|Offsets)\\b", "name": "keyword.spirv" }, "BitEnum_FPFastMathMode": { - "match": "\\b(None|NotNaN|NotInf|NSZ|AllowRecip|Fast)\\b", + "match": "\\b(None|NotNaN|NotInf|NSZ|AllowRecip|Fast|AllowContract|AllowReassoc|AllowTransform)\\b", "name": "keyword.spirv" }, "BitEnum_SelectionControl": { @@ -65,19 +83,19 @@ "name": "keyword.spirv" }, "BitEnum_LoopControl": { - "match": "\\b(None|Unroll|DontUnroll|DependencyInfinite|DependencyLength|MinIterations|MaxIterations|IterationMultiple|PeelCount|PartialCount)\\b", + "match": "\\b(None|Unroll|DontUnroll|DependencyInfinite|DependencyLength|MinIterations|MaxIterations|IterationMultiple|PeelCount|PartialCount|InitiationIntervalINTEL|MaxConcurrencyINTEL|DependencyArrayINTEL|PipelineEnableINTEL|LoopCoalesceINTEL|MaxInterleavingINTEL|SpeculatedIterationsINTEL|NoFusionINTEL|LoopCountINTEL|MaxReinvocationDelayINTEL)\\b", "name": "keyword.spirv" }, "BitEnum_FunctionControl": { - "match": "\\b(None|Inline|DontInline|Pure|Const)\\b", + "match": "\\b(None|Inline|DontInline|Pure|Const|OptNoneEXT)\\b", "name": "keyword.spirv" }, "BitEnum_MemorySemantics": { - "match": "\\b(Relaxed|None|Acquire|Release|AcquireRelease|SequentiallyConsistent|UniformMemory|SubgroupMemory|WorkgroupMemory|CrossWorkgroupMemory|AtomicCounterMemory|ImageMemory|OutputMemory|OutputMemoryKHR|MakeAvailable|MakeAvailableKHR|MakeVisible|MakeVisibleKHR|Volatile)\\b", + "match": "\\b(Relaxed|Acquire|Release|AcquireRelease|SequentiallyConsistent|UniformMemory|SubgroupMemory|WorkgroupMemory|CrossWorkgroupMemory|AtomicCounterMemory|ImageMemory|OutputMemory|MakeAvailable|MakeVisible|Volatile)\\b", "name": "keyword.spirv" }, "BitEnum_MemoryAccess": { - "match": "\\b(None|Volatile|Aligned|Nontemporal|MakePointerAvailable|MakePointerAvailableKHR|MakePointerVisible|MakePointerVisibleKHR|NonPrivatePointer|NonPrivatePointerKHR)\\b", + "match": "\\b(None|Volatile|Aligned|Nontemporal|MakePointerAvailable|MakePointerVisible|NonPrivatePointer|AliasScopeINTELMask|NoAliasINTELMask)\\b", "name": "keyword.spirv" }, "BitEnum_KernelProfilingInfo": { @@ -85,35 +103,43 @@ "name": "keyword.spirv" }, "BitEnum_RayFlags": { - "match": "\\b(NoneKHR|OpaqueKHR|NoOpaqueKHR|TerminateOnFirstHitKHR|SkipClosestHitShaderKHR|CullBackFacingTrianglesKHR|CullFrontFacingTrianglesKHR|CullOpaqueKHR|CullNoOpaqueKHR|SkipTrianglesKHR|SkipAABBsKHR)\\b", + "match": "\\b(NoneKHR|OpaqueKHR|NoOpaqueKHR|TerminateOnFirstHitKHR|SkipClosestHitShaderKHR|CullBackFacingTrianglesKHR|CullFrontFacingTrianglesKHR|CullOpaqueKHR|CullNoOpaqueKHR|SkipTrianglesKHR|SkipAABBsKHR|ForceOpacityMicromap2StateEXT)\\b", + "name": "keyword.spirv" + }, + "BitEnum_FragmentShadingRate": { + "match": "\\b(Vertical2Pixels|Vertical4Pixels|Horizontal2Pixels|Horizontal4Pixels)\\b", + "name": "keyword.spirv" + }, + "BitEnum_RawAccessChainOperands": { + "match": "\\b(None|RobustnessPerComponentNV|RobustnessPerElementNV)\\b", "name": "keyword.spirv" }, "ValueEnum_SourceLanguage": { - "match": "\\b(Unknown|ESSL|GLSL|OpenCL_C|OpenCL_CPP|HLSL)\\b", + "match": "\\b(Unknown|ESSL|GLSL|OpenCL_C|OpenCL_CPP|HLSL|CPP_for_OpenCL|SYCL|HERO_C|NZSL|WGSL|Slang|Zig)\\b", "name": "keyword.spirv" }, "ValueEnum_ExecutionModel": { - "match": "\\b(Vertex|TessellationControl|TessellationEvaluation|Geometry|Fragment|GLCompute|Kernel|TaskNV|MeshNV|RayGenerationNV|RayGenerationKHR|IntersectionNV|IntersectionKHR|AnyHitNV|AnyHitKHR|ClosestHitNV|ClosestHitKHR|MissNV|MissKHR|CallableNV|CallableKHR)\\b", + "match": "\\b(Vertex|TessellationControl|TessellationEvaluation|Geometry|Fragment|GLCompute|Kernel|TaskNV|MeshNV|RayGenerationKHR|IntersectionKHR|AnyHitKHR|ClosestHitKHR|MissKHR|CallableKHR|TaskEXT|MeshEXT)\\b", "name": "keyword.spirv" }, "ValueEnum_AddressingModel": { - "match": "\\b(Logical|Physical32|Physical64|PhysicalStorageBuffer64|PhysicalStorageBuffer64EXT)\\b", + "match": "\\b(Logical|Physical32|Physical64|PhysicalStorageBuffer64)\\b", "name": "keyword.spirv" }, "ValueEnum_MemoryModel": { - "match": "\\b(Simple|GLSL450|OpenCL|Vulkan|VulkanKHR)\\b", + "match": "\\b(Simple|GLSL450|OpenCL|Vulkan)\\b", "name": "keyword.spirv" }, "ValueEnum_ExecutionMode": { - "match": "\\b(Invocations|SpacingEqual|SpacingFractionalEven|SpacingFractionalOdd|VertexOrderCw|VertexOrderCcw|PixelCenterInteger|OriginUpperLeft|OriginLowerLeft|EarlyFragmentTests|PointMode|Xfb|DepthReplacing|DepthGreater|DepthLess|DepthUnchanged|LocalSize|LocalSizeHint|InputPoints|InputLines|InputLinesAdjacency|Triangles|InputTrianglesAdjacency|Quads|Isolines|OutputVertices|OutputPoints|OutputLineStrip|OutputTriangleStrip|VecTypeHint|ContractionOff|Initializer|Finalizer|SubgroupSize|SubgroupsPerWorkgroup|SubgroupsPerWorkgroupId|LocalSizeId|LocalSizeHintId|PostDepthCoverage|DenormPreserve|DenormFlushToZero|SignedZeroInfNanPreserve|RoundingModeRTE|RoundingModeRTZ|StencilRefReplacingEXT|OutputLinesNV|OutputPrimitivesNV|DerivativeGroupQuadsNV|DerivativeGroupLinearNV|OutputTrianglesNV|PixelInterlockOrderedEXT|PixelInterlockUnorderedEXT|SampleInterlockOrderedEXT|SampleInterlockUnorderedEXT|ShadingRateInterlockOrderedEXT|ShadingRateInterlockUnorderedEXT)\\b", + "match": "\\b(Invocations|SpacingEqual|SpacingFractionalEven|SpacingFractionalOdd|VertexOrderCw|VertexOrderCcw|PixelCenterInteger|OriginUpperLeft|OriginLowerLeft|EarlyFragmentTests|PointMode|Xfb|DepthReplacing|DepthGreater|DepthLess|DepthUnchanged|LocalSize|LocalSizeHint|InputPoints|InputLines|InputLinesAdjacency|Triangles|InputTrianglesAdjacency|Quads|Isolines|OutputVertices|OutputPoints|OutputLineStrip|OutputTriangleStrip|VecTypeHint|ContractionOff|Initializer|Finalizer|SubgroupSize|SubgroupsPerWorkgroup|SubgroupsPerWorkgroupId|LocalSizeId|LocalSizeHintId|NonCoherentColorAttachmentReadEXT|NonCoherentDepthAttachmentReadEXT|NonCoherentStencilAttachmentReadEXT|SubgroupUniformControlFlowKHR|PostDepthCoverage|DenormPreserve|DenormFlushToZero|SignedZeroInfNanPreserve|RoundingModeRTE|RoundingModeRTZ|EarlyAndLateFragmentTestsAMD|StencilRefReplacingEXT|CoalescingAMDX|IsApiEntryAMDX|MaxNodeRecursionAMDX|StaticNumWorkgroupsAMDX|ShaderIndexAMDX|MaxNumWorkgroupsAMDX|StencilRefUnchangedFrontAMD|StencilRefGreaterFrontAMD|StencilRefLessFrontAMD|StencilRefUnchangedBackAMD|StencilRefGreaterBackAMD|StencilRefLessBackAMD|QuadDerivativesKHR|RequireFullQuadsKHR|SharesInputWithAMDX|OutputLinesEXT|OutputPrimitivesEXT|DerivativeGroupQuadsKHR|DerivativeGroupLinearKHR|OutputTrianglesEXT|PixelInterlockOrderedEXT|PixelInterlockUnorderedEXT|SampleInterlockOrderedEXT|SampleInterlockUnorderedEXT|ShadingRateInterlockOrderedEXT|ShadingRateInterlockUnorderedEXT|SharedLocalMemorySizeINTEL|RoundingModeRTPINTEL|RoundingModeRTNINTEL|FloatingPointModeALTINTEL|FloatingPointModeIEEEINTEL|MaxWorkgroupSizeINTEL|MaxWorkDimINTEL|NoGlobalOffsetINTEL|NumSIMDWorkitemsINTEL|SchedulerTargetFmaxMhzINTEL|MaximallyReconvergesKHR|FPFastMathDefault|StreamingInterfaceINTEL|RegisterMapInterfaceINTEL|NamedBarrierCountINTEL|MaximumRegistersINTEL|MaximumRegistersIdINTEL|NamedMaximumRegistersINTEL)\\b", "name": "keyword.spirv" }, "ValueEnum_StorageClass": { - "match": "\\b(UniformConstant|Input|Uniform|Output|Workgroup|CrossWorkgroup|Private|Function|Generic|PushConstant|AtomicCounter|Image|StorageBuffer|CallableDataNV|CallableDataKHR|IncomingCallableDataNV|IncomingCallableDataKHR|RayPayloadNV|RayPayloadKHR|HitAttributeNV|HitAttributeKHR|IncomingRayPayloadNV|IncomingRayPayloadKHR|ShaderRecordBufferNV|ShaderRecordBufferKHR|PhysicalStorageBuffer|PhysicalStorageBufferEXT)\\b", + "match": "\\b(UniformConstant|Input|Uniform|Output|Workgroup|CrossWorkgroup|Private|Function|Generic|PushConstant|AtomicCounter|Image|StorageBuffer|TileImageEXT|NodePayloadAMDX|CallableDataKHR|IncomingCallableDataKHR|RayPayloadKHR|HitAttributeKHR|IncomingRayPayloadKHR|ShaderRecordBufferKHR|PhysicalStorageBuffer|HitObjectAttributeNV|TaskPayloadWorkgroupEXT|CodeSectionINTEL|DeviceOnlyINTEL|HostOnlyINTEL)\\b", "name": "keyword.spirv" }, "ValueEnum_Dim": { - "match": "\\b(1D|2D|3D|Cube|Rect|Buffer|SubpassData)\\b", + "match": "\\b(1D|2D|3D|Cube|Rect|Buffer|SubpassData|TileImageDataEXT)\\b", "name": "keyword.spirv" }, "ValueEnum_SamplerAddressingMode": { @@ -125,7 +151,7 @@ "name": "keyword.spirv" }, "ValueEnum_ImageFormat": { - "match": "\\b(Unknown|Rgba32f|Rgba16f|R32f|Rgba8|Rgba8Snorm|Rg32f|Rg16f|R11fG11fB10f|R16f|Rgba16|Rgb10A2|Rg16|Rg8|R16|R8|Rgba16Snorm|Rg16Snorm|Rg8Snorm|R16Snorm|R8Snorm|Rgba32i|Rgba16i|Rgba8i|R32i|Rg32i|Rg16i|Rg8i|R16i|R8i|Rgba32ui|Rgba16ui|Rgba8ui|R32ui|Rgb10a2ui|Rg32ui|Rg16ui|Rg8ui|R16ui|R8ui)\\b", + "match": "\\b(Unknown|Rgba32f|Rgba16f|R32f|Rgba8|Rgba8Snorm|Rg32f|Rg16f|R11fG11fB10f|R16f|Rgba16|Rgb10A2|Rg16|Rg8|R16|R8|Rgba16Snorm|Rg16Snorm|Rg8Snorm|R16Snorm|R8Snorm|Rgba32i|Rgba16i|Rgba8i|R32i|Rg32i|Rg16i|Rg8i|R16i|R8i|Rgba32ui|Rgba16ui|Rgba8ui|R32ui|Rgb10a2ui|Rg32ui|Rg16ui|Rg8ui|R16ui|R8ui|R64ui|R64i)\\b", "name": "keyword.spirv" }, "ValueEnum_ImageChannelOrder": { @@ -133,35 +159,55 @@ "name": "keyword.spirv" }, "ValueEnum_ImageChannelDataType": { - "match": "\\b(SnormInt8|SnormInt16|UnormInt8|UnormInt16|UnormShort565|UnormShort555|UnormInt101010|SignedInt8|SignedInt16|SignedInt32|UnsignedInt8|UnsignedInt16|UnsignedInt32|HalfFloat|Float|UnormInt24|UnormInt101010_2)\\b", + "match": "\\b(SnormInt8|SnormInt16|UnormInt8|UnormInt16|UnormShort565|UnormShort555|UnormInt101010|SignedInt8|SignedInt16|SignedInt32|UnsignedInt8|UnsignedInt16|UnsignedInt32|HalfFloat|Float|UnormInt24|UnormInt101010_2|UnsignedIntRaw10EXT|UnsignedIntRaw12EXT|UnormInt2_101010EXT)\\b", "name": "keyword.spirv" }, "ValueEnum_FPRoundingMode": { "match": "\\b(RTE|RTZ|RTP|RTN)\\b", "name": "keyword.spirv" }, + "ValueEnum_FPDenormMode": { + "match": "\\b(Preserve|FlushToZero)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_QuantizationModes": { + "match": "\\b(TRN|TRN_ZERO|RND|RND_ZERO|RND_INF|RND_MIN_INF|RND_CONV|RND_CONV_ODD)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_FPOperationMode": { + "match": "\\b(IEEE|ALT)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_OverflowModes": { + "match": "\\b(WRAP|SAT|SAT_ZERO|SAT_SYM)\\b", + "name": "keyword.spirv" + }, "ValueEnum_LinkageType": { - "match": "\\b(Export|Import)\\b", + "match": "\\b(Export|Import|LinkOnceODR)\\b", "name": "keyword.spirv" }, "ValueEnum_AccessQualifier": { "match": "\\b(ReadOnly|WriteOnly|ReadWrite)\\b", "name": "keyword.spirv" }, + "ValueEnum_HostAccessQualifier": { + "match": "\\b(NoneINTEL|ReadINTEL|WriteINTEL|ReadWriteINTEL)\\b", + "name": "keyword.spirv" + }, "ValueEnum_FunctionParameterAttribute": { - "match": "\\b(Zext|Sext|ByVal|Sret|NoAlias|NoCapture|NoWrite|NoReadWrite)\\b", + "match": "\\b(Zext|Sext|ByVal|Sret|NoAlias|NoCapture|NoWrite|NoReadWrite|RuntimeAlignedINTEL)\\b", "name": "keyword.spirv" }, "ValueEnum_Decoration": { - "match": "\\b(RelaxedPrecision|SpecId|Block|BufferBlock|RowMajor|ColMajor|ArrayStride|MatrixStride|GLSLShared|GLSLPacked|CPacked|BuiltIn|NoPerspective|Flat|Patch|Centroid|Sample|Invariant|Restrict|Aliased|Volatile|Constant|Coherent|NonWritable|NonReadable|Uniform|UniformId|SaturatedConversion|Stream|Location|Component|Index|Binding|DescriptorSet|Offset|XfbBuffer|XfbStride|FuncParamAttr|FPRoundingMode|FPFastMathMode|LinkageAttributes|NoContraction|InputAttachmentIndex|Alignment|MaxByteOffset|AlignmentId|MaxByteOffsetId|NoSignedWrap|NoUnsignedWrap|ExplicitInterpAMD|OverrideCoverageNV|PassthroughNV|ViewportRelativeNV|SecondaryViewportRelativeNV|PerPrimitiveNV|PerViewNV|PerTaskNV|PerVertexNV|NonUniform|NonUniformEXT|RestrictPointer|RestrictPointerEXT|AliasedPointer|AliasedPointerEXT|CounterBuffer|HlslCounterBufferGOOGLE|UserSemantic|HlslSemanticGOOGLE|UserTypeGOOGLE)\\b", + "match": "\\b(RelaxedPrecision|SpecId|Block|BufferBlock|RowMajor|ColMajor|ArrayStride|MatrixStride|GLSLShared|GLSLPacked|CPacked|BuiltIn|NoPerspective|Flat|Patch|Centroid|Sample|Invariant|Restrict|Aliased|Volatile|Constant|Coherent|NonWritable|NonReadable|Uniform|UniformId|SaturatedConversion|Stream|Location|Component|Index|Binding|DescriptorSet|Offset|XfbBuffer|XfbStride|FuncParamAttr|FPRoundingMode|FPFastMathMode|LinkageAttributes|NoContraction|InputAttachmentIndex|Alignment|MaxByteOffset|AlignmentId|MaxByteOffsetId|NoSignedWrap|NoUnsignedWrap|WeightTextureQCOM|BlockMatchTextureQCOM|BlockMatchSamplerQCOM|ExplicitInterpAMD|NodeSharesPayloadLimitsWithAMDX|NodeMaxPayloadsAMDX|TrackFinishWritingAMDX|PayloadNodeNameAMDX|PayloadNodeBaseIndexAMDX|PayloadNodeSparseArrayAMDX|PayloadNodeArraySizeAMDX|PayloadDispatchIndirectAMDX|OverrideCoverageNV|PassthroughNV|ViewportRelativeNV|SecondaryViewportRelativeNV|PerPrimitiveEXT|PerViewNV|PerTaskNV|PerVertexKHR|NonUniform|RestrictPointer|AliasedPointer|HitObjectShaderRecordBufferNV|BindlessSamplerNV|BindlessImageNV|BoundSamplerNV|BoundImageNV|SIMTCallINTEL|ReferencedIndirectlyINTEL|ClobberINTEL|SideEffectsINTEL|VectorComputeVariableINTEL|FuncParamIOKindINTEL|VectorComputeFunctionINTEL|StackCallINTEL|GlobalVariableOffsetINTEL|CounterBuffer|UserSemantic|UserTypeGOOGLE|FunctionRoundingModeINTEL|FunctionDenormModeINTEL|RegisterINTEL|MemoryINTEL|NumbanksINTEL|BankwidthINTEL|MaxPrivateCopiesINTEL|SinglepumpINTEL|DoublepumpINTEL|MaxReplicatesINTEL|SimpleDualPortINTEL|MergeINTEL|BankBitsINTEL|ForcePow2DepthINTEL|StridesizeINTEL|WordsizeINTEL|TrueDualPortINTEL|BurstCoalesceINTEL|CacheSizeINTEL|DontStaticallyCoalesceINTEL|PrefetchINTEL|StallEnableINTEL|FuseLoopsInFunctionINTEL|MathOpDSPModeINTEL|AliasScopeINTEL|NoAliasINTEL|InitiationIntervalINTEL|MaxConcurrencyINTEL|PipelineEnableINTEL|BufferLocationINTEL|IOPipeStorageINTEL|FunctionFloatingPointModeINTEL|SingleElementVectorINTEL|VectorComputeCallableFunctionINTEL|MediaBlockIOINTEL|StallFreeINTEL|FPMaxErrorDecorationINTEL|LatencyControlLabelINTEL|LatencyControlConstraintINTEL|ConduitKernelArgumentINTEL|RegisterMapKernelArgumentINTEL|MMHostInterfaceAddressWidthINTEL|MMHostInterfaceDataWidthINTEL|MMHostInterfaceLatencyINTEL|MMHostInterfaceReadWriteModeINTEL|MMHostInterfaceMaxBurstINTEL|MMHostInterfaceWaitRequestINTEL|StableKernelArgumentINTEL|HostAccessINTEL|InitModeINTEL|ImplementInRegisterMapINTEL|CacheControlLoadINTEL|CacheControlStoreINTEL)\\b", "name": "keyword.spirv" }, "ValueEnum_BuiltIn": { - "match": "\\b(Position|PointSize|ClipDistance|CullDistance|VertexId|InstanceId|PrimitiveId|InvocationId|Layer|ViewportIndex|TessLevelOuter|TessLevelInner|TessCoord|PatchVertices|FragCoord|PointCoord|FrontFacing|SampleId|SamplePosition|SampleMask|FragDepth|HelperInvocation|NumWorkgroups|WorkgroupSize|WorkgroupId|LocalInvocationId|GlobalInvocationId|LocalInvocationIndex|WorkDim|GlobalSize|EnqueuedWorkgroupSize|GlobalOffset|GlobalLinearId|SubgroupSize|SubgroupMaxSize|NumSubgroups|NumEnqueuedSubgroups|SubgroupId|SubgroupLocalInvocationId|VertexIndex|InstanceIndex|SubgroupEqMask|SubgroupGeMask|SubgroupGtMask|SubgroupLeMask|SubgroupLtMask|SubgroupEqMaskKHR|SubgroupGeMaskKHR|SubgroupGtMaskKHR|SubgroupLeMaskKHR|SubgroupLtMaskKHR|BaseVertex|BaseInstance|DrawIndex|DeviceIndex|ViewIndex|BaryCoordNoPerspAMD|BaryCoordNoPerspCentroidAMD|BaryCoordNoPerspSampleAMD|BaryCoordSmoothAMD|BaryCoordSmoothCentroidAMD|BaryCoordSmoothSampleAMD|BaryCoordPullModelAMD|FragStencilRefEXT|ViewportMaskNV|SecondaryPositionNV|SecondaryViewportMaskNV|PositionPerViewNV|ViewportMaskPerViewNV|FullyCoveredEXT|TaskCountNV|PrimitiveCountNV|PrimitiveIndicesNV|ClipDistancePerViewNV|CullDistancePerViewNV|LayerPerViewNV|MeshViewCountNV|MeshViewIndicesNV|BaryCoordNV|BaryCoordNoPerspNV|FragSizeEXT|FragmentSizeNV|FragInvocationCountEXT|InvocationsPerPixelNV|LaunchIdNV|LaunchIdKHR|LaunchSizeNV|LaunchSizeKHR|WorldRayOriginNV|WorldRayOriginKHR|WorldRayDirectionNV|WorldRayDirectionKHR|ObjectRayOriginNV|ObjectRayOriginKHR|ObjectRayDirectionNV|ObjectRayDirectionKHR|RayTminNV|RayTminKHR|RayTmaxNV|RayTmaxKHR|InstanceCustomIndexNV|InstanceCustomIndexKHR|ObjectToWorldNV|ObjectToWorldKHR|WorldToObjectNV|WorldToObjectKHR|HitTNV|HitTKHR|HitKindNV|HitKindKHR|IncomingRayFlagsNV|IncomingRayFlagsKHR|RayGeometryIndexKHR|WarpsPerSMNV|SMCountNV|WarpIDNV|SMIDNV)\\b", + "match": "\\b(Position|PointSize|ClipDistance|CullDistance|VertexId|InstanceId|PrimitiveId|InvocationId|Layer|ViewportIndex|TessLevelOuter|TessLevelInner|TessCoord|PatchVertices|FragCoord|PointCoord|FrontFacing|SampleId|SamplePosition|SampleMask|FragDepth|HelperInvocation|NumWorkgroups|WorkgroupSize|WorkgroupId|LocalInvocationId|GlobalInvocationId|LocalInvocationIndex|WorkDim|GlobalSize|EnqueuedWorkgroupSize|GlobalOffset|GlobalLinearId|SubgroupSize|SubgroupMaxSize|NumSubgroups|NumEnqueuedSubgroups|SubgroupId|SubgroupLocalInvocationId|VertexIndex|InstanceIndex|CoreIDARM|CoreCountARM|CoreMaxIDARM|WarpIDARM|WarpMaxIDARM|SubgroupEqMask|SubgroupGeMask|SubgroupGtMask|SubgroupLeMask|SubgroupLtMask|BaseVertex|BaseInstance|DrawIndex|PrimitiveShadingRateKHR|DeviceIndex|ViewIndex|ShadingRateKHR|BaryCoordNoPerspAMD|BaryCoordNoPerspCentroidAMD|BaryCoordNoPerspSampleAMD|BaryCoordSmoothAMD|BaryCoordSmoothCentroidAMD|BaryCoordSmoothSampleAMD|BaryCoordPullModelAMD|FragStencilRefEXT|RemainingRecursionLevelsAMDX|ShaderIndexAMDX|ViewportMaskNV|SecondaryPositionNV|SecondaryViewportMaskNV|PositionPerViewNV|ViewportMaskPerViewNV|FullyCoveredEXT|TaskCountNV|PrimitiveCountNV|PrimitiveIndicesNV|ClipDistancePerViewNV|CullDistancePerViewNV|LayerPerViewNV|MeshViewCountNV|MeshViewIndicesNV|BaryCoordKHR|BaryCoordNoPerspKHR|FragSizeEXT|FragInvocationCountEXT|PrimitivePointIndicesEXT|PrimitiveLineIndicesEXT|PrimitiveTriangleIndicesEXT|CullPrimitiveEXT|LaunchIdKHR|LaunchSizeKHR|WorldRayOriginKHR|WorldRayDirectionKHR|ObjectRayOriginKHR|ObjectRayDirectionKHR|RayTminKHR|RayTmaxKHR|InstanceCustomIndexKHR|ObjectToWorldKHR|WorldToObjectKHR|HitTNV|HitKindKHR|CurrentRayTimeNV|HitTriangleVertexPositionsKHR|HitMicroTriangleVertexPositionsNV|HitMicroTriangleVertexBarycentricsNV|IncomingRayFlagsKHR|RayGeometryIndexKHR|WarpsPerSMNV|SMCountNV|WarpIDNV|SMIDNV|HitKindFrontFacingMicroTriangleNV|HitKindBackFacingMicroTriangleNV|CullMaskKHR)\\b", "name": "keyword.spirv" }, "ValueEnum_Scope": { - "match": "\\b(CrossDevice|Device|Workgroup|Subgroup|Invocation|QueueFamily|QueueFamilyKHR|ShaderCallKHR)\\b", + "match": "\\b(CrossDevice|Device|Workgroup|Subgroup|Invocation|QueueFamily|ShaderCallKHR)\\b", "name": "keyword.spirv" }, "ValueEnum_GroupOperation": { @@ -173,7 +219,7 @@ "name": "keyword.spirv" }, "ValueEnum_Capability": { - "match": "\\b(Matrix|Shader|Geometry|Tessellation|Addresses|Linkage|Kernel|Vector16|Float16Buffer|Float16|Float64|Int64|Int64Atomics|ImageBasic|ImageReadWrite|ImageMipmap|Pipes|Groups|DeviceEnqueue|LiteralSampler|AtomicStorage|Int16|TessellationPointSize|GeometryPointSize|ImageGatherExtended|StorageImageMultisample|UniformBufferArrayDynamicIndexing|SampledImageArrayDynamicIndexing|StorageBufferArrayDynamicIndexing|StorageImageArrayDynamicIndexing|ClipDistance|CullDistance|ImageCubeArray|SampleRateShading|ImageRect|SampledRect|GenericPointer|Int8|InputAttachment|SparseResidency|MinLod|Sampled1D|Image1D|SampledCubeArray|SampledBuffer|ImageBuffer|ImageMSArray|StorageImageExtendedFormats|ImageQuery|DerivativeControl|InterpolationFunction|TransformFeedback|GeometryStreams|StorageImageReadWithoutFormat|StorageImageWriteWithoutFormat|MultiViewport|SubgroupDispatch|NamedBarrier|PipeStorage|GroupNonUniform|GroupNonUniformVote|GroupNonUniformArithmetic|GroupNonUniformBallot|GroupNonUniformShuffle|GroupNonUniformShuffleRelative|GroupNonUniformClustered|GroupNonUniformQuad|ShaderLayer|ShaderViewportIndex|SubgroupBallotKHR|DrawParameters|SubgroupVoteKHR|StorageBuffer16BitAccess|StorageUniformBufferBlock16|UniformAndStorageBuffer16BitAccess|StorageUniform16|StoragePushConstant16|StorageInputOutput16|DeviceGroup|MultiView|VariablePointersStorageBuffer|VariablePointers|AtomicStorageOps|SampleMaskPostDepthCoverage|StorageBuffer8BitAccess|UniformAndStorageBuffer8BitAccess|StoragePushConstant8|DenormPreserve|DenormFlushToZero|SignedZeroInfNanPreserve|RoundingModeRTE|RoundingModeRTZ|RayQueryProvisionalKHR|RayTraversalPrimitiveCullingProvisionalKHR|Float16ImageAMD|ImageGatherBiasLodAMD|FragmentMaskAMD|StencilExportEXT|ImageReadWriteLodAMD|ShaderClockKHR|SampleMaskOverrideCoverageNV|GeometryShaderPassthroughNV|ShaderViewportIndexLayerEXT|ShaderViewportIndexLayerNV|ShaderViewportMaskNV|ShaderStereoViewNV|PerViewAttributesNV|FragmentFullyCoveredEXT|MeshShadingNV|ImageFootprintNV|FragmentBarycentricNV|ComputeDerivativeGroupQuadsNV|FragmentDensityEXT|ShadingRateNV|GroupNonUniformPartitionedNV|ShaderNonUniform|ShaderNonUniformEXT|RuntimeDescriptorArray|RuntimeDescriptorArrayEXT|InputAttachmentArrayDynamicIndexing|InputAttachmentArrayDynamicIndexingEXT|UniformTexelBufferArrayDynamicIndexing|UniformTexelBufferArrayDynamicIndexingEXT|StorageTexelBufferArrayDynamicIndexing|StorageTexelBufferArrayDynamicIndexingEXT|UniformBufferArrayNonUniformIndexing|UniformBufferArrayNonUniformIndexingEXT|SampledImageArrayNonUniformIndexing|SampledImageArrayNonUniformIndexingEXT|StorageBufferArrayNonUniformIndexing|StorageBufferArrayNonUniformIndexingEXT|StorageImageArrayNonUniformIndexing|StorageImageArrayNonUniformIndexingEXT|InputAttachmentArrayNonUniformIndexing|InputAttachmentArrayNonUniformIndexingEXT|UniformTexelBufferArrayNonUniformIndexing|UniformTexelBufferArrayNonUniformIndexingEXT|StorageTexelBufferArrayNonUniformIndexing|StorageTexelBufferArrayNonUniformIndexingEXT|RayTracingNV|VulkanMemoryModel|VulkanMemoryModelKHR|VulkanMemoryModelDeviceScope|VulkanMemoryModelDeviceScopeKHR|PhysicalStorageBufferAddresses|PhysicalStorageBufferAddressesEXT|ComputeDerivativeGroupLinearNV|RayTracingProvisionalKHR|CooperativeMatrixNV|FragmentShaderSampleInterlockEXT|FragmentShaderShadingRateInterlockEXT|ShaderSMBuiltinsNV|FragmentShaderPixelInterlockEXT|DemoteToHelperInvocationEXT|SubgroupShuffleINTEL|SubgroupBufferBlockIOINTEL|SubgroupImageBlockIOINTEL|SubgroupImageMediaBlockIOINTEL|IntegerFunctions2INTEL|SubgroupAvcMotionEstimationINTEL|SubgroupAvcMotionEstimationIntraINTEL|SubgroupAvcMotionEstimationChromaINTEL)\\b", + "match": "\\b(Matrix|Shader|Geometry|Tessellation|Addresses|Linkage|Kernel|Vector16|Float16Buffer|Float16|Float64|Int64|Int64Atomics|ImageBasic|ImageReadWrite|ImageMipmap|Pipes|Groups|DeviceEnqueue|LiteralSampler|AtomicStorage|Int16|TessellationPointSize|GeometryPointSize|ImageGatherExtended|StorageImageMultisample|UniformBufferArrayDynamicIndexing|SampledImageArrayDynamicIndexing|StorageBufferArrayDynamicIndexing|StorageImageArrayDynamicIndexing|ClipDistance|CullDistance|ImageCubeArray|SampleRateShading|ImageRect|SampledRect|GenericPointer|Int8|InputAttachment|SparseResidency|MinLod|Sampled1D|Image1D|SampledCubeArray|SampledBuffer|ImageBuffer|ImageMSArray|StorageImageExtendedFormats|ImageQuery|DerivativeControl|InterpolationFunction|TransformFeedback|GeometryStreams|StorageImageReadWithoutFormat|StorageImageWriteWithoutFormat|MultiViewport|SubgroupDispatch|NamedBarrier|PipeStorage|GroupNonUniform|GroupNonUniformVote|GroupNonUniformArithmetic|GroupNonUniformBallot|GroupNonUniformShuffle|GroupNonUniformShuffleRelative|GroupNonUniformClustered|GroupNonUniformQuad|ShaderLayer|ShaderViewportIndex|UniformDecoration|CoreBuiltinsARM|TileImageColorReadAccessEXT|TileImageDepthReadAccessEXT|TileImageStencilReadAccessEXT|CooperativeMatrixLayoutsARM|FragmentShadingRateKHR|SubgroupBallotKHR|DrawParameters|WorkgroupMemoryExplicitLayoutKHR|WorkgroupMemoryExplicitLayout8BitAccessKHR|WorkgroupMemoryExplicitLayout16BitAccessKHR|SubgroupVoteKHR|StorageBuffer16BitAccess|UniformAndStorageBuffer16BitAccess|StoragePushConstant16|StorageInputOutput16|DeviceGroup|MultiView|VariablePointersStorageBuffer|VariablePointers|AtomicStorageOps|SampleMaskPostDepthCoverage|StorageBuffer8BitAccess|UniformAndStorageBuffer8BitAccess|StoragePushConstant8|DenormPreserve|DenormFlushToZero|SignedZeroInfNanPreserve|RoundingModeRTE|RoundingModeRTZ|RayQueryProvisionalKHR|RayQueryKHR|UntypedPointersKHR|RayTraversalPrimitiveCullingKHR|RayTracingKHR|TextureSampleWeightedQCOM|TextureBoxFilterQCOM|TextureBlockMatchQCOM|TextureBlockMatch2QCOM|Float16ImageAMD|ImageGatherBiasLodAMD|FragmentMaskAMD|StencilExportEXT|ImageReadWriteLodAMD|Int64ImageEXT|ShaderClockKHR|ShaderEnqueueAMDX|QuadControlKHR|SampleMaskOverrideCoverageNV|GeometryShaderPassthroughNV|ShaderViewportIndexLayerEXT|ShaderViewportMaskNV|ShaderStereoViewNV|PerViewAttributesNV|FragmentFullyCoveredEXT|MeshShadingNV|ImageFootprintNV|MeshShadingEXT|FragmentBarycentricKHR|ComputeDerivativeGroupQuadsKHR|FragmentDensityEXT|GroupNonUniformPartitionedNV|ShaderNonUniform|RuntimeDescriptorArray|InputAttachmentArrayDynamicIndexing|UniformTexelBufferArrayDynamicIndexing|StorageTexelBufferArrayDynamicIndexing|UniformBufferArrayNonUniformIndexing|SampledImageArrayNonUniformIndexing|StorageBufferArrayNonUniformIndexing|StorageImageArrayNonUniformIndexing|InputAttachmentArrayNonUniformIndexing|UniformTexelBufferArrayNonUniformIndexing|StorageTexelBufferArrayNonUniformIndexing|RayTracingPositionFetchKHR|RayTracingNV|RayTracingMotionBlurNV|VulkanMemoryModel|VulkanMemoryModelDeviceScope|PhysicalStorageBufferAddresses|ComputeDerivativeGroupLinearKHR|RayTracingProvisionalKHR|CooperativeMatrixNV|FragmentShaderSampleInterlockEXT|FragmentShaderShadingRateInterlockEXT|ShaderSMBuiltinsNV|FragmentShaderPixelInterlockEXT|DemoteToHelperInvocation|DisplacementMicromapNV|RayTracingOpacityMicromapEXT|ShaderInvocationReorderNV|BindlessTextureNV|RayQueryPositionFetchKHR|AtomicFloat16VectorNV|RayTracingDisplacementMicromapNV|RawAccessChainsNV|CooperativeMatrixReductionsNV|CooperativeMatrixConversionsNV|CooperativeMatrixPerElementOperationsNV|CooperativeMatrixTensorAddressingNV|CooperativeMatrixBlockLoadsNV|TensorAddressingNV|SubgroupShuffleINTEL|SubgroupBufferBlockIOINTEL|SubgroupImageBlockIOINTEL|SubgroupImageMediaBlockIOINTEL|RoundToInfinityINTEL|FloatingPointModeINTEL|IntegerFunctions2INTEL|FunctionPointersINTEL|IndirectReferencesINTEL|AsmINTEL|AtomicFloat32MinMaxEXT|AtomicFloat64MinMaxEXT|AtomicFloat16MinMaxEXT|VectorComputeINTEL|VectorAnyINTEL|ExpectAssumeKHR|SubgroupAvcMotionEstimationINTEL|SubgroupAvcMotionEstimationIntraINTEL|SubgroupAvcMotionEstimationChromaINTEL|VariableLengthArrayINTEL|FunctionFloatControlINTEL|FPGAMemoryAttributesINTEL|FPFastMathModeINTEL|ArbitraryPrecisionIntegersINTEL|ArbitraryPrecisionFloatingPointINTEL|UnstructuredLoopControlsINTEL|FPGALoopControlsINTEL|KernelAttributesINTEL|FPGAKernelAttributesINTEL|FPGAMemoryAccessesINTEL|FPGAClusterAttributesINTEL|LoopFuseINTEL|FPGADSPControlINTEL|MemoryAccessAliasingINTEL|FPGAInvocationPipeliningAttributesINTEL|FPGABufferLocationINTEL|ArbitraryPrecisionFixedPointINTEL|USMStorageClassesINTEL|RuntimeAlignedAttributeINTEL|IOPipesINTEL|BlockingPipesINTEL|FPGARegINTEL|DotProductInputAll|DotProductInput4x8Bit|DotProductInput4x8BitPacked|DotProduct|RayCullMaskKHR|CooperativeMatrixKHR|ReplicatedCompositesEXT|BitInstructions|GroupNonUniformRotateKHR|FloatControls2|AtomicFloat32AddEXT|AtomicFloat64AddEXT|LongCompositesINTEL|OptNoneEXT|AtomicFloat16AddEXT|DebugInfoModuleINTEL|BFloat16ConversionINTEL|SplitBarrierINTEL|ArithmeticFenceEXT|FPGAClusterAttributesV2INTEL|FPGAKernelAttributesv2INTEL|FPMaxErrorINTEL|FPGALatencyControlINTEL|FPGAArgumentInterfacesINTEL|GlobalVariableHostAccessINTEL|GlobalVariableFPGADecorationsINTEL|SubgroupBufferPrefetchINTEL|GroupUniformArithmeticKHR|MaskedGatherScatterINTEL|CacheControlsINTEL|RegisterLimitsINTEL)\\b", "name": "keyword.spirv" }, "ValueEnum_RayQueryIntersection": { @@ -188,8 +234,52 @@ "match": "\\b(RayQueryCandidateIntersectionTriangleKHR|RayQueryCandidateIntersectionAABBKHR)\\b", "name": "keyword.spirv" }, + "ValueEnum_PackedVectorFormat": { + "match": "\\b(PackedVectorFormat4x8Bit)\\b", + "name": "keyword.spirv" + }, + "BitEnum_CooperativeMatrixOperands": { + "match": "\\b(NoneKHR|MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR|MatrixCSignedComponentsKHR|MatrixResultSignedComponentsKHR|SaturatingAccumulationKHR)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_CooperativeMatrixLayout": { + "match": "\\b(RowMajorKHR|ColumnMajorKHR|RowBlockedInterleavedARM|ColumnBlockedInterleavedARM)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_CooperativeMatrixUse": { + "match": "\\b(MatrixAKHR|MatrixBKHR|MatrixAccumulatorKHR)\\b", + "name": "keyword.spirv" + }, + "BitEnum_CooperativeMatrixReduce": { + "match": "\\b(Row|Column|2x2)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_TensorClampMode": { + "match": "\\b(Undefined|Constant|ClampToEdge|Repeat|RepeatMirrored)\\b", + "name": "keyword.spirv" + }, + "BitEnum_TensorAddressingOperands": { + "match": "\\b(None|TensorView|DecodeFunc)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_InitializationModeQualifier": { + "match": "\\b(InitOnDeviceReprogramINTEL|InitOnDeviceResetINTEL)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_LoadCacheControl": { + "match": "\\b(UncachedINTEL|CachedINTEL|StreamingINTEL|InvalidateAfterReadINTEL|ConstCachedINTEL)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_StoreCacheControl": { + "match": "\\b(UncachedINTEL|WriteThroughINTEL|WriteBackINTEL|StreamingINTEL)\\b", + "name": "keyword.spirv" + }, + "ValueEnum_NamedMaximumNumberOfRegisters": { + "match": "\\b(AutoINTEL)\\b", + "name": "keyword.spirv" + }, "BitEnum_DebugInfoFlags": { - "match": "\\b(FlagIsProtected|FlagIsPrivate|FlagIsPublic|FlagIsLocal|FlagIsDefinition|FlagFwdDecl|FlagArtificial|FlagExplicit|FlagPrototyped|FlagObjectPointer|FlagStaticMember|FlagIndirectVariable|FlagLValueReference|FlagRValueReference|FlagIsOptimized|FlagIsEnumClass|FlagTypePassByValue|FlagTypePassByReference)\\b", + "match": "\\b(None|FlagIsProtected|FlagIsPrivate|FlagIsPublic|FlagIsLocal|FlagIsDefinition|FlagFwdDecl|FlagArtificial|FlagExplicit|FlagPrototyped|FlagObjectPointer|FlagStaticMember|FlagIndirectVariable|FlagLValueReference|FlagRValueReference|FlagIsOptimized|FlagIsEnumClass|FlagTypePassByValue|FlagTypePassByReference)\\b", "name": "keyword.spirv" }, "ValueEnum_DebugBaseTypeAttributeEncoding": { @@ -217,7 +307,7 @@ "name": "entity.name.function.spirv" }, "extopcode": { - "match": "(Round|RoundEven|Trunc|FAbs|SAbs|FSign|SSign|Floor|Ceil|Fract|Radians|Degrees|Sin|Cos|Tan|Asin|Acos|Atan|Sinh|Cosh|Tanh|Asinh|Acosh|Atanh|Atan2|Pow|Exp|Log|Exp2|Log2|Sqrt|InverseSqrt|Determinant|MatrixInverse|Modf|ModfStruct|FMin|UMin|SMin|FMax|UMax|SMax|FClamp|UClamp|SClamp|FMix|IMix|Step|SmoothStep|Fma|Frexp|FrexpStruct|Ldexp|PackSnorm4x8|PackUnorm4x8|PackSnorm2x16|PackUnorm2x16|PackHalf2x16|PackDouble2x32|UnpackSnorm2x16|UnpackUnorm2x16|UnpackHalf2x16|UnpackSnorm4x8|UnpackUnorm4x8|UnpackDouble2x32|Length|Distance|Cross|Normalize|FaceForward|Reflect|Refract|FindILsb|FindSMsb|FindUMsb|InterpolateAtCentroid|InterpolateAtSample|InterpolateAtOffset|NMin|NMax|NClamp|acos|acosh|acospi|asin|asinh|asinpi|atan|atan2|atanh|atanpi|atan2pi|cbrt|ceil|copysign|cos|cosh|cospi|erfc|erf|exp|exp2|exp10|expm1|fabs|fdim|floor|fma|fmax|fmin|fmod|fract|frexp|hypot|ilogb|ldexp|lgamma|lgamma_r|log|log2|log10|log1p|logb|mad|maxmag|minmag|modf|nan|nextafter|pow|pown|powr|remainder|remquo|rint|rootn|round|rsqrt|sin|sincos|sinh|sinpi|sqrt|tan|tanh|tanpi|tgamma|trunc|half_cos|half_divide|half_exp|half_exp2|half_exp10|half_log|half_log2|half_log10|half_powr|half_recip|half_rsqrt|half_sin|half_sqrt|half_tan|native_cos|native_divide|native_exp|native_exp2|native_exp10|native_log|native_log2|native_log10|native_powr|native_recip|native_rsqrt|native_sin|native_sqrt|native_tan|s_abs|s_abs_diff|s_add_sat|u_add_sat|s_hadd|u_hadd|s_rhadd|u_rhadd|s_clamp|u_clamp|clz|ctz|s_mad_hi|u_mad_sat|s_mad_sat|s_max|u_max|s_min|u_min|s_mul_hi|rotate|s_sub_sat|u_sub_sat|u_upsample|s_upsample|popcount|s_mad24|u_mad24|s_mul24|u_mul24|u_abs|u_abs_diff|u_mul_hi|u_mad_hi|fclamp|degrees|fmax_common|fmin_common|mix|radians|step|smoothstep|sign|cross|distance|length|normalize|fast_distance|fast_length|fast_normalize|bitselect|select|vloadn|vstoren|vload_half|vload_halfn|vstore_half|vstore_half_r|vstore_halfn|vstore_halfn_r|vloada_halfn|vstorea_halfn|vstorea_halfn_r|shuffle|shuffle2|printf|prefetch|DebugInfoNone|DebugCompilationUnit|DebugTypeBasic|DebugTypePointer|DebugTypeQualifier|DebugTypeArray|DebugTypeVector|DebugTypedef|DebugTypeFunction|DebugTypeEnum|DebugTypeComposite|DebugTypeMember|DebugTypeInheritance|DebugTypePtrToMember|DebugTypeTemplate|DebugTypeTemplateParameter|DebugTypeTemplateTemplateParameter|DebugTypeTemplateParameterPack|DebugGlobalVariable|DebugFunctionDeclaration|DebugFunction|DebugLexicalBlock|DebugLexicalBlockDiscriminator|DebugScope|DebugNoScope|DebugInlinedAt|DebugLocalVariable|DebugInlinedVariable|DebugDeclare|DebugValue|DebugOperation|DebugExpression|DebugMacroDef|DebugMacroUndef|DebugImportedEntity|DebugSource)", + "match": "(Round|RoundEven|Trunc|FAbs|SAbs|FSign|SSign|Floor|Ceil|Fract|Radians|Degrees|Sin|Cos|Tan|Asin|Acos|Atan|Sinh|Cosh|Tanh|Asinh|Acosh|Atanh|Atan2|Pow|Exp|Log|Exp2|Log2|Sqrt|InverseSqrt|Determinant|MatrixInverse|Modf|ModfStruct|FMin|UMin|SMin|FMax|UMax|SMax|FClamp|UClamp|SClamp|FMix|IMix|Step|SmoothStep|Fma|Frexp|FrexpStruct|Ldexp|PackSnorm4x8|PackUnorm4x8|PackSnorm2x16|PackUnorm2x16|PackHalf2x16|PackDouble2x32|UnpackSnorm2x16|UnpackUnorm2x16|UnpackHalf2x16|UnpackSnorm4x8|UnpackUnorm4x8|UnpackDouble2x32|Length|Distance|Cross|Normalize|FaceForward|Reflect|Refract|FindILsb|FindSMsb|FindUMsb|InterpolateAtCentroid|InterpolateAtSample|InterpolateAtOffset|NMin|NMax|NClamp|acos|acosh|acospi|asin|asinh|asinpi|atan|atan2|atanh|atanpi|atan2pi|cbrt|ceil|copysign|cos|cosh|cospi|erfc|erf|exp|exp2|exp10|expm1|fabs|fdim|floor|fma|fmax|fmin|fmod|fract|frexp|hypot|ilogb|ldexp|lgamma|lgamma_r|log|log2|log10|log1p|logb|mad|maxmag|minmag|modf|nan|nextafter|pow|pown|powr|remainder|remquo|rint|rootn|round|rsqrt|sin|sincos|sinh|sinpi|sqrt|tan|tanh|tanpi|tgamma|trunc|half_cos|half_divide|half_exp|half_exp2|half_exp10|half_log|half_log2|half_log10|half_powr|half_recip|half_rsqrt|half_sin|half_sqrt|half_tan|native_cos|native_divide|native_exp|native_exp2|native_exp10|native_log|native_log2|native_log10|native_powr|native_recip|native_rsqrt|native_sin|native_sqrt|native_tan|s_abs|s_abs_diff|s_add_sat|u_add_sat|s_hadd|u_hadd|s_rhadd|u_rhadd|s_clamp|u_clamp|clz|ctz|s_mad_hi|u_mad_sat|s_mad_sat|s_max|u_max|s_min|u_min|s_mul_hi|rotate|s_sub_sat|u_sub_sat|u_upsample|s_upsample|popcount|s_mad24|u_mad24|s_mul24|u_mul24|u_abs|u_abs_diff|u_mul_hi|u_mad_hi|fclamp|degrees|fmax_common|fmin_common|mix|radians|step|smoothstep|sign|cross|distance|length|normalize|fast_distance|fast_length|fast_normalize|bitselect|select|vloadn|vstoren|vload_half|vload_halfn|vstore_half|vstore_half_r|vstore_halfn|vstore_halfn_r|vloada_halfn|vstorea_halfn|vstorea_halfn_r|shuffle|shuffle2|printf|prefetch|DebugInfoNone|DebugCompilationUnit|DebugTypeBasic|DebugTypePointer|DebugTypeQualifier|DebugTypeArray|DebugTypeVector|DebugTypedef|DebugTypeFunction|DebugTypeEnum|DebugTypeComposite|DebugTypeMember|DebugTypeInheritance|DebugTypePtrToMember|DebugTypeTemplate|DebugTypeTemplateParameter|DebugTypeTemplateTemplateParameter|DebugTypeTemplateParameterPack|DebugGlobalVariable|DebugFunctionDeclaration|DebugFunction|DebugLexicalBlock|DebugLexicalBlockDiscriminator|DebugScope|DebugNoScope|DebugInlinedAt|DebugLocalVariable|DebugInlinedVariable|DebugDeclare|DebugValue|DebugOperation|DebugExpression|DebugMacroDef|DebugMacroUndef|DebugImportedEntity|DebugSource|DebugModuleINTEL)", "name": "entity.name.function.ext" }, "identifier": { diff --git a/third_party/spirv-tools/utils/vscode/src/langsvr.go b/third_party/spirv-tools/utils/vscode/src/langsvr.go index b76e35f78d..56b11b2d4f 100644 --- a/third_party/spirv-tools/utils/vscode/src/langsvr.go +++ b/third_party/spirv-tools/utils/vscode/src/langsvr.go @@ -19,7 +19,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -67,7 +66,7 @@ func (s wSpy) Write(p []byte) (n int, err error) { // main entry point. func main() { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) if enableDebugLogging { // create a log file in the executable's directory. if logfile, err := os.Create(path.Join(path.Dir(os.Args[0]), "log.txt")); err == nil { @@ -213,6 +212,10 @@ func (s *server) Initialize(ctx context.Context, p *lsp.ParamInitia) (*lsp.Initi ReferencesProvider: true, RenameProvider: true, DocumentFormattingProvider: true, + CompletionProvider: &lsp.CompletionOptions{ + TriggerCharacters: []string{"%"}, + ResolveProvider: false, + }, }, } return &res, nil @@ -225,9 +228,56 @@ func (s *server) WillSaveWaitUntil(ctx context.Context, p *lsp.WillSaveTextDocum log.Println("server.WillSaveWaitUntil()") return nil, nil } + +func markdownOpcode(op *schema.Opcode) string { + sb := strings.Builder{} + sb.WriteString(fmt.Sprintf("**%s** (%s)\n\n", op.Opname, op.Class)) + + for idx, operand := range op.Operands { + sb.WriteString(fmt.Sprintf("Operand %d%s: ", idx, operand.Quantifier)) + sb.WriteString(fmt.Sprintf("%s (%s)\n", operand.Name, operand.Kind.Kind)) + } + + return sb.String() +} + func (s *server) Completion(ctx context.Context, p *lsp.CompletionParams) (*lsp.CompletionList, error) { log.Println("server.Completion()") - return nil, nil + f := s.getFile(p.TextDocument.URI) + if f == nil { + return nil, fmt.Errorf("Unknown file") + } + + if p.Context.TriggerCharacter == "%" { + idents := []lsp.CompletionItem{} + for name, ident := range f.res.Identifiers { + idents = append(idents, lsp.CompletionItem{ + Label: name, + Kind: 6, + Documentation: ident.Definition.Range.Text(f.res.Lines), + }) + } + res := &lsp.CompletionList{ + IsIncomplete: false, + Items: idents, + } + + return res, nil + } + + opcodes := []lsp.CompletionItem{} + for name, opcode := range schema.Opcodes { + opcodes = append(opcodes, lsp.CompletionItem{ + Label: name, + Kind: 3, + Documentation: markdownOpcode(opcode), + }) + } + res := &lsp.CompletionList{ + IsIncomplete: false, + Items: opcodes, + } + return res, nil } func (s *server) Resolve(ctx context.Context, p *lsp.CompletionItem) (*lsp.CompletionItem, error) { log.Println("server.Resolve()") @@ -246,7 +296,7 @@ func (s *server) Hover(ctx context.Context, p *lsp.HoverParams) (*lsp.Hover, err default: sb.WriteString(fmt.Sprintf("", v)) case *parser.Instruction: - sb.WriteString(fmt.Sprintf("```\n%v\n```", v.Opcode.Opname)) + sb.WriteString(markdownOpcode(v.Opcode)) case *parser.Identifier: sb.WriteString(fmt.Sprintf("```\n%v\n```", v.Definition.Range.Text(f.res.Lines))) case *parser.Operand: diff --git a/third_party/spirv-tools/utils/vscode/src/schema/schema.go b/third_party/spirv-tools/utils/vscode/src/schema/schema.go index ed02de4e3a..4a34feca8d 100755 --- a/third_party/spirv-tools/utils/vscode/src/schema/schema.go +++ b/third_party/spirv-tools/utils/vscode/src/schema/schema.go @@ -447,12 +447,60 @@ var ( "OpPtrEqual": OpPtrEqual, "OpPtrNotEqual": OpPtrNotEqual, "OpPtrDiff": OpPtrDiff, + "OpColorAttachmentReadEXT": OpColorAttachmentReadEXT, + "OpDepthAttachmentReadEXT": OpDepthAttachmentReadEXT, + "OpStencilAttachmentReadEXT": OpStencilAttachmentReadEXT, + "OpTerminateInvocation": OpTerminateInvocation, + "OpTypeUntypedPointerKHR": OpTypeUntypedPointerKHR, + "OpUntypedVariableKHR": OpUntypedVariableKHR, + "OpUntypedAccessChainKHR": OpUntypedAccessChainKHR, + "OpUntypedInBoundsAccessChainKHR": OpUntypedInBoundsAccessChainKHR, "OpSubgroupBallotKHR": OpSubgroupBallotKHR, "OpSubgroupFirstInvocationKHR": OpSubgroupFirstInvocationKHR, + "OpUntypedPtrAccessChainKHR": OpUntypedPtrAccessChainKHR, + "OpUntypedInBoundsPtrAccessChainKHR": OpUntypedInBoundsPtrAccessChainKHR, + "OpUntypedArrayLengthKHR": OpUntypedArrayLengthKHR, + "OpUntypedPrefetchKHR": OpUntypedPrefetchKHR, "OpSubgroupAllKHR": OpSubgroupAllKHR, "OpSubgroupAnyKHR": OpSubgroupAnyKHR, "OpSubgroupAllEqualKHR": OpSubgroupAllEqualKHR, + "OpGroupNonUniformRotateKHR": OpGroupNonUniformRotateKHR, "OpSubgroupReadInvocationKHR": OpSubgroupReadInvocationKHR, + "OpExtInstWithForwardRefsKHR": OpExtInstWithForwardRefsKHR, + "OpTraceRayKHR": OpTraceRayKHR, + "OpExecuteCallableKHR": OpExecuteCallableKHR, + "OpConvertUToAccelerationStructureKHR": OpConvertUToAccelerationStructureKHR, + "OpIgnoreIntersectionKHR": OpIgnoreIntersectionKHR, + "OpTerminateRayKHR": OpTerminateRayKHR, + "OpSDot": OpSDot, + "OpUDot": OpUDot, + "OpSUDot": OpSUDot, + "OpSDotAccSat": OpSDotAccSat, + "OpUDotAccSat": OpUDotAccSat, + "OpSUDotAccSat": OpSUDotAccSat, + "OpTypeCooperativeMatrixKHR": OpTypeCooperativeMatrixKHR, + "OpCooperativeMatrixLoadKHR": OpCooperativeMatrixLoadKHR, + "OpCooperativeMatrixStoreKHR": OpCooperativeMatrixStoreKHR, + "OpCooperativeMatrixMulAddKHR": OpCooperativeMatrixMulAddKHR, + "OpCooperativeMatrixLengthKHR": OpCooperativeMatrixLengthKHR, + "OpConstantCompositeReplicateEXT": OpConstantCompositeReplicateEXT, + "OpSpecConstantCompositeReplicateEXT": OpSpecConstantCompositeReplicateEXT, + "OpCompositeConstructReplicateEXT": OpCompositeConstructReplicateEXT, + "OpTypeRayQueryKHR": OpTypeRayQueryKHR, + "OpRayQueryInitializeKHR": OpRayQueryInitializeKHR, + "OpRayQueryTerminateKHR": OpRayQueryTerminateKHR, + "OpRayQueryGenerateIntersectionKHR": OpRayQueryGenerateIntersectionKHR, + "OpRayQueryConfirmIntersectionKHR": OpRayQueryConfirmIntersectionKHR, + "OpRayQueryProceedKHR": OpRayQueryProceedKHR, + "OpRayQueryGetIntersectionTypeKHR": OpRayQueryGetIntersectionTypeKHR, + "OpImageSampleWeightedQCOM": OpImageSampleWeightedQCOM, + "OpImageBoxFilterQCOM": OpImageBoxFilterQCOM, + "OpImageBlockMatchSSDQCOM": OpImageBlockMatchSSDQCOM, + "OpImageBlockMatchSADQCOM": OpImageBlockMatchSADQCOM, + "OpImageBlockMatchWindowSSDQCOM": OpImageBlockMatchWindowSSDQCOM, + "OpImageBlockMatchWindowSADQCOM": OpImageBlockMatchWindowSADQCOM, + "OpImageBlockMatchGatherSSDQCOM": OpImageBlockMatchGatherSSDQCOM, + "OpImageBlockMatchGatherSADQCOM": OpImageBlockMatchGatherSADQCOM, "OpGroupIAddNonUniformAMD": OpGroupIAddNonUniformAMD, "OpGroupFAddNonUniformAMD": OpGroupFAddNonUniformAMD, "OpGroupFMinNonUniformAMD": OpGroupFMinNonUniformAMD, @@ -464,45 +512,66 @@ var ( "OpFragmentMaskFetchAMD": OpFragmentMaskFetchAMD, "OpFragmentFetchAMD": OpFragmentFetchAMD, "OpReadClockKHR": OpReadClockKHR, + "OpAllocateNodePayloadsAMDX": OpAllocateNodePayloadsAMDX, + "OpEnqueueNodePayloadsAMDX": OpEnqueueNodePayloadsAMDX, + "OpTypeNodePayloadArrayAMDX": OpTypeNodePayloadArrayAMDX, + "OpFinishWritingNodePayloadAMDX": OpFinishWritingNodePayloadAMDX, + "OpNodePayloadArrayLengthAMDX": OpNodePayloadArrayLengthAMDX, + "OpIsNodePayloadValidAMDX": OpIsNodePayloadValidAMDX, + "OpConstantStringAMDX": OpConstantStringAMDX, + "OpSpecConstantStringAMDX": OpSpecConstantStringAMDX, + "OpGroupNonUniformQuadAllKHR": OpGroupNonUniformQuadAllKHR, + "OpGroupNonUniformQuadAnyKHR": OpGroupNonUniformQuadAnyKHR, + "OpHitObjectRecordHitMotionNV": OpHitObjectRecordHitMotionNV, + "OpHitObjectRecordHitWithIndexMotionNV": OpHitObjectRecordHitWithIndexMotionNV, + "OpHitObjectRecordMissMotionNV": OpHitObjectRecordMissMotionNV, + "OpHitObjectGetWorldToObjectNV": OpHitObjectGetWorldToObjectNV, + "OpHitObjectGetObjectToWorldNV": OpHitObjectGetObjectToWorldNV, + "OpHitObjectGetObjectRayDirectionNV": OpHitObjectGetObjectRayDirectionNV, + "OpHitObjectGetObjectRayOriginNV": OpHitObjectGetObjectRayOriginNV, + "OpHitObjectTraceRayMotionNV": OpHitObjectTraceRayMotionNV, + "OpHitObjectGetShaderRecordBufferHandleNV": OpHitObjectGetShaderRecordBufferHandleNV, + "OpHitObjectGetShaderBindingTableRecordIndexNV": OpHitObjectGetShaderBindingTableRecordIndexNV, + "OpHitObjectRecordEmptyNV": OpHitObjectRecordEmptyNV, + "OpHitObjectTraceRayNV": OpHitObjectTraceRayNV, + "OpHitObjectRecordHitNV": OpHitObjectRecordHitNV, + "OpHitObjectRecordHitWithIndexNV": OpHitObjectRecordHitWithIndexNV, + "OpHitObjectRecordMissNV": OpHitObjectRecordMissNV, + "OpHitObjectExecuteShaderNV": OpHitObjectExecuteShaderNV, + "OpHitObjectGetCurrentTimeNV": OpHitObjectGetCurrentTimeNV, + "OpHitObjectGetAttributesNV": OpHitObjectGetAttributesNV, + "OpHitObjectGetHitKindNV": OpHitObjectGetHitKindNV, + "OpHitObjectGetPrimitiveIndexNV": OpHitObjectGetPrimitiveIndexNV, + "OpHitObjectGetGeometryIndexNV": OpHitObjectGetGeometryIndexNV, + "OpHitObjectGetInstanceIdNV": OpHitObjectGetInstanceIdNV, + "OpHitObjectGetInstanceCustomIndexNV": OpHitObjectGetInstanceCustomIndexNV, + "OpHitObjectGetWorldRayDirectionNV": OpHitObjectGetWorldRayDirectionNV, + "OpHitObjectGetWorldRayOriginNV": OpHitObjectGetWorldRayOriginNV, + "OpHitObjectGetRayTMaxNV": OpHitObjectGetRayTMaxNV, + "OpHitObjectGetRayTMinNV": OpHitObjectGetRayTMinNV, + "OpHitObjectIsEmptyNV": OpHitObjectIsEmptyNV, + "OpHitObjectIsHitNV": OpHitObjectIsHitNV, + "OpHitObjectIsMissNV": OpHitObjectIsMissNV, + "OpReorderThreadWithHitObjectNV": OpReorderThreadWithHitObjectNV, + "OpReorderThreadWithHintNV": OpReorderThreadWithHintNV, + "OpTypeHitObjectNV": OpTypeHitObjectNV, "OpImageSampleFootprintNV": OpImageSampleFootprintNV, + "OpCooperativeMatrixConvertNV": OpCooperativeMatrixConvertNV, + "OpEmitMeshTasksEXT": OpEmitMeshTasksEXT, + "OpSetMeshOutputsEXT": OpSetMeshOutputsEXT, "OpGroupNonUniformPartitionNV": OpGroupNonUniformPartitionNV, "OpWritePackedPrimitiveIndices4x8NV": OpWritePackedPrimitiveIndices4x8NV, - "OpReportIntersectionNV": OpReportIntersectionNV, + "OpFetchMicroTriangleVertexPositionNV": OpFetchMicroTriangleVertexPositionNV, + "OpFetchMicroTriangleVertexBarycentricNV": OpFetchMicroTriangleVertexBarycentricNV, "OpReportIntersectionKHR": OpReportIntersectionKHR, "OpIgnoreIntersectionNV": OpIgnoreIntersectionNV, - "OpIgnoreIntersectionKHR": OpIgnoreIntersectionKHR, "OpTerminateRayNV": OpTerminateRayNV, - "OpTerminateRayKHR": OpTerminateRayKHR, "OpTraceNV": OpTraceNV, - "OpTraceRayKHR": OpTraceRayKHR, - "OpTypeAccelerationStructureNV": OpTypeAccelerationStructureNV, + "OpTraceMotionNV": OpTraceMotionNV, + "OpTraceRayMotionNV": OpTraceRayMotionNV, + "OpRayQueryGetIntersectionTriangleVertexPositionsKHR": OpRayQueryGetIntersectionTriangleVertexPositionsKHR, "OpTypeAccelerationStructureKHR": OpTypeAccelerationStructureKHR, - "OpTypeRayQueryProvisionalKHR": OpTypeRayQueryProvisionalKHR, - "OpRayQueryInitializeKHR": OpRayQueryInitializeKHR, - "OpRayQueryTerminateKHR": OpRayQueryTerminateKHR, - "OpRayQueryGenerateIntersectionKHR": OpRayQueryGenerateIntersectionKHR, - "OpRayQueryConfirmIntersectionKHR": OpRayQueryConfirmIntersectionKHR, - "OpRayQueryProceedKHR": OpRayQueryProceedKHR, - "OpRayQueryGetIntersectionTypeKHR": OpRayQueryGetIntersectionTypeKHR, - "OpRayQueryGetRayTMinKHR": OpRayQueryGetRayTMinKHR, - "OpRayQueryGetRayFlagsKHR": OpRayQueryGetRayFlagsKHR, - "OpRayQueryGetIntersectionTKHR": OpRayQueryGetIntersectionTKHR, - "OpRayQueryGetIntersectionInstanceCustomIndexKHR": OpRayQueryGetIntersectionInstanceCustomIndexKHR, - "OpRayQueryGetIntersectionInstanceIdKHR": OpRayQueryGetIntersectionInstanceIdKHR, - "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR": OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR, - "OpRayQueryGetIntersectionGeometryIndexKHR": OpRayQueryGetIntersectionGeometryIndexKHR, - "OpRayQueryGetIntersectionPrimitiveIndexKHR": OpRayQueryGetIntersectionPrimitiveIndexKHR, - "OpRayQueryGetIntersectionBarycentricsKHR": OpRayQueryGetIntersectionBarycentricsKHR, - "OpRayQueryGetIntersectionFrontFaceKHR": OpRayQueryGetIntersectionFrontFaceKHR, - "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR": OpRayQueryGetIntersectionCandidateAABBOpaqueKHR, - "OpRayQueryGetIntersectionObjectRayDirectionKHR": OpRayQueryGetIntersectionObjectRayDirectionKHR, - "OpRayQueryGetIntersectionObjectRayOriginKHR": OpRayQueryGetIntersectionObjectRayOriginKHR, - "OpRayQueryGetWorldRayDirectionKHR": OpRayQueryGetWorldRayDirectionKHR, - "OpRayQueryGetWorldRayOriginKHR": OpRayQueryGetWorldRayOriginKHR, - "OpRayQueryGetIntersectionObjectToWorldKHR": OpRayQueryGetIntersectionObjectToWorldKHR, - "OpRayQueryGetIntersectionWorldToObjectKHR": OpRayQueryGetIntersectionWorldToObjectKHR, "OpExecuteCallableNV": OpExecuteCallableNV, - "OpExecuteCallableKHR": OpExecuteCallableKHR, "OpTypeCooperativeMatrixNV": OpTypeCooperativeMatrixNV, "OpCooperativeMatrixLoadNV": OpCooperativeMatrixLoadNV, "OpCooperativeMatrixStoreNV": OpCooperativeMatrixStoreNV, @@ -510,8 +579,33 @@ var ( "OpCooperativeMatrixLengthNV": OpCooperativeMatrixLengthNV, "OpBeginInvocationInterlockEXT": OpBeginInvocationInterlockEXT, "OpEndInvocationInterlockEXT": OpEndInvocationInterlockEXT, - "OpDemoteToHelperInvocationEXT": OpDemoteToHelperInvocationEXT, + "OpCooperativeMatrixReduceNV": OpCooperativeMatrixReduceNV, + "OpCooperativeMatrixLoadTensorNV": OpCooperativeMatrixLoadTensorNV, + "OpCooperativeMatrixStoreTensorNV": OpCooperativeMatrixStoreTensorNV, + "OpCooperativeMatrixPerElementOpNV": OpCooperativeMatrixPerElementOpNV, + "OpTypeTensorLayoutNV": OpTypeTensorLayoutNV, + "OpTypeTensorViewNV": OpTypeTensorViewNV, + "OpCreateTensorLayoutNV": OpCreateTensorLayoutNV, + "OpTensorLayoutSetDimensionNV": OpTensorLayoutSetDimensionNV, + "OpTensorLayoutSetStrideNV": OpTensorLayoutSetStrideNV, + "OpTensorLayoutSliceNV": OpTensorLayoutSliceNV, + "OpTensorLayoutSetClampValueNV": OpTensorLayoutSetClampValueNV, + "OpCreateTensorViewNV": OpCreateTensorViewNV, + "OpTensorViewSetDimensionNV": OpTensorViewSetDimensionNV, + "OpTensorViewSetStrideNV": OpTensorViewSetStrideNV, + "OpDemoteToHelperInvocation": OpDemoteToHelperInvocation, "OpIsHelperInvocationEXT": OpIsHelperInvocationEXT, + "OpTensorViewSetClipNV": OpTensorViewSetClipNV, + "OpTensorLayoutSetBlockSizeNV": OpTensorLayoutSetBlockSizeNV, + "OpCooperativeMatrixTransposeNV": OpCooperativeMatrixTransposeNV, + "OpConvertUToImageNV": OpConvertUToImageNV, + "OpConvertUToSamplerNV": OpConvertUToSamplerNV, + "OpConvertImageToUNV": OpConvertImageToUNV, + "OpConvertSamplerToUNV": OpConvertSamplerToUNV, + "OpConvertUToSampledImageNV": OpConvertUToSampledImageNV, + "OpConvertSampledImageToUNV": OpConvertSampledImageToUNV, + "OpSamplerImageAddressingModeNV": OpSamplerImageAddressingModeNV, + "OpRawAccessChainNV": OpRawAccessChainNV, "OpSubgroupShuffleINTEL": OpSubgroupShuffleINTEL, "OpSubgroupShuffleDownINTEL": OpSubgroupShuffleDownINTEL, "OpSubgroupShuffleUpINTEL": OpSubgroupShuffleUpINTEL, @@ -536,10 +630,17 @@ var ( "OpUSubSatINTEL": OpUSubSatINTEL, "OpIMul32x16INTEL": OpIMul32x16INTEL, "OpUMul32x16INTEL": OpUMul32x16INTEL, + "OpConstantFunctionPointerINTEL": OpConstantFunctionPointerINTEL, + "OpFunctionPointerCallINTEL": OpFunctionPointerCallINTEL, + "OpAsmTargetINTEL": OpAsmTargetINTEL, + "OpAsmINTEL": OpAsmINTEL, + "OpAsmCallINTEL": OpAsmCallINTEL, + "OpAtomicFMinEXT": OpAtomicFMinEXT, + "OpAtomicFMaxEXT": OpAtomicFMaxEXT, + "OpAssumeTrueKHR": OpAssumeTrueKHR, + "OpExpectKHR": OpExpectKHR, "OpDecorateString": OpDecorateString, - "OpDecorateStringGOOGLE": OpDecorateStringGOOGLE, "OpMemberDecorateString": OpMemberDecorateString, - "OpMemberDecorateStringGOOGLE": OpMemberDecorateStringGOOGLE, "OpVmeImageINTEL": OpVmeImageINTEL, "OpTypeVmeImageINTEL": OpTypeVmeImageINTEL, "OpTypeAvcImePayloadINTEL": OpTypeAvcImePayloadINTEL, @@ -658,6 +759,109 @@ var ( "OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL": OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL, "OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL": OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL, "OpSubgroupAvcSicGetInterRawSadsINTEL": OpSubgroupAvcSicGetInterRawSadsINTEL, + "OpVariableLengthArrayINTEL": OpVariableLengthArrayINTEL, + "OpSaveMemoryINTEL": OpSaveMemoryINTEL, + "OpRestoreMemoryINTEL": OpRestoreMemoryINTEL, + "OpArbitraryFloatSinCosPiINTEL": OpArbitraryFloatSinCosPiINTEL, + "OpArbitraryFloatCastINTEL": OpArbitraryFloatCastINTEL, + "OpArbitraryFloatCastFromIntINTEL": OpArbitraryFloatCastFromIntINTEL, + "OpArbitraryFloatCastToIntINTEL": OpArbitraryFloatCastToIntINTEL, + "OpArbitraryFloatAddINTEL": OpArbitraryFloatAddINTEL, + "OpArbitraryFloatSubINTEL": OpArbitraryFloatSubINTEL, + "OpArbitraryFloatMulINTEL": OpArbitraryFloatMulINTEL, + "OpArbitraryFloatDivINTEL": OpArbitraryFloatDivINTEL, + "OpArbitraryFloatGTINTEL": OpArbitraryFloatGTINTEL, + "OpArbitraryFloatGEINTEL": OpArbitraryFloatGEINTEL, + "OpArbitraryFloatLTINTEL": OpArbitraryFloatLTINTEL, + "OpArbitraryFloatLEINTEL": OpArbitraryFloatLEINTEL, + "OpArbitraryFloatEQINTEL": OpArbitraryFloatEQINTEL, + "OpArbitraryFloatRecipINTEL": OpArbitraryFloatRecipINTEL, + "OpArbitraryFloatRSqrtINTEL": OpArbitraryFloatRSqrtINTEL, + "OpArbitraryFloatCbrtINTEL": OpArbitraryFloatCbrtINTEL, + "OpArbitraryFloatHypotINTEL": OpArbitraryFloatHypotINTEL, + "OpArbitraryFloatSqrtINTEL": OpArbitraryFloatSqrtINTEL, + "OpArbitraryFloatLogINTEL": OpArbitraryFloatLogINTEL, + "OpArbitraryFloatLog2INTEL": OpArbitraryFloatLog2INTEL, + "OpArbitraryFloatLog10INTEL": OpArbitraryFloatLog10INTEL, + "OpArbitraryFloatLog1pINTEL": OpArbitraryFloatLog1pINTEL, + "OpArbitraryFloatExpINTEL": OpArbitraryFloatExpINTEL, + "OpArbitraryFloatExp2INTEL": OpArbitraryFloatExp2INTEL, + "OpArbitraryFloatExp10INTEL": OpArbitraryFloatExp10INTEL, + "OpArbitraryFloatExpm1INTEL": OpArbitraryFloatExpm1INTEL, + "OpArbitraryFloatSinINTEL": OpArbitraryFloatSinINTEL, + "OpArbitraryFloatCosINTEL": OpArbitraryFloatCosINTEL, + "OpArbitraryFloatSinCosINTEL": OpArbitraryFloatSinCosINTEL, + "OpArbitraryFloatSinPiINTEL": OpArbitraryFloatSinPiINTEL, + "OpArbitraryFloatCosPiINTEL": OpArbitraryFloatCosPiINTEL, + "OpArbitraryFloatASinINTEL": OpArbitraryFloatASinINTEL, + "OpArbitraryFloatASinPiINTEL": OpArbitraryFloatASinPiINTEL, + "OpArbitraryFloatACosINTEL": OpArbitraryFloatACosINTEL, + "OpArbitraryFloatACosPiINTEL": OpArbitraryFloatACosPiINTEL, + "OpArbitraryFloatATanINTEL": OpArbitraryFloatATanINTEL, + "OpArbitraryFloatATanPiINTEL": OpArbitraryFloatATanPiINTEL, + "OpArbitraryFloatATan2INTEL": OpArbitraryFloatATan2INTEL, + "OpArbitraryFloatPowINTEL": OpArbitraryFloatPowINTEL, + "OpArbitraryFloatPowRINTEL": OpArbitraryFloatPowRINTEL, + "OpArbitraryFloatPowNINTEL": OpArbitraryFloatPowNINTEL, + "OpLoopControlINTEL": OpLoopControlINTEL, + "OpAliasDomainDeclINTEL": OpAliasDomainDeclINTEL, + "OpAliasScopeDeclINTEL": OpAliasScopeDeclINTEL, + "OpAliasScopeListDeclINTEL": OpAliasScopeListDeclINTEL, + "OpFixedSqrtINTEL": OpFixedSqrtINTEL, + "OpFixedRecipINTEL": OpFixedRecipINTEL, + "OpFixedRsqrtINTEL": OpFixedRsqrtINTEL, + "OpFixedSinINTEL": OpFixedSinINTEL, + "OpFixedCosINTEL": OpFixedCosINTEL, + "OpFixedSinCosINTEL": OpFixedSinCosINTEL, + "OpFixedSinPiINTEL": OpFixedSinPiINTEL, + "OpFixedCosPiINTEL": OpFixedCosPiINTEL, + "OpFixedSinCosPiINTEL": OpFixedSinCosPiINTEL, + "OpFixedLogINTEL": OpFixedLogINTEL, + "OpFixedExpINTEL": OpFixedExpINTEL, + "OpPtrCastToCrossWorkgroupINTEL": OpPtrCastToCrossWorkgroupINTEL, + "OpCrossWorkgroupCastToPtrINTEL": OpCrossWorkgroupCastToPtrINTEL, + "OpReadPipeBlockingINTEL": OpReadPipeBlockingINTEL, + "OpWritePipeBlockingINTEL": OpWritePipeBlockingINTEL, + "OpFPGARegINTEL": OpFPGARegINTEL, + "OpRayQueryGetRayTMinKHR": OpRayQueryGetRayTMinKHR, + "OpRayQueryGetRayFlagsKHR": OpRayQueryGetRayFlagsKHR, + "OpRayQueryGetIntersectionTKHR": OpRayQueryGetIntersectionTKHR, + "OpRayQueryGetIntersectionInstanceCustomIndexKHR": OpRayQueryGetIntersectionInstanceCustomIndexKHR, + "OpRayQueryGetIntersectionInstanceIdKHR": OpRayQueryGetIntersectionInstanceIdKHR, + "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR": OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR, + "OpRayQueryGetIntersectionGeometryIndexKHR": OpRayQueryGetIntersectionGeometryIndexKHR, + "OpRayQueryGetIntersectionPrimitiveIndexKHR": OpRayQueryGetIntersectionPrimitiveIndexKHR, + "OpRayQueryGetIntersectionBarycentricsKHR": OpRayQueryGetIntersectionBarycentricsKHR, + "OpRayQueryGetIntersectionFrontFaceKHR": OpRayQueryGetIntersectionFrontFaceKHR, + "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR": OpRayQueryGetIntersectionCandidateAABBOpaqueKHR, + "OpRayQueryGetIntersectionObjectRayDirectionKHR": OpRayQueryGetIntersectionObjectRayDirectionKHR, + "OpRayQueryGetIntersectionObjectRayOriginKHR": OpRayQueryGetIntersectionObjectRayOriginKHR, + "OpRayQueryGetWorldRayDirectionKHR": OpRayQueryGetWorldRayDirectionKHR, + "OpRayQueryGetWorldRayOriginKHR": OpRayQueryGetWorldRayOriginKHR, + "OpRayQueryGetIntersectionObjectToWorldKHR": OpRayQueryGetIntersectionObjectToWorldKHR, + "OpRayQueryGetIntersectionWorldToObjectKHR": OpRayQueryGetIntersectionWorldToObjectKHR, + "OpAtomicFAddEXT": OpAtomicFAddEXT, + "OpTypeBufferSurfaceINTEL": OpTypeBufferSurfaceINTEL, + "OpTypeStructContinuedINTEL": OpTypeStructContinuedINTEL, + "OpConstantCompositeContinuedINTEL": OpConstantCompositeContinuedINTEL, + "OpSpecConstantCompositeContinuedINTEL": OpSpecConstantCompositeContinuedINTEL, + "OpCompositeConstructContinuedINTEL": OpCompositeConstructContinuedINTEL, + "OpConvertFToBF16INTEL": OpConvertFToBF16INTEL, + "OpConvertBF16ToFINTEL": OpConvertBF16ToFINTEL, + "OpControlBarrierArriveINTEL": OpControlBarrierArriveINTEL, + "OpControlBarrierWaitINTEL": OpControlBarrierWaitINTEL, + "OpArithmeticFenceEXT": OpArithmeticFenceEXT, + "OpSubgroupBlockPrefetchINTEL": OpSubgroupBlockPrefetchINTEL, + "OpGroupIMulKHR": OpGroupIMulKHR, + "OpGroupFMulKHR": OpGroupFMulKHR, + "OpGroupBitwiseAndKHR": OpGroupBitwiseAndKHR, + "OpGroupBitwiseOrKHR": OpGroupBitwiseOrKHR, + "OpGroupBitwiseXorKHR": OpGroupBitwiseXorKHR, + "OpGroupLogicalAndKHR": OpGroupLogicalAndKHR, + "OpGroupLogicalOrKHR": OpGroupLogicalOrKHR, + "OpGroupLogicalXorKHR": OpGroupLogicalXorKHR, + "OpMaskedGatherINTEL": OpMaskedGatherINTEL, + "OpMaskedScatterINTEL": OpMaskedScatterINTEL, } // ExtOpcodes is a map of extension name to Opcode description list. @@ -946,6 +1150,7 @@ var ( "DebugMacroUndef": OpenCLDebugInfo100_DebugMacroUndef, "DebugImportedEntity": OpenCLDebugInfo100_DebugImportedEntity, "DebugSource": OpenCLDebugInfo100_DebugSource, + "DebugModuleINTEL": OpenCLDebugInfo100_DebugModuleINTEL, }, } @@ -1297,6 +1502,11 @@ var ( Name: "'Width'", Quantifier: "", }, + Operand { + Kind: OperandKindFPEncoding, + Name: "'Floating Point Encoding'", + Quantifier: "?", + }, }, } OpTypeVector = &Opcode { @@ -10022,6 +10232,197 @@ var ( }, }, } + OpColorAttachmentReadEXT = &Opcode { + Opname: "OpColorAttachmentReadEXT", + Class: "Image", + Opcode: 4160, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Attachment'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Sample'", + Quantifier: "?", + }, + }, + } + OpDepthAttachmentReadEXT = &Opcode { + Opname: "OpDepthAttachmentReadEXT", + Class: "Image", + Opcode: 4161, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Sample'", + Quantifier: "?", + }, + }, + } + OpStencilAttachmentReadEXT = &Opcode { + Opname: "OpStencilAttachmentReadEXT", + Class: "Image", + Opcode: 4162, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Sample'", + Quantifier: "?", + }, + }, + } + OpTerminateInvocation = &Opcode { + Opname: "OpTerminateInvocation", + Class: "Control-Flow", + Opcode: 4416, + Operands: []Operand { + }, + } + OpTypeUntypedPointerKHR = &Opcode { + Opname: "OpTypeUntypedPointerKHR", + Class: "Type-Declaration", + Opcode: 4417, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindStorageClass, + Name: "", + Quantifier: "", + }, + }, + } + OpUntypedVariableKHR = &Opcode { + Opname: "OpUntypedVariableKHR", + Class: "Memory", + Opcode: 4418, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindStorageClass, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Data Type'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Initializer'", + Quantifier: "?", + }, + }, + } + OpUntypedAccessChainKHR = &Opcode { + Opname: "OpUntypedAccessChainKHR", + Class: "Memory", + Opcode: 4419, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Indexes'", + Quantifier: "*", + }, + }, + } + OpUntypedInBoundsAccessChainKHR = &Opcode { + Opname: "OpUntypedInBoundsAccessChainKHR", + Class: "Memory", + Opcode: 4420, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Indexes'", + Quantifier: "*", + }, + }, + } OpSubgroupBallotKHR = &Opcode { Opname: "OpSubgroupBallotKHR", Class: "Group", @@ -10066,6 +10467,144 @@ var ( }, }, } + OpUntypedPtrAccessChainKHR = &Opcode { + Opname: "OpUntypedPtrAccessChainKHR", + Class: "Memory", + Opcode: 4423, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Element'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Indexes'", + Quantifier: "*", + }, + }, + } + OpUntypedInBoundsPtrAccessChainKHR = &Opcode { + Opname: "OpUntypedInBoundsPtrAccessChainKHR", + Class: "Memory", + Opcode: 4424, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Element'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Indexes'", + Quantifier: "*", + }, + }, + } + OpUntypedArrayLengthKHR = &Opcode { + Opname: "OpUntypedArrayLengthKHR", + Class: "Memory", + Opcode: 4425, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Array member'", + Quantifier: "", + }, + }, + } + OpUntypedPrefetchKHR = &Opcode { + Opname: "OpUntypedPrefetchKHR", + Class: "Memory", + Opcode: 4426, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Num Bytes'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RW'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Locality'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Cache Type'", + Quantifier: "?", + }, + }, + } OpSubgroupAllKHR = &Opcode { Opname: "OpSubgroupAllKHR", Class: "Group", @@ -10132,6 +10671,43 @@ var ( }, }, } + OpGroupNonUniformRotateKHR = &Opcode { + Opname: "OpGroupNonUniformRotateKHR", + Class: "Group", + Opcode: 4431, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Delta'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClusterSize'", + Quantifier: "?", + }, + }, + } OpSubgroupReadInvocationKHR = &Opcode { Opname: "OpSubgroupReadInvocationKHR", Class: "Group", @@ -10159,6 +10735,1056 @@ var ( }, }, } + OpExtInstWithForwardRefsKHR = &Opcode { + Opname: "OpExtInstWithForwardRefsKHR", + Class: "Extension", + Opcode: 4433, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Set'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralExtInstInteger, + Name: "'Instruction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand 1', + 'Operand 2', + ...", + Quantifier: "*", + }, + }, + } + OpTraceRayKHR = &Opcode { + Opname: "OpTraceRayKHR", + Class: "Reserved", + Opcode: 4445, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Accel'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Flags'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Cull Mask'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Miss Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Tmin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Tmax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "", + }, + }, + } + OpExecuteCallableKHR = &Opcode { + Opname: "OpExecuteCallableKHR", + Class: "Reserved", + Opcode: 4446, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Callable Data'", + Quantifier: "", + }, + }, + } + OpConvertUToAccelerationStructureKHR = &Opcode { + Opname: "OpConvertUToAccelerationStructureKHR", + Class: "Reserved", + Opcode: 4447, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accel'", + Quantifier: "", + }, + }, + } + OpIgnoreIntersectionKHR = &Opcode { + Opname: "OpIgnoreIntersectionKHR", + Class: "Reserved", + Opcode: 4448, + Operands: []Operand { + }, + } + OpTerminateRayKHR = &Opcode { + Opname: "OpTerminateRayKHR", + Class: "Reserved", + Opcode: 4449, + Operands: []Operand { + }, + } + OpSDot = &Opcode { + Opname: "OpSDot", + Class: "Arithmetic", + Opcode: 4450, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpUDot = &Opcode { + Opname: "OpUDot", + Class: "Arithmetic", + Opcode: 4451, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpSUDot = &Opcode { + Opname: "OpSUDot", + Class: "Arithmetic", + Opcode: 4452, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpSDotAccSat = &Opcode { + Opname: "OpSDotAccSat", + Class: "Arithmetic", + Opcode: 4453, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accumulator'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpUDotAccSat = &Opcode { + Opname: "OpUDotAccSat", + Class: "Arithmetic", + Opcode: 4454, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accumulator'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpSUDotAccSat = &Opcode { + Opname: "OpSUDotAccSat", + Class: "Arithmetic", + Opcode: 4455, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Vector 2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accumulator'", + Quantifier: "", + }, + Operand { + Kind: OperandKindPackedVectorFormat, + Name: "'Packed Vector Format'", + Quantifier: "?", + }, + }, + } + OpTypeCooperativeMatrixKHR = &Opcode { + Opname: "OpTypeCooperativeMatrixKHR", + Class: "Type-Declaration", + Opcode: 4456, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Component Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Scope'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Rows'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Columns'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Use'", + Quantifier: "", + }, + }, + } + OpCooperativeMatrixLoadKHR = &Opcode { + Opname: "OpCooperativeMatrixLoadKHR", + Class: "Memory", + Opcode: 4457, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'MemoryLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Stride'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindMemoryAccess, + Name: "'Memory Operand'", + Quantifier: "?", + }, + }, + } + OpCooperativeMatrixStoreKHR = &Opcode { + Opname: "OpCooperativeMatrixStoreKHR", + Class: "Memory", + Opcode: 4458, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'MemoryLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Stride'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindMemoryAccess, + Name: "'Memory Operand'", + Quantifier: "?", + }, + }, + } + OpCooperativeMatrixMulAddKHR = &Opcode { + Opname: "OpCooperativeMatrixMulAddKHR", + Class: "Arithmetic", + Opcode: 4459, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'C'", + Quantifier: "", + }, + Operand { + Kind: OperandKindCooperativeMatrixOperands, + Name: "'Cooperative Matrix Operands'", + Quantifier: "?", + }, + }, + } + OpCooperativeMatrixLengthKHR = &Opcode { + Opname: "OpCooperativeMatrixLengthKHR", + Class: "Miscellaneous", + Opcode: 4460, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Type'", + Quantifier: "", + }, + }, + } + OpConstantCompositeReplicateEXT = &Opcode { + Opname: "OpConstantCompositeReplicateEXT", + Class: "Constant-Creation", + Opcode: 4461, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpSpecConstantCompositeReplicateEXT = &Opcode { + Opname: "OpSpecConstantCompositeReplicateEXT", + Class: "Constant-Creation", + Opcode: 4462, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpCompositeConstructReplicateEXT = &Opcode { + Opname: "OpCompositeConstructReplicateEXT", + Class: "Composite", + Opcode: 4463, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpTypeRayQueryKHR = &Opcode { + Opname: "OpTypeRayQueryKHR", + Class: "Type-Declaration", + Opcode: 4472, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + }, + } + OpRayQueryInitializeKHR = &Opcode { + Opname: "OpRayQueryInitializeKHR", + Class: "Reserved", + Opcode: 4473, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accel'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayFlags'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'CullMask'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayOrigin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayTMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayDirection'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayTMax'", + Quantifier: "", + }, + }, + } + OpRayQueryTerminateKHR = &Opcode { + Opname: "OpRayQueryTerminateKHR", + Class: "Reserved", + Opcode: 4474, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGenerateIntersectionKHR = &Opcode { + Opname: "OpRayQueryGenerateIntersectionKHR", + Class: "Reserved", + Opcode: 4475, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HitT'", + Quantifier: "", + }, + }, + } + OpRayQueryConfirmIntersectionKHR = &Opcode { + Opname: "OpRayQueryConfirmIntersectionKHR", + Class: "Reserved", + Opcode: 4476, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryProceedKHR = &Opcode { + Opname: "OpRayQueryProceedKHR", + Class: "Reserved", + Opcode: 4477, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionTypeKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionTypeKHR", + Class: "Reserved", + Opcode: 4479, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpImageSampleWeightedQCOM = &Opcode { + Opname: "OpImageSampleWeightedQCOM", + Class: "Image", + Opcode: 4480, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Texture'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Weights'", + Quantifier: "", + }, + }, + } + OpImageBoxFilterQCOM = &Opcode { + Opname: "OpImageBoxFilterQCOM", + Class: "Image", + Opcode: 4481, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Texture'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Box Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchSSDQCOM = &Opcode { + Opname: "OpImageBlockMatchSSDQCOM", + Class: "Image", + Opcode: 4482, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchSADQCOM = &Opcode { + Opname: "OpImageBlockMatchSADQCOM", + Class: "Image", + Opcode: 4483, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchWindowSSDQCOM = &Opcode { + Opname: "OpImageBlockMatchWindowSSDQCOM", + Class: "Image", + Opcode: 4500, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchWindowSADQCOM = &Opcode { + Opname: "OpImageBlockMatchWindowSADQCOM", + Class: "Image", + Opcode: 4501, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchGatherSSDQCOM = &Opcode { + Opname: "OpImageBlockMatchGatherSSDQCOM", + Class: "Image", + Opcode: 4502, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } + OpImageBlockMatchGatherSADQCOM = &Opcode { + Opname: "OpImageBlockMatchGatherSADQCOM", + Class: "Image", + Opcode: 4503, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Sampled Image'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Reference Coordinates'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Block Size'", + Quantifier: "", + }, + }, + } OpGroupIAddNonUniformAMD = &Opcode { Opname: "OpGroupIAddNonUniformAMD", Class: "Group", @@ -10491,7 +12117,1238 @@ var ( }, Operand { Kind: OperandKindIdScope, - Name: "'Execution'", + Name: "'Scope'", + Quantifier: "", + }, + }, + } + OpAllocateNodePayloadsAMDX = &Opcode { + Opname: "OpAllocateNodePayloadsAMDX", + Class: "Reserved", + Opcode: 5074, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Visibility'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload Count'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Node Index'", + Quantifier: "", + }, + }, + } + OpEnqueueNodePayloadsAMDX = &Opcode { + Opname: "OpEnqueueNodePayloadsAMDX", + Class: "Reserved", + Opcode: 5075, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Payload Array'", + Quantifier: "", + }, + }, + } + OpTypeNodePayloadArrayAMDX = &Opcode { + Opname: "OpTypeNodePayloadArrayAMDX", + Class: "Reserved", + Opcode: 5076, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload Type'", + Quantifier: "", + }, + }, + } + OpFinishWritingNodePayloadAMDX = &Opcode { + Opname: "OpFinishWritingNodePayloadAMDX", + Class: "Reserved", + Opcode: 5078, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "", + }, + }, + } + OpNodePayloadArrayLengthAMDX = &Opcode { + Opname: "OpNodePayloadArrayLengthAMDX", + Class: "Reserved", + Opcode: 5090, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload Array'", + Quantifier: "", + }, + }, + } + OpIsNodePayloadValidAMDX = &Opcode { + Opname: "OpIsNodePayloadValidAMDX", + Class: "Reserved", + Opcode: 5101, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Node Index'", + Quantifier: "", + }, + }, + } + OpConstantStringAMDX = &Opcode { + Opname: "OpConstantStringAMDX", + Class: "Reserved", + Opcode: 5103, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralString, + Name: "'Literal String'", + Quantifier: "", + }, + }, + } + OpSpecConstantStringAMDX = &Opcode { + Opname: "OpSpecConstantStringAMDX", + Class: "Reserved", + Opcode: 5104, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralString, + Name: "'Literal String'", + Quantifier: "", + }, + }, + } + OpGroupNonUniformQuadAllKHR = &Opcode { + Opname: "OpGroupNonUniformQuadAllKHR", + Class: "Non-Uniform", + Opcode: 5110, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Predicate'", + Quantifier: "", + }, + }, + } + OpGroupNonUniformQuadAnyKHR = &Opcode { + Opname: "OpGroupNonUniformQuadAnyKHR", + Class: "Non-Uniform", + Opcode: 5111, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Predicate'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordHitMotionNV = &Opcode { + Opname: "OpHitObjectRecordHitMotionNV", + Class: "Reserved", + Opcode: 5249, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'InstanceId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PrimitiveId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'GeometryIndex'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Kind'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Current Time'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HitObject Attributes'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordHitWithIndexMotionNV = &Opcode { + Opname: "OpHitObjectRecordHitWithIndexMotionNV", + Class: "Reserved", + Opcode: 5250, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'InstanceId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PrimitiveId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'GeometryIndex'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Kind'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Current Time'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HitObject Attributes'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordMissMotionNV = &Opcode { + Opname: "OpHitObjectRecordMissMotionNV", + Class: "Reserved", + Opcode: 5251, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Current Time'", + Quantifier: "", + }, + }, + } + OpHitObjectGetWorldToObjectNV = &Opcode { + Opname: "OpHitObjectGetWorldToObjectNV", + Class: "Reserved", + Opcode: 5252, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetObjectToWorldNV = &Opcode { + Opname: "OpHitObjectGetObjectToWorldNV", + Class: "Reserved", + Opcode: 5253, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetObjectRayDirectionNV = &Opcode { + Opname: "OpHitObjectGetObjectRayDirectionNV", + Class: "Reserved", + Opcode: 5254, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetObjectRayOriginNV = &Opcode { + Opname: "OpHitObjectGetObjectRayOriginNV", + Class: "Reserved", + Opcode: 5255, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectTraceRayMotionNV = &Opcode { + Opname: "OpHitObjectTraceRayMotionNV", + Class: "Reserved", + Opcode: 5256, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayFlags'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Cullmask'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Miss Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Time'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "", + }, + }, + } + OpHitObjectGetShaderRecordBufferHandleNV = &Opcode { + Opname: "OpHitObjectGetShaderRecordBufferHandleNV", + Class: "Reserved", + Opcode: 5257, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetShaderBindingTableRecordIndexNV = &Opcode { + Opname: "OpHitObjectGetShaderBindingTableRecordIndexNV", + Class: "Reserved", + Opcode: 5258, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordEmptyNV = &Opcode { + Opname: "OpHitObjectRecordEmptyNV", + Class: "Reserved", + Opcode: 5259, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectTraceRayNV = &Opcode { + Opname: "OpHitObjectTraceRayNV", + Class: "Reserved", + Opcode: 5260, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayFlags'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Cullmask'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Miss Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordHitNV = &Opcode { + Opname: "OpHitObjectRecordHitNV", + Class: "Reserved", + Opcode: 5261, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'InstanceId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PrimitiveId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'GeometryIndex'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Kind'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HitObject Attributes'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordHitWithIndexNV = &Opcode { + Opname: "OpHitObjectRecordHitWithIndexNV", + Class: "Reserved", + Opcode: 5262, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Acceleration Structure'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'InstanceId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PrimitiveId'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'GeometryIndex'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Kind'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Record Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HitObject Attributes'", + Quantifier: "", + }, + }, + } + OpHitObjectRecordMissNV = &Opcode { + Opname: "OpHitObjectRecordMissNV", + Class: "Reserved", + Opcode: 5263, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'SBT Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TMax'", + Quantifier: "", + }, + }, + } + OpHitObjectExecuteShaderNV = &Opcode { + Opname: "OpHitObjectExecuteShaderNV", + Class: "Reserved", + Opcode: 5264, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "", + }, + }, + } + OpHitObjectGetCurrentTimeNV = &Opcode { + Opname: "OpHitObjectGetCurrentTimeNV", + Class: "Reserved", + Opcode: 5265, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetAttributesNV = &Opcode { + Opname: "OpHitObjectGetAttributesNV", + Class: "Reserved", + Opcode: 5266, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object Attribute'", + Quantifier: "", + }, + }, + } + OpHitObjectGetHitKindNV = &Opcode { + Opname: "OpHitObjectGetHitKindNV", + Class: "Reserved", + Opcode: 5267, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetPrimitiveIndexNV = &Opcode { + Opname: "OpHitObjectGetPrimitiveIndexNV", + Class: "Reserved", + Opcode: 5268, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetGeometryIndexNV = &Opcode { + Opname: "OpHitObjectGetGeometryIndexNV", + Class: "Reserved", + Opcode: 5269, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetInstanceIdNV = &Opcode { + Opname: "OpHitObjectGetInstanceIdNV", + Class: "Reserved", + Opcode: 5270, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetInstanceCustomIndexNV = &Opcode { + Opname: "OpHitObjectGetInstanceCustomIndexNV", + Class: "Reserved", + Opcode: 5271, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetWorldRayDirectionNV = &Opcode { + Opname: "OpHitObjectGetWorldRayDirectionNV", + Class: "Reserved", + Opcode: 5272, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetWorldRayOriginNV = &Opcode { + Opname: "OpHitObjectGetWorldRayOriginNV", + Class: "Reserved", + Opcode: 5273, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetRayTMaxNV = &Opcode { + Opname: "OpHitObjectGetRayTMaxNV", + Class: "Reserved", + Opcode: 5274, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectGetRayTMinNV = &Opcode { + Opname: "OpHitObjectGetRayTMinNV", + Class: "Reserved", + Opcode: 5275, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectIsEmptyNV = &Opcode { + Opname: "OpHitObjectIsEmptyNV", + Class: "Reserved", + Opcode: 5276, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectIsHitNV = &Opcode { + Opname: "OpHitObjectIsHitNV", + Class: "Reserved", + Opcode: 5277, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpHitObjectIsMissNV = &Opcode { + Opname: "OpHitObjectIsMissNV", + Class: "Reserved", + Opcode: 5278, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + }, + } + OpReorderThreadWithHitObjectNV = &Opcode { + Opname: "OpReorderThreadWithHitObjectNV", + Class: "Reserved", + Opcode: 5279, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hit Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Hint'", + Quantifier: "?", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Bits'", + Quantifier: "?", + }, + }, + } + OpReorderThreadWithHintNV = &Opcode { + Opname: "OpReorderThreadWithHintNV", + Class: "Reserved", + Opcode: 5280, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Hint'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Bits'", + Quantifier: "", + }, + }, + } + OpTypeHitObjectNV = &Opcode { + Opname: "OpTypeHitObjectNV", + Class: "Type-Declaration", + Opcode: 5281, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", Quantifier: "", }, }, @@ -10538,6 +13395,72 @@ var ( }, }, } + OpCooperativeMatrixConvertNV = &Opcode { + Opname: "OpCooperativeMatrixConvertNV", + Class: "Conversion", + Opcode: 5293, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Matrix'", + Quantifier: "", + }, + }, + } + OpEmitMeshTasksEXT = &Opcode { + Opname: "OpEmitMeshTasksEXT", + Class: "Reserved", + Opcode: 5294, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Group Count X'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Group Count Y'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Group Count Z'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", + Quantifier: "?", + }, + }, + } + OpSetMeshOutputsEXT = &Opcode { + Opname: "OpSetMeshOutputsEXT", + Class: "Reserved", + Opcode: 5295, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Vertex Count'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Primitive Count'", + Quantifier: "", + }, + }, + } OpGroupNonUniformPartitionNV = &Opcode { Opname: "OpGroupNonUniformPartitionNV", Class: "Non-Uniform", @@ -10577,10 +13500,10 @@ var ( }, }, } - OpReportIntersectionNV = &Opcode { - Opname: "OpReportIntersectionNV", + OpFetchMicroTriangleVertexPositionNV = &Opcode { + Opname: "OpFetchMicroTriangleVertexPositionNV", Class: "Reserved", - Opcode: 5334, + Opcode: 5300, Operands: []Operand { Operand { Kind: OperandKindIdResultType, @@ -10594,12 +13517,69 @@ var ( }, Operand { Kind: OperandKindIdRef, - Name: "'Hit'", + Name: "'Accel'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'HitKind'", + Name: "'Instance Id'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Geometry Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Primitive Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Barycentric'", + Quantifier: "", + }, + }, + } + OpFetchMicroTriangleVertexBarycentricNV = &Opcode { + Opname: "OpFetchMicroTriangleVertexBarycentricNV", + Class: "Reserved", + Opcode: 5301, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Accel'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Instance Id'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Geometry Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Primitive Index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Barycentric'", Quantifier: "", }, }, @@ -10638,13 +13618,6 @@ var ( Operands: []Operand { }, } - OpIgnoreIntersectionKHR = &Opcode { - Opname: "OpIgnoreIntersectionKHR", - Class: "Reserved", - Opcode: 5335, - Operands: []Operand { - }, - } OpTerminateRayNV = &Opcode { Opname: "OpTerminateRayNV", Class: "Reserved", @@ -10652,13 +13625,6 @@ var ( Operands: []Operand { }, } - OpTerminateRayKHR = &Opcode { - Opname: "OpTerminateRayKHR", - Class: "Reserved", - Opcode: 5336, - Operands: []Operand { - }, - } OpTraceNV = &Opcode { Opname: "OpTraceNV", Class: "Reserved", @@ -10721,10 +13687,10 @@ var ( }, }, } - OpTraceRayKHR = &Opcode { - Opname: "OpTraceRayKHR", + OpTraceMotionNV = &Opcode { + Opname: "OpTraceMotionNV", Class: "Reserved", - Opcode: 5337, + Opcode: 5338, Operands: []Operand { Operand { Kind: OperandKindIdRef, @@ -10776,6 +13742,11 @@ var ( Name: "'Ray Tmax'", Quantifier: "", }, + Operand { + Kind: OperandKindIdRef, + Name: "'Time'", + Quantifier: "", + }, Operand { Kind: OperandKindIdRef, Name: "'PayloadId'", @@ -10783,52 +13754,11 @@ var ( }, }, } - OpTypeAccelerationStructureNV = &Opcode { - Opname: "OpTypeAccelerationStructureNV", + OpTraceRayMotionNV = &Opcode { + Opname: "OpTraceRayMotionNV", Class: "Reserved", - Opcode: 5341, + Opcode: 5339, Operands: []Operand { - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - }, - } - OpTypeAccelerationStructureKHR = &Opcode { - Opname: "OpTypeAccelerationStructureKHR", - Class: "Reserved", - Opcode: 5341, - Operands: []Operand { - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - }, - } - OpTypeRayQueryProvisionalKHR = &Opcode { - Opname: "OpTypeRayQueryProvisionalKHR", - Class: "Reserved", - Opcode: 4472, - Operands: []Operand { - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - }, - } - OpRayQueryInitializeKHR = &Opcode { - Opname: "OpRayQueryInitializeKHR", - Class: "Reserved", - Opcode: 4473, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, Operand { Kind: OperandKindIdRef, Name: "'Accel'", @@ -10836,103 +13766,65 @@ var ( }, Operand { Kind: OperandKindIdRef, - Name: "'RayFlags'", + Name: "'Ray Flags'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'CullMask'", + Name: "'Cull Mask'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'RayOrigin'", + Name: "'SBT Offset'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'RayTMin'", + Name: "'SBT Stride'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'RayDirection'", + Name: "'Miss Index'", Quantifier: "", }, Operand { Kind: OperandKindIdRef, - Name: "'RayTMax'", + Name: "'Ray Origin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Tmin'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Direction'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Ray Tmax'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Time'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Payload'", Quantifier: "", }, }, } - OpRayQueryTerminateKHR = &Opcode { - Opname: "OpRayQueryTerminateKHR", + OpRayQueryGetIntersectionTriangleVertexPositionsKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionTriangleVertexPositionsKHR", Class: "Reserved", - Opcode: 4474, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGenerateIntersectionKHR = &Opcode { - Opname: "OpRayQueryGenerateIntersectionKHR", - Class: "Reserved", - Opcode: 4475, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'HitT'", - Quantifier: "", - }, - }, - } - OpRayQueryConfirmIntersectionKHR = &Opcode { - Opname: "OpRayQueryConfirmIntersectionKHR", - Class: "Reserved", - Opcode: 4476, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryProceedKHR = &Opcode { - Opname: "OpRayQueryProceedKHR", - Class: "Reserved", - Opcode: 4477, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionTypeKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionTypeKHR", - Class: "Reserved", - Opcode: 4479, + Opcode: 5340, Operands: []Operand { Operand { Kind: OperandKindIdResultType, @@ -10956,438 +13848,16 @@ var ( }, }, } - OpRayQueryGetRayTMinKHR = &Opcode { - Opname: "OpRayQueryGetRayTMinKHR", - Class: "Reserved", - Opcode: 6016, + OpTypeAccelerationStructureKHR = &Opcode { + Opname: "OpTypeAccelerationStructureKHR", + Class: "Type-Declaration", + Opcode: 5341, Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, Operand { Kind: OperandKindIdResult, Name: "", Quantifier: "", }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetRayFlagsKHR = &Opcode { - Opname: "OpRayQueryGetRayFlagsKHR", - Class: "Reserved", - Opcode: 6017, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionTKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionTKHR", - Class: "Reserved", - Opcode: 6018, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionInstanceCustomIndexKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionInstanceCustomIndexKHR", - Class: "Reserved", - Opcode: 6019, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionInstanceIdKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionInstanceIdKHR", - Class: "Reserved", - Opcode: 6020, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR", - Class: "Reserved", - Opcode: 6021, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionGeometryIndexKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionGeometryIndexKHR", - Class: "Reserved", - Opcode: 6022, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionPrimitiveIndexKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionPrimitiveIndexKHR", - Class: "Reserved", - Opcode: 6023, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionBarycentricsKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionBarycentricsKHR", - Class: "Reserved", - Opcode: 6024, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionFrontFaceKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionFrontFaceKHR", - Class: "Reserved", - Opcode: 6025, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR", - Class: "Reserved", - Opcode: 6026, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionObjectRayDirectionKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionObjectRayDirectionKHR", - Class: "Reserved", - Opcode: 6027, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionObjectRayOriginKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionObjectRayOriginKHR", - Class: "Reserved", - Opcode: 6028, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetWorldRayDirectionKHR = &Opcode { - Opname: "OpRayQueryGetWorldRayDirectionKHR", - Class: "Reserved", - Opcode: 6029, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetWorldRayOriginKHR = &Opcode { - Opname: "OpRayQueryGetWorldRayOriginKHR", - Class: "Reserved", - Opcode: 6030, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionObjectToWorldKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionObjectToWorldKHR", - Class: "Reserved", - Opcode: 6031, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, - }, - } - OpRayQueryGetIntersectionWorldToObjectKHR = &Opcode { - Opname: "OpRayQueryGetIntersectionWorldToObjectKHR", - Class: "Reserved", - Opcode: 6032, - Operands: []Operand { - Operand { - Kind: OperandKindIdResultType, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdResult, - Name: "", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'RayQuery'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Intersection'", - Quantifier: "", - }, }, } OpExecuteCallableNV = &Opcode { @@ -11407,26 +13877,9 @@ var ( }, }, } - OpExecuteCallableKHR = &Opcode { - Opname: "OpExecuteCallableKHR", - Class: "Reserved", - Opcode: 5344, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'SBT Index'", - Quantifier: "", - }, - Operand { - Kind: OperandKindIdRef, - Name: "'Callable DataId'", - Quantifier: "", - }, - }, - } OpTypeCooperativeMatrixNV = &Opcode { Opname: "OpTypeCooperativeMatrixNV", - Class: "Reserved", + Class: "Type-Declaration", Opcode: 5358, Operands: []Operand { Operand { @@ -11593,9 +14046,392 @@ var ( Operands: []Operand { }, } - OpDemoteToHelperInvocationEXT = &Opcode { - Opname: "OpDemoteToHelperInvocationEXT", + OpCooperativeMatrixReduceNV = &Opcode { + Opname: "OpCooperativeMatrixReduceNV", + Class: "Arithmetic", + Opcode: 5366, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Matrix'", + Quantifier: "", + }, + Operand { + Kind: OperandKindCooperativeMatrixReduce, + Name: "'Reduce'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'CombineFunc'", + Quantifier: "", + }, + }, + } + OpCooperativeMatrixLoadTensorNV = &Opcode { + Opname: "OpCooperativeMatrixLoadTensorNV", + Class: "Memory", + Opcode: 5367, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindMemoryAccess, + Name: "'Memory Operand'", + Quantifier: "", + }, + Operand { + Kind: OperandKindTensorAddressingOperands, + Name: "'Tensor Addressing Operands'", + Quantifier: "", + }, + }, + } + OpCooperativeMatrixStoreTensorNV = &Opcode { + Opname: "OpCooperativeMatrixStoreTensorNV", + Class: "Memory", + Opcode: 5368, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Object'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindMemoryAccess, + Name: "'Memory Operand'", + Quantifier: "", + }, + Operand { + Kind: OperandKindTensorAddressingOperands, + Name: "'Tensor Addressing Operands'", + Quantifier: "", + }, + }, + } + OpCooperativeMatrixPerElementOpNV = &Opcode { + Opname: "OpCooperativeMatrixPerElementOpNV", + Class: "Function", + Opcode: 5369, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Matrix'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Func'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operands'", + Quantifier: "*", + }, + }, + } + OpTypeTensorLayoutNV = &Opcode { + Opname: "OpTypeTensorLayoutNV", + Class: "Type-Declaration", + Opcode: 5370, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Dim'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClampMode'", + Quantifier: "", + }, + }, + } + OpTypeTensorViewNV = &Opcode { + Opname: "OpTypeTensorViewNV", + Class: "Type-Declaration", + Opcode: 5371, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Dim'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'HasDimensions'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'p'", + Quantifier: "*", + }, + }, + } + OpCreateTensorLayoutNV = &Opcode { + Opname: "OpCreateTensorLayoutNV", Class: "Reserved", + Opcode: 5372, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + }, + } + OpTensorLayoutSetDimensionNV = &Opcode { + Opname: "OpTensorLayoutSetDimensionNV", + Class: "Reserved", + Opcode: 5373, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Dim'", + Quantifier: "*", + }, + }, + } + OpTensorLayoutSetStrideNV = &Opcode { + Opname: "OpTensorLayoutSetStrideNV", + Class: "Reserved", + Opcode: 5374, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Stride'", + Quantifier: "*", + }, + }, + } + OpTensorLayoutSliceNV = &Opcode { + Opname: "OpTensorLayoutSliceNV", + Class: "Reserved", + Opcode: 5375, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operands'", + Quantifier: "*", + }, + }, + } + OpTensorLayoutSetClampValueNV = &Opcode { + Opname: "OpTensorLayoutSetClampValueNV", + Class: "Reserved", + Opcode: 5376, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpCreateTensorViewNV = &Opcode { + Opname: "OpCreateTensorViewNV", + Class: "Reserved", + Opcode: 5377, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + }, + } + OpTensorViewSetDimensionNV = &Opcode { + Opname: "OpTensorViewSetDimensionNV", + Class: "Reserved", + Opcode: 5378, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorView'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Dim'", + Quantifier: "*", + }, + }, + } + OpTensorViewSetStrideNV = &Opcode { + Opname: "OpTensorViewSetStrideNV", + Class: "Reserved", + Opcode: 5379, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorView'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Stride'", + Quantifier: "*", + }, + }, + } + OpDemoteToHelperInvocation = &Opcode { + Opname: "OpDemoteToHelperInvocation", + Class: "Control-Flow", Opcode: 5380, Operands: []Operand { }, @@ -11617,6 +14453,283 @@ var ( }, }, } + OpTensorViewSetClipNV = &Opcode { + Opname: "OpTensorViewSetClipNV", + Class: "Reserved", + Opcode: 5382, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorView'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClipRowOffset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClipRowSpan'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClipColOffset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ClipColSpan'", + Quantifier: "", + }, + }, + } + OpTensorLayoutSetBlockSizeNV = &Opcode { + Opname: "OpTensorLayoutSetBlockSizeNV", + Class: "Reserved", + Opcode: 5384, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'TensorLayout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'BlockSize'", + Quantifier: "*", + }, + }, + } + OpCooperativeMatrixTransposeNV = &Opcode { + Opname: "OpCooperativeMatrixTransposeNV", + Class: "Conversion", + Opcode: 5390, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Matrix'", + Quantifier: "", + }, + }, + } + OpConvertUToImageNV = &Opcode { + Opname: "OpConvertUToImageNV", + Class: "Reserved", + Opcode: 5391, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpConvertUToSamplerNV = &Opcode { + Opname: "OpConvertUToSamplerNV", + Class: "Reserved", + Opcode: 5392, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpConvertImageToUNV = &Opcode { + Opname: "OpConvertImageToUNV", + Class: "Reserved", + Opcode: 5393, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpConvertSamplerToUNV = &Opcode { + Opname: "OpConvertSamplerToUNV", + Class: "Reserved", + Opcode: 5394, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpConvertUToSampledImageNV = &Opcode { + Opname: "OpConvertUToSampledImageNV", + Class: "Reserved", + Opcode: 5395, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpConvertSampledImageToUNV = &Opcode { + Opname: "OpConvertSampledImageToUNV", + Class: "Reserved", + Opcode: 5396, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand'", + Quantifier: "", + }, + }, + } + OpSamplerImageAddressingModeNV = &Opcode { + Opname: "OpSamplerImageAddressingModeNV", + Class: "Reserved", + Opcode: 5397, + Operands: []Operand { + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Bit Width'", + Quantifier: "", + }, + }, + } + OpRawAccessChainNV = &Opcode { + Opname: "OpRawAccessChainNV", + Class: "Memory", + Opcode: 5398, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Base'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Byte stride'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Element index'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Byte offset'", + Quantifier: "", + }, + Operand { + Kind: OperandKindRawAccessChainOperands, + Name: "", + Quantifier: "?", + }, + }, + } OpSubgroupShuffleINTEL = &Opcode { Opname: "OpSubgroupShuffleINTEL", Class: "Group", @@ -12260,6 +15373,249 @@ var ( }, }, } + OpConstantFunctionPointerINTEL = &Opcode { + Opname: "OpConstantFunctionPointerINTEL", + Class: "@exclude", + Opcode: 5600, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Function'", + Quantifier: "", + }, + }, + } + OpFunctionPointerCallINTEL = &Opcode { + Opname: "OpFunctionPointerCallINTEL", + Class: "@exclude", + Opcode: 5601, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Operand 1'", + Quantifier: "*", + }, + }, + } + OpAsmTargetINTEL = &Opcode { + Opname: "OpAsmTargetINTEL", + Class: "@exclude", + Opcode: 5609, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralString, + Name: "'Asm target'", + Quantifier: "", + }, + }, + } + OpAsmINTEL = &Opcode { + Opname: "OpAsmINTEL", + Class: "@exclude", + Opcode: 5610, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Asm type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralString, + Name: "'Asm instructions'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralString, + Name: "'Constraints'", + Quantifier: "", + }, + }, + } + OpAsmCallINTEL = &Opcode { + Opname: "OpAsmCallINTEL", + Class: "@exclude", + Opcode: 5611, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Asm'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Argument 0'", + Quantifier: "*", + }, + }, + } + OpAtomicFMinEXT = &Opcode { + Opname: "OpAtomicFMinEXT", + Class: "Atomic", + Opcode: 5614, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Memory'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdMemorySemantics, + Name: "'Semantics'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpAtomicFMaxEXT = &Opcode { + Opname: "OpAtomicFMaxEXT", + Class: "Atomic", + Opcode: 5615, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Memory'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdMemorySemantics, + Name: "'Semantics'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpAssumeTrueKHR = &Opcode { + Opname: "OpAssumeTrueKHR", + Class: "Miscellaneous", + Opcode: 5630, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Condition'", + Quantifier: "", + }, + }, + } + OpExpectKHR = &Opcode { + Opname: "OpExpectKHR", + Class: "Miscellaneous", + Opcode: 5631, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ExpectedValue'", + Quantifier: "", + }, + }, + } OpDecorateString = &Opcode { Opname: "OpDecorateString", Class: "Annotation", @@ -12277,23 +15633,6 @@ var ( }, }, } - OpDecorateStringGOOGLE = &Opcode { - Opname: "OpDecorateStringGOOGLE", - Class: "Annotation", - Opcode: 5632, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'Target'", - Quantifier: "", - }, - Operand { - Kind: OperandKindDecoration, - Name: "", - Quantifier: "", - }, - }, - } OpMemberDecorateString = &Opcode { Opname: "OpMemberDecorateString", Class: "Annotation", @@ -12316,28 +15655,6 @@ var ( }, }, } - OpMemberDecorateStringGOOGLE = &Opcode { - Opname: "OpMemberDecorateStringGOOGLE", - Class: "Annotation", - Opcode: 5633, - Operands: []Operand { - Operand { - Kind: OperandKindIdRef, - Name: "'Struct Type'", - Quantifier: "", - }, - Operand { - Kind: OperandKindLiteralInteger, - Name: "'Member'", - Quantifier: "", - }, - Operand { - Kind: OperandKindDecoration, - Name: "", - Quantifier: "", - }, - }, - } OpVmeImageINTEL = &Opcode { Opname: "OpVmeImageINTEL", Class: "@exclude", @@ -15439,6 +18756,3782 @@ var ( }, }, } + OpVariableLengthArrayINTEL = &Opcode { + Opname: "OpVariableLengthArrayINTEL", + Class: "@exclude", + Opcode: 5818, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Lenght'", + Quantifier: "", + }, + }, + } + OpSaveMemoryINTEL = &Opcode { + Opname: "OpSaveMemoryINTEL", + Class: "@exclude", + Opcode: 5819, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + }, + } + OpRestoreMemoryINTEL = &Opcode { + Opname: "OpRestoreMemoryINTEL", + Class: "@exclude", + Opcode: 5820, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Ptr'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSinCosPiINTEL = &Opcode { + Opname: "OpArbitraryFloatSinCosPiINTEL", + Class: "@exclude", + Opcode: 5840, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'FromSign'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCastINTEL = &Opcode { + Opname: "OpArbitraryFloatCastINTEL", + Class: "@exclude", + Opcode: 5841, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCastFromIntINTEL = &Opcode { + Opname: "OpArbitraryFloatCastFromIntINTEL", + Class: "@exclude", + Opcode: 5842, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'FromSign'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCastToIntINTEL = &Opcode { + Opname: "OpArbitraryFloatCastToIntINTEL", + Class: "@exclude", + Opcode: 5843, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatAddINTEL = &Opcode { + Opname: "OpArbitraryFloatAddINTEL", + Class: "@exclude", + Opcode: 5846, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSubINTEL = &Opcode { + Opname: "OpArbitraryFloatSubINTEL", + Class: "@exclude", + Opcode: 5847, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatMulINTEL = &Opcode { + Opname: "OpArbitraryFloatMulINTEL", + Class: "@exclude", + Opcode: 5848, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatDivINTEL = &Opcode { + Opname: "OpArbitraryFloatDivINTEL", + Class: "@exclude", + Opcode: 5849, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatGTINTEL = &Opcode { + Opname: "OpArbitraryFloatGTINTEL", + Class: "@exclude", + Opcode: 5850, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatGEINTEL = &Opcode { + Opname: "OpArbitraryFloatGEINTEL", + Class: "@exclude", + Opcode: 5851, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLTINTEL = &Opcode { + Opname: "OpArbitraryFloatLTINTEL", + Class: "@exclude", + Opcode: 5852, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLEINTEL = &Opcode { + Opname: "OpArbitraryFloatLEINTEL", + Class: "@exclude", + Opcode: 5853, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatEQINTEL = &Opcode { + Opname: "OpArbitraryFloatEQINTEL", + Class: "@exclude", + Opcode: 5854, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatRecipINTEL = &Opcode { + Opname: "OpArbitraryFloatRecipINTEL", + Class: "@exclude", + Opcode: 5855, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatRSqrtINTEL = &Opcode { + Opname: "OpArbitraryFloatRSqrtINTEL", + Class: "@exclude", + Opcode: 5856, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCbrtINTEL = &Opcode { + Opname: "OpArbitraryFloatCbrtINTEL", + Class: "@exclude", + Opcode: 5857, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatHypotINTEL = &Opcode { + Opname: "OpArbitraryFloatHypotINTEL", + Class: "@exclude", + Opcode: 5858, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSqrtINTEL = &Opcode { + Opname: "OpArbitraryFloatSqrtINTEL", + Class: "@exclude", + Opcode: 5859, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLogINTEL = &Opcode { + Opname: "OpArbitraryFloatLogINTEL", + Class: "@exclude", + Opcode: 5860, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLog2INTEL = &Opcode { + Opname: "OpArbitraryFloatLog2INTEL", + Class: "@exclude", + Opcode: 5861, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLog10INTEL = &Opcode { + Opname: "OpArbitraryFloatLog10INTEL", + Class: "@exclude", + Opcode: 5862, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatLog1pINTEL = &Opcode { + Opname: "OpArbitraryFloatLog1pINTEL", + Class: "@exclude", + Opcode: 5863, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatExpINTEL = &Opcode { + Opname: "OpArbitraryFloatExpINTEL", + Class: "@exclude", + Opcode: 5864, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatExp2INTEL = &Opcode { + Opname: "OpArbitraryFloatExp2INTEL", + Class: "@exclude", + Opcode: 5865, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatExp10INTEL = &Opcode { + Opname: "OpArbitraryFloatExp10INTEL", + Class: "@exclude", + Opcode: 5866, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatExpm1INTEL = &Opcode { + Opname: "OpArbitraryFloatExpm1INTEL", + Class: "@exclude", + Opcode: 5867, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSinINTEL = &Opcode { + Opname: "OpArbitraryFloatSinINTEL", + Class: "@exclude", + Opcode: 5868, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCosINTEL = &Opcode { + Opname: "OpArbitraryFloatCosINTEL", + Class: "@exclude", + Opcode: 5869, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSinCosINTEL = &Opcode { + Opname: "OpArbitraryFloatSinCosINTEL", + Class: "@exclude", + Opcode: 5870, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatSinPiINTEL = &Opcode { + Opname: "OpArbitraryFloatSinPiINTEL", + Class: "@exclude", + Opcode: 5871, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatCosPiINTEL = &Opcode { + Opname: "OpArbitraryFloatCosPiINTEL", + Class: "@exclude", + Opcode: 5872, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatASinINTEL = &Opcode { + Opname: "OpArbitraryFloatASinINTEL", + Class: "@exclude", + Opcode: 5873, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatASinPiINTEL = &Opcode { + Opname: "OpArbitraryFloatASinPiINTEL", + Class: "@exclude", + Opcode: 5874, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatACosINTEL = &Opcode { + Opname: "OpArbitraryFloatACosINTEL", + Class: "@exclude", + Opcode: 5875, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatACosPiINTEL = &Opcode { + Opname: "OpArbitraryFloatACosPiINTEL", + Class: "@exclude", + Opcode: 5876, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatATanINTEL = &Opcode { + Opname: "OpArbitraryFloatATanINTEL", + Class: "@exclude", + Opcode: 5877, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatATanPiINTEL = &Opcode { + Opname: "OpArbitraryFloatATanPiINTEL", + Class: "@exclude", + Opcode: 5878, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatATan2INTEL = &Opcode { + Opname: "OpArbitraryFloatATan2INTEL", + Class: "@exclude", + Opcode: 5879, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatPowINTEL = &Opcode { + Opname: "OpArbitraryFloatPowINTEL", + Class: "@exclude", + Opcode: 5880, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatPowRINTEL = &Opcode { + Opname: "OpArbitraryFloatPowRINTEL", + Class: "@exclude", + Opcode: 5881, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M2'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpArbitraryFloatPowNINTEL = &Opcode { + Opname: "OpArbitraryFloatPowNINTEL", + Class: "@exclude", + Opcode: 5882, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'A'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'M1'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'B'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Mout'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'EnableSubnormals'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingMode'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'RoundingAccuracy'", + Quantifier: "", + }, + }, + } + OpLoopControlINTEL = &Opcode { + Opname: "OpLoopControlINTEL", + Class: "Reserved", + Opcode: 5887, + Operands: []Operand { + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Loop Control Parameters'", + Quantifier: "*", + }, + }, + } + OpAliasDomainDeclINTEL = &Opcode { + Opname: "OpAliasDomainDeclINTEL", + Class: "@exclude", + Opcode: 5911, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Name'", + Quantifier: "?", + }, + }, + } + OpAliasScopeDeclINTEL = &Opcode { + Opname: "OpAliasScopeDeclINTEL", + Class: "@exclude", + Opcode: 5912, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Alias Domain'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Name'", + Quantifier: "?", + }, + }, + } + OpAliasScopeListDeclINTEL = &Opcode { + Opname: "OpAliasScopeListDeclINTEL", + Class: "@exclude", + Opcode: 5913, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'AliasScope1, AliasScope2, ...'", + Quantifier: "*", + }, + }, + } + OpFixedSqrtINTEL = &Opcode { + Opname: "OpFixedSqrtINTEL", + Class: "@exclude", + Opcode: 5923, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedRecipINTEL = &Opcode { + Opname: "OpFixedRecipINTEL", + Class: "@exclude", + Opcode: 5924, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedRsqrtINTEL = &Opcode { + Opname: "OpFixedRsqrtINTEL", + Class: "@exclude", + Opcode: 5925, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedSinINTEL = &Opcode { + Opname: "OpFixedSinINTEL", + Class: "@exclude", + Opcode: 5926, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedCosINTEL = &Opcode { + Opname: "OpFixedCosINTEL", + Class: "@exclude", + Opcode: 5927, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedSinCosINTEL = &Opcode { + Opname: "OpFixedSinCosINTEL", + Class: "@exclude", + Opcode: 5928, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedSinPiINTEL = &Opcode { + Opname: "OpFixedSinPiINTEL", + Class: "@exclude", + Opcode: 5929, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedCosPiINTEL = &Opcode { + Opname: "OpFixedCosPiINTEL", + Class: "@exclude", + Opcode: 5930, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedSinCosPiINTEL = &Opcode { + Opname: "OpFixedSinCosPiINTEL", + Class: "@exclude", + Opcode: 5931, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedLogINTEL = &Opcode { + Opname: "OpFixedLogINTEL", + Class: "@exclude", + Opcode: 5932, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpFixedExpINTEL = &Opcode { + Opname: "OpFixedExpINTEL", + Class: "@exclude", + Opcode: 5933, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input Type'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'S'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'I'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'rI'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Q'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'O'", + Quantifier: "", + }, + }, + } + OpPtrCastToCrossWorkgroupINTEL = &Opcode { + Opname: "OpPtrCastToCrossWorkgroupINTEL", + Class: "@exclude", + Opcode: 5934, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + }, + } + OpCrossWorkgroupCastToPtrINTEL = &Opcode { + Opname: "OpCrossWorkgroupCastToPtrINTEL", + Class: "@exclude", + Opcode: 5938, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + }, + } + OpReadPipeBlockingINTEL = &Opcode { + Opname: "OpReadPipeBlockingINTEL", + Class: "Pipe", + Opcode: 5946, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Packet Size'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Packet Alignment'", + Quantifier: "", + }, + }, + } + OpWritePipeBlockingINTEL = &Opcode { + Opname: "OpWritePipeBlockingINTEL", + Class: "Pipe", + Opcode: 5947, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Packet Size'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Packet Alignment'", + Quantifier: "", + }, + }, + } + OpFPGARegINTEL = &Opcode { + Opname: "OpFPGARegINTEL", + Class: "Reserved", + Opcode: 5949, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Result'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Input'", + Quantifier: "", + }, + }, + } + OpRayQueryGetRayTMinKHR = &Opcode { + Opname: "OpRayQueryGetRayTMinKHR", + Class: "Reserved", + Opcode: 6016, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetRayFlagsKHR = &Opcode { + Opname: "OpRayQueryGetRayFlagsKHR", + Class: "Reserved", + Opcode: 6017, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionTKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionTKHR", + Class: "Reserved", + Opcode: 6018, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionInstanceCustomIndexKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionInstanceCustomIndexKHR", + Class: "Reserved", + Opcode: 6019, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionInstanceIdKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionInstanceIdKHR", + Class: "Reserved", + Opcode: 6020, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR", + Class: "Reserved", + Opcode: 6021, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionGeometryIndexKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionGeometryIndexKHR", + Class: "Reserved", + Opcode: 6022, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionPrimitiveIndexKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionPrimitiveIndexKHR", + Class: "Reserved", + Opcode: 6023, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionBarycentricsKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionBarycentricsKHR", + Class: "Reserved", + Opcode: 6024, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionFrontFaceKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionFrontFaceKHR", + Class: "Reserved", + Opcode: 6025, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR", + Class: "Reserved", + Opcode: 6026, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionObjectRayDirectionKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionObjectRayDirectionKHR", + Class: "Reserved", + Opcode: 6027, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionObjectRayOriginKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionObjectRayOriginKHR", + Class: "Reserved", + Opcode: 6028, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetWorldRayDirectionKHR = &Opcode { + Opname: "OpRayQueryGetWorldRayDirectionKHR", + Class: "Reserved", + Opcode: 6029, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetWorldRayOriginKHR = &Opcode { + Opname: "OpRayQueryGetWorldRayOriginKHR", + Class: "Reserved", + Opcode: 6030, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionObjectToWorldKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionObjectToWorldKHR", + Class: "Reserved", + Opcode: 6031, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpRayQueryGetIntersectionWorldToObjectKHR = &Opcode { + Opname: "OpRayQueryGetIntersectionWorldToObjectKHR", + Class: "Reserved", + Opcode: 6032, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'RayQuery'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Intersection'", + Quantifier: "", + }, + }, + } + OpAtomicFAddEXT = &Opcode { + Opname: "OpAtomicFAddEXT", + Class: "Atomic", + Opcode: 6035, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Pointer'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Memory'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdMemorySemantics, + Name: "'Semantics'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Value'", + Quantifier: "", + }, + }, + } + OpTypeBufferSurfaceINTEL = &Opcode { + Opname: "OpTypeBufferSurfaceINTEL", + Class: "Type-Declaration", + Opcode: 6086, + Operands: []Operand { + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindAccessQualifier, + Name: "'AccessQualifier'", + Quantifier: "", + }, + }, + } + OpTypeStructContinuedINTEL = &Opcode { + Opname: "OpTypeStructContinuedINTEL", + Class: "Type-Declaration", + Opcode: 6090, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Member 0 type', + 'member 1 type', + ...", + Quantifier: "*", + }, + }, + } + OpConstantCompositeContinuedINTEL = &Opcode { + Opname: "OpConstantCompositeContinuedINTEL", + Class: "Constant-Creation", + Opcode: 6091, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Constituents'", + Quantifier: "*", + }, + }, + } + OpSpecConstantCompositeContinuedINTEL = &Opcode { + Opname: "OpSpecConstantCompositeContinuedINTEL", + Class: "Constant-Creation", + Opcode: 6092, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Constituents'", + Quantifier: "*", + }, + }, + } + OpCompositeConstructContinuedINTEL = &Opcode { + Opname: "OpCompositeConstructContinuedINTEL", + Class: "Composite", + Opcode: 6096, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Constituents'", + Quantifier: "*", + }, + }, + } + OpConvertFToBF16INTEL = &Opcode { + Opname: "OpConvertFToBF16INTEL", + Class: "Conversion", + Opcode: 6116, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Float Value'", + Quantifier: "", + }, + }, + } + OpConvertBF16ToFINTEL = &Opcode { + Opname: "OpConvertBF16ToFINTEL", + Class: "Conversion", + Opcode: 6117, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'BFloat16 Value'", + Quantifier: "", + }, + }, + } + OpControlBarrierArriveINTEL = &Opcode { + Opname: "OpControlBarrierArriveINTEL", + Class: "Barrier", + Opcode: 6142, + Operands: []Operand { + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Memory'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdMemorySemantics, + Name: "'Semantics'", + Quantifier: "", + }, + }, + } + OpControlBarrierWaitINTEL = &Opcode { + Opname: "OpControlBarrierWaitINTEL", + Class: "Barrier", + Opcode: 6143, + Operands: []Operand { + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Memory'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdMemorySemantics, + Name: "'Semantics'", + Quantifier: "", + }, + }, + } + OpArithmeticFenceEXT = &Opcode { + Opname: "OpArithmeticFenceEXT", + Class: "Miscellaneous", + Opcode: 6145, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Target '", + Quantifier: "", + }, + }, + } + OpSubgroupBlockPrefetchINTEL = &Opcode { + Opname: "OpSubgroupBlockPrefetchINTEL", + Class: "Group", + Opcode: 6221, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Ptr'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'NumBytes'", + Quantifier: "", + }, + Operand { + Kind: OperandKindMemoryAccess, + Name: "", + Quantifier: "?", + }, + }, + } + OpGroupIMulKHR = &Opcode { + Opname: "OpGroupIMulKHR", + Class: "Group", + Opcode: 6401, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupFMulKHR = &Opcode { + Opname: "OpGroupFMulKHR", + Class: "Group", + Opcode: 6402, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupBitwiseAndKHR = &Opcode { + Opname: "OpGroupBitwiseAndKHR", + Class: "Group", + Opcode: 6403, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupBitwiseOrKHR = &Opcode { + Opname: "OpGroupBitwiseOrKHR", + Class: "Group", + Opcode: 6404, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupBitwiseXorKHR = &Opcode { + Opname: "OpGroupBitwiseXorKHR", + Class: "Group", + Opcode: 6405, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupLogicalAndKHR = &Opcode { + Opname: "OpGroupLogicalAndKHR", + Class: "Group", + Opcode: 6406, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupLogicalOrKHR = &Opcode { + Opname: "OpGroupLogicalOrKHR", + Class: "Group", + Opcode: 6407, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpGroupLogicalXorKHR = &Opcode { + Opname: "OpGroupLogicalXorKHR", + Class: "Group", + Opcode: 6408, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdScope, + Name: "'Execution'", + Quantifier: "", + }, + Operand { + Kind: OperandKindGroupOperation, + Name: "'Operation'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'X'", + Quantifier: "", + }, + }, + } + OpMaskedGatherINTEL = &Opcode { + Opname: "OpMaskedGatherINTEL", + Class: "Memory", + Opcode: 6428, + Operands: []Operand { + Operand { + Kind: OperandKindIdResultType, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdResult, + Name: "", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PtrVector'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Alignment'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Mask'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'FillEmpty'", + Quantifier: "", + }, + }, + } + OpMaskedScatterINTEL = &Opcode { + Opname: "OpMaskedScatterINTEL", + Class: "Memory", + Opcode: 6429, + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'InputVector'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'PtrVector'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Alignment'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Mask'", + Quantifier: "", + }, + }, + } GLSLStd450_Round = &Opcode { Opname: "Round", @@ -19600,6 +26693,51 @@ var ( }, }, } + OpenCLDebugInfo100_DebugModuleINTEL = &Opcode { + Opname: "DebugModuleINTEL", + Operands: []Operand { + Operand { + Kind: OperandKindIdRef, + Name: "'Name'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Source'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'Parent'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'Line'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'ConfigurationMacros'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'IncludePath'", + Quantifier: "", + }, + Operand { + Kind: OperandKindIdRef, + Name: "'APINotesFile'", + Quantifier: "", + }, + Operand { + Kind: OperandKindLiteralInteger, + Name: "'IsDeclaration'", + Quantifier: "", + }, + }, + } OperandKindImageOperands = &OperandKind { @@ -19618,56 +26756,56 @@ var ( Value: 0x0001, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Lod", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Grad", Value: 0x0004, Capabilities: []string{}, Parameters: []Parameter{{OperandKindIdRef, ""},{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ConstOffset", Value: 0x0008, Capabilities: []string{}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Offset", Value: 0x0010, Capabilities: []string{"ImageGatherExtended",}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ConstOffsets", Value: 0x0020, Capabilities: []string{"ImageGatherExtended",}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Sample", Value: 0x0040, Capabilities: []string{}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MinLod", Value: 0x0080, Capabilities: []string{"MinLod",}, Parameters: []Parameter{{OperandKindIdRef, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MakeTexelAvailable", @@ -19676,13 +26814,6 @@ var ( Parameters: []Parameter{{OperandKindIdScope, ""},}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakeTexelAvailableKHR", - Value: 0x0100, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{{OperandKindIdScope, ""},}, - Version: "1.5", - }, Enumerant{ Enumerant: "MakeTexelVisible", Value: 0x0200, @@ -19690,13 +26821,6 @@ var ( Parameters: []Parameter{{OperandKindIdScope, ""},}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakeTexelVisibleKHR", - Value: 0x0200, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{{OperandKindIdScope, ""},}, - Version: "1.5", - }, Enumerant{ Enumerant: "NonPrivateTexel", Value: 0x0400, @@ -19704,13 +26828,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "NonPrivateTexelKHR", - Value: 0x0400, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "VolatileTexel", Value: 0x0800, @@ -19718,13 +26835,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "VolatileTexelKHR", - Value: 0x0800, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "SignExtend", Value: 0x1000, @@ -19739,6 +26849,20 @@ var ( Parameters: []Parameter{}, Version: "1.4", }, + Enumerant{ + Enumerant: "Nontemporal", + Value: 0x4000, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "Offsets", + Value: 0x10000, + Capabilities: []string{}, + Parameters: []Parameter{{OperandKindIdRef, ""},}, + Version: "1.0", + }, }, Bases: []*OperandKind {}, } @@ -19751,42 +26875,63 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NotNaN", Value: 0x0001, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NotInf", Value: 0x0002, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NSZ", Value: 0x0004, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "AllowRecip", Value: 0x0008, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Fast", Value: 0x0010, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "AllowContract", + Value: 0x10000, + Capabilities: []string{"FloatControls2","FPFastMathModeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AllowReassoc", + Value: 0x20000, + Capabilities: []string{"FloatControls2","FPFastMathModeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AllowTransform", + Value: 0x40000, + Capabilities: []string{"FloatControls2",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -19800,21 +26945,21 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Flatten", Value: 0x0001, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DontFlatten", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -19828,21 +26973,21 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Unroll", Value: 0x0001, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DontUnroll", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DependencyInfinite", @@ -19893,6 +27038,76 @@ var ( Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, Version: "1.4", }, + Enumerant{ + Enumerant: "InitiationIntervalINTEL", + Value: 0x10000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxConcurrencyINTEL", + Value: 0x20000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "DependencyArrayINTEL", + Value: 0x40000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "PipelineEnableINTEL", + Value: 0x80000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "LoopCoalesceINTEL", + Value: 0x100000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxInterleavingINTEL", + Value: 0x200000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SpeculatedIterationsINTEL", + Value: 0x400000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NoFusionINTEL", + Value: 0x800000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "LoopCountINTEL", + Value: 0x1000000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxReinvocationDelayINTEL", + Value: 0x2000000, + Capabilities: []string{"FPGALoopControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -19905,35 +27120,42 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Inline", Value: 0x0001, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DontInline", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Pure", Value: 0x0004, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Const", Value: 0x0008, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "OptNoneEXT", + Value: 0x10000, + Capabilities: []string{"OptNoneEXT",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -19947,84 +27169,77 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", - }, - Enumerant{ - Enumerant: "None", - Value: 0x0000, - Capabilities: []string{}, - Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Acquire", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Release", Value: 0x0004, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "AcquireRelease", Value: 0x0008, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SequentiallyConsistent", Value: 0x0010, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UniformMemory", Value: 0x0040, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupMemory", Value: 0x0080, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WorkgroupMemory", Value: 0x0100, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CrossWorkgroupMemory", Value: 0x0200, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "AtomicCounterMemory", Value: 0x0400, Capabilities: []string{"AtomicStorage",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageMemory", Value: 0x0800, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OutputMemory", @@ -20033,13 +27248,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "OutputMemoryKHR", - Value: 0x1000, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "MakeAvailable", Value: 0x2000, @@ -20047,13 +27255,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakeAvailableKHR", - Value: 0x2000, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "MakeVisible", Value: 0x4000, @@ -20061,13 +27262,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakeVisibleKHR", - Value: 0x4000, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "Volatile", Value: 0x8000, @@ -20087,28 +27281,28 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Volatile", Value: 0x0001, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Aligned", Value: 0x0002, Capabilities: []string{}, Parameters: []Parameter{{OperandKindLiteralInteger, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Nontemporal", Value: 0x0004, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MakePointerAvailable", @@ -20117,13 +27311,6 @@ var ( Parameters: []Parameter{{OperandKindIdScope, ""},}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakePointerAvailableKHR", - Value: 0x0008, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{{OperandKindIdScope, ""},}, - Version: "1.5", - }, Enumerant{ Enumerant: "MakePointerVisible", Value: 0x0010, @@ -20131,13 +27318,6 @@ var ( Parameters: []Parameter{{OperandKindIdScope, ""},}, Version: "1.5", }, - Enumerant{ - Enumerant: "MakePointerVisibleKHR", - Value: 0x0010, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{{OperandKindIdScope, ""},}, - Version: "1.5", - }, Enumerant{ Enumerant: "NonPrivatePointer", Value: 0x0020, @@ -20146,11 +27326,18 @@ var ( Version: "1.5", }, Enumerant{ - Enumerant: "NonPrivatePointerKHR", - Value: 0x0020, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", + Enumerant: "AliasScopeINTELMask", + Value: 0x10000, + Capabilities: []string{"MemoryAccessAliasingINTEL",}, + Parameters: []Parameter{{OperandKindIdRef, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NoAliasINTELMask", + Value: 0x20000, + Capabilities: []string{"MemoryAccessAliasingINTEL",}, + Parameters: []Parameter{{OperandKindIdRef, ""},}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -20164,14 +27351,14 @@ var ( Value: 0x0000, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CmdExecTime", Value: 0x0001, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -20183,80 +27370,150 @@ var ( Enumerant{ Enumerant: "NoneKHR", Value: 0x0000, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "OpaqueKHR", Value: 0x0001, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "NoOpaqueKHR", Value: 0x0002, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "TerminateOnFirstHitKHR", Value: 0x0004, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "SkipClosestHitShaderKHR", Value: 0x0008, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "CullBackFacingTrianglesKHR", Value: 0x0010, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "CullFrontFacingTrianglesKHR", Value: 0x0020, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "CullOpaqueKHR", Value: 0x0040, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "CullNoOpaqueKHR", Value: 0x0080, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "SkipTrianglesKHR", Value: 0x0100, - Capabilities: []string{"RayTraversalPrimitiveCullingProvisionalKHR",}, + Capabilities: []string{"RayTraversalPrimitiveCullingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "SkipAABBsKHR", Value: 0x0200, - Capabilities: []string{"RayTraversalPrimitiveCullingProvisionalKHR",}, + Capabilities: []string{"RayTraversalPrimitiveCullingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ForceOpacityMicromap2StateEXT", + Value: 0x0400, + Capabilities: []string{"RayTracingOpacityMicromapEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindFragmentShadingRate = &OperandKind { + Kind: "FragmentShadingRate", + Category: "BitEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "Vertical2Pixels", + Value: 0x0001, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Vertical4Pixels", + Value: 0x0002, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Horizontal2Pixels", + Value: 0x0004, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Horizontal4Pixels", + Value: 0x0008, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindRawAccessChainOperands = &OperandKind { + Kind: "RawAccessChainOperands", + Category: "BitEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "None", + Value: 0x0000, + Capabilities: []string{}, Parameters: []Parameter{}, Version: "", }, + Enumerant{ + Enumerant: "RobustnessPerComponentNV", + Value: 0x0001, + Capabilities: []string{"RawAccessChainsNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RobustnessPerElementNV", + Value: 0x0002, + Capabilities: []string{"RawAccessChainsNV",}, + Parameters: []Parameter{}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -20269,42 +27526,91 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ESSL", Value: 1, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GLSL", Value: 2, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OpenCL_C", Value: 3, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OpenCL_CPP", Value: 4, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "HLSL", Value: 5, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "CPP_for_OpenCL", + Value: 6, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "SYCL", + Value: 7, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "HERO_C", + Value: 8, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "NZSL", + Value: 9, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "WGSL", + Value: 10, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "Slang", + Value: 11, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "Zig", + Value: 12, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -20318,49 +27624,49 @@ var ( Value: 0, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessellationControl", Value: 1, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessellationEvaluation", Value: 2, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Geometry", Value: 3, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Fragment", Value: 4, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GLCompute", Value: 5, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Kernel", Value: 6, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TaskNV", @@ -20376,87 +27682,59 @@ var ( Parameters: []Parameter{}, Version: "None", }, - Enumerant{ - Enumerant: "RayGenerationNV", - Value: 5313, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, Enumerant{ Enumerant: "RayGenerationKHR", Value: 5313, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "IntersectionNV", - Value: 5314, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "IntersectionKHR", Value: 5314, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "AnyHitNV", - Value: 5315, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "AnyHitKHR", Value: 5315, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "ClosestHitNV", - Value: 5316, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "ClosestHitKHR", Value: 5316, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "MissNV", - Value: 5317, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "MissKHR", Value: 5317, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "CallableNV", - Value: 5318, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "CallableKHR", Value: 5318, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TaskEXT", + Value: 5364, + Capabilities: []string{"MeshShadingEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MeshEXT", + Value: 5365, + Capabilities: []string{"MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, @@ -20472,21 +27750,21 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Physical32", Value: 1, Capabilities: []string{"Addresses",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Physical64", Value: 2, Capabilities: []string{"Addresses",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PhysicalStorageBuffer64", @@ -20495,13 +27773,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "PhysicalStorageBuffer64EXT", - Value: 5348, - Capabilities: []string{"PhysicalStorageBufferAddresses",}, - Parameters: []Parameter{}, - Version: "1.5", - }, }, Bases: []*OperandKind {}, } @@ -20514,21 +27785,21 @@ var ( Value: 0, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GLSL450", Value: 1, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OpenCL", Value: 2, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Vulkan", @@ -20537,13 +27808,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "VulkanKHR", - Value: 3, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, }, Bases: []*OperandKind {}, } @@ -20556,217 +27820,217 @@ var ( Value: 0, Capabilities: []string{"Geometry",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Number of <>'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SpacingEqual", Value: 1, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SpacingFractionalEven", Value: 2, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SpacingFractionalOdd", Value: 3, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "VertexOrderCw", Value: 4, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "VertexOrderCcw", Value: 5, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PixelCenterInteger", Value: 6, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OriginUpperLeft", Value: 7, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OriginLowerLeft", Value: 8, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "EarlyFragmentTests", Value: 9, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PointMode", Value: 10, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Xfb", Value: 11, Capabilities: []string{"TransformFeedback",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DepthReplacing", Value: 12, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DepthGreater", Value: 14, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DepthLess", Value: 15, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DepthUnchanged", Value: 16, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LocalSize", Value: 17, Capabilities: []string{}, Parameters: []Parameter{{OperandKindLiteralInteger, "'x size'"},{OperandKindLiteralInteger, "'y size'"},{OperandKindLiteralInteger, "'z size'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LocalSizeHint", Value: 18, Capabilities: []string{"Kernel",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'x size'"},{OperandKindLiteralInteger, "'y size'"},{OperandKindLiteralInteger, "'z size'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputPoints", Value: 19, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputLines", Value: 20, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputLinesAdjacency", Value: 21, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Triangles", Value: 22, Capabilities: []string{"Geometry","Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputTrianglesAdjacency", Value: 23, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Quads", Value: 24, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Isolines", Value: 25, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OutputVertices", Value: 26, - Capabilities: []string{"Geometry","Tessellation","MeshShadingNV",}, + Capabilities: []string{"Geometry","Tessellation","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Vertex count'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OutputPoints", Value: 27, - Capabilities: []string{"Geometry","MeshShadingNV",}, + Capabilities: []string{"Geometry","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OutputLineStrip", Value: 28, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "OutputTriangleStrip", Value: 29, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "VecTypeHint", Value: 30, Capabilities: []string{"Kernel",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Vector type'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ContractionOff", Value: 31, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Initializer", @@ -20814,9 +28078,37 @@ var ( Enumerant: "LocalSizeHintId", Value: 39, Capabilities: []string{"Kernel",}, - Parameters: []Parameter{{OperandKindIdRef, "'Local Size Hint'"},}, + Parameters: []Parameter{{OperandKindIdRef, "'x size hint'"},{OperandKindIdRef, "'y size hint'"},{OperandKindIdRef, "'z size hint'"},}, Version: "1.2", }, + Enumerant{ + Enumerant: "NonCoherentColorAttachmentReadEXT", + Value: 4169, + Capabilities: []string{"TileImageColorReadAccessEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "NonCoherentDepthAttachmentReadEXT", + Value: 4170, + Capabilities: []string{"TileImageDepthReadAccessEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "NonCoherentStencilAttachmentReadEXT", + Value: 4171, + Capabilities: []string{"TileImageStencilReadAccessEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SubgroupUniformControlFlowKHR", + Value: 4421, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "PostDepthCoverage", Value: 4446, @@ -20859,6 +28151,13 @@ var ( Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},}, Version: "1.4", }, + Enumerant{ + Enumerant: "EarlyAndLateFragmentTestsAMD", + Value: 5017, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "StencilRefReplacingEXT", Value: 5027, @@ -20867,37 +28166,142 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "OutputLinesNV", - Value: 5269, - Capabilities: []string{"MeshShadingNV",}, + Enumerant: "CoalescingAMDX", + Value: 5069, + Capabilities: []string{"ShaderEnqueueAMDX",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "OutputPrimitivesNV", + Enumerant: "IsApiEntryAMDX", + Value: 5070, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Is Entry'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxNodeRecursionAMDX", + Value: 5071, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Number of recursions'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StaticNumWorkgroupsAMDX", + Value: 5072, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'x size'"},{OperandKindIdRef, "'y size'"},{OperandKindIdRef, "'z size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "ShaderIndexAMDX", + Value: 5073, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Shader Index'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxNumWorkgroupsAMDX", + Value: 5077, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'x size'"},{OperandKindIdRef, "'y size'"},{OperandKindIdRef, "'z size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefUnchangedFrontAMD", + Value: 5079, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefGreaterFrontAMD", + Value: 5080, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefLessFrontAMD", + Value: 5081, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefUnchangedBackAMD", + Value: 5082, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefGreaterBackAMD", + Value: 5083, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StencilRefLessBackAMD", + Value: 5084, + Capabilities: []string{"StencilExportEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "QuadDerivativesKHR", + Value: 5088, + Capabilities: []string{"QuadControlKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RequireFullQuadsKHR", + Value: 5089, + Capabilities: []string{"QuadControlKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SharesInputWithAMDX", + Value: 5102, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Node Name'"},{OperandKindIdRef, "'Shader Index'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "OutputLinesEXT", + Value: 5269, + Capabilities: []string{"MeshShadingNV","MeshShadingEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "OutputPrimitivesEXT", Value: 5270, - Capabilities: []string{"MeshShadingNV",}, + Capabilities: []string{"MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Primitive count'"},}, Version: "None", }, Enumerant{ - Enumerant: "DerivativeGroupQuadsNV", + Enumerant: "DerivativeGroupQuadsKHR", Value: 5289, - Capabilities: []string{"ComputeDerivativeGroupQuadsNV",}, + Capabilities: []string{"ComputeDerivativeGroupQuadsNV","ComputeDerivativeGroupQuadsKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "DerivativeGroupLinearNV", + Enumerant: "DerivativeGroupLinearKHR", Value: 5290, - Capabilities: []string{"ComputeDerivativeGroupLinearNV",}, + Capabilities: []string{"ComputeDerivativeGroupLinearNV","ComputeDerivativeGroupLinearKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "OutputTrianglesNV", + Enumerant: "OutputTrianglesEXT", Value: 5298, - Capabilities: []string{"MeshShadingNV",}, + Capabilities: []string{"MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, @@ -20943,6 +28347,132 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "SharedLocalMemorySizeINTEL", + Value: 5618, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "RoundingModeRTPINTEL", + Value: 5620, + Capabilities: []string{"RoundToInfinityINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "RoundingModeRTNINTEL", + Value: 5621, + Capabilities: []string{"RoundToInfinityINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "FloatingPointModeALTINTEL", + Value: 5622, + Capabilities: []string{"RoundToInfinityINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "FloatingPointModeIEEEINTEL", + Value: 5623, + Capabilities: []string{"RoundToInfinityINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxWorkgroupSizeINTEL", + Value: 5893, + Capabilities: []string{"KernelAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'max_x_size'"},{OperandKindLiteralInteger, "'max_y_size'"},{OperandKindLiteralInteger, "'max_z_size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxWorkDimINTEL", + Value: 5894, + Capabilities: []string{"KernelAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'max_dimensions'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NoGlobalOffsetINTEL", + Value: 5895, + Capabilities: []string{"KernelAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "NumSIMDWorkitemsINTEL", + Value: 5896, + Capabilities: []string{"FPGAKernelAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'vector_width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SchedulerTargetFmaxMhzINTEL", + Value: 5903, + Capabilities: []string{"FPGAKernelAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'target_fmax'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaximallyReconvergesKHR", + Value: 6023, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPFastMathDefault", + Value: 6028, + Capabilities: []string{"FloatControls2",}, + Parameters: []Parameter{{OperandKindIdRef, "'Target Type'"},{OperandKindIdRef, "'Fast-Math Mode'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StreamingInterfaceINTEL", + Value: 6154, + Capabilities: []string{"FPGAKernelAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'StallFreeReturn'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "RegisterMapInterfaceINTEL", + Value: 6160, + Capabilities: []string{"FPGAKernelAttributesv2INTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'WaitForDoneWrite'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NamedBarrierCountINTEL", + Value: 6417, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Barrier Count'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaximumRegistersINTEL", + Value: 6461, + Capabilities: []string{"RegisterLimitsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Number of Registers'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaximumRegistersIdINTEL", + Value: 6462, + Capabilities: []string{"RegisterLimitsINTEL",}, + Parameters: []Parameter{{OperandKindIdRef, "'Number of Registers'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NamedMaximumRegistersINTEL", + Value: 6463, + Capabilities: []string{"RegisterLimitsINTEL",}, + Parameters: []Parameter{{OperandKindNamedMaximumNumberOfRegisters, "'Named Maximum Number of Registers'"},}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -20955,84 +28485,84 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Input", Value: 1, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Uniform", Value: 2, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Output", Value: 3, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Workgroup", Value: 4, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CrossWorkgroup", Value: 5, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Private", Value: 6, - Capabilities: []string{"Shader",}, + Capabilities: []string{"Shader","VectorComputeINTEL",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Function", Value: 7, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Generic", Value: 8, Capabilities: []string{"GenericPointer",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PushConstant", Value: 9, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "AtomicCounter", Value: 10, Capabilities: []string{"AtomicStorage",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Image", Value: 11, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageBuffer", @@ -21042,86 +28572,58 @@ var ( Version: "1.3", }, Enumerant{ - Enumerant: "CallableDataNV", - Value: 5328, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Enumerant: "TileImageEXT", + Value: 4172, + Capabilities: []string{"TileImageColorReadAccessEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "NodePayloadAMDX", + Value: 5068, + Capabilities: []string{"ShaderEnqueueAMDX",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "CallableDataKHR", Value: 5328, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "IncomingCallableDataNV", - Value: 5329, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "IncomingCallableDataKHR", Value: 5329, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "RayPayloadNV", - Value: 5338, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "RayPayloadKHR", Value: 5338, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "HitAttributeNV", - Value: 5339, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "HitAttributeKHR", Value: 5339, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "IncomingRayPayloadNV", - Value: 5342, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "IncomingRayPayloadKHR", Value: 5342, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "ShaderRecordBufferNV", - Value: 5343, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "ShaderRecordBufferKHR", Value: 5343, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, @@ -21133,11 +28635,39 @@ var ( Version: "1.5", }, Enumerant{ - Enumerant: "PhysicalStorageBufferEXT", - Value: 5349, - Capabilities: []string{"PhysicalStorageBufferAddresses",}, + Enumerant: "HitObjectAttributeNV", + Value: 5385, + Capabilities: []string{"ShaderInvocationReorderNV",}, Parameters: []Parameter{}, - Version: "1.5", + Version: "None", + }, + Enumerant{ + Enumerant: "TaskPayloadWorkgroupEXT", + Value: 5402, + Capabilities: []string{"MeshShadingEXT",}, + Parameters: []Parameter{}, + Version: "1.4", + }, + Enumerant{ + Enumerant: "CodeSectionINTEL", + Value: 5605, + Capabilities: []string{"FunctionPointersINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "DeviceOnlyINTEL", + Value: 5936, + Capabilities: []string{"USMStorageClassesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HostOnlyINTEL", + Value: 5937, + Capabilities: []string{"USMStorageClassesINTEL",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -21149,51 +28679,58 @@ var ( Enumerant{ Enumerant: "1D", Value: 0, - Capabilities: []string{"Sampled1D","Image1D",}, + Capabilities: []string{"Sampled1D",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "2D", Value: 1, - Capabilities: []string{"Shader","Kernel","ImageMSArray",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "3D", Value: 2, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Cube", Value: 3, - Capabilities: []string{"Shader","ImageCubeArray",}, + Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rect", Value: 4, - Capabilities: []string{"SampledRect","ImageRect",}, + Capabilities: []string{"SampledRect",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Buffer", Value: 5, - Capabilities: []string{"SampledBuffer","ImageBuffer",}, + Capabilities: []string{"SampledBuffer",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubpassData", Value: 6, Capabilities: []string{"InputAttachment",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "TileImageDataEXT", + Value: 4173, + Capabilities: []string{"TileImageColorReadAccessEXT",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -21205,37 +28742,37 @@ var ( Enumerant{ Enumerant: "None", Value: 0, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ClampToEdge", Value: 1, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Clamp", Value: 2, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Repeat", Value: 3, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RepeatMirrored", Value: 4, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21247,16 +28784,16 @@ var ( Enumerant{ Enumerant: "Nearest", Value: 0, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Linear", Value: 1, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21270,280 +28807,294 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba32f", Value: 1, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba16f", Value: 2, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R32f", Value: 3, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba8", Value: 4, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba8Snorm", Value: 5, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg32f", Value: 6, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg16f", Value: 7, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R11fG11fB10f", Value: 8, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R16f", Value: 9, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba16", Value: 10, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgb10A2", Value: 11, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg16", Value: 12, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg8", Value: 13, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R16", Value: 14, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R8", Value: 15, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba16Snorm", Value: 16, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg16Snorm", Value: 17, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg8Snorm", Value: 18, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R16Snorm", Value: 19, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R8Snorm", Value: 20, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba32i", Value: 21, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba16i", Value: 22, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba8i", Value: 23, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R32i", Value: 24, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg32i", Value: 25, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg16i", Value: 26, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg8i", Value: 27, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R16i", Value: 28, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R8i", Value: 29, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba32ui", Value: 30, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba16ui", Value: 31, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgba8ui", Value: 32, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R32ui", Value: 33, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rgb10a2ui", Value: 34, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg32ui", Value: 35, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg16ui", Value: 36, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rg8ui", Value: 37, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R16ui", Value: 38, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "R8ui", Value: 39, Capabilities: []string{"StorageImageExtendedFormats",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "R64ui", + Value: 40, + Capabilities: []string{"Int64ImageEXT",}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "R64i", + Value: 41, + Capabilities: []string{"Int64ImageEXT",}, + Parameters: []Parameter{}, + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21555,142 +29106,142 @@ var ( Enumerant{ Enumerant: "R", Value: 0, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "A", Value: 1, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RG", Value: 2, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RA", Value: 3, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RGB", Value: 4, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RGBA", Value: 5, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "BGRA", Value: 6, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ARGB", Value: 7, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Intensity", Value: 8, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Luminance", Value: 9, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Rx", Value: 10, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RGx", Value: 11, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RGBx", Value: 12, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Depth", Value: 13, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DepthStencil", Value: 14, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "sRGB", Value: 15, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "sRGBx", Value: 16, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "sRGBA", Value: 17, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "sBGRA", Value: 18, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ABGR", Value: 19, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21702,121 +29253,142 @@ var ( Enumerant{ Enumerant: "SnormInt8", Value: 0, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SnormInt16", Value: 1, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormInt8", Value: 2, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormInt16", Value: 3, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormShort565", Value: 4, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormShort555", Value: 5, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormInt101010", Value: 6, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SignedInt8", Value: 7, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SignedInt16", Value: 8, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SignedInt32", Value: 9, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnsignedInt8", Value: 10, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnsignedInt16", Value: 11, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnsignedInt32", Value: 12, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "HalfFloat", Value: 13, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Float", Value: 14, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormInt24", Value: 15, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UnormInt101010_2", Value: 16, - Capabilities: []string{"Kernel",}, + Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "UnsignedIntRaw10EXT", + Value: 19, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "UnsignedIntRaw12EXT", + Value: 20, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "UnormInt2_101010EXT", + Value: 21, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21830,28 +29402,168 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RTZ", Value: 1, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RTP", Value: 2, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RTN", Value: 3, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindFPDenormMode = &OperandKind { + Kind: "FPDenormMode", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "Preserve", + Value: 0, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FlushToZero", + Value: 1, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindQuantizationModes = &OperandKind { + Kind: "QuantizationModes", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "TRN", + Value: 0, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TRN_ZERO", + Value: 1, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND", + Value: 2, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND_ZERO", + Value: 3, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND_INF", + Value: 4, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND_MIN_INF", + Value: 5, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND_CONV", + Value: 6, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RND_CONV_ODD", + Value: 7, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindFPOperationMode = &OperandKind { + Kind: "FPOperationMode", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "IEEE", + Value: 0, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ALT", + Value: 1, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindOverflowModes = &OperandKind { + Kind: "OverflowModes", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "WRAP", + Value: 0, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SAT", + Value: 1, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SAT_ZERO", + Value: 2, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SAT_SYM", + Value: 3, + Capabilities: []string{"ArbitraryPrecisionFixedPointINTEL",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -21865,14 +29577,21 @@ var ( Value: 0, Capabilities: []string{"Linkage",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Import", Value: 1, Capabilities: []string{"Linkage",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "LinkOnceODR", + Value: 2, + Capabilities: []string{"Linkage",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -21886,21 +29605,56 @@ var ( Value: 0, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WriteOnly", Value: 1, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ReadWrite", Value: 2, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindHostAccessQualifier = &OperandKind { + Kind: "HostAccessQualifier", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "NoneINTEL", + Value: 0, + Capabilities: []string{"GlobalVariableHostAccessINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ReadINTEL", + Value: 1, + Capabilities: []string{"GlobalVariableHostAccessINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "WriteINTEL", + Value: 2, + Capabilities: []string{"GlobalVariableHostAccessINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ReadWriteINTEL", + Value: 3, + Capabilities: []string{"GlobalVariableHostAccessINTEL",}, + Parameters: []Parameter{}, + Version: "None", }, }, Bases: []*OperandKind {}, @@ -21914,56 +29668,63 @@ var ( Value: 0, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Sext", Value: 1, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ByVal", Value: 2, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Sret", Value: 3, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoAlias", Value: 4, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoCapture", Value: 5, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoWrite", Value: 6, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoReadWrite", Value: 7, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "RuntimeAlignedINTEL", + Value: 5940, + Capabilities: []string{"RuntimeAlignedAttributeINTEL",}, + Parameters: []Parameter{}, + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -21977,187 +29738,187 @@ var ( Value: 0, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SpecId", Value: 1, Capabilities: []string{"Shader","Kernel",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Specialization Constant ID'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Block", Value: 2, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "BufferBlock", Value: 3, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "RowMajor", Value: 4, Capabilities: []string{"Matrix",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ColMajor", Value: 5, Capabilities: []string{"Matrix",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ArrayStride", Value: 6, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Array Stride'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MatrixStride", Value: 7, Capabilities: []string{"Matrix",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Matrix Stride'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GLSLShared", Value: 8, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GLSLPacked", Value: 9, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CPacked", Value: 10, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "BuiltIn", Value: 11, Capabilities: []string{}, Parameters: []Parameter{{OperandKindBuiltIn, ""},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoPerspective", Value: 13, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Flat", Value: 14, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Patch", Value: 15, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Centroid", Value: 16, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Sample", Value: 17, Capabilities: []string{"SampleRateShading",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Invariant", Value: 18, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Restrict", Value: 19, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Aliased", Value: 20, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Volatile", Value: 21, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Constant", Value: 22, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Coherent", Value: 23, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NonWritable", Value: 24, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NonReadable", Value: 25, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Uniform", Value: 26, - Capabilities: []string{"Shader",}, + Capabilities: []string{"Shader","UniformDecoration",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UniformId", Value: 27, - Capabilities: []string{"Shader",}, + Capabilities: []string{"Shader","UniformDecoration",}, Parameters: []Parameter{{OperandKindIdScope, "'Execution'"},}, Version: "1.4", }, @@ -22166,119 +29927,119 @@ var ( Value: 28, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Stream", Value: 29, Capabilities: []string{"GeometryStreams",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Stream Number'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Location", Value: 30, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Location'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Component", Value: 31, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Component'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Index", Value: 32, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Index'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Binding", Value: 33, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Binding Point'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DescriptorSet", Value: 34, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Descriptor Set'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Offset", Value: 35, Capabilities: []string{"Shader",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Byte Offset'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "XfbBuffer", Value: 36, Capabilities: []string{"TransformFeedback",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'XFB Buffer Number'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "XfbStride", Value: 37, Capabilities: []string{"TransformFeedback",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'XFB Stride'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FuncParamAttr", Value: 38, Capabilities: []string{"Kernel",}, Parameters: []Parameter{{OperandKindFunctionParameterAttribute, "'Function Parameter Attribute'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FPRoundingMode", Value: 39, Capabilities: []string{}, Parameters: []Parameter{{OperandKindFPRoundingMode, "'Floating-Point Rounding Mode'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FPFastMathMode", Value: 40, - Capabilities: []string{"Kernel",}, + Capabilities: []string{"Kernel","FloatControls2",}, Parameters: []Parameter{{OperandKindFPFastMathMode, "'Fast-Math Mode'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LinkageAttributes", Value: 41, Capabilities: []string{"Linkage",}, Parameters: []Parameter{{OperandKindLiteralString, "'Name'"},{OperandKindLinkageType, "'Linkage Type'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NoContraction", Value: 42, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputAttachmentIndex", Value: 43, Capabilities: []string{"InputAttachment",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Attachment Index'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Alignment", Value: 44, Capabilities: []string{"Kernel",}, Parameters: []Parameter{{OperandKindLiteralInteger, "'Alignment'"},}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MaxByteOffset", @@ -22315,6 +30076,27 @@ var ( Parameters: []Parameter{}, Version: "1.4", }, + Enumerant{ + Enumerant: "WeightTextureQCOM", + Value: 4487, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BlockMatchTextureQCOM", + Value: 4488, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BlockMatchSamplerQCOM", + Value: 4499, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "ExplicitInterpAMD", Value: 4999, @@ -22322,6 +30104,62 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "NodeSharesPayloadLimitsWithAMDX", + Value: 5019, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Payload Type'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NodeMaxPayloadsAMDX", + Value: 5020, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Max number of payloads'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "TrackFinishWritingAMDX", + Value: 5078, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "PayloadNodeNameAMDX", + Value: 5091, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Node Name'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "PayloadNodeBaseIndexAMDX", + Value: 5098, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Base Index'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "PayloadNodeSparseArrayAMDX", + Value: 5099, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "PayloadNodeArraySizeAMDX", + Value: 5100, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{{OperandKindIdRef, "'Array Size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "PayloadDispatchIndirectAMDX", + Value: 5105, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "OverrideCoverageNV", Value: 5248, @@ -22351,9 +30189,9 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "PerPrimitiveNV", + Enumerant: "PerPrimitiveEXT", Value: 5271, - Capabilities: []string{"MeshShadingNV",}, + Capabilities: []string{"MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, @@ -22367,14 +30205,14 @@ var ( Enumerant{ Enumerant: "PerTaskNV", Value: 5273, - Capabilities: []string{"MeshShadingNV",}, + Capabilities: []string{"MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "PerVertexNV", + Enumerant: "PerVertexKHR", Value: 5285, - Capabilities: []string{"FragmentBarycentricNV",}, + Capabilities: []string{"FragmentBarycentricKHR",}, Parameters: []Parameter{}, Version: "None", }, @@ -22385,13 +30223,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "NonUniformEXT", - Value: 5300, - Capabilities: []string{"ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "RestrictPointer", Value: 5355, @@ -22399,13 +30230,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "RestrictPointerEXT", - Value: 5355, - Capabilities: []string{"PhysicalStorageBufferAddresses",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "AliasedPointer", Value: 5356, @@ -22414,11 +30238,102 @@ var ( Version: "1.5", }, Enumerant{ - Enumerant: "AliasedPointerEXT", - Value: 5356, - Capabilities: []string{"PhysicalStorageBufferAddresses",}, + Enumerant: "HitObjectShaderRecordBufferNV", + Value: 5386, + Capabilities: []string{"ShaderInvocationReorderNV",}, Parameters: []Parameter{}, - Version: "1.5", + Version: "None", + }, + Enumerant{ + Enumerant: "BindlessSamplerNV", + Value: 5398, + Capabilities: []string{"BindlessTextureNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BindlessImageNV", + Value: 5399, + Capabilities: []string{"BindlessTextureNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BoundSamplerNV", + Value: 5400, + Capabilities: []string{"BindlessTextureNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BoundImageNV", + Value: 5401, + Capabilities: []string{"BindlessTextureNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SIMTCallINTEL", + Value: 5599, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'N'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "ReferencedIndirectlyINTEL", + Value: 5602, + Capabilities: []string{"IndirectReferencesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ClobberINTEL", + Value: 5607, + Capabilities: []string{"AsmINTEL",}, + Parameters: []Parameter{{OperandKindLiteralString, "'Register'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SideEffectsINTEL", + Value: 5608, + Capabilities: []string{"AsmINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "VectorComputeVariableINTEL", + Value: 5624, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FuncParamIOKindINTEL", + Value: 5625, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Kind'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "VectorComputeFunctionINTEL", + Value: 5626, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StackCallINTEL", + Value: 5627, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "GlobalVariableOffsetINTEL", + Value: 5628, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Offset'"},}, + Version: "None", }, Enumerant{ Enumerant: "CounterBuffer", @@ -22427,13 +30342,6 @@ var ( Parameters: []Parameter{{OperandKindIdRef, "'Counter Buffer'"},}, Version: "1.4", }, - Enumerant{ - Enumerant: "HlslCounterBufferGOOGLE", - Value: 5634, - Capabilities: []string{}, - Parameters: []Parameter{{OperandKindIdRef, "'Counter Buffer'"},}, - Version: "None", - }, Enumerant{ Enumerant: "UserSemantic", Value: 5635, @@ -22441,13 +30349,6 @@ var ( Parameters: []Parameter{{OperandKindLiteralString, "'Semantic'"},}, Version: "1.4", }, - Enumerant{ - Enumerant: "HlslSemanticGOOGLE", - Value: 5635, - Capabilities: []string{}, - Parameters: []Parameter{{OperandKindLiteralString, "'Semantic'"},}, - Version: "None", - }, Enumerant{ Enumerant: "UserTypeGOOGLE", Value: 5636, @@ -22455,6 +30356,377 @@ var ( Parameters: []Parameter{{OperandKindLiteralString, "'User Type'"},}, Version: "None", }, + Enumerant{ + Enumerant: "FunctionRoundingModeINTEL", + Value: 5822, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},{OperandKindFPRoundingMode, "'FP Rounding Mode'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "FunctionDenormModeINTEL", + Value: 5823, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},{OperandKindFPDenormMode, "'FP Denorm Mode'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "RegisterINTEL", + Value: 5825, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MemoryINTEL", + Value: 5826, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralString, "'Memory Type'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NumbanksINTEL", + Value: 5827, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Banks'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "BankwidthINTEL", + Value: 5828, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Bank Width'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxPrivateCopiesINTEL", + Value: 5829, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Maximum Copies'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SinglepumpINTEL", + Value: 5830, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "DoublepumpINTEL", + Value: 5831, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxReplicatesINTEL", + Value: 5832, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Maximum Replicates'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SimpleDualPortINTEL", + Value: 5833, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MergeINTEL", + Value: 5834, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralString, "'Merge Key'"},{OperandKindLiteralString, "'Merge Type'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "BankBitsINTEL", + Value: 5835, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Bank Bits'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "ForcePow2DepthINTEL", + Value: 5836, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Force Key'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StridesizeINTEL", + Value: 5883, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Stride Size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "WordsizeINTEL", + Value: 5884, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Word Size'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "TrueDualPortINTEL", + Value: 5885, + Capabilities: []string{"FPGAMemoryAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BurstCoalesceINTEL", + Value: 5899, + Capabilities: []string{"FPGAMemoryAccessesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CacheSizeINTEL", + Value: 5900, + Capabilities: []string{"FPGAMemoryAccessesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Cache Size in bytes'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "DontStaticallyCoalesceINTEL", + Value: 5901, + Capabilities: []string{"FPGAMemoryAccessesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "PrefetchINTEL", + Value: 5902, + Capabilities: []string{"FPGAMemoryAccessesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Prefetcher Size in bytes'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StallEnableINTEL", + Value: 5905, + Capabilities: []string{"FPGAClusterAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FuseLoopsInFunctionINTEL", + Value: 5907, + Capabilities: []string{"LoopFuseINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MathOpDSPModeINTEL", + Value: 5909, + Capabilities: []string{"FPGADSPControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Mode'"},{OperandKindLiteralInteger, "'Propagate'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "AliasScopeINTEL", + Value: 5914, + Capabilities: []string{"MemoryAccessAliasingINTEL",}, + Parameters: []Parameter{{OperandKindIdRef, "'Aliasing Scopes List'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "NoAliasINTEL", + Value: 5915, + Capabilities: []string{"MemoryAccessAliasingINTEL",}, + Parameters: []Parameter{{OperandKindIdRef, "'Aliasing Scopes List'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "InitiationIntervalINTEL", + Value: 5917, + Capabilities: []string{"FPGAInvocationPipeliningAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Cycles'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaxConcurrencyINTEL", + Value: 5918, + Capabilities: []string{"FPGAInvocationPipeliningAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Invocations'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "PipelineEnableINTEL", + Value: 5919, + Capabilities: []string{"FPGAInvocationPipeliningAttributesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Enable'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "BufferLocationINTEL", + Value: 5921, + Capabilities: []string{"FPGABufferLocationINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Buffer Location ID'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "IOPipeStorageINTEL", + Value: 5944, + Capabilities: []string{"IOPipesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'IO Pipe ID'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "FunctionFloatingPointModeINTEL", + Value: 6080, + Capabilities: []string{"FunctionFloatControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Target Width'"},{OperandKindFPOperationMode, "'FP Operation Mode'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "SingleElementVectorINTEL", + Value: 6085, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "VectorComputeCallableFunctionINTEL", + Value: 6087, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MediaBlockIOINTEL", + Value: 6140, + Capabilities: []string{"VectorComputeINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StallFreeINTEL", + Value: 6151, + Capabilities: []string{"FPGAClusterAttributesV2INTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPMaxErrorDecorationINTEL", + Value: 6170, + Capabilities: []string{"FPMaxErrorINTEL",}, + Parameters: []Parameter{{OperandKindLiteralFloat, "'Max Error'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "LatencyControlLabelINTEL", + Value: 6172, + Capabilities: []string{"FPGALatencyControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Latency Label'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "LatencyControlConstraintINTEL", + Value: 6173, + Capabilities: []string{"FPGALatencyControlINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Relative To'"},{OperandKindLiteralInteger, "'Control Type'"},{OperandKindLiteralInteger, "'Relative Cycle'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "ConduitKernelArgumentINTEL", + Value: 6175, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RegisterMapKernelArgumentINTEL", + Value: 6176, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceAddressWidthINTEL", + Value: 6177, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'AddressWidth'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceDataWidthINTEL", + Value: 6178, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'DataWidth'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceLatencyINTEL", + Value: 6179, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Latency'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceReadWriteModeINTEL", + Value: 6180, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindAccessQualifier, "'ReadWriteMode'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceMaxBurstINTEL", + Value: 6181, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'MaxBurstCount'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "MMHostInterfaceWaitRequestINTEL", + Value: 6182, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Waitrequest'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "StableKernelArgumentINTEL", + Value: 6183, + Capabilities: []string{"FPGAArgumentInterfacesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HostAccessINTEL", + Value: 6188, + Capabilities: []string{"GlobalVariableHostAccessINTEL",}, + Parameters: []Parameter{{OperandKindHostAccessQualifier, "'Access'"},{OperandKindLiteralString, "'Name'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "InitModeINTEL", + Value: 6190, + Capabilities: []string{"GlobalVariableFPGADecorationsINTEL",}, + Parameters: []Parameter{{OperandKindInitializationModeQualifier, "'Trigger'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "ImplementInRegisterMapINTEL", + Value: 6191, + Capabilities: []string{"GlobalVariableFPGADecorationsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "Value"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "CacheControlLoadINTEL", + Value: 6442, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Cache Level'"},{OperandKindLoadCacheControl, "'Cache Control'"},}, + Version: "None", + }, + Enumerant{ + Enumerant: "CacheControlStoreINTEL", + Value: 6443, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{{OperandKindLiteralInteger, "'Cache Level'"},{OperandKindStoreCacheControl, "'Cache Control'"},}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -22467,287 +30739,322 @@ var ( Value: 0, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PointSize", Value: 1, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ClipDistance", Value: 3, Capabilities: []string{"ClipDistance",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CullDistance", Value: 4, Capabilities: []string{"CullDistance",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "VertexId", Value: 5, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InstanceId", Value: 6, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PrimitiveId", Value: 7, - Capabilities: []string{"Geometry","Tessellation","RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"Geometry","Tessellation","RayTracingNV","RayTracingKHR","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InvocationId", Value: 8, Capabilities: []string{"Geometry","Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Layer", Value: 9, - Capabilities: []string{"Geometry","ShaderLayer","ShaderViewportIndexLayerEXT",}, + Capabilities: []string{"Geometry","ShaderLayer","ShaderViewportIndexLayerEXT","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ViewportIndex", Value: 10, - Capabilities: []string{"MultiViewport","ShaderViewportIndex","ShaderViewportIndexLayerEXT",}, + Capabilities: []string{"MultiViewport","ShaderViewportIndex","ShaderViewportIndexLayerEXT","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessLevelOuter", Value: 11, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessLevelInner", Value: 12, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessCoord", Value: 13, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PatchVertices", Value: 14, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FragCoord", Value: 15, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "PointCoord", Value: 16, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FrontFacing", Value: 17, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampleId", Value: 18, Capabilities: []string{"SampleRateShading",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SamplePosition", Value: 19, Capabilities: []string{"SampleRateShading",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampleMask", Value: 20, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "FragDepth", Value: 22, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "HelperInvocation", Value: 23, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NumWorkgroups", Value: 24, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WorkgroupSize", Value: 25, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WorkgroupId", Value: 26, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LocalInvocationId", Value: 27, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GlobalInvocationId", Value: 28, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LocalInvocationIndex", Value: 29, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WorkDim", Value: 30, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GlobalSize", Value: 31, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "EnqueuedWorkgroupSize", Value: 32, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GlobalOffset", Value: 33, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GlobalLinearId", Value: 34, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupSize", Value: 36, Capabilities: []string{"Kernel","GroupNonUniform","SubgroupBallotKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupMaxSize", Value: 37, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NumSubgroups", Value: 38, Capabilities: []string{"Kernel","GroupNonUniform",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "NumEnqueuedSubgroups", Value: 39, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupId", Value: 40, Capabilities: []string{"Kernel","GroupNonUniform",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupLocalInvocationId", Value: 41, Capabilities: []string{"Kernel","GroupNonUniform","SubgroupBallotKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "VertexIndex", Value: 42, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InstanceIndex", Value: 43, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", + }, + Enumerant{ + Enumerant: "CoreIDARM", + Value: 4160, + Capabilities: []string{"CoreBuiltinsARM",}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "CoreCountARM", + Value: 4161, + Capabilities: []string{"CoreBuiltinsARM",}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "CoreMaxIDARM", + Value: 4162, + Capabilities: []string{"CoreBuiltinsARM",}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "WarpIDARM", + Value: 4163, + Capabilities: []string{"CoreBuiltinsARM",}, + Parameters: []Parameter{}, + Version: "1.0", + }, + Enumerant{ + Enumerant: "WarpMaxIDARM", + Value: 4164, + Capabilities: []string{"CoreBuiltinsARM",}, + Parameters: []Parameter{}, + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupEqMask", @@ -22784,41 +31091,6 @@ var ( Parameters: []Parameter{}, Version: "1.3", }, - Enumerant{ - Enumerant: "SubgroupEqMaskKHR", - Value: 4416, - Capabilities: []string{"SubgroupBallotKHR","GroupNonUniformBallot",}, - Parameters: []Parameter{}, - Version: "1.3", - }, - Enumerant{ - Enumerant: "SubgroupGeMaskKHR", - Value: 4417, - Capabilities: []string{"SubgroupBallotKHR","GroupNonUniformBallot",}, - Parameters: []Parameter{}, - Version: "1.3", - }, - Enumerant{ - Enumerant: "SubgroupGtMaskKHR", - Value: 4418, - Capabilities: []string{"SubgroupBallotKHR","GroupNonUniformBallot",}, - Parameters: []Parameter{}, - Version: "1.3", - }, - Enumerant{ - Enumerant: "SubgroupLeMaskKHR", - Value: 4419, - Capabilities: []string{"SubgroupBallotKHR","GroupNonUniformBallot",}, - Parameters: []Parameter{}, - Version: "1.3", - }, - Enumerant{ - Enumerant: "SubgroupLtMaskKHR", - Value: 4420, - Capabilities: []string{"SubgroupBallotKHR","GroupNonUniformBallot",}, - Parameters: []Parameter{}, - Version: "1.3", - }, Enumerant{ Enumerant: "BaseVertex", Value: 4424, @@ -22836,10 +31108,17 @@ var ( Enumerant{ Enumerant: "DrawIndex", Value: 4426, - Capabilities: []string{"DrawParameters","MeshShadingNV",}, + Capabilities: []string{"DrawParameters","MeshShadingNV","MeshShadingEXT",}, Parameters: []Parameter{}, Version: "1.3", }, + Enumerant{ + Enumerant: "PrimitiveShadingRateKHR", + Value: 4432, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "DeviceIndex", Value: 4438, @@ -22854,6 +31133,13 @@ var ( Parameters: []Parameter{}, Version: "1.3", }, + Enumerant{ + Enumerant: "ShadingRateKHR", + Value: 4444, + Capabilities: []string{"FragmentShadingRateKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "BaryCoordNoPerspAMD", Value: 4992, @@ -22910,6 +31196,20 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "RemainingRecursionLevelsAMDX", + Value: 5021, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ShaderIndexAMDX", + Value: 5073, + Capabilities: []string{"ShaderEnqueueAMDX",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "ViewportMaskNV", Value: 5253, @@ -23009,247 +31309,191 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "BaryCoordNV", + Enumerant: "BaryCoordKHR", Value: 5286, - Capabilities: []string{"FragmentBarycentricNV",}, + Capabilities: []string{"FragmentBarycentricKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "BaryCoordNoPerspNV", + Enumerant: "BaryCoordNoPerspKHR", Value: 5287, - Capabilities: []string{"FragmentBarycentricNV",}, + Capabilities: []string{"FragmentBarycentricKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "FragSizeEXT", Value: 5292, - Capabilities: []string{"FragmentDensityEXT","ShadingRateNV",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "FragmentSizeNV", - Value: 5292, - Capabilities: []string{"ShadingRateNV","FragmentDensityEXT",}, + Capabilities: []string{"FragmentDensityEXT",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "FragInvocationCountEXT", Value: 5293, - Capabilities: []string{"FragmentDensityEXT","ShadingRateNV",}, + Capabilities: []string{"FragmentDensityEXT",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "InvocationsPerPixelNV", - Value: 5293, - Capabilities: []string{"ShadingRateNV","FragmentDensityEXT",}, + Enumerant: "PrimitivePointIndicesEXT", + Value: 5294, + Capabilities: []string{"MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "LaunchIdNV", - Value: 5319, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Enumerant: "PrimitiveLineIndicesEXT", + Value: 5295, + Capabilities: []string{"MeshShadingEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "PrimitiveTriangleIndicesEXT", + Value: 5296, + Capabilities: []string{"MeshShadingEXT",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CullPrimitiveEXT", + Value: 5299, + Capabilities: []string{"MeshShadingEXT",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "LaunchIdKHR", Value: 5319, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "LaunchSizeNV", - Value: 5320, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "LaunchSizeKHR", Value: 5320, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "WorldRayOriginNV", - Value: 5321, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "WorldRayOriginKHR", Value: 5321, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "WorldRayDirectionNV", - Value: 5322, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "WorldRayDirectionKHR", Value: 5322, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "ObjectRayOriginNV", - Value: 5323, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "ObjectRayOriginKHR", Value: 5323, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "ObjectRayDirectionNV", - Value: 5324, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "ObjectRayDirectionKHR", Value: 5324, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "RayTminNV", - Value: 5325, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "RayTminKHR", Value: 5325, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "RayTmaxNV", - Value: 5326, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "RayTmaxKHR", Value: 5326, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "InstanceCustomIndexNV", - Value: 5327, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "InstanceCustomIndexKHR", Value: 5327, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "ObjectToWorldNV", - Value: 5330, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "ObjectToWorldKHR", Value: 5330, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "WorldToObjectNV", - Value: 5331, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "WorldToObjectKHR", Value: 5331, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "HitTNV", Value: 5332, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "HitTKHR", - Value: 5332, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "HitKindNV", - Value: 5333, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "HitKindKHR", Value: 5333, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "IncomingRayFlagsNV", - Value: 5351, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Enumerant: "CurrentRayTimeNV", + Value: 5334, + Capabilities: []string{"RayTracingMotionBlurNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HitTriangleVertexPositionsKHR", + Value: 5335, + Capabilities: []string{"RayTracingPositionFetchKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HitMicroTriangleVertexPositionsNV", + Value: 5337, + Capabilities: []string{"RayTracingDisplacementMicromapNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HitMicroTriangleVertexBarycentricsNV", + Value: 5344, + Capabilities: []string{"RayTracingDisplacementMicromapNV",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "IncomingRayFlagsKHR", Value: 5351, - Capabilities: []string{"RayTracingNV","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingNV","RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ Enumerant: "RayGeometryIndexKHR", Value: 5352, - Capabilities: []string{"RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingKHR",}, Parameters: []Parameter{}, Version: "None", }, @@ -23281,6 +31525,27 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "HitKindFrontFacingMicroTriangleNV", + Value: 5405, + Capabilities: []string{"RayTracingDisplacementMicromapNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "HitKindBackFacingMicroTriangleNV", + Value: 5406, + Capabilities: []string{"RayTracingDisplacementMicromapNV",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CullMaskKHR", + Value: 6021, + Capabilities: []string{"RayCullMaskKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -23293,35 +31558,35 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Device", Value: 1, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Workgroup", Value: 2, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Subgroup", Value: 3, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Invocation", Value: 4, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "QueueFamily", @@ -23330,19 +31595,12 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "QueueFamilyKHR", - Value: 5, - Capabilities: []string{"VulkanMemoryModel",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "ShaderCallKHR", Value: 6, - Capabilities: []string{"RayTracingProvisionalKHR",}, + Capabilities: []string{"RayTracingKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, }, Bases: []*OperandKind {}, @@ -23356,21 +31614,21 @@ var ( Value: 0, Capabilities: []string{"Kernel","GroupNonUniformArithmetic","GroupNonUniformBallot",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InclusiveScan", Value: 1, Capabilities: []string{"Kernel","GroupNonUniformArithmetic","GroupNonUniformBallot",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ExclusiveScan", Value: 2, Capabilities: []string{"Kernel","GroupNonUniformArithmetic","GroupNonUniformBallot",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ClusteredReduce", @@ -23412,21 +31670,21 @@ var ( Value: 0, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WaitKernel", Value: 1, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "WaitWorkGroup", Value: 2, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, }, Bases: []*OperandKind {}, @@ -23440,392 +31698,392 @@ var ( Value: 0, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Shader", Value: 1, Capabilities: []string{"Matrix",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Geometry", Value: 2, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Tessellation", Value: 3, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Addresses", Value: 4, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Linkage", Value: 5, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Kernel", Value: 6, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Vector16", Value: 7, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Float16Buffer", Value: 8, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Float16", Value: 9, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Float64", Value: 10, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Int64", Value: 11, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Int64Atomics", Value: 12, Capabilities: []string{"Int64",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageBasic", Value: 13, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageReadWrite", Value: 14, Capabilities: []string{"ImageBasic",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageMipmap", Value: 15, Capabilities: []string{"ImageBasic",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Pipes", Value: 17, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Groups", Value: 18, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DeviceEnqueue", Value: 19, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "LiteralSampler", Value: 20, Capabilities: []string{"Kernel",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "AtomicStorage", Value: 21, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Int16", Value: 22, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TessellationPointSize", Value: 23, Capabilities: []string{"Tessellation",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GeometryPointSize", Value: 24, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageGatherExtended", Value: 25, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageImageMultisample", Value: 27, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "UniformBufferArrayDynamicIndexing", Value: 28, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampledImageArrayDynamicIndexing", Value: 29, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageBufferArrayDynamicIndexing", Value: 30, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageImageArrayDynamicIndexing", Value: 31, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ClipDistance", Value: 32, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "CullDistance", Value: 33, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageCubeArray", Value: 34, Capabilities: []string{"SampledCubeArray",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampleRateShading", Value: 35, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageRect", Value: 36, Capabilities: []string{"SampledRect",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampledRect", Value: 37, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GenericPointer", Value: 38, Capabilities: []string{"Addresses",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Int8", Value: 39, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InputAttachment", Value: 40, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SparseResidency", Value: 41, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MinLod", Value: 42, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Sampled1D", Value: 43, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "Image1D", Value: 44, Capabilities: []string{"Sampled1D",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampledCubeArray", Value: 45, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SampledBuffer", Value: 46, Capabilities: []string{}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageBuffer", Value: 47, Capabilities: []string{"SampledBuffer",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageMSArray", Value: 48, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageImageExtendedFormats", Value: 49, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "ImageQuery", Value: 50, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "DerivativeControl", Value: 51, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "InterpolationFunction", Value: 52, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "TransformFeedback", Value: 53, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "GeometryStreams", Value: 54, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageImageReadWithoutFormat", Value: 55, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "StorageImageWriteWithoutFormat", Value: 56, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "MultiViewport", Value: 57, Capabilities: []string{"Geometry",}, Parameters: []Parameter{}, - Version: "", + Version: "1.0", }, Enumerant{ Enumerant: "SubgroupDispatch", @@ -23918,6 +32176,55 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, + Enumerant{ + Enumerant: "UniformDecoration", + Value: 71, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "CoreBuiltinsARM", + Value: 4165, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TileImageColorReadAccessEXT", + Value: 4166, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TileImageDepthReadAccessEXT", + Value: 4167, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TileImageStencilReadAccessEXT", + Value: 4168, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixLayoutsARM", + Value: 4201, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FragmentShadingRateKHR", + Value: 4422, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "SubgroupBallotKHR", Value: 4423, @@ -23932,6 +32239,27 @@ var ( Parameters: []Parameter{}, Version: "1.3", }, + Enumerant{ + Enumerant: "WorkgroupMemoryExplicitLayoutKHR", + Value: 4428, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "WorkgroupMemoryExplicitLayout8BitAccessKHR", + Value: 4429, + Capabilities: []string{"WorkgroupMemoryExplicitLayoutKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "WorkgroupMemoryExplicitLayout16BitAccessKHR", + Value: 4430, + Capabilities: []string{"WorkgroupMemoryExplicitLayoutKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "SubgroupVoteKHR", Value: 4431, @@ -23946,24 +32274,10 @@ var ( Parameters: []Parameter{}, Version: "1.3", }, - Enumerant{ - Enumerant: "StorageUniformBufferBlock16", - Value: 4433, - Capabilities: []string{}, - Parameters: []Parameter{}, - Version: "1.3", - }, Enumerant{ Enumerant: "UniformAndStorageBuffer16BitAccess", Value: 4434, - Capabilities: []string{"StorageBuffer16BitAccess","StorageUniformBufferBlock16",}, - Parameters: []Parameter{}, - Version: "1.3", - }, - Enumerant{ - Enumerant: "StorageUniform16", - Value: 4434, - Capabilities: []string{"StorageBuffer16BitAccess","StorageUniformBufferBlock16",}, + Capabilities: []string{"StorageBuffer16BitAccess",}, Parameters: []Parameter{}, Version: "1.3", }, @@ -24087,9 +32401,58 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "RayTraversalPrimitiveCullingProvisionalKHR", + Enumerant: "RayQueryKHR", + Value: 4472, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "UntypedPointersKHR", + Value: 4473, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RayTraversalPrimitiveCullingKHR", Value: 4478, - Capabilities: []string{"RayQueryProvisionalKHR","RayTracingProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RayTracingKHR", + Value: 4479, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TextureSampleWeightedQCOM", + Value: 4484, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TextureBoxFilterQCOM", + Value: 4485, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TextureBlockMatchQCOM", + Value: 4486, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TextureBlockMatch2QCOM", + Value: 4498, + Capabilities: []string{}, Parameters: []Parameter{}, Version: "None", }, @@ -24128,13 +32491,34 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "Int64ImageEXT", + Value: 5016, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "ShaderClockKHR", Value: 5055, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ShaderEnqueueAMDX", + Value: 5067, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "QuadControlKHR", + Value: 5087, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "SampleMaskOverrideCoverageNV", Value: 5249, @@ -24156,17 +32540,10 @@ var ( Parameters: []Parameter{}, Version: "None", }, - Enumerant{ - Enumerant: "ShaderViewportIndexLayerNV", - Value: 5254, - Capabilities: []string{"MultiViewport",}, - Parameters: []Parameter{}, - Version: "None", - }, Enumerant{ Enumerant: "ShaderViewportMaskNV", Value: 5255, - Capabilities: []string{"ShaderViewportIndexLayerNV",}, + Capabilities: []string{"ShaderViewportIndexLayerEXT",}, Parameters: []Parameter{}, Version: "None", }, @@ -24206,28 +32583,28 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "FragmentBarycentricNV", + Enumerant: "MeshShadingEXT", + Value: 5283, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FragmentBarycentricKHR", Value: 5284, Capabilities: []string{}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "ComputeDerivativeGroupQuadsNV", + Enumerant: "ComputeDerivativeGroupQuadsKHR", Value: 5288, - Capabilities: []string{}, - Parameters: []Parameter{}, - Version: "None", - }, - Enumerant{ - Enumerant: "FragmentDensityEXT", - Value: 5291, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, Version: "None", }, Enumerant{ - Enumerant: "ShadingRateNV", + Enumerant: "FragmentDensityEXT", Value: 5291, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, @@ -24247,13 +32624,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "ShaderNonUniformEXT", - Value: 5301, - Capabilities: []string{"Shader",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "RuntimeDescriptorArray", Value: 5302, @@ -24261,13 +32631,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "RuntimeDescriptorArrayEXT", - Value: 5302, - Capabilities: []string{"Shader",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "InputAttachmentArrayDynamicIndexing", Value: 5303, @@ -24275,13 +32638,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "InputAttachmentArrayDynamicIndexingEXT", - Value: 5303, - Capabilities: []string{"InputAttachment",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "UniformTexelBufferArrayDynamicIndexing", Value: 5304, @@ -24289,13 +32645,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "UniformTexelBufferArrayDynamicIndexingEXT", - Value: 5304, - Capabilities: []string{"SampledBuffer",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "StorageTexelBufferArrayDynamicIndexing", Value: 5305, @@ -24303,13 +32652,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "StorageTexelBufferArrayDynamicIndexingEXT", - Value: 5305, - Capabilities: []string{"ImageBuffer",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "UniformBufferArrayNonUniformIndexing", Value: 5306, @@ -24317,13 +32659,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "UniformBufferArrayNonUniformIndexingEXT", - Value: 5306, - Capabilities: []string{"ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "SampledImageArrayNonUniformIndexing", Value: 5307, @@ -24331,13 +32666,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "SampledImageArrayNonUniformIndexingEXT", - Value: 5307, - Capabilities: []string{"ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "StorageBufferArrayNonUniformIndexing", Value: 5308, @@ -24345,13 +32673,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "StorageBufferArrayNonUniformIndexingEXT", - Value: 5308, - Capabilities: []string{"ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "StorageImageArrayNonUniformIndexing", Value: 5309, @@ -24359,13 +32680,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "StorageImageArrayNonUniformIndexingEXT", - Value: 5309, - Capabilities: []string{"ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "InputAttachmentArrayNonUniformIndexing", Value: 5310, @@ -24373,13 +32687,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "InputAttachmentArrayNonUniformIndexingEXT", - Value: 5310, - Capabilities: []string{"InputAttachment","ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "UniformTexelBufferArrayNonUniformIndexing", Value: 5311, @@ -24387,13 +32694,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "UniformTexelBufferArrayNonUniformIndexingEXT", - Value: 5311, - Capabilities: []string{"SampledBuffer","ShaderNonUniform",}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "StorageTexelBufferArrayNonUniformIndexing", Value: 5312, @@ -24402,11 +32702,11 @@ var ( Version: "1.5", }, Enumerant{ - Enumerant: "StorageTexelBufferArrayNonUniformIndexingEXT", - Value: 5312, - Capabilities: []string{"ImageBuffer","ShaderNonUniform",}, + Enumerant: "RayTracingPositionFetchKHR", + Value: 5336, + Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "1.5", + Version: "None", }, Enumerant{ Enumerant: "RayTracingNV", @@ -24416,14 +32716,14 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "VulkanMemoryModel", - Value: 5345, - Capabilities: []string{}, + Enumerant: "RayTracingMotionBlurNV", + Value: 5341, + Capabilities: []string{"Shader",}, Parameters: []Parameter{}, - Version: "1.5", + Version: "None", }, Enumerant{ - Enumerant: "VulkanMemoryModelKHR", + Enumerant: "VulkanMemoryModel", Value: 5345, Capabilities: []string{}, Parameters: []Parameter{}, @@ -24436,13 +32736,6 @@ var ( Parameters: []Parameter{}, Version: "1.5", }, - Enumerant{ - Enumerant: "VulkanMemoryModelDeviceScopeKHR", - Value: 5346, - Capabilities: []string{}, - Parameters: []Parameter{}, - Version: "1.5", - }, Enumerant{ Enumerant: "PhysicalStorageBufferAddresses", Value: 5347, @@ -24451,16 +32744,9 @@ var ( Version: "1.5", }, Enumerant{ - Enumerant: "PhysicalStorageBufferAddressesEXT", - Value: 5347, - Capabilities: []string{"Shader",}, - Parameters: []Parameter{}, - Version: "1.5", - }, - Enumerant{ - Enumerant: "ComputeDerivativeGroupLinearNV", + Enumerant: "ComputeDerivativeGroupLinearKHR", Value: 5350, - Capabilities: []string{}, + Capabilities: []string{"Shader",}, Parameters: []Parameter{}, Version: "None", }, @@ -24507,10 +32793,108 @@ var ( Version: "None", }, Enumerant{ - Enumerant: "DemoteToHelperInvocationEXT", + Enumerant: "DemoteToHelperInvocation", Value: 5379, Capabilities: []string{"Shader",}, Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "DisplacementMicromapNV", + Value: 5380, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RayTracingOpacityMicromapEXT", + Value: 5381, + Capabilities: []string{"RayQueryKHR","RayTracingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ShaderInvocationReorderNV", + Value: 5383, + Capabilities: []string{"RayTracingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BindlessTextureNV", + Value: 5390, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RayQueryPositionFetchKHR", + Value: 5391, + Capabilities: []string{"Shader",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat16VectorNV", + Value: 5404, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RayTracingDisplacementMicromapNV", + Value: 5409, + Capabilities: []string{"RayTracingKHR",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RawAccessChainsNV", + Value: 5414, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixReductionsNV", + Value: 5430, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixConversionsNV", + Value: 5431, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixPerElementOperationsNV", + Value: 5432, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixTensorAddressingNV", + Value: 5433, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixBlockLoadsNV", + Value: 5434, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TensorAddressingNV", + Value: 5439, + Capabilities: []string{}, + Parameters: []Parameter{}, Version: "None", }, Enumerant{ @@ -24541,6 +32925,20 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "RoundToInfinityINTEL", + Value: 5582, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FloatingPointModeINTEL", + Value: 5583, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "IntegerFunctions2INTEL", Value: 5584, @@ -24548,6 +32946,69 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "FunctionPointersINTEL", + Value: 5603, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "IndirectReferencesINTEL", + Value: 5604, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AsmINTEL", + Value: 5606, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat32MinMaxEXT", + Value: 5612, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat64MinMaxEXT", + Value: 5613, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat16MinMaxEXT", + Value: 5616, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "VectorComputeINTEL", + Value: 5617, + Capabilities: []string{"VectorAnyINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "VectorAnyINTEL", + Value: 5619, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ExpectAssumeKHR", + Value: 5629, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, Enumerant{ Enumerant: "SubgroupAvcMotionEstimationINTEL", Value: 5696, @@ -24569,6 +33030,384 @@ var ( Parameters: []Parameter{}, Version: "None", }, + Enumerant{ + Enumerant: "VariableLengthArrayINTEL", + Value: 5817, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FunctionFloatControlINTEL", + Value: 5821, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAMemoryAttributesINTEL", + Value: 5824, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPFastMathModeINTEL", + Value: 5837, + Capabilities: []string{"Kernel",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ArbitraryPrecisionIntegersINTEL", + Value: 5844, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ArbitraryPrecisionFloatingPointINTEL", + Value: 5845, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "UnstructuredLoopControlsINTEL", + Value: 5886, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGALoopControlsINTEL", + Value: 5888, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "KernelAttributesINTEL", + Value: 5892, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAKernelAttributesINTEL", + Value: 5897, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAMemoryAccessesINTEL", + Value: 5898, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAClusterAttributesINTEL", + Value: 5904, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "LoopFuseINTEL", + Value: 5906, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGADSPControlINTEL", + Value: 5908, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MemoryAccessAliasingINTEL", + Value: 5910, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAInvocationPipeliningAttributesINTEL", + Value: 5916, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGABufferLocationINTEL", + Value: 5920, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ArbitraryPrecisionFixedPointINTEL", + Value: 5922, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "USMStorageClassesINTEL", + Value: 5935, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RuntimeAlignedAttributeINTEL", + Value: 5939, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "IOPipesINTEL", + Value: 5943, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BlockingPipesINTEL", + Value: 5945, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGARegINTEL", + Value: 5948, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "DotProductInputAll", + Value: 6016, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "DotProductInput4x8Bit", + Value: 6017, + Capabilities: []string{"Int8",}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "DotProductInput4x8BitPacked", + Value: 6018, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "DotProduct", + Value: 6019, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + Enumerant{ + Enumerant: "RayCullMaskKHR", + Value: 6020, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CooperativeMatrixKHR", + Value: 6022, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ReplicatedCompositesEXT", + Value: 6024, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BitInstructions", + Value: 6025, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "GroupNonUniformRotateKHR", + Value: 6026, + Capabilities: []string{"GroupNonUniform",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FloatControls2", + Value: 6029, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat32AddEXT", + Value: 6033, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat64AddEXT", + Value: 6034, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "LongCompositesINTEL", + Value: 6089, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "OptNoneEXT", + Value: 6094, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "AtomicFloat16AddEXT", + Value: 6095, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "DebugInfoModuleINTEL", + Value: 6114, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "BFloat16ConversionINTEL", + Value: 6115, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SplitBarrierINTEL", + Value: 6141, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ArithmeticFenceEXT", + Value: 6144, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAClusterAttributesV2INTEL", + Value: 6150, + Capabilities: []string{"FPGAClusterAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAKernelAttributesv2INTEL", + Value: 6161, + Capabilities: []string{"FPGAKernelAttributesINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPMaxErrorINTEL", + Value: 6169, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGALatencyControlINTEL", + Value: 6171, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "FPGAArgumentInterfacesINTEL", + Value: 6174, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "GlobalVariableHostAccessINTEL", + Value: 6187, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "GlobalVariableFPGADecorationsINTEL", + Value: 6189, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SubgroupBufferPrefetchINTEL", + Value: 6220, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "GroupUniformArithmeticKHR", + Value: 6400, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MaskedGatherScatterINTEL", + Value: 6427, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CacheControlsINTEL", + Value: 6441, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RegisterLimitsINTEL", + Value: 6460, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, }, Bases: []*OperandKind {}, } @@ -24579,16 +33418,16 @@ var ( Enumerant{ Enumerant: "RayQueryCandidateIntersectionKHR", Value: 0, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "RayQueryCommittedIntersectionKHR", Value: 1, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, }, Bases: []*OperandKind {}, @@ -24600,23 +33439,23 @@ var ( Enumerant{ Enumerant: "RayQueryCommittedIntersectionNoneKHR", Value: 0, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "RayQueryCommittedIntersectionTriangleKHR", Value: 1, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "RayQueryCommittedIntersectionGeneratedKHR", Value: 2, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, }, Bases: []*OperandKind {}, @@ -24628,20 +33467,363 @@ var ( Enumerant{ Enumerant: "RayQueryCandidateIntersectionTriangleKHR", Value: 0, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, Enumerant{ Enumerant: "RayQueryCandidateIntersectionAABBKHR", Value: 1, - Capabilities: []string{"RayQueryProvisionalKHR",}, + Capabilities: []string{"RayQueryKHR",}, Parameters: []Parameter{}, - Version: "", + Version: "None", }, }, Bases: []*OperandKind {}, } + OperandKindPackedVectorFormat = &OperandKind { + Kind: "PackedVectorFormat", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "PackedVectorFormat4x8Bit", + Value: 0, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "1.6", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindCooperativeMatrixOperands = &OperandKind { + Kind: "CooperativeMatrixOperands", + Category: "BitEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "NoneKHR", + Value: 0x0000, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixASignedComponentsKHR", + Value: 0x0001, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixBSignedComponentsKHR", + Value: 0x0002, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixCSignedComponentsKHR", + Value: 0x0004, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixResultSignedComponentsKHR", + Value: 0x0008, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "SaturatingAccumulationKHR", + Value: 0x0010, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindCooperativeMatrixLayout = &OperandKind { + Kind: "CooperativeMatrixLayout", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "RowMajorKHR", + Value: 0, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ColumnMajorKHR", + Value: 1, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RowBlockedInterleavedARM", + Value: 4202, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ColumnBlockedInterleavedARM", + Value: 4203, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindCooperativeMatrixUse = &OperandKind { + Kind: "CooperativeMatrixUse", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "MatrixAKHR", + Value: 0, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixBKHR", + Value: 1, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "MatrixAccumulatorKHR", + Value: 2, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindCooperativeMatrixReduce = &OperandKind { + Kind: "CooperativeMatrixReduce", + Category: "BitEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "Row", + Value: 0x0001, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Column", + Value: 0x0002, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "2x2", + Value: 0x0004, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindTensorClampMode = &OperandKind { + Kind: "TensorClampMode", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "Undefined", + Value: 0, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Constant", + Value: 1, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ClampToEdge", + Value: 2, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "Repeat", + Value: 3, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "RepeatMirrored", + Value: 4, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindTensorAddressingOperands = &OperandKind { + Kind: "TensorAddressingOperands", + Category: "BitEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "None", + Value: 0x0000, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "TensorView", + Value: 0x0001, + Capabilities: []string{"CooperativeMatrixTensorAddressingNV",}, + Parameters: []Parameter{{OperandKindIdRef, ""},}, + Version: "None", + }, + Enumerant{ + Enumerant: "DecodeFunc", + Value: 0x0002, + Capabilities: []string{"CooperativeMatrixBlockLoadsNV",}, + Parameters: []Parameter{{OperandKindIdRef, ""},}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindInitializationModeQualifier = &OperandKind { + Kind: "InitializationModeQualifier", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "InitOnDeviceReprogramINTEL", + Value: 0, + Capabilities: []string{"GlobalVariableFPGADecorationsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "InitOnDeviceResetINTEL", + Value: 1, + Capabilities: []string{"GlobalVariableFPGADecorationsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindLoadCacheControl = &OperandKind { + Kind: "LoadCacheControl", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "UncachedINTEL", + Value: 0, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "CachedINTEL", + Value: 1, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StreamingINTEL", + Value: 2, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "InvalidateAfterReadINTEL", + Value: 3, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "ConstCachedINTEL", + Value: 4, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindStoreCacheControl = &OperandKind { + Kind: "StoreCacheControl", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "UncachedINTEL", + Value: 0, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "WriteThroughINTEL", + Value: 1, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "WriteBackINTEL", + Value: 2, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + Enumerant{ + Enumerant: "StreamingINTEL", + Value: 3, + Capabilities: []string{"CacheControlsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindNamedMaximumNumberOfRegisters = &OperandKind { + Kind: "NamedMaximumNumberOfRegisters", + Category: "ValueEnum", + Enumerants: []Enumerant { + Enumerant{ + Enumerant: "AutoINTEL", + Value: 0, + Capabilities: []string{"RegisterLimitsINTEL",}, + Parameters: []Parameter{}, + Version: "None", + }, + }, + Bases: []*OperandKind {}, + } + OperandKindFPEncoding = &OperandKind { + Kind: "FPEncoding", + Category: "ValueEnum", + Enumerants: []Enumerant { + }, + Bases: []*OperandKind {}, + } OperandKindIdResultType = &OperandKind { Kind: "IdResultType", Category: "Id", @@ -24691,6 +33873,13 @@ var ( }, Bases: []*OperandKind {}, } + OperandKindLiteralFloat = &OperandKind { + Kind: "LiteralFloat", + Category: "Literal", + Enumerants: []Enumerant { + }, + Bases: []*OperandKind {}, + } OperandKindLiteralContextDependentNumber = &OperandKind { Kind: "LiteralContextDependentNumber", Category: "Literal", @@ -24737,6 +33926,13 @@ var ( Kind: "DebugInfoFlags", Category: "BitEnum", Enumerants: []Enumerant { + Enumerant{ + Enumerant: "None", + Value: 0x0000, + Capabilities: []string{}, + Parameters: []Parameter{}, + Version: "", + }, Enumerant{ Enumerant: "FlagIsProtected", Value: 0x01,