Commit Graph

775 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
2144274a91 Clean up conditional branch codegen.
Should only need to look at whether or not we're branching to our own
merge target. Any other branch needs to emit code in some way.
2020-09-17 12:12:37 +02:00
Hans-Kristian Arntzen
54cc0b01f6 Deal with case where a selection construct conditionally merges/breaks. 2020-09-17 12:02:43 +02:00
Hans-Kristian Arntzen
66afe8c499 Implement a simple evaluator of specialization constants.
In some cases, we need to get a literal value from a spec constant op.
Mostly relevant when emitting buffers, so implement a 32-bit integer
scalar subset of the evaluator. Can be extended as needed to support
evaluating any specialization constant operation.
2020-09-14 11:45:59 +02:00
Hans-Kristian Arntzen
18d03b3ea6 Handle OpUndef %void.
Apparently this is legal and spirv-opt is starting to emit this kind of
code now.
2020-09-04 09:29:44 +02:00
Hans-Kristian Arntzen
3360daa6f3 MSL: Fix OpCompositeInsert and OpVectorInsertDynamic.
Need to take care of unpacked RHS expressions.
2020-09-02 10:27:39 +02:00
Hans-Kristian Arntzen
a07441568e Overhaul how we deal with reserved identifiers.
- Do not silently drop reserved identifiers in the parser. This makes it
  possible to reflect identifiers which are reserved by the
  cross-compiler module.
- Instead of dropping the name, emit _RESERVED_IDENTIFIER_FIXUP in the
  source to make it clear that a name has been rewritten.
- Document what is reserved and not.
2020-08-21 16:33:27 +02:00
Hans-Kristian Arntzen
fad36a6b28 HLSL: Deal with partially filled 16-byte word in cbuffers.
The last element of an array or matrix in HLSL cbuffers are not filled
completely, but only have a size equal to the base vector.
2020-08-20 16:05:21 +02:00
Hans-Kristian Arntzen
dd1f53ff15 HLSL: Fix bug in is_packing_standard for cbuffer.
Was not keeping offset in sync with actual_offset and HLSL could trigger
spurious realignments due to the straddle check.
2020-08-20 15:26:55 +02:00
Hans-Kristian Arntzen
eb580d6656 Ensure that we use primary alias type when emitting flattened members. 2020-07-29 13:02:25 +02:00
Hans-Kristian Arntzen
aac6885950 GLSL: Be more aggressive about using type_alias.
To facilitate an improved linking-by-name use case for older GL,
we will be more aggressive about merging struct definitions, even for
rather unrelated cases where we don't strictly need to use type aliases.
2020-07-29 12:48:41 +02:00
Hans-Kristian Arntzen
038b0bf238 Only rewrite type aliases for the base type. 2020-07-29 12:48:41 +02:00
Hans-Kristian Arntzen
57c93d44ac GLSL: Add option to force flattening IO blocks.
It is not always desirable to use actual blocks.
A prime example in the case where EXT_shader_io_blocks is not supported
on the target implementation.
2020-07-28 15:16:06 +02:00
Hans-Kristian Arntzen
fa5b206d97 MSL: Workaround broken vector -> scalar access chain in MSL.
On MSL, the compiler refuses to allow access chains into a normal vector type.
What happens in practice instead is a read-modify-write where a vector type is
loaded, modified and written back.

