Commit Graph

1014 Commits

Author SHA1 Message Date
John Kessenich
3dad506ac6 Merge pull request #215 from Qining/spec-constants-operations
SPV: Spec Constant Operations
2016-03-31 12:22:14 -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
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
John Kessenich
c3869fee41 Merge pull request #211 from Qining/spec-constants-composite
SPV: Support specialization composite constants.
2016-03-25 13:17:27 -06: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
28001b1cbb Merge pull request #212 from amdrexu/bugfix
VS2012: Fix a build issue in parser.
2016-03-22 08:56:20 -06:00
Rex Xu
4e8bf59778 Parser: Fix a build issue (VS2012). 2016-03-22 15:42:07 +08:00
John Kessenich
5ace09a75b Merge pull request #210 from AWoloszyn/fix-compilation
Fixed compilation issue introduced by my last commit
2016-03-21 14:06:55 -06:00
Andrew Woloszyn
272afd2d0a Fixed compilation issue introduced by my last commit 2016-03-21 16:05:47 -04:00
John Kessenich
56368b68ed Merge pull request #198 from AWoloszyn/update-includer
Updated the includer interface to allow relative includes.
2016-03-21 13:23:20 -06:00
John Kessenich
ddb65a46f7 Front-end: Propagate spec-constness up through aggregate constructors. 2016-03-21 12:55:00 -06:00
Andrew Woloszyn
a132af5b78 Updated the includer interface to allow relative includes.
This plumbs both the current file path and the include depth
back up to the includer. This allows the includer to properly
support relative paths.

This also replaces the string copy that was done during include
with a zero-copy method of accomplishing the same thing. This
prevents extra copies of entire files.
2016-03-21 10:19:45 -04:00
John Kessenich
6d2b07dc39 Front-end: propagate specialization-constness through conversions and swizzles. 2016-03-20 18:45:23 -06:00
John Kessenich
a5845766e0 Front-end: Add specialization-constant subtrees for const variables/symbols. 2016-03-20 16:46:00 -06: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
John Kessenich
952543e757 Front-end infrastructure: simplify and localize creating symbol nodes, reducing replication. 2016-03-19 18:10:22 -06:00
John Kessenich
2cc221ade3 Merge pull request #209 from amdrexu/bugfix
Parser: Type promotion for operator modulus(%) is missing.
2016-03-18 14:42:07 -06:00
Rex Xu
644c21025d Parser: Type promotion for operator modulus(%) is missing. 2016-03-18 16:26:23 +08:00
John Kessenich
b1dece2737 Merge pull request #203 from dneto0/wip-mingw
Support Linux-to-Windows cross compile via MinGW
2016-03-16 14:08:30 -06:00
David Neto
ed5fd5d846 Support compilation via MinGW
Change-Id: Ie52f0b1b2b20948c6f4b3cb5474537d36a5a3385
2016-03-16 15:41:31 -04:00
John Kessenich
2de792c574 Merge pull request #204 from amdrexu/bugfix
SPV: Implement boolean selection for mix().
2016-03-15 09:14:27 -06: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
6cc7674b6d Merge pull request #199 from dekimir/test-dead-decors
SPV test: Test dead-decoration removal.
2016-03-11 12:34:02 -07:00
Dejan Mircevski
2677d918f1 Test dead-decoration removal. 2016-03-11 12:06:41 -05:00
John Kessenich
5639f3aca5 Merge pull request #195 from Qining/remove-decoration-on-undef-IDs
SPV: Remove decoration of undefined IDs
2016-03-10 09:51:22 -07:00
qining
95aa52737d Change to traditional 'for' loop 2016-03-09 21:40:41 -05:00
John Kessenich
663cbcdcf8 Merge pull request #194 from google/if-macro
Preprocessor: Fix array out of bounds bug in processing if-else-endif macros.
2016-03-09 19:07:41 -07:00
qining
da39733f28 Remove decoration of undefined IDs
Fix issue #185 by removing OpDecorate instructions whose target IDs are
defined in unreachable blocks and thus not dumped in the generated
SPIR-V code.
2016-03-09 19:54:03 -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
qining
3d7b89a872 Enable adding capability: MultiViewport
Fix issue #191:
https://github.com/KhronosGroup/glslang/issues/191
2016-03-07 21:32:15 -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
84ecb413ac Infrastructure: Tweak CMake for 31c294cea8, removal of bison. 2016-03-06 15:37:56 -07:00
John Kessenich
31c294cea8 Merge pull request #122 from baldurk/remove-bison-binary
Remove bison binary
2016-03-06 15:14:46 -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
John Kessenich
be0fa3c4c0 Merge pull request #188 from bsalomon/master
Fix line endings in Test/100.conf
2016-03-03 21:57:51 -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
John Kessenich
8e3f4c2d66 Syntax: correct spelling of rgb10_a2ui. 2016-03-01 08:43:17 -07:00
baldurk
395b7dd3f5 Remove custom command for bison, it fails if bison is not found 2016-02-28 09:15:31 +01:00
baldurk
530690e442 Commit bison-generated files from Windows GNU Bison 2.7 2016-02-28 09:15:31 +01:00
baldurk
ac13240328 Add a note to README.md about how to build the bison grammar 2016-02-28 09:12:01 +01:00
baldurk
768fb8b49e Remove bison binaries see issue #103 2016-02-28 09:12:00 +01:00
John Kessenich
32fb11daa9 Merge pull request #173 from amdrexu/bugfix
SPV: Fix an issue caused by bool-to-uint32 conversion.
2016-02-27 21:37:17 -07:00
John Kessenich
52d08596ec Merge pull request #175 from rdb/master
Fix compilation issues with MSVC 2010
2016-02-27 21:29:14 -07:00
John Kessenich
ced70f4e28 Merge pull request #178 from baldurk/minor-warning-fix
Minor warning fixes
2016-02-27 21:14:15 -07:00