Граф коммитов

691 Коммитов

Автор SHA1 Сообщение Дата
qining 5bec2b5619 integer type operation should not be noContraction 2016-05-09 10:46:40 -04:00
qining 34d257184a simplified the symbol definition collector code, add assert() 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 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 015150e4b3 Removed the redundant functionalities in the assignee checking traverser 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
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
John Kessenich 5cc344d8ce Front-End: precise: capture noContraction on output parameter declarations. 2016-05-05 13:36:55 -06:00
John Kessenich 076879d61c Merge pull request #266 from dekimir/kfixstoll
Use strtoll, as stoll is unavailable on Android.
2016-05-05 12:59:56 -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
Dejan Mircevski a25352eb4f Use strtoll, as stoll is unavailable on Android. 2016-05-05 13:46:51 -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
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 758bb5520d Bison: Non-functional: Move to revision 3.0.4.
This hopefully prevents obsucuring actual changes in a future commit.

Also, adds a script to update the grammar.
2016-05-04 12:54:56 -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
John Kessenich 6f29a1bb3b SPV for OpenGL: Issue #229: don't allow gl_VertexIndex or gl_InstanceIndex under -G. 2016-04-12 18:35:12 -06:00
baldurk 40289165dd Fix warning about function parameter shadowing class member variable 2016-04-09 13:11:50 +02: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
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
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
Eric Engestrom 6a6d6dda95 fix spelling mistakes 2016-04-03 01:17:13 +01: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
Rex Xu 4e8bf59778 Parser: Fix a build issue (VS2012). 2016-03-22 15:42:07 +08: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
Rex Xu 644c21025d Parser: Type promotion for operator modulus(%) is missing. 2016-03-18 16:26:23 +08:00
David Neto ed5fd5d846 Support compilation via MinGW
Change-Id: Ie52f0b1b2b20948c6f4b3cb5474537d36a5a3385
2016-03-16 15:41:31 -04: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
John Kessenich b3dc3acd59 Refactor TParseContext into 3 level inheritance.
Adds parseVersions.h as the base TParseVersions for versioning,
and splits the remainder between TParseContextBase (sharable across parsers)
and TParseContext (now the GLSL-specific part).
2016-03-12 19:08:55 -07:00
John Kessenich 66e2faf844 Support multiple source languages, adding HLSL as an option. 2016-03-12 18:34:36 -07:00
John Kessenich 4d65ee31a6 Generalize "main" to a settable entry point name. 2016-03-12 18:17:47 -07: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