the following warning gets emitted:
```
In file included from ./Vulkan/glslang/SPIRV/hex_float.h:39,
from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/bitutils.h: In instantiation of ‘Dest spvutils::BitwiseCast(Src) [with Dest = spvutils::Float16; Src = short unsigned int]’:
./Vulkan/glslang/SPIRV/hex_float.h:138:47: required from ‘T spvutils::FloatProxy<T>::getAsFloat() const [with T = spvutils::Float16]’
./Vulkan/glslang/SPIRV/hex_float.h:821:52: required from here
./Vulkan/glslang/SPIRV/bitutils.h:29:14: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class spvutils::Float16’; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
std::memcpy(&dest, &source, sizeof(dest));
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/hex_float.h:43:7: note: ‘class spvutils::Float16’ declared here
class Float16 {
^~~~~~~
In file included from ./Vulkan/glslang/SPIRV/hex_float.h:39,
from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/bitutils.h: In instantiation of ‘Dest spvutils::BitwiseCast(Src) [with Dest = spvutils::FloatProxy<spvutils::Float16>; Src = short unsigned int]’:
./Vulkan/glslang/SPIRV/hex_float.h:431:28: required from ‘void spvutils::HexFloat<T, Traits>::setFromSignUnbiasedExponentAndNormalizedSignificand(bool, spvutils::HexFloat<T, Traits>::int_type, spvutils::HexFloat<T, Traits>::uint_type, bool) [with T = spvutils::FloatProxy<spvutils::Float16>; Traits = spvutils::HexFloatTraits<spvutils::FloatProxy<spvutils::Float16> >; spvutils::HexFloat<T, Traits>::int_type = short int; spvutils::HexFloat<T, Traits>::uint_type = short unsigned int]’
./Vulkan/glslang/SPIRV/hex_float.h:633:5: required from ‘void spvutils::HexFloat<T, Traits>::castTo(other_T&, spvutils::round_direction) [with other_T = spvutils::HexFloat<spvutils::FloatProxy<spvutils::Float16>, spvutils::HexFloatTraits<spvutils::FloatProxy<spvutils::Float16> > >; T = spvutils::FloatProxy<float>; Traits = spvutils::HexFloatTraits<spvutils::FloatProxy<float> >]’
./Vulkan/glslang/SPIRV/hex_float.h:817:39: required from here
./Vulkan/glslang/SPIRV/bitutils.h:29:14: warning: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class spvutils::FloatProxy<spvutils::Float16>’ from an array of ‘short unsigned int’ [-Wclass-memaccess]
std::memcpy(&dest, &source, sizeof(dest));
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/hex_float.h:115:7: note: ‘class spvutils::FloatProxy<spvutils::Float16>’ declared here
class FloatProxy {
^~~~~~~~~~
```
When capabilities are needed for specific SPIR-V instructions, it is
fragile to do so based on GLSL/AST usage; it should be based on actual
instructions they got translated to.
When constructing a matrix from another matrix with smaller dimensions,
there's no need to extract the scalars out of columns and rebuild the
resulting matrix from scalars - instead, we can just construct shorter
vectors with OpShuffle and combine them to the final result.
This keeps the common casts such as mat3(mat4) in vector registers,
which may improve performance for some GPUs, and cleans up output of
translation tools like SPIRV-Cross.
Fixes#1412.
These introduce limited support for 8/16-bit types such that they can only be accessed in buffer memory and converted to/from 32-bit types.
Contributed from Khronos-internal work.
- Use much simpler method to update implicit array sizes.
The previous overly complicated method was error prone.
- Rationalize all use of unsized arrays.
- Combine decorations when generating SPIR-V, to simplify
adding extensions.
There a couple functional problems, which when reduced down also led to
some good simplifications and rationalization. So, this commit:
- corrects "mixed" functionality: int[A] f[B] -> f[B][A]
- correct multi-identifier decls: int[A] f[B], g[C] -> f and g are independently sized.
- increases symmetry between different places in the code that do this
- makes fewer ways to do the same thing; several methods are just gone now
- makes more clear when something is copied or shared
glslang/SPIRV/SpvBuilder.cpp:2533:27: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
for (int c = 0; c < accessChain.swizzle.size(); ++c)
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
glslang/hlsl/hlslParseHelper.cpp:69:5: error: field 'cullDistanceInput' will be initialized after field 'clipDistanceOutput' [-Werror,-Wreorder]
cullDistanceInput(nullptr),
^
1 error generated.
glslang/glslang/MachineIndependent/attribute.cpp:85:16: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
if (argNum >= args->getSequence().size())
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
When a matrix is divided by a scalar it tries to take the reciprocal
of the scalar to convert the operation into a multiply. However it was
always doing this by making a 32-bit constant. If the scalar is a
double then this would end up making an FDiv instruction with
different types in the operands.
This patch adds a helper method called makeFpConstant which makes a
floating-point constant of the given type. The code to take the
reciprocal now uses it to make the same type as the result.
Fixes https://github.com/KhronosGroup/glslang/issues/1278
This factored computeTypeLocationSize() out of needing the TIntermediate contents,
and uses it to show how to know how many locations an object needs.
However, it still does not do cross stage, or mixed location/no-location
analysis.
HLSL allows image and texture types to be templatized on sub-vec4 types,
or even structures. This was mostly handled already during creation of
sampling operations. However, for operator[] which can generate image
loads, this wasn't happening.
It also isn't very easy to do at that point in time, because operator[]
does not know where the results it produces will end up. They may be
an lvalue or an rvalue, and there's a post-process to convert loads to
stores. They may end up in atomic ops.
To bypass that difficulty, GlslangToSpv now looks for this case and
adds the appropriate conversion. LIMITATION: this only works for
cases for which a simple conversion opcode suffices. That is to say,
it will not work if the type is templatized on a struct.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
TGlslangToSpvTraverser::getExtBuiltins is only used when AMD_EXTENSIONS
is defined, so only define it in that case to avoid an unused function
warning.
Also, only emit this XFB information where the SPIR-V spec says
it should be emitted: essentially, on objects.
This and the previous commit together fix#1185.
This continues to prevent writing output buffers (out from a function),
but fixes the problem where the copy-in/out was not getting done.
Making everything work will require knowing both in/out-ness and bufferness,
but these are currently mutually exclusive, because both are storage
qualifiers.