Commit Graph

60 Commits

Author SHA1 Message Date
dan sinclair
00965b9fa9
Remove unused variable. (#2273)
The `isMat` variable is no longer used in the HLSL parser. Removed.
2020-06-15 12:10:44 -06:00
Ryan Harrison
8496b782fb
Remove unused function, BaseTypeName (#2272) 2020-06-15 10:58:02 -06:00
John Kessenich
a58978ac9a HLSL: Remove support for having GLSL versions of HLSL intrinsics.
Related to PR #2265.
2020-06-15 10:28:09 -06:00
rdb
ebf55a0711
HLSL: Fix incorrect case in name of DX9-style cube sampler type (#2265) 2020-06-15 06:39:43 -06:00
John Kessenich
bd1c1831d5 Manually merge ClemensRognerSD-dx9-sampler and resolve conflicts. 2018-12-07 18:38:26 -07:00
otakuto
d03da06ac1 Remove execute permissions 2018-08-07 03:16:20 +09:00
John Kessenich
11da9eed5d HLSL: Fix #1445: distance() works on scalars. 2018-07-23 16:55:01 -06:00
Neil Henning
fd920b3b6a WaveReadLaneFirst is the correct wording (was using WaveReadFirstLane previously...). 2018-03-07 17:04:20 +00:00
John Kessenich
66011cb2c2 SPV: Implement Vulkan 1.1 features and extensions. 2018-03-06 16:12:04 -07:00
John Kessenich
e22e347395 HLSL: Fix #1208: accept both int and uint in asuint() and asint(). 2018-01-11 13:26:09 -07:00
John Kessenich
838d7afc61 SPV: HLSL: Move to correct HLSL barrier semantics, per Khronos recommendation. 2017-12-16 00:34:08 -07:00
John Kessenich
4ce5b562bb Fix #1103: clip() works on int/uint. 2017-10-16 11:42:35 -06:00
LoopDawg
7f93d56ef2 HLSL: add subpass input types and methods
Add support for Subpass Input proposal of issue #1069.

Subpass input types are given as:

    layout(input_attachment_index = 1) SubpassInput<float4> subpass_f;
    layout(input_attachment_index = 2) SubpassInput<int4>   subpass_i;
    layout(input_attachment_index = 3) SubpassInput<uint4>  subpass_u;

    layout(input_attachment_index = 1) SubpassInputMS<float4> subpass_ms_f;
    layout(input_attachment_index = 2) SubpassInputMS<int4>   subpass_ms_i;
    layout(input_attachment_index = 3) SubpassInputMS<uint4>  subpass_ms_u;

The input attachment may also be specified using attribute syntax:

    [[vk::input_attachment_index(7)]] SubpassInput subpass_2;

The template type may be a shorter-than-vec4 vector, but currently user
structs are not supported.  (An unimplemented error will be issued).

The load operations are methods on objects of the above type:

    float4 result = subpass_f.SubpassLoad();
    int4   result = subpass_i.SubpassLoad();
    uint4  result = subpass_u.SubpassLoad();

    float4 result = subpass_ms_f.SubpassLoad(samp);
    int4   result = subpass_ms_i.SubpassLoad(samp);
    uint4  result = subpass_ms_u.SubpassLoad(samp);

Additionally, the AST printer could not print EOpSubpass* nodes.  Now it can.

Fixes #1069
2017-10-02 12:46:55 -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
steve-lunarg
6817f81e02 HLSL: Implement missing GatherCmp 2017-05-01 21:59:34 -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
steve-lunarg
1ca04c2bbd HLSL: allow length() on scalars 2017-03-24 10:12:53 -06:00
steve-lunarg
e7d0752a33 HLSL: use prefix for builtin functions names to avoid namespace collisions
It would have been possible for globally scoped user functions to collide
with builtin method names.  This adds a prefix to avoid polluting the
namespace.

Ideally this would be an invalid character to use in user identifiers, but
as that requires changing the scanner, for the moment it's an unlikely yet
valid prefix.
2017-03-19 18:22:11 -06: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
John Kessenich
927608b393 Non-functional: White space after "//", mostly for copyrights. 2017-01-06 12:34:14 -07:00
John Kessenich
ecba76fe73 Non-Functional: Whitespace, comments, replace accidentally deleted comment.
- fixed ParseHelper.cpp newlines (crlf -> lf)
- removed trailing white space in most source files
- fix some spelling issues
- extra blank lines
- tabs to spaces
- replace #include comment about no location
2017-01-06 11:24:14 -07:00
John Kessenich
5abd308e71 Merge pull request #659 from steve-lunarg/d3dcolortoubyte4
Add D3DCOLORtoUBYTE4 decomposition
2017-01-03 15:34:33 -07:00
steve-lunarg
7ea7ff4cd4 Add EOpD3DCOLORtoUBYTE4 decomposition 2017-01-03 14:42:18 -07:00
steve-lunarg
26d3145334 HLSL default function parameters
This PR adds support for default function parameters in the following cases:

1. Simple constants, such as void fn(int x, float myparam = 3)
2. Expressions that can be const folded, such a ... myparam = sin(some_const)
3. Initializer lists that can be const folded, such as ... float2 myparam = {1,2}

New tests are added: hlsl.params.default.frag and hlsl.params.default.err.frag
(for testing error situations, such as ambiguity or non-const-foldable).

In order to avoid sampler method ambiguity, the hlsl better() lambda now
considers sampler matches.  Previously, all sampler types looked identical
since only the basic type of EbtSampler was considered.
2016-12-29 12:15:48 -07:00
steve-lunarg
ef33ec0925 HLSL: add intrinsic function implicit promotions
This PR handles implicit promotions for intrinsics when there is no exact match,
such as for example clamp(int, bool, float).  In this case the int and bool will
be promoted to a float, and the clamp(float, float, float) form used.

These promotions can be mixed with shape conversions, e.g, clamp(int, bool2, float2).

Output conversions are handled either via the existing addOutputArgumentConversion
function, which this PR generalizes to handle either aggregates or unaries, or by
intrinsic decomposition.  If there are methods or intrinsics to be decomposed,
then decomposition is responsible for any output conversions, which turns out to
happen automatically in all current cases.  This can be revisited once inout
conversions are in place.

Some cases of actual ambiguity were fixed in several tests, e.g, spv.register.autoassign.*

Some intrinsics with only uint versions were expanded to signed ints natively, where the
underlying AST and SPIR-V supports that.  E.g, countbits.  This avoids extraneous
conversion nodes.

A new function promoteAggregate is added, and used by findFunction.  This is essentially
a generalization of the "promote 1st or 2nd arg" algorithm in promoteBinary.

The actual selection proceeds in three steps, as described in the comments in
hlslParseContext::findFunction:

1. Attempt an exact match.  If found, use it.
2. If not, obtain the operator from step 1, and promote arguments.
3. Re-select the intrinsic overload from the results of step 2.
2016-11-23 10:36:34 -07:00
John Kessenich
e122f053bb Merge pull request #599 from steve-lunarg/gs
HLSL: Add GS support
2016-11-23 00:29:30 -07:00
steve-lunarg
f49cdf4183 WIP: HLSL: Add GS support
This PR adds:

[maxvertexcount(n)] attributes

point/line/triangle/lineadj/triangleadj qualifiers

PointStream/LineStream/TriangleStream templatized types

Append method on above template types

RestartStrip method on above template types.
2016-11-21 18:25:08 -07:00
steve-lunarg
0842dbb39a HLSL: use HLSL parser to parse HLSL intrinsic prototypes, enable int/bool mats
This PR adds a CreateParseContext() fn analogous to CreateBuiltInParseables(),
to create a language specific built in parser.  (This code was present before
but not encapsualted in a fn).  This can now be used to create a source language
specific parser for builtins.

Along with this, the code creating HLSL intrinsic prototypes can now produce
them in HLSL syntax, rather than GLSL syntax.  This relaxes certain prior
restrictions at the parser level.  Lower layers (e.g, SPIR-V) may still have
such restrictions, such as around Nx1 matrices: this code does not impact
that.

This PR also fleshes out matrix types for bools and ints, both of which were
partially in place before.  This was easier than maintaining the restrictions
in the HLSL prototype generator to avoid creating protoypes with those types.

Many tests change because the result type from intrinsics moves from "global"
to "temp".

Several new tests are added for the new types.
2016-11-16 11:19:22 -07:00
steve-lunarg
e5921f1309 HLSL: Fix unary and binary operator type conversion issues
This fixes defects as follows:

1. handleLvalue could be called on a non-L-value, and it shouldn't be.

2. HLSL allows unary negation on non-bool values.  TUnaryOperator::promote
   can now promote other types (e.g, int, float) to bool for this op.

3. HLSL allows binary logical operations (&&, ||) on arbitrary types, similar
   (2).

4. HLSL allows mod operation on arbitrary types, which will be promoted.
   E.g, int % float -> float % float.
2016-10-18 16:56:37 -06:00
steve-lunarg
8b0227ced9 HLSL: phase 3b: Texture methods remember and return vector size.
Also makes a (correct) test change for global -> temp vars.
2016-10-14 18:44:32 -06:00
steve-lunarg
bb0183f817 HLSL: phase 1: add RWTexture and RWBuffer
There's a lot to do for RWTexture and RWBuffer, so it will be broken up into
several PRs.  This is #1.

This adds RWTexture and RWBuffer support, with the following limitations:
  * Only 4 component formats supported
  * No operator[] yet

Those will be added in other PRs.

This PR supports declarations and the Load & GetDimensions methods.  New tests are
added.
2016-10-06 10:51:52 -06:00
steve-lunarg
297ae211f1 WIP: HLSL: Treat HLSL rows as GLSL columns.
WIP: HLSL: EOpGenMul arg reversal
2016-09-09 12:02:42 -06:00
steve-lunarg
61da5e41f7 HLSL: Put intrinsics in symbol table for all stages 2016-08-11 07:29:30 -06:00
steve-lunarg
7dfcf4d1ad HLSL: Add GatherRed/Green/Blue/Alpha methods, inc 4-offset forms 2016-08-03 13:34:39 -06:00
John Kessenich
c552aece83 Merge pull request #417 from steve-lunarg/buffers
HLSL: add Buffer support for Load method
2016-07-28 16:56:39 -06:00
steve-lunarg
cf57c04401 HLSL: add missing vec,vec,scalar form of lerp(), + test 2016-07-28 13:23:22 -06:00
steve-lunarg
d53f717fd3 HLSL: add Buffer support for Load method 2016-07-27 15:57:31 -06:00
steve-lunarg
68f2c144e3 HLSL: Add CalculateLevelOfDetail, and unimplemented errors for *Unclamped and GetSamplePosition 2016-07-27 10:46:33 -06:00
steve-lunarg
1e19d90043 HLSL: add 2DMS texture formats, and matching Load / GetDimensions support 2016-07-27 07:37:21 -06:00
LoopDawg
a2f3d285a8 HLSL: Add gather, improve proto generator machine for upcoming 2DMS/Shadow 2016-07-22 12:46:11 -06:00
LoopDawg
3ef7852ef6 HLSL: Add SampleLevel method 2016-07-21 15:02:30 -06:00
John Kessenich
2f003ac4e6 Merge pull request #393 from steve-lunarg/warning-enable
Build: Add g++/clang warnings to match some enabled by /W4 in MSVC
2016-07-21 14:46:21 -06:00
LoopDawg
6d478956ac Add g++/clang warnings to match some enabled by /W4 in MSVC. 2016-07-21 09:59:18 -06:00
LoopDawg
f245101954 HLSL: Add texture Load method & decomposition 2016-07-21 09:42:35 -06:00
LoopDawg
a78b02941b HLSL: Add SampleCmp and SampleCmpLevelZero texture methods 2016-07-20 09:57:03 -06:00
LoopDawg
5d58faecc0 HLSL: Add tx.GetDimensions method (uint returns only) 2016-07-18 16:40:21 -06:00
John Kessenich
e4821e43c8 Build: Fix three new warnings in HLSL code. 2016-07-16 10:19:43 -06:00
LoopDawg
a2b7991497 HLSL: Add SampleBias and SampleGrad, and associated tests 2016-07-15 11:38:49 -06:00
LoopDawg
92aff54632 HLSL: add offset Sample() form and arrayed texture support 2016-07-13 11:58:56 -06:00