[Mesa-dev] [RFC PATCH 12/26] glsl: add image functions for bindless image types
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Apr 11 16:48:23 UTC 2017
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/compiler/glsl/builtin_functions.cpp | 81 +++++++++++++++++++++++++++++----
1 file changed, 73 insertions(+), 8 deletions(-)
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index b57823fa78..0dc8af8194 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -849,6 +849,24 @@ v130_desktop_bindless(const _mesa_glsl_parse_state *state)
return v130_desktop(state) && bindless(state);
}
+static bool
+shader_image_atomic_exchange_float_bindless(const _mesa_glsl_parse_state *state)
+{
+ return shader_image_atomic_exchange_float(state) && bindless(state);
+}
+
+static bool
+shader_image_atomic_bindless(const _mesa_glsl_parse_state *state)
+{
+ return shader_image_atomic(state) && bindless(state);
+}
+
+static bool
+shader_image_load_store_bindless(const _mesa_glsl_parse_state *state)
+{
+ return shader_image_load_store(state) && bindless(state);
+}
+
/** @} */
/******************************************************************************/
@@ -1212,7 +1230,8 @@ enum image_function_flags {
IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
IMAGE_FUNCTION_MS_ONLY = (1 << 7),
- IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8)
+ IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),
+ IMAGE_FUNCTION_BINDLESS = (1 << 9),
};
} /* anonymous namespace */
@@ -3539,7 +3558,40 @@ builtin_builder::add_image_function(const char *name,
glsl_type::uimage2DArray_type,
glsl_type::uimageCubeArray_type,
glsl_type::uimage2DMS_type,
- glsl_type::uimage2DMSArray_type
+ glsl_type::uimage2DMSArray_type,
+ glsl_type::image1DBindless_type,
+ glsl_type::image2DBindless_type,
+ glsl_type::image3DBindless_type,
+ glsl_type::image2DRectBindless_type,
+ glsl_type::imageCubeBindless_type,
+ glsl_type::imageBufferBindless_type,
+ glsl_type::image1DArrayBindless_type,
+ glsl_type::image2DArrayBindless_type,
+ glsl_type::imageCubeArrayBindless_type,
+ glsl_type::image2DMSBindless_type,
+ glsl_type::image2DMSArrayBindless_type,
+ glsl_type::iimage1DBindless_type,
+ glsl_type::iimage2DBindless_type,
+ glsl_type::iimage3DBindless_type,
+ glsl_type::iimage2DRectBindless_type,
+ glsl_type::iimageCubeBindless_type,
+ glsl_type::iimageBufferBindless_type,
+ glsl_type::iimage1DArrayBindless_type,
+ glsl_type::iimage2DArrayBindless_type,
+ glsl_type::iimageCubeArrayBindless_type,
+ glsl_type::iimage2DMSBindless_type,
+ glsl_type::iimage2DMSArrayBindless_type,
+ glsl_type::uimage1DBindless_type,
+ glsl_type::uimage2DBindless_type,
+ glsl_type::uimage3DBindless_type,
+ glsl_type::uimage2DRectBindless_type,
+ glsl_type::uimageCubeBindless_type,
+ glsl_type::uimageBufferBindless_type,
+ glsl_type::uimage1DArrayBindless_type,
+ glsl_type::uimage2DArrayBindless_type,
+ glsl_type::uimageCubeArrayBindless_type,
+ glsl_type::uimage2DMSBindless_type,
+ glsl_type::uimage2DMSArrayBindless_type
};
ir_function *f = new(mem_ctx) ir_function(name);
@@ -3548,9 +3600,16 @@ builtin_builder::add_image_function(const char *name,
if ((types[i]->sampled_type != GLSL_TYPE_FLOAT ||
(flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) &&
(types[i]->sampler_dimensionality == GLSL_SAMPLER_DIM_MS ||
- !(flags & IMAGE_FUNCTION_MS_ONLY)))
- f->add_signature(_image(prototype, types[i], intrinsic_name,
- num_arguments, flags, intrinsic_id));
+ !(flags & IMAGE_FUNCTION_MS_ONLY))) {
+ if (types[i]->is_bindless_image())
+ f->add_signature(_image(prototype, types[i], intrinsic_name,
+ num_arguments,
+ flags | IMAGE_FUNCTION_BINDLESS,
+ intrinsic_id));
+ else
+ f->add_signature(_image(prototype, types[i], intrinsic_name,
+ num_arguments, flags, intrinsic_id));
+ }
}
shader->symbols->add_function(f);
@@ -6097,14 +6156,20 @@ get_image_available_predicate(const glsl_type *type, unsigned flags)
{
if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE) &&
type->sampled_type == GLSL_TYPE_FLOAT)
- return shader_image_atomic_exchange_float;
+ return (flags & IMAGE_FUNCTION_BINDLESS) ?
+ shader_image_atomic_exchange_float_bindless :
+ shader_image_atomic_exchange_float;
else if (flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
IMAGE_FUNCTION_AVAIL_ATOMIC))
- return shader_image_atomic;
+ return (flags & IMAGE_FUNCTION_BINDLESS) ?
+ shader_image_atomic_bindless :
+ shader_image_atomic;
else
- return shader_image_load_store;
+ return (flags & IMAGE_FUNCTION_BINDLESS) ?
+ shader_image_load_store_bindless :
+ shader_image_load_store;
}
ir_function_signature *
--
2.12.2
More information about the mesa-dev
mailing list