[Mesa-dev] [RFC PATCH 05/26] glsl: add new glsl_type helpers for bindless sampler/image types
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Apr 11 16:48:16 UTC 2017
Similar to existing helpers for sampler/image types.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/compiler/glsl_types.cpp | 31 +++++++++++++++++++++++++++++++
src/compiler/glsl_types.h | 28 ++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 1b06eb68f4..c7a41b785e 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -225,6 +225,21 @@ glsl_type::contains_sampler() const
}
}
+bool
+glsl_type::contains_bindless_sampler() const
+{
+ if (this->is_array()) {
+ return this->fields.array->contains_bindless_sampler();
+ } else if (this->is_record() || this->is_interface()) {
+ for (unsigned int i = 0; i < this->length; i++) {
+ if (this->fields.structure[i].type->contains_bindless_sampler())
+ return true;
+ }
+ return false;
+ } else {
+ return this->is_bindless_sampler();
+ }
+}
bool
glsl_type::contains_integer() const
@@ -341,6 +356,22 @@ glsl_type::contains_image() const
}
}
+bool
+glsl_type::contains_bindless_image() const
+{
+ if (this->is_array()) {
+ return this->fields.array->contains_bindless_image();
+ } else if (this->is_record() || this->is_interface()) {
+ for (unsigned int i = 0; i < this->length; i++) {
+ if (this->fields.structure[i].type->contains_bindless_image())
+ return true;
+ }
+ return false;
+ } else {
+ return this->is_bindless_image();
+ }
+}
+
const glsl_type *glsl_type::get_base_type() const
{
switch (base_type) {
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 4cb330e4a3..230fc7dbee 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -552,12 +552,26 @@ struct glsl_type {
}
/**
+ * Query whether or not a type is a bindless sampler.
+ */
+ bool is_bindless_sampler() const
+ {
+ return base_type == GLSL_TYPE_BINDLESS_SAMPLER;
+ }
+
+ /**
* Query whether or not type is a sampler, or for struct, interface and
* array types, contains a sampler.
*/
bool contains_sampler() const;
/**
+ * Query whether or not type is a bindless sampler, or for struct, interface
+ * and array types, contains a bindless sampler.
+ */
+ bool contains_bindless_sampler() const;
+
+ /**
* Get the Mesa texture target index for a sampler type.
*/
gl_texture_index sampler_index() const;
@@ -569,6 +583,12 @@ struct glsl_type {
bool contains_image() const;
/**
+ * Query whether or not type is a bindless image, or for struct, interface
+ * and array types, contains a bindless image.
+ */
+ bool contains_bindless_image() const;
+
+ /**
* Query whether or not a type is an image
*/
bool is_image() const
@@ -577,6 +597,14 @@ struct glsl_type {
}
/**
+ * Query whether or not a type is a bindless image.
+ */
+ bool is_bindless_image() const
+ {
+ return base_type == GLSL_TYPE_BINDLESS_IMAGE;
+ }
+
+ /**
* Query whether or not a type is an array
*/
bool is_array() const
--
2.12.2
More information about the mesa-dev
mailing list