Commit Graph

177 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
ec42cb1c41 Roll deps. 2024-01-05 13:36:34 +01:00
Try
967ad0bb4d Fix unroll, when storing to pointer to array
#fixed #2196
2023-09-28 23:58:51 +02:00
Hans-Kristian Arntzen
bf752edaa4 Update test output for preserve structured. 2023-05-19 11:38:12 +02:00
Laura Hermanns
578bdf410b Added tests for HLSL structured buffers. 2023-05-17 13:52:24 -04:00
Try
dd8839c6f9 task shader initial 2023-03-18 17:20:16 +01:00
rdb
53974b4fae GLSL/HLSL: Add emulated fallbacks for sinh/cosh/tanh/asinh/acosh/atanh
The inverse hyperbolic functions are not supported in HLSL, and none of them are supported in legacy GLSL.
2023-01-26 19:40:42 +01:00
rdb
26da9c58a6 HLSL: Support PointSize output in vertex shader in SM 3.0 2023-01-17 23:42:04 +01:00
rdb
4ba13e0c1a GLSL/HLSL: Add legacy handling for int vertex attributes 2023-01-14 18:57:24 +01:00
Hans-Kristian Arntzen
ebf779dcfb HLSL: Do not support ClipCull size > 4 in mesh shaders.
The array mechanism breaks DXC which needs to observe that all
components have been written.

Uninitialized outputs will be undefined. Resort to simple vector
instead.
2022-11-02 13:34:11 +01:00
Hans-Kristian Arntzen
f5ef0a74fb HLSL: Make sure to test deeply nested functions in mesh shaders. 2022-11-02 12:56:10 +01:00
Try
80146a20da HLSL: Implement VK_EXT_mesh_shader 2022-11-02 11:48:58 +01:00
Hans-Kristian Arntzen
d08ce828f4 Promote Unreachable cases into break to avoid fallthrough.
HLSL is very fussy about fallthrough in switch blocks, so promote
Unreachable blocks to breaks if they are inside a switch construct.

Some false positives are possible in weird multi-break scenarios, but
this is benign.
2022-05-18 18:36:32 +02:00
Hans-Kristian Arntzen
a7eefbc114 HLSL: Disable FXC testing for rayquery shaders.
Manually tested that it compiles on DXC.
2022-03-22 12:34:43 +01:00
Hans-Kristian Arntzen
c95338e03e Merge branch 'ray_query' of https://github.com/k-payl/SPIRV-Cross into pr-1859 2022-03-22 12:29:49 +01:00
Konstantin Pail
251361bd6f VK_KHR_ray_query implementation 2022-03-15 21:54:29 +03:00
Hans-Kristian Arntzen
31be74a853 Add relax_nan_checks options.
Makes codegen from typical D3D emulation SPIR-V more readable.
Also makes cross compilation with NotEqual more sensible.
It's very rare to actually need the strict NaN-checks in practice.

Also, glslang now emits UnordNotEqual by default it seems, so give up
trying to assume OrdNotEqual. Harmonize for UnordNotEqual as the sane
default.
2022-03-03 14:50:56 +01:00
Shintaro Sakahara
ed4ded040e HLSL: Make --flatten-ubo work correctly 2022-02-16 21:53:24 +09:00
Hans-Kristian Arntzen
fe8848a6f2 Roll dependencies. 2022-01-05 14:56:01 +01: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
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
Tomek Ponitka
ba58f78395 Adding BuiltInSampleMask in HLSL 2020-07-27 14:14:26 +02:00
Hans-Kristian Arntzen
d13dc0ce47 HLSL: Fix texProj in legacy HLSL. 2020-06-16 12:54:22 +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
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
28bf9057df HLSL: Add support for treating NonWritable UAV texture as SRV instead. 2020-04-03 11:50:50 +02:00
Hans-Kristian Arntzen
185551bfaf HLSL: Do not emit globallycoherent for SRV ByteAddressBuffer. 2020-03-05 10:37:36 +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
ca9398c122 HLSL: Support loading complex composites from ByteAddressBuffer. 2020-01-08 13:05:56 +01:00
Dan Sinclair
d409210ee5 Move all .invalid shaders into no-opt folders. 2019-11-05 13:19:19 -05:00
Hans-Kristian Arntzen
a9be92569f HLSL: Fix unrolled S/G LE/LT/GE/GT opcodes.
Need to bitcast the unrolled expressions as well.
2019-10-14 16:08:39 +02:00
Chip Davis
2eff420d9a Support the SPV_EXT_fragment_shader_interlock extension.
This was straightforward to implement in GLSL. The
`ShadingRateInterlockOrderedEXT` and `ShadingRateInterlockUnorderedEXT`
modes aren't implemented yet, because we don't support
`SPV_NV_shading_rate` or `SPV_EXT_fragment_invocation_density` yet.

HLSL and MSL were more interesting. They don't support this directly,
but they do support marking resources as "rasterizer ordered," which
does roughly the same thing. So this implementation scans all accesses
inside the critical section and marks all storage resources found
therein as rasterizer ordered. They also don't support the fine-grained
controls on pixel- vs. sample-level interlock and disabling ordering
guarantees that GLSL and SPIR-V do, but that's OK. "Unordered" here
merely means the order is undefined; that it just so happens to be the
same as rasterizer order is immaterial. As for pixel- vs. sample-level
interlock, Vulkan explicitly states:

> With sample shading enabled, [the `PixelInterlockOrderedEXT` and
> `PixelInterlockUnorderedEXT`] execution modes are treated like
> `SampleInterlockOrderedEXT` or `SampleInterlockUnorderedEXT`
> respectively.

and:

> If [the `SampleInterlockOrderedEXT` or `SampleInterlockUnorderedEXT`]
> execution modes are used in single-sample mode they are treated like
> `PixelInterlockOrderedEXT` or `PixelInterlockUnorderedEXT`
> respectively.

So this will DTRT for MoltenVK and gfx-rs, at least.

MSL additionally supports multiple raster order groups; resources that
are not accessed together can be placed in different ROGs to allow them
to be synchronized separately. A more sophisticated analysis might be
able to place resources optimally, but that's outside the scope of this
change. For now, we assign all resources to group 0, which should do for
our purposes.

`glslang` doesn't support the `RasterizerOrdered` UAVs this
implementation produces for HLSL, so the test case needs `fxc.exe`.

It also insists on GLSL 4.50 for `GL_ARB_fragment_shader_interlock`,
even though the spec says it needs either 4.20 or
`GL_ARB_shader_image_load_store`; and it doesn't support the
`GL_NV_fragment_shader_interlock` extension at all. So I haven't been
able to test those code paths.

Fixes #1002.
2019-09-02 12:31:10 -05:00
Chip Davis
50dce10c5d Support the SPV_EXT_demote_to_helper_invocation extension.
This extension provides a new operation which causes a fragment to be
discarded without terminating the fragment shader invocation. The
invocation for the discarded fragment becomes a helper invocation, so
that derivatives will remain defined. The old `HelperInvocation` builtin
becomes undefined when this occurs, so a second new instruction queries
the current helper invocation status.

This is only fully supported for GLSL. HLSL doesn't support the
`IsHelperInvocation` operation and MSL doesn't support the
`DemoteToHelperInvocation` op.

Fixes #1052.
2019-07-17 09:12:22 -05:00
Chip Davis
343c6f4ff4 Update external repos.
Fix fallout from changes.

There's a bug in glslang that prevents `float16_t`, `[u]int16_t`, and
`[u]int8_t` constants from adding the corresponding SPIR-V capabilities.
SPIRV-Tools, meanwhile, tightened validation so that these constants are
only valid if the corresponding `Float16`, `Int16`, and `Int8` caps are
on. This affects the `16bit-constants.frag` test for GLSL and MSL.
2019-07-13 16:50:21 -05:00
Hans-Kristian Arntzen
50342966c0 Fall back to complex loop if non-trivial continue block is found.
There is a case where we can deduce a for/while loop, but the continue
block is actually very painful to deal with, so handle that case as
well. Removes an exceptional case.
2019-07-08 11:54:29 +02:00
Hans-Kristian Arntzen
041f103d44 MSL/HLSL: Support scalar reflect and refract. 2019-07-03 12:31:52 +02:00
Hans-Kristian Arntzen
f8b084de61 MSL/HLSL: Support OpOuterProduct. 2019-07-01 10:57:27 +02:00
Hans-Kristian Arntzen
ff87419607 Deal with scalar input values for distance/length/normalize.
HLSL and MSL don't support it, so fall back to simpler intrinsics.
2019-06-28 11:20:14 +02:00
Hans-Kristian Arntzen
c76b99b711 Handle more cases with FP16 and texture sampling. 2019-06-27 15:04:22 +02:00
Hans-Kristian Arntzen
65af09d2d1 Support emitting OpLine directive.
Facilitates easier mapping from source language to cross-compiled output
in tooling.
2019-05-28 13:44:24 +02:00
Hans-Kristian Arntzen
647ddaee42 HLSL/MSL: Deal correctly with nonuniformEXT qualifier.
MSL does not seem to have a qualifier for this, but HLSL SM 5.1 does.
glslangValidator for HLSL does not support this, so skip any validation,
but it passes in FXC.
2019-05-13 14:58:27 +02:00
Hans-Kristian Arntzen
e9da5ed631 HLSL: Support OpArrayLength. 2019-05-07 15:53:41 +02:00
Hans-Kristian Arntzen
2a0365c813 GLSL/HLSL: Implement NMin/NMax/NClamp.
Need to emulate these calls for correctness.
2019-03-21 15:26:46 +01:00
Hans-Kristian Arntzen
a4ac27546a MSL: Fix textures which are sampled and compared against.
depth2d in MSL only returns float, not float4, even for normal sampling.
We need to conditionally remap-swizzle back to float4.
2019-02-22 12:27:40 +01:00
Hans-Kristian Arntzen
056a0ba27e Fix case where a struct is loaded which contains a row-major matrix. 2019-02-20 12:19:00 +01:00
Hans-Kristian Arntzen
3e584f2c3f Support LUTs in single-function CFGs on Private storage class.
Fairly common pattern in unoptimized SPIR-V. Support this case as well.
2019-02-06 10:38:59 +01:00
Hans-Kristian Arntzen
4e7777c443 Update to latest glslang/SPIRV-Tools.
Fix various bugs along the way.
2019-01-30 13:41:57 +01:00
Hans-Kristian Arntzen
3e09879131 Support initializers on StorageClassOutput. 2019-01-30 10:29:08 +01:00
Hans-Kristian Arntzen
a365ff17bd HLSL: Support dual-source blending. 2019-01-11 10:03:45 +01:00