Commit Graph

692 Commits

Author SHA1 Message Date
John Kessenich
c51287d744 SPV: Update to spec. decisions (and issue #205) for barrier().
A barrier (ESSL/GLSL) or OpControlBarrier when in a tessellation control
shader also means doing memory synchronization for output variables.
2016-06-14 19:50:26 -06:00
LoopDawg
589107095c Implement atomic ops, bit conversions, fix fwidth stage mask, fix saturate dest modifier. 2016-06-13 20:50:36 -06:00
John Kessenich
cd784bc561 Merge pull request #337 from steve-lunarg/intrinsics
HLSL: Add decompositions for some intrinsics.
2016-06-13 08:54:45 -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
LoopDawg
592860cae5 Add decompositions for some HLSL intrinsics. 2016-06-10 17:11:18 -06:00
John Kessenich
41ebc42926 Merge pull request #335 from jekstrand/sampler-params
SPV: Fix pointer address spaces for sampler function parameters
2016-06-09 20:42:23 -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
71351de879 HLSL: Add all int/float/bool/uint matrix types, void for functions, and a few others. 2016-06-09 01:33:10 -06:00
Jason Ekstrand
ed15ef1a5b GlslangToSpv: Pass the pointer directly into the client function for opaque types
For opaque types such as samplers, images, and atomic counters, we want to
reference the actual object in the child function.  For a long time, we
used a shadow variable and made a copy of the image/sampler.  In 76d0ac1a,
this was changed to not shadow samplers.  However, this didn't cover all
opaque types and it also didn't get the pointer storage classes right.
This commit fixes both of these issues.

Fixes #324
2016-06-08 17:22:46 -07:00
David Neto
a901ffed40 Defer capability decl for ClipDistance, CullDistance, PointSize until actual use
The compiler will mark struct members with those builtins, but won't
declare the capability until that member is accessed by some executable
instruction.

Test changes:
- spv.430.vert: was missing ClipDistance capability.
- spv.precise.tese: remove TessellationPointSize capability.
2016-06-08 09:30:04 -04:00
John Kessenich
80cb324ff6 Front-end: Fix issue #146: which versions allow double in/out. 2016-06-05 18:52:05 -06:00
John Kessenich
133253b6ee Front-end: Fix issue #147: ensure layout(index=N) has N in [0,1]. 2016-06-05 17:25:34 -06:00
John Kessenich
119f8f6906 HLSL: Flesh out the loop grammar and productions. 2016-06-05 15:44:07 -06:00
John Kessenich
0d2b6de45b HLSL: Attribute grammar and if-else grammar/productions. 2016-06-05 12:32:18 -06:00
John Kessenich
1cc1a2813e HLSL: 1) Implement lookahead buffers/stacks for token advance/recede, 2) use it for cast operation.
The grammar now accepts type casts, like "(int)x", but that
has to be disambiguated from "(a + b)", needed deeper lookahead
and backing up than what existed so far.
2016-06-03 16:57:53 -06:00
LoopDawg
643fcb5b43 Add negative intrinsics tests 2016-06-03 16:28:57 -06:00
LoopDawg
ef764a24b2 Fix for empty statement segfault. 2016-06-03 10:57:03 -06:00
LoopDawg
4b67732c13 Initial implementation of direct-mapped subset of HLSL intrinsics with type subset.
This checkin implements about half of the HLSL intrinsics for a subset of their
entire type support (but a useful subset).  The uncommented lines in
TBuiltInParseablesHlsl::identifyBuiltIns shows which are connected.
2016-06-03 08:28:29 -06:00
John Kessenich
a5c33d6ffb SPV: Fix issue #320: Fetch needs to extract the image.
GLSL takes a traditional sampler, but SPIR-V wants just the
sampled image, not the combined sampler and image.
2016-06-02 23:47:29 -06:00
John Kessenich
548c3adecd Front-end: Complete GL_ARB_compute_shader, previous commit was missing new barriers.
This amends the previous commit, which ommitted barriers in version 420 for compute shader.
2016-05-30 19:38:39 -06:00
John Kessenich
d94c003fb7 Front-end: Complete GL_ARB_compute_shader implementation.
Core compute shaders were working, but the extension wasn't implemented.
2016-05-30 19:29:40 -06:00
John Kessenich
0f5e3ad23c Fix issue #313: Catch internal attempts to modify built-in symbols that don't exist.
Also beefed up support for running compute shaders is #version 420, but this
work is only partially done.
2016-05-29 18:24:31 -06:00
John Kessenich
7d8141987c Merge pull request #309 from jekstrand/sampler-params
SPV: Don't shadow sampler parameters when performing function calls
2016-05-25 17:35:54 -06:00
Jason Ekstrand
76d0ac1a6f SPV: Don't shadow sampler parameters when performing function calls
Fixes #179
2016-05-25 13:49:47 -07:00
Thomas Perl
7bfd08d21c Check for linking multiple ES shaders to the same stage 2016-05-25 09:26:43 +02:00
Thomas Perl
0bb546f8ae Fix test case for the "empty" linker test case
The test result should only give one error about linking
ES and non-ES shading language compilation units:

 - empty.frag: No version info, interpreted as 100, ES
 - empty2.frag: No version info, interpreted as 100, ES
 - empty3.frag: Version declared as 110, non-ES

