Commit Graph

14 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
d1479f871a MSL: Do not generate UnsafeArray<> for any array inside buffer objects.
This avoids a lot of huge code changes.
Arrays generally cannot be copied in and out of buffers, at least no
compiler frontend seems to do it.

Also avoids a lot of issues surrounding packed vectors and matrices.
2019-10-24 12:22:30 +02:00
Lukas Hermanns
7ad0a84778 Updates for pull request #1162 2019-09-24 14:35:25 -04:00
Lukas Hermanns
cb3ecb9e1b Updated reference Metal shaders. 2019-09-17 15:11:19 -04:00
Mark Satterthwaite
564cb3c08d Update the Metal shaders to account for changes in the shader compilation. 2019-09-11 15:06:05 -04:00
Chip Davis
27af716c3a MSL: Emit F{Min,Max,Clamp} as fast:: and N{Min,Max,Clamp} as precise::.
This roughly matches their semantics in SPIR-V and MSL. For `FMin`,
`FMax`, and `FClamp`, and the Metal functions `fast::min()`,
`fast::max()`, and `fast::clamp()`, the result is undefined if any
operand is NaN. For the 'N' operations and their corresponding MSL
`precise::` functions, the result is consistent with IEEE 754 (first
non-NaN wins; result is NaN if all operands are NaN).

We can only do this with 32-bit floats, though, because Metal only
provides these variants for `float`. `half` only has one variant of
these functions that is presumably consistent with IEEE 754. I guess
that's OK; the SPIR-V spec only says that `F{Min,Max,Clamp}` are
undefined for NaNs. Performance might suffer, though.
2018-09-01 23:01:46 -05: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
192a882df3 Also unpack regular unary/binary operations on MSL.
Apparently MSL gets confused when you have packed_float3 op float3 ...
2018-06-11 16:23:09 +02:00
Bill Hollings
1c18078811 Enhancements to MSL compute and entry point naming.
Support Workgroup (threadgroup) variables.
Mark if SPIRConstant is used as an array length, since it cannot be specialized.
Resolve specialized array length constants.
Support passing an array to MSL function.
Support emitting GLSL array assignments in MSL via an array copy function.
Support for memory and control barriers.
Struct packing enhancements, including packing nested structs.
Enhancements to replacing illegal MSL variable and function names.
Add Compiler::get_entry_point_name_map() function to retrieve entry point renamings.
Remove CompilerGLSL::clean_func_name() as obsolete.
Fixes to types in bitcast MSL functions.
Add Variant::get_id() member function.
Add CompilerMSL::Options::msl_version option.
Add numerous MSL compute tests.
2017-11-05 21:34:42 -05:00
Hans-Kristian Arntzen
de33d89074 Add explicit in/out locations everywhere.
Needed for newer glslang. With Vulkan semantics for SPIR-V, all
locations must be explicitly defined.
2017-06-21 09:39:08 +02:00
Bill Hollings
192bdc9516 CompilerMSL elide unused builtins from entry function input and output structs.
Add Compiler::has_active_builtin() function.
Update test reference shaders that included unused builtins.
2017-05-24 09:31:38 -04:00
Hans-Kristian Arntzen
91379fb0d0 Implement more sophisticated check for point_size. 2017-05-23 10:15:22 +02:00
Bill Hollings
f9f87ca391 CompilerMSL output [[point_size]] attribute for BuiltInPointSize member by default.
CompilerMSL::Options::is_rendering_points defaults to true.
2017-05-05 16:13:55 -04:00
Hans-Kristian Arntzen
ab21dfb25b Fix execution order for for-loop emission.
In some cases, the compiler decided to emit continue block first,
which invalidated the expressions used by the condition.
Parameters to functions can be evaluated in any order which caused
"random" behavior.
2017-02-04 10:07:20 +01:00