Commit Graph

262 Commits

Author SHA1 Message Date
FrostyLeaves
153064f2c7 fix: Support SV_ViewID keywords for hlsl. 2023-11-22 17:04:38 -05:00
Nathaniel Cesario
a1f8cd429f Fix ByteAddressBuffer as function parameter
Make sure that an id represents a variable before adding it to an entry
point's interface.

Fixes #3297.
2023-08-31 16:22:03 -06:00
Dawid-Lorenz-Mobica
d5f3ad6c9a
HLSL: support binary literals
Fixes #3089
2023-07-18 09:35:36 -06:00
Arcady Goldmints-Orlov
68f073b195 Add a test for empty structs in HLSL hull shaders 2023-04-13 09:49:00 -04:00
Arcady Goldmints-Orlov
adcc7e8163 Add tests for conditionals that return a struct value
There are 3 separate tests added to cover the 3 cases in
visitSelection(). With SPIR-V versions prior to 1.4, control flow is
generated, with GLSL generating code to execute only the appropriate
branch of the conditional while HLSL executes both branches and uses the
control flow to select the appropriate one. Finally, with SPIR-V
versions newer than 1.4, OpSelect can be used on structs.

Note that the hlsl.structcopy.comp and hlsl.structcopylogical.comp tests
have identical shader code, but are compiled with different versions of
SPIR-V and result in different codepaths being used and different SPIR-V
generated.
2023-04-03 12:33:59 -04:00
Maciej
d604f26843 Add test 2023-02-02 16:33:32 -07:00
Jeremy Hayes
7a914ce926 Implement NonSemantic.Shader.DebugInfo.100
See https://github.com/KhronosGroup/SPIRV-Registry.
2022-08-26 16:17:54 -06:00
Gabriele Di Bari
353ef3ac3e Add test for the instance param (geometry shader) 2022-05-24 18:53:39 +02:00
Greg Fischer
9ebd8ff6c1 Add Vulkan 1.3 support
Also update known goods to Vulkan 1.3 support
Also re-enable SPIR-V 1.6 tests with vulkan1.3 target
Also re-cache SPIRV 1.6 header which somehow regressed back to 1.5
2022-01-26 17:57:31 -07:00
Greg Fischer
140a76a447 Temporarily disable spirv1.6 tests
These tests will be re-enabled when a Vulkan version is released that
supports spirv1.6.

Fixes #2858
2022-01-11 13:13:50 -07:00
Greg Fischer
7a49192d23 Add support for spirv1.6
Add command line support which enables the following behavior:

- Remap discard

  Map discard to DemoteToHelperInvocation for HLSL shaders. Map to
  OpTerminateInvocation for GLSL shaders.

- Decorate HelperInvocation with Volatile

- Use localSizeId for execution mode

  WorkGroupSize is deprecated in spirv1.6

