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

1660 Коммитов

Автор SHA1 Сообщение Дата
steve-lunarg ef33ec0925 HLSL: add intrinsic function implicit promotions
This PR handles implicit promotions for intrinsics when there is no exact match,
such as for example clamp(int, bool, float).  In this case the int and bool will
be promoted to a float, and the clamp(float, float, float) form used.

These promotions can be mixed with shape conversions, e.g, clamp(int, bool2, float2).

Output conversions are handled either via the existing addOutputArgumentConversion
function, which this PR generalizes to handle either aggregates or unaries, or by
intrinsic decomposition.  If there are methods or intrinsics to be decomposed,
then decomposition is responsible for any output conversions, which turns out to
happen automatically in all current cases.  This can be revisited once inout
conversions are in place.

Some cases of actual ambiguity were fixed in several tests, e.g, spv.register.autoassign.*

Some intrinsics with only uint versions were expanded to signed ints natively, where the
underlying AST and SPIR-V supports that.  E.g, countbits.  This avoids extraneous
conversion nodes.

A new function promoteAggregate is added, and used by findFunction.  This is essentially
a generalization of the "promote 1st or 2nd arg" algorithm in promoteBinary.

The actual selection proceeds in three steps, as described in the comments in
hlslParseContext::findFunction:

1. Attempt an exact match.  If found, use it.
2. If not, obtain the operator from step 1, and promote arguments.
3. Re-select the intrinsic overload from the results of step 2.
2016-11-23 10:36:34 -07:00
John Kessenich 1c573fbcfb Merge pull request #601 from BearishSun/master
A way to query "location" qualifier for vertex attributes, using TProgram reflection API
2016-11-23 00:38:32 -07:00
John Kessenich e122f053bb Merge pull request #599 from steve-lunarg/gs
HLSL: Add GS support
2016-11-23 00:29:30 -07:00
John Kessenich 6e848daf45 Merge pull request #596 from steve-lunarg/hlsl-intrinsic-parsing
HLSL: use HLSL parser for HLSL intrinsic prototypes, enable int/bool mats
2016-11-23 00:19:40 -07:00
John Kessenich d347794ed1 Merge pull request #597 from steve-lunarg/sample-keyword-fix
HLSL: allow "sample" as a valid identifier.
2016-11-22 23:33:40 -07:00
BearishSun 32c294ed76 Adding a way to retrieve vertex attribute TType using TProgram reflection API (required in order to query location attributes). 2016-11-22 09:53:04 +01:00
steve-lunarg f49cdf4183 WIP: HLSL: Add GS support
This PR adds:

[maxvertexcount(n)] attributes

point/line/triangle/lineadj/triangleadj qualifiers

PointStream/LineStream/TriangleStream templatized types

Append method on above template types

RestartStrip method on above template types.
2016-11-21 18:25:08 -07:00
steve-lunarg 75fd223f03 HLSL: allow "sample" as a valid identifier.
HLSL has keywords for various interpolation modifiers such as "linear",
"centroid", "sample", etc.  Of these, "sample" appears to be special,
as it is also accepted as an identifier string, where the others are not.

This PR adds this ability, so the construct "int sample = 42;" no longer
produces a compilation error.

New test = hlsl.identifier.sample.frag
2016-11-16 13:22:11 -07:00
steve-lunarg 0842dbb39a HLSL: use HLSL parser to parse HLSL intrinsic prototypes, enable int/bool mats
This PR adds a CreateParseContext() fn analogous to CreateBuiltInParseables(),
to create a language specific built in parser.  (This code was present before
but not encapsualted in a fn).  This can now be used to create a source language
specific parser for builtins.

Along with this, the code creating HLSL intrinsic prototypes can now produce
them in HLSL syntax, rather than GLSL syntax.  This relaxes certain prior
restrictions at the parser level.  Lower layers (e.g, SPIR-V) may still have
such restrictions, such as around Nx1 matrices: this code does not impact
that.

This PR also fleshes out matrix types for bools and ints, both of which were
partially in place before.  This was easier than maintaining the restrictions
in the HLSL prototype generator to avoid creating protoypes with those types.

Many tests change because the result type from intrinsics moves from "global"
to "temp".

Several new tests are added for the new types.
2016-11-16 11:19:22 -07:00
John Kessenich fabe7d6a61 Test results: Fix incorrect test result caused by parallel development. Issue #594. 2016-11-14 21:22:05 -07:00
John Kessenich 0bf06d3cf5 Merge pull request #576 from steve-lunarg/uav-registers
Add UAV (image) binding offset and HLSL register class support
2016-11-14 09:39:46 -07:00
John Kessenich 20b030a7a6 Merge pull request #592 from ChrisGautier/barrier-wg
SPV: The execution scope for barriers should be Workgroup.
2016-11-14 09:37:34 -07:00
chrgau01@arm.com c3f1cdfa57 GLSL: The execution scope for barriers should be Workgroup. 2016-11-14 10:10:05 +01:00
John Kessenich 84d11e1859 Merge pull request #583 from null77/fix-unref-warning
SPV: Fix unreferenced variable warning with AMD_EXTENSIONS disabled.
2016-11-13 22:04:04 -07:00
John Kessenich 610ff835c9 Merge pull request #589 from steve-lunarg/vec1-promotion-fix
HLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1
2016-11-13 22:01:54 -07:00
steve-lunarg d9cb832f9c HLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1
Previously, an error was thrown when assigning a float1 to a scalar float,
or similar for other basic types.  This allows that.

