From 4d4f14937683110c7b61acb1555f31d070316b04 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 29 Sep 2017 10:16:43 -0700 Subject: i965: Only add the wpos state reference if we lowered something Otherwise, in the ARB program case _mesa_add_state_reference may grow the parameter array which will cause brw_nir_setup_arb_uniforms to write past the end of the param array because it only looks at the parameter list length but the parma array is allocated based on nir->num_uniforms. The only reason this hasn't caused us problems is because we are padding out the param array for fragment programs unnecessarily. Reviewed-by: Jordan Justen Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_program.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index f88977fb723..3b54b37cfaa 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -71,7 +71,6 @@ brw_create_nir(struct brw_context *brw, struct gl_context *ctx = &brw->ctx; const nir_shader_compiler_options *options = ctx->Const.ShaderCompilerOptions[stage].NirOptions; - bool progress; nir_shader *nir; /* First, lower the GLSL IR or Mesa IR to NIR */ @@ -88,8 +87,6 @@ brw_create_nir(struct brw_context *brw, } nir_validate_shader(nir); - (void)progress; - nir = brw_preprocess_nir(brw->screen->compiler, nir); if (stage == MESA_SHADER_FRAGMENT) { @@ -98,13 +95,16 @@ brw_create_nir(struct brw_context *brw, .fs_coord_pixel_center_integer = 1, .fs_coord_origin_upper_left = 1, }; - _mesa_add_state_reference(prog->Parameters, - (gl_state_index *) wpos_options.state_tokens); + bool progress = false; NIR_PASS(progress, nir, nir_lower_wpos_ytransform, &wpos_options); + if (progress) { + _mesa_add_state_reference(prog->Parameters, + (gl_state_index *) wpos_options.state_tokens); + } } - NIR_PASS(progress, nir, nir_lower_system_values); + NIR_PASS_V(nir, nir_lower_system_values); NIR_PASS_V(nir, brw_nir_lower_uniforms, is_scalar); return nir; -- cgit v1.2.3