Commit Graph

2447 Commits

Author SHA1 Message Date
John Kessenich
eaed06823a Merge pull request #1011 from LoopDawg/pragma-pack-matrix
HLSL: implement #pragma pack_matrix(layout)
2017-08-08 06:35:29 +09:00
LoopDawg
6a264bed88 HLSL: implement #pragma pack_matrix(layout)
This adds support for #pragma pack_matrix() to the HLSL front end.

The pragma sets the default matrix layout for subsequent unqualified matrices
in structs or buffers. Explicit qualification overrides the pragma value. Matrix
layout is not permitted at the structure level in HLSL, so only leaves which are
matrix types can be so qualified.

Note that due to the semantic (not layout) difference in first matrix indirections
between HLSL and SPIR-V, the sense of row and column major are flipped.  That's
independent of this PR: just a factor to note.  A column_major qualifier appears
as a RowMajor member decoration in SPIR-V modules, and vice versa.
2017-08-07 12:41:44 -06:00
John Kessenich
d5aedc199f HLSL: Correct which things flattening tracks for linkage, based on caller, not type.
Includes related trackLinkage() code removal and name improvements.
2017-08-06 21:18:56 -06:00
John Kessenich
7497e7c9f3 Merge pull request #1010 from LoopDawg/mat-rowcol-fix-1
HLSL: fix qualifier propagation from user struct types to block defin…
2017-08-06 03:03:05 +09:00
LoopDawg
898f5fbef7 HLSL: fix qualifier propagation from user struct types to block definitions.
The HLSL FE tracks four versions of a declared type to avoid losing information, since it
is not (at type-decl time) known how the type will be used downstream.  If such a type
was used in a cbuffer declaration, the cbuffer type's members should have been using
the uniform form of the original user structure type, but were not.

This would manifest as matrix qualifiers (and other things, such as pack offsets) on user struct
members going missing in the SPIR-V module if the struct type was a member of a cbuffer, like so:

    struct MyBuffer
    {
        row_major float4x4 mat1;
        column_major float4x4 mat2;
    };

    cbuffer Example
    {
        MyBuffer g_MyBuffer;
    };

Fixes: #789
2017-08-04 15:50:10 -06:00
John Kessenich
2b4f77f2dc HLSL: Correct use of isPerVertexBuiltIn() to be isClipOrCullDistance().
This allows removal of isPerVertexBuiltIn(). It also leads to
removal of addInterstageIoToLinkage(), which is no longer needed.

Includes related name improvements.
2017-08-04 15:32:24 -06:00
John Kessenich
d319fb4e63 HLSL: Test change: Geometry shaders can't return values from main. 2017-08-04 13:41:32 -06:00
John Kessenich
b6be80f44e HLSL: Flatten more I/O: non-arrayed user-only structures.
The goal is to flatten all I/O, but there are multiple categories and
steps to complete, likely including a final unification of splitting
and flattening.
2017-08-04 12:19:58 -06:00
John Kessenich
cca42a8ea6 HLSL: Stop including empty structures in the I/O interface. Fix #785. 2017-08-03 18:41:48 -06:00
John Kessenich
6042eb475b Non-functional: HLSL: Simplify I/O logic for splitting. 2017-08-02 17:08:43 -06:00
John Kessenich
4cf5266042 Merge pull request #1006 from KhronosGroup/4.60
GLSL: Add GLSL 4.60 features
2017-08-02 02:11:52 +09:00
John Kessenich
934d11b6db GLSL 4.6: Implement shader group vote. 2017-07-31 03:00:04 -06:00
John Kessenich
941f3bbd7a GLSL 4.6: Implement draw parameters. 2017-07-31 03:00:04 -06:00
John Kessenich
0d0c6d38f0 GLSL 4.6: Implement atomic counter ops and SPV_KHR_shader_atomic_counter_ops. 2017-07-31 03:00:04 -06:00
John Kessenich
de16e52b25 GLSL: Initiate version GLSL 460, including accept extraneous semicolons. 2017-07-31 03:00:04 -06:00
John Kessenich
fda6edcbad HLSL Tests: Fix two tests to be valid under FXC. 2017-07-31 01:19:26 -06:00
John Kessenich
318a379b1f Non-functional: HLSL further simplications to base I/O flattening on. 2017-07-30 23:51:35 -06:00
John Kessenich
8bcdf2eaf5 Non-functional: HLSL: clean up dead code for splitting.
Most of this was obsoleted by entry-point wrapping.
Some other is just unnecessary.
Also, includes some spelling/name improvements.

This is to help lay ground work for flattening user I/O.
2017-07-30 18:53:16 -06:00
John Kessenich
48dc58721e Merge pull request #1005 from LoopDawg/remove-unused
HLSL: Non-functional: warning fix + remove unused member
2017-07-30 06:23:11 +09:00
LoopDawg
7a3cef10dc HLSL: Non-functional: warning fix, remove unused member.
Two non-functional changes:

1. Remove flattenLevel, which is unneeded since at or around d1be7545c6.

2. Fix build warining about unused variable in executeInitializer.
2017-07-28 18:41:53 -06:00
John Kessenich
a58cc9ffdf GLSL reflection: Fix #985: reflect runtime sized arrays having no constant index. 2017-07-28 17:37:31 -06:00
John Kessenich
a353bf1f20 Nonfunctional: Add reflect test case, and fix long lines in reflection code. 2017-07-28 17:32:27 -06:00
John Kessenich
2ceec68109 Nonfunctional: Shorten some lines to the coding standard, to retrigger failed test run. 2017-07-28 16:21:04 -06:00
John Kessenich
38151b2f45 Merge pull request #1002 from amdrexu/bugfix
SPV: Memory qualifiers should decorate top-level block members
2017-07-28 01:35:42 +09:00
Rex Xu
286ca432cf SPV: Memory qualifiers should decorate top-level block members 2017-07-27 14:33:16 +08:00
John Kessenich
f1f5058a3c Merge pull request #997 from LoopDawg/clipcull-semantic
HLSL: handle multiple clip/cull semantic IDs
2017-07-27 08:38:03 +09:00
LoopDawg
307b6507b3 HLSL: handle multiple clip/cull semantic IDs
HLSL allows several variables to be declared.  There are packing rules involved:
e.g, a float3 and a float1 can be packed into a single array[4], while for a
float3 and another float3, the second one will skip the third array entry to
avoid straddling

This is implements that ability.  Because there can be multiple variables involved,
and the final output array will often be a different type altogether (to fuse
the values into a single destination), a new variable is synthesized, unlike the prior
clip/cull support which used the declared variable.  The new variable name is
taken from one of the declared ones, so the old tests are unchanged.

Several new tests are added to test various packing scenarios.

Only two semantic IDs are supported: 0, and 1, per HLSL rules.  This is
encapsulated in

     static const int maxClipCullRegs = 2;

and the algorithm (probably :) ) generalizes to larger values, although there
are a few issues around how HLSL would pack (e.g, would 4 scalars be packed into
a single HLSL float4 out reg?  Probably, and this algorithm assumes so).
2017-07-26 11:18:09 -06:00
John Kessenich
d2d3a14237 SPV: Update to latest 1.0 headers, removing redundancies in GLSL.ext.AMD.h. 2017-07-25 21:03:29 -06:00
John Kessenich
cd52fd5a42 Merge pull request #1000 from LoopDawg/samplecmpzero-cubearray-fix
Fix dref explicit LOD form of sample with cube texture arrays
2017-07-25 16:36:17 +09:00
LoopDawg
ef94b1a5ca Fix dref explicit LOD form of sample with cube texture arrays
The dref parameter was being used as the LOD.  Now it it's properly the dref.
2017-07-24 18:45:37 -06:00
John Kessenich
53863a3a90 GLSL: Implement version 320 for ES. 2017-07-23 13:54:15 -06:00
John Kessenich
9353f1afab GLSL: Add version-number checking. 2017-07-23 11:49:42 -06:00
John Kessenich
67eb497002 SPV/OpenGL: Require locations on non-opaque uniform variables. 2017-07-21 13:37:46 -06:00
John Kessenich
ab0086754e Merge pull request #991 from LoopDawg/resource-set-binding-fix
HLSL: Fix crash with --resource-set-binding [n] (global form, not per-register form)
2017-07-22 01:59:42 +09:00
John Kessenich
a2b71902e2 Reflection: Fix #977: Expose getBinding(), use in new getUniformBinding(). 2017-07-20 16:44:17 -06:00
LoopDawg
52017192e5 Fix crash with --resource-set-binding [n] (common set form, not per-register form)
--resource-set-binding has a mode which allows per-register assignments of
bindings and descriptor sets on the command line, and another accepting a
single descriptor set value to assign to all variables.

The former worked, but the latter would crash when assigning the values.
This fixes it, and makes the former case a bit more robust against premature
termination of the pre-register values, which must come in (regname,set,binding)
triples.

This also allows the form "--resource-set-binding stage setnum", which was
mentioned in the usage message, but did not parse.

The operation of the per-register form of this option is unchanged.
2017-07-18 11:15:40 -06:00
John Kessenich
0e392aa92e Merge pull request #996 from KhronosGroup/decorate-parameters
SPV: Decorate parameters
2017-07-18 03:51:02 -06:00
John Kessenich
961cd35b73 SPV: Fix #995: Include memory decorations on parameters. 2017-07-18 03:07:43 -06:00
John Kessenich
fad6297206 SPV: Non-functional: support lists of decorations per parameter. 2017-07-18 02:46:59 -06:00
John Kessenich
198652a6d4 Merge pull request #994 from KhronosGroup/opaque-init
HLSL: Fix #980: flatten opaque initializers to use aliases.
2017-07-16 06:01:38 -06:00
John Kessenich
0e6e2ffd9c Fix #980: flatten opaque initializers to use aliases. 2017-07-16 05:46:13 -06:00
John Kessenich
37c202aa02 Merge pull request #992 from polarina/null-deref-fix
Fix NULL pointer dereference in TParseContext::builtInOpCheck
2017-07-16 01:16:55 -06:00
Gabríel Arthúr Pétursson
b5d9c11e1a Fix NULL pointer dereference in TParseContext::builtInOpCheck 2017-07-15 15:22:50 +00:00
John Kessenich
91e69c03bd SPV: Address #989: Don't add Location to built-ins when automapping. 2017-07-14 05:54:05 -06:00
John Kessenich
56d2b9904e Merge pull request #987 from KhronosGroup/global-std140
Address part B of #982: $Global will use std140 instead of HLSL offsets.
2017-07-14 05:45:50 -06:00
John Kessenich
735d7e56a6 Address part A of #982: $Global will use std140 instead of HLSL offsets.
From comment about this:
Adjust alignment for HLSL rules
TODO: make this consistent in early phases of code: adjusting this late means inconsistencies with earlier code, which for reflection is an issue.
Until reflection is brought in sync with these adjustments, don't apply to $Global,
which is the most likely to rely on reflection, and least likely to rely
implicit layouts.
2017-07-13 11:39:16 -06:00
John Kessenich
1e4a721cef Merge pull request #978 from LoopDawg/global-const-init-fix
HLSL: support global const initializers from non-constant rvalues
2017-07-13 08:29:53 -06:00
John Kessenich
d854ac8b71 Merge pull request #983 from LoopDawg/warning-fix
Fix StandAlone.cpp compilation warnings
2017-07-13 07:14:26 -06:00
LoopDawg
b97b25e40b Fix StandAlone.cpp compilation warnings
find_first_of returns size_t, was overflowing int.
2017-07-12 09:05:05 -06:00
LoopDawg
0fca0bafaf WIP: HLSL: support global const initializers from non-constant rvalues
Semantic test left over from other source languages is removed, since this is permitted by HLSL.
Also, to support the functionality, a targeted test is performed for this case and it is
turned into a EvqGlobal qualifier to create an AST initialization segment when needed.

Constness is now propagated up aggregate chains during initializer construction.  This
handles hierarchical cases such as the distinction between:

    static const float2 a[2] = { { 1, 2 }, { 3, 4} };

vs

    static const float2 a[2] = { { 1, 2 }, { cbuffer_member, 4} };

The first of which can use a first class constant initalization, and the second cannot.
2017-07-11 13:41:39 -06:00