It both seems to be a bit of a hack (since it probably doesn't conform
with the GLSL spec, but I've given up on worrying too much about that),
and the most sensible thing to do.
Shadow swizzling can return a single component but OpVectorShuffle
doesn't support returning a scalar. This is essentially duplicating the
vector logic in proc_field.
The whole point of prototypes is to ensure arguments are of the correct
type. Fixes some ints getting into places where floats were expected
(eg, mix, smoothstep, etc).
The function queue needs to be cleared before figuring out the interface
symbols otherwise the variables referenced only by called functions will
not get into the list of interface symbols.
This fixes the constant type reference ICE for subpassLoad. The problem
was stale symbols recorded in the expressions thus gsubpassInput
referred to the allowed types for the generic function rather than the
type specific to the call.
`address_expr()` wasn't enough because it returns pointers instead of
references (quite correct) which messes with checks for references
elsewhere (also quite correct). It seems I've finally got reference
parameters working.
Generic function parameters can now use references (currently via
`@reference()`) for generic types. And seem to work. There's still a
problem with chains: `atomicExchange(__imageTexel(...))` is
dereferencing __imageTexel's return value.
It seems it should return an Image storage class pointer. Validation
still fails because of the ptr local var (not allowed by default) and so
needs to be an SSA temp, but I'm having a little trouble with *that*.
It turned out error checking on type functions was broken by generic
functions because type_function wasn't being called. The rest of the
changes were for error recovery.
The default value is 1, and the assumption in target_spirv is that if
the first one is set, all are set, but the source code doesn't need to
set any explicitly.
Doing <= when I wanted != caused some very strange behavior with
valgrind and bsearch. Also, going with negative logic rather than
positive logic is probably the cause of the brainfart.
This means that `layout(triangles)` etc now work, though there are
issues with frag shaders missing functions (since getting function calls
working) and compute shaders silently failing.
But only for non-extension. I'm not sure it's quite right (as I don't
know if all void intrinsics should not have res type/id (all extension
instructions *do*)).
When I wrote vkgen's stdint.h, qfcc didn't support long or ulong, and
with the common init check, it now matters that the correct types are
used. It turns out some of my structs may not have been initialized
correctly, but with the next commits (long and ulong for cexpr), they
should be but do seem to be working at least.
This is a nice common place (all languages and targets use it) for the
warning and any conversions, though those are still spread in various
places (and need to be cleaned up), so it doesn't do all that much yet.
The spir-v back-end needs to emit literal values in some places and
supporting that in explicit intrinsics required marking the expression
as special. Unary = seems a little odd at first, but at the same time
seems to make sense, especially for marking expressions as "use literal
value" (eg =ImageOperands.Lod will result in a literal 2 instead of an
op id that points to the 2).
The dereferencing was done for implicit intrinsic args, but I had
forgotten about it for explicit intrinsics. Now the scalar `a` version
of `mix` works.