aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <[email protected]>2020-06-19 18:34:51 +0200
committerPierre-Eric Pelloux-Prayer <[email protected]>2020-07-09 09:58:01 +0200
commit233af4a412db87a9b8430104a58c1b6adb704b1c (patch)
tree05d97cba2d5a14e3e12eae183a0f533c4ffcaede /src
parent438392243fb284884e8499758064256fb3dad48d (diff)
glsl: don't expose imageAtomicIncWrap for signed image
The spec says that it's only allowed for unsigned ones. Same from imageAtomicDecWrap. Fixes: fc0a2e5d017 ("glsl: add EXT_shader_image_load_store new image functions") Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5688>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 172633042ba..f6c208e60c1 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -1253,6 +1253,7 @@ enum image_function_flags {
IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),
IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9),
IMAGE_FUNCTION_EXT_ONLY = (1 << 10),
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE = (1 << 11),
};
} /* anonymous namespace */
@@ -4631,14 +4632,15 @@ builtin_builder::add_image_function(const char *name,
ir_function *f = new(mem_ctx) ir_function(name);
for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) {
- 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));
+ if (types[i]->sampled_type == GLSL_TYPE_FLOAT && !(flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE))
+ continue;
+ if (types[i]->sampled_type == GLSL_TYPE_INT && !(flags & IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE))
+ continue;
+ if ((types[i]->sampler_dimensionality != GLSL_SAMPLER_DIM_MS) && (flags & IMAGE_FUNCTION_MS_ONLY))
+ continue;
+ f->add_signature(_image(prototype, types[i], intrinsic_name,
+ num_arguments, flags, intrinsic_id));
}
-
shader->symbols->add_function(f);
}
@@ -4652,6 +4654,7 @@ builtin_builder::add_image_functions(bool glsl)
&builtin_builder::_image_prototype, 0,
(flags | IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |
IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |
IMAGE_FUNCTION_READ_ONLY),
ir_intrinsic_image_load);
@@ -4661,6 +4664,7 @@ builtin_builder::add_image_functions(bool glsl)
(flags | IMAGE_FUNCTION_RETURNS_VOID |
IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |
IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |
IMAGE_FUNCTION_WRITE_ONLY),
ir_intrinsic_image_store);
@@ -4670,32 +4674,38 @@ builtin_builder::add_image_functions(bool glsl)
"__intrinsic_image_atomic_add",
&builtin_builder::_image_prototype, 1,
(flags | IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |
- IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),
+ IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE),
ir_intrinsic_image_atomic_add);
add_image_function(glsl ? "imageAtomicMin" : "__intrinsic_image_atomic_min",
"__intrinsic_image_atomic_min",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_min);
add_image_function(glsl ? "imageAtomicMax" : "__intrinsic_image_atomic_max",
"__intrinsic_image_atomic_max",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_max);
add_image_function(glsl ? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
"__intrinsic_image_atomic_and",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_and);
add_image_function(glsl ? "imageAtomicOr" : "__intrinsic_image_atomic_or",
"__intrinsic_image_atomic_or",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_or);
add_image_function(glsl ? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
"__intrinsic_image_atomic_xor",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_xor);
add_image_function((glsl ? "imageAtomicExchange" :
@@ -4703,25 +4713,29 @@ builtin_builder::add_image_functions(bool glsl)
"__intrinsic_image_atomic_exchange",
&builtin_builder::_image_prototype, 1,
(flags | IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |
IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),
ir_intrinsic_image_atomic_exchange);
add_image_function((glsl ? "imageAtomicCompSwap" :
"__intrinsic_image_atomic_comp_swap"),
"__intrinsic_image_atomic_comp_swap",
- &builtin_builder::_image_prototype, 2, atom_flags,
+ &builtin_builder::_image_prototype, 2,
+ atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_atomic_comp_swap);
add_image_function(glsl ? "imageSize" : "__intrinsic_image_size",
"__intrinsic_image_size",
&builtin_builder::_image_size_prototype, 1,
- flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE,
+ flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,
ir_intrinsic_image_size);
add_image_function(glsl ? "imageSamples" : "__intrinsic_image_samples",
"__intrinsic_image_samples",
&builtin_builder::_image_samples_prototype, 1,
flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |
+ IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |
IMAGE_FUNCTION_MS_ONLY,
ir_intrinsic_image_samples);