Hi Jason, On Wed, 2016-11-16 at 11:31 -0800, Jason Ekstrand wrote: > The lower_input_attachments pass that we're about to add will > generate > additional uses of system values and we want those to be reflected in > gather_info. > --- > src/intel/vulkan/anv_pipeline.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/intel/vulkan/anv_pipeline.c > b/src/intel/vulkan/anv_pipeline.c > index bdac404..c251463 100644 > --- a/src/intel/vulkan/anv_pipeline.c > +++ b/src/intel/vulkan/anv_pipeline.c > @@ -166,8 +166,6 @@ anv_shader_compile_to_nir(struct anv_device > *device, > > nir = brw_preprocess_nir(compiler, nir); > > - nir_shader_gather_info(nir, entry_point->impl); > - > nir_variable_mode indirect_mask = 0; > if (compiler->glsl_compiler_options[stage].EmitNoIndirectInput) > indirect_mask |= nir_var_shader_in; > @@ -369,6 +367,8 @@ anv_pipeline_compile(struct anv_pipeline > *pipeline, > */ > nir->num_uniforms = prog_data->nr_params * 4; > > + nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); > +
This breaks a ton of Vulkan CTS tests due to memory corruption issues. The problem is that we need to call this before we compute the number of parameters (which is done right above this). Otherwise we end up with an incorrect number of parameters and that leads to out-of-bounds writes in some places. The attached patch (which applies on top of the series) fixes the regressions. You probably want to merge it in this patch and the next. Iago > return nir; > } >
From ec586f02b408da68a26798e66c285cf6370a60e0 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga <ito...@atlantix-intelskylake.local.igalia.com> Date: Thu, 17 Nov 2016 13:26:07 +0100 Subject: [PATCH] anv/pipeline: call nir_shader_gather_info() before we compute num_params Because gather info updates the number of images that we use to compute the number of parameters. Fixes memory corruption due to out-of-bounds writes because of incorrect param count. --- src/intel/vulkan/anv_pipeline.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 77c2ba7..0a3adc9 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -316,6 +316,11 @@ anv_pipeline_compile(struct anv_pipeline *pipeline, anv_nir_lower_push_constants(nir); + if (stage == MESA_SHADER_FRAGMENT) + anv_nir_lower_input_attachments(nir); + + nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); + /* Figure out the number of parameters */ prog_data->nr_params = 0; @@ -364,9 +369,6 @@ anv_pipeline_compile(struct anv_pipeline *pipeline, /* Set up dynamic offsets */ anv_nir_apply_dynamic_offsets(pipeline, nir, prog_data); - if (stage == MESA_SHADER_FRAGMENT) - anv_nir_lower_input_attachments(nir); - /* Apply the actual pipeline layout to UBOs, SSBOs, and textures */ if (pipeline->layout) anv_nir_apply_pipeline_layout(pipeline, nir, prog_data, map); @@ -376,8 +378,6 @@ anv_pipeline_compile(struct anv_pipeline *pipeline, */ nir->num_uniforms = prog_data->nr_params * 4; - nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); - return nir; } -- 2.8.1
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev