summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-04-03r300: fix constants_remap_table memory leak related to the dummy shader pathPatrick Lerda1-0/+1
A last memory leak related to constants_remap_table is happening. This memory leak is triggered by two deqp-gles2 tests. For instance, this issue is triggered with "deqp-gles2 --deqp-case=dEQP-GLES2.functional.uniform_api.random.13": Direct leak of 336 byte(s) in 1 object(s) allocated from: #0 0x7f1b4a5de7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef) #1 0x7f1b401a2cdf in rc_remove_unused_constants ../src/gallium/drivers/r300/compiler/radeon_remove_constants.c:101 #2 0x7f1b40185386 in rc_run_compiler_passes ../src/gallium/drivers/r300/compiler/radeon_compiler.c:476 #3 0x7f1b40185625 in rc_run_compiler ../src/gallium/drivers/r300/compiler/radeon_compiler.c:498 #4 0x7f1b401c14d2 in r3xx_compile_fragment_program ../src/gallium/drivers/r300/compiler/r3xx_fragprog.c:172 #5 0x7f1b401b669a in r300_translate_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:516 #6 0x7f1b401baf73 in r300_pick_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:592 #7 0x7f1b40128db7 in r300_create_fs_state ../src/gallium/drivers/r300/r300_state.c:1071 #8 0x7f1b3e67799d in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1073 #9 0x7f1b3e680285 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1119 #10 0x7f1b3e6812fa in st_precompile_shader_variant ../src/mesa/state_tracker/st_program.c:1284 #11 0x7f1b3e6812fa in st_finalize_program ../src/mesa/state_tracker/st_program.c:1363 #12 0x7f1b3f13d501 in st_link_glsl_to_nir ../src/mesa/state_tracker/st_glsl_to_nir.cpp:754 #13 0x7f1b3f13d501 in st_link_shader ../src/mesa/state_tracker/st_glsl_to_nir.cpp:990 #14 0x7f1b3efeef75 in link_program ../src/mesa/main/shaderapi.c:1336 #15 0x7f1b3efeef75 in link_program_error ../src/mesa/main/shaderapi.c:1445 Fixes: 29df85788a7f ("r300: fix constants_remap_table memory leak") Signed-off-by: Patrick Lerda <patrick9876@free.fr> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28522>
2024-03-04r300: fix constants_remap_table memory leakPatrick Lerda1-0/+2
For instance, this issue is triggered with "piglit/bin/object-namespace-pollution glBitmap program -auto -fbo": Direct leak of 112 byte(s) in 7 object(s) allocated from: #0 0x7f472540e7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef) #1 0x7f471a9ce18f in rc_remove_unused_constants ../src/gallium/drivers/r300/compiler/radeon_remove_constants.c:101 #2 0x7f471a9b0836 in rc_run_compiler_passes ../src/gallium/drivers/r300/compiler/radeon_compiler.c:476 #3 0x7f471a9b0ad5 in rc_run_compiler ../src/gallium/drivers/r300/compiler/radeon_compiler.c:498 #4 0x7f471a9ec862 in r3xx_compile_fragment_program ../src/gallium/drivers/r300/compiler/r3xx_fragprog.c:172 #5 0x7f471a9e1ab2 in r300_translate_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:516 #6 0x7f471a9e6303 in r300_pick_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:591 #7 0x7f471a9544fe in r300_create_fs_state ../src/gallium/drivers/r300/r300_state.c:1073 #8 0x7f4718f2ebe5 in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1070 #9 0x7f4718f374b5 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1116 #10 0x7f4718f38273 in st_precompile_shader_variant ../src/mesa/state_tracker/st_program.c:1281 #11 0x7f4718f38273 in st_finalize_program ../src/mesa/state_tracker/st_program.c:1345 #12 0x7f4718f389e9 in st_program_string_notify ../src/mesa/state_tracker/st_program.c:1378 #13 0x7f47199d9f99 in set_program_string ../src/mesa/main/arbprogram.c:413 Fixes: 1c2c4ddbd1e9 ("r300g: copy the compiler from r300c") Signed-off-by: Patrick Lerda <patrick9876@free.fr> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27957>
2024-02-26r300: fix memory leaks when register allocation failsPatrick Lerda3-0/+3
For instance, this issue is triggered with "piglit/bin/ext_framebuffer_multisample-accuracy all_samples color depthstencil -auto -fbo": Direct leak of 1160 byte(s) in 1 object(s) allocated from: #0 0x7fbe8897d7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef) #1 0x7fbe7e7abfcc in rc_constants_copy ../src/gallium/drivers/r300/compiler/radeon_code.c:47 #2 0x7fbe7e7ec902 in r3xx_compile_fragment_program ../src/gallium/drivers/r300/compiler/r3xx_fragprog.c:174 #3 0x7fbe7e7e1b22 in r300_translate_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:516 #4 0x7fbe7e7e6373 in r300_pick_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:591 #5 0x7fbe7e75456e in r300_create_fs_state ../src/gallium/drivers/r300/r300_state.c:1073 #6 0x7fbe7cd2ebe5 in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1070 #7 0x7fbe7cd374b5 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1116 #8 0x7fbe7cd38273 in st_precompile_shader_variant ../src/mesa/state_tracker/st_program.c:1281 #9 0x7fbe7cd38273 in st_finalize_program ../src/mesa/state_tracker/st_program.c:1345 #10 0x7fbe7d798ca8 in st_link_glsl_to_nir ../src/mesa/state_tracker/st_glsl_to_nir.cpp:724 #11 0x7fbe7d798ca8 in st_link_shader ../src/mesa/state_tracker/st_glsl_to_nir.cpp:952 #12 0x7fbe7d6790d5 in link_program ../src/mesa/main/shaderapi.c:1336 #13 0x7fbe7d6790d5 in link_program_error ../src/mesa/main/shaderapi.c:1447 ... SUMMARY: AddressSanitizer: 2528456 byte(s) leaked in 1057 allocation(s). Fixes: 54f6e72b2715 ("r300: better register allocator for vertex shaders") Signed-off-by: Patrick Lerda <patrick9876@free.fr> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27792>
2022-03-03r300/compiler/tests: print regoff_t as size_tAlex Xu (Hello71)1-2/+3
fixes compilation on musl Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13949>
2014-10-14r300/compiler: remove useless checkDavid Heidelberger1-5/+2
This code is already in if (!variable->C->is_r500) so no need check twice. Reviewed-by: Tom Stellard <thomas.stellard@amd.com> Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
2013-12-09r300/compiler/tests: Fix line length check in test parserTom Stellard1-1/+3
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> CC: "9.2" "10.0" <mesa-stable@lists.freedesktop.org>
2013-12-09r300/compiler/tests: Fix segfaultTom Stellard1-6/+5
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> CC: "9.2" "10.0" <mesa-stable@lists.freedesktop.org>
2013-02-06r300/compiler: copy-propagate saturate mode when possibleMarek Olšák1-2/+19
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
2013-02-06r300/compiler: add support for saturate output modifier in r500 vertex shadersMarek Olšák2-10/+19
The GLSL compiler can simplify clamp(v,0,1) to saturate. The state tracker doesn't use it yet, but it will. Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
2012-11-16r300/compiler: Avoid generating MOV instructions for invalid IMM swizzles v2Tom Stellard1-4/+349
If an instruction reads from a constant register that contains immediates using an invalid swizzle, we can avoid generating MOV instructions to fix up the swizzle by loading the immediates into a different constant register that can be read using a valid swizzle. This only affects r300 and r400 cards. For example: CONST[1] = { -3.5000 3.5000 2.5000 1.5000 } MAD temp[4].xy, const[0].xy__, const[1].xz__, input[0].xy__; ========== Before this change would be lowered to: ========= CONST[1] = { -3.5000 3.5000 2.5000 1.5000 } MOV temp[0].x, const[1].x___; MOV temp[0].y, const[1]._z__; MAD temp[4].xy, const[0].xy__, temp[0].xy__, input[0].xy__; ========== After this change is lowered to: =============== CONST[1] = { -3.5000 3.5000 2.5000 1.5000 } CONST[2] = { 0.0000 -3.5000 2.5000 0.0000 } MAD temp[4].xy, const[0].xy__, const[2].yz__, input[0].xy__; ============================================================ This change reduces one of the Lightsmark shaders from 133 to 91 instructions. v2: - Fix crash caused by swizzles with only inline constants.
2012-09-19r300/compiler: Use precomputed q values in the register allocatorTom Stellard1-1/+69
2012-09-19r300/compiler: Don't create register classes for inputsTom Stellard1-14/+1
2012-08-26r300/compiler: Use variable lists in the rename_regs passTom Stellard1-17/+14
2012-04-14r300/compiler: Exit immediately from rc_vert_fc() if there is an errorTom Stellard1-0/+4
This way we correctly report "Too many temporaries" errors. https://bugs.freedesktop.org/show_bug.cgi?id=48680 Note: This is a candidate for the stable branches.
2012-04-14r300/compiler: Copy all instruction attributes during local transfomsTom Stellard1-31/+42
Instruction attributes like WriteALUResult and ALUResultCompare were being discarded during the some of the local transformations. This fixes the following piglit tests: glsl1-inequality (vec2, pass) loopfunc fs-any-bvec2-using-if fs-op-ne-bvec2-bvec2-using-if fs-op-ne-ivec2-ivec2-using-if fs-op-ne-mat2-mat2-using-if fs-op-ne-vec2-vec2-using-if fs-op-ne-mat2x3-mat2x3-using-if fs-op-ne-mat2x4-mat2x4-using-if https://bugs.freedesktop.org/show_bug.cgi?id=45921 NOTE: This is a candidate for the stable branches.
2012-04-13r300/compiler: Fix nested flow control in r500 vertex shadersTom Stellard11-178/+438
2012-04-13r300/compiler: Clear loop registers in vertex shaders w/o loopsTom Stellard2-16/+13
The loop registers weren't being cleared, so any shader that was executed after a shader containing loops was at risk of having a loop randomly inserted into it. This fixes over one hundred piglit tests, although these test only failed during full piglit runs and would pass if run individually. The exact number of piglit tests that this patch fixes will vary depending on the version of piglit and the order the tests are run. NOTE: This is a candidate for the stable branches.
2012-03-04r300/compiler: Add support for inline literalsTom Stellard12-9/+192
On R500 chips, shader instructions can take 7-bit (3-bit mantissa, 4-bit exponent) floating point values as inputs in place of registers.
2012-02-26r300/compiler: Schedule KIL instructions before output writesTom Stellard1-0/+4
2012-02-26r300/compiler: Use the smart scheduler for r300 cardsTom Stellard1-73/+54
2012-02-26r300/compiler: Fix bug when lowering KILP on r300 cardsTom Stellard1-10/+54
KILP instruction inside IF blocks were being lowered to an unconditional KIL. Since r300 doesn't support branching, when the IF's were lowered to conditional moves, the KIL would always be executed. This is not a problem with the mesa state tracker, because the GLSL compiler handles lowering IF's, but this bug was appearing in the VDPAU state tracker, which does not use the GLSL compiler. Note: This is a candidate for the stable branches.
2012-01-05r300/compiler: fix buffer underflow when setting SEM_WAIT on last instructionMarek Olšák2-4/+4
Do it after we check whether inst_end != -1. Also move the code structure at the beginning of r300_fragment_shader_code to detect underflows easily with valgrind.
2011-10-27r300/compiler: Fix scheduler bug causing texture corruptionTom Stellard1-6/+35
We weren't setting TEX_SEM_WAIT on instructions that read the value of a TEX instruction and also wrote the same register as the TEX instruction. This is the sequence we were miscompiling: 1: TEX temp[0], input[2].xy__, 2D[0] ... 16: src0.xyz = temp[22], src1.xyz = temp[0], src2.xyz = temp[19] MAD temp[0].xyz, src0.xxx, src1.xyz, src2.xxx https://bugs.freedesktop.org/show_bug.cgi?id=42090
2011-10-16r300/compiler: Try to eliminate REPL_ALPHA instructionsTom Stellard1-33/+57
Scalar instruction that need to write to the xyz components of a register must reserve the RGB instruction slot for a REPL_ALPHA instruction. With this commit, the scheduler will attempt to free the RGB slot by moving the write to the w component of a register.
2011-10-16r300/compiler: More agressive RGB to Alpha conversionsTom Stellard1-8/+10
2011-10-16r300/compiler: Only convert RGB->Alpha when optimizations are enabledTom Stellard2-1/+8
2011-10-14r300/compiler: Enable reg rename pass on r500 and run it before optimizationsTom Stellard1-4/+1
The scheduler and the register allocator are now smart enough to handle it.
2011-10-14r300/compiler: Implement the texture semaphoreTom Stellard6-49/+308
The texture semaphore allows for prefetching of texture data. On my RV515, this increases the FPS of Lightsmark by 33% (This is with the reg_rename pass enabled, which is enabled in the next commit). There is a new env variable now called RADEON_TEX_GROUP, which allows you to specify the maximum number of texture lookups to do at once. The default is 8, but different values could produce better results for various application / card combinations.
2011-10-14r300/compiler: Don't pair output writes with GPR writes in the schedulerTom Stellard1-0/+7
2011-10-14r300/compiler: Prevent regalloc from creating non-native swizzlesTom Stellard1-16/+63
2011-10-14r300/compiler: Allow merged instructions to be scheduled on demandTom Stellard1-50/+99
We no longer emit full instructions immediately after they have been merged. Instead merged instructions are added to the ready list and the scheduler can commit them whenever it wants.
2011-10-02r300/compiler: Fix error in OMOD optimizationTom Stellard1-0/+16
Classic compiler mistake. In the example below, the OMOD optimization was combining instructions 4 and 10, but since there was an instruction (#8) in between them that wrote to the same registers as instruction 10, instruction 11 was reading the wrong value. Example of the mistake: Before OMOD: 4: MAD temp[0].y, temp[3]._y__, const[0]._x__, const[0]._y__; ... 8: ADD temp[2].x, temp[1].x___, -temp[4].x___; ... 10: MUL temp[2].x, const[1].y___, temp[0].y___; 11: FRC temp[5].x, temp[2].x___; After OMOD: 4: MAD temp[2].x / 8, temp[3]._y__, const[0]._x__, const[0]._y__; ... 8: ADD temp[2].x, temp[1].x___, -temp[4].x___; ... 11: FRC temp[5].x, temp[2].x___; https://bugs.freedesktop.org/show_bug.cgi?id=41367
2011-10-02r300/compiler: Rewrite source swizzles when using OMODTom Stellard1-1/+6
2011-10-02r300/compiler: Fix rc_normal_rewrite_writemask()Tom Stellard1-5/+4
This function had not been updated to use conversion swizzles.
2011-10-02r300/compiler: Use consistent src swizzles for transcendent instructionsTom Stellard5-6/+33
Source swizzles for transcendent instructions were being stored in the X channel regardless of what channel the instruction was writing. This was causing problems for some helper functions that were expecting source swizzles to occupy channels corresponding to the instruction's writemask. This commit makes transcendent instructions follow the same convention as normal instructions for representing source swizzles. Previous behavior: LG2 temp[0].y, input[0].x___; Current behavior: LG2 temp[0].y, input[0]._x__;
2011-09-18r300/compiler: Fix regalloc for values with multiple writersTom Stellard1-3/+6
https://bugs.freedesktop.org/show_bug.cgi?id=40062 https://bugs.freedesktop.org/show_bug.cgi?id=36939 Note: This is a candidate for the 7.11 branch.
2011-09-16r300/compiler: Add support for the output modifier (OMOD)Tom Stellard16-25/+310
2011-09-16r300/compiler: Move some helper functions to radeon_compiler_util.cTom Stellard3-33/+68
2011-09-16r300/compiler: Don't unroll loops that conditionally increment the counterTom Stellard1-2/+14
2011-09-10r300/compiler: Implement ROUNDTom Stellard4-1/+56
According to the GLSL spec, the implementor can decide which way to round when the fraction is .5. The r300 compiler will round down.
2011-07-25r300/compiler: simplify code in peephole_add_presub_addTobias Droste1-17/+18
Signed-off-by: Tobias Droste <tdroste@gmx.de> Signed-off-by: Marek Olšák <maraeo@gmail.com>
2011-07-15r300/compiler: remove an unused-but-set variable and simplify the codeMarek Olšák1-9/+6
2011-07-15r300/compiler: fix a warning that a variable may be uninitializedMarek Olšák1-1/+1
2011-05-17r300/compiler: Fix bug in rc_get_variables()Tom Stellard1-45/+13
Variables that write to the same source select need to pe paired together otherwise the register allocator might fail. https://bugs.freedesktop.org/show_bug.cgi?id=36753
2011-05-14r300/compiler: Use ALU Result for IF conditionalsTom Stellard6-20/+212
This saves one instruction per IF.
2011-05-11r300/compiler: Fix bug in rc_get_variables()Tom Stellard1-7/+11
Variables that share readers were not always being linked together. https://bugs.freedesktop.org/show_bug.cgi?id=36939
2011-05-11r300/compiler: Limit instructions to 3 source selectsTom Stellard4-39/+104
Some presubtract conversions were generating more than 3 source selects. https://bugs.freedesktop.org/show_bug.cgi?id=36527 Note: This is a candidate for the 7.10 branch.
2011-05-11r300/compiler: Add simple unit test frameworkTom Stellard7-0/+579
Plus three tests for rc_inst_can_use_presub()
2011-05-09r300/compiler: align memory allocations to 8-bytesMatt Turner1-1/+1
Eliminates unaligned accesses on strict architectures. Spotted by Jay Estabrook. Signed-off-by: Matt Turner <mattst88@gmail.com> NOTE: This is a candidate for the 7.10 branch.
2011-05-09r300c: Fix up for register allocator rewrite.Michel Dänzer2-0/+2
Was broken by commit fe622bac0c1b5b9f2a9fcf9f35b51232a06bea42 ('r300/compiler: Rewrite register allocator').