summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/a3xx
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2013-10-31 09:59:49 -0400
committerRob Clark <[email protected]>2013-11-01 20:19:42 -0400
commita53fe2221c3d48b3b1c8bdf4c2da33fe91ad7cda (patch)
tree4c0f7114b174a80b9bd7b10aeb3a922df8ab8956 /src/gallium/drivers/freedreno/a3xx
parent310fd5839cd5f221680de8a80ae97e099e0116b7 (diff)
freedreno/a3xx/compiler: highp frag shader
Fixes use of full-precision in fragment shader (ie. don't clobber r0.x since that can be used by future bary instructions for varying fetch). And makes use of full-precision the default in fragment shader (but can be overriden via FD_MESA_DEBUG=fraghalf). Seems like half precision is often not enough for texture coordinates. The blob compiler is clever enough to keep texture coords in full precision registers while using half precision for everything else. But we aren't quite that clever yet, so better to default to full precision. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a3xx')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_compiler.c14
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_program.c9
2 files changed, 11 insertions, 12 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
index 5e94a6f397a..760fb7de2ed 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
@@ -153,7 +153,7 @@ static unsigned
compile_init(struct fd3_compile_context *ctx, struct fd3_shader_stateobj *so,
const struct tgsi_token *tokens)
{
- unsigned ret;
+ unsigned ret, base = 0;
ctx->tokens = tokens;
ctx->ir = so->ir;
@@ -175,11 +175,17 @@ compile_init(struct fd3_compile_context *ctx, struct fd3_shader_stateobj *so,
ctx->base_reg[TGSI_FILE_IMMEDIATE] =
ctx->info.file_max[TGSI_FILE_CONSTANT] + 1;
+ /* if full precision and fragment shader, don't clobber
+ * r0.x w/ bary fetch:
+ */
+ if ((so->type == SHADER_FRAGMENT) && !so->half_precision)
+ base = 1;
+
/* Temporaries after outputs after inputs: */
- ctx->base_reg[TGSI_FILE_INPUT] = 0;
- ctx->base_reg[TGSI_FILE_OUTPUT] =
+ ctx->base_reg[TGSI_FILE_INPUT] = base;
+ ctx->base_reg[TGSI_FILE_OUTPUT] = base +
ctx->info.file_max[TGSI_FILE_INPUT] + 1;
- ctx->base_reg[TGSI_FILE_TEMPORARY] =
+ ctx->base_reg[TGSI_FILE_TEMPORARY] = base +
ctx->info.file_max[TGSI_FILE_INPUT] + 1 +
ctx->info.file_max[TGSI_FILE_OUTPUT] + 1;
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c
index b0eec6e66d3..7bb96faa899 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c
@@ -98,15 +98,8 @@ create_shader(struct pipe_context *pctx, const struct pipe_shader_state *cso,
tgsi_dump(cso->tokens, 0);
}
- if (type == SHADER_FRAGMENT) {
- /* we seem to get wrong colors (maybe swap/endianess or hw issue?)
- * with full precision color reg. And blob driver only seems to
- * use half precision register for color output (that I can find
- * so far), even with highp precision. So for force half precision
- * for frag shader:
- */
+ if ((type == SHADER_FRAGMENT) && (fd_mesa_debug & FD_DBG_FRAGHALF))
so->half_precision = true;
- }
ret = fd3_compile_shader(so, cso->tokens);
if (ret) {