+ state->ARB_shader_image_size_enable);
+}
+
+static bool
gs_streams(const _mesa_glsl_parse_state *state)
{
return gpu_shader5(state) && gs_only(state);
@@ -502,8 +509,8 @@ private:
};
/**
- * Create a new image built-in function for all known image types.
- * \p flags is a bitfield of \c image_function_flags flags.
+ * Create a new image built-in function for image load/store for all known
+ * image types. \p flags is a bitfield of \c image_function_flags flags.
*/
void add_image_function(const char *name,
const char *intrinsic_name,
@@ -511,14 +518,24 @@ private:
unsigned flags);
/**
- * Create new functions for all known image built-ins and types.
- * If \p glsl is \c true, use the GLSL built-in names and emit code
- * to call into the actual compiler intrinsic. If \p glsl is
+ * Create a new image built-in function for image load/store for all known
+ * image types. If \p glsl is \c true, use the GLSL built-in names and emit
+ * code to call into the actual compiler intrinsic. If \p glsl is
* false, emit a function prototype with no body for each image
* intrinsic name.
*/
void add_image_functions(bool glsl);
+ /**
+ * Create the imageSize built-in function for all known image built-ins and
+ * types. If \p glsl is \c true, use the GLSL built-in names and emit code
+ * to call into the actual compiler intrinsic. If \p glsl is
+ * false, emit a function prototype with no body for each image
+ * intrinsic name.
+ */
+ void add_image_size_functions(const char *name, const char *intrinsic_name,
+ unsigned flags);
+
ir_function_signature *new_sig(const glsl_type *return_type,
builtin_available_predicate avail,
int num_params, ...);
@@ -718,6 +735,10 @@ private:
ir_function_signature *_memory_barrier(
builtin_available_predicate avail);
+ ir_function_signature *_image_size(const glsl_type *image_type,
+ const char *intrinsic_name,
+ unsigned flags);
+
#undef B0
#undef B1
#undef B2
@@ -2549,53 +2570,54 @@ builtin_builder::add_function(const char *name, ...)
shader->symbols->add_function(f);
}
+static const glsl_type *const image_types[] = {
+ glsl_type::image1D_type,
+ glsl_type::image2D_type,
+ glsl_type::image3D_type,
+ glsl_type::image2DRect_type,
+ glsl_type::imageCube_type,
+ glsl_type::imageBuffer_type,
+ glsl_type::image1DArray_type,
+ glsl_type::image2DArray_type,
+ glsl_type::imageCubeArray_type,
+ glsl_type::image2DMS_type,
+ glsl_type::image2DMSArray_type,
+ glsl_type::iimage1D_type,
+ glsl_type::iimage2D_type,
+ glsl_type::iimage3D_type,
+ glsl_type::iimage2DRect_type,
+ glsl_type::iimageCube_type,
+ glsl_type::iimageBuffer_type,
+ glsl_type::iimage1DArray_type,
+ glsl_type::iimage2DArray_type,
+ glsl_type::iimageCubeArray_type,
+ glsl_type::iimage2DMS_type,
+ glsl_type::iimage2DMSArray_type,
+ glsl_type::uimage1D_type,
+ glsl_type::uimage2D_type,
+ glsl_type::uimage3D_type,
+ glsl_type::uimage2DRect_type,
+ glsl_type::uimageCube_type,
+ glsl_type::uimageBuffer_type,
+ glsl_type::uimage1DArray_type,
+ glsl_type::uimage2DArray_type,
+ glsl_type::uimageCubeArray_type,
+ glsl_type::uimage2DMS_type,
+ glsl_type::uimage2DMSArray_type
+};
+
void
builtin_builder::add_image_function(const char *name,
const char *intrinsic_name,
unsigned num_arguments,
unsigned flags)
{
- static const glsl_type *const types[] = {
- glsl_type::image1D_type,
- glsl_type::image2D_type,
- glsl_type::image3D_type,
- glsl_type::image2DRect_type,
- glsl_type::imageCube_type,
- glsl_type::imageBuffer_type,
- glsl_type::image1DArray_type,
- glsl_type::image2DArray_type,
- glsl_type::imageCubeArray_type,
- glsl_type::image2DMS_type,
- glsl_type::image2DMSArray_type,
- glsl_type::iimage1D_type,
- glsl_type::iimage2D_type,
- glsl_type::iimage3D_type,
- glsl_type::iimage2DRect_type,
- glsl_type::iimageCube_type,
- glsl_type::iimageBuffer_type,
- glsl_type::iimage1DArray_type,
- glsl_type::iimage2DArray_type,
- glsl_type::iimageCubeArray_type,
- glsl_type::iimage2DMS_type,
- glsl_type::iimage2DMSArray_type,
- glsl_type::uimage1D_type,
- glsl_type::uimage2D_type,
- glsl_type::uimage3D_type,
- glsl_type::uimage2DRect_type,
- glsl_type::uimageCube_type,
- glsl_type::uimageBuffer_type,
- glsl_type::uimage1DArray_type,
- glsl_type::uimage2DArray_type,
- glsl_type::uimageCubeArray_type,
- glsl_type::uimage2DMS_type,
- glsl_type::uimage2DMSArray_type
- };
ir_function *f = new(mem_ctx) ir_function(name);
- for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) {
- if (types[i]->sampler_type != GLSL_TYPE_FLOAT ||
+ for (unsigned i = 0; i < ARRAY_SIZE(image_types); ++i) {
+ if (image_types[i]->sampler_type != GLSL_TYPE_FLOAT ||
(flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE))
- f->add_signature(_image(types[i], intrinsic_name,
+ f->add_signature(_image(image_types[i], intrinsic_name,
num_arguments, flags));
}
@@ -2603,6 +2625,20 @@ builtin_builder::add_image_function(const char *name,
}
void
+builtin_builder::add_image_size_functions(const char *name,
+ const char *intrinsic_name,
+ unsigned flags)
+{
+ ir_function *f = new(mem_ctx) ir_function(name);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(image_types); ++i) {
+ f->add_signature(_image_size(image_types[i], intrinsic_name, flags));