Commit Graph

576 Commits

Author SHA1 Message Date
Rex Xu
5eafa472d3 SPV: Support the new OpCode - OpImageSparseRead 2016-02-19 22:24:03 +08: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
5d0fa9781b SPV Capabilities: StorageImageExtendedFormats, StorageImageReadWithoutFormat, and StorageImageWriteWithoutFormat. 2016-02-15 11:57:00 -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
ba5685a332 Semantics: Map noise*() to an operator for PureOperatorBuiltins mode.
Fixes issue #157.
2016-02-02 15:59:12 -07:00
John Kessenich
32cfd49b68 SPV: RelaxedPrecision: Plumb this through the full AST->SPV translator. 2016-02-02 13:55:29 -07:00
John Kessenich
9218759ebb SPV: Address superset of issue #151: missing OpCapability instructions.
This commit adds:
CapabilityGeometryPointSize
CapabilityTessellationPointSize
CapabilityClipDistance
CapabilityCullDistance
CapabilityMultiViewport
CapabilityTransformFeedback
CapabilityGeometryStreams
CapabilityDerivativeControl
CapabilityInterpolationFunction
2016-02-01 13:45:25 -07:00
John Kessenich
9df51caba9 Fix front-end bug: Constant folding of array-of-struct index op.
If a constant object was both an array and a structure, and was
indexed with a constant, the arrayness was ignored and the wrong
subconstant selected.  This fixes that.
2016-02-01 11:57:33 -07:00
John Kessenich
f6eae2a54a SPV: Require desktop 140 or ES 310 or above. 2016-01-22 17:47:22 -07:00
John Kessenich
4bfeed5fe8 Semantics: Spec. changing to reflect reality of int/uint conversion for |^&.
This effects 4.x, where int/uint conversions are done, but not earlier.
2016-01-22 15:40:24 -07:00
John Kessenich
4889167430 SPV: Use a more accurate MemorySemanticsAllMemory mask. 2016-01-22 10:15:03 -07:00
John Kessenich
cd26144d24 SPV: the OpImageTexelPointer sample 0 should be <id> of 0, not literal 0. 2016-01-22 09:54:12 -07:00
John Kessenich
7b9fa25bad SPV: Add recursive distrubition of 'location' across structure members. 2016-01-21 18:56:57 -07:00
John Kessenich
7a53f76d38 SPV: Add unary-matrix operations, operating at vector level. 2016-01-20 11:19:27 -07:00
Dejan Mircevski
2ab5a373d9 Add Test/spv.for-complex-condition.vert. 2016-01-20 11:54:11 -05:00
Dejan Mircevski
213bbbe4a7 Split loop header from condition testing for for/while loops. 2016-01-20 11:51:43 -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
f3c63cc359 Move continue-block to after all branches. 2016-01-19 16:56:45 -05:00
Dejan Mircevski
e7f6cac1bd Merge branch 'topo' into loopgen-after-readable-order 2016-01-19 16:47:41 -05:00
Dejan Mircevski
38d039d063 Rework inReadableOrder() as a recursive descent.
Add a test for unreachable merge block.

Update test results with the new order: mainly delaying merge blocks and
removing unreachable ones.
2016-01-19 10:14:50 -05:00
Dejan Mircevski
baa55a1591 Add spv.branch-return.vert and fix inReadableOrder(). 2016-01-19 10:11:34 -05:00
John Kessenich
712ecb96a2 Doubles: Add all the missing built-in double-based prototypes. 2016-01-16 20:37:43 -07: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
John Kessenich
e95fa5e095 Tests: Update to match previous pull request. 2016-01-13 19:04:19 -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
c8fbbab419 Update .out files with new loop SPIR-V.
Also update breakForLoop and call builder.closeLoop() in code
generation.

Remove dead code.

