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().
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.
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.
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.
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.
This PR sets the TQualifier layoutFormat according to the HLSL image type.
For instance:
RWTexture1D <float2> g_tTex1df2;
becomes ElfRg32f. Similar on Buffers, e.g, Buffer<float4> mybuffer;
The return type for image and buffer loads is now taken from the storage format.
Also, the qualifier for the return type is now (properly) a temp, not a global.
- hlsl.struct.frag variable changed to static, assignment replacd.
- Created new low level functions addBinaryNode and addUnaryNode. These are
used by higher level functions such as addAssignment, and do not do any
argument promotion or conversion of any sort.
- Two functions above are now used in RWTexture lvalue conversions. Also,
other direction creations of unary or binary nodes now use them, e.g, addIndex.
This cleans up some existing code.
- removed handling of EOpVectorTimesScalar from promote()
- removed comment from ParseHelper.cpp
This commit splits lValueErrorCheck into machine dependent and independent
parts. The GLSL form in TParseContext inherits from and invokes the
machine dependent part in TParseContextBase. The base form checks language
independent things. This split does not change the set of errors tested
for: the test results are identical.
The new base class interface is now used from the HLSL FE to test lvalues.
There was one test diff due to this, where the test was writing to a uniform.
It still does the same indirections, but does not attempt a uniform write.
This commit adds l-value support for RW texture and buffer objects.
Supported are:
- pre and post inc/decrement
- function out parameters
- op-assignments, such as *=, +-, etc.
- result values from op-assignments. e.g, val=(MyRwTex[loc] *= 2);
Not supported are:
- Function inout parameters
- multiple post-inc/decrement operators. E.g, MyRWTex[loc]++++;
This commit adds r-value support for RW textures and buffers.
Supported is:
- Function in parameter conversions
- conversion of rvalue use to imageLoad
There's a lot to do for RWTexture and RWBuffer, so it will be broken up into
several PRs. This is #1.
This adds RWTexture and RWBuffer support, with the following limitations:
* Only 4 component formats supported
* No operator[] yet
Those will be added in other PRs.
This PR supports declarations and the Load & GetDimensions methods. New tests are
added.
If a member-wise assignment from a non-flattened struct to a flattened struct sees a complex R-value
(not a symbol), it now creates a temporary to hold that value, to avoid repeating the R-value.
This avoids, e.g, duplicating a whole function call. Also, it avoids re-using the AST node, making a
new one for each member inside the member loop.
The latter (re-use of AST node) was also an issue in the GetDimensions intrinsic decomposition,
so this PR fixes that one too.
- Add new queries: TProgram::getUniformTType and getUniformBlockTType,
which return a const TType*, or nullptr on a bad index. These are valid for
any source language.
- Interface name for HLSL cbuffers is taken from the (only) available declaration name,
whereas before it was always an empty string, which caused some troubles with reflection
mapping them all to the same index slot. This also makes it appear in the SPIR-V binary
instead of an empty string.
- Print the binding as part of the reflection textual dump.
- TType::clone becomes const. Needed to call it from a const method, and anyway it doesn't
change the object it's called on.
- Because the TObjectReflection constructor is called with a TType *reference* (not pointer)
so that it's guaranteed to pass in a type, and the "badReflection" value should use a nullptr
there, that now has a dedicated static method to obtain the bad value. It uses a private
constructor, so external users can't create one with a nullptr type.
Previously the uniform array flattening feature would trigger on loose
uniform arrays of any basic type (e.g, floats). This PR restricts it
to sampler and texture arrays. Other arrays would end up in their own
uniform block (anonymous or otherwise). (Atomic counter arrays might be an
exception, but those are not currently flattened).
Fix for two defects as follows:
- The IO mapping traverser was not setting inVisit, and would skip some AST nodes.
Depending on the order of nodes, this could have prevented the binding from
showing up in the generated SPIR-V.
- If a uniform array was flattened, each of the flattened scalars from the array
is still a (now-scalar) uniform. It was being converted to a temporary.
This checkin adds a --flatten-uniform-arrays option which can break
uniform arrays of samplers, textures, or UBOs up into individual
scalars named (e.g) myarray[0], myarray[1], etc. These appear as
individual linkage objects.
Code notes:
- shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform,
but is the only flattening query directly called.
- flattenVariable will handle structs or arrays (but not yet arrayed structs;
this is tested an an error is generated).
- There's some error checking around unhandled situations. E.g, flattening
uniform arrays with initializer lists is not implemented.
- This piggybacks on as much of the existing mechanism for struct flattening
as it can. E.g, it uses the same flattenMap, and the same
flattenAccess() method.
- handleAssign() has been generalized to cope with either structs or arrays.
- Extended test infrastructure to test flattening ability.