[virglrenderer-devel] [PATCHv3] shader: improve TXQ translation

Dave Airlie airlied at gmail.com
Mon Feb 29 00:12:18 UTC 2016


On 29 February 2016 at 10:02, Dave Airlie <airlied at gmail.com> wrote:
> On 29 February 2016 at 09:42,  <marcandre.lureau at redhat.com> wrote:
>> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>>
>> TXQ may query levels and size.
>>
>> Fixes all piglit texturesize tests and others.
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
>> ---
>>  src/vrend_shader.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
>>  1 file changed, 46 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/vrend_shader.c b/src/vrend_shader.c
>> index 885b384..835618d 100644
>> --- a/src/vrend_shader.c
>> +++ b/src/vrend_shader.c
>> @@ -25,6 +25,7 @@
>>  #include "tgsi/tgsi_info.h"
>>  #include "tgsi/tgsi_iterate.h"
>>  #include "util/u_memory.h"
>> +#include "util/u_math.h"
>>  #include <string.h>
>>  #include <stdio.h>
>>  #include <math.h>
>> @@ -966,7 +967,7 @@ static int translate_tex(struct dump_ctx *ctx,
>>                           const char *dstconv,
>>                           const char *dtypeprefix)
>>  {
>> -   const char *twm, *gwm = NULL, *txfi;
>> +   const char *twm = "", *gwm = NULL, *txfi;
>>     bool is_shad = false;
>>     char buf[512];
>>     char offbuf[128] = {0};
>> @@ -1033,13 +1034,52 @@ static int translate_tex(struct dump_ctx *ctx,
>>
>>        /* need to emit a textureQueryLevels */
>>        if (inst->Dst[0].Register.WriteMask & 0x8) {
>> -         ctx->uses_txq_levels = true;
>> -         snprintf(buf, 255, "%s = %s(%s(textureQueryLevels(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index]);
>> -         return emit_buf(ctx, buf);
>> -      } else {
>> -         snprintf(buf, 255, "%s = %s(%s(textureSize(%s%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index], bias);
>> +
>> +         if (inst->Texture.Texture != TGSI_TEXTURE_BUFFER &&
>> +             inst->Texture.Texture != TGSI_TEXTURE_RECT &&
>> +             inst->Texture.Texture != TGSI_TEXTURE_2D_MSAA &&
>> +             inst->Texture.Texture != TGSI_TEXTURE_2D_ARRAY_MSAA) {
>> +            ctx->uses_txq_levels = true;
>> +            if (inst->Dst[0].Register.WriteMask & 0x7)
>> +               twm = ".w";
>> +            snprintf(buf, 255, "%s%s = %s(textureQueryLevels(%s));\n", dsts[0], twm, dtypeprefix, srcs[sampler_index]);
>> +            emit_buf(ctx, buf);
>> +         }
>> +
>
> All the code below with & 0x7 could be pulled out a level,
> and the two if & 0x7 levels collapsed into one section.
>

Actually it can't, I'm doing something dumb here, I might try and clean it
up further. okay with this patch stuff passes for me.

> also we should be using the EMIT_BUF_WITH_RET macro in both places.

so really just this is all I'm going to change.
Dave.


More information about the virglrenderer-devel mailing list