Previously, because the new intermediate is always created
without version/profile information, there would be two
linker errors:

 1.) When merging the new intermediate with empty.frag
 2.) When merging (new intermediate + empty.frag + empty2.frag) with empty3.frag

Now, there is only one error; as the error with merging the
new intermediate with empty.frag has been removed.
2016-05-24 13:24:24 +02:00
Thomas Perl
63d4794e8e Add test case: Link 2 ESSL fragment shader units 2016-05-24 13:15:01 +02:00
John Kessenich
d82c906378 Vulkan: Finish semantics for what creates spec-const-semantics.
Note: This required adding a new test mode to see the AST for vulkan tests.
This also required reworking some deeper parts of type creation, regarding
when storage qualification and constness is deduced bottom-up or dictated
top-down.
2016-05-23 23:10:18 -06:00
Rex Xu
bbceed7be3 SPV: Fix an issue of interpolation decoration.
GLSL interpolation qualifiers and auxiliary storage qualifiers are not
mutually exclusive. So when they are translated to SPIR-V decorations, two
independent utility methods should be employed to do this job.
2016-05-21 09:45:47 +08:00
John Kessenich
2921e0c54a KHR_vulkan_glsl: name mangle distinguish pure textures.
Fixes issue #252.
2016-05-20 16:59:27 -06:00
John Kessenich
22e0d41448 SPV: Don't put locations on OpTypeStruct. Related to Issue #291. 2016-05-20 15:40:53 -06:00
John Kessenich
eee0c73432 Merge pull request #297 from antiagainst/config-tests
Test compiling shaders with given resource limits using GTest.
2016-05-20 13:46:31 -06:00
John Kessenich
0133c1233e HLSL: Add more matrix types to the grammar. 2016-05-20 12:17:26 -06:00
John Kessenich
8d72f1a2c4 Full stack: distinguish between a scalar and a vector of size 1.
There have been GLSL extensions considering this, and HLSL does it.
This is a fully backward compatible change that allows this distinction.
2016-05-20 12:14:39 -06:00
John Kessenich
823fc65644 SPV: Don't emit memory barrier for ESSL barrier(), but still do for GLSL barrier().
Addresses issue #205.
Current open Khronos bug for finalizing this.
2016-05-19 18:26:42 -06:00
Lei Zhang
1b141728a6 Test compiling shaders with given resource limits using GTest. 2016-05-19 14:18:21 -04:00
John Kessenich
b5cfd79f0a Merge pull request #288 from thp/attribute-reflection
Reflection: Add support for querying vertex attributes in reflection API
2016-05-19 10:13:08 -06:00
Thomas Perl
bef7428dfd Update test cases for vertex attribute reflection 2016-05-19 09:30:29 +02:00
John Kessenich
9349108d06 Merge pull request #295 from amdrexu/bugfix
Parser: Redeclaration of gl_CullDistance is disallowed mistakenly.
2016-05-19 00:00:54 -06:00
Rex Xu
3d9165fde4 Parser: Redeclaration of gl_CullDistance is disallowed mistakenly. 2016-05-19 12:26:27 +08:00
scygan
2c86427640 Fix missing location decoration for structures put directly on input/output interfaces
Spec for decorating the OpVariable:
	"The remaining variables listed by OpEntryPoint with the Input or Output storage class form the user-defined variable interface. These variables must be identified with a Location decoration"

