Commit Graph

400 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
325f107c5b
Merge pull request #1745 from billhollings/location-component-vecsize
MSL: Track location component to match vecsize between shader stages.
2021-09-30 14:02:25 +02:00
Bill Hollings
5742047b24 MSL: Honor infinities in OpQuantizeToF16 when compiling using fast-math.
Add spvQuantizeToF16() family of synthetic functions to convert
from float to half and back again, and add function attribute
[[clang::optnone]] to honor infinities during conversions.

Adjust SPIRV-Cross unit test reference shaders to accommodate these changes.
2021-09-24 11:22:05 -04:00
Bill Hollings
548a23da34 MSL: Track location component to match vecsize between shader stages.
Matching output/input struct member types between shader stages could fail if
a location is shared between members, each using different components of that
location, because the member vecsize was only stored once for the location.

Add MSLShaderInput::component member.
Use LocationComponentPair to key inputs_by_location, instead of just location.
ensure_correct_input_type() pass component value as well as location.
2021-09-23 09:56:04 -04:00
Bill Hollings
86dfac12c8 MSL: Fix location and component variable matching between shader stages.
Consolidate derivation of Metal 'user(locnL_C)' output/input location
and component attribute qualifier, to establish SVOT across stages.
2021-09-18 18:55:12 -04:00
Bill Hollings
5fb1ca4f0d Add support for additional ops in OpSpecConstantOp.
MSL: Support op OpQuantizeToF16 in OpSpecConstantOp.
All: Support op OpSRem in OpSpecConstantOp.
2021-09-03 18:20:49 -04: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
Jon Leech
f2a65545b8 Finish adding SPDX tags and setup a reuse checked in Github Actions CI 2021-06-29 11:03:52 +02:00
Hans-Kristian Arntzen
d62b3c2b92 GLSL: Implement control flow hints. 2021-06-03 12:01:49 +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
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
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
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
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
faf80b08fc MSL: Don't report fallback location allocations as being "used".
It may shadow unused *real* inputs and confuse applications.
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
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
425e968720 MSL: Handle flattening of patch block outputs as well.
Always propagate InterfaceMember decoration.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
6ecdd64a91 MSL: Emit a masked builtin IO block if necessary. 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
f2b5fb3f45 MSL: Emit threadgroup storage class for masked control point outputs.
Shader can still rely on writes to threadgroup memory to be visible.
2021-04-19 12:10:49 +02:00
Hans-Kristian Arntzen
9a144bb2b9 Clean up member sorting. 2021-04-19 12:10:49 +02:00
Bill Hollings
b3bfe22eaa MSL: Fixes to support padding Metal argument buffer entries based on argument index.
For buffers, support all MSLResourceBinding::basetype pointers, not just void*.
Rename MSLResourceBinding::base_type to basetype for consistent use in other structs.
2021-04-18 17:34:55 -04:00
Bill Hollings
daba0dfba6 MSL: Fixes to support padding Metal argument buffer entries based on argument index.
For completeness, add [[id(N)]] qualifier to padding struct members.
Run clang-format.
2021-04-17 15:20:53 -04:00
Bill Hollings
9060e5a13c MSL: Fixes to support padding Metal argument buffer entries based on argument index.
Use separate lookups for texture and sampler members when padding for SamplerImages.
Remove unreachable code following SPIRV_CROSS_THROW.
2021-04-16 15:00:59 -04:00
Bill Hollings
9866cf4496 MSL: Fixes to support padding Metal argument buffer entries based on argument index.
Add lookup from argument buffer argument index to resource binding for efficiency.
Fix error in advancing padding counts with combined image samplers.
Run clang-format.
2021-04-16 09:05:15 -04:00
Bill Hollings
17dab614dc MSL: Support padding Metal argument buffer entries based on argument index.
If CompilerMSL::Options::pad_argument_buffer_resources enabled, Metal argument buffer
struct members are positionally aligned to their argument indexes by adding synthetic
padding members when needed. The types and sizes of these synthetic members are
identified in the resource_bindings vector provided through the API.

Add CompilerMSL::Options::pad_argument_buffer_resources to enable padding
Metal argument buffer structs to positionally match members to argument indexes.
Add MSLResourceBinding::base_type to identify resource type through API.
2021-04-13 19:01:20 -04: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
aa271c1460 MSL: Refactor out location consumption count computation. 2021-02-17 11:29:33 +01:00
Hans-Kristian Arntzen
6f1f6775f3 Add comment where aux image atomic buffers are reflected from.
They also use secondary bindings, not just samplers.
2021-02-17 10:42:58 +01:00
Hans-Kristian Arntzen
4704482bbc meta: Update copyright headers to 2021. 2021-01-14 16:07:49 +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
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
cf1e9e0643 Add MIT dual license for the SPIRV-Cross API. 2020-12-01 16:47:08 +01: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
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
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
Hans-Kristian Arntzen
244839d350
Merge pull request #1516 from billhollings/VK_EXT_descriptor_indexing
MSL: Support run-time sized image and sampler arrays
2020-11-03 10:15:36 +01:00
Bill Hollings
4bdd49df3f Syntax and format updates from code review. 2020-11-02 22:15:20 -05:00
Bill Hollings
b7b0e804e5 MSL: Support run-time sized image and sampler arrays
(GL_EXT_nonuniform_qualifier/SPV_EXT_descriptor_indexing).

MSLResourceBinding includes array size through API, and substitutes
in that size if the image or sampler array is not explicitly sized.
OpCopyObject supports SPIRCombinedImageSampler type in MSL.
2020-10-29 18:50:42 -04: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
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
Hans-Kristian Arntzen
9c220a8247
Merge pull request #1490 from KhronosGroup/fix-1488
MSL: Support querying and modifying generated combined sampler suffix.
2020-10-15 10:52:28 +02: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
Hans-Kristian Arntzen
bd1ee4344e MSL: Support querying and modifying generated combined sampler suffix. 2020-10-14 14:52:18 +02: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
Hans-Kristian Arntzen
bdbef7b1f3
Merge pull request #1461 from Kangz/fix-warnings
Fix -Wduplicate-enum and -Wrange-for-analysis.
2020-09-04 12:59:22 +02:00
Corentin Wallez
bcd71536e2 Fix -Wduplicate-enum and -Wrange-for-analysis. 2020-09-04 11:13:21 +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
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
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
Chip Davis
884bc6df65 MSL: Factor creating a uint type into its own method.
This is so common for artificially created variables that it's worth it
to create it once and save it for later use.
2020-07-22 16:25:14 -05:00
Chip Davis
5e13f7fdf2 MSL: Factor a really gnarly condition into its own method.
That branch has become nigh unreadable. This new method should make it
readable again.
2020-07-22 16:25:10 -05: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
d573a95a9c Run format_all.sh. 2020-07-01 11:42:58 +02:00
Hans-Kristian Arntzen
f9da366ae6 MSL: Remove the old VertexAttr API.
Too many issues with deprecated declarations on various compilers, just
get rid of it.
2020-06-22 11:14:24 +02:00
Corentin Wallez
8aee532f56 Fix placement of SPIRV_CROSS_DEPRECATED.
The [[deprecated]] attribute is supposed to be in front of a typedef,
not after the typedef keyword.
2020-06-19 14:28:00 +02:00
Hans-Kristian Arntzen
11832b6e14 Clean up some deprecation warnings when building with Makefile. 2020-06-18 10:07:31 +02:00
Hans-Kristian Arntzen
5e509b159a Remove unused member in MSLShaderInput.
Missed in review.
2020-06-18 10:07:17 +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
553a7f959b
Merge pull request #1385 from KhronosGroup/fix-1237
GLSL: Implement sparse feedback.
2020-06-08 11:12:00 +02:00
Hans-Kristian Arntzen
cbe0cca73b Refactor texture fetch function generation.
Use structs instead of a million bool/uint32_t arguments passed on stack.
2020-06-08 10:17:40 +02:00
Hans-Kristian Arntzen
275974e062 GLSL: Implement sparse feedback. 2020-06-04 15:50:28 +02:00
Hans-Kristian Arntzen
6600793884 MSL: Remove obsolete MSLVertexAttr members.
These are completely unused. Need to keep the members around for ABI
compatbility however ...
2020-06-04 12:43:04 +02:00
Hans-Kristian Arntzen
6ef47d6657 MSL: Fix case where subpassInput is passed to leaf functions. 2020-04-27 11:29:21 +02: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
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
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
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
c9d4f9cd74 MSL: Add a workaround path to force native arrays for everything. 2020-02-24 12:47:14 +01:00
Chip Davis
ae6c05f6f4 MSL: Move inline uniform blocks to the end of the argument buffer.
Limit inline blocks to one per descriptor set.

This should avoid the need for complicated code to calculate the
argument buffer ID stride of an inline uniform block. If there's demand
for more inline blocks, we can revisit this.
2020-01-25 13:40:51 -06:00
Chip Davis
fedbc35315 MSL: Support inline uniform blocks in argument buffers.
Here, the inline uniform block is explicit: we instantiate the buffer
block itself in the argument buffer, instead of a pointer to the buffer.
I just hope this will work with the `MTLArgumentDescriptor` API...

