Commit Graph

2262 Commits

Author SHA1 Message Date
Rex Xu
e8fdd79f2e SPV: Implement extension SPV_EXT_shader_stencil_export 2017-08-24 06:26:15 +08:00
John Kessenich
778806a692 HLSL: Fix #1018: Give an error for mismatched return type. 2017-08-19 17:29:44 -06:00
John Kessenich
b207daa5d3 Merge pull request #1017 from LoopDawg/texture-struct-return.1
HLSL: add methods to handle user structures in texture template type.
2017-08-19 16:00:26 -06:00
John Kessenich
786e8795ee Build: Fix build when NV_EXTENSIONS is not enabled. 2017-08-19 15:54:49 -06:00
John Kessenich
d6be6da031 SPV: Fix #1016: Don't allow non-GLSL-extension protected Layer and ViewportIndex members. 2017-08-17 23:49:39 -06:00
LoopDawg
5ee05891cf HLSL: add methods to track user structure in texture return type.
Some languages allow a restricted set of user structure types returned from texture sampling
operations.  Restrictions include the total vector size of all components may not exceed 4,
and the basic types of all members must be identical.

This adds underpinnings for that ability.  Because storing a whole TType or even a simple
TTypeList in the TSampler would be expensive, the structure definition is held in a
table outside the TType.  The TSampler contains a small bitfield index, currently 4 bits
to support up to 15 separate texture template structure types, but that can be adjusted
up or down.  Vector returns are handled as before.

There are abstraction methods accepting and returning a TType (such as may have been parsed
from a grammar).  The new methods will accept a texture template type and set the
sampler to the structure if possible, checking a range of error conditions such as whether
the total structure vector components exceed 4, or whether their basic types differe, or
whether the struct contains non-vector-or-scalar members.  Another query returns the
appropriate TType for the sampler.

High level summary of design:

In the TSampler, this holds an index into the texture structure return type table:

    unsigned int structReturnIndex : structReturnIndexBits;

These are the methods to set or get the return type from the TSampler.  They work for vector or structure returns, and potentially could be expanded to handle other things (small arrays?) if ever needed.

    bool setTextureReturnType(TSampler& sampler, const TType& retType, const TSourceLoc& loc);
    void getTextureReturnType(const TSampler& sampler, const TType& retType, const TSourceLoc& loc) const;

The ``convertReturn`` lambda in ``HlslParseContext::decomposeSampleMethods`` is greatly expanded to know how to copy a vec4 sample return to whatever the structure type should be.  This is a little awkward since it involves introducing a comma expression to return the proper aggregate value after a set of memberwise copies.
2017-08-15 16:40:21 -06:00
John Kessenich
03e63fa805 HLSL: Add fall-back for opaque initializers to just generate long-term expected code.
This generated code needs an optimization pass to eliminate the assignments
to the opaque members.
2017-08-15 10:18:32 -06:00
John Kessenich
25495fdfa7 Merge pull request #1013 from KhronosGroup/flatten-nonarrayed
HLSL: Flatten structs for all non-arrayed I/O interfaces.
2017-08-15 13:16:36 +09:00
John Kessenich
260f50616a SPV: Correct selection of storage-image capabilities. Fixes #986.
Code was reflecting an old historical use of sampled as a SPIR-V
2-valued operand, instead of its current 3 values.
2017-08-14 22:10:00 -06:00
John Kessenich
e29ff3cd65 HLSL: Flatten structs for all non-arrayed I/O interfaces. 2017-08-11 00:17:26 -06:00
John Kessenich
01109546d8 HLSL: Make fresh array sizes for TessLevelOuter and TessLevelInner arrays.
This prevents potentional sharing from inadvertently affecting other arrays.
2017-08-11 00:14:46 -06:00
John Kessenich
4baebea8d6 HLSL Test: Expand test, adding a user-patch-constant signature. 2017-08-10 11:41:11 -06:00
John Kessenich
e516d4335f HLSL: Move debug naming to a simpler, more consistent, scheme.
This will help in expanding flattening and reducing splitting.
2017-08-09 14:29:29 -06:00
John Kessenich
3322dd8f99 HLSL: Include built-in processing for vertex input and fragment output flattening. 2017-08-09 11:03:49 -06:00
John Kessenich
ecd08bc36c Non-functional HLSL: Factor out built-ins from splitting and related simplifications. 2017-08-08 17:32:38 -06:00
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