mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-24 03:00:30 +01:00
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 <robclark@freedesktop.org>
This commit is contained in:
parent
310fd5839c
commit
a53fe2221c
4 changed files with 14 additions and 12 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ static const struct debug_named_value debug_options[] = {
|
|||
{"dscis", FD_DBG_DSCIS, "Disable scissor optimization"},
|
||||
{"direct", FD_DBG_DIRECT, "Force inline (SS_DIRECT) state loads"},
|
||||
{"dbypass", FD_DBG_DBYPASS,"Disable GMEM bypass"},
|
||||
{"fraghalf", FD_DBG_FRAGHALF, "Use half-precision in fragment shader"},
|
||||
DEBUG_NAMED_VALUE_END
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
|
|||
#define FD_DBG_DSCIS 0x10
|
||||
#define FD_DBG_DIRECT 0x20
|
||||
#define FD_DBG_DBYPASS 0x40
|
||||
#define FD_DBG_FRAGHALF 0x80
|
||||
|
||||
extern int fd_mesa_debug;
|
||||
|
||||
#define DBG(fmt, ...) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue