Module: Mesa Branch: staging/20.2 Commit: 6b823dfc0168eecc6c29ee2186a043391f44e4c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b823dfc0168eecc6c29ee2186a043391f44e4c8
Author: Rhys Perry <[email protected]> Date: Thu Aug 6 14:16:08 2020 +0100 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 <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2768 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6205> (cherry picked from commit 6e70508151823ce63e0976b4fa56e4d847a3c9b8) --- .pick_status.json | 2 +- src/amd/compiler/aco_instruction_selection_setup.cpp | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d90e547d635..f05868f5feb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -202,7 +202,7 @@ "description": "aco: set constant_data_offset correctly in the case of merged shaders", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, 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); _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
