Commit Graph

322 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
9ddbd5aff6 Run format_all.sh. 2018-06-28 23:00:26 +02:00
Hans-Kristian Arntzen
f1752e58e1 Add basic namespace to internal macros.
Some projects build SPIRV-Cross as a single translation unit
and this causes a lot of warnings because the same macro is redeclared
multiple times in the different backends. This make sure that each
backend has its own namespace for internal macros.
2018-06-28 22:57:52 +02:00
Bill Hollings
9bf226cb05 Fixes for code review of PR 626. 2018-06-27 10:34:15 -04:00
Bill Hollings
4c5142b9d3 CompilerMSL support larger texel buffers by using 2D Metal textures.
Add CompilerMSL::Options::texture_width_max.
Emit and use spvTexelBufferCoord() function to convert 1D
texel buffer coordinates to 2D Metal texture coordinates.
2018-06-26 17:30:21 -04:00
Bill Hollings
4beefe756c Fixes from PR 621 code review. 2018-06-25 11:40:20 -04:00
Bill Hollings
f66507a701 Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2018-06-25 10:52:15 -04:00
Bill Hollings
e091031613 CompilerMSL pass builtin struct members into functions.
Add and use Compiler::get_non_pointer_type() convenience functions.
2018-06-24 15:06:12 -04:00
Hans-Kristian Arntzen
d94d20f4f3 Deal with some builtins being declared with wrong signedness. 2018-06-22 11:30:56 +02:00
Bill Hollings
ab2ea93e35 Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2018-06-12 11:42:56 -04:00
Bill Hollings
9b4defe202 CompilerMSL support matrices & arrays in stage-in & stage-out.
Support flattening StorageOutput & StorageInput matrices and arrays.
No longer move matrix & array inputs to separate buffer.
Add separate SPIRFunction::fixup_statements_in & SPIRFunction::fixup_statements_out
instead of just  SPIRFunction::fixup_statements.
Emit SPIRFunction::fixup_statements at beginning of functions.
CompilerMSL track vars_needing_early_declaration.
Pass global output variables as variables to functions that access them.
Sort input structs by location, same as output structs.
Emit struct declarations in order output, input, uniforms.
Regenerate reference shaders to new formats defined by above.
2018-06-12 11:41:35 -04:00
Hans-Kristian Arntzen
58fab58e5e Do not unpack transposed matrices. 2018-06-12 09:43:47 +02:00
Hans-Kristian Arntzen
04b149feb0 Fix image load/store on cube arrays in MSL. 2018-05-25 12:43:25 +02:00
Hans-Kristian Arntzen
6b3da831be Declare read-only SSBOs as const device in MSL. 2018-05-25 10:14:05 +02:00
Hans-Kristian Arntzen
bcaae84c76 Deal with scoping for Private variables. 2018-05-16 10:49:30 +02:00
Hans-Kristian Arntzen
26b887ec99 Fix atomic_compare_exchange_weak_explicit.
Need to emit a CAS loop.
Fix shared memory declaration.
Declare atomic ops with correct memory scope.
2018-05-15 16:04:21 +02:00
Hans-Kristian Arntzen
fb7181bff1 Run format_all.sh. 2018-05-15 14:24:59 +02:00
Hans-Kristian Arntzen
991b655c72 Declare OpSpecConstantOp up-front on relevant targets.
Required, since spec constants can include results from constant ops.
2018-05-15 14:20:16 +02:00
Hans-Kristian Arntzen
d2df067dd4 Force recompile if we add row-major transpose functions in MSL. 2018-05-04 09:43:34 +02:00
Hans-Kristian Arntzen
7b95168c3d Do not clear spv_function_implementations on MSL.
Will fail when recompiles are necessary.
2018-05-02 21:37:36 +02:00
Bill Hollings
57213cb7ca Compiler MSL default gather offset when component specified. 2018-04-30 16:30:29 -04:00
Hans-Kristian Arntzen
d93807a625 Deal with OpImageFetch without explicit LOD. 2018-04-30 10:54:44 +02:00
Hans-Kristian Arntzen
e351e5c565 Use convert_to_string for lod clamp. 2018-04-18 16:31:08 +02:00
Hans-Kristian Arntzen
e30a94225f Complete MSL constexpr samplers.
Deal with defaults and avoid verbose declarations.
2018-04-18 16:19:55 +02:00
Hans-Kristian Arntzen
64f9461d72 Check for array of samplers. 2018-04-17 17:47:15 +02:00
Hans-Kristian Arntzen
df58debf7a Add support for constexpr samplers in MSL. 2018-04-17 17:43:32 +02:00
Hans-Kristian Arntzen
9c2761f69a Run format_all.sh. 2018-04-10 12:32:14 +02:00
Hans-Kristian Arntzen
8175e2e200 Fix depth compare textures when used in functions without argument. 2018-04-10 12:31:13 +02:00
Hans-Kristian Arntzen
ac81a0ce68 Use declared binding in SPIR-V as a fallback for explicit MSL binds. 2018-04-04 12:25:11 +02:00
Hans-Kristian Arntzen
e8ca39b7b5 Add test for sampler image arrays. 2018-04-04 09:41:20 +02:00
Hans-Kristian Arntzen
382101bd05 Run format_all.sh. 2018-04-04 09:26:53 +02:00
Hans-Kristian Arntzen
5827dd54ea Support array of images and samplers in MSL. 2018-04-04 09:26:53 +02:00
Hans-Kristian Arntzen
81eb72a9a0 Ignore LOD when sampling 1D textures in MSL.
Not supported.
2018-04-04 09:26:53 +02:00
Hans-Kristian Arntzen
65be63fd04
Merge pull request #521 from KhronosGroup/fix-516
Support dual-source blending on GLSL and MSL.
2018-04-03 16:54:32 +02:00
Hans-Kristian Arntzen
a6e211e00b Support dual-source blending on GLSL and MSL. 2018-04-03 16:04:49 +02:00
Hans-Kristian Arntzen
3229e6efb6 Add more illegal name replacement in MSL. 2018-04-03 15:36:35 +02:00
Hans-Kristian Arntzen
719cf9d42f Run format_all.sh. 2018-03-13 14:05:33 +01:00
Hans-Kristian Arntzen
8e90382675 Properly flatten MRT outputs in MSL. 2018-03-13 14:03:35 +01:00
Hans-Kristian Arntzen
6e6ca0b237 Attempt MRT-as-array in MSL. 2018-03-13 13:17:17 +01:00
Hans-Kristian Arntzen
4979d10b54 Implement packHalf2x16/unpackHalf2x16 on MSL. 2018-03-12 17:51:14 +01:00
Hans-Kristian Arntzen
938c7debed Handle control-dependent temporaries.
Derivatives, subgroup and implicit-lod instructions all need to happen
in the block they were created.
2018-03-12 17:34:54 +01:00
Hans-Kristian Arntzen
e8e58844d4 Rewrite everything to use Bitset rather than uint64_t. 2018-03-12 13:24:14 +01:00
Hans-Kristian Arntzen
a803e5ae38 Deprecate set_options()/get_options() interface, replace it.
Replace with common/hlsl/msl instead. The old interface had some bad
interaction with overloading which meant you had to up-cast to base
class to be able to use set_options, which was awkward.
2018-03-09 15:25:25 +01:00
Hans-Kristian Arntzen
ac0e93f392 Run format_all.sh. 2018-03-07 10:29:20 +01:00
Hans-Kristian Arntzen
18ad1be3c3 Add FP16 test for MSL as well. 2018-03-07 10:29:11 +01:00
Hans-Kristian Arntzen
47d94ff8d9 Add FP16 to HLSL.
Cannot be used in buffer types, similar to mediump in GLSL.
half is useless, because it's 32-bit in FXC.
2018-03-07 10:21:25 +01:00
Hans-Kristian Arntzen
d9da2db442 Some compat fixes for MSL and Half. 2018-03-06 17:09:18 +01:00
Hans-Kristian Arntzen
294259e2f1 Fix type aliasing on MSL.
Be careful about who gets to be the alias master, and don't alias types
when we have packed types in play.
2018-03-05 16:27:04 +01:00
Hans-Kristian Arntzen
6a12ff7fb7 Fix multiple declaration of spvDet2x2 on MSL. 2018-02-23 16:52:11 +01:00
Hans-Kristian Arntzen
dd603eab58 Support spec constant array size in blocks.
Won't really be correct if the spec constant is changed outside
SPIRV-Cross, but nothing we can do about that, really.
2018-02-23 15:11:45 +01:00
Hans-Kristian Arntzen
a04bdcc7f7 Handle overloaded functions which share the same OpName.
Awkward, but legal SPIR-V.
2018-02-23 14:15:51 +01:00
Bill Hollings
50ef6cd95f CompilerMSL remove incorrect packing of non-interface type-aliased structs. 2018-02-21 17:52:03 -05:00
Hans-Kristian Arntzen
54a065bb5f Run format_all.sh. 2018-02-15 13:32:49 +01:00
Hans-Kristian Arntzen
3fa6cc8f2c Implement FRem. 2018-02-15 13:31:29 +01:00
Bill Hollings
2964e328e6 CompilerMSL support gl_SampleMask and convert it to scalar uint from array. 2018-02-13 14:44:40 -05:00
Bill Hollings
b453348370 Merge branch 'master' of https://github.com/billhollings/SPIRV-Cross 2018-02-11 16:54:25 -05:00
Bill Hollings
607b0d6d42 CompilerMSL support smaller offsets for 3-row row-major matrices.
Support MSL typedefs to declare 3-row row-major matrices as 3-column matrices.
Allow those matrices to be decorated as packed.
Support transposing those matrices when used.
Modify how member alignments are calculated.
2018-02-11 16:52:57 -05:00
Hans-Kristian Arntzen
a3104e98f9 Also check that type we load is an image. 2018-02-10 11:12:05 +01:00
Hans-Kristian Arntzen
a3ae861844 Fix depth image usage in MSL for separate image/samplers. 2018-02-10 10:55:10 +01:00
Hans-Kristian Arntzen
702e08671b Support passing implicit frag_coord arguments down to functions. 2018-02-10 10:55:09 +01:00
Hans-Kristian Arntzen
0912427046 Begin implementing subpassLoad in MSL. 2018-02-10 10:54:56 +01:00
Hans-Kristian Arntzen
c9db3e5521 Overload on constant storage. 2018-02-08 17:58:46 +01:00
Hans-Kristian Arntzen
b2c9487b0f Attempt to deduce constant/thread storage. 2018-02-08 17:07:50 +01:00
Hans-Kristian Arntzen
1a9c960058 MSL cannot declare inline arrays except in certain cases. 2018-02-08 13:06:29 +01:00
Hans-Kristian Arntzen
156dd905fd Implicit return value takes thread storage. 2018-02-08 12:22:08 +01:00
Hans-Kristian Arntzen
d89b79025b Fix wrong function declaration in MSL. 2018-02-08 12:22:08 +01:00
Hans-Kristian Arntzen
00ccd590ee Return arrays in HLSL/MSL by writing to an output variable instead. 2018-02-08 12:22:08 +01:00
Hans-Kristian Arntzen
9fa91f7e1c Support returning arrays from functions in GLSL/MSL.
Not possible in HLSL apparently, need workaround ...
2018-02-08 12:22:08 +01:00
msiglreith
d096f5cafe hlsl: Support custom root constant layout 2018-02-07 15:21:52 +01:00
Hans-Kristian Arntzen
6ca408aac2
Merge pull request #420 from billhollings/master
Update copyright dates to 2018 in main files.
2018-02-01 09:02:11 +01:00
Hans-Kristian Arntzen
4c1e57ee03
Merge pull request #413 from zeux/master
MSL: Order resources by type and binding index in the output
2018-02-01 09:01:34 +01:00
Bill Hollings
1c94715350 Update copyright dates to 2018 in main files. 2018-01-31 17:08:43 -05:00
Arseny Kapoulkine
7c8db865c4 Format spirv_msl.cpp 2018-01-29 06:42:34 -08:00
Arseny Kapoulkine
050361422c MSL: Order resources by type and binding index in the output
We've hit a bizarre bug on NVidia / macOS 10.13 where if two subsequent draw
calls use two different shaders that both have VS use buffers 0 & 1, but one
declares them in the increasing binding order and another one declares them
in the decreasing binding order, then the second draw call (with the decreasing
order) doesn't get correct data in some cases.

