mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 18:50:10 +01:00
glsl: rework zero initialization
This commit makes zero_init a bitfield of types of variables to zeroinit. This will allow some flexibility that will be used in the next commit. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4607>
This commit is contained in:
parent
84f58a0863
commit
fa6b22d36a
3 changed files with 16 additions and 6 deletions
|
|
@ -5265,10 +5265,8 @@ ast_declarator_list::hir(exec_list *instructions,
|
|||
apply_layout_qualifier_to_variable(&this->type->qualifier, var, state,
|
||||
&loc);
|
||||
|
||||
if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary
|
||||
|| var->data.mode == ir_var_shader_out)
|
||||
&& (var->type->is_numeric() || var->type->is_boolean())
|
||||
&& state->zero_init) {
|
||||
if ((state->zero_init & (1u << var->data.mode)) &&
|
||||
(var->type->is_numeric() || var->type->is_boolean())) {
|
||||
const ir_constant_data data = { { 0 } };
|
||||
var->data.has_initializer = true;
|
||||
var->constant_initializer = new(var) ir_constant(var->type, &data);
|
||||
|
|
@ -5861,6 +5859,13 @@ ast_parameter_declarator::hir(exec_list *instructions,
|
|||
apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
|
||||
true);
|
||||
|
||||
if (((1u << var->data.mode) & state->zero_init) &&
|
||||
(var->type->is_numeric() || var->type->is_boolean())) {
|
||||
const ir_constant_data data = { { 0 } };
|
||||
var->data.has_initializer = true;
|
||||
var->constant_initializer = new(var) ir_constant(var->type, &data);
|
||||
}
|
||||
|
||||
/* From section 4.1.7 of the GLSL 4.40 spec:
|
||||
*
|
||||
* "Opaque variables cannot be treated as l-values; hence cannot
|
||||
|
|
|
|||
|
|
@ -82,7 +82,11 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
|
|||
/* Set default language version and extensions */
|
||||
this->language_version = 110;
|
||||
this->forced_language_version = ctx->Const.ForceGLSLVersion;
|
||||
this->zero_init = ctx->Const.GLSLZeroInit;
|
||||
if (ctx->Const.GLSLZeroInit == 1) {
|
||||
this->zero_init = (1u << ir_var_auto) | (1u << ir_var_temporary) | (1u << ir_var_shader_out);
|
||||
} else {
|
||||
this->zero_init = 0;
|
||||
}
|
||||
this->gl_version = 20;
|
||||
this->compat_shader = true;
|
||||
this->es_shader = false;
|
||||
|
|
|
|||
|
|
@ -388,7 +388,8 @@ struct _mesa_glsl_parse_state {
|
|||
bool compat_shader;
|
||||
unsigned language_version;
|
||||
unsigned forced_language_version;
|
||||
bool zero_init;
|
||||
/* Bitfield of ir_variable_mode to zero init */
|
||||
uint32_t zero_init;
|
||||
unsigned gl_version;
|
||||
gl_shader_stage stage;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue