Commit Graph

1329 Commits

Author SHA1 Message Date
Chip Davis
03ad13bae6 MSL: Simplify spvSubgroupBallot().
A bitcast to `uint2` will do just fine. I honestly don't know why I
didn't do it this way earlier.
2021-07-21 00:25:09 -05:00
Hans-Kristian Arntzen
18f3cd6810 GLSL: Ensure ray query object decls are flushed if allocated in Function.
glslang always emits Private variables, but DXC not so much.
2021-07-20 12:04:00 +02:00
Hans-Kristian Arntzen
5b227cc57c GLSL: Implement GL_EXT_ray_query. 2021-07-19 14:01:21 +02:00
Bill Hollings
ebb5098def MSL: Adjust gl_SampleMaskIn for sample-shading and/or fixed sample mask.
Vulkan specifies that the Sample Mask Test occurs before fragment shading.
This means gl_SampleMaskIn should be influenced by both sample-shading and
VkPipelineMultisampleStateCreateInfo::pSampleMask.

CTS tests dEQP-VK.pipeline.multisample_shader_builtin.* bear this out.

For sample-shading, gl_SampleMaskIn should only have a single bit set,
Since Metal does not filter for this, apply a bitmask based on gl_SampleID.

For a fixed sample mask, since Metal is unaware of
VkPipelineMultisampleStateCreateInfo::pSampleMask, we need to ensure that
we apply it to both gl_SampleMaskIn and gl_SampleMask. This has the side
effect of a redundant application of pSampleMask if the shader already
includes gl_SampleMaskIn when setting gl_SampleMask, but I don't see an
easy way around this.

Also, simplify the logic for including the fixed sample mask in gl_ShaderMask,
and print the fixed sample mask as a hex value for readability of bits.
2021-07-13 21:22:13 -04:00
Hans-Kristian Arntzen
71b83a18f4 MSL: Add test for scalar access chain pull interpolant. 2021-07-13 12:25:18 +02:00
Hans-Kristian Arntzen
206ee8f171 GLSL: Support pervertexNV in NV barycentric extension. 2021-06-30 16:27:46 +02:00
Hans-Kristian Arntzen
d6b29ab017 HLSL: Rewrite how block IO is emitted.
Emit block members directly in the IO structs and sort them.
Ensures we can get some kind of stable order between stages.

To complete the story, we'll need to be able to inject unused inputs /
builtins, or eliminate unused outputs (probably easiest solution).
2021-06-28 15:04:49 +02:00
Hans-Kristian Arntzen
8216e87f02 Handle SPIR-V 1.4 selection constructs.
Fix bug in to_trivial_mix_op, where we made a pre-1.4 assumption that
component count of selector is equal to value component count.
2021-06-28 12:23:44 +02:00
Hans-Kristian Arntzen
2e1b5fb39e
Merge pull request #1686 from KhronosGroup/fix-1684
GLSL: Support control flow hints
2021-06-03 14:13:18 +02:00
Hans-Kristian Arntzen
449f68ef3b Ensure loop control flow hints only appear above loops. 2021-06-03 12:19:10 +02:00
Hans-Kristian Arntzen
d62b3c2b92 GLSL: Implement control flow hints. 2021-06-03 12:01:49 +02:00
Hans-Kristian Arntzen
165dbff228 Handle odd type for textureGather component. 2021-06-03 11:37:45 +02:00
xndcn
02fb8f2a24 Add comment after inf/nan float number for clarifying. 2021-05-27 02:40:41 +08:00
Hans-Kristian Arntzen
bf3793dd35 MSL: Improve handling of split tessellation access chains. 2021-05-21 16:32:03 +02:00
Hans-Kristian Arntzen
a6c9514856
Merge pull request #1676 from KhronosGroup/fix-1671
GLSL: Implement noncoherent framebuffer fetch.
2021-05-21 15:43:58 +02:00
Hans-Kristian Arntzen
26a4986009 GLSL: Implement noncoherent framebuffer fetch. 2021-05-21 14:22:57 +02:00
Hans-Kristian Arntzen
99ae0d32e9 MSL: Handle array with component when we cannot rely on user() attrib.
In these cases, we emit one variable per location, and so we must
flatten stuff.
2021-05-21 13:46:33 +02:00
Hans-Kristian Arntzen
b8115ffbe0 HLSL: Implement invariant as precise.
Only option we have.
2021-05-07 13:15:55 +02:00
Hans-Kristian Arntzen
e47a30e807 Honor NoContraction qualifier.
We'll need to force a temporary and mark it as precise.
MSL is a little weird here, but we can piggyback on top of the invariant
float math option here to force fma() operations everywhere.
2021-05-07 12:59:47 +02:00
Hans-Kristian Arntzen
6dbab0df47 Update reference output. 2021-05-07 11:12:22 +02:00
Lukas Taparauskas
72a2ec4c1b
MSL: Fix '--msl-multi-patch-workgroup' out of bounds reads when dispatching more threads than control points (#1662)
* Fix '--msl-multi-patch-workgroup' cases where thread count exceeds data bounds

*Fix gl_PrimitiveID off by one error when computing last valid index
*Point gl_out to the last patch's data when threads exceed input data bounds
*Point patchOut to the last patch's data when threads exceed input data bounds

* Update MSL test expectations.

* Undo change to MSL multi-patch hull output bound checks

* Update MSL multi-patch test expectations.
2021-04-29 20:01:26 +02:00
Hans-Kristian Arntzen
c624d5387c
Merge pull request #1660 from KhronosGroup/fix-1658
MSL: Use proper array for quad tess levels.
2021-04-23 15:21:00 +02:00
Hans-Kristian Arntzen
82a77e534e MSL: Use proper array for quad tess levels.
We need to handle loads from array as well, so the float4 hack doesn't
work.
2021-04-23 14:12:00 +02:00
Hans-Kristian Arntzen
0e963c62b6 HLSL: Support Shuffle wave ops.
WaveReadLaneAt is no longer restricted to dynamically uniform index,
so can implement the other shuffle ops.
2021-04-23 13:03:35 +02:00
Hans-Kristian Arntzen
532f65583e Rewrite how non-uniform qualifiers are handled.
Remove all shenanigans with propagation, and only consume nonuniform
qualifiers exactly where needed (last minute).
2021-04-22 16:03:08 +02:00
Hans-Kristian Arntzen
d137abeef5
Merge pull request #1655 from KhronosGroup/fix-1640
GLSL: Support shading rate builtins.
2021-04-20 16:35:02 +02:00
Hans-Kristian Arntzen
8e24e0b224
Merge pull request #1654 from KhronosGroup/fix-1641
GLSL: Implement gl_FragFullyCoveredNV.
2021-04-20 16:34:53 +02:00
Hans-Kristian Arntzen
71eb1754e3
Merge pull request #1653 from KhronosGroup/fix-1638
GLSL: Support GL_EXT_shader_image_load_formatted.
2021-04-20 16:34:44 +02:00
Hans-Kristian Arntzen
c89b5a1a3f GLSL: Support shading rate builtins. 2021-04-20 13:58:07 +02:00
Hans-Kristian Arntzen
3fd148450a GLSL: Implement gl_FragFullyCoveredNV. 2021-04-20 13:44:52 +02:00
Hans-Kristian Arntzen
f93a8fb1fe GLSL: Support GL_EXT_shader_image_load_formatted. 2021-04-20 13:36:51 +02:00
Hans-Kristian Arntzen
96ba044f01 HLSL: Fix automatic location assignment in block IO. 2021-04-20 13:04:26 +02:00
Hans-Kristian Arntzen
ae9ca7d73c MSL: Fix copy of arrays to/from stage IO variables.
Need to take into account effective storage classes and whether or not
we target stage IO blocks since native arrays are conditionally enabled.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
986196030d MSL: Don't use native arrays for tess level inputs. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
4a379a00f3 MSL: Don't emit native array for masked clip/cull distance. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
682a227f4b MSL: Make builtin argument type declaration context sensitive.
Sometimes we'll need array template, sometimes not 🤷.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
c1edd35d57 MSL: Use spvUnsafeArray for builtin arrays after all.
It will get too messy to deal with constant initializers any other way,
so just deal with complexity in argument_decl instead ...
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
7b9a591aa7 MSL: Hoist out to_tesc_invocation_id() in more places.
When emitting fixup code, we might not have gl_InvocationID yet.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
75ed73818c MSL: Handle loading Clip/CullDistance in TESE.
Need to allow the flattened space to go through in some edge cases where
we cannot reasonably unflatten.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
a159334895 MSL: Correctly analyze if builtin block is active.
Need to consider all members, bi_type is invalid for Blocks, need to
look at member decorations.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
cea934c03f MSL: Test that we can capture cull distance to buffer. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
5826298697 MSL: Handle CullDistance better. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
23da445bd4 MSL: Emit multiple threadgroup slices for multi-patch.
Multiple patches can run in the same workgroup when using multi-patch
mode, so we need to allocate enough storage to avoid false sharing.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
b442500204 MSL: Unroll initializations of CullDistance/ClipDistance control points. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
c9946296dd MSL: Fix initialization of masked threadgroup variables. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
5e9c2d060e MSL: Cleanup fallback IO block emission.
Need to emit in add_variable_to_iface(). Unifies the code paths a fair
bit.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
e32c474911 MSL: Handle masking of TESC IO block members. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
dc54f75eec MSL: Fixup gl_PerVertex names if we're emitting masked builtins. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
40f628f49c MSL: Add test for complex control point outputs. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
46c48ee6b5 MSL: Rewrite how IO blocks are emitted in multi-patch mode.
Firstly, never flatten inputs or outputs in multi-patch mode.
The main scenario where we do need to care is Block IO.
In this case, we should only flatten the top-level member, and after
that we use access chains as normal.

Using structs in Input storage class is now possible as well. We don't
need to consider per-location fixups at all here. In Vulkan, IO structs
must match exactly. Only plain vectors can have smaller vector sizes as
a special case.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
ff3f5bcba5 MSL: Handle masking of builtin control points. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
436b1250da MSL: Do not perform scalar fixups for control-point outputs. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
74b2acab9b MSL: Always emit block variable for block types. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
ae7bb41ef4 MSL: Test that we can mask location writes in TESC. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
ba93b6518d MSL: Fix masking of vertex block outputs. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
857295a9ab MSL: Add tests for masking with --for-tess. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
43b6ea2c9a MSL: Remove position mask tests. They will fail compilation. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
65b5ff7ece MSL: Don't emit weird reference type for spvUnsafeArray types. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
50a6bc058a MSL: Force builtin arrays for builtin array types.
Handles argument_decl() correctly.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
88b54f5dab MSL: Add tests for vertex output masking. 2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
0997e81118 MSL: Sort builtin IO block members by builtin type.
Ensures consistent block matching.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
ee31e84e30 GLSL: Handle complex load/store scenarios to gl_SampleMask.
Need special workarounds to handle array load/store since array size is
unsized in GLSL, and array copy is not possible.
Also, consider bitcast for scalar loads and stores.
2021-03-09 10:25:03 +01:00
Hans-Kristian Arntzen
fb1f295aaf
Merge pull request #1635 from KhronosGroup/fix-1627
Handle edge cases in OpCopyMemory.
2021-03-09 10:21:35 +01:00
Hans-Kristian Arntzen
4ca06c7278 Handle edge cases in OpCopyMemory.
Implement this by synthesizing an OpLoad/OpStore pair instead.
2021-03-08 14:15:27 +01:00
Hans-Kristian Arntzen
aea6d29aa8 MSL: Add test for logical subgroup arith ops. 2021-03-08 12:57:37 +01:00
Hans-Kristian Arntzen
d6c2c1b39a HLSL: Support logical subgroup ops. 2021-03-08 12:52:03 +01:00
Hans-Kristian Arntzen
5570043af3 GLSL: Add support for Logical subgroup ops.
Completely missed these ...
2021-03-08 12:06:46 +01:00
Hans-Kristian Arntzen
97796e0609 MSL: Deal with pointer-to-pointer qualifier ordering. 2021-02-26 13:37:14 +01:00
Hans-Kristian Arntzen
621884d709
Merge pull request #1622 from KhronosGroup/fix-1619
MSL: Handle load and store to TessLevel array in TESC.
2021-02-17 20:46:06 +01:00
Hans-Kristian Arntzen
85704f70bc MSL: Handle load and store to TessLevel array in TESC.
More edge cases ... :(
2021-02-17 13:26:08 +01:00
Hans-Kristian Arntzen
ce552f4f91 MSL: Gracefully assign automatic input locations to builtin attributes. 2021-02-17 12:29:19 +01:00
Hans-Kristian Arntzen
bae17e8204
Merge pull request #1617 from KhronosGroup/fix-1608
MSL: Fixup type when using tessellation levels in TESC functions.
2021-02-16 11:10:07 +01:00
Hans-Kristian Arntzen
daddbd4078 MSL: Fixup type when using tessellation levels in TESC functions.
Need to rewrite array size depending on execution mode.
2021-02-15 13:28:11 +01:00
Hans-Kristian Arntzen
0ad12a0036 MSL: Always return [[position]] when required. 2021-02-15 12:57:37 +01:00
Hans-Kristian Arntzen
ea02a0c03a Check entry point variables in is_hidden_variables.
Need to be careful not to emit globals we're not supposed to.
2021-01-22 13:53:22 +01:00
Hans-Kristian Arntzen
4bedad3860 Handle nonuniformEXT qualifier for acceleration structures. 2021-01-22 13:13:56 +01:00
Hans-Kristian Arntzen
7ab3f3f74e Deal better with CompositeExtract from constant composite.
There is no good reason for applications to emit this kind of code, but
some do. Special case this scenario.
2021-01-22 12:30:16 +01:00
Hans-Kristian Arntzen
66fb0bd9df GLSL: Handle tracing against incoming payload/callable. 2021-01-22 11:23:04 +01:00
Hans-Kristian Arntzen
2097c30985 GLSL: Support both SPV_KHR_ray_tracing and NV_ray_tracing.
Fairly minor differences, so can keep them side by side without too much
effort. NV support is effectively deprecated now however.

- Add OpConvertUToAccelerationStructureKHR
- Ignore/Terminate ray is now a terminator in KHR, but a call in NV.
- Fix some bugs with reportIntersection.
2021-01-08 14:59:04 +01:00
Hans-Kristian Arntzen
5d82d32e0f Roll dependencies. 2021-01-08 10:41:51 +01:00
Hans-Kristian Arntzen
893a011299 MSL: Fix various bugs with framebuffer fetch on macOS and argument buffers.
Introduce a helper to make it clearer if a resource can be
considered for argument buffers or not.
2021-01-08 10:19:18 +01:00
Hans-Kristian Arntzen
3136e34215 MSL: Always use input_attachment_index for framebuffer fetch binding.
--msl-decoration-binding would end up overriding the input attachment
index to binding which is very unexpected and broken.
2021-01-08 10:17:42 +01:00
Hans-Kristian Arntzen
03ee71e86c Add test for pure initializer gl_FragDepth.
Tests that the builtin is considered active.
2021-01-07 15:32:15 +01:00
Hans-Kristian Arntzen
3776d8978c GLSL: Force block declaration if clip/cull is used in tesc. 2021-01-07 15:32:15 +01:00
Hans-Kristian Arntzen
014b3bc5ea MSL: Make sure initialized output builtins are considered active. 2021-01-07 15:32:13 +01:00
Hans-Kristian Arntzen
a4a9b53b5b MSL: Always enable Outputs in vertex stages.
Subsequent stages can legally attempt to read from these variables,
which causes compilation failure.

Always make sure we emit user outputs in vertex shaders if they are
active in the entry point.
2021-01-07 11:24:47 +01:00
Hans-Kristian Arntzen
fa76d01203 MSL: Only consider builtin variables if they are part of IO interface. 2021-01-07 10:50:29 +01:00
Hans-Kristian Arntzen
efed4c9738 MSL: Fix initializer for tess level outputs.
It's an array, not vector.
2021-01-06 10:39:39 +01:00
Hans-Kristian Arntzen
ab9200ffdf MSL: Don't flatten builtin arrays unless they're part of IO interface. 2021-01-06 10:33:17 +01:00
Hans-Kristian Arntzen
df4f8ef8fe MSL: Emit correct initializer for tessellation control points. 2021-01-05 15:16:49 +01:00
Hans-Kristian Arntzen
ad3e1584f9 MSL: Handle initializers for tess levels. 2021-01-05 13:25:50 +01:00
Hans-Kristian Arntzen
6a3ea0385e GLSL: Add test for initializing tess level output. 2021-01-05 12:12:26 +01:00
Hans-Kristian Arntzen
175381fe08 GLSL: Handle some extreme edge cases in Output variable initialization.
Deal with patch blocks, arrays of patch blocks, arrays of blocks, etc.
2021-01-05 12:06:36 +01:00
Hans-Kristian Arntzen
a1c784f002 More robust handling of initialized output builtin variables. 2021-01-04 19:12:43 +01:00
Hans-Kristian Arntzen
9a304fe931 Handle output IO block initializers more robustly. 2021-01-04 19:04:10 +01:00
Hans-Kristian Arntzen
ddb3c65648 Handle reserved identifiers for functions.
gl_ identifiers are already handled by fixups, so remove redundant code.
2021-01-04 10:00:12 +01:00
Hans-Kristian Arntzen
c4ff129fe3 MSL: Handle reserved identifiers for entry point.
We only considered invalid names, and overwrote the alias for the
function. The correct fix is to replace illegal names early, do the
reserved fixup, then copy back alias to entry point name.
2021-01-04 09:40:11 +01:00
Hans-Kristian Arntzen
c8765a75f2 GLSL: Fix KHR subgroup extension table for subgroups. 2020-12-11 12:26:43 +01:00
Hans-Kristian Arntzen
762c3082ae
Merge pull request #1564 from KhronosGroup/fix-1558
GLSL: Emit nonuniformEXT in correct place for late-combined samplers.
2020-12-07 14:07:38 +01:00
Hans-Kristian Arntzen
a11c4780d0 GLSL: Emit nonuniformEXT in correct place for late-combined samplers.
Need to emit nonuniformEXT(sampler2D()) since constructor expressions in
Vulkan GLSL do not propgate the nonuniform qualifier.
2020-12-07 13:00:15 +01:00
Hans-Kristian Arntzen
dc940846d7 GLSL/HLSL: Disallow VariablePointers capability outright.
Cannot be supported, error out early.
2020-12-07 12:16:02 +01:00
comex
c80cbde7aa spirv_msl: Don't add fixup hooks for builtin variables if they're unused.
This is necessary to avoid invalid output because of how implicit
dependencies on builtins work.

For example, the fixup for `BuiltInSubgroupEqMask` initializes the
variable based on `builtin_subgroup_invocation_id_id`, a field storing
the ID for a variable with decoration `BuiltInSubgroupLocalInvocationId`.
This could be either a variable that already exists in the input
(spirv_msl.cpp:300) or, if necessary, a newly created one
(spirv_msl.cpp:621).  In both cases, though,
`builtin_subgroup_invocation_id_id` is only set under the condition
`need_subgroup_mask || needs_subgroup_invocation_id`.
`need_subgroup_mask` is true if any of the `BuiltInSubgroupXXMask` are
set in `active_input_builtins`.

Normally, if the program contains `BuiltInSubgroupEqMask`,
`Compiler::ActiveBuiltinHandler` will set it in `active_input_builtins`.
But this only happens if the variable is actually used, whereas
`fix_up_shader_inputs_outputs` loops over all variables in the program
regardless of whether they're used.

If `BuiltInSubgroupEqMask` is not used,
`builtin_subgroup_invocation_id_id` is never set, but before this patch
the fixup hook would try to use it anyway, producing MSL that references
a nonexistent variable named `_0`.

Avoid this by changing `fix_up_shader_inputs_outputs` to skip builtins
which are not set in `active_input_builtins` or
`active_output_builtins`.  And add a test case.
2020-11-25 13:41:12 -05:00
Chip Davis
1e67b21ee9 MSL: Don't mask off inactive bits in ballot masks.
This was based on my misreading the spec. The Vulkan CTS expects the
bits to be set, even if the invocations corresponding to them are
inactive.
2020-11-25 09:29:51 -06:00
Chip Davis
fd738e3387 MSL: Adjust FragCoord for sample-rate shading.
In Metal, the `[[position]]` input to a fragment shader remains at
fragment center, even at sample rate, like OpenGL and Direct3D. In
Vulkan, however, when the fragment shader runs at sample rate, the
`FragCoord` builtin moves to the sample position in the framebuffer,
instead of the fragment center. To account for this difference, adjust
the `FragCoord`, if present, by the sample position. The -0.5 offset is
because the fragment center is at (0.5, 0.5).

Also, add an option to force sample-rate shading in a fragment shader.
Since Metal has no explicit control for this, this is done by adding a
dummy `[[sample_id]]` which is otherwise unused, if none is already
present. This is intended to be used from e.g. MoltenVK when a
pipeline's `minSampleShading` value is nonzero.

Instead of checking if any `Input` variables have `Sample`
interpolation, I've elected to check that the `SampleRateShading`
capability is present. Since `SampleId`, `SamplePosition`, and the
`Sample` interpolation decoration require this cap, this should be
equivalent for any valid SPIR-V module. If this isn't acceptable, let me
know.
2020-11-23 10:30:24 -06:00
Hans-Kristian Arntzen
e07f0a9df5 GLSL: Fix buffer_reference with aliased names. 2020-11-23 16:36:49 +01:00
Hans-Kristian Arntzen
c5826b4b69 GLSL: Emit storage qualifiers for buffer_reference. 2020-11-23 16:26:33 +01:00
Hans-Kristian Arntzen
650b5e1b12 HLSL: Fix validation with FXC for test. 2020-11-23 16:03:35 +01:00
Hans-Kristian Arntzen
6a614cc7f7 Normalize all internal workaround methods to use spv prefix.
We have been interchanging spv and SPIRV_Cross_ for a while, which
causes weirdness since we don't explicitly ban SPIRV_Cross identifiers,
as these identifiers are generally used for interface variable
workarounds.
2020-11-23 15:42:27 +01:00
Chip Davis
68908355a9 MSL: Expand subgroup support.
Add support for declaring a fixed subgroup size. Metal, like Vulkan with
`VK_EXT_subgroup_size_control`, allows the thread execution width to
vary depending on factors such as register usage. Unfortunately, this
breaks several tests that depend on the subgroup size being what the
device says it is. So we'll fix the subgroup size at the size the device
declares. The extra invocations in the subgroup will appear to be
inactive. Because of this, the ballot mask builtins are now ANDed with
the active subgroup mask.

Add support for emulating a subgroup of size 1. This is intended to be
used by Vulkan Portability implementations (e.g. MoltenVK) when the
hardware/software combo provides insufficient support for subgroups.
Luckily for us, Vulkan 1.1 only requires that the subgroup size be at
least 1.

Add support for quadgroup and SIMD-group functions which were added to
iOS in Metal 2.2 and 2.3. This will allow clients to take advantage of
expanded quadgroup and SIMD-group support in recent Metal versions and
on recent Apple GPUs (families 6 and 7).

Gut emulation of subgroup builtins in fragment shaders. It turns out
codegen for the SIMD-group functions in fragment wasn't implemented for
AMD on Mojave; it's a safe bet that it wasn't implemented for the other
drivers either. Subgroup support in fragment shaders now requires Metal
2.2.
2020-11-20 15:55:49 -06:00
Hans-Kristian Arntzen
1ee2d13873 MSL: Add missing reference file. 2020-11-11 16:25:01 +01:00
Jan Sikorski
f0239bce05 MSL: extract global variables from subgroup ballot operations
Fixes #1513.
2020-11-09 11:23:01 +01:00
Hans-Kristian Arntzen
71fcf0d9e6 Update texture gather test result. 2020-11-08 13:54:30 +01:00
Hans-Kristian Arntzen
46bf1e99d6
Merge pull request #1525 from cdavis5e/msl-interpolation-functions
MSL: Support pull-model interpolation on MSL 2.3+.
2020-11-07 17:04:56 +01:00
Hans-Kristian Arntzen
683c3f5c3f
Merge pull request #1530 from rdb/legacy-glsl-round
GLSL: Provide round/roundEven for legacy GLSL
2020-11-07 16:40:18 +01:00
Hans-Kristian Arntzen
ea334c14bc
Merge pull request #1527 from rdb/legacy-transpose
GLSL: implement transpose() in GLSL 1.10 / ES 1.00
2020-11-07 16:37:59 +01:00
Hans-Kristian Arntzen
2417010046
Merge pull request #1528 from rdb/fix-legacy-vertex-shader-lod
GLSL: Fix support for textureLod in legacy vertex shaders
2020-11-07 16:33:50 +01:00
rdb
bf71994dae GLSL: implement transpose() in GLSL 1.10 / ES 1.00 2020-11-06 22:27:54 +01:00
rdb
9e6e5d2738 GLSL: Fix round/roundEven for legacy GLSL. 2020-11-06 17:34:38 +01:00
rdb
e8c500ceef GLSL: Fix support for textureLod in legacy vertex shaders 2020-11-06 16:37:27 +01:00
Hans-Kristian Arntzen
db13762297 MSL: Fix regression in image gather handling.
It was not always possible to get backing variable for a late-combined
image sampler.
2020-11-06 16:21:30 +01:00
Chip Davis
aca9b6879a MSL: Support pull-model interpolation on MSL 2.3+.
New in MSL 2.3 is a template that can be used in the place of a scalar
type in a stage-in struct. This template has methods which interpolate
the varying at the given points. Curiously, you can't set interpolation
attributes on such a varying; perspective-correctness is encoded in the
type, while interpolation must be done using one of the methods. This
makes using this somewhat awkward from SPIRV-Cross, requiring us to jump
through a bunch of hoops to make this all work.

Using varyings from functions in particular is a pain point, requiring
us to pass the stage-in struct itself around. An alternative is to pass
references to the interpolants; except this will fall over badly with
composite types, which naturally must be flattened.  As with
tessellation, dynamic indexing isn't supported with pull-model
interpolation. This is because of the need to reference the original
struct member in order to call one of the pull-model interpolation
methods on it. Also, this is done at the variable level; this means that
if one varying in a struct is used with the pull-model functions, then
the entire struct is emitted as pull-model interpolants.

For some reason, this was not documented in the MSL spec, though there
is a property on `MTLDevice`, `supportsPullModelInterpolation`,
indicating support for this, which *is* documented. This does not appear
to be implemented yet for AMD: it returns `NO` from
`supportsPullModelInterpolation`, and pipelines with shaders using the
templates fail to compile. It *is* implemeted for Intel. It's probably
also implemented for Apple GPUs: on Apple Silicon, OpenGL calls down to
Metal, and it wouldn't be possible to use the interpolation functions
without this implemented in Metal.

Based on my testing, where SPIR-V and GLSL have the offset relative to
the pixel center, in Metal it appears to be relative to the pixel's
upper-left corner, as in HLSL. Therefore, I've added an offset 0.4375,
i.e. one half minus one sixteenth, to all arguments to
`interpolate_at_offset()`.

This also fixes a long-standing bug: if a pull-model interpolation
function is used on a varying, make sure that varying is declared. We
were already doing this only for the AMD pull-model function,
`interpolateAtVertexAMD()`; for reasons which are completely beyond me,
we weren't doing this for the base interpolation functions. I also note
that there are no tests for the interpolation functions for GLSL or
HLSL.
2020-11-05 11:57:45 -06:00
rdb
135933d59e HLSL: Add regression test for SM3.0 texture samplers 2020-11-03 18:15:05 +01:00
Hans-Kristian Arntzen
fc644b50e6
Merge pull request #1523 from KhronosGroup/fix-1512
HLSL: Add option to flatten matrix vertex input semantics.
2020-11-03 13:16:54 +01:00
Hans-Kristian Arntzen
b3344174f7 HLSL: Add option to flatten matrix vertex input semantics.
Helps translation layers where we expect inputs to be multiple float
vectors rather than an indexed matrix.
2020-11-03 11:18:32 +01:00
Hans-Kristian Arntzen
1f018b0fb8 Parser: Don't assume OpTypePointer will always take a SPIRType.
Possible to receive a function prototype here. Don't try to do anything
smart here, just don't crash during parsing.
2020-11-03 10:53:37 +01:00
Hans-Kristian Arntzen
c5a3f37a1c
Merge pull request #1519 from cdavis5e/msl-mac-comparison-bias-grad
MSL: Allow Bias and Grad arguments with comparison on Mac in MSL 2.3.
2020-11-02 20:01:14 +01:00
criss
6402586015 Updated ref file for subgroups_basicvoteballot.vk.comp 2020-11-02 18:40:56 +01:00
Chip Davis
547c29f7bb MSL: Allow Bias and Grad arguments with comparison on Mac in MSL 2.3.
I kept the code to replace constant zero arguments, because `Bias` and
`Grad` still have some problems on desktop GPUs.

`Bias` works on AMD GPUs. `Grad` does not. Both work on Intel. Still
needs testing on NV. It will definitely work with Apple GPUs.
2020-10-30 11:14:59 -05:00
Hans-Kristian Arntzen
439b666829 GLSL: Fix nonuniformEXT injection.
Needs to consider that other expressions might be using brackets as well
...
2020-10-30 14:11:16 +01:00
Hans-Kristian Arntzen
541a801fed
Merge pull request #1514 from cdavis5e/msl-mac-framebuffer-fetch
MSL: Allow framebuffer fetch on Mac in MSL 2.3.
2020-10-30 08:09:41 +01:00
Yuwen Wu
c8a43876c7
added metal keyworld: "level" (#1501)
* added metal keyworld: "level"

* added more metal keywords

* updated test case.
2020-10-30 08:07:25 +01:00
Chip Davis
c20d5945a2 MSL: Allow framebuffer fetch on Mac in MSL 2.3.
Another Apple GPU feature that will now be supported on Apple Silicon
Macs.
2020-10-29 10:50:59 -05:00
Hans-Kristian Arntzen
78c6d2d628
Merge pull request #1509 from cdavis5e/mac-post-depth-coverage
MSL: Allow post-depth coverage on Mac in MSL 2.3.
2020-10-29 09:50:44 +01:00
Hans-Kristian Arntzen
08e49bfd67
Merge pull request #1508 from KhronosGroup/fix-1507
Handle case where block is loop header, continue AND break block.
2020-10-28 16:04:14 +01:00
Chip Davis
d48d2a95c7 MSL: Allow post-depth coverage on Mac in MSL 2.3.
It's still only supported on Apple GPUs, but Macs will have those soon.
2020-10-27 22:07:01 -05:00
Hans-Kristian Arntzen
542d460364 Handle case where block is loop header, continue AND break block. 2020-10-27 12:29:08 +01:00
Hans-Kristian Arntzen
e47561a28b GLSL: Support a workaround for loading row-major matrices.
On AMD Windows OpenGL, it has been reported that we need to load
matrices via a wrapper function.
2020-10-27 12:07:09 +01:00
Hans-Kristian Arntzen
f65f259ab7 MSL: Do not use component::x gather for depth2d textures. 2020-10-26 10:18:17 +01:00
Chip Davis
1264e2705e MSL: Cast broadcast booleans to ushort.
Metal doesn't support broadcasting or shuffling boolean values, but we
can work around that by casting it to `ushort`, then casting it back to
`bool`. I used `ushort` instead of `uint` because 16-bit values give
better throughput on Apple GPUs.
2020-10-23 21:55:46 -05:00
Chip Davis
065b5bda3c MSL: Mask ballots passed to Ballot bit ops.
Only the least *n* bits are significant, where *n* is the subgroup size.
The Vulkan CTS actually checks this.

The `FindLSB` tests weren't actually failing, but I masked that anyway,
in case there's some corner case the CTS is missing.
2020-10-23 21:55:46 -05:00
Chip Davis
781367d083 MSL: Support vectors with OpGroupNonUniformAllEqual.
This was not tested here in SPIRV-Cross. Predictably, it broke when I
tried it in the CTS.
2020-10-23 21:55:46 -05:00
Chip Davis
6ccb902462 MSL: Correct definitions of subgroup ballot mask variables.
`SubgroupEqMask` had a fencepost error that gave wrong values for
invocation ID 32.

For `SubgroupGeMask` and `SubgroupGtMask`, I forgot to shift the values
from `extract_bits()` up so that the mask is in the correct position.
Using `insert_bits()` instead should fold these two operations into one.

`SubgroupLtMask` and `SubgroupLeMask` were already correct.
2020-10-23 21:54:55 -05:00
Chip Davis
064ed448b9 MSL: Don't remove periods from swizzle buffer index exprs. 2020-10-20 17:47:40 -05:00
Chip Davis
5845e009ea MSL: Handle Offset and Grad operands for 1D-as-2D textures. 2020-10-15 12:51:00 -05:00
Chip Davis
3e6010d8c5 MSL: Don't use a bitcast for tessellation levels in tesc shaders.
`half` cannot be bitcasted to `float`, because the two types are not the
same size. Use an expanding cast instead.

We were already doing this for stores to the tessellation levels; why I
didn't also do this for loads is beyond me.
2020-10-14 18:35:59 -05:00
Chip Davis
21d38f74ce MSL: Fix calculation of atomic image buffer address.
Fix reversed coordinates: `y` should be used to calculate the row
address. Align row address to the row stride.

I've made the row alignment a function constant; this makes it possible
to override it at pipeline compile time.

Honestly, I don't know how this worked at all for Epic. It definitely
didn't work in the CTS prior to this.
2020-10-13 20:51:56 -05:00
Chip Davis
7a5d0d6b29 MSL: Add missing interlock handling to atomic image buffers. 2020-10-13 11:44:17 -05:00
Hans-Kristian Arntzen
fab6ad234e
Merge pull request #1486 from cdavis5e/atomic-image-argument-buffer
MSL: Support atomic access to images from argument buffers.
2020-10-13 12:55:43 +02:00
Chip Davis
9cafea6cf8 MSL: Support atomic access to images from argument buffers.
This was not added when Epic contributed atomic image support.

Fixes #1484.
2020-10-13 02:37:18 -05:00
Chip Davis
2219c4a392 MSL: Support SPV_EXT_demote_to_helper_invocation for MSL 2.3.
MSL 2.3 has everything needed to support this extension on all
platforms. The existing `discard_fragment()` function was given demote
semantics, similar to Direct3D, and the `simd_is_helper_thread()`
function was finally added to iOS.

I've left the old test alone. Should I remove it in favor of these?
2020-10-13 00:25:32 -05:00
Hans-Kristian Arntzen
5619329665 Style nits for GL subgroup implementation. 2020-10-08 13:25:29 +02:00
Hans-Kristian Arntzen
a6f6547cf1 Add missing VK variant of the test file. 2020-10-08 12:22:45 +02:00
Hans-Kristian Arntzen
28994a3186 Update GL subgroup test file. 2020-10-08 12:22:24 +02:00
Hans-Kristian Arntzen
819c599ecd Merge branch 'issues1350-2' of git://github.com/devshgraphicsprogramming/SPIRV-Cross into master 2020-10-08 12:20:07 +02:00
criss
db52e277b9 Resolved issues 1350, 1351, 1352 2020-10-08 12:14:52 +02:00
Hans-Kristian Arntzen
e0c9aad934 GLSL: Add support for transform_feedback3 geometry streams. 2020-09-30 13:01:35 +02:00
dan sinclair
9880b05572 Roll dependencies.
This CL rolls the spirv-tools, spirv-headers and glslang dependencies.
2020-09-22 12:31:38 -04:00
Hans-Kristian Arntzen
54cc0b01f6 Deal with case where a selection construct conditionally merges/breaks. 2020-09-17 12:02:43 +02:00
Hans-Kristian Arntzen
66afe8c499 Implement a simple evaluator of specialization constants.
In some cases, we need to get a literal value from a spec constant op.
Mostly relevant when emitting buffers, so implement a 32-bit integer
scalar subset of the evaluator. Can be extended as needed to support
evaluating any specialization constant operation.
2020-09-14 11:45:59 +02:00
Chip Davis
4cf840ee7b MSL: Support layered input attachments.
These need to use arrayed texture types, or Metal will complain when
binding the resource. The target layer is addressed relative to the
Layer output by the vertex pipeline, or to the ViewIndex if in a
multiview pipeline. Unlike with the s/t coordinates, Vulkan does not
forbid non-zero layer coordinates here, though this cannot be expressed
in Vulkan GLSL.

Supporting 3D textures will require additional work. Part of the problem
is that Metal does not allow texture views to subset a 3D texture, so we
need some way to pass the base depth to the shader.
2020-09-02 09:18:25 -05:00
Hans-Kristian Arntzen
3360daa6f3 MSL: Fix OpCompositeInsert and OpVectorInsertDynamic.
Need to take care of unpacked RHS expressions.
2020-09-02 10:27:39 +02:00
Chip Davis
cab7335e64 MSL: Don't set the layer for multiview if the device doesn't support it.
Some older iOS devices don't support layered rendering. In that case,
don't set `[[render_target_array_index]]`, because the compiler will
reject the shader in that case. The client will then have to unroll the
render pass manually.
2020-09-01 19:30:28 -05:00
Chip Davis
53080ecca8 MSL: Fix multiview view index calculation with a non-zero base instance.
Account for a non-zero base instance when calculating the view index and
the "real" instance index. Before, it was likely broken with a non-zero
base instance, since the calculated instance index could be less than
the base instance.
2020-08-31 20:33:44 -05:00
Hans-Kristian Arntzen
a07441568e Overhaul how we deal with reserved identifiers.
- Do not silently drop reserved identifiers in the parser. This makes it
  possible to reflect identifiers which are reserved by the
  cross-compiler module.
- Instead of dropping the name, emit _RESERVED_IDENTIFIER_FIXUP in the
  source to make it clear that a name has been rewritten.
- Document what is reserved and not.
2020-08-21 16:33:27 +02:00
Hans-Kristian Arntzen
f0fe4442e3
Merge pull request #1448 from KhronosGroup/fix-1437
HLSL: Fix some subtle bugs in buffer packing handling.
2020-08-20 19:21:50 +02:00
Hans-Kristian Arntzen
fdbc80d131 HLSL: Fix FragCoord.w.
Need to invert it, SM 4.0+ uses W, not 1/W (like Vulkan/GL).
2020-08-20 16:22:48 +02:00
Hans-Kristian Arntzen
fad36a6b28 HLSL: Deal with partially filled 16-byte word in cbuffers.
The last element of an array or matrix in HLSL cbuffers are not filled
completely, but only have a size equal to the base vector.
2020-08-20 16:05:21 +02:00
Hans-Kristian Arntzen
dd1f53ff15 HLSL: Fix bug in is_packing_standard for cbuffer.
Was not keeping offset in sync with actual_offset and HLSL could trigger
spurious realignments due to the straddle check.
2020-08-20 15:26:55 +02:00
Le Hoang Quyen
ab8eb70af1 Fix #1445: MSL: Enclose args when convert distance(a,b) to abs(a-b) 2020-08-13 21:16:08 +08:00
Chip Davis
3347b1076d MSL: Fix handling of matrices and structs in the output control point array.
Prior to this point, we were treating them as flattened, as they are in
old-style tessellation control shaders, and still are for structs in
new-style shaders. This is not true for outputs; output composites are
not flattened at all. This semantic mismatch broke a Vulkan CTS test.
It should now pass.
2020-08-03 17:18:18 -05:00
Hans-Kristian Arntzen
8a1843ab20 Add some test cases for complex type aliasing scenario. 2020-07-29 13:02:52 +02:00
Hans-Kristian Arntzen
aac6885950 GLSL: Be more aggressive about using type_alias.
To facilitate an improved linking-by-name use case for older GL,
we will be more aggressive about merging struct definitions, even for
rather unrelated cases where we don't strictly need to use type aliases.
2020-07-29 12:48:41 +02:00
Hans-Kristian Arntzen
57c93d44ac GLSL: Add option to force flattening IO blocks.
It is not always desirable to use actual blocks.
A prime example in the case where EXT_shader_io_blocks is not supported
on the target implementation.
2020-07-28 15:16:06 +02:00
Hans-Kristian Arntzen
f5e9f4a172
Merge pull request #1432 from ponitka/hlsl-sample-mask
Adding BuiltInSampleMask in HLSL
2020-07-28 14:40:40 +02:00
Tomek Ponitka
ba58f78395 Adding BuiltInSampleMask in HLSL 2020-07-27 14:14:26 +02:00
Tomek Ponitka
18f23c47d9 Enabling setting a fixed sampleMask in Metal fragment shaders.
In Metal render pipelines don't have an option to set a sampleMask
parameter, the only way to get that functionality is to set the
sample_mask output of the fragment shader to this value directly.
We also need to take care to combine the fixed sample mask with the
one that the shader might possibly output.
2020-07-24 11:19:46 +02:00
Chip Davis
688c5fcbda MSL: Add support for processing more than one patch per workgroup.
This should hopefully reduce underutilization of the GPU, especially on
GPUs where the thread execution width is greater than the number of
control points.

This also simplifies initialization by reading the buffer directly
instead of using Metal's vertex-attribute-in-compute support. It turns
out the only way in which shader stages are allowed to differ in their
interfaces is in the number of components per vector; the base type must
be the same. Since we are using the raw buffer instead of attributes, we
can now also emit arrays and matrices directly into the buffer, instead
of flattening them and then unpacking them. Structs are still flattened,
however; this is due to the need to handle vectors with fewer components
than were output, and I think handling this while also directly emitting
structs could get ugly.

Another advantage of this scheme is that the extra invocations needed to
read the attributes when there were more input than output points are
now no more. The number of threads per workgroup is now lcm(SIMD-size,
output control points). This should ensure we always process a whole
number of patches per workgroup.

To avoid complexity handling indices in the tessellation control shader,
I've also changed the way vertex shaders for tessellation are handled.
They are now compute kernels using Metal's support for vertex-style
stage input. This lets us always emit vertices into the buffer in order
of vertex shader execution. Now we no longer have to deal with indexing
in the tessellation control shader. This also fixes a long-standing
issue where if an index were greater than the number of vertices to
draw, the vertex shader would wind up writing outside the buffer, and
the vertex would be lost.

This is a breaking change, and I know SPIRV-Cross has other clients, so
I've hidden this behind an option for now. In the future, I want to
remove this option and make it the default.
2020-07-23 17:59:54 -05:00
dan sinclair
c4f3d4ae29 Roll GLSLang, SPIRV-Headers and SPIRV-Tools.
This Cl updates the various dependencies and the test file outputs.
2020-07-22 23:03:11 -04:00
dan sinclair
63fbdaca93 Roll deps.
This CL updates the GLSLang and SPIRV-Tools depedencies and updates test
files as needed.
2020-07-06 11:24:30 -04:00
Hans-Kristian Arntzen
711300baed MSL: Do not emit swizzled writes in packing fixups.
Similar to scalar access chain fix, this causes a read-modify-write on
memory we're not supposed to write to.
2020-07-06 10:03:46 +02:00
Hans-Kristian Arntzen
fa5b206d97 MSL: Workaround broken vector -> scalar access chain in MSL.
On MSL, the compiler refuses to allow access chains into a normal vector type.
What happens in practice instead is a read-modify-write where a vector type is
loaded, modified and written back.

The workaround is to convert a vector into a pointer-to-scalar before
the access chain continues to add the scalar index.
2020-07-06 10:03:44 +02:00
Hans-Kristian Arntzen
e1600d4df8 MSL: Use input attachment index directly for resource index fallback. 2020-07-06 09:49:46 +02:00
Hans-Kristian Arntzen
2ac8f51b06 GLSL: Support I/O flattening with arrays as final type. 2020-07-06 09:18:30 +02:00
Hans-Kristian Arntzen
2d43103a55 GLSL: Support multi-level struct flattening for I/O. 2020-07-03 14:38:51 +02:00
Hans-Kristian Arntzen
70f17142de GLSL: Fix nested legacy switch workarounds. 2020-06-30 12:02:24 +02:00
Hans-Kristian Arntzen
b1082c10af
Merge pull request #1410 from KhronosGroup/fix-1406
GLSL: Support switch more properly in legacy ESSL
2020-06-29 15:22:39 +02:00
Hans-Kristian Arntzen
4d79d634f5 GLSL: Implement switch on ESSL 1.0.
Cannot use switch on legacy ESSL, fallback to plain branches.
2020-06-29 13:35:46 +02:00
Hans-Kristian Arntzen
bae76d7915 GLSL: Use for-loop fallback instead of do/while for legacy ESSL.
do/while loops are not guaranteed to be supported in ESSL 1.0 / OpenGLES
2.0 implementations.
2020-06-29 12:50:31 +02:00
Hans-Kristian Arntzen
3afbfdb090 Implement context-sensitive expression read tracking.
When inside a loop, treat any read of outer expressions to happen
multiple times, forcing a temporary of said outer expressions.
This avoids the problem where we can end up relying on loop-invariant code motion to happen in the
compiler when converting optimized shaders.
2020-06-29 12:20:35 +02:00
Hans-Kristian Arntzen
05188aca69 Fix bug with control dependent expression tracking.
For a direct branch without merge, we lost control dependent
expressions.
2020-06-29 10:55:50 +02:00
Hans-Kristian Arntzen
eb0f0323d3 HLSL: Workaround FXC bugs with degenerate switch blocks.
When we see a switch block which only contains one default block, emit a
do {} while(false) statement instead, which is far more idiomatic and
readable anyways.
2020-06-23 15:39:04 +02:00
dan sinclair
0abc017501 Roll deps and update tests.
This CL rolls the GLSlang, SPIRV-Tools and SPIRV-Headers dependencies
and updates the various test files.
2020-06-22 09:33:29 -04:00
Hans-Kristian Arntzen
f141521ebe Fix duplicated initialization for loop variables with initializers. 2020-06-19 10:51:00 +02:00
Hans-Kristian Arntzen
ace4d25222 MSL: Add test case for constructing struct with non-value-type array. 2020-06-18 12:55:59 +02:00
Hans-Kristian Arntzen
7314f51a32 MSL: Deal with loading non-value-type arrays. 2020-06-18 12:46:39 +02:00
Hans-Kristian Arntzen
02db4c1f16 MSL: Add tests for array copies in and out of buffers. 2020-06-18 11:59:02 +02:00
Hans-Kristian Arntzen
a64484f62b
Merge pull request #1392 from cdavis5e/msl-frag-input-vecsize
MSL: Fix up input variables' vector lengths in all stages.
2020-06-17 09:41:04 +02:00
Chip Davis
5281d9997e MSL: Fix up input variables' vector lengths in all stages.
Metal is picky about interface matching. If the types don't match
exactly, down to the number of vector components, Metal fails pipline
compilation. To support pipelines where the number of components
consumed by the fragment shader is less than that produced by the vertex
shader, we have to fix up the fragment shader to accept all the
components produced.
2020-06-16 14:50:30 -05:00
Hans-Kristian Arntzen
d13dc0ce47 HLSL: Fix texProj in legacy HLSL. 2020-06-16 12:54:22 +02:00
Hans-Kristian Arntzen
f383cc98f2 GLSL: Handle the rest of GL_ARB_sparse_texture_clamp.
Missed these in initial sparse implementation.
2020-06-08 13:40:11 +02:00
Hans-Kristian Arntzen
857e1c445c GLSL: Support uint code for sparse residency query. 2020-06-08 11:40:02 +02:00
Hans-Kristian Arntzen
553a7f959b
Merge pull request #1385 from KhronosGroup/fix-1237
GLSL: Implement sparse feedback.
2020-06-08 11:12:00 +02:00
Hans-Kristian Arntzen
275974e062 GLSL: Implement sparse feedback. 2020-06-04 15:50:28 +02:00
Hans-Kristian Arntzen
2d5200650a HLSL: Add native support for 16-bit types.
Adds support for templated load/store in SM 6.2 to deal with small
types.
2020-06-04 12:33:56 +02:00
Hans-Kristian Arntzen
58dad82fcb Handle physical pointers in reflection API. 2020-05-25 13:45:49 +02:00
Hans-Kristian Arntzen
ef247e75ec GLSL: Improve support for GL_ARB_shader_draw_parameters in desktop GLSL.
Opt-in to using the extension to support gl_InstanceIndex.
2020-05-22 12:53:34 +02:00
dan sinclair
3d01d1bf50 Roll SPIRV-Tools, SPIRV-Headers and GLSLang.
This CL rolls the various dependencies and updates the test files.
2020-05-21 15:21:41 -04:00
Hans-Kristian Arntzen
287e93ff80
Merge pull request #1370 from dj2/roll_deps_20
Roll dependencies
2020-05-21 13:18:50 +02:00
dan sinclair
8bf916f575 Roll dependencies
This CL updates the GLSLang, SPIRV-Tools and SPIRV-Headers dependencies.
2020-05-20 10:27:51 -04:00
Hans-Kristian Arntzen
b4dd0b6fb1 GLSL: Add more test shaders for hit attribute types. 2020-05-20 15:07:50 +02:00
Hans-Kristian Arntzen
66ec3e3e54 GLSL: Support ray payloads and hit attributes declared as Block. 2020-05-20 15:07:47 +02:00
Hans-Kristian Arntzen
271ad33380 GLSL: Add some more focused RT test shaders. 2020-05-20 14:11:28 +02:00
Hans-Kristian Arntzen
f3a362b1aa HLSL: Implement image queries for UAV images.
This was completely unimplemented for some reason.
2020-05-19 13:53:04 +02:00
Hans-Kristian Arntzen
86380acf4d Support gl_InstanceID in RT shaders. 2020-05-08 13:39:43 +02:00
Hans-Kristian Arntzen
107ab7c2b7 MSL: Avoid packed arrays in more cases.
Extend the array stride relaxation to non-packed arrays as well, as
long as the array in question contains a single array element.
2020-05-06 10:27:12 +02:00
Hans-Kristian Arntzen
de3698f0e0 Add missing reference files from PR merge. 2020-05-06 10:08:01 +02:00
Le Hoang Quyen
9ddfe6db6d Fix #1359: MSL: If the packed type is scalar, don't emit "pack_" prefix.
Scalar type is already packed in metal.
2020-05-06 00:43:34 +08:00
Hans-Kristian Arntzen
0ebb88cc39 MSL: Redirect member indices when buffer has been sorted by Offset.
If a buffer rewrites its Offsets, all member references to that struct
are invalidated, and must be redirected, do so in to_member_reference,
but there might be other places where this is needed. Fix as required.
SPIR-V code relying on this is somewhat questionable, but seems to be
in-spec.
2020-04-30 11:48:53 +02:00
Hans-Kristian Arntzen
d7d630a0b7
Merge pull request #1347 from KhronosGroup/fix-1343
Implement OpAtomicLoad/OpAtomicStore.
2020-04-27 15:29:21 +02:00
Hans-Kristian Arntzen
9b7140e2ba Implement OpAtomicLoad/OpAtomicStore.
Need some emulation on GLSL/HLSL, fix bug with atomic store on MSL.
2020-04-27 12:11:46 +02:00
Hans-Kristian Arntzen
6ef47d6657 MSL: Fix case where subpassInput is passed to leaf functions. 2020-04-27 11:29:21 +02:00
dan sinclair
171c646474 Roll GLSLang, SPIRV-Tools and SPIRV-Headers.
This CL rolls the various dependencies and updates tests to match.
2020-04-23 10:53:49 -04:00
Hans-Kristian Arntzen
5e5d1c27ce GLSL: Support f16x2 <-> f32 bitcast.
There is no native formulation, so introduce a concept of a "complex"
bitcast to handle odd-ball cases which have no native unary operation.
2020-04-21 23:27:33 +02:00
Hans-Kristian Arntzen
bdb343ea06 Be a bit more careful what nonuniform state is propagated. 2020-04-21 14:48:44 +02:00
Hans-Kristian Arntzen
5cb0f0a640
Merge pull request #1335 from KhronosGroup/fix-1325
GLSL/HLSL: Implement unpack/pack2x32Uint
2020-04-21 14:05:12 +02:00
Hans-Kristian Arntzen
7b9cba7424 HLSL: Add parens in unpackUint2x32 for clarity. 2020-04-21 11:49:26 +02:00
Hans-Kristian Arntzen
a396744f89 Ensure unpack/pack2x32 tests are compatible with test suite. 2020-04-21 11:48:58 +02:00
Asuka
55dfbead2f GLSL/HLSL: Support packUint2x32 and unpackUint2x32 2020-04-21 11:34:12 +02:00
Hans-Kristian Arntzen
f8592ecdfc MSL: Deal correctly with initializers on Private variables.
Do not attempt to defer declaration. It would happen to work in most
cases, but the edge case is where the first thing that happens to a
variable is being OpStore'd into.
2020-04-21 11:20:49 +02:00
Hans-Kristian Arntzen
17ad62eea4 MSL: Support edge case with DX layout in scalar block layout.
DX may emit ArrayStride and MatrixStride of 16, but the size of the
object does not align with that and expect to pack other members inside
its last member.

The workaround is to emit array size/col/row one less than we expect and
rely on padding to carve out a "dead zone" for the last member.
2020-04-20 15:29:24 +02:00
Hans-Kristian Arntzen
ebf463674d MSL: Allow removing clip distance user varyings.
Only safe if user knows that subsequent shader stage will not read clip
distance.
2020-04-20 09:58:40 +02:00
Panagiotis Christopoulos Charitos
b3109b8ad0 Reflection: Add specialization constant name
Fixes #1311
2020-04-18 22:00:36 +02:00
Chip Davis
96f7008aa8 MSL: Force disabled fragment builtins to have the right name.
DXVK emits SPIR-V where fragment shader builtins have names derived from
DXBC assembly, e.g. `oDepth` for `FragDepth`. When we declared the
disabled output, we used this name, but when referencing it, we
continued to use the GLSL name. This breaks compilation.
2020-04-15 19:25:18 -05:00
Chip Davis
495e48de44 MSL: Only disable output variables in fragment shaders.
Forgot to do this in #1319.

Fixes #1322.
2020-04-15 12:14:57 -05:00
Chip Davis
b29f83c383 MSL: Add options to control emission of fragment outputs.
Like with `point_size` when not rendering points, Metal complains when
writing to a variable using the `[[depth]]` qualifier when no depth
buffer be attached. In that case, we must avoid emitting `FragDepth`,
just like with `PointSize`.

I assume it will also complain if there be no stencil attachment and the
shader write to `[[stencil]]`, or it write to `[[color(n)]]` but there
be no color attachment at n.
2020-04-13 15:29:11 -05:00
Hans-Kristian Arntzen
c7b75a8fe6 MSL: Do not use base expression with PhysicalTypeID OpCompositeExtract.
Similar reasoning as packed expressions.
2020-04-07 18:25:44 +02:00
Hans-Kristian Arntzen
14f24d71ab
Merge pull request #1308 from KhronosGroup/fix-1306
HLSL: Add support for treating NonWritable UAV texture as SRV instead.
2020-04-03 17:42:56 +02:00
Hans-Kristian Arntzen
d9d3359ffb MSL: Deal with cases where builtin is implicitly needed, declared, but unused.
We need to make sure any builtins which are declared and unused are
emitted as active variables.
2020-04-03 12:50:21 +02:00
Hans-Kristian Arntzen
28bf9057df HLSL: Add support for treating NonWritable UAV texture as SRV instead. 2020-04-03 11:50:50 +02:00
Hans-Kristian Arntzen
3cb6aeb480 MSL: Fix access chain for deep struct hierarchy on array of buffers. 2020-03-31 14:17:29 +02:00
dan sinclair
32307df73a Roll GLSLang, SPIRV-Tools and SPIRV-Headers
This CL rolls the various dependencies and updates tests as needed.
2020-03-30 11:03:43 -04:00
Hans-Kristian Arntzen
b8905bbd95 Add support for forcefully zero-initialized variables.
Useful to better support certain platforms which require all variables
to be initialized to something.
2020-03-26 13:38:27 +01:00
Hans-Kristian Arntzen
04e877df12 GLSL: Implement GL_EXT_shader_framebuffer_fetch. 2020-03-19 14:53:39 +01:00
Hans-Kristian Arntzen
05004a57ea GLSL/HLSL: Fix nonuniform qualifier for SSBO atomics. 2020-03-19 12:05:27 +01:00
Hans-Kristian Arntzen
a3d3c80dd7 GLSL/HLSL: Implement nonuniform qualifier for image atomics. 2020-03-19 11:35:29 +01:00
Hans-Kristian Arntzen
185551bfaf HLSL: Do not emit globallycoherent for SRV ByteAddressBuffer. 2020-03-05 10:37:36 +01:00
Hans-Kristian Arntzen
95cd20f1c7 Add test for disable-storage-image-qualifier-deduction. 2020-03-04 16:42:31 +01:00
Hans-Kristian Arntzen
c27e1efbf1 HLSL: Add option to always treat SSBO as UAV, even with readonly.
This can make codegen more predictable since ByteAddressBuffer is SRV
and not UAV.
2020-03-04 16:42:31 +01:00
Hans-Kristian Arntzen
d91e134500 MSL: Add native array test for composite array initialization. 2020-02-24 13:34:51 +01:00
Hans-Kristian Arntzen
30343f3e95 MSL: Reintroduce workaround for constant arrays being passed by value. 2020-02-24 13:22:52 +01:00