[Mesa-dev] [PATCH 3/3] r300g/compiler: Prevent the regalloc from swizzling texture operands v2
From: Tom Stellard thomas.stell...@amd.com https://bugs.freedesktop.org/show_bug.cgi?id=63520 NOTE: This is a candidate for the stable branches. --- src/gallium/drivers/r300/Makefile.am |1 + .../drivers/r300/compiler/radeon_pair_regalloc.c |8 ++ .../r300/compiler/tests/r300_compiler_tests.c |1 + .../tests/radeon_compiler_regalloc_tests.c | 99 .../compiler/tests/regalloc_tex_1d_swizzle.test| 15 +++ 5 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c create mode 100644 src/gallium/drivers/r300/compiler/tests/regalloc_tex_1d_swizzle.test diff --git a/src/gallium/drivers/r300/Makefile.am b/src/gallium/drivers/r300/Makefile.am index f82b8e9..ab8b4e8 100644 --- a/src/gallium/drivers/r300/Makefile.am +++ b/src/gallium/drivers/r300/Makefile.am @@ -24,6 +24,7 @@ r300_compiler_tests_CPPFLAGS = \ r300_compiler_tests_SOURCES = \ $(testdir)/r300_compiler_tests.c \ $(testdir)/radeon_compiler_optimize_tests.c \ + $(testdir)/radeon_compiler_regalloc_tests.c \ $(testdir)/radeon_compiler_util_tests.c \ $(testdir)/rc_test_helpers.c \ $(testdir)/unit_test.c diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c index 6442e0d..1970a34 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c @@ -383,6 +383,14 @@ static enum rc_reg_class variable_get_class( RC_INSTRUCTION_PAIR ) { old_swizzle = r.U.P.Arg-Swizzle; } else { + /* Source operands of TEX +* instructions can't be +* swizzle on r300/r400 GPUs. +*/ + if (!variable-C-is_r500) { + can_change_writemask = 0; + break; + } old_swizzle = r.U.I.Src-Swizzle; } new_swizzle = rc_adjust_channels( diff --git a/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c b/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c index cc4725a..0406ae6 100644 --- a/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c +++ b/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c @@ -33,6 +33,7 @@ int main(int argc, char ** argv) { unsigned pass = 1; pass = radeon_compiler_optimize_run_tests(); + pass = radeon_compiler_regalloc_run_tests(); pass = radeon_compiler_util_run_tests(); if (pass) { diff --git a/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c b/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c new file mode 100644 index 000..eeb6b07 --- /dev/null +++ b/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c @@ -0,0 +1,99 @@ +/* + * Copyright 2013 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Author: Tom Stellard thomas.stell...@amd.com + */ + +#include radeon_program_pair.h + +#include r300_compiler_tests.h +#include rc_test_helpers.h +#include unit_test.h + +static void dummy_allocate_hw_inputs( + struct r300_fragment_program_compiler * c, + void (*allocate)(void * data, unsigned input, unsigned hwreg), +
Re: [Mesa-dev] [PATCH 3/3] r300g/compiler: Prevent the regalloc from swizzling texture operands v2
Reviewed-by: Marek Olšák mar...@gmail.com Marek On Thu, Jun 27, 2013 at 6:57 AM, Tom Stellard t...@stellard.net wrote: From: Tom Stellard thomas.stell...@amd.com https://bugs.freedesktop.org/show_bug.cgi?id=63520 NOTE: This is a candidate for the stable branches. --- src/gallium/drivers/r300/Makefile.am |1 + .../drivers/r300/compiler/radeon_pair_regalloc.c |8 ++ .../r300/compiler/tests/r300_compiler_tests.c |1 + .../tests/radeon_compiler_regalloc_tests.c | 99 .../compiler/tests/regalloc_tex_1d_swizzle.test| 15 +++ 5 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c create mode 100644 src/gallium/drivers/r300/compiler/tests/regalloc_tex_1d_swizzle.test diff --git a/src/gallium/drivers/r300/Makefile.am b/src/gallium/drivers/r300/Makefile.am index f82b8e9..ab8b4e8 100644 --- a/src/gallium/drivers/r300/Makefile.am +++ b/src/gallium/drivers/r300/Makefile.am @@ -24,6 +24,7 @@ r300_compiler_tests_CPPFLAGS = \ r300_compiler_tests_SOURCES = \ $(testdir)/r300_compiler_tests.c \ $(testdir)/radeon_compiler_optimize_tests.c \ + $(testdir)/radeon_compiler_regalloc_tests.c \ $(testdir)/radeon_compiler_util_tests.c \ $(testdir)/rc_test_helpers.c \ $(testdir)/unit_test.c diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c index 6442e0d..1970a34 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c @@ -383,6 +383,14 @@ static enum rc_reg_class variable_get_class( RC_INSTRUCTION_PAIR ) { old_swizzle = r.U.P.Arg-Swizzle; } else { + /* Source operands of TEX +* instructions can't be +* swizzle on r300/r400 GPUs. +*/ + if (!variable-C-is_r500) { + can_change_writemask = 0; + break; + } old_swizzle = r.U.I.Src-Swizzle; } new_swizzle = rc_adjust_channels( diff --git a/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c b/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c index cc4725a..0406ae6 100644 --- a/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c +++ b/src/gallium/drivers/r300/compiler/tests/r300_compiler_tests.c @@ -33,6 +33,7 @@ int main(int argc, char ** argv) { unsigned pass = 1; pass = radeon_compiler_optimize_run_tests(); + pass = radeon_compiler_regalloc_run_tests(); pass = radeon_compiler_util_run_tests(); if (pass) { diff --git a/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c b/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c new file mode 100644 index 000..eeb6b07 --- /dev/null +++ b/src/gallium/drivers/r300/compiler/tests/radeon_compiler_regalloc_tests.c @@ -0,0 +1,99 @@ +/* + * Copyright 2013 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Author: Tom Stellard thomas.stell...@amd.com + */ + +#include radeon_program_pair.h + +#include r300_compiler_tests.h