diff options
author | Rob Clark <robclark@freedesktop.org> | 2014-09-29 10:44:46 -0400 |
---|---|---|
committer | Rob Clark <robclark@freedesktop.org> | 2014-09-29 18:30:43 -0400 |
commit | 7cdd4679943a72b97aad1c584da4bcb0e1f003f2 (patch) | |
tree | bdae118969b3ffab4d27a8c40787e9ebf00d3806 /src/gallium/drivers/freedreno/ir3 | |
parent | 3541705816f18bce0f9f6794e9b1c409a81ed98e (diff) |
freedreno/a3xx: add support to emulate GL_CLAMP
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.h | 15 |
4 files changed, 51 insertions, 2 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index c2d4942b66d..07b57b8d049 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -135,7 +135,7 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, { unsigned ret; struct tgsi_shader_info *info = &ctx->info; - const struct fd_lowering_config lconfig = { + struct fd_lowering_config lconfig = { .color_two_side = so->key.color_two_side, .lower_DST = true, .lower_XPD = true, @@ -153,6 +153,20 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, .lower_DP2A = true, }; + switch (so->type) { + case SHADER_FRAGMENT: + case SHADER_COMPUTE: + lconfig.saturate_s = so->key.fsaturate_s; + lconfig.saturate_t = so->key.fsaturate_t; + lconfig.saturate_r = so->key.fsaturate_r; + break; + case SHADER_VERTEX: + lconfig.saturate_s = so->key.vsaturate_s; + lconfig.saturate_t = so->key.vsaturate_t; + lconfig.saturate_r = so->key.vsaturate_r; + break; + } + ctx->tokens = fd_transform_lowering(&lconfig, tokens, &ctx->info); ctx->free_tokens = !!ctx->tokens; if (!ctx->tokens) { diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c index 1e1ca7ad813..4267feb351f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c @@ -125,7 +125,7 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, { unsigned ret, base = 0; struct tgsi_shader_info *info = &ctx->info; - const struct fd_lowering_config lconfig = { + struct fd_lowering_config lconfig = { .color_two_side = so->key.color_two_side, .lower_DST = true, .lower_XPD = true, @@ -143,6 +143,20 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, .lower_DP2A = true, }; + switch (so->type) { + case SHADER_FRAGMENT: + case SHADER_COMPUTE: + lconfig.saturate_s = so->key.fsaturate_s; + lconfig.saturate_t = so->key.fsaturate_t; + lconfig.saturate_r = so->key.fsaturate_r; + break; + case SHADER_VERTEX: + lconfig.saturate_s = so->key.vsaturate_s; + lconfig.saturate_t = so->key.vsaturate_t; + lconfig.saturate_r = so->key.vsaturate_r; + break; + } + ctx->tokens = fd_transform_lowering(&lconfig, tokens, &ctx->info); ctx->free_tokens = !!ctx->tokens; if (!ctx->tokens) { diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 6d45597886b..ed7c639c930 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -185,11 +185,17 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key) */ if (shader->type == SHADER_FRAGMENT) { key.binning_pass = false; + key.vsaturate_s = 0; + key.vsaturate_t = 0; + key.vsaturate_r = 0; } if (shader->type == SHADER_VERTEX) { key.color_two_side = false; key.half_precision = false; key.alpha = false; + key.fsaturate_s = 0; + key.fsaturate_t = 0; + key.fsaturate_r = 0; } for (v = shader->variants; v; v = v->next) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index ea861649176..04a737ef19d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -52,8 +52,23 @@ static inline uint16_t sem2idx(ir3_semantic sem) /* Configuration key used to identify a shader variant.. different * shader variants can be used to implement features not supported * in hw (two sided color), binning-pass vertex shader, etc. + * + * TODO since shader key is starting to get larger (than 32bit) + * we probably should pass it around by ptr rather than value more + * of the places.. but watch out in ir3_shader_variant() where the + * key gets normalized, we need to make a copy there. */ struct ir3_shader_key { + /* bitmask of sampler which needs coords clamped for vertex + * shader: + */ + unsigned vsaturate_s, vsaturate_t, vsaturate_r; + + /* bitmask of sampler which needs coords clamped for frag + * shader: + */ + unsigned fsaturate_s, fsaturate_t, fsaturate_r; + /* * Vertex shader variant parameters: */ |