[Mesa-dev] [PATCH] r600g: mask unused source components for SAMPLE
Vadim Girlin
vadimgirlin at gmail.com
Sat Apr 27 06:28:00 PDT 2013
On 04/27/2013 02:53 PM, Marek Olšák wrote:
> Reviewed-by: Marek Olšák <maraeo at gmail.com>
>
> This looks incomplete though. There are a lot more texture opcodes and
> texture targets which could be handled there as well.
Yes, this patch handles most trivial cases, though I think they are most
frequently used cases as well. Also it covers all known to me cases
where it caused problems for optimization.
I'll look into other cases later - they are more complex, so there is
more chances to break something (I'm not sure about piglit coverage for
this), and IIRC many of them either actually use all components of
source register or modify the swizzles in such a way that there is no
unused components, e.g. xyzz with SHADOW2D/SAMPLE_C.
Vadim
> Marek
>
> On Sat, Apr 27, 2013 at 10:29 AM, Vadim Girlin <vadimgirlin at gmail.com> wrote:
>> This results in more clean shader code and may improve the quality of
>> optimized code produced by r600-sb due to eliminated false dependencies
>> in some cases.
>>
>> Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
>> ---
>>
>> There are no piglit regressions with this patch on evergreen.
>>
>> I consider this as a prerequisite for r600-sb branch, it fixes the performance
>> regression with optimized shaders uncovered by some recent changes to tgsi
>> and/or r600 codegen.
>>
>> If there are no objections or new suggestions, is it OK to push the latest
>> version of r600-sb-2 branch [1] that includes this patch?
>>
>> The changes in the branch after the recent mail include 3 additional patches
>> to improve handling of some corner cases (they fix some issues reported on IRC),
>> also they add switching to unoptimized code in case of possible internal
>> optimization problems, and new option "sbnofallback" for R600_DEBUG to disable
>> such fallback.
>>
>> Vadim
>>
>> [1] http://cgit.freedesktop.org/~vadimg/mesa/log/?h=r600-sb-2
>>
>> src/gallium/drivers/r600/r600_shader.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>>
>> diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
>> index 0204f80..aa88252 100644
>> --- a/src/gallium/drivers/r600/r600_shader.c
>> +++ b/src/gallium/drivers/r600/r600_shader.c
>> @@ -4739,6 +4739,26 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
>> /* the array index is read from Z */
>> tex.coord_type_z = 0;
>>
>> + /* mask unused source components */
>> + if (opcode == FETCH_OP_SAMPLE) {
>> + switch (inst->Texture.Texture) {
>> + case TGSI_TEXTURE_2D:
>> + case TGSI_TEXTURE_RECT:
>> + tex.src_sel_z = 7;
>> + tex.src_sel_w = 7;
>> + break;
>> + case TGSI_TEXTURE_1D_ARRAY:
>> + tex.src_sel_y = 7;
>> + tex.src_sel_w = 7;
>> + break;
>> + case TGSI_TEXTURE_1D:
>> + tex.src_sel_y = 7;
>> + tex.src_sel_z = 7;
>> + tex.src_sel_w = 7;
>> + break;
>> + }
>> + }
>> +
>> r = r600_bytecode_add_tex(ctx->bc, &tex);
>> if (r)
>> return r;
>> --
>> 1.8.2.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list