Commit Graph

291 Commits

Author SHA1 Message Date
John Kessenich
d1be7545c6 HLSL: Non-functional: Move partial flattened access into symbol node.
Lays the groundwork for fixing issue #954.

Partial flattenings were previously tracked through a stack of active subsets
in the parse context, but full functionality needs AST nodes to represent
this across time, removing the need for parsecontext tracking.
2017-07-03 21:49:09 -06:00
John Kessenich
02a14e7c99 HLSL: Non-functional: some coding convention tweaks (120 columns, nullptr).
This commit, and next one, are specifically to make a future commit
handling partial dereferences of flattening objects easier to see.
2017-07-03 21:49:09 -06:00
Rex Xu
37cdceed41 Implement extension GL_ARB_shader_stencil_export 2017-06-29 17:50:46 +08:00
John Kessenich
89f8d1e64f HLSL: Fix #942: Map SV_TargetN to SPV Location N. 2017-06-27 15:17:38 -06:00
John Kessenich
fe6689c6c4 HLSL: support point mode. 2017-06-26 17:52:22 -06:00
LoopDawg
c44b95fdec WIP: HLSL: handle clip/cull distance array semantic matching
In HLSL, there are three (TODO: ??) dimensions of clip and cull
distance values:

  * The semantic's value N, ala SV_ClipDistanceN.
  * The array demension, if the value is an array.
  * The vector element, if the value is a vector or array of vectors.

In SPIR-V, clip and cull distance are arrays of scalar floats, always.

This PR currently ignores the semantic N axis, and handles the other
two axes by sequentially copying each vector element of each array member
into sequential floats in the output array.

Fixes: #946
2017-06-23 13:06:53 -06:00
John Kessenich
4329d555ad HLSL: Broaden solution for #940, editing integer input for 'flat'. 2017-06-21 01:35:57 -06:00
John Kessenich
f0bc598dd7 HLSL: Force flat interpolation for structure members. Fixes #940. 2017-06-20 13:19:53 -06:00
John Kessenich
54596ff99e HLSL: Force flat (nointerp) onto integer fragment inputs.
Addresses #940.
2017-06-20 03:20:59 -06:00
John Kessenich
f02c8e6ba1 Non-functional: Attempt to reset Travis error, while adding more nullptr use.
Top of master is listing a test error, not from glslang, but internally
within Travis itself.  Seeing if another run gets it to work again.
2017-06-19 16:25:44 -06:00
LoopDawg
e2713125b9 HLSL: fix several issues in mat construction from scalars
This fixes:

1. A compilation error when assigning scalars to matricies

2. A semantic error in matrix construction from scalars.  This was
initializing the diagonal, where HLSL semantics require the scalar be
replicated to every matrix element.

3. Functions accepting mats can be called with scalars, which will
be shape-converted to the matrix type.  This was previously failing
to match the function signature.

NOTE: this does not yet handle complex scalars (a function call,
say) used to construct matricies.  That'll be added when the
node replicator service is available.  For now, there's an assert.

There's one new test (hlsl.scalar2matrix.frag).  An existing test
lsl.type.half.frag changes, because of (2) above, and a negative
test error message changes due to (3) above.

Fixes #923.
2017-06-14 14:11:18 -06:00
John Kessenich
82ae8c31e0 HLSL: Fix #924: Convert between two different arrays with cast. 2017-06-13 23:13:10 -06:00
LoopDawg
1892886ae1 HLSL: compilation warning fix: no functional change
One liner to eliminate a compile warning.
2017-06-10 07:42:03 -06:00
John Kessenich
f6deacd579 HLSL: Track control-flow nesting and warn on aliasing under it. 2017-06-06 19:53:24 -06:00
John Kessenich
9b2531ba23 Infrastructure: Move nesting counters, etc., to base class.
This lets all languages share the same definitions.
2017-06-06 19:53:24 -06:00
John Kessenich
f31507421b HLSL: Convert run-time sampler assignments to compile-time aliases.
For "s.m = t", a sampler member assigned a sampler, make t an alias
for s.m, and when s.m is flattened, it will flatten to the alias t.
Normally, assignments to samplers are disallowed.
2017-06-02 18:27:21 -06:00
John Kessenich
750c2d07f7 SPV: When passing structs of opaque types, flatten and pass the members instead.
This avoids either A) needing uniformConstant struct, or
B) initializing a struct with opaque members, as writing them is not
allowed.
2017-06-01 18:49:04 -06:00
John Kessenich
d6af18f621 Merge pull request #901 from LoopDawg/imat-construct
HLSL: Add imat, umat, and bmat constructors
2017-05-24 23:12:58 -06:00
John Kessenich
6e2295d340 HLSL: Fix #902: Incorrect protection against zero arguments. 2017-05-24 16:02:56 -06:00
LoopDawg
174ccb8f1d HLSL: Add imat, umat, and bmat constructors
Fixes #894
2017-05-20 21:54:16 -06:00
John Kessenich
24e895b4a3 Merge pull request #860 from steve-lunarg/sb-counter-args.2
HLSL: add ability to pass struct buffers with counters to fns
2017-05-17 10:55:22 -06:00
steve-lunarg
2bb1f39fa7 WIP: HLSL: add ability to pass struct buffers with counters to fns
This modifies function parameter passing to pass the counter
buffer associated with a struct buffer to a function as a
hidden parameter.  Similarly function declarations will have
hidden parameters added to accept the associated counter buffers.

There is a limitation: if a SB type may or may not have an associated
counter, passing it as a function parameter will assume that it does, and
the counter will appear in the linkage whether or not there is a counter
method used on the object.
2017-05-17 09:18:53 -06:00
John Kessenich
0a2a0cd3a4 HLSL: Implement member functions calling member functions. 2017-05-17 02:20:34 -06:00
steve-lunarg
a4bfed129f WIP: track declared builtin type [proposal]
Marking as WIP since it might deserve discussion or at least explicit consideration.

During type sanitization, the TQualifier's TBuiltInVariable type is lost.  However,
sometimes it's needed downstream.  There were already two methods in use to track
it through to places it was needed: one in the TParameter, and one in a map in the
HlslParseContext used for structured buffers.

The latter was going to be insufficient when SB types with counters are passed to
user functions, and it's proving awkward to track the data to where it's needed.
This PR holds a proposal: track the original declared builtin type in the TType,
so it's trivially available where needed.

This lets the other two mechanisms be removed (and they are in this PR).  There's a
side benefit of not losing certain types of information before the reflection interface.

This PR is only that proposal, so it changes no test results.  If it's acceptable,
I'll use it for the last piece of SB counter functionality.
2017-05-15 15:44:00 -06:00
LoopDawg
726bf96a72 HLSL: add .mips[][] operator for texture types
This implements mytex.mips[mip][coord] for texture types.  There is
some error testing, but not comprehensive.  The constructs can be
nested, e.g in this case the inner .mips is parsed before the completion
of the outer [][] operator.

   tx.mips[tx.mips[a][b].x][c]
2017-05-15 09:13:58 -06:00
LoopDawg
c6510a33ff HLSL: allow GS-specific methods in other stages
Using GS methods such as Append() in non-GS stages should be ignored, but was
creating errors due to the lack of a stream output symbol for the non-GS stage.
2017-05-13 09:20:11 -06:00
John Kessenich
02c4728a83 Merge pull request #874 from xlpiao/DescriptorSet-and-Binding
HLSL: Manually configure descriptor set and binding number for resources
2017-05-10 11:10:53 -06:00
Hyangran Park
36dc82908f HLSL: Manually configure descriptor set and binding number for resources 2017-05-10 16:50:18 +09:00
steve-lunarg
f1709e7146 HLSL: implement [unroll] and [loop] attributes
This adds infrastructure suitable for any front end to create SPIR-V loop
control flags.  The only current front end doing so is HLSL.

[unroll] turns into spv::LoopControlUnrollMask
[loop] turns into spv::LoopControlDontUnrollMask
no specification means spv::LoopControlMaskNone
2017-05-03 13:44:40 -06:00
steve-lunarg
d4d0b29752 HLSL: add standard sample position return form of GetSamplePosition method
Multisample textures support a GetSamplePosition() method intended to query
positions given a sample index.  This cannot be truly implemented in SPIR-V,
but #753 requested returning standard positions for the 1..16 cases, which
this PR adds.  Anything besides that returns (0,0).  If the standard positions
are not used, this will be wrong.

This should be revisited when there is a real query available.
2017-04-26 08:31:56 -06:00
Daniel Koch
15bb43703c Fix Android build errors
glslang/MachineIndependent/iomapper.cpp:207:9: error: field 'resolver' will be initialized after field 'stage' [-Werror,-Wreorder]
      : resolver(r)
        ^
glslang/MachineIndependent/iomapper.cpp:263:9: error: field 'resolver' will be initialized after field 'stage' [-Werror,-Wreorder]
      : resolver(r)
        ^
hlsl/hlslParseHelper.cpp:70:5: error: field 'gsStreamOutput' will be initialized after field 'inputPatch' [-Werror,-Wreorder]
    gsStreamOutput(nullptr),
    ^
