Commit Graph

128 Commits

Author SHA1 Message Date
Chip Davis
8855ea0a3e Move is_sampled_image_type() onto the Compiler class.
While I'm at it, don't use a bitwise op with a `bool` variable.
Apparently, MSVC doesn't like that.
2018-09-24 12:24:58 -05:00
Chip Davis
c11374c3cf Don't override Compiler::analyze_image_and_sampler_usage().
Just add our own separate function for analyzing sampled image usage.
2018-09-24 12:10:27 -05:00
Chip Davis
4302c5abfb Pass the swizzle constants as a buffer.
It'll be useful to have an "auxiliary buffer" for other builtins--e.g.
`DrawIndex` (which should be easier to implement now), or `ViewIndex`
when someone gets around to implementing multiview.

Pass this buffer to leaf functions as well.

Test that we handle this for integer textures as well.
2018-09-22 19:36:11 -05:00
Hans-Kristian Arntzen
d310060f92 MSL: Support global I/O block and struct Input/Output usage.
Implement this by flattening outputs and unflattening inputs explicitly.
This allows us to pass down a single struct instead of dealing with the
insanity that would be passing down each flattened member separately.

Remove stage_uniforms_var_id.
Seems to be dead code. Naked uniforms do not exist in SPIR-V for Vulkan,
which this seems to have been intended for. It was also unused elsewhere.
2018-09-13 16:04:24 +02:00
Hans-Kristian Arntzen
e86018f8a1 Add a helper function to improve reflection on runtime sized arrays. 2018-09-10 11:08:47 +02:00
Hans-Kristian Arntzen
8c314112b4 Run format_all.sh. 2018-07-05 14:18:34 +02:00
Hans-Kristian Arntzen
d29f48ef06 Deduce constant LUTs from read-write variables. 2018-07-05 13:25:57 +02:00
Hans-Kristian Arntzen
b5ed706860 Hoist out variable scope analysis. 2018-07-05 10:42:05 +02:00
Hans-Kristian Arntzen
c26c41b26b Make the CFGs for all active functions available.
Will make writing other CFG-depended stuff easier.
2018-07-04 17:26:53 +02:00
Hans-Kristian Arntzen
6fdadb9218 Track partial writes as well.
We will need this for LUT promotion.
2018-07-04 16:46:25 +02:00
Hans-Kristian Arntzen
7216129377 Hoist out the inline VariableAccessHandler class.
Will need this refactor to make it more widely useful for more advanced
workarounds.
2018-07-04 16:20:38 +02:00
Hans-Kristian Arntzen
e044732896 Support OpTypeImage with depth == 2 (unknown) properly.
Track which OpSampledImages are ever used with Dref opcodes.
2018-07-04 14:26:23 +02: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
Brad Davis
762040084d More feedback 2018-06-20 10:25:38 -07:00
Brad Davis
d0a67ba6a7 Code consolidation, const correctness, faster regression testing 2018-06-20 09:20:45 -07:00
Brad Davis
6c88b0048b PR feedback 2018-06-20 09:20:45 -07:00
Hans-Kristian Arntzen
3a9b045dc3 Various maintenance fixes.
- Do not emit set = in GLSL, even when non-zero.
- Fix warning on tautological comparison.
- Expose get_buffer_block_flags as mentioned in reflection guide.
2018-06-03 12:00:22 +02:00
Hans-Kristian Arntzen
a39eb4826b Combined array of images is starting to work ... 2018-04-23 11:52:05 +02:00
Hans-Kristian Arntzen
215d3ca0a4 Add support for new HLSL semantic/counter buffer decorations. 2018-04-04 12:54:31 +02:00
Hans-Kristian Arntzen
382101bd05 Run format_all.sh. 2018-04-04 09:26:53 +02: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
9fbd8b789e Update tests for latest SPIRV-Tools and glslang. 2018-03-12 15:11:55 +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
8d557d4103 Handle cases where merge selects as also loop merge or continue blocks. 2018-03-08 14:01:10 +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
467c95679e
Merge pull request #480 from KhronosGroup/fix-476
Take execution model into account for entry point methods.
2018-03-01 14:42:16 +01:00
Hans-Kristian Arntzen
1e4db56a65 Run format_all.sh. 2018-03-01 14:03:59 +01:00
Hans-Kristian Arntzen
eecbeaa33d Take execution model into account for entry point methods.
SPIR-V allows names to alias if they implement different stages.
Deprecate the old interface and replace it with a new one which takes
execution modes into account.
2018-03-01 14:00:55 +01:00
Hans-Kristian Arntzen
3c1b147272 Support Invariant for BuiltInPosition. 2018-03-01 12:31:39 +01:00
Hans-Kristian Arntzen
fb3f92a3ff Overhaul clip/cull distance support in GLSL. 2018-02-22 14:36:50 +01:00
Hans-Kristian Arntzen
1a2e4de7a5 Add test for texelFetch without sampler. 2018-02-21 13:45:59 +01:00
Hans-Kristian Arntzen
4db7061dd1 Begin implementing texelFetch(texture2D) workaround on GLSL. 2018-02-21 13:08:30 +01:00
Hans-Kristian Arntzen
18a594a76b Implement subpass input support in HLSL. 2018-02-10 10:54:42 +01:00
Bill Hollings
1c94715350 Update copyright dates to 2018 in main files. 2018-01-31 17:08:43 -05: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
Hans-Kristian Arntzen
d4e470babd Analyze the CFG for temporaries as well.
Normally, temporary declaration must dominate any use of it,
so we generally did not need to analyze the CFG for these variables,
but there is an edge case where you have an inliner doing:

do {
	create_temporary;
	break;
} while(0);

use_temporary;

The inside of the loop dominates the outer scope, but we cannot emit
code like this in GLSL, so make sure we hoist these temporaries outside
the "loop".
2018-01-12 10:56:11 +01:00
Hans-Kristian Arntzen
b737d2bc07 Lift variable accesses in continue blocks out to loop header. 2017-12-05 17:40:23 +01:00
Hans-Kristian Arntzen
2c90ea3acc Improve handling of block name declaration in GLSL.
HLSL UAVs are a bit annoying because they can share block types,
so reflection becomes rather awkward. Sometimes we will need to make
some nasty fallbacks, so add a reflection interface which lets you query
post-shader compile which names was actually declared in the shader.
2017-12-01 14:30:10 +01:00
Hans-Kristian Arntzen
0fd028147f Hoist all phi-local variables to entry block.
We don't have a mechanism to move temporaries to their appropriate
scope, and Phi behavior is weird enough that it will be a heroic effort
to not do this rather ugly codegen :(
2017-11-23 09:50:11 +01:00
Hans-Kristian Arntzen
4427cb993d Add support for renaming entry points. 2017-11-13 13:50:37 +01:00
Bill Hollings
1014847f17 Fixes from review #3 of PR 321. 2017-11-10 16:40:33 -05:00
Bill Hollings
696bf0db0f Fixes from review #2 of PR 321. 2017-11-08 13:54:28 -05:00
Bill Hollings
bac657d873 Fixes from review of PR 321. 2017-11-07 15:38:13 -05:00
Bill Hollings
ba865733eb Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2017-11-05 22:49:08 -05: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
f0200bb18d Use packoffset in HLSL.
Rewrite how cbuffers are emitted.
2017-10-10 13:15:49 +02:00
Hans-Kristian Arntzen
5a89606f26 Add support for GL_ARB_enhanced_layouts. 2017-10-10 11:05:46 +02:00
Hans-Kristian Arntzen
6a7b95d2d6 Validate that std140 packing can actually be used. 2017-10-10 10:12:27 +02:00
Hans-Kristian Arntzen
aab3107a3f Add WorkGroupID/NumWorkGroups to MSL. Fix block name alias. 2017-09-29 12:16:53 +02:00