Note that Metal recursively assigns individual members of embedded
structs IDs. This means for automatic assignment that we have to
calculate the binding stride for a given buffer block. For MoltenVK,
we'll simply increment the ID by the size of the inline uniform block.
Then the later IDs will never conflict with the inline uniform block. We
can get away with this because Metal doesn't require that IDs be
contiguous, only monotonically increasing.
2020-01-24 18:51:24 -06:00
Hans-Kristian Arntzen
f9818f0804 Update license headers to 2020. 2020-01-16 15:24:37 +01:00
Hans-Kristian Arntzen
c3bd136df1 MSL: Add support for force-activating IAB resources.
Important for ABI compatibility on MSL in certain cases.
2020-01-16 11:12:06 +01:00
Hans-Kristian Arntzen
cc153f8d7f HLSL: Add a resource remapping API similar to MSL.
Allows more flexibility of how resources are assigned without having to
remap decorations.
2020-01-09 12:41:06 +01:00
Hans-Kristian Arntzen
93f3265fe0 MSL: Deal with packing vectors for vertex input/fragment output. 2020-01-07 14:14:31 +01:00
Hans-Kristian Arntzen
123fa906ec Merge branch 'ue4-merge' 2019-10-28 15:14:42 +01:00
Hans-Kristian Arntzen
39bd5f1834 Run format_all.sh. 2019-10-28 12:55:14 +01:00
Hans-Kristian Arntzen
1d5eba67f8 MSL: Remove hacky workaround for patch constant passing.
There was a hack to workaround a bug in DXC where control point -> patch
constant phase was passed in Function storage, but we have to use
Workgroup here. We will not support these kinds of hacks for invalid
SPIR-V, so hack the reference files to use the "proper" fix and remove
the hack for time being.
2019-10-28 12:52:28 +01:00
Hans-Kristian Arntzen
27d6d45671 MSL: Rewrite tessellation_access_chain.
To support loading array of array properly in tessellation, we need a
rewrite of how tessellation access chains are handled.

The major change is to remove the implicit unflatten step inside
access_chain which does not take into account the case where you load
directly from a control point array variable.

We defer unflatten step until OpLoad time instead.
This fixes cases where we load array of {array,matrix,struct}.

Removes the hacky path for MSL access chain index workaround.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
8066d13599 MSL: Rewrite propagated depth comparison state handling.
Far cleaner, and more correct to run the traversal twice.
Fixes a case where we propagate depth state through multiple functions.
2019-10-26 16:10:11 +02:00
Bill Hollings
4b5c6c188c MSL: Support option for treating 1D textures as 2D textures of height 1.
Add CompilerMSL::Options::texture_1D_as_2D.

Metal imposes significant restrictions on 1D textures, including not being
renderable, clearable, or permitting mipmaps. This option allows SPIR-V 1D
textures to be treated as 2D textures to permit this additional behaviour.
App must of course supply the textures to Metal as 2D textures.
2019-10-24 12:31:20 -04:00
Hans-Kristian Arntzen
4ac12594c9 MSL: Be a little clearer how needs_base_vertex_idx is implemented.
There is an implicit tristate with {-1, 0, +1} values, but it was not
obvious how this was supposed to work before studying the implementation,
so refactor into a tristate enum class.
2019-10-24 12:41:37 +02:00
Hans-Kristian Arntzen
6ca3fe22c3 MSL: Remove some dead code w.r.t. vertex/instance_idx. 2019-10-24 12:36:01 +02:00
Hans-Kristian Arntzen
6edbf0c9e9 MSL: Minor cleanups for texture atomic emulation.
Storing pointers to internal objects is generally not done, IDs are
preferred.
2019-10-24 11:30:20 +02:00
Lukas Hermanns
b0d616aa6d Removed 'argument_buffer_offset' and fixed packed matrix Metal output. 2019-10-23 16:28:32 -04:00
Lukas Hermanns
6673a675ba Simplified overriding of 'access_chain_internal' function in CompilerMSL. 2019-10-22 11:06:16 -04:00
Lukas Hermanns
84351d3aed Merge remote-tracking branch 'upstream/master' 2019-10-21 18:55:36 -04:00
Lukas Hermanns
e1b161b54b Removed bounds checks in favor of SPIRV-Tools pass '--graphics-robust-access' 2019-10-21 16:39:53 -04:00
Hans-Kristian Arntzen
4bb673a626 MSL: Add opt-in support for huge IABs.
If there are enough members in an IAB, we cannot use the constant
address space as MSL compiler complains about there being too many
members. Support emitting the device address space instead.
2019-10-14 16:20:34 +02:00
Lukas Hermanns
ffbd801853 Added '--msl-invariant-float-math' option and new test case for it. 2019-10-09 14:03:06 -04:00