Commit Graph

67 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
36e1c470a2 Fix formatting. 2017-05-06 13:59:00 +02:00
Hans-Kristian Arntzen
07ee7d09cb Fix deep call hierarchies in CombinedImageSamplerUsageHandler. 2017-05-06 13:53:06 +02:00
Hans-Kristian Arntzen
f4d7268565 GLSL will also need shadow state analysis.
Refactor stuff out to top-level.

Fix some bugs with combined shadow samplers in regular GLSL.
2017-05-06 13:21:35 +02:00
Hans-Kristian Arntzen
100e9d34b8 HLSL: Basic support for separate image/samplers. 2017-05-06 12:39:04 +02:00
Hans-Kristian Arntzen
93fe19c0f7 Add support for querying binary offsets of decorations in SPIR-V.
Facilitates easy SPIR-V patching when needed.
2017-04-26 09:24:24 +02:00
Yuriy O'Donnell
ae8de51138 Added a Compiler ctor that takes IR as raw array and count
This avoids the need to construct a temporary std::vector on the application side just to create a Compiler instance if application itself doesn't use STL containers.
2017-04-01 14:35:42 +02:00
Hans-Kristian Arntzen
c609eab443 Fix includes. 2017-03-25 16:43:26 +01:00
Hans-Kristian Arntzen
bf5c07532c Run format_all.sh. 2017-03-25 16:28:44 +01:00
Hans-Kristian Arntzen
b2c2e6483b Analyze parameter preservation for functions.
This is kinda tricky, because if we only conditionally write to a
function parameter variable it is implicitly preserved in SPIR-V, so we must force
an in qualifier on the parameter to get the same behavior in GLSL.
2017-03-25 16:25:30 +01:00
Hans-Kristian Arntzen
cd9c90202e Make buffer decoration interface public. 2017-03-23 12:36:53 +01:00
Hans-Kristian Arntzen
61c31c6054 Make use of explicit locations in HLSL. 2017-03-21 13:48:50 +01:00
Hans-Kristian Arntzen
2ebe1a87a1 Run format_all.sh. 2017-03-21 13:48:50 +01:00
Hans-Kristian Arntzen
bdea1a444a Begin rewriting how HLSL deals with inputs and outputs. 2017-03-21 13:48:50 +01:00
Hans-Kristian Arntzen
099f307123 Add traversal for active builtin variables.
Refactor some ugly type-copying for access chains.
2017-03-21 13:48:28 +01:00
Hans-Kristian Arntzen
75391f9a68 Handle vector variants of OpLogicalAnd/Or/Not. 2017-03-20 22:45:40 +01:00
Bill Hollings
52a5597161 Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2017-03-17 11:16:47 -04:00
Hans-Kristian Arntzen
8411470ab9 Add deprecation macro. 2017-03-15 10:31:19 +01:00
Bill Hollings
dc69427402 Updates to MSL functionality to support PR review feedback. 2017-03-11 12:17:22 -05:00
Bill Hollings
484931d8b2 spirv_msl auto-alignment of members of MSL uniform structs.
spirv_msl optionally add padding and packing to allow MSL
struct members to align with SPIR-V struct alignments.
spirv_cross add convenience methods for testing Decorations.
spirv_glsl replace member_decl() function with new emit_stuct_member().
Allow struct member types to be marked as packed via DecorationCPacked decoration.
2017-02-28 21:44:36 -05:00
Hans-Kristian Arntzen
18c37bcdab Update license headers for 2017. 2017-01-28 09:00:40 +01:00
Robert Konrad
429b8cb25f Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross into hlsl
# Conflicts:
#	spirv_glsl.hpp
2017-01-23 14:44:41 +01:00
Robert Konrad
451bdeeeff Fix HLSL binding numbers 2017-01-23 14:40:25 +01:00
Hans-Kristian Arntzen
9540979c55 Support int and uint as flattened UBO types. 2017-01-21 12:29:20 +01:00
Hans-Kristian Arntzen
d3cad99347 Cleanups for flattened access chains. 2017-01-21 11:30:33 +01:00
Hans-Kristian Arntzen
016b1d86e9 Emit readonly, writeonly for SSBOs. 2017-01-21 10:08:27 +01:00
Arseny Kapoulkine
0185f0a6b8 Implement buffer block flattening
Legacy GLSL targets do not support uniform buffers, and as such require
some sort of emulation. There are two alternatives - one is to represent
a uniform buffer as a uniform struct, and another one is to flatten it
into an array of primitive vector types (vec4).

Uniform struct have two disadvantages that make using them prohibitive
in some applications:

- The location assignment for struct members is arbitrary which means
the application has to set each struct member one by one
- Some Android drivers fail to link shader programs if both vertex and
fragment shader use the same uniform struct

Because of this, we need to support flattening uniform buffers into an
array. This is not just important for legacy GLSL but also is sometimes
useful for ESSL 3.0 where some Android drivers do not have stable UBO
support.

The way flattening works is the entire buffer is represented as a vec4
array; each access chain is rewritten into a combination of array
accesses, swizzles and data type constructors. Specifically:

- Extracting a vector or a scalar requires indexing into the array with
an optional swizzle, for example CB0[13].yz for reading vec2
- Extracting a matrix or a struct requires extracting each individual
vector or struct member and then combining them into the resulting
object
- Extracting arrays is not supported, mostly because the resulting
construct is very inefficient and ESSL 1.0 does not support array
constructors.

Additionally, while we try to constant-fold each individual indexing
operation, there are cases where we have to use dynamic index
computation (specifically for indexing arrays with non-constants); so
the general form of the primitive array extraction expression is:

buffer[stride0*index0+...+strideN*indexN+offset]

Where stride/offset are integer literals and index represents variables.
2017-01-17 23:26:08 -08:00
Graham Wihlidal
2edc350aa1 Remove whitespace 2017-01-05 21:04:42 +01:00
Graham Wihlidal
9b1ee8f10a Improve fix for boolean decorations queried in get_decoration, added support to get_member_decoration, and updated comments to reflect the change in behavior. 2017-01-05 21:01:49 +01:00
Bill Hollings
7d38f1822a CompilerMSL fixes to support pull-request feedback.
Make Compiler::OpcodeHandler and Compiler::traverse_all_reachable_opcodes protected
instead of private, for use by subclasses.
Add CompilerMSL::CustomFunctionHandler and traverse_all_reachable_opcodes() to detect
active opcodes that require the output of a custom function.
CompilerMSL::custom_function_ops use std::set to retain ordering to improve testability.
2016-12-21 16:31:13 -05:00
Panagiotis Christopoulos Charitos
946f7796c1 Add an option to disable exceptions
Some refactoring in the no-exceptions case

Grooming the no-exceptions patch for pull request
2016-12-15 17:49:01 +01:00
Hans-Kristian Arntzen
b847c88559 Cleanup, and make cfg analysis optional. 2016-11-18 17:06:49 +01:00
Hans-Kristian Arntzen
5ff11cc689 Handle more corner cases with the CFG traversal. 2016-11-18 16:45:11 +01:00
Hans-Kristian Arntzen
dad4a34072 Start adding CFG analysis.
Not complete yet, but partly working ...
2016-11-17 16:58:05 +01:00
Bill Hollings
ac00c6032f Run clang-format. 2016-10-24 09:24:24 -04:00
Bill Hollings
a759e2c872 Merge Brenwill fork with upstream. 2016-10-19 14:09:51 -07:00
Hans-Kristian Arntzen
6bd545bc6b Basic support for specialization constant reflection. 2016-10-03 12:29:46 +02:00
Hans-Kristian Arntzen
4d4e6d7a41 Document variable type remap interface a bit more.
Fix some minor missing pieces from C++.
Type remapping like this doesn't seem to fit MSL backend so well, as it
does a lot of remapping internally on its own.

Type name remapping, really is for fringe extension cases in GLSL which
aren't yet supported in SPIR-V.
2016-09-20 10:55:09 +02:00
Panagiotis Christopoulos Charitos
66e76d903f Add support of variable type remapping 2016-09-20 10:26:07 +02:00
Hans-Kristian Arntzen
ed98a8ec86 Begin implementing parameter remapping for combined image sampler.
The basic idea here is that all functions will have a list of which
combinations of parameters will be combined inside the function.
The caller will then know which combined samplers must be provided to
the callee in order to satisfy it.
2016-09-11 11:39:20 +02:00
Hans-Kristian Arntzen
dd1513b814 Trace usage of image/sampler variants through calls. 2016-09-10 21:52:22 +02:00
Hans-Kristian Arntzen
71bacc4469 Basic combined image sampler emulation hooked up. 2016-09-10 17:48:52 +02:00
Hans-Kristian Arntzen
1b5ca8d868 Move combined image hiding logic into is_hidden. 2016-09-10 16:20:19 +02:00
Hans-Kristian Arntzen
bcb5560109 Sketch out interface for combined image samplers. 2016-09-10 13:56:36 +02:00
Hans-Kristian Arntzen
e92020819e Add reflection support for separate textures and samplers. 2016-09-10 13:05:35 +02:00
Bill Hollings
cf476f36d1 Merge MSL with upstream. 2016-08-31 21:00:56 -04:00
Hans-Kristian Arntzen
f61a5d1e5d Implement dead variable elimination. 2016-08-26 12:58:50 +02:00
Bill Hollings
0dfeabc6d2 Merge branch 'master' of https://github.com/KhronosGroup/SPIRV-Cross 2016-08-01 15:38:57 -04:00
Hans-Kristian Arntzen
042475e88e Add support for multiple entry points.
- Only consider I/O variables if part of OpEntryPoint.
- Keep a safe fallback if #entry-points is 1 to avoid potentially
  breaking previously working shaders.
2016-07-28 13:18:55 +02:00
Bill Hollings
7c255dde4d Merged with upstream 2016-07-24 22:40:20 -07:00
Hans-Kristian Arntzen
5c24d99ff2 Add distinction between type_id and base_type_id in resource interface.
type_id was not intuitive and did not allow for parsing array sizes of
variables.

Expose another member, base_type_id which will provide the base type
suitable for parsing metadata such as decorations and type_id will now
point to the actual type which includes full type information such as
arrays and so on.
2016-07-12 21:20:18 +02:00