Commit Graph

165 Commits

Author SHA1 Message Date
LoopDawg
132a28aac4 HLSL: allow name mangling based on texture template type
Name mangling did not account for the vector size in the template type of a texture.
This adds that.  The mangle is as it ever was for the vec4 case, which leaves
all GLSL behavior and most HLSL behavior uneffected.  For vec1-3 the size is added
to the mangle.

Current limitation: textures cannot presently be templatized on structured types,
so this works only for vectors of basic types.

Fixes #895.
2017-05-19 20:12:50 -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
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
c0043cda82 HLSL: Allow empty struct initializers
Review request: does this harm GLSL in any way?
2017-04-27 18:22:52 -06:00
steve-lunarg
a766b838f5 HLSL: Add ConstantBuffer<T> syntax
Note: multi-dimension arrays of ConstantBuffer objects will go through uniform flattening.
2017-04-25 09:30:28 -06: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
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
97366a0df0 HLSL: Fix #770: implicitly convert bool operands to numeric operators. 2017-04-12 22:38:24 -06:00
John Kessenich
a0c578a6df HLSL: Fix #758: Support character literals (except for numeric escape sequences). 2017-04-12 16:58:30 -06:00
John Kessenich
776c515ea5 HLSL: Support 1.#INF and -1.#INF syntax. 2017-04-12 13:40:53 -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
steve-lunarg
13975525d7 Decompose OpIsFinite to avoid capability restrictions
OpIsFinite is not available everywhere: decompose isfinite
to !isinf && !isnan.
2017-04-03 20:05:21 -06:00
steve-lunarg
067eb9b48a WIP: HLSL: Support InputPatch variables in patch constant functions
Previously, patch constant functions only accepted OutputPatch.  This
adds InputPatch support, via a pseudo-builtin variable type, so that
the patch can be tracked clear through from the qualifier.
2017-04-03 19:39:44 -06:00
steve-lunarg
f38cca3ccf HLSL: handle PCF input to DS in arbitrary argument position
In the hull shader, the PCF output does not participate in an argument list,
so has no defined ordering.  It is always put at the end of the linkage.  That
means the DS input reading PCF data must be be at the end of the DS linkage
as well, no matter where it may appear in the argument list.  This change
makes sure that happens.

The detection is by looking for arguments that contain tessellation factor
builtins, even as a struct member.  The whole struct is taken as the PCF output
if any members are so qualified.
2017-04-03 10:14:50 -06:00
John Kessenich
84a30c8bae Merge pull request #774 from steve-lunarg/tess-ctrlpt-pcf
HLSL: support per control point patch const fn invocation
2017-03-31 13:37:52 -06:00
steve-lunarg
db2e3b4169 HLSL: fix crash on empty sequence node passed to intrinsic expansions 2017-03-31 12:47:34 -06:00
steve-lunarg
e741249b72 HLSL: pass tessellation execution modes through to SPIR-V
The SPIR-V generator had assumed tessellation modes such as
primitive type and vertex order would only appear in tess eval
(domain) shaders.  SPIR-V allows either, and HLSL allows and
possibly requires them to be in the hull shader.

This change:

1. Passes them through for either tessellation stage, and,

2. Does not set up defaults in the domain stage for HLSl compilation,
to avoid conflicting definitions.
2017-03-31 11:47:18 -06:00
John Kessenich
9ce76553b8 Merge pull request #797 from steve-lunarg/scalar-length
HLSL: allow length() on scalars
2017-03-31 09:26:47 -06:00
John Kessenich
18958f6cd2 HLSL: Fix #802: Preserve promoted child under ! operator. 2017-03-30 23:32:21 -06:00
John Kessenich
7e997e2612 HLSL: Implicit bool conversions for conditional expressions and related.
Covers if(cond), while(cond), do-while(cond), for(;cond;), and (cond ? :).
Fixes #778.
2017-03-30 22:52:33 -06:00
John Kessenich
8f9fdc986a HLSL: Add namespace grammar and some basic semantics.
Unknown how extensive the semantics need to be yet. Need real
feedback from workloads. This is just done as part of unifying it
with the class/struct namespaces and grammar productions.
2017-03-30 16:30:17 -06:00
steve-lunarg
9cee73e028 HLSL: support per control point patch const fn invocation
This PR emulates per control point inputs to patch constant functions.
Without either an extension to look across SIMD lanes or a dedicated
stage, the emulation must use separate invocations of the wrapped
entry point to obtain the per control point values.  This is provided
since shaders are wanting this functionality now, but such an extension
is not yet available.

Entry point arguments qualified as an invocation ID are replaced by the
current control point number when calling the wrapped entry point.  There
is no particular optimization for the case of the entry point not having
such an input but the PCF still accepting ctrl pt frequency data.  It'll
work, but anyway makes no so much sense.

