glsl: Prohibit implicit conversion of mem parameter in atomicOP functions

Per OpenGL Shading Language, section 8.11. "Atomic Memory Functions"
first argument "mem" of all atomicOP functions is inout.
The same is true for ARB_shader_storage_buffer_object and
GL_INTEL_shader_atomic_float_minmax

For implicit conversion of inout parameters it is required for type
to support bi-directional conversion, since there is no such types
in glsl - implicit conversion is effectively prohibited.

Alternatively we could have marked atomic_var parameter of built-in
atomicOP functions as inout, however it opens another can of worms
during NIR lowerings.

Fixes: ea0a1f5beb
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2837
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4887>
This commit is contained in:
Danylo Piliaiev
2020-04-29 14:08:48 +03:00
committed by Danylo Piliaiev
parent 5c77f99c2e
commit c0f623e62f
5 changed files with 14 additions and 6 deletions

View File

@@ -7340,6 +7340,8 @@ builtin_builder::_atomic_op2(const char *intrinsic,
ir_variable *data = in_var(type, "atomic_data"); ir_variable *data = in_var(type, "atomic_data");
MAKE_SIG(type, avail, 2, atomic, data); MAKE_SIG(type, avail, 2, atomic, data);
atomic->data.implicit_conversion_prohibited = true;
ir_variable *retval = body.make_temp(type, "atomic_retval"); ir_variable *retval = body.make_temp(type, "atomic_retval");
body.emit(call(shader->symbols->get_function(intrinsic), retval, body.emit(call(shader->symbols->get_function(intrinsic), retval,
sig->parameters)); sig->parameters));
@@ -7357,6 +7359,8 @@ builtin_builder::_atomic_op3(const char *intrinsic,
ir_variable *data2 = in_var(type, "atomic_data2"); ir_variable *data2 = in_var(type, "atomic_data2");
MAKE_SIG(type, avail, 3, atomic, data1, data2); MAKE_SIG(type, avail, 3, atomic, data1, data2);
atomic->data.implicit_conversion_prohibited = true;
ir_variable *retval = body.make_temp(type, "atomic_retval"); ir_variable *retval = body.make_temp(type, "atomic_retval");
body.emit(call(shader->symbols->get_function(intrinsic), retval, body.emit(call(shader->symbols->get_function(intrinsic), retval,
sig->parameters)); sig->parameters));

View File

@@ -2073,6 +2073,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->data.stream = 0; this->data.stream = 0;
this->data.xfb_buffer = -1; this->data.xfb_buffer = -1;
this->data.xfb_stride = -1; this->data.xfb_stride = -1;
this->data.implicit_conversion_prohibited = false;
this->interface_type = NULL; this->interface_type = NULL;

View File

@@ -892,6 +892,12 @@ public:
*/ */
unsigned bound:1; unsigned bound:1;
/**
* Non-zero if the variable shall not be implicitly converted during
* functions matching.
*/
unsigned implicit_conversion_prohibited:1;
/** /**
* Emit a warning if this variable is accessed. * Emit a warning if this variable is accessed.
*/ */

View File

@@ -83,8 +83,9 @@ parameter_lists_match(_mesa_glsl_parse_state *state,
case ir_var_const_in: case ir_var_const_in:
case ir_var_function_in: case ir_var_function_in:
if (!actual->type->can_implicitly_convert_to(param->type, state)) if (param->data.implicit_conversion_prohibited ||
return PARAMETER_LIST_NO_MATCH; !actual->type->can_implicitly_convert_to(param->type, state))
return PARAMETER_LIST_NO_MATCH;
break; break;
case ir_var_function_out: case ir_var_function_out:

View File

@@ -704,10 +704,6 @@ spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.geom: skip
spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.tesc: skip spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.tesc: skip
spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.tese: skip spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.tese: skip
spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.vert: skip spec/arb_shader_stencil_export/preprocessor/disabled-undefined-core.vert: skip
spec/arb_shader_storage_buffer_object/compiler/atomiccompswap-implicit-conversion.vert: crash
spec/arb_shader_storage_buffer_object/compiler/atomicmin-array-element-implicit-conversion.vert: crash
spec/arb_shader_storage_buffer_object/compiler/atomicmin-implicit-conversion.vert: crash
spec/arb_shader_storage_buffer_object/compiler/atomicmin-swizzle-implicit-conversion.vert: crash
spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-compat.frag: skip spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-compat.frag: skip
spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-compat.vert: skip spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-compat.vert: skip
spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-core.comp: skip spec/arb_shader_storage_buffer_object/preprocessor/disabled-defined-core.comp: skip