Commit Graph

265 Commits

Author SHA1 Message Date
LoopDawg
592860cae5 Add decompositions for some HLSL intrinsics. 2016-06-10 17:11:18 -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
Jason Ekstrand
c24cc29d37 GlslangToSpv: Properly handle opaque types in TranslateStorageClass 2016-06-08 17:05:19 -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
GregF
39d5e711a7 remapper: do not eliminate interface variables in dce by default
this is done by counting op_entrypoint as a use/def
2016-06-03 09:57:57 -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
iostrows
af7f1c8f24 Fix double matrix creation 2016-06-01 16:40:00 +02: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
Jason Ekstrand
76d0ac1a6f SPV: Don't shadow sampler parameters when performing function calls
Fixes #179
2016-05-25 13:49:47 -07: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
22e0d41448 SPV: Don't put locations on OpTypeStruct. Related to Issue #291. 2016-05-20 15:40:53 -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
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
9af54c3337 Non-functional: Fix some comments English and brace formatting in recent merges. 2016-05-17 10:24:00 -06: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
bedde872b6 Merge pull request #285 from baldurk/vs2010-fixes
VS2010 compilation fixes
2016-05-17 00:31:36 -06: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
baldurk
ab44ba757e [VS2010] Remove use of ranged-for loops 2016-05-17 01:20:30 +02:00
baldurk
c1d81cb171 [VS2010] Remove use of "= default" and "= delete" 2016-05-17 01:20:25 +02:00
Rex Xu
73e3ce78f4 SPV: Handle matrix's OpFConvert vector by vector. 2016-05-14 09:20:52 +08:00
Rex Xu
5839031759 SPV: Add capability ImageGatherExtended if necessary. 2016-05-11 16:38:50 +08:00
Lei Zhang
cb3236d9f9 Use std::string for TBD/missing functionality reporting.
We can have multiple instances of the same string, so comparing
const char* is not guaranteed working.

Fixed the failure on VS 2013 with Debug build.
2016-05-10 10:52:32 -04:00
qining
25262b3fd9 Resolve comments
1. Sink adding noContraction decoration to createBinaryOperation() and
createUnaryOperation().

2. Fix comments.

3. Remove the #define of my delimiter, use global constant char.
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
John Kessenich
d3d3ce7160 Comments only. 2016-05-06 13:06:11 -06: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
91cef52f63 SPV: Non-functional: modularize createInvocationsOperation() from the previous commit. 2016-05-05 16:45:40 -06: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
e2d06dbf60 Merge pull request #268 from AWoloszyn/update-cmake
CMake: Updated to better organize folders and options.
2016-05-05 13:46:36 -06:00
Andrew Woloszyn
db0eaf9887 Updated cmake to better organize folders and options.
This adds solution folders that properly group gtest/glslang/hlsl.
This also marks gtest options as advanced so they don't show up
in cmake-gui by default.
2016-05-05 14:45:53 -04: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
Lei Zhang
09caf12bec Avoid printing to stdout directly in library functions.
Previously GlslangToSpv() reported missing/TBD functionalities
by directly writing to stdout using printf. That could cause
problems to callers of GlslangToSpv(). This patch cleans up
the error reporting logic in GlslangToSpv(), TGlslangToSpvTraverser,
and spv::Builder a little bit to use ostringstream.

Also fixed the usage of GlslangToSpv() in GTest fixtures to
capture warnings/errors reported when translating AST to SPIR-V.
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
Lei Zhang
3f460532cc Remove duplicated cmake_minimum_required() calls. 2016-05-04 17:01:36 -04: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
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
baldurk
3cb57d3731 Fix warning about losing information, use size_t instead of int 2016-04-09 13:11:49 +02:00
John Kessenich
6e620c4674 Nonfunctional: Remove stray ';' and fix Google Test sentence in README. 2016-04-07 09:10:47 -06:00
John Kessenich
7e3e486344 Memory: Don't use pool memory to store the entry point name in the intermediate representation.
This might address issue #221, which I couldn't reproduce.
2016-04-06 19:03:15 -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