Spec for decorating struct type:
	"The layout of a structure type used as an Input or Output depends on whether it is also a Block (i.e. has a Block decoration).
	If it is a not a Block, then the structure type must have a Location decoration"
2016-05-18 18:22:21 +02:00
John Kessenich
6e0985dd9d Merge branch 'struct_member_decorations' of https://github.com/scyganINTEL/glslang into scyganINTEL-struct_member_decorations 2016-05-17 10:03:37 -06:00
Rex Xu
c1992e5e57 SPV: Correct an issue in createUnaryMatrixOperation().
Type of the source is not necessarily the same as that of the destination.
2016-05-17 18:57:18 +08:00
John Kessenich
ebb505355d SPV: Don't add clip/cull distance capabilities unless used.
These capabalities were added on declaration of the members, but
that is considered too aggressive, as those members are automatically
declared in some shaders that don't use them.  Now, actual access
is needed to make the capabalities be declared.
2016-05-16 19:32:59 -06:00
John Kessenich
e5f29393da Tests: Add a set of gtest-file-based HLSL tests. 2016-05-16 17:39:50 -06:00
John Kessenich
7a27de6dd1 Merge pull request #253 from amdrexu/bugfix2
SPV: Handle matrix's OpFConvert vector by vector.
2016-05-16 16:49:20 -06:00
Rex Xu
62dda787c7 Parser: Add missing vector relational functions for double type. 2016-05-14 14:21:16 +08:00
Rex Xu
73e3ce78f4 SPV: Handle matrix's OpFConvert vector by vector. 2016-05-14 09:20:52 +08:00
John Kessenich
4678ca9dac HLSL: Add function call syntax and AST building. 2016-05-13 09:33:42 -06:00
John Kessenich
36962c7ab7 Merge pull request #276 from amdrexu/bugfix
Parser: Redeclare gl_ClipDistance/gl_CullDistance should update their array sizes.
2016-05-12 14:22:56 -06:00
Rex Xu
5839031759 SPV: Add capability ImageGatherExtended if necessary. 2016-05-11 16:38:50 +08:00
Rex Xu
827b23b8a1 Parser: Redeclare gl_ClipDistance/gl_CullDistance should update their array sizes. 2016-05-11 15:50:41 +08:00
John Kessenich
3357d870e4 Merge pull request #222 from Qining/support-precise
Full stack: Support *precise* qualifier
2016-05-09 20:18:33 -06:00
John Kessenich
7b3096a93d Merge pull request #270 from scyganINTEL/bitfield_buildins
Use proper precision qualifiers for bitfield build-in functions on ES
2016-05-09 20:17:40 -06:00
GregF
5bdf49cdc8 fix check for non-positive array size 2016-05-09 17:07:04 -06:00
scygan
9c56d84b73 Use proper precision qualifiers for bitfield build-in functions on ES
This change causes ES shaders to precision qualifiers for build-in functions as defined in ESSL spec. It especially mattersfor functions that are defined as highp or taking a highp.

Fixes vulkanCTS dEQP-VK.glsl.builtin.function.integer.bitfieldreverse.*, where bitfieldReverse() retval was wrongly marked as RelaxedPrecision.

Note: floatBitsToInt/floatBitsToUInt precision is also broken, but in different way - so it is not addressed here.
2016-05-09 17:51:25 +02:00
qining
5bec2b5619 integer type operation should not be noContraction 2016-05-09 10:46:40 -04:00
qining
0c96db5a4c add a test for matrix, fix a variable name 2016-05-09 10:46:40 -04:00
qining
1a0d93f416 Fix the test of precise output function parameter
Rebase to 5cc344d8ce and update the
expected test result.
2016-05-09 10:46:40 -04:00
qining
9220dbb078 Precise and noContraction propagation
Reimplement the whole workflow to make that: precise'ness of struct
    members won't spread to other non-precise members of the same struct
    instance.

    Approach:
    1. Build the map from symbols to their defining nodes. And for each
    object node (StructIndex, DirectIndex, Symbol nodes, etc), generates an
    accesschain path. Different AST nodes that indicating a same object
    should have the same accesschain path.

    2. Along the building phase in step 1, collect the initial set of
    'precise' (AST qualifier: 'noContraction') objects' accesschain paths.

    3. Start with the initial set of 'precise' accesschain paths, use it as
    a worklist, do as the following steps until the worklist is empty:

        1) Pop an accesschain path from worklist.
        2) Get the symbol part from the accesschain path.
        3) Find the defining nodes of that symbol.
        4) For each defining node, check whether it is defining a 'precise'
        object, or its assignee has nested 'precise' object. Get the
        incremental path from assignee to its nested 'precise' object (if
        any).
        5) Traverse the right side of the defining node, obtain the
        accesschain paths of the corresponding involved 'precise' objects.
        Update the worklist with those new objects' accesschain paths.
        Label involved operations with 'noContraction'.

    In each step, whenever we find the parent object of an nested object is
    'precise' (has 'noContraction' qualifier), we let the nested object
    inherit the 'precise'ness from its parent object.
2016-05-09 10:46:40 -04:00
scygan
8add151c4b SPIR-V do not decorate: members of plain structs with location; non-top level members with interp.
This fixes some vulkanCTS tests that use struct arrays as a member of in/out interface blocks.

From Vulkan spec:
"If it is a not a Block, then the structure type must have a Location decoration. Its members are assigned consecutive locations in their declaration order, with the first member assigned to the location specified for the structure type. >>>>> The members, and their nested types, must not themselves have Location decorations <<<<"

From SPIR-V spec:
"When applied to structure-type members, the Decorations Noperspective, Flat, Patch, Centroid, and Sample can only be applied to the top-level members of the structure type. (Nested objects' types cannot be structures whose members are decorated with these decorations.)"
2016-05-06 16:54:54 +02:00
John Kessenich
baa9fa5df7 Merge branch 'feature2' of https://github.com/amdrexu/glslang into amdrexu-feature2 2016-05-05 16:32:39 -06:00
John Kessenich
5cc344d8ce Front-End: precise: capture noContraction on output parameter declarations. 2016-05-05 13:36:55 -06:00
John Kessenich
c8a5676025 Merge branch 'feature' of https://github.com/amdrexu/glslang into amdrexu-feature 2016-05-05 12:04:22 -06:00
Lei Zhang
17535f7d55 Create a new logger class for all messages w.r.t. SPIR-V build. 2016-05-05 10:15:06 -04:00
Rex Xu
338b185a2b Implement the extension GL_ARB_shader_group_vote. 2016-05-05 20:38:33 +08:00
Rex Xu
574ab04caa Implement the extension GL_ARB_shader_ballot
Add new built-in variables and functions to the parser (SPIR-V tokens are missing).
2016-05-05 19:02:35 +08:00
John Kessenich
3c1e08057e Front-end precise: Propagate noContraction up the AST when dereferencing structs.
This should be the last commit in this sequence to form the base of the work
in pull request #222.
2016-05-04 13:29:21 -06:00
John Kessenich
17f0786418 Parser: Precise: Recognize 'precise', tag types, and do related semantic checking.
This partly overlaps pull request #222, we have divided the work on this one.
2016-05-04 12:54:56 -06:00
John Kessenich
34fb036a9c HLSL: Add (almost) full expression grammar: Binary, unary (pre/post-fix), assign, ... 2016-05-03 23:33:00 -06:00
John Kessenich
e512cd943e Vulkan: Add the #define VULKAN 100 when compiled for Vulkan.
Note this requires test-based piecing together of the preamble string,
so it changed to being a std::string to make it easier to do.

This closes issue #254.
2016-05-03 21:18:59 -06:00
John Kessenich
af459216a1 Correct precision qualification on built-in functions.
This is a replacement commit for pull request #238.

This is a design change, followed by implementation change that
A) fixes the changes caused by the design change, and
B) fixes some cases that were originally incorrect.

The design change is to not give built-in functions default precision qualification.
This is to allow the rule that the precision of some built-in functions adopt their
precision qualification from the calling arguments.  This is A above.

A consequence of this design change is that all built-ins that are supposed to have
an explicit precision qualifier must now be declared that way.  So, a lot more
built-in declarations now have precision qualifiers, just to keep things the same.
This is B above.
2016-05-03 19:34:00 -06:00
Rex Xu
8ff43de891 Implement the extension GL_ARB_gpu_shader_int64
- Add new keyword int64_t/uint64_t/i64vec/u64vec.
- Support 64-bit integer literals (dec/hex/oct).
- Support built-in operators for 64-bit integer type.
- Add implicit and explicit type conversion for 64-bit integer type.
- Add new built-in functions defined in this extension.
2016-04-30 13:34:34 +08:00
qining
94a89d51f3 add .err file for eof_missing test 2016-04-27 10:22:22 -04:00
qining
19647a32b9 Fix the infinite loop when an input file lacks EOF
The input scanner can be trapped in an infinite loop if the given input
file does not have EOF (and is not ended with a 'whitespace').