Also update known goods to SPIRV 1.6
2021-12-16 15:01:42 -07:00
Greg Fischer
10be28ac9b Fix struct type sharing
Fixes #2812
2021-11-12 16:57:11 -07:00
Nathan Reed
fc9897d1ba
Fix OpImageRead result type when compiling HLSL (#2706)
Fix OpImageRead result type when compiling HLSL

- Per the Vulkan spec, OpImageRead must return a 4-component vector always. When compiling HLSL, loads from a RWTexture of a template type with < 4 components would incorrectly generate an OpImageRead with a < 4 component result, resulting in validation errors.
- This was previously fixed for OpImageFetch in commit 4425f24; this commit does the same thing for OpImageRead.
- Added associated tests and expanded existing image fetch tests to check all the different types of textures, in both float and int incarnations, for completeness.
- Update other HLSL tests involving OpImageRead
2021-07-28 09:29:17 -06:00
Greg Fischer
7fbaca0d06 Fix SPIR-V for HLSL EvaluateAttribute* of interpolants in structs
Generate load of interpolant for first operand to GLSLstd450
InterpolateAt* SPIR-V ops. This allows the interpolants to
propagate from the input struct in the wrapper around main
into the shader during HLSL legalization. A new pass has been
added to legalization which will remove the load and replace
with the pointer of the load to create valid external
interpolate op.

Fixes #2584
2021-04-01 00:31:31 -06:00
rdb
589aaff11c Don't use roundEven() to implement round() in DX9 compatibility mode 2020-12-16 18:35:42 +01:00
Rex Xu
f6e0fe8600 HLSL: Add support for printf().
Translate printf() to what GL_EXT_debug_printf has done. HLSL could
define non-constant string variable and we don't have such features
in SPIR-V, so just support constant string variable.
2020-10-24 22:10:13 +08:00
Rémi Verschelde
69d0c1acc2
Remove executable bits from code/data files (#2420) 2020-10-12 10:08:47 -06:00
johnkslang
23f3bdfea1 Build/Test: Dropping 2013 allows using the latest googletests.
These have a new spelling: INSTANTIATE_TEST_CASE_P -> INSTANTIATE_TEST_SUITE_P
2020-08-05 11:07:07 -06:00
lriki
1ee750aed5 Add pack_matrix test 2020-06-25 17:54:16 +09:00
rdb
78a3c915a1
HLSL: Add better diagnostic when using in/out qualifiers in global scope (#2258) 2020-06-02 00:32:35 -06:00
greg-lunarg
e00d27c6d6
Fix missing patch decoration for TessFactor PCF arg (#2249)
Fixes #1553
2020-05-27 22:12:42 -06:00
John Kessenich
abfc4c2ceb Fix part of #2070: Correctly handle promotion for <unary-op>(int).
This still only handles a scalar correctly, and some
vector cases need additional fixes.
2020-02-18 06:53:39 -07:00
John Kessenich
2d9b0a3550 HLSL: Fix #1912: add attribute syntax for overriding image formats. 2019-09-28 11:39:15 -06:00
John Kessenich
4b4b41a634 HLSL: Fix #1815: Don't constant fold spec-constant array indexing. 2019-07-03 01:28:51 -06:00
John Kessenich
cfea59d357 SPV 1.4: Add testing infrastructure for SPV 1.4 tests.
This includes the test for the first feature of OpEntryPoint.
2019-05-10 00:02:45 -06:00
John Kessenich
544c039d26 HLSL: Fix #1679: Add HLSL earlydepthstencil -> SPV EarlyFragmentTests. 2019-01-28 22:19:43 -07:00
Greg Fischer
5620a2f95e Add passes to legalization to preserve source line info when generated. 2018-12-16 13:13:46 -07:00
Rémi Verschelde
ebfd91a719 Remove Unix executable permission from text files 2018-12-10 10:49:16 +01:00
John Kessenich
bd1c1831d5 Manually merge ClemensRognerSD-dx9-sampler and resolve conflicts. 2018-12-07 18:38:26 -07:00
greg-lunarg
5d43c4aac7 SPV: Fix #1575, fix #1593: Support HLSL #line
SPIR-V OpLines now contain filenames from HLSL-style #lines.
2018-12-07 17:36:33 -07:00
t.jung
b16bea801c [HLSL/Spir-V] fix for incorrect spir-v on int dot(int, int)
Decomposes OpDot into corresponding multiplies and additions.
2018-11-15 11:02:30 +01:00
t.jung
8279f0728a Updated type conversion rules for HLSL frontend 2018-11-14 08:13:32 +01:00
otakuto
d03da06ac1 Remove execute permissions 2018-08-07 03:16:20 +09:00
John Kessenich
cf6bd066b9 HLSL: Fix #1432: Globally initialize local static variables. 2018-07-11 01:09:14 -06:00
LoopDawg
c59916710e HLSL: allow self-type cast (as no-op passthrough)
Previously, casting an object of a struct type to an identical type
would produce an error.  This PR allows this case.

As a side-effect of the change, several self-type casts in existing
tests go away.  For example:

    0:10          Construct float ( temp float)
    0:10            'f' ( in float)

becomes this (without the unneeded constructor op):

    0:10          'f' ( in float)

For vector or array types this can result in somewhat less overall code.

Fixes: #1218
2018-05-17 13:03:12 -06:00
LoopDawg
4e6d3eaf5d HLSL: require coverage mask to be arrayed output.
SPIR-V requires the coverage mask to be an array of integers, but HLSL
allows scalar integers.  This adds the requisite type conversion and
wrapped entry point handling.

Fixes: #1202
2018-05-16 13:58:10 -06:00
John Kessenich
cfb05ec702
Merge pull request #1379 from LoopDawg/groupid-fix
HLSL: various SPIR-V compute shader IDs must be 3-vectors of integers
2018-05-16 10:36:16 -06:00
LoopDawg
91a8178efb HLSL: various SPIR-V compute shader IDs must be a 3-vector of integers.
This PR forces the external definition of SV_GroupID variables to 3-vectors.
The conversion process between the shader-declared type and the external type
happens in wrapped main IO variable conversion.

The same applies to SV_DispatchThreadID and SV_GroupThreadID.

Fixes: #1371
2018-05-16 06:48:02 -06:00
LoopDawg
1326b8c754 HLSL: Allow stream output Append() method after entry point.
Append() method is special: unlike most outputs, it does not copy
some temporary data to a symbol in the entry point epilogue, but
rather uses an emit builtin after each write to the output stream.

This had been handled by remembering the special output symbol for
the stream as it was declared in the shader entry point before
symbol sanitization.  However the prior code was too simple and
only handled cases where the Append() method happened after the
entry point, so that the output symbol had been seen.

This PR adds a patching step so that the Append()s may appear in
any order WRT the entry point.  They are patched in an epilogue,
whereupon it is guaranteed in a well formed shader that we have
seen the appropriate declaration.

Fixes #1217.
2018-05-15 15:13:09 -06:00
GregF
fb03a55e0f Only print legalization warning if optimizer disabled 2018-03-29 13:17:54 -06:00
John Kessenich
66011cb2c2 SPV: Implement Vulkan 1.1 features and extensions. 2018-03-06 16:12:04 -07:00
John Kessenich
b2ae1d0521 Revert "Merge pull request #1274 from greg-lunarg/legal2"
This reverts commit 2c65069ecd, reversing
changes made to fa9b465b92.
2018-03-06 14:50:41 -07:00
John Kessenich
663b90d908 Build: Fix build issues with previous commit. 2018-03-06 14:20:16 -07:00
GregF
fd50f6a4c3 Legalization: Omit legalization warning when spirv-opt is linked. 2018-03-06 13:00:08 -07:00
John Kessenich
9c9c4e90df GLSL/SPV: Fix #1196: Require resources to have layout(binding=X). 2018-02-22 11:47:41 -07:00
LoopDawg
4425f245a5 HLSL: Add conversions for image ops during SPV construction
HLSL allows image and texture types to be templatized on sub-vec4 types,
or even structures.  This was mostly handled already during creation of
sampling operations.  However, for operator[] which can generate image
loads, this wasn't happening.

It also isn't very easy to do at that point in time, because operator[]
does not know where the results it produces will end up.  They may be
an lvalue or an rvalue, and there's a post-process to convert loads to
stores.  They may end up in atomic ops.

To bypass that difficulty, GlslangToSpv now looks for this case and
adds the appropriate conversion.  LIMITATION: this only works for
cases for which a simple conversion opcode suffices.  That is to say,
it will not work if the type is templatized on a struct.
2018-02-18 13:13:36 -07:00
John Kessenich
e18fd20d5c HLSL: Refactor attribute implementation.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
2018-02-01 00:30:34 -07:00
LoopDawg
280c75ca51 HLSL: Allow primitive id on hull shader inputs
Fixes #979
2017-12-08 12:01:16 -07:00
John Kessenich
471bfed062 HLSL: Fix #606: make layout() override register. 2017-12-06 08:17:21 -07:00
John Kessenich
cc951f8183 HLSL: Fix #1154: Support PointSize, as an attribute. 2017-12-06 07:33:36 -07:00