2017-04-21 16:16:43 -04:00
steve-lunarg
3cbc32f472 HLSL: add error for expected comparison sampler in SampleCmp* ops
This adds an error message if a non-comparison sampler is used with
comparison sampling methods.  There's no functional change for correct shaders.
2017-04-21 09:54:53 -06:00
John Kessenich
0603a383c1 Merge pull request #847 from steve-lunarg/sb-param-fix
HLSL: fix for byte address buffers in fn parmeters
2017-04-20 20:36:06 -06:00
steve-lunarg
e404e088b1 HLSL: fix for byte address buffers in fn parmeters
Byte address buffers were failing to detect that they were byte address
buffers when used as fn parameters.

Note: this detection is a little awkward, and could be simplified if
it was easy to obtain the declared builtin type for an object.
2017-04-20 16:37:14 -06:00
steve-lunarg
f8203a0acd HLSL: cast non-int types to uint on Load/Store indexes
Some texture and SB operations can take non-integer indexes, which should be
cast to integers before use if they are not already.  This adds makeIntegerIndex()
for the purpose.  Int types are left alone.

(This was done before for operator[], but needs to apply to some other things
too, hence its extraction into common function now)
2017-04-20 09:00:56 -06:00
John Kessenich
a8d3db6b32 Merge pull request #835 from steve-lunarg/sb-counters
HLSL: structuredbuffer counter functionality
2017-04-19 17:42:22 -06:00
John Kessenich
d5d9ffbdfd HLSL: vector shape conversions for all ops: Fix #839. Fix #653. Fix #631. 2017-04-18 21:07:05 -06:00
steve-lunarg
350b94856a WIP: HLSL: add refection queries for structuredbuffer counter blocks
This adds TProgram::getUniformBlockCounterIndex(int index), which returns the
index the block of the counter buffer associated with the block of the passed in
index, if any, or -1 if none.
2017-04-18 12:58:15 -06:00
steve-lunarg
12bc9aa9ce WIP: HLSL: add Append/ConsumeBuffer support 2017-04-13 19:09:05 -06:00
steve-lunarg
8e26feb8f2 WIP: HLSL: structuredbuffer counter functionality
This is WIP, heavy on the IP part.  There's not yet enough to use in real workloads.

Currently present:

* Creation of separate counter buffers for structured buffer types needing them.
* IncrementCounter / DecrementCounter methods
* Postprocess to remove unused counter buffers from linkage
* Associated counter buffers are given @count suffix (invalid as a user identifier)

Not yet present:

* reflection queries to obtain bindings for counter buffers
* Append/Consume buffers
* Ability to use SB references passed as fn parameters
2017-04-13 18:43:26 -06:00
John Kessenich
2051815bcc HLSL: Fix #803: Add shape conversions to the constant-initializer path. 2017-04-12 14:56:52 -06:00
John Kessenich
b5e739c20e HLSL: Fix boolean conversion bug and add more tests for ?:.
Null-conversion needs the right sized vectors to kick out with matching types.
2017-04-11 20:21:45 -06:00
John Kessenich
636b62db8b HLSL: Support vector 'cond ? :' -> EOpMix -> OpSelect. 2017-04-11 19:45:00 -06:00
steve-lunarg
9e5a19fd3a HLSL: fix return type for isfinite
The prior decomposition of isfinite was not setting the return type on the
sequence node.  (Sequence was used because there's an internal temporary
to avoid the complex rvalue problem).
2017-04-10 08:27:34 -06:00
John Kessenich
6fa17641b5 HLSL: Emit the OpSource HLSL instruction for HLSL, using new headers. 2017-04-07 15:40:01 -06:00
steve-lunarg
2efd6c6d0c HLSL: cast bracket dereference index to int type if not.
HLSL can index arrays using operator[] with non-integer types, and
inserts a conversion to a uint if needed.
2017-04-06 20:27:10 -06:00
steve-lunarg
ccb076ac9b HLSL: allow non-vec3 tessellation coordinate declarations
HLSL requires vec2 tessellation coordinate declarations in some cases
(e.g, isoline topology), where SPIR-V requires the TessCoord qualified
builtin to be a vec3 in all cases.  This alters the IO form of the
variable to be a vec3, which will be copied to the shader's declared
type if needed.  This is not a validation; the shader type must be correct.
2017-04-05 11:03:02 -06:00
John Kessenich
82460b5e21 HLSL: Fix #805: Support cast of scalars to structures.
Somewhat complex due to recognizing a general scalar, but not
replicating it for each member to avoid side effects.
2017-04-04 11:49:33 -06:00
John Kessenich
5ce1e4aff8 Merge pull request #817 from steve-lunarg/isfinite
HLSL: Decompose OpIsFinite to avoid capability restrictions
2017-04-03 22:32:35 -06:00
John Kessenich
c633f644da HLSL: Non-functional: rationalize making constructors.
Improves foundation for adding scalar casts.

Makes handle/make names more sane, better commented, uses more
precise subclass typing, and removes mutual recursion between
converting initializer lists and making constructors.
2017-04-03 22:17:57 -06:00