The workaround is to convert a vector into a pointer-to-scalar before
the access chain continues to add the scalar index.
2020-07-06 10:03:44 +02:00
Hans-Kristian Arntzen
2ac8f51b06 GLSL: Support I/O flattening with arrays as final type. 2020-07-06 09:18:30 +02:00
Hans-Kristian Arntzen
2d43103a55 GLSL: Support multi-level struct flattening for I/O. 2020-07-03 14:38:51 +02:00
Hans-Kristian Arntzen
d573a95a9c Run format_all.sh. 2020-07-01 11:42:58 +02:00
Hans-Kristian Arntzen
70f17142de GLSL: Fix nested legacy switch workarounds. 2020-06-30 12:02:24 +02:00
Hans-Kristian Arntzen
b1082c10af
Merge pull request #1410 from KhronosGroup/fix-1406
GLSL: Support switch more properly in legacy ESSL
2020-06-29 15:22:39 +02:00
Hans-Kristian Arntzen
4d79d634f5 GLSL: Implement switch on ESSL 1.0.
Cannot use switch on legacy ESSL, fallback to plain branches.
2020-06-29 13:35:46 +02:00
Hans-Kristian Arntzen
bae76d7915 GLSL: Use for-loop fallback instead of do/while for legacy ESSL.
do/while loops are not guaranteed to be supported in ESSL 1.0 / OpenGLES
2.0 implementations.
2020-06-29 12:50:31 +02:00
Hans-Kristian Arntzen
3afbfdb090 Implement context-sensitive expression read tracking.
When inside a loop, treat any read of outer expressions to happen
multiple times, forcing a temporary of said outer expressions.
This avoids the problem where we can end up relying on loop-invariant code motion to happen in the
compiler when converting optimized shaders.
2020-06-29 12:20:35 +02:00
Hans-Kristian Arntzen
05188aca69 Fix bug with control dependent expression tracking.
For a direct branch without merge, we lost control dependent
expressions.
2020-06-29 10:55:50 +02:00
Hans-Kristian Arntzen
eb0f0323d3 HLSL: Workaround FXC bugs with degenerate switch blocks.
When we see a switch block which only contains one default block, emit a
do {} while(false) statement instead, which is far more idiomatic and
readable anyways.
2020-06-23 15:39:04 +02:00
Hans-Kristian Arntzen
f141521ebe Fix duplicated initialization for loop variables with initializers. 2020-06-19 10:51:00 +02:00
Hans-Kristian Arntzen
7314f51a32 MSL: Deal with loading non-value-type arrays. 2020-06-18 12:46:39 +02:00
Hans-Kristian Arntzen
03d4bcea68 MSL: Improve handling of array types in buffer objects.
When loading and storing array types which belong to buffer objects, we
need to treat these values as not being value types. Also, need to
handle array load/store from/to more address space combinations.
2020-06-18 11:49:03 +02:00
Chip Davis
5281d9997e MSL: Fix up input variables' vector lengths in all stages.
Metal is picky about interface matching. If the types don't match
exactly, down to the number of vector components, Metal fails pipline
compilation. To support pipelines where the number of components
consumed by the fragment shader is less than that produced by the vertex
shader, we have to fix up the fragment shader to accept all the
components produced.
2020-06-16 14:50:30 -05:00
rdb
031cbaa5a2 GLSL: Require GL_ARB_draw_instanced for gl_InstanceID in GLSL < 1.40 2020-06-12 22:42:26 +02:00
Hans-Kristian Arntzen
f383cc98f2 GLSL: Handle the rest of GL_ARB_sparse_texture_clamp.
Missed these in initial sparse implementation.
2020-06-08 13:40:11 +02:00
Hans-Kristian Arntzen
857e1c445c GLSL: Support uint code for sparse residency query. 2020-06-08 11:40:02 +02:00
Hans-Kristian Arntzen
cbe0cca73b Refactor texture fetch function generation.
Use structs instead of a million bool/uint32_t arguments passed on stack.
2020-06-08 10:17:40 +02:00
Hans-Kristian Arntzen
275974e062 GLSL: Implement sparse feedback. 2020-06-04 15:50:28 +02:00
Hans-Kristian Arntzen
d31bc0247e Do not mask writes to remapped variables in all cases.
If they don't have a static expression we should still write to it.
2020-05-28 11:49:28 +02:00
Hans-Kristian Arntzen
ef247e75ec GLSL: Improve support for GL_ARB_shader_draw_parameters in desktop GLSL.
Opt-in to using the extension to support gl_InstanceIndex.
2020-05-22 12:53:34 +02:00
Hans-Kristian Arntzen
66ec3e3e54 GLSL: Support ray payloads and hit attributes declared as Block. 2020-05-20 15:07:47 +02:00
Hans-Kristian Arntzen
271ad33380 GLSL: Add some more focused RT test shaders. 2020-05-20 14:11:28 +02:00
Hans-Kristian Arntzen
86380acf4d Support gl_InstanceID in RT shaders. 2020-05-08 13:39:43 +02:00
Hans-Kristian Arntzen
9b7140e2ba Implement OpAtomicLoad/OpAtomicStore.
Need some emulation on GLSL/HLSL, fix bug with atomic store on MSL.
2020-04-27 12:11:46 +02:00
Hans-Kristian Arntzen
5e5d1c27ce GLSL: Support f16x2 <-> f32 bitcast.
There is no native formulation, so introduce a concept of a "complex"
bitcast to handle odd-ball cases which have no native unary operation.
2020-04-21 23:27:33 +02:00
Hans-Kristian Arntzen
c58839bfd4
Merge pull request #1336 from KhronosGroup/fix-1333
Handle RayQueryKHR type.
2020-04-21 16:31:22 +02:00
Hans-Kristian Arntzen
bdb343ea06 Be a bit more careful what nonuniform state is propagated. 2020-04-21 14:48:44 +02:00
Hans-Kristian Arntzen
6b0e558169 Handle RayQueryKHR type.
Do not error out in parsing in shaders which use ray queries.
2020-04-21 14:25:18 +02:00
Hans-Kristian Arntzen
b2e934b53f
Merge pull request #1328 from devshgraphicsprogramming/patch-1
Try and solve issue #1327
2020-04-21 14:06:27 +02:00
Hans-Kristian Arntzen
5cb0f0a640
Merge pull request #1335 from KhronosGroup/fix-1325
GLSL/HLSL: Implement unpack/pack2x32Uint
2020-04-21 14:05:12 +02:00
Mateusz Kielan
127224d816 Fix issue #1327
Drop the nonuniform_qualifier in GLSL downcompile NV_gpu_shader5 supports divergent indexing transparently, but obviously runtime sized descriptor arrays are not supported by anything in OpenGL.
2020-04-21 13:29:30 +02:00
Asuka
55dfbead2f GLSL/HLSL: Support packUint2x32 and unpackUint2x32 2020-04-21 11:34:12 +02:00
Hans-Kristian Arntzen
f8592ecdfc MSL: Deal correctly with initializers on Private variables.
Do not attempt to defer declaration. It would happen to work in most
cases, but the edge case is where the first thing that happens to a
variable is being OpStore'd into.
2020-04-21 11:20:49 +02:00
Hans-Kristian Arntzen
c7b75a8fe6 MSL: Do not use base expression with PhysicalTypeID OpCompositeExtract.
Similar reasoning as packed expressions.
2020-04-07 18:25:44 +02:00
Hans-Kristian Arntzen
941cceedb4 Expose a query if samplers or images are comparison resources. 2020-04-03 17:43:42 +02:00
Hans-Kristian Arntzen
b691b7d1e3 Do not add NonWritable/NonReadable decorations for regular images. 2020-04-03 17:43:42 +02:00