Commit Graph

75 Commits

Author SHA1 Message Date
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
qining
95aa52737d Change to traditional 'for' loop 2016-03-09 21:40:41 -05: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
John Kessenich
52d08596ec Merge pull request #175 from rdb/master
Fix compilation issues with MSVC 2010
2016-02-27 21:29:14 -07:00
baldurk
227e026dbf MSVC warning fix - conversion from size_t to int, possible loss of data 2016-02-25 21:19:49 +01:00
rdb
32084e889d Fix compilation issues with MSVC 2010
(mostly by eliminating use of range-based for loops and std::tie)
2016-02-23 22:17:38 +01:00
Mark Adams
18b637f9dc Fix warnings/errors for strict aliasing & function prototypes
This fixes various issues related to gcc's strict-aliasing warning
by using unions. It also handles various cases hit with
gcc's missing-declarations warning.
2016-02-23 12:17:11 -05: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
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
32cfd49b68 SPV: RelaxedPrecision: Plumb this through the full AST->SPV translator. 2016-02-02 13:55:29 -07:00
Mark Adams
d5ac538e23 Fix two new Windows build warnings/errors 2016-02-01 19:13:06 -08:00
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