Change-Id: Ic8ce5b208530f8787989ef45a2efa405f1b45310
2016-01-11 14:48:36 -05:00
Dejan Mircevski
13228243b2 Test a for loop with no body.
Change-Id: I5b53cc008349afad94b14500506fcab4d6e64d2e
2016-01-10 23:15:08 -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
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
4998789d4e SPV: Fix array strides by explicitly computing them in the getBaseAlignment() algorithm. 2015-12-29 19:20:55 -07:00
John Kessenich
e0b6cad44f SPV: Generalize multiple struct-type instances for interpolation/invariant qualifiers. 2015-12-24 10:30:13 -07:00
John Kessenich
69d01eadd6 Semantics: Catch nested types containing 'int' with non-'flat' interpolation. 2015-12-22 16:39:07 -07:00
John Kessenich
2211835b4d SPV: Implement composite comparisons (reductions across hierchical compare). 2015-12-21 20:54:09 -07:00
John Kessenich
59420fd356 SPV: Move to deterministic results for OpEntryPoint, for test stability across platforms. 2015-12-21 11:45:34 -07:00
John Kessenich
7ba6341a05 SPV: Make OpEntryPoint I/O list include all static uses.
Before, it was only including explicit interface, sufficient for IO-Block-declared
oriented interface, but not sufficient for all modes GLSL might be used with
SPIR-V.

Two things are accomplished now:
1) each id will appear exactly once
2) the OpEntryPoint list will union static use with declarations
2015-12-20 17:37:07 -07:00
John Kessenich
3ac051e41d SPV: recursively propagate row/col majorness through nested structures.
This includes doing structure uniqueness modulo majorness, for shared nested structures.
2015-12-20 12:25:21 -07:00
John Kessenich
f85e806e44 SPV: Nested layouts: Recursively send around the top-level std140 or std430 packing.
This also distinguishes between the same struct included in multiple parent packings.
2015-12-19 15:21:38 -07:00
John Kessenich
b62e693f74 Merge pull request #118 from amdrexu/bugfix
SPV: Fix an issue related with imageStore() for 2DMS.
2015-12-19 11:20:25 -07:00
John Kessenich
aa1dd61257 Merge branch 'master' of github.com:KhronosGroup/glslang 2015-12-19 11:10:56 -07:00
John Kessenich
b6d7fa91a1 Merge pull request #117 from amdrexu/feature
SPV: Implement GLSL built-in bitcast functions.
2015-12-19 11:08:02 -07:00
John Kessenich
297bb3f2d0 Tests for PR: Fix results for 4f68b83ea1. 2015-12-19 11:05:44 -07:00
John Kessenich
61c47a951b Constant folding: Correct result type of non-square matrix folding.
This also made the function easier to read by identifying
left and right operands more clearly.
2015-12-16 15:50:25 -07:00
Rex Xu
7beb44190f SPV: Fix an issue related with imageStore() for 2DMS. 2015-12-15 17:52:45 +08:00
Rex Xu
cbc426ee62 SPV: Implement GLSL built-in bitcast functions. 2015-12-15 16:03:10 +08:00
John Kessenich
e7c83cfb8c SPV GLSL.std.450: Add needed smear operations for min, max, clamp, mix, step, and smoothstep. 2015-12-13 13:34:37 -07:00
John Kessenich
6feb4989fe SPV texturing: Use comp. 2 as the 3rd comp. for Dref in ImageSampleProjDrefImplicitLod. 2015-12-13 12:23:33 -07:00
John Kessenich
61d9fb9048 Semantics: 'invocations' defaults to 1, not 0.
'invocations' was using 0 as the "shader never set" flag and as the
default. Formalize this and explicit set to 1 and link time.
2015-12-13 10:59:17 -07:00
John Kessenich
04bb8a01d6 SPV: Implement all matrix operators {+,-,*,/} for {matrix,scalar,vector}. 2015-12-12 12:28:14 -07:00
John Kessenich
494a02a2b0 Semantics: Geometry stage can support max_vertices = 0.
To do this, more generally use a named -1 as a not set value.
2015-12-11 17:54:35 -07:00
John Kessenich
3c24a06c8c SPV tests: Turn on some more tests related to currently pending issues. 2015-12-11 15:08:26 -07:00
John Kessenich
cc16fa0720 Tests: Move to just linefeed to simply cross-platform test changes. 2015-12-10 18:01:54 -07:00
John Kessenich
562394d112 Linux: Fix case of test file. 2015-12-10 12:01:41 -07:00
John Kessenich
c51710e0a9 Merge pull request #115 from amdrexu/bugfix
SPV: Smear 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 18:47:48 -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
Rex Xu
e553ace049 Parser: Extension requirement of gl_PrimitiveID and gl_Layer should be checked only for ESSL instead of GLSL. 2015-12-09 15:03:41 +08:00
John Kessenich
e00e72ded1 SPV: Protect getStorageClass() with a test that the thing is pointer. 2015-12-08 20:48:49 -07:00
John Kessenich
33661450c7 SPV: Implement OpImage functionality (emit before query). 2015-12-08 19:32:47 -07:00
Rex Xu
7a26c176ce SPV: Implement GLSL interpolation built-in functions. 2015-12-08 17:40:11 +08:00
John Kessenich
8c1c2ca0d7 Built-ins: fix mapping of packDouble2x32 and unpackDouble2x32. 2015-12-06 19:33:07 -07:00
John Kessenich
2359bd0a1d SPV: Fix extra operands when using the "struct" form of a built-in taking an 'out' param. 2015-12-06 19:29:11 -07:00
John Kessenich
e721f49dbd SPV: Distinguish between std140 and std430 layouts, and correctly use alignments as the base for strides. 2015-12-06 19:17:49 -07:00
John Kessenich
dd6ca17845 Semantics: Correct that std430 is universally disallowed with 'uniform'. 2015-12-06 18:10:27 -07:00
John Kessenich
1be8063e01 Require l-value patch-out indexing to be gl_InvocationID.
Also, generally allow ES variable indexing of in/out blocks.
2015-11-28 16:52:25 -07:00
John Kessenich
989df85dcd Array-sizing bug fix: multiple array initializers of different size in the same declaration.
Handles the case of
    float[] x = float[] (1.0, 2.0, 3.0),
            y = float[] (1.0, 2.0, 3.0, 4.0);
where a shallow copy of the type arrayness from the left-most float[]
was getting used twice.
2015-11-28 12:52:29 -07:00
Rex Xu
71519fe70b SPV: Fix an issue related with using CubeArrayShadow for texture() 2015-11-22 21:43:05 +08:00
John Kessenich
085371d9d4 SPV testing: Add missing test case. 2015-11-16 09:31:26 -07: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
fa540d1414 SPV: Remove accidental inclusion of a test. 2015-10-15 13:55:18 -06:00
John Kessenich
7c1aa1026e SPV: Implement short circuiting of && and || when emitting SPIR-V. 2015-10-15 13:50:48 -06:00
John Kessenich
da581a2b95 GL_ARB_shader_draw_parameters: From @amdrexu, implement extension. 2015-10-14 14:10:30 -06:00
John Kessenich
b5c046e58b Front-end: Fix missing tessellation shader built-in qualifiers.
The gl_in array has a special path due to context-specific
gl_MaxPatchVertices, making the code out of order for tagging built-ins.
This commit moves the tagging to the correct location.
This also fixes issue #80.
2015-10-13 17:23:10 -06:00
John Kessenich
e690332c3c SPV: Add modes for spacing, depth, depth replacing, winding, and point mode. 2015-10-13 16:29:02 -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
19c6e5919f Fix an issue related with texelFetchOffset 2015-10-12 17:02:21 +08:00
John Kessenich
820a22fcc8 Give error for calling a user-defined function at global scope. 2015-10-06 13:11:38 -06:00
John Kessenich
894c1c109f Add another frexp() test. 2015-10-05 10:00:27 -06:00
John Kessenich
eb505e4262 Allow future keywords to be accessed as members in a struct.
This fixes a bug where a token that could be a keyword in one version
is not a keyword in another version, but treated like a non-member after
a "." dereference.
2015-10-02 15:01:53 -06:00
John Kessenich
6373574b13 Front-end: Fix: Cubemap arrays only use 3-component coord when accessed as an image.
4 components are needed when used a texture, but not an image, which multiplies
layers and faces into the same coordinate.  This fixes it from using 4 everywhere,
to only using 4 for textures and 3 for images.
2015-10-01 12:40:48 -06:00
John Kessenich
3cd0024ea8 GLSL front-end: Check recursively for opaque types in a block; these are all illegal. 2015-09-30 18:57:47 -06:00
John Kessenich
ee21fc9081 SPV: Fix missing 'Member' operand to OpArrayLength. 2015-09-21 21:50:29 -06:00
John Kessenich
b56a26ab4d SPV: Generate the LocalSize Execution Mode for compute shaders. 2015-09-16 16:04:05 -06:00
John Kessenich
56bab0483a SPV: Minor corrections to previous big merge for images and atomics. 2015-09-16 11:42:16 -06:00
Rex Xu
6b86d496c2 Add new test case for image functions and fix issues caught by this test 2015-09-16 17:48:22 +08:00
John Kessenich
2398b3a458 Full stack: implement textureQueryLod(*) and textureQueryLevels(*). 2015-09-15 19:38:56 -06:00
John Kessenich
3e60a6ff13 SPV OpAtomicCompareSwap: Generate correct operand order and number of operands. 2015-09-14 22:45:16 -06: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
John Kessenich
5f5b205ce9 Bump up layout(location) limit from 62 to 4094, to handle bigger uniform locations. 2015-09-13 21:03:33 -06: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
John Kessenich
9312269d09 Front-end Arrays of arrays: Add ES-specific checks and tests. AoA should be quite close to done now. 2015-09-11 15:25:38 -06:00
John Kessenich
31ed4830d1 SPV: Only decorate array and matrix strides for transparent types requiring explicit layouts. 2015-09-09 17:51:38 -06:00
John Kessenich
874b1f8858 Add test results for merge pull request #69. 2015-09-09 16:36:37 -06:00
John Kessenich
358dd560c5 Update test results for pull request #68, SPIRV: Decorate matrices and arrays with their strides. 2015-09-09 16:19:15 -06:00
John Kessenich
68e1c454da Merge pull request #60 from xorgy/no-define-defined
Preprocessor:  'defined' cannot be used as a macro name in #define or #undef.
2015-09-09 15:45:23 -06:00
John Kessenich
c8b2e36f52 Implement GL_KHR_blend_equation_advanced. 2015-08-30 05:43:51 -06:00
Aaron Hamilton
7d3b73bfff 'defined' cannot be used as a macro name in #define or #undef. 2015-08-29 23:15:13 +00:00
John Kessenich
d6c37b190b GL_OES_shader_multisample_interpolation: Include scalar swizzles as valid for interpolateAt*. 2015-08-22 16:54:35 -06:00
John Kessenich
0fc4338f3e Implement GL_OES_shader_multisample_interpolation, as well as core desktop versions of it. 2015-08-22 13:11:12 -06:00
John Kessenich
fc51d284aa Backward incompatible: Turn on PureOperatorBuiltins: use only enum-based built-in functions in the AST.
If this breaks your AST consumer, best is to modify it to test
against the enum values instead of doing string comparisons on
built-in function names.  This is the reason the change was made.

