Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2021-04-16 14:32:37 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2021-04-19 13:10:49 +0300
commitb4a380a04c47a5cbed8655b8cdb729563e952c5b (patch)
treefe15ebc56dc3e7c258e931ccadbc4362da690b56 /spirv_cross.hpp
parent852f2da63cb3b501fe52504f67a550329b0bfa7e (diff)
Support reflecting builtins.
They were ignored in input/output variables.
Diffstat (limited to 'spirv_cross.hpp')
-rw-r--r--spirv_cross.hpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/spirv_cross.hpp b/spirv_cross.hpp
index 84e23ca3..d818bb66 100644
--- a/spirv_cross.hpp
+++ b/spirv_cross.hpp
@@ -59,6 +59,26 @@ struct Resource
std::string name;
};
+struct BuiltInResource
+{
+ // This is mostly here to support reflection of builtins such as Position/PointSize/CullDistance/ClipDistance.
+ // This needs to be different from Resource since we can collect builtins from blocks.
+ // A builtin present here does not necessarily mean it's considered an active builtin,
+ // since variable ID "activeness" is only tracked on OpVariable level, not Block members.
+ // For that, update_active_builtins() -> has_active_builtin() can be used to further refine the reflection.
+ spv::BuiltIn builtin;
+
+ // This is the actual value type of the builtin.
+ // Typically float4, float, array<float, N> for the gl_PerVertex builtins.
+ TypeID value_type_id;
+
+ // This refers to the base resource which contains the builtin.
+ // If resource is a Block, it can hold multiple builtins, or it might not be a block.
+ // For advanced reflection scenarios, all information in builtin/value_type_id can be deduced,
+ // it's just more convenient this way.
+ Resource resource;
+};
+
struct ShaderResources
{
SmallVector<Resource> uniform_buffers;
@@ -79,6 +99,9 @@ struct ShaderResources
// these correspond to separate texture2D and samplers respectively.
SmallVector<Resource> separate_images;
SmallVector<Resource> separate_samplers;
+
+ SmallVector<BuiltInResource> builtin_inputs;
+ SmallVector<BuiltInResource> builtin_outputs;
};
struct CombinedImageSampler
@@ -324,7 +347,7 @@ public:
// Traverses all reachable opcodes and sets active_builtins to a bitmask of all builtin variables which are accessed in the shader.
void update_active_builtins();
- bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage);
+ bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage) const;
// Query and modify OpExecutionMode.
const Bitset &get_execution_mode_bitset() const;