From 6e70508151823ce63e0976b4fa56e4d847a3c9b8 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 6 Aug 2020 14:16:08 +0100 Subject: [PATCH] aco: set constant_data_offset correctly in the case of merged shaders setup_nir() is done for all shaders before any of them are selected, so constant_data_offset could be incorrect for the first shader. Fixes incorrect geometry in Mafia III and Max Payne 3. Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2768 Part-of: --- .../aco_instruction_selection_setup.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index 117918e0b48..4f76289be45 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -936,6 +936,14 @@ void init_context(isel_context *ctx, nir_shader *shader) ctx->allocated.reset(allocated.release()); ctx->cf_info.nir_to_aco.reset(nir_to_aco.release()); + + /* align and copy constant data */ + while (ctx->program->constant_data.size() % 4u) + ctx->program->constant_data.push_back(0); + ctx->constant_data_offset = ctx->program->constant_data.size(); + ctx->program->constant_data.insert(ctx->program->constant_data.end(), + (uint8_t*)shader->constant_data, + (uint8_t*)shader->constant_data + shader->constant_data_size); } Pseudo_instruction *add_startpgm(struct isel_context *ctx) @@ -1304,16 +1312,6 @@ lower_bit_size_callback(const nir_alu_instr *alu, void *_) void setup_nir(isel_context *ctx, nir_shader *nir) { - Program *program = ctx->program; - - /* align and copy constant data */ - while (program->constant_data.size() % 4u) - program->constant_data.push_back(0); - ctx->constant_data_offset = program->constant_data.size(); - program->constant_data.insert(program->constant_data.end(), - (uint8_t*)nir->constant_data, - (uint8_t*)nir->constant_data + nir->constant_data_size); - /* the variable setup has to be done before lower_io / CSE */ setup_variables(ctx, nir); -- 2.30.2