Commit Graph

110 Commits

Author SHA1 Message Date
Dejan Mircevski
97605c86fd Fix #137 by avoiding a C++11 feature.
Apparently, older MSVC versions don't support brace-initializers for
function arguments.

Thanks @baldurk for a suggestion on his branch.
2016-01-20 10:25:28 -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
e7f6cac1bd Merge branch 'topo' into loopgen-after-readable-order 2016-01-19 16:47:41 -05:00
Dejan Mircevski
454796e008 Call addPredecessor() on OpSwitch blocks. 2016-01-19 10:10:15 -05:00
Dejan Mircevski
5fe789b4af Add Block::successors. 2016-01-19 10:10:15 -05:00
John Kessenich
3e9add360d Merge pull request #133 from AWoloszyn/spirv-memory
Free memory associated with SPIR-V generation and the pragmaTable.
2016-01-18 10:48:07 -07:00
Andrew Woloszyn
b7946d16bb Free memory associated with SPIR-V generation. 2016-01-18 10:29:41 -05: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
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
7819bee82c Switch loops stack to use LoopBlocks.
Also remove dead code.

Change-Id: I2c0177d8cab48b7d6f9442715aecb7951597f3c8
2016-01-11 09:35:22 -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
Mark Adams
364c21c8c0 Fix several build warnings/error encountered with VS2013
This also fixes the newlines for spirv.hpp to be consistent with the rest of the files.
2016-01-06 13:41:02 -05:00
Rex Xu
48edadfd24 Parser & SPV: Implement two extensions regarding GLSL sparse texture.
Implement extension "GL_ARB_sparse_texture2".
Implement extension "GL_ARB_sparse_texture_clamp".
2016-01-05 16:07:02 +08:00
John Kessenich
e23c9849c2 SPV: Handle type punning in createCompositeCompare(). 2016-01-04 23:59:09 -07:00
John Kessenich
c9e0a42b92 SPV: Handle stride decorations for arrays of arrays, and using multiple type instances when strides are used. 2015-12-29 21:27:24 -07:00
John Kessenich
50e57560a1 SPV: Don't make MissingFunctionality() exit anymore. 2015-12-21 21:21:11 -07:00
John Kessenich
2211835b4d SPV: Implement composite comparisons (reductions across hierchical compare). 2015-12-21 20:54:09 -07:00
John Kessenich
76f7139789 SPV: Modify last merge: Have promoteScalar() generate the correct vectorType. 2015-12-09 19:08:42 -07:00
Rex Xu
e723b45bca SPV: Scalar smear operation should use type of the scalar to make the
expected vector type when the provided vector type is incompatible with
the scalar.
2015-12-09 16:05:06 +08:00
John Kessenich
55e7d11ce8 SPIR-V: Move from Version .99 Rev 31 to Version 1.0, Rev 2. 2015-11-15 22:31:41 -07:00
John Kessenich
f685df8c16 Add comment that was missed in previous commit. 2015-10-13 10:55:08 -06:00
John Kessenich
716312771c SPV constants and constOffsets completion: isConstant() and disassembler to see results.
Expand to full isConstant() implementation.
Fix disassembler to generate texture look-up masks.
2015-10-13 10:45:22 -06:00
Rex Xu
86e608133c Generate correct image operand mask for Offset and ConstOffset(#77) 2015-10-11 19:37:48 +08:00
John Kessenich
ee21fc9081 SPV: Fix missing 'Member' operand to OpArrayLength. 2015-09-21 21:50:29 -06:00
Andrew Woloszyn
2d83ab2f57 Fixed subtle issue that causes tests to fail in VS2013 in some configs.
Depending on specific optimization settings VS2013 will sometimes
execute the operands to

new Instruction(builder.getUniqueId(), builder.makeBoolType(), OpPhi)

left-to-right, and sometimes right-to-left. Since makeBoolType can
also call getUniqueId(), the IDs to the OpPhi can sometimes be swapped.

This guarantees an explicit ordering of the Ids so that tests work
reliably.
2015-09-18 16:12:03 -04:00
John Kessenich
b56a26ab4d SPV: Generate the LocalSize Execution Mode for compute shaders. 2015-09-16 16:04:05 -06:00
Rex Xu
bba5c80957 Merge master branch from upstream 2015-09-16 13:20:37 +08:00
John Kessenich
7355eebb18 SPV legacy texturing: Smear result of Op*Dref* up to a vector to match
the expectations of old GLSL shadow*() lookups.
2015-09-14 22:08:12 -06:00
John Kessenich
e770b3e6cf SPV return from main: Simplify a legacy design such returns are not jumps to exit block.
Structured control-flow rules allow leaving the middle of a construct through
a return, but not through a jump to a block that does a return.

Addresses issue #58.
2015-09-14 21:08:58 -06:00
Rex Xu
30f9258d5e Merge master branch from upstream 2015-09-14 10:38:56 +08:00
John Kessenich
fa668dad99 SPV: Reduce spurious type generation by removing intermediate types in the middle of access chains.
This generally simplifies access chain generation, with far fewer  type conversions.
It is particularly important to future SPIR-V changes where there is less aggregate
type uniqueness due to carrying different layout information with the type.
2015-09-13 14:46:30 -06:00
John Kessenich
c9a808319a SPV arrays: Add support for runtime-sized array types and arrays of arrays.
This includes run-time block.member.length() (OpArrayLength).
2015-09-13 10:18:19 -06:00
Rex Xu
fc6189197d SPIRV: Add the support of missing image functions #72 2015-09-09 16:42:49 +08:00
Jason Ekstrand
18b9fbd742 SPIRV: Add support for texelFetch
There's nothing really special about texelFetch other than the opcode and
some restrictions so adding it is pretty trivial.
2015-09-05 14:17:24 -07:00
Miro Knejp
28f9b1c28d SPIR-V: Return undefined values from implicit returns instead of dummy
Previously if a non-void function implictly returned, a dummy variable
was created as return value. Now instead it returns the result of the
OpUndef instruction. This better conveys the presence of undefined
behavior to SPIR-V consuming tools (and humans).

It also saves one ID per occurrence...
2015-08-11 03:26:46 +02:00
John Kessenich
5e4b1242bf Move to revision 31 of SPIR-V. 2015-08-06 22:55:01 -06:00
John Kessenich
306695360d Fixes to 8f1684b7bb, merge pull request 52. 2015-08-06 22:02:24 -06:00
baldurk
d7c5ead6a1 Compile fixes for gcc -Wall 2015-08-05 21:04:23 +02:00
John Kessenich
426394d0c8 AST -> SPV: Add basic atomic_uint and atomic*() built-in function functionality. 2015-07-23 10:22:48 -06:00
David Neto
3e6a33cedf spv::Builder::Loop constructor inits all members.
After construction, the Loop is effectively const.

This perturbs the IDs in SPIR-V tests because the body block
is created before generating any of the loop code, rather than
only when the body is first referenced.
2015-07-22 12:24:21 -04:00
John Kessenich
96f4911351 SPV: Make previous commit compile with MSVC 2012. 2015-07-20 22:34:49 -06:00
David Neto
c22f37cfb4 Generate correctly structured do-while loops.
The loop test is always emitted before the loop body.

For do-while loops, use a phi node to track whether we're
on the first loop iteration, and only check the loop test
on the second and subsequent iterations.

For do-while loops, the loop test branch no longer occurs
at the top of the loop, so it must get its own selection
merge instruction.

A block can't be the target of more than one merge instruction.
So when the loop test executes after the body (as in do-while in GLSL)
we need to introduce a dummy block to be the target of the selection
merge just before the loop test conditional branch.

The other arm of the branch exits the loop and hence is the
"break block" exception in the structured control flow rules.
2015-07-17 17:51:51 -04:00
baldurk
d76692dfb8 on x64, size_t is 64-bit and int is 32-bit, so needs an explicit cast 2015-07-12 11:32:58 +02:00
Andre Weissflog
a5ade51363 Fix most clang warnings
- member initializing order in some constructors
- missing default branches in switch-case
- uninitialized variable if switch-case default (uncritical because
  program would exit)
- && and || brace warnings in if()
2015-07-11 14:45:57 +02:00
John Kessenich
140f3df134 Final round for line endings. 2015-06-26 16:58:36 -06:00
John Kessenich
fae38ee277 glslang portability: Fixed a slew of OSX compilation warnings (but not all).
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31469 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-06-10 23:23:12 +00:00
John Kessenich
79eaa91e6f glslang portability: Resolve OSX errors, some other OS warnings.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31468 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-06-10 22:05:48 +00:00
John Kessenich
06e1d0b434 glslang -> SPV: Improvements in swizzles on access chains: Bug 14007 (wrong type), simplications, tests, support mixed swizzle with dynamic component selection.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31277 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-05-22 21:57:58 +00:00
John Kessenich
e61ed59726 glsl -> SPV: fix OpVectorInsertDynamic result type bug.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31262 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-05-22 00:58:41 +00:00
John Kessenich
593a3f7f6b glslang -> SPV: improved support for do-while/continue. Contributed by David Neto (dneto@google.com).
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31205 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-05-15 18:44:16 +00:00
John Kessenich
93dfbe1309 glslang: Fix over 100 warnings from MSVC warning level 4.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31202 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-05-15 17:30:55 +00:00
John Kessenich
735a2efa70 glslang -> SPV: 1) Include post switch-break unreachable blocks and 2) Generally, don't emit degenerate (basically empty) unreachable blocks.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31023 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-05-03 22:38:16 +00:00
John Kessenich
bcef333a78 SPV: Emit layout(index=) as Index decoration.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30939 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-04-27 10:03:25 +00:00
John Kessenich
edd181944e glslang and SPIR-V: Some basic turn on for doubles (previously untested but existed code). Partly from a submission, partly addressing bug 13772.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30794 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-04-17 21:47:07 +00:00
John Kessenich
5302c7d836 glslang -> SPIR-V: Correct renaming mistake made in moving to the auto-generated headers.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30510 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-04-03 00:10:51 +00:00
John Kessenich
b40d6ac9e7 glslang AST -> SPIR-V: Move to new auto-generated official headers, and for the disassembler, mirror the split done between the auto-generation header database and the specification.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30434 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-03-30 17:41:16 +00:00
John Kessenich
1f77cacd69 glslang -> SPIR-V: Correct code generated for EmitStreamVertex and EndStreamPrimitive.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30270 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-03-24 00:32:50 +00:00
John Kessenich
0df0cdeeeb glslangValidator: Add straightforward SPIR-V support (non-optimizing, ~3.x functionality).
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30032 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2015-03-03 17:09:43 +00:00