If you need the old behavior, you should be able to get it back by changing
PureOperatorBuiltins to be false instead of true.  This path will work for
a while, but is marked deprecated.

Also, the old behavior is tagged as release 2.4.
2015-08-19 13:43:25 -06:00
John Kessenich
ef676b0a59 Front-end "pure" built-in TOperator: Finish adding full support, but still turned off.
This is to avoid all need to do text comparison of built-in function names
when consuming the AST.  All built-in functions get enumerants.

Will want to turn on soon.  See PureOperatorBuiltins.  See issue #8.
2015-08-18 23:17:15 -06:00
John Kessenich
e88217b7d8 Add more TOperator: fma/frexp/ldexp, AddCarry/SubBorrow/MulExtended/Bit*/Find*, (un)pack4x8/2x32, ftransform.
Also corrects some existing ones missing the "Op" part of their name.
2015-08-18 22:27:23 -06:00
John Kessenich
f5b2c06b32 Turn on the gpu_shader5 of the AEP .tesc test. 2015-08-18 22:27:22 -06:00
John Kessenich
fb5ba510ca Implement GL_OES_shader_image_atomic. 2015-08-16 23:40:15 -06:00
John Kessenich
556ab3ac96 Implement GL_OES_sample_variables. 2015-08-16 21:55:59 -06:00
John Kessenich
a39159a192 Implement GL_OES_texture_storage_multisample_2d_array. 2015-08-16 21:10:38 -06:00
John Kessenich
2b0a11351f Fix two multi-sample bugs: 1) include MS in name mangling, 2) add 'sample' argument texelFetch(*MS*,...). 2015-08-16 21:04:07 -06:00
John Kessenich
dc9eff7221 Implement GL_OES_texture_cube_map_array. 2015-08-16 14:21:20 -06:00
John Kessenich
302b46aebc Implement GL_OES_texture_buffer. 2015-08-16 13:11:01 -06:00
John Kessenich
30314590ff Implement GL_OES_primitive_bounding_box. 2015-08-16 12:09:15 -06:00
John Kessenich
cee88e3644 Whitespace in preprocessor results; trying to eliminate differences. 2015-08-16 11:35:30 -06: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
65c78a0b62 Array of array: Implement the core functionality: types, constructors, operations.
There will be subsequent commits to refine semantics, esp. version-specific semantics,
as well as I/O functionality and restrictions.

Note: I'm getting white-space differences in the preprocessor test results,
which I'm not checking in.  I think they need to be tagged as binary or something.
2015-08-10 17:08:55 -06:00
John Kessenich
5e4b1242bf Move to revision 31 of SPIR-V. 2015-08-06 22:55:01 -06:00
Lei Zhang
1eed969b2d Output wrapping #line directives for included content.
Also changed the includer interface to let it return the actual
full path of the included file.
2015-07-31 19:41:19 -04:00
Lei Zhang
9c1280b225 Use extension framework to enable #include directive.
This patch introduces a new extension, GL_GOOGLE_include_directive,
to enable support #include directives. It depends on the extension
GL_GOOGLE_cpp_style_line_directive.
2015-07-31 19:41:19 -04:00
Dejan Mircevski
7be4b8282d Add #include processing to glslang (though turned off by default).
When an include directive is recognized by the preprocessor, it
executes a callback on the filepath argument to obtain the file
contents.  That way the compilation client can deal with the file
system, include paths, etc.

Currently only accepts quoted filepaths -- no angle brackets yet.
2015-07-31 19:41:18 -04:00
Lei Zhang
780a2f4426 Use requireExtensions() to check extension and turn on more tests.
Use requireExtensions() to check GL_GOOGLE_cpp_style_line_directive
is turned on. Add register more tests for running.
2015-07-28 12:21:00 -04:00
Lei Zhang
5011fbebc3 Extend the syntax of #line and __FILE__ to support filename strings.
According to the GLSL spec, the second parameter to #line should be
an integer source string number and __FILE__ will be substituted
with the integer source string number currently processed. This
patch extends the syntax of #line and __FILE__. Now #line accepts
as the second parameter a filename string quoted by double quotation
marks. And if such a #line is set, __FILE__ will be substituted with
the currently set filename string. The implementation is done via
introducing a new extension GL_GOOGLE_cpp_style_line_directive using
the extension framework.

The purpose is to support cpp-style #line directives, which is
required by #include.
2015-07-27 13:07:52 -04:00
John Kessenich
c777fc2c4c Scanning: 1) rationalize end-of-input everywhere, 2) prevent infinite loop at end-of-input, 3) use positive chars.
Fixes issue #25. (char 255 aliased to -1 and missing tests for end of input).

1) All layers of input scanning now share a single EndOfInput value.
This avoids translation of it across layers of encapsulation.

2) Some places looking for end of line were not stopping on EndOfInput.

3) Use of "char" for the input made char values > 127 be negative numbers.
This allowed for aliasing of 255 to -1, etc.  This is fixed by using
unsigned char.
2015-07-27 09:37:55 -06:00
John Kessenich
aead93aafd Preprocessor: Allow '\' as a token, which gets actual use in #error, but should have no other use.
This is just for '\' that's not before a new line.
Note the specification says it has no use other than as line continuation,
but #error is a grey area. (There are no escape sequences.)
2015-07-25 17:34:32 -06:00
John Kessenich
f330f08129 Consolidate all token length limits (1024), including one bad one (80) hardcoded on the stack (issue #40, issue #41). 2015-07-25 14:02:53 -06:00
John Kessenich
62aa5bdfca AST -> SPV testing: Update test for using new TbdFunctionality() that is non-fatal and uniquifies printed TBDs. 2015-07-23 10:25:20 -06:00
John Kessenich
426394d0c8 AST -> SPV: Add basic atomic_uint and atomic*() built-in function functionality. 2015-07-23 10:22:48 -06:00
John Kessenich
917ec4ac8c Front-end atomics: Finish adding atomic built-in functions (non-image) into the AST. 2015-07-22 19:58:15 -06:00
John Kessenich
96d8042a64 Merge pull request #31 from google/explicit-extension-directive
Only output explicit extension directives in preprocessing.
2015-07-22 15:20:54 -06:00
John Kessenich
12a383379c Issue 32: Guard against constructors consuming unsized arrays. 2015-07-22 11:44:59 -06:00
John Kessenich
f498400945 Merge pull request #33 from google/spv-builder-loop-ctor-inits-all-members
spv::Builder::Loop constructor inits all members.
2015-07-22 11:39:29 -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
8ba301c7c2 Issue #28: Correctly handle a single input argument conversion when the input argument is an aggregate. 2015-07-21 16:00:34 -06:00
Lei Zhang
1d2996db68 Only output explicit extension directives in preprocessing.
Preprocessing output shouldn't contain extensions enabled as
dependencies.
2015-07-21 17:47:47 -04:00
John Kessenich
efb8461722 Issue #26: Detect empty array constructors, require at least on operand. 2015-07-21 14:35:39 -06:00
John Kessenich
37e8337958 Merge pull request #22 from google/structured-do-while
Generate correctly structured do-while loops.
2015-07-20 22:14:38 -06:00
John Kessenich
d2762564dc Preprocessor: Prevent (and give an error on) expression division by 0. 2015-07-20 12:29:41 -06:00
John Kessenich
e9022e1ffe Tests: Increase testing around incorrect use of block names and instances. 2015-07-20 12:03:04 -06:00
John Kessenich
2b4b9bd65b Front-end: Add error-recovery code for a switch statement that ends with a case/default that has no statements. 2015-07-18 11:13:14 -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
John Kessenich
e3933d684d Front-end: Implement GL_OES_gpu_shader5. 2015-07-15 19:42:59 -06:00
John Kessenich
279012d8c4 Merge pull request #16 from google/pp-directive
Preprocessing directive handling
2015-07-14 19:36:29 -06:00
John Kessenich
fdfa6bbdfe Front-end: enforce qualifiers that cannot appear on block declarations.
Also seems to pick up some white-space (line-ending) test differences with a
prevoius checkin.
2015-07-14 19:30:11 -06:00
Andrew Woloszyn
aae1ad8296 Added error output to the preprocessor.
This patch distinguishes preprocessing errors with normal parsing
errors and gives glslangValidator the ability to output preprocessing
errors.
2015-07-14 16:02:25 -04:00
Lei Zhang
46ea5396ef Fix empty line handling in line directive callback.
The current line number for the #line directive should be passed
in as parameter to the line directive callback. Without it, we
don't know how many empty lines we should output.
2015-07-14 14:38:14 -04:00