From aa036b8bcbe35fc5d2b5d17f12c6f4893c87987f Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 9 Jan 2019 15:47:56 +0100 Subject: [PATCH] shader: double size of offbuf and bias This gets rid of some warnings about buffers being too small. Signed-off-by: Dave Airlie --- src/vrend_shader.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index ea6872d..2a8e8d3 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -1916,7 +1916,7 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D_ARRAY: - snprintf(offbuf, 25, ", int(%d)", imd->val[inst->TexOffsets[0].SwizzleX].i); + snprintf(offbuf, 256, ", int(%d)", imd->val[inst->TexOffsets[0].SwizzleX].i); break; case TGSI_TEXTURE_RECT: case TGSI_TEXTURE_SHADOWRECT: @@ -1924,10 +1924,10 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOW2D_ARRAY: - snprintf(offbuf, 25, ", ivec2(%d, %d)", imd->val[inst->TexOffsets[0].SwizzleX].i, imd->val[inst->TexOffsets[0].SwizzleY].i); + snprintf(offbuf, 256, ", ivec2(%d, %d)", imd->val[inst->TexOffsets[0].SwizzleX].i, imd->val[inst->TexOffsets[0].SwizzleY].i); break; case TGSI_TEXTURE_3D: - snprintf(offbuf, 25, ", ivec3(%d, %d, %d)", imd->val[inst->TexOffsets[0].SwizzleX].i, imd->val[inst->TexOffsets[0].SwizzleY].i, + snprintf(offbuf, 256, ", ivec3(%d, %d, %d)", imd->val[inst->TexOffsets[0].SwizzleX].i, imd->val[inst->TexOffsets[0].SwizzleY].i, imd->val[inst->TexOffsets[0].SwizzleZ].i); break; default: @@ -1942,7 +1942,7 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D_ARRAY: - snprintf(offbuf, 120, ", int(floatBitsToInt(temp%d[%d].%c))", + snprintf(offbuf, 256, ", int(floatBitsToInt(temp%d[%d].%c))", range->first, idx, get_swiz_char(inst->TexOffsets[0].SwizzleX)); break; @@ -1952,14 +1952,14 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOW2D_ARRAY: - snprintf(offbuf, 120, ", ivec2(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c))", + snprintf(offbuf, 256, ", ivec2(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c))", range->first, idx, get_swiz_char(inst->TexOffsets[0].SwizzleX), range->first, idx, get_swiz_char(inst->TexOffsets[0].SwizzleY)); break; case TGSI_TEXTURE_3D: - snprintf(offbuf, 120, ", ivec3(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c)", + snprintf(offbuf, 256, ", ivec3(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c)", range->first, idx, get_swiz_char(inst->TexOffsets[0].SwizzleX), range->first, idx, @@ -1981,7 +1981,7 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D_ARRAY: - snprintf(offbuf, 120, ", int(floatBitsToInt(%s.%c))", + snprintf(offbuf, 256, ", int(floatBitsToInt(%s.%c))", ctx->inputs[j].glsl_name, get_swiz_char(inst->TexOffsets[0].SwizzleX)); break; @@ -1991,14 +1991,14 @@ static bool fill_offset_buffer(struct dump_ctx *ctx, case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOW2D_ARRAY: - snprintf(offbuf, 120, ", ivec2(floatBitsToInt(%s.%c), floatBitsToInt(%s.%c))", + snprintf(offbuf, 256, ", ivec2(floatBitsToInt(%s.%c), floatBitsToInt(%s.%c))", ctx->inputs[j].glsl_name, get_swiz_char(inst->TexOffsets[0].SwizzleX), ctx->inputs[j].glsl_name, get_swiz_char(inst->TexOffsets[0].SwizzleY)); break; case TGSI_TEXTURE_3D: - snprintf(offbuf, 120, ", ivec3(floatBitsToInt(%s.%c), floatBitsToInt(%s.%c), floatBitsToInt(%s.%c)", + snprintf(offbuf, 256, ", ivec3(floatBitsToInt(%s.%c), floatBitsToInt(%s.%c), floatBitsToInt(%s.%c)", ctx->inputs[j].glsl_name, get_swiz_char(inst->TexOffsets[0].SwizzleX), ctx->inputs[j].glsl_name, @@ -2028,8 +2028,8 @@ static void translate_tex(struct dump_ctx *ctx, unsigned twm = TGSI_WRITEMASK_NONE, gwm = TGSI_WRITEMASK_NONE; enum vrend_type_qualifier dtypeprefix = TYPE_CONVERSION_NONE; bool is_shad = false; - char offbuf[128] = {0}; - char bias[128] = {0}; + char offbuf[256] = {0}; + char bias[256] = {0}; int sampler_index; const char *tex_ext; @@ -2219,7 +2219,7 @@ static void translate_tex(struct dump_ctx *ctx, } if (inst->Instruction.Opcode == TGSI_OPCODE_TXL || inst->Instruction.Opcode == TGSI_OPCODE_TXL2 || inst->Instruction.Opcode == TGSI_OPCODE_TXD || (inst->Instruction.Opcode == TGSI_OPCODE_TG4 && is_shad)) { - char tmp[128]; + char tmp[256]; strcpy(tmp, offbuf); strcpy(offbuf, bias); strcpy(bias, tmp);