The wrapped entry point must return the per control point data by value.
At this time it is not supported as an output parameter.
2017-03-30 14:36:56 -06:00
Rex Xu
86e49d1773 HLSL: Move frexp() to a separate test file. 2017-03-29 17:04:58 +08:00
steve-lunarg
1ca04c2bbd HLSL: allow length() on scalars 2017-03-24 10:12:53 -06:00
steve-lunarg
d8e34c5119 HLSL: fix crash on empty struct return from entry point 2017-03-24 08:56:37 -06:00
John Kessenich
7a41f96d10 HLSL: Implement 'this' keyword. 2017-03-22 11:38:22 -06:00
John Kessenich
4960baaf66 HLSL: Basic turn on of non-static member functions.
Still need: pass by reference in SPIR-V and symbol-table level
for accessing 'this' members from member functions.
2017-03-19 18:09:59 -06:00
John Kessenich
54ee28f4d0 HLSL: Add scoping operator, accept static member functions, and support calling them. 2017-03-11 14:13:00 -07:00
John Kessenich
6e1d50a7a2 HLSL: Accept SV_Cull/ClipDistanceN, by refactoring the way semantics are mapped. 2017-03-09 14:37:32 -07:00
steve-lunarg
d00b026111 Enable GatherCmpRed. Green/Blue/Alpha cannot be supported.
This implements GatherCmpRed in terms of OpImageDrefGather.

There appears to be no way to implement the Green/Blue/Apha forms: see #673.
2017-03-09 08:59:45 -07:00
John Kessenich
854fe24786 HLSL: Fix #747: accept 'struct' in front of previously user-defined type name. 2017-03-02 14:30:59 -07:00
John Kessenich
69a2c69649 Merge pull request #736 from steve-lunarg/structbuffer-params
HLSL: add structuredbuffer pass by reference in fn params
2017-02-28 13:10:51 -07:00
steve-lunarg
86b510efd1 WIP: HLSL: add f16tof32 and f32tof16 decompositions. 2017-02-27 15:19:49 -07:00
steve-lunarg
dd8287a109 WIP: HLSL: add structuredbuffer pass by reference in fn params
This PR adds the ability to pass structuredbuffer types by reference
as function parameters.

It also changes the representation of structuredbuffers from anonymous
blocks with named members, to named blocks with pseudonymous members.
That should not be an externally visible change.
2017-02-26 11:13:42 -07:00
steve-lunarg
5da1f038d8 HLSL: implement 4 (of 6) structuredbuffer types
This is a partial implemention of structurebuffers supporting:

* structured buffer types of:
*   StructuredBuffer
*   RWStructuredBuffer
*   ByteAddressBuffer
*   RWByteAddressBuffer

* Atomic operations on RWByteAddressBuffer

* Load/Load[234], Store/Store[234], GetDimensions methods (where allowed by type)

* globallycoherent flag

But NOT yet supporting:

* AppendStructuredBuffer / ConsumeStructuredBuffer types
* IncrementCounter/DecrementCounter methods

Please note: the stride returned by GetDimensions is as calculated by glslang for std430,
and may not match other environments in all cases.
2017-02-21 15:51:49 -07:00
steve-lunarg
858c928ac7 Add basic HS/DS implementation.
This obsoletes WIP PR #704, which was built on the pre entry point wrapping master.  New version
here uses entry point wrapping.

This is a limited implementation of tessellation shaders.  In particular, the following are not functional,
and will be added as separate stages to reduce the size of each PR.

* patchconstantfunctions accepting per-control-point input values, such as
  const OutputPatch <hs_out_t, 3> cpv are not implemented.

* patchconstantfunctions whose signature requires an aggregate input type such as
  a structure containing builtin variables.  Code to synthesize such calls is not
  yet present.

These restrictions will be relaxed as soon as possible.  Simple cases can compile now: see for example
Test/hulsl.hull.1.tesc - e.g, writing to inner and outer tessellation factors.

PCF invocation is synthesized as an entry point epilogue protected behind a barrier and a test on
invocation ID == 0.  If there is an existing invocation ID variable it will be used, otherwise one is
added to the linkage.  The PCF and the shader EP interfaces are unioned and builtins appearing in
the PCF but not the EP are also added to the linkage and synthesized as shader inputs.
Parameter matching to (eventually arbitrary) PCF signatures is by builtin variable type.  Any user
variables in the PCF signature will result in an error.  Overloaded PCF functions will also result in
an error.

[domain()], [partitioning()], [outputtopology()], [outputcontrolpoints()], and [patchconstantfunction()]
attributes to the shader entry point are in place, with the exception of the Pow2 partitioning mode.
2017-02-10 16:59:09 -07:00
John Kessenich
65ee230f1c HLSL: Add tests and refine what decorations are passed through per stage/in/out. 2017-02-06 23:13:16 -07:00