The problem is caused by unget(), which keeps rolling back the scanner
pointer without hitting an EOF at the end of the file. This makes getch()
function keep returning the last character of the file and never ends,
and the effect of advance() is always counteracted by unget().
2016-04-27 10:05:57 -04:00
Rex Xu
c7d3656dde SPV: Use OpLogicalEqual/OpLogicalNotEqual for boolean type comparison. 2016-04-27 08:15:37 +08:00
qining
1f2820a3d3 fix the problem that spec constant composite instruction being used when only front-end constants are used in the constructor 2016-04-14 18:34:27 -04:00
qining
27e04a004d Fix spec const construtor for matrix and vector
Fix issue: #237

1. The code generated for matrix constructor should 1) build column
vectors first, 2) build matrix with the vectors.

2. When there is only one scalar type constituent in vector's
constructor, we should populate the constituent to fill all the slots in
the vector. As for matrix, the single constituent should be populated to
the diagonal positions (top-left to bottom-right diagonal).

remove createSpvConstantFromConstSubTree()
2016-04-14 17:52:57 -04:00
qining
189b2033a4 Refine the code and address comments 2016-04-12 23:19:28 -04:00
qining
e24aa5edbb SpecOp bool->uint/int and uint<->int conversion
Bool -> uint/int with OpSpecConstantOp OpSelect instruction.

uint <-> int conversion with OpSpecConstantOp OpIAdd instruction.

Note, implicit conversion: `const uint = an_int_spec_constant` is not
supported. Explicit type casting is required: `const uint =
uint(an_int_spec_constant)`
2016-04-12 22:01:55 -04:00
John Kessenich
78a6b78810 Front-end: Get the right set of nodes marked as spec-const.
This is according to the expected KHR_vulkan_glsl without floating point.
So, floating-point spec-const operations no longer work, and that's
reflected in the tests.
2016-04-06 13:32:44 -06:00
qining
75d1d80109 add SpecConstantOpModeGuard to GlslangToSpvTraverser::visitSymbol() 2016-04-06 14:42:01 -04:00
qining
408876600f Turn on SpecConstantOpMode based on node qualifier
Move SpecConstantOpModeGuard from makeSpvConstantFromConstSubTree() to
visitbinary() and visitunary(). Checking if the visiting node is a spec
constants, if so, turn on the SpecConstantOpMode, otherwise, stay in the
normal mode.
2016-04-06 12:56:31 -04:00
qining
4c9126153d fix the wrong generated code when a non-constant array is declared with its size derived from spec constant operations 2016-04-06 12:51:50 -04:00
John Kessenich
aa0298bfde Merge pull request #220 from Qining/fix-built-in-spec-constants
Handle built-in constants redeclared with a specialization constant id.
2016-04-04 15:43:58 -06:00
qining
4f4bb81cd9 Built-in values declared as specialization constant
Support declaring built-in values as spec constants.

Refine the code in createSpvConstant().
2016-04-04 11:10:41 -04:00
John Kessenich
1c7e70763b Merge branch 'master' into hlsl-frontend 2016-04-03 20:36:48 -06:00
John Kessenich
a42533eca1 Merge pull request #190 from antiagainst/gtest
Add Google Test as the new test framework
2016-03-31 12:31:45 -06:00
John Kessenich
af59197ba4 Merge pull request #214 from amdrexu/bugfix
Parser: Update array size of gl_ClipDistance/gl_CullDistance in gl_in[].
2016-03-31 12:28:47 -06:00
qining
5c61d8e0f9 fix format; remove unnecessary parameters; rename some spec op mode guard class; remove support of float point comparison and composite type comparison; update the tests. 2016-03-31 13:57:28 -04:00
Lei Zhang
414eb60482 Link in Google Test framework.
The existing test harness is a homemade shell script. All the tests
and the expected results are written in plain text files. The harness
just reads in a test, invoke the glslangValidator binary on it, and
compare the result with the golden file. All tests are kinda
integration tests.

This patch add Google Test as an external project, which provides a
new harness for reading shader source files, compile to SPIR-V, and
then compare with the expected output.
2016-03-31 10:31:30 -04:00
qining
135452061a Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.

'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.

Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.

Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:

1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants

Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-30 16:18:26 -04:00
Rex Xu
cb0e471ad4 Parser: Update array size of gl_ClipDistance/gl_CullDistance in gl_in[]. 2016-03-27 08:47:43 +08:00
qining
0840838d17 Support specialization composite constants
Fix issue #163, support creation and reference of composite type
specialization constants.

e.g.:
```
layout(constant_id = 200) const float myfloat = 1.25;
layout(constant_id = 201) const int myint = 14;
struct structtype {
  float f;
  int i;
};
const structtype outer_struct_var = {myfloat, myint};
void main(){}
```
generated code (use glslangValidator):
```
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 12

                              Capability Shader
               1:             ExtInstImport  "GLSL.std.450"
                              MemoryModel Logical GLSL450
                              EntryPoint Vertex 4  "main"
                              Source GLSL 450
                              Name 4  "main"
                              Name 10  "structtype"
                              MemberName 10(structtype) 0  "f"
                              MemberName 10(structtype) 1  "i"
                              Decorate 7 SpecId 200
                              Decorate 9 SpecId 201
               2:             TypeVoid
               3:             TypeFunction 2
               6:             TypeFloat 32
               7:    6(float) SpecConstant 1067450368
               8:             TypeInt 32 1
               9:      8(int) SpecConstant 14
  10(structtype):             TypeStruct 6(float) 8(int)
              11:10(structtype) SpecConstantComposite 7 9
         4(main):           2 Function None 3
               5:             Label
                              Return
                              FunctionEnd
```

Rname two function names to match their functionalities.
1) Rename `GlslangToSpvTraverser::createSpvSpecConstant()` to
`createSpvConstant()`;
2) Rename `GlslangToSpvTraverser::createSpvConstant()` to
`createSpvConstantFromConstUnionArray()`

Add function `GlslangToSpvTraverser::createSpvConstantFromSubTree()` to
handle constant creation from sub trees (e.g.: specialization constants).

Related PR: #208
2016-03-24 18:04:00 -04:00
John Kessenich
7cc0e2896e Front-end infrastructure: Encapsulate semantic-level questions/actions about const/temp.
Much about const or temp is mechanical, about actual declaration,
while much is semantic, about something higher level.  This commit
checks every use everywhere, and for the high-level ones, substitutes
an encapsulated version instead.
2016-03-20 00:46:02 -06:00
Rex Xu
644c21025d Parser: Type promotion for operator modulus(%) is missing. 2016-03-18 16:26:23 +08:00
Rex Xu
d715adc0f2 SPV: Implement boolean selection for mix().
Use OpSelect to implement boolean selection of mix(). FMix is applicable
to linear blending of mix().
2016-03-15 18:19:26 +08:00
John Kessenich
5f934b039a HLSL: Accept basic funtion definitions. (Not yet mapping input/output for entry point.) 2016-03-13 17:58:25 -06:00
John Kessenich
d016be19fb HLSL: Hook up constructor expressions through the AST. 2016-03-13 11:24:20 -06:00
John Kessenich
87142c71fb HLSL: Add basic declaration syntax and AST generation. 2016-03-12 21:40:38 -07:00
John Kessenich
e01a9bc8c0 HLSL: Plumb in HLSL parse context and keywords, and most basic HLSL parser and test. 2016-03-12 21:40:08 -07:00
Dejan Mircevski
2677d918f1 Test dead-decoration removal. 2016-03-11 12:06:41 -05:00
Lei Zhang
24e4bc99ac Fix array out of bounds bug in processing if-else-endif macros.
If we are not inside an if macro, we cannot simply decrease
elsetracker.