This has been reported to Apple and they will probably fix it at some point;
to work around that it's sufficient to sort resources by their binding index.

For consistency we also sort by type to get a stable order, and output builtins
after that to prevent random bugs like this from happening.
2018-01-29 06:35:41 -08:00
Hans-Kristian Arntzen
38b8f733d1 Fix passing arrays of arrays to functions in MSL. 2018-01-29 10:57:52 +01:00
Bill Hollings
e43f244399 Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2018-01-24 17:34:50 -05:00
Bill Hollings
fe3683eefa CompilerMSL declare threadgroup variables accessed in called functions. 2018-01-24 15:38:17 -05:00
Hans-Kristian Arntzen
09f550f718 Handle exponential explosion of code-gen during first phase of compile.
Certain patterns with OpVectorShuffle (and probably others) will cascade
to so large, that they can cause OOM. After we have observed
force_recompile, don't spend unnecessary memory emitting code which will
never be used.
2018-01-24 18:12:41 +01:00
Hans-Kristian Arntzen
06041985d0 Fix HLSL regression with struct declaration.
It actually worked surprisingly. Fix it properly.
2018-01-23 16:36:20 +01:00
Hans-Kristian Arntzen
7d223b8987 Fix CFG for forwarded temporaries.
Forwarded temporaries would never declare a temporary.
Figure out all result types ahead of time so we can deal with those
temporaries as well.
2018-01-18 12:11:33 +01:00
Bill Hollings
ba1e415a9c Use initializer list for composite initializations if backend.use_initializer_list is on. 2018-01-12 17:19:24 -05:00
Hans-Kristian Arntzen
f708b497a4 Opt in to gl_in/gl_out handling rather than other way around. 2018-01-09 09:16:33 +01:00
Bill Hollings
27d4af75a0 Revert to not forcing gl_in/gl_out block for MSL, and add MSL gl_ClipDistance tests. 2018-01-08 16:18:34 -05:00
Bill Hollings
6371d9e43a CompilerMSL emit no-warning pragma when emitting spvConvertFromRowMajorCxR functions. 2018-01-06 00:51:25 -05:00
Bill Hollings
5ee6b46087 Fixes from review of PR #373.
Code fixes from review.
Refactor MSL tests back to using the SPIRV-Tools
and glslang loaded by checkout_glslang_spirv_tools.sh.
2018-01-05 23:22:36 -05:00
Bill Hollings
3a7e8a1035 CompilerMSL fix bad cast error on result type derivation. 2018-01-04 21:13:38 -05:00
Bill Hollings
8890578d2a CompilerMSL support conversion of non-square row-major matrices. 2018-01-04 16:33:45 -05:00
Bill Hollings
a68b32733a CompilerMSL enhancements to nested function use of globals.
Allow function calls to include globals as arguments.
Allow function calls to include built-ins as arguments.
Include all meta info when creating function args from globals.
Do not manufacture a sampler for Buffer-type sampled images.
Add code option to test_shaders.py to preserve SPIR-V code for interactive debugging.
2017-12-26 16:32:45 -05:00
Bill Hollings
3fcdce08ab CompilerMSL support platform semantics.
Support customizing MSL based on iOS or macOS platform.
Support SPIV-V containing multiple memory semantics.
2017-12-26 13:39:07 -05:00
Vadim Shcherbakov
3376198740 and a bit better case placemenent 2017-12-13 13:03:31 +03:00
Vadim Shcherbakov
db402236a7 move BuiltInLayer to vertex out function block 2017-12-13 13:02:03 +03:00
Vadim Shcherbakov
717d9fefd8 another formatting fix and a comment 2017-12-11 21:02:13 +03:00
Vadim Shcherbakov
6c41f9e9da MSL improvements:
- pack/unpack nested constant buffer structs
- support for write-only textures (only global ones for now)
- better rt index support for msl generator
2017-12-06 09:52:07 -08:00
Hans-Kristian Arntzen
aa2557c7df Fixups for PR #353. 2017-12-05 09:58:12 +01:00
Bill Hollings
c93d44ba3c For MSL, use {} instead of constructors to init OpUndef values. 2017-11-30 15:03:27 -05:00
Hans-Kristian Arntzen
ce18d4ce74 Run format_all.sh. 2017-11-17 13:38:29 +01:00
Bill Hollings
e83e2b2217 CompilerMSL support and tests for OpUndef. 2017-11-15 22:44:42 -05:00
Hans-Kristian Arntzen
4427cb993d Add support for renaming entry points. 2017-11-13 13:50:37 +01:00
Hans-Kristian Arntzen
f486142e36 Run format_all.sh. 2017-11-13 09:52:35 +01:00
Hans-Kristian Arntzen
997be5cb23 Build/warning fix on modern GCC. 2017-11-13 09:26:19 +01:00
Bill Hollings
696bf0db0f Fixes from review #2 of PR 321. 2017-11-08 13:54:28 -05:00