Commit Graph

59 Commits

Author SHA1 Message Date
John Kessenich
b23d232ec5 Licensing. Fixes #958. Add licenes file and update copyrights. 2018-12-14 10:47:35 -07: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
cf6bd066b9 HLSL: Fix #1432: Globally initialize local static variables. 2018-07-11 01:09:14 -06:00
John Kessenich
e18fd20d5c HLSL: Refactor attribute implementation.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
2018-02-01 00:30:34 -07:00
John Kessenich
132cf53737 HLSL: Fix #1203: Declare anonymous members for cbuffer with no ';'
The grammar for no semicolon and no object name for cbuffer/tbuffer
was correct, but the production still skipped the anonymous declarations
if an identifier followed.
2018-01-02 11:27:54 -07:00
John Kessenich
046bae0bab HLSL: Attributes: Add [[vk::constant_id()]] and [[vk::push_constant]] 2017-12-23 17:29:45 -07:00
LoopDawg
e5530b92ce HLSL: implement TextureBuffer<type>
Almost equivalent to tbuffer, except members not at global scope.
So, reference is "TextureBuffer_var.member", not simply "member".
2017-11-08 19:48:11 -07: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
9855bdad00 GLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.
Fixes #1045.
2017-09-12 09:40:54 -06:00
Rex Xu
57e65929e4 HLSL: Translate directive [flatten] and [branch] to SPV control mask. 2017-07-06 11:31:33 +08:00
John Kessenich
0320d090e2 HLSL: Recognize types declared as identifiers as identifiers.
E.g., in

    float float;
    (float) * float;

The "(float)" is not a type cast, it is an expression.
2017-06-13 22:22:52 -06:00
John Kessenich
0e07119ae2 HLSL: Fix #919: for-init-statement is arbitrary declaration or expression.
Unlike "if (XXX)" and "while (XXX)", with "for (YYY...", the YYY can be
more kinds of statements than the XXX.
2017-06-06 11:37:33 -06: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
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
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
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
John Kessenich
aa3c64c214 Fix #800 (mostly): set of Linux warnings. 2017-03-28 09:52:38 -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
f3d88bd498 HLSL non-functional: Generalize namespace nesting.
Also use this to move deferred member-function-body parsing to a better
place.

This should also be well poised for implementing the 'namespace' keyword.
2017-03-19 13:01:58 -06:00
John Kessenich
b16f7e6819 HLSL: Member-functions: capture body token stream for deferred syntax/semantics.
This is needed for accessing types/variables within a member function body that are
not known until after the struct is finished being declared. However, that funtionality
is not yet present, this is just the deferred processing, which is working for
static member functions.
2017-03-11 19:37:29 -07:00
John Kessenich
088d52bac2 HLSL: Non-functional: consolidate function declarator information. 2017-03-11 19:37:29 -07: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
ca71d946d7 HLSL: Grammar: Generalize accepting a declaration to accept an aggregate of subtrees.
This is slightly cleaner today for entry-point wrapping, which sometimes made
two subtrees for a function definition instead of just one subtree.  It will be
critical though for recognizing a struct with multiple member functions.
2017-03-07 20:44:09 -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
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
02467d8d94 HLSL: Wrap the entry-point; need to write 'in' args, and support 'inout' args.
This needs some render testing, but is destined to be part of master.

This also leads to a variety of other simplifications.
 - IO are global symbols, so only need one list of linkage nodes (deferred)
 - no longer need parse-context-wide 'inEntryPoint' state, entry-point is localized
 - several parts of splitting/flattening are now localized
2017-02-06 22:58:32 -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
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
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
1868b14435 HLSL: implement numthreads for compute shaders
This PR adds handling of the numthreads attribute for compute shaders, as well as a general
infrastructure for returning attribute values from acceptAttributes, which may be needed in other
cases, e.g, unroll(x), or merely to know if some attribute without params was given.

A map of enum values from TAttributeType to TIntermAggregate nodes is built and returned.  It
can be queried with operator[] on the map.  In the future there may be a need to also handle
strings (e.g, for patchconstantfunc), and those can be easily added into the class if needed.

New test is in hlsl.numthreads.comp.
2016-10-31 09:28:17 -06:00
John Kessenich
a1e2d4952e HLSL: Move to correct parsing of annotations, improving all annotations and recent string grammar. 2016-09-20 13:22:58 -06:00
John Kessenich
86f7138706 HLSL: Add string basic type and recognize string declaration grammar.
This includes the "< decl ; decl ; >" syntax which has its own namespace.
This functionality is not implemented, just silently accepted.
2016-09-19 20:29:45 -06:00
John Kessenich
7735b94403 HLSL Non-Functional: Move to more robust capturing of postDecls into a qualifier.
This will prevent a possible future defect of thinking the type can be changed,
where there is a code path today that would drop that change.
2016-09-05 12:40:06 -06:00
John Kessenich
b9e39120b4 HLSL: Partially address issue #463: accept GLSL layout(...).
This includes all "per variable" layout qualifiers, but the
key ones mattering and tested for now are:
  set=
  binding=
  constant_id=
  push_constant
2016-08-17 17:38:45 -06:00
John Kessenich
00957f8110 HLSL: Implement ?: grammar productions.
Missing are implicit conversions between int/bool/etc.
2016-07-27 10:39:57 -06:00
LoopDawg
4886f69734 HLSL: Sampler/texture declarations, method syntax, partial Sample method 2016-07-12 15:57:46 -06:00
John Kessenich
7f349c73db Build: Remove causes of pedantic warnings. Addresses issue #352 and PR #242. 2016-07-08 22:09:10 -06:00
John Kessenich
073542416c HLSL: Grammar: Recognize { } style initializers for composites. 2016-07-01 19:58:06 -06:00
LoopDawg
6daaa4fadf HLSL: Add template style constructors for vector & matrix types 2016-07-01 13:59:36 -06:00
John Kessenich
d02dc5d05a HLSL: Implement switch/case/default. 2016-07-01 00:04:11 -06:00
John Kessenich
5bc4d9a26f HLSL: Airplane work: break/continue/discard grammar, and decls for for/if/while. 2016-06-27 21:12:07 -06:00
John Kessenich
19b92fff7e HLSL: Basic array grammar. 2016-06-19 11:50:34 -06:00
John Kessenich
630dd7da43 HLSL: Flesh out misc. declaration grammar: semantics/registers/annotations/precise/etc.
Details within these bear even more fleshing out, but would like to have
that driven by actual need.
2016-06-12 23:54:31 -06:00
John Kessenich
e6e7494e2a HLSL: Implement basic "struct" grammar. 2016-06-12 23:54:31 -06:00
John Kessenich
077e052a8f HLSL: Implement proper nesting of symbol-table scopes and identifier searching. 2016-06-09 02:03:46 -06:00
John Kessenich
0d2b6de45b HLSL: Attribute grammar and if-else grammar/productions. 2016-06-05 12:32:18 -06:00
John Kessenich
21472aee75 HLSL: Finish skeletan of the "statement" grammar. 2016-06-04 11:46:33 -06:00