Fixes https://github.com/KhronosGroup/glslang/issues/29.
2016-03-09 15:11:56 -05:00
John Kessenich
f7497e289b SPV: Issue #180: push_constants don't have descriptor sets. 2016-03-08 21:43:14 -07:00
John Kessenich
2107c76a08 Merge pull request #192 from Qining/enable-adding-multiviewport-capability
SPV: Declare MultiViewport capability.
2016-03-07 21:22:54 -07:00
qining
be4f52a484 Run regression tests, update spv.420.geom.out so capability MultiViewport is declared 2016-03-07 23:05:59 -05:00
John Kessenich
3c5b1e6b31 Merge pull request #168 from amdrexu/feature2
SPV: Add support for memory qualifiers.
2016-03-06 15:45:11 -07:00
John Kessenich
1250c9e1bd Merge pull request #165 from amdrexu/feature
SPV: Support the new OpCode - OpImageSparseRead
2016-03-06 15:43:01 -07:00
John Kessenich
f2d8a5c53f SPV: Use heuristic to avoid geometry multi-streams when possible. 2016-03-03 22:29:11 -07:00
John Kessenich
2ac71dfb78 Merge pull request #187 from amdrexu/bugfix
SPV: Continue to fix the issue of bool -> uint32
2016-03-03 21:59:21 -07:00
Brian Salomon
5dc8a76265 Fix line endings in Test/100.conf. 2016-03-03 12:12:07 -05:00
Rex Xu
b4fd8d10f0 SPV: Continue to fix the issue of bool -> uint32
For short-circuit operator (&& and ||), the conversion is missing.
2016-03-03 14:38:51 +08:00
Rex Xu
2725323bba SPV: Fix an issue caused by bool-to-uint32 conversion.
This issue is related with the commit
103bef9d74.
2016-02-24 12:27:10 +08:00
Rex Xu
1da878f6d1 SPV: Add support for memory qualifiers. 2016-02-21 21:02:08 +08:00
John Kessenich
0967748fbc SPV: Fix 'location' inheritance bug. 2016-02-19 12:21:50 -07:00
Rex Xu
5eafa472d3 SPV: Support the new OpCode - OpImageSparseRead 2016-02-19 22:24:03 +08:00
John Kessenich
6c292d3ba7 SPV: Implement Vulkan version of GLSL (KHR_vulkan_glsl). 2016-02-15 21:46:55 -07:00
John Kessenich
019f08fcd8 SPV: Fix issue #159: use ExplicitLod forms for non-fragment stages. 2016-02-15 15:40:42 -07:00
John Kessenich
5d0fa9781b SPV Capabilities: StorageImageExtendedFormats, StorageImageReadWithoutFormat, and StorageImageWriteWithoutFormat. 2016-02-15 11:57:00 -07:00
John Kessenich
5e80113939 SPV Capabilities: SampleRateShading, SparseResidency, MinLod, and ImageQuery. 2016-02-15 11:09:46 -07:00
John Kessenich
b0364dcc3e SPV Capabilities: Image types.
SampledBuffer
ImageBuffer
Sampled1D
Image1D
SampledCubeArray
ImageCubeArray
SampledRect
ImageRect
InputAttachment
ImageMSArray
StorageImageMultisample
2016-02-14 17:37:30 -07:00
John Kessenich
3c52207e8a SPV capabilities: Add int16, int64, float16, and float64. 2016-02-14 17:11:15 -07:00
John Kessenich
103bef9d74 SPV: Handle GLSL bool loads from a uniform buffer as a conversion from int -> bool.
SPIR-V bool is abstract; it has no bit pattern for storage with transparent memory.
OpenGL's convention is a bool in a uniform buffer is 32-bit int with non-0 being 'true'.
2016-02-08 21:41:30 -07:00
John Kessenich
ba5685a332 Semantics: Map noise*() to an operator for PureOperatorBuiltins mode.
Fixes issue #157.
2016-02-02 15:59:12 -07:00
John Kessenich
32cfd49b68 SPV: RelaxedPrecision: Plumb this through the full AST->SPV translator. 2016-02-02 13:55:29 -07:00
John Kessenich
9218759ebb SPV: Address superset of issue #151: missing OpCapability instructions.
This commit adds:
CapabilityGeometryPointSize
CapabilityTessellationPointSize
CapabilityClipDistance
CapabilityCullDistance
CapabilityMultiViewport
CapabilityTransformFeedback
CapabilityGeometryStreams
CapabilityDerivativeControl
CapabilityInterpolationFunction
2016-02-01 13:45:25 -07:00
John Kessenich
9df51caba9 Fix front-end bug: Constant folding of array-of-struct index op.
If a constant object was both an array and a structure, and was
indexed with a constant, the arrayness was ignored and the wrong
subconstant selected.  This fixes that.
2016-02-01 11:57:33 -07:00
John Kessenich
f6eae2a54a SPV: Require desktop 140 or ES 310 or above. 2016-01-22 17:47:22 -07:00
John Kessenich
4bfeed5fe8 Semantics: Spec. changing to reflect reality of int/uint conversion for |^&.
This effects 4.x, where int/uint conversions are done, but not earlier.
2016-01-22 15:40:24 -07:00
John Kessenich
4889167430 SPV: Use a more accurate MemorySemanticsAllMemory mask. 2016-01-22 10:15:03 -07:00
John Kessenich
cd26144d24 SPV: the OpImageTexelPointer sample 0 should be <id> of 0, not literal 0. 2016-01-22 09:54:12 -07:00
John Kessenich
7b9fa25bad SPV: Add recursive distrubition of 'location' across structure members. 2016-01-21 18:56:57 -07:00
John Kessenich
7a53f76d38 SPV: Add unary-matrix operations, operating at vector level. 2016-01-20 11:19:27 -07:00
Dejan Mircevski
2ab5a373d9 Add Test/spv.for-complex-condition.vert. 2016-01-20 11:54:11 -05:00
Dejan Mircevski
213bbbe4a7 Split loop header from condition testing for for/while loops. 2016-01-20 11:51:43 -05:00
Dejan Mircevski
ed55bcd9f8 Don't remove SPIR-V blocks before codegen.
A removed block releases its instructions, so Module::idToInstruction
suddenly contains dangling references.  The original motivation for
block removal was to skip some unreachable blocks, but that's already
achieved by InReadableOrder.cpp.

Also updated stale comments.
2016-01-19 21:18:14 -05:00
Dejan Mircevski
f3c63cc359 Move continue-block to after all branches. 2016-01-19 16:56:45 -05:00
Dejan Mircevski
e7f6cac1bd Merge branch 'topo' into loopgen-after-readable-order 2016-01-19 16:47:41 -05:00
Dejan Mircevski
38d039d063 Rework inReadableOrder() as a recursive descent.
Add a test for unreachable merge block.

Update test results with the new order: mainly delaying merge blocks and
removing unreachable ones.
2016-01-19 10:14:50 -05:00
Dejan Mircevski
baa55a1591 Add spv.branch-return.vert and fix inReadableOrder(). 2016-01-19 10:11:34 -05:00
John Kessenich
712ecb96a2 Doubles: Add all the missing built-in double-based prototypes. 2016-01-16 20:37:43 -07:00
John Kessenich
68f1431a55 Merge pull request #121 from amdrexu/feature
Parser & SPV: Implement two extensions regarding GLSL sparse texture.
2016-01-15 00:52:18 -07:00
John Kessenich
e95fa5e095 Tests: Update to match previous pull request. 2016-01-13 19:04:19 -07:00
Dejan Mircevski
dba2826328 Merge branch 'master' of github.com:google/glslang into loopgen
Change-Id: Ie8236430bb9e30a9be2e0c1573c42183c2f4d0d4
2016-01-11 16:26:18 -05:00
Dejan Mircevski
832c65c33b Fix back-branch target for do-while loops.
To ensure back branches always go to a header block, create a header
block even for !testFirst loops.  Then unify common code between the
testFirst/!testFirst cases.

Generate the header-block code first, so update golden files.

Realize that certain infinite loops generate invalid SPIR-V, so put a
TODO to instead abort code generation in such cases.

Change-Id: I1e173c8f73daad186cfc666b7d72bd563ed7665d
2016-01-11 15:57:11 -05:00
Dejan Mircevski
c8fbbab419 Update .out files with new loop SPIR-V.
Also update breakForLoop and call builder.closeLoop() in code
generation.

Remove dead code.

Change-Id: Ic8ce5b208530f8787989ef45a2efa405f1b45310
2016-01-11 14:48:36 -05:00
Dejan Mircevski
13228243b2 Test a for loop with no body.
Change-Id: I5b53cc008349afad94b14500506fcab4d6e64d2e
2016-01-10 23:15:08 -05:00
Dejan Mircevski
e537b8b488 Fix unreachable-block removal.
Add a test for loop without a condition.

Change-Id: Idd7fc462218a84b1e745207e2975a3f2897d30a0
2016-01-10 19:37:00 -05:00
Dejan Mircevski
9c6734c8df First cut at new loop codegen.
Change-Id: Id3bdf8b7a5606e7ce5d856ef225d5ddbe59a584b
2016-01-10 12:15:13 -05:00