Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-11-23MSL: Adjust FragCoord for sample-rate shading.Chip Davis
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-09MSL: extract global variables from subgroup ballot operationsJan Sikorski
Fixes #1513.
2020-11-05MSL: Support pull-model interpolation on MSL 2.3+.Chip Davis
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-10-30MSL: Allow Bias and Grad arguments with comparison on Mac in MSL 2.3.Chip Davis
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-28MSL: Allow post-depth coverage on Mac in MSL 2.3.Chip Davis
It's still only supported on Apple GPUs, but Macs will have those soon.
2020-10-21MSL: Don't remove periods from swizzle buffer index exprs.Chip Davis
2020-10-15MSL: Handle Offset and Grad operands for 1D-as-2D textures.Chip Davis
2020-10-15MSL: Don't use a bitcast for tessellation levels in tesc shaders.Chip Davis
`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-13MSL: Add missing interlock handling to atomic image buffers.Chip Davis
2020-10-13Merge pull request #1486 from cdavis5e/atomic-image-argument-bufferHans-Kristian Arntzen
MSL: Support atomic access to images from argument buffers.
2020-10-13MSL: Support atomic access to images from argument buffers.Chip Davis
This was not added when Epic contributed atomic image support. Fixes #1484.
2020-10-13MSL: Support SPV_EXT_demote_to_helper_invocation for MSL 2.3.Chip Davis
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-09-02MSL: Support layered input attachments.Chip Davis
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-02MSL: Don't set the layer for multiview if the device doesn't support it.Chip Davis
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-08-13Fix #1445: MSL: Enclose args when convert distance(a,b) to abs(a-b)Le Hoang Quyen
2020-08-04MSL: Fix handling of matrices and structs in the output control point array.Chip Davis
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-07-24Enabling setting a fixed sampleMask in Metal fragment shaders.Tomek Ponitka
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-24MSL: Add support for processing more than one patch per workgroup.Chip Davis
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-06-16MSL: Fix up input variables' vector lengths in all stages.Chip Davis
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-05-05Fix #1359: MSL: If the packed type is scalar, don't emit "pack_" prefix.Le Hoang Quyen
Scalar type is already packed in metal.
2020-04-20MSL: Allow removing clip distance user varyings.Hans-Kristian Arntzen
Only safe if user knows that subsequent shader stage will not read clip distance.
2020-04-16MSL: Force disabled fragment builtins to have the right name.Chip Davis
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-15MSL: Only disable output variables in fragment shaders.Chip Davis
Forgot to do this in #1319. Fixes #1322.
2020-04-13MSL: Add options to control emission of fragment outputs.Chip Davis
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-02-24MSL: Add native array test for composite array initialization.Hans-Kristian Arntzen
2020-02-24MSL: Reinstate workaround for returning arrays.Hans-Kristian Arntzen
2020-02-24MSL: Add a workaround path to force native arrays for everything.Hans-Kristian Arntzen
2020-01-25MSL: Support inline uniform blocks in argument buffers.Chip Davis
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.
2019-12-02MSL: Support ClipDistance as an input stage variable.Hans-Kristian Arntzen
MSL does not support this, so we have to emulate it by passing it around as a varying between stages. We use a special "user(clipN)" attribute for this rather than locN which is used for user varyings.
2019-11-28MSL: Fix automatic binding allocation for image atomic buffers.Hans-Kristian Arntzen
The Primary decoration was used by the atomic buffer, causing the texture binding to be potentially overlapping with other resources.
2019-11-05Move all .invalid shaders into no-opt folders.Dan Sinclair
2019-10-26MSL: Fix array of array declaration.Hans-Kristian Arntzen
Arrays-of-arrays were declared in wrong order.
2019-10-26MSL: Rewrite tessellation_access_chain.Hans-Kristian Arntzen
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-26MSL: Rewrite propagated depth comparison state handling.Hans-Kristian Arntzen
Far cleaner, and more correct to run the traversal twice. Fixes a case where we propagate depth state through multiple functions.
2019-10-24MSL: Do not declare complex composite array in main for non-inlined.Hans-Kristian Arntzen
Need to consider that complex composite arrays may be used in leaf functions, and avoid the MSL library link fix unless everything is nicely inlined.
2019-10-24Moved all UE4 test shaders into 'shaders-ue4/' folder.Lukas Hermanns
2019-10-22Merge remote-tracking branch 'upstream/master'Lukas Hermanns
2019-10-21Removed bounds checks in favor of SPIRV-Tools pass '--graphics-robust-access'Lukas Hermanns
2019-10-14Merge pull request #1175 from KhronosGroup/fix-1164Hans-Kristian Arntzen
Implement unordered compare on GLSL/HLSL.
2019-10-14MSL: Add opt-in support for huge IABs.Hans-Kristian Arntzen
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-14HLSL: Fix unrolled S/G LE/LT/GE/GT opcodes.Hans-Kristian Arntzen
Need to bitcast the unrolled expressions as well.
2019-10-09Added '--msl-invariant-float-math' option and new test case for it.Lukas Hermanns
2019-09-27Further updates for pull request #1162; also added two test cases for ↵Lukas Hermanns
spvCubemapTo2DArrayFace function and added '--msl-framebuffer-fetch'/ '--msl-emulate-cube-array' compiler options.
2019-09-20Merge branch 'ue4_dev'Lukas Hermanns
2019-09-18Update external/ to SPIR-V 1.5Ryan Harrison
Rolled the hashes used for glslang, SPIRV-Tools, and SPIRV-Headers to HEAD, which includes the update to 1.5. Added passing '--amb' to glslang, so I didn't have to explicitly set bindings in a large number of test shaders that currently don't, and now glslang considers them invalid. Marked all shaders that no longer pass spirv-val as .invalid.
2019-09-16Renamed new test shaders to fit the naming convention in SPIRV-Cross.Lukas Hermanns
2019-09-13Removed all '.DS_Store' files.Lukas Hermanns
2019-09-06MSL: Support dynamic offsets for buffers in argument buffers.Chip Davis
Vulkan has two types of buffer descriptors, `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC` and `VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC`, which allow the client to offset the buffers by an amount given when the descriptor set is bound to a pipeline. Metal provides no direct support for this when the buffer in question is in an argument buffer, so once again we're on our own. These offsets cannot be stored or associated in any way with the argument buffer itself, because they are set at bind time. Different pipelines may have different offsets set. Therefore, we must use a separate buffer, not in any argument buffer, to hold these offsets. Then the shader must manually offset the buffer pointer. This change fully supports arrays, including arrays of arrays, even though Vulkan forbids them. It does not, however, support runtime arrays. Perhaps later.
2019-09-05MSL: Force storage images on iOS to use discrete descriptors.Chip Davis
Writable textures cannot use argument buffers on iOS. They must be passed as arguments directly to the shader function. Since we won't know if a given storage image will have the `NonWritable` decoration at the time we encode the argument buffer, we must therefore pass all storage images as discrete arguments. Previously, we were throwing an error if we encountered an argument buffer with a writable texture in it on iOS.
2019-09-03Port the UE4 spirv shaders to ASM shaders that can be used in the test-rig - ↵Mark Satterthwaite
this will help show why the changes are required.