Also, this allows calling functions accepting scalars with float1 params,
so for example sin(float1) will work.  This is a minor change in
HlslParseContext::findFunction().
2016-11-13 14:44:46 -07:00
John Kessenich e69e196e02 Merge pull request #584 from steve-lunarg/attribute-expressions
HLSL: Allow expressions in attributes
2016-11-11 11:27:12 -07:00
steve-lunarg a22f7dbb71 HLSL: Allow expressions in attributes
For example:

[numthreads(2+2, 2*3, (1+FOO)*BAR)]

This will result in a thread count (4, 6, 8).
2016-11-11 08:23:03 -07:00
Jamie Madill 57cb69a3f1 Fix unrefenced variable warning with AMD_EXTENSIONS disabled. 2016-11-09 13:49:24 -05:00
John Kessenich d3f1122a44 Whole stack: Fix stale types in the AST linker object nodes, fixing #557.
Rationalizes the entire tracking of the linker object nodes, effecting
GLSL, HLSL, and SPIR-V, to allow tracked objects to be fully edited before
their type snapshot for linker objects.

Should only effect things when the rest of the AST contained no reference to
the symbol, because normal AST nodes were not stale. Also will only effect such
objects when their types were edited.
2016-11-05 10:22:33 -06:00
steve-lunarg 9088be4c07 Add UAV (image) binding offset and HLSL register support
This PR adds:

1. The "u" register class for RW* objects.

2. --shift-image-bindings (== --sib), analogous to --shift-texture-bindings etc.

3. Case insensitive reg classes.

4. Tests for above.
2016-11-01 14:44:54 -06:00
John Kessenich e5e58cfee3 Merge pull request #575 from steve-lunarg/iomap-warning-fix
Fix build warnings in iomapper.cpp, re-indent to glslang standard
2016-11-01 09:49:49 -06:00
steve-lunarg 5b2d667fea Fix build warnings in remapper, re-indent for glslang standard
This has no functional changes.
2016-11-01 08:51:46 -06:00
John Kessenich 89df3c2dcb Merge pull request #572 from steve-lunarg/numthreads
HLSL: implement numthreads for compute shaders
2016-11-01 00:25:06 -06:00
John Kessenich 1061accfac Merge pull request #562 from TiemoJung/io_map_control_publish
HLSL -> Spir-V: Resource mapping handler
2016-11-01 00:24:01 -06:00
John Kessenich 909b8afa4a Merge pull request #570 from steve-lunarg/mintypes
HLSL: Add min*{float,int,uint} types
2016-11-01 00:23:29 -06:00
John Kessenich cf35b17c4f Merge pull request #574 from dneto0/android-has-no-std-stoi
Use std::atoi instead of std::stoi
2016-11-01 00:08:40 -06:00
David Neto e301f67828 Use std::atoi instead of std::stoi
Some Android cross cross-compilers don't have std::stoi.

E.g. i686-linux-android-g++ from Android NDK r10e don't have std::stoi.
2016-10-31 17:02:45 -04:00
steve-lunarg 3226b0835c HLSL: Add min*{float,int,uint} types
These HLSL types are guaranteed to have at least the given number of bits, but may have more.

min{16,10}float is mapped to EbtFloat at medium precision -> SPIRV RelaxedPrecision
min{16,12}int and min16uint are mapped to mediump -> SPIR-V RelaxedPrecision
2016-10-31 12:46:05 -06:00
steve-lunarg 1868b14435 HLSL: implement numthreads for compute shaders
This PR adds handling of the numthreads attribute for compute shaders, as well as a general
infrastructure for returning attribute values from acceptAttributes, which may be needed in other
cases, e.g, unroll(x), or merely to know if some attribute without params was given.

A map of enum values from TAttributeType to TIntermAggregate nodes is built and returned.  It
can be queried with operator[] on the map.  In the future there may be a need to also handle
strings (e.g, for patchconstantfunc), and those can be easily added into the class if needed.

New test is in hlsl.numthreads.comp.
2016-10-31 09:28:17 -06:00
John Kessenich e19e68d431 Merge pull request #571 from baldurk/explicit-lambda-returns
Add explicit lambda return types, for compilers without C++14 support
2016-10-28 19:16:13 -06:00
baldurk ca73570447 Add explicit lambda return types, for compilers without C++14 support 2016-10-28 17:57:25 +02:00
t.jung c2016a52d2 New uniform mapping handling
- add optional callback to handle mapping of uniform variables in linking phase
- if no resolver is provided, it uses the internal default resolver with all shifts and auto bind settings

Change-Id: Icfe38a9eabe8bfc8f8bb6d8150c06f7ed38bb762
2016-10-28 15:43:14 +02:00
John Kessenich 9507885537 Merge pull request #560 from jeremy-lunarg/pragmas
silence -Wunknown-pragmas warnings on gcc
2016-10-26 23:02:47 -06:00
John Kessenich 51634468da Merge pull request #568 from steve-lunarg/logicalop-fix
HLSL: allow component-wise operations for logical || and &&.
2016-10-26 23:01:16 -06:00
John Kessenich aba444005f Merge pull request #567 from steve-lunarg/compare-fix
HLSL: Enable component-wise vector comparisons from operators
2016-10-26 22:54:35 -06:00
John Kessenich 850ac0628d Merge pull request #561 from jeremy-lunarg/unused
GLSL: apply unused variable
2016-10-26 22:51:43 -06:00
steve-lunarg 27939caa86 HLSL: allow component-wise operations for logical || and &&.
HLSL || and && can operate component-wise.
2016-10-26 12:54:56 -06:00
steve-lunarg 85244d7486 HLSL: Enable component-wise vector comparisons from operators
This PR only changes a few lines of code, but is subtle.

In HLSL, comparison operators (<,>,<=,>=,==,!=) operate component-wise
when given a vector operand.  If a whole vector equality or inequality is
desired, then all() or any() can be used on the resulting bool vector.

This PR enables this change.  Existing shape conversion is used when
one of the two arguments is a vector and one is a scalar.

Some existing HLSL tests had assumed == and != meant vector-wise
instead of component-wise comparisons.  These tests have been changed
to add an explicit any() or all() to the test source.  This verifably
does not change the final SPIR-V binary relative to the old behavior
for == and !=.  The AST does change for the (now explicit, formerly
implicit) any() and all().  Also, a few tests changes where they
previously had the return type wrong, e.g, from a vec < vec comparison
in hlsl.shapeConv.frag.

Promotion of comparison opcodes to vector forms
(EOpEqual->EOpVectorEqual) is handled in promoteBinary(), as is setting
the proper vector type of the result.

EOpVectorEqual and EOpVectorNotEqual are now accepted as either
aggregate or binary nodes, similar to how the other operators are
handled.  Partial support already existed for this: it has been
fleshed out in the printing functions in intermOut.cpp.

There is an existing defect around shape conversion with 1-vectors, but
that is orthogonal to this PR and not addressed by it.
2016-10-26 08:50:10 -06:00
John Kessenich 0d628c179d Merge pull request #565 from mre4ce/master
Disabled MSVC 2015 compile warnings.
2016-10-25 00:16:12 -06:00
steve-lunarg 4e3dd2087c WIP: avoid strtok 2016-10-21 14:51:43 -06:00
Jeremy Hayes c8e60e28b7 WIP: apply unused variable
I happened upon numArgs while hunting for unused variables. I suspect
the intent was to apply it as shown in this patch. However, I am not a
compiler dude. Someone more appropriate should grok this change.
2016-10-21 14:48:46 -06:00
Johannes van Waveren d1300753f7 update 2016-10-21 17:30:50 +09:00
Johannes van Waveren 2f4c832d47 Merge remote-tracking branch 'upstream/master' 2016-10-21 17:21:46 +09:00
Johannes van Waveren 8e1e717cae fixed MSVC 2015 compile warnings 2016-10-21 17:21:12 +09:00
John Kessenich 3fc1543794 Merge pull request #559 from steve-lunarg/samplecmp-fix
HLSL: fix defect in EOpMethodSampleCmp* texture decomposition
2016-10-20 19:22:57 -06:00
John Kessenich 04e2dc164e Merge pull request #558 from steve-lunarg/image-atomics
HLSL: phase 4 of RWTexture support: add image atomics
2016-10-20 19:09:55 -06:00
John Kessenich 921d315f3c Merge pull request #555 from steve-lunarg/promotion-fixes
HLSL: Fix unary and binary operator type conversion issues
2016-10-20 19:07:27 -06:00
John Kessenich 720e89b314 Merge pull request #556 from dneto0/guard-amd-enums
SPV: Add missing guard to code that uses AMD extensions
2016-10-20 19:04:30 -06:00
steve-lunarg 6b596682c9 HLSL: fix defect in EOpMethodSampleCmp* texture decomposition
HLSL holds the compare value in a separate intrinsic arg, but the AST wants
a vector including the cmp val, except in the 4-dim coord case, where it
doesn't fit and is in fact a separate AST parameter.  This is awkward but
necessary, given AST semantics.  In the process, a new vector is constructed
for the combined result, but this vector was not being given the correct
TType, so was causing some downstream troubles.

Now it is.  A similar defect existed in OpTextureBias, and has also been
fixed.
2016-10-20 14:50:12 -06:00