diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index bb9908907a3..24d3902f541 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -479,29 +479,6 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s) progress |= OPT(s, ir3_nir_lower_view_layer_id, layer_zero, view_zero); } - struct nir_lower_tex_options tex_options = { }; - - switch (so->shader->type) { - case MESA_SHADER_FRAGMENT: - tex_options.saturate_s = so->key.fsaturate_s; - tex_options.saturate_t = so->key.fsaturate_t; - tex_options.saturate_r = so->key.fsaturate_r; - break; - case MESA_SHADER_VERTEX: - tex_options.saturate_s = so->key.vsaturate_s; - tex_options.saturate_t = so->key.vsaturate_t; - tex_options.saturate_r = so->key.vsaturate_r; - break; - default: - /* TODO */ - break; - } - - if (tex_options.saturate_s || tex_options.saturate_t || - tex_options.saturate_r) { - progress |= OPT(s, nir_lower_tex, &tex_options); - } - /* Move large constant variables to the constants attached to the NIR * shader, which we will upload in the immediates range. This generates * amuls, so we need to clean those up after. diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 30b94fadfa5..27f0966325c 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -428,9 +428,6 @@ ir3_setup_used_key(struct ir3_shader *shader) key->ucp_enables = 0xff; if (info->stage == MESA_SHADER_FRAGMENT) { - key->fsaturate_s = ~0; - key->fsaturate_t = ~0; - key->fsaturate_r = ~0; key->fastc_srgb = ~0; key->fsamples = ~0; @@ -455,9 +452,6 @@ ir3_setup_used_key(struct ir3_shader *shader) key->has_gs = true; if (info->stage == MESA_SHADER_VERTEX) { - key->vsaturate_s = ~0; - key->vsaturate_t = ~0; - key->vsaturate_r = ~0; key->vastc_srgb = ~0; key->vsamples = ~0; } diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 8ce5ae566e4..06d8e643e07 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -325,16 +325,6 @@ struct ir3_shader_key { uint32_t global; }; - /* bitmask of sampler which needs coords clamped for vertex - * shader: - */ - uint16_t vsaturate_s, vsaturate_t, vsaturate_r; - - /* bitmask of sampler which needs coords clamped for frag - * shader: - */ - uint16_t fsaturate_s, fsaturate_t, fsaturate_r; - /* bitmask of ms shifts */ uint32_t vsamples, fsamples; @@ -371,10 +361,7 @@ static inline bool ir3_shader_key_changes_fs(struct ir3_shader_key *key, struct ir3_shader_key *last_key) { if (last_key->has_per_samp || key->has_per_samp) { - if ((last_key->fsaturate_s != key->fsaturate_s) || - (last_key->fsaturate_t != key->fsaturate_t) || - (last_key->fsaturate_r != key->fsaturate_r) || - (last_key->fsamples != key->fsamples) || + if ((last_key->fsamples != key->fsamples) || (last_key->fastc_srgb != key->fastc_srgb)) return true; } @@ -399,10 +386,7 @@ static inline bool ir3_shader_key_changes_vs(struct ir3_shader_key *key, struct ir3_shader_key *last_key) { if (last_key->has_per_samp || key->has_per_samp) { - if ((last_key->vsaturate_s != key->vsaturate_s) || - (last_key->vsaturate_t != key->vsaturate_t) || - (last_key->vsaturate_r != key->vsaturate_r) || - (last_key->vsamples != key->vsamples) || + if ((last_key->vsamples != key->vsamples) || (last_key->vastc_srgb != key->vastc_srgb)) return true; } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.h b/src/gallium/drivers/freedreno/a3xx/fd3_context.h index 0c9412a7501..9000a64336e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.h @@ -47,19 +47,6 @@ struct fd3_context { struct u_upload_mgr *border_color_uploader; struct pipe_resource *border_color_buf; - /* if *any* of bits are set in {v,f}saturate_{s,t,r} */ - bool vsaturate, fsaturate; - - /* 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; - /* some state changes require a different shader variant. Keep * track of this so we know when we need to re-emit shader state * due to variant change. See fixup_shader_state() diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 062cbe56abd..4f6d03187ca 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -121,7 +121,6 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, unsigned index_offset) in_dt { - struct fd3_context *fd3_ctx = fd3_context(ctx); struct fd3_emit emit = { .debug = &ctx->debug, .vtx = &ctx->vtx, @@ -129,15 +128,7 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, .info = info, .indirect = indirect, .draw = draw, - .key = { - .has_per_samp = (fd3_ctx->fsaturate || fd3_ctx->vsaturate), - .vsaturate_s = fd3_ctx->vsaturate_s, - .vsaturate_t = fd3_ctx->vsaturate_t, - .vsaturate_r = fd3_ctx->vsaturate_r, - .fsaturate_s = fd3_ctx->fsaturate_s, - .fsaturate_t = fd3_ctx->fsaturate_t, - .fsaturate_r = fd3_ctx->fsaturate_r, - }, + .key = { { { 0 } } }, .rasterflat = ctx->rasterizer->flatshade, .sprite_coord_enable = ctx->rasterizer->sprite_coord_enable, .sprite_coord_mode = ctx->rasterizer->sprite_coord_mode, diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index bea94bf0008..3518dacd24b 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -34,14 +34,8 @@ #include "fd3_format.h" static enum a3xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) +tex_clamp(unsigned wrap, bool *needs_border) { - /* Hardware does not support _CLAMP, but we emulate it: */ - if (wrap == PIPE_TEX_WRAP_CLAMP) { - wrap = (clamp_to_edge) ? - PIPE_TEX_WRAP_CLAMP_TO_EDGE : PIPE_TEX_WRAP_CLAMP_TO_BORDER; - } - switch (wrap) { case PIPE_TEX_WRAP_REPEAT: return A3XX_TEX_REPEAT; @@ -87,7 +81,6 @@ fd3_sampler_state_create(struct pipe_context *pctx, struct fd3_sampler_stateobj *so = CALLOC_STRUCT(fd3_sampler_stateobj); unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8)); bool miplinear = false; - bool clamp_to_edge; if (!so) return NULL; @@ -97,21 +90,6 @@ fd3_sampler_state_create(struct pipe_context *pctx, so->base = *cso; - /* - * For nearest filtering, _CLAMP means _CLAMP_TO_EDGE; for linear - * filtering, _CLAMP means _CLAMP_TO_BORDER while additionally - * clamping the texture coordinates to [0.0, 1.0]. - * - * The clamping will be taken care of in the shaders. There are two - * filters here, but let the minification one has a say. - */ - clamp_to_edge = (cso->min_img_filter == PIPE_TEX_FILTER_NEAREST); - if (!clamp_to_edge) { - so->saturate_s = (cso->wrap_s == PIPE_TEX_WRAP_CLAMP); - so->saturate_t = (cso->wrap_t == PIPE_TEX_WRAP_CLAMP); - so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); - } - so->needs_border = false; so->texsamp0 = COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) | @@ -120,9 +98,9 @@ fd3_sampler_state_create(struct pipe_context *pctx, A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A3XX_TEX_SAMP_0_ANISO(aniso) | - A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | - A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) | - A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border)); + A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, &so->needs_border)) | + A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, &so->needs_border)) | + A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, &so->needs_border)); if (cso->compare_mode) so->texsamp0 |= A3XX_TEX_SAMP_0_COMPARE_FUNC(cso->compare_func); /* maps 1:1 */ @@ -146,53 +124,6 @@ fd3_sampler_state_create(struct pipe_context *pctx, return so; } -static void -fd3_sampler_states_bind(struct pipe_context *pctx, - enum pipe_shader_type shader, unsigned start, - unsigned nr, void **hwcso) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd3_context *fd3_ctx = fd3_context(ctx); - uint16_t saturate_s = 0, saturate_t = 0, saturate_r = 0; - unsigned i; - - if (!hwcso) - nr = 0; - - for (i = 0; i < nr; i++) { - if (hwcso[i]) { - struct fd3_sampler_stateobj *sampler = - fd3_sampler_stateobj(hwcso[i]); - if (sampler->saturate_s) - saturate_s |= (1 << i); - if (sampler->saturate_t) - saturate_t |= (1 << i); - if (sampler->saturate_r) - saturate_r |= (1 << i); - } - } - - fd_sampler_states_bind(pctx, shader, start, nr, hwcso); - - if (shader == PIPE_SHADER_FRAGMENT) { - fd3_ctx->fsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd3_ctx->fsaturate_s = saturate_s; - fd3_ctx->fsaturate_t = saturate_t; - fd3_ctx->fsaturate_r = saturate_r; - } else if (shader == PIPE_SHADER_VERTEX) { - fd3_ctx->vsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd3_ctx->vsaturate_s = saturate_s; - fd3_ctx->vsaturate_t = saturate_t; - fd3_ctx->vsaturate_r = saturate_r; - } -} - static enum a3xx_tex_type tex_type(unsigned target) { @@ -291,7 +222,7 @@ void fd3_texture_init(struct pipe_context *pctx) { pctx->create_sampler_state = fd3_sampler_state_create; - pctx->bind_sampler_states = fd3_sampler_states_bind; + pctx->bind_sampler_states = fd_sampler_states_bind; pctx->create_sampler_view = fd3_sampler_view_create; pctx->set_sampler_views = fd_set_sampler_views; } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h index f0f51381666..ddc4dfd65b4 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h @@ -38,7 +38,6 @@ struct fd3_sampler_stateobj { struct pipe_sampler_state base; uint32_t texsamp0, texsamp1; - bool saturate_s, saturate_t, saturate_r; bool needs_border; }; diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.h b/src/gallium/drivers/freedreno/a4xx/fd4_context.h index a84e3a90f83..917e2778b1f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_context.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.h @@ -48,19 +48,6 @@ struct fd4_context { struct u_upload_mgr *border_color_uploader; struct pipe_resource *border_color_buf; - /* if *any* of bits are set in {v,f}saturate_{s,t,r} */ - bool vsaturate, fsaturate; - - /* bitmask of sampler which needs coords clamped for vertex - * shader: - */ - uint16_t vsaturate_s, vsaturate_t, vsaturate_r; - - /* bitmask of sampler which needs coords clamped for frag - * shader: - */ - uint16_t fsaturate_s, fsaturate_t, fsaturate_r; - /* bitmask of samplers which need astc srgb workaround: */ uint16_t vastc_srgb, fastc_srgb; diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c index 021f1b6e61a..91d7beffd1b 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c @@ -116,14 +116,7 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, .key = { .rasterflat = ctx->rasterizer->flatshade, .ucp_enables = ctx->rasterizer->clip_plane_enable, - .has_per_samp = (fd4_ctx->fsaturate || fd4_ctx->vsaturate || - fd4_ctx->fastc_srgb || fd4_ctx->vastc_srgb), - .vsaturate_s = fd4_ctx->vsaturate_s, - .vsaturate_t = fd4_ctx->vsaturate_t, - .vsaturate_r = fd4_ctx->vsaturate_r, - .fsaturate_s = fd4_ctx->fsaturate_s, - .fsaturate_t = fd4_ctx->fsaturate_t, - .fsaturate_r = fd4_ctx->fsaturate_r, + .has_per_samp = fd4_ctx->fastc_srgb || fd4_ctx->vastc_srgb, .vastc_srgb = fd4_ctx->vastc_srgb, .fastc_srgb = fd4_ctx->fastc_srgb, }, diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c index 16fbb463419..15f716ed5d6 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c @@ -34,14 +34,8 @@ #include "fd4_format.h" static enum a4xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) +tex_clamp(unsigned wrap, bool *needs_border) { - /* Hardware does not support _CLAMP, but we emulate it: */ - if (wrap == PIPE_TEX_WRAP_CLAMP) { - wrap = (clamp_to_edge) ? - PIPE_TEX_WRAP_CLAMP_TO_EDGE : PIPE_TEX_WRAP_CLAMP_TO_BORDER; - } - switch (wrap) { case PIPE_TEX_WRAP_REPEAT: return A4XX_TEX_REPEAT; @@ -87,7 +81,6 @@ fd4_sampler_state_create(struct pipe_context *pctx, struct fd4_sampler_stateobj *so = CALLOC_STRUCT(fd4_sampler_stateobj); unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8)); bool miplinear = false; - bool clamp_to_edge; if (!so) return NULL; @@ -97,30 +90,15 @@ fd4_sampler_state_create(struct pipe_context *pctx, so->base = *cso; - /* - * For nearest filtering, _CLAMP means _CLAMP_TO_EDGE; for linear - * filtering, _CLAMP means _CLAMP_TO_BORDER while additionally - * clamping the texture coordinates to [0.0, 1.0]. - * - * The clamping will be taken care of in the shaders. There are two - * filters here, but let the minification one has a say. - */ - clamp_to_edge = (cso->min_img_filter == PIPE_TEX_FILTER_NEAREST); - if (!clamp_to_edge) { - so->saturate_s = (cso->wrap_s == PIPE_TEX_WRAP_CLAMP); - so->saturate_t = (cso->wrap_t == PIPE_TEX_WRAP_CLAMP); - so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); - } - so->needs_border = false; so->texsamp0 = COND(miplinear, A4XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) | A4XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A4XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A4XX_TEX_SAMP_0_ANISO(aniso) | - A4XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | - A4XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) | - A4XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border)); + A4XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, &so->needs_border)) | + A4XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, &so->needs_border)) | + A4XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, &so->needs_border)); so->texsamp1 = // COND(miplinear, A4XX_TEX_SAMP_1_MIPFILTER_LINEAR_FAR) | @@ -140,52 +118,6 @@ fd4_sampler_state_create(struct pipe_context *pctx, return so; } -static void -fd4_sampler_states_bind(struct pipe_context *pctx, - enum pipe_shader_type shader, unsigned start, - unsigned nr, void **hwcso) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd4_context *fd4_ctx = fd4_context(ctx); - uint16_t saturate_s = 0, saturate_t = 0, saturate_r = 0; - unsigned i; - - if (!hwcso) - nr = 0; - - for (i = 0; i < nr; i++) { - if (hwcso[i]) { - struct fd4_sampler_stateobj *sampler = - fd4_sampler_stateobj(hwcso[i]); - if (sampler->saturate_s) - saturate_s |= (1 << i); - if (sampler->saturate_t) - saturate_t |= (1 << i); - if (sampler->saturate_r) - saturate_r |= (1 << i); - } - } - - fd_sampler_states_bind(pctx, shader, start, nr, hwcso); - - if (shader == PIPE_SHADER_FRAGMENT) { - fd4_ctx->fsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd4_ctx->fsaturate_s = saturate_s; - fd4_ctx->fsaturate_t = saturate_t; - fd4_ctx->fsaturate_r = saturate_r; - } else if (shader == PIPE_SHADER_VERTEX) { - fd4_ctx->vsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd4_ctx->vsaturate_s = saturate_s; - fd4_ctx->vsaturate_t = saturate_t; - fd4_ctx->vsaturate_r = saturate_r; - } -} static enum a4xx_tex_type tex_type(unsigned target) @@ -350,7 +282,7 @@ void fd4_texture_init(struct pipe_context *pctx) { pctx->create_sampler_state = fd4_sampler_state_create; - pctx->bind_sampler_states = fd4_sampler_states_bind; + pctx->bind_sampler_states = fd_sampler_states_bind; pctx->create_sampler_view = fd4_sampler_view_create; pctx->set_sampler_views = fd4_set_sampler_views; } diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.h b/src/gallium/drivers/freedreno/a4xx/fd4_texture.h index 2e8861e4d78..42b5d2df33f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.h @@ -38,7 +38,6 @@ struct fd4_sampler_stateobj { struct pipe_sampler_state base; uint32_t texsamp0, texsamp1; - bool saturate_s, saturate_t, saturate_r; bool needs_border; }; diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_context.h b/src/gallium/drivers/freedreno/a5xx/fd5_context.h index 466cb5cb3c0..4d96bc35873 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_context.h +++ b/src/gallium/drivers/freedreno/a5xx/fd5_context.h @@ -51,19 +51,6 @@ struct fd5_context { struct u_upload_mgr *border_color_uploader; struct pipe_resource *border_color_buf; - /* if *any* of bits are set in {v,f}saturate_{s,t,r} */ - bool vsaturate, fsaturate; - - /* bitmask of sampler which needs coords clamped for vertex - * shader: - */ - uint16_t vsaturate_s, vsaturate_t, vsaturate_r; - - /* bitmask of sampler which needs coords clamped for frag - * shader: - */ - uint16_t fsaturate_s, fsaturate_t, fsaturate_r; - /* bitmask of samplers which need astc srgb workaround: */ uint16_t vastc_srgb, fastc_srgb; diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_draw.c b/src/gallium/drivers/freedreno/a5xx/fd5_draw.c index 0f5ad2c2de6..a2bbf887495 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_draw.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_draw.c @@ -111,14 +111,7 @@ fd5_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, .key = { .rasterflat = ctx->rasterizer->flatshade, .ucp_enables = ctx->rasterizer->clip_plane_enable, - .has_per_samp = (fd5_ctx->fsaturate || fd5_ctx->vsaturate || - fd5_ctx->fastc_srgb || fd5_ctx->vastc_srgb), - .vsaturate_s = fd5_ctx->vsaturate_s, - .vsaturate_t = fd5_ctx->vsaturate_t, - .vsaturate_r = fd5_ctx->vsaturate_r, - .fsaturate_s = fd5_ctx->fsaturate_s, - .fsaturate_t = fd5_ctx->fsaturate_t, - .fsaturate_r = fd5_ctx->fsaturate_r, + .has_per_samp = fd5_ctx->fastc_srgb || fd5_ctx->vastc_srgb, .vastc_srgb = fd5_ctx->vastc_srgb, .fastc_srgb = fd5_ctx->fastc_srgb, .vsamples = ctx->tex[PIPE_SHADER_VERTEX].samples, diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c index 370b9e9f931..0d6191d19dd 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c @@ -34,14 +34,8 @@ #include "fd5_format.h" static enum a5xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) +tex_clamp(unsigned wrap, bool *needs_border) { - /* Hardware does not support _CLAMP, but we emulate it: */ - if (wrap == PIPE_TEX_WRAP_CLAMP) { - wrap = (clamp_to_edge) ? - PIPE_TEX_WRAP_CLAMP_TO_EDGE : PIPE_TEX_WRAP_CLAMP_TO_BORDER; - } - switch (wrap) { case PIPE_TEX_WRAP_REPEAT: return A5XX_TEX_REPEAT; @@ -87,7 +81,6 @@ fd5_sampler_state_create(struct pipe_context *pctx, struct fd5_sampler_stateobj *so = CALLOC_STRUCT(fd5_sampler_stateobj); unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8)); bool miplinear = false; - bool clamp_to_edge; if (!so) return NULL; @@ -97,30 +90,15 @@ fd5_sampler_state_create(struct pipe_context *pctx, if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR) miplinear = true; - /* - * For nearest filtering, _CLAMP means _CLAMP_TO_EDGE; for linear - * filtering, _CLAMP means _CLAMP_TO_BORDER while additionally - * clamping the texture coordinates to [0.0, 1.0]. - * - * The clamping will be taken care of in the shaders. There are two - * filters here, but let the minification one has a say. - */ - clamp_to_edge = (cso->min_img_filter == PIPE_TEX_FILTER_NEAREST); - if (!clamp_to_edge) { - so->saturate_s = (cso->wrap_s == PIPE_TEX_WRAP_CLAMP); - so->saturate_t = (cso->wrap_t == PIPE_TEX_WRAP_CLAMP); - so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); - } - so->needs_border = false; so->texsamp0 = COND(miplinear, A5XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) | A5XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A5XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A5XX_TEX_SAMP_0_ANISO(aniso) | - A5XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | - A5XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) | - A5XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border)); + A5XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, &so->needs_border)) | + A5XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, &so->needs_border)) | + A5XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, &so->needs_border)); so->texsamp1 = COND(!cso->seamless_cube_map, A5XX_TEX_SAMP_1_CUBEMAPSEAMLESSFILTOFF) | @@ -148,53 +126,6 @@ fd5_sampler_state_create(struct pipe_context *pctx, return so; } -static void -fd5_sampler_states_bind(struct pipe_context *pctx, - enum pipe_shader_type shader, unsigned start, - unsigned nr, void **hwcso) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd5_context *fd5_ctx = fd5_context(ctx); - uint16_t saturate_s = 0, saturate_t = 0, saturate_r = 0; - unsigned i; - - if (!hwcso) - nr = 0; - - for (i = 0; i < nr; i++) { - if (hwcso[i]) { - struct fd5_sampler_stateobj *sampler = - fd5_sampler_stateobj(hwcso[i]); - if (sampler->saturate_s) - saturate_s |= (1 << i); - if (sampler->saturate_t) - saturate_t |= (1 << i); - if (sampler->saturate_r) - saturate_r |= (1 << i); - } - } - - fd_sampler_states_bind(pctx, shader, start, nr, hwcso); - - if (shader == PIPE_SHADER_FRAGMENT) { - fd5_ctx->fsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd5_ctx->fsaturate_s = saturate_s; - fd5_ctx->fsaturate_t = saturate_t; - fd5_ctx->fsaturate_r = saturate_r; - } else if (shader == PIPE_SHADER_VERTEX) { - fd5_ctx->vsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd5_ctx->vsaturate_s = saturate_s; - fd5_ctx->vsaturate_t = saturate_t; - fd5_ctx->vsaturate_r = saturate_r; - } -} - static bool use_astc_srgb_workaround(struct pipe_context *pctx, enum pipe_format format) { @@ -349,7 +280,7 @@ void fd5_texture_init(struct pipe_context *pctx) { pctx->create_sampler_state = fd5_sampler_state_create; - pctx->bind_sampler_states = fd5_sampler_states_bind; + pctx->bind_sampler_states = fd_sampler_states_bind; pctx->create_sampler_view = fd5_sampler_view_create; pctx->set_sampler_views = fd5_set_sampler_views; } diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_texture.h b/src/gallium/drivers/freedreno/a5xx/fd5_texture.h index 5cb201dfdf7..b45c526dfce 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_texture.h +++ b/src/gallium/drivers/freedreno/a5xx/fd5_texture.h @@ -38,7 +38,6 @@ struct fd5_sampler_stateobj { struct pipe_sampler_state base; uint32_t texsamp0, texsamp1, texsamp2, texsamp3; - bool saturate_s, saturate_t, saturate_r; bool needs_border; }; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_context.h b/src/gallium/drivers/freedreno/a6xx/fd6_context.h index ae1b4283c07..d8552f31c55 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_context.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_context.h @@ -70,19 +70,6 @@ struct fd6_context { struct u_upload_mgr *border_color_uploader; struct pipe_resource *border_color_buf; - /* if *any* of bits are set in {v,f}saturate_{s,t,r} */ - bool vsaturate, fsaturate; - - /* bitmask of sampler which needs coords clamped for vertex - * shader: - */ - uint16_t vsaturate_s, vsaturate_t, vsaturate_r; - - /* bitmask of sampler which needs coords clamped for frag - * shader: - */ - uint16_t fsaturate_s, fsaturate_t, fsaturate_r; - /* some state changes require a different shader variant. Keep * track of this so we know when we need to re-emit shader state * due to variant change. See fixup_shader_state() diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index 83e76af88be..c7af50aa4e5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -188,13 +188,6 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, .key = { .rasterflat = ctx->rasterizer->flatshade, .ucp_enables = ctx->rasterizer->clip_plane_enable, - .has_per_samp = (fd6_ctx->fsaturate || fd6_ctx->vsaturate), - .vsaturate_s = fd6_ctx->vsaturate_s, - .vsaturate_t = fd6_ctx->vsaturate_t, - .vsaturate_r = fd6_ctx->vsaturate_r, - .fsaturate_s = fd6_ctx->fsaturate_s, - .fsaturate_t = fd6_ctx->fsaturate_t, - .fsaturate_r = fd6_ctx->fsaturate_r, .layer_zero = !gs_info || !(gs_info->outputs_written & VARYING_BIT_LAYER), .vsamples = ctx->tex[PIPE_SHADER_VERTEX].samples, .fsamples = ctx->tex[PIPE_SHADER_FRAGMENT].samples, diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index 10462e852cd..56d25ce9a0d 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -46,14 +46,8 @@ remove_tex_entry(struct fd6_context *fd6_ctx, struct hash_entry *entry) } static enum a6xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) +tex_clamp(unsigned wrap, bool *needs_border) { - /* Hardware does not support _CLAMP, but we emulate it: */ - if (wrap == PIPE_TEX_WRAP_CLAMP) { - wrap = (clamp_to_edge) ? - PIPE_TEX_WRAP_CLAMP_TO_EDGE : PIPE_TEX_WRAP_CLAMP_TO_BORDER; - } - switch (wrap) { case PIPE_TEX_WRAP_REPEAT: return A6XX_TEX_REPEAT; @@ -99,7 +93,6 @@ fd6_sampler_state_create(struct pipe_context *pctx, struct fd6_sampler_stateobj *so = CALLOC_STRUCT(fd6_sampler_stateobj); unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8)); bool miplinear = false; - bool clamp_to_edge; if (!so) return NULL; @@ -110,30 +103,15 @@ fd6_sampler_state_create(struct pipe_context *pctx, if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR) miplinear = true; - /* - * For nearest filtering, _CLAMP means _CLAMP_TO_EDGE; for linear - * filtering, _CLAMP means _CLAMP_TO_BORDER while additionally - * clamping the texture coordinates to [0.0, 1.0]. - * - * The clamping will be taken care of in the shaders. There are two - * filters here, but let the minification one has a say. - */ - clamp_to_edge = (cso->min_img_filter == PIPE_TEX_FILTER_NEAREST); - if (!clamp_to_edge) { - so->saturate_s = (cso->wrap_s == PIPE_TEX_WRAP_CLAMP); - so->saturate_t = (cso->wrap_t == PIPE_TEX_WRAP_CLAMP); - so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); - } - so->needs_border = false; so->texsamp0 = COND(miplinear, A6XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) | A6XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A6XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A6XX_TEX_SAMP_0_ANISO(aniso) | - A6XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | - A6XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) | - A6XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border)); + A6XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, &so->needs_border)) | + A6XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, &so->needs_border)) | + A6XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, &so->needs_border)); so->texsamp1 = COND(cso->min_mip_filter == PIPE_TEX_MIPFILTER_NONE, @@ -177,53 +155,6 @@ fd6_sampler_state_delete(struct pipe_context *pctx, void *hwcso) free(hwcso); } -static void -fd6_sampler_states_bind(struct pipe_context *pctx, - enum pipe_shader_type shader, unsigned start, - unsigned nr, void **hwcso) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd6_context *fd6_ctx = fd6_context(ctx); - uint16_t saturate_s = 0, saturate_t = 0, saturate_r = 0; - unsigned i; - - if (!hwcso) - nr = 0; - - for (i = 0; i < nr; i++) { - if (hwcso[i]) { - struct fd6_sampler_stateobj *sampler = - fd6_sampler_stateobj(hwcso[i]); - if (sampler->saturate_s) - saturate_s |= (1 << i); - if (sampler->saturate_t) - saturate_t |= (1 << i); - if (sampler->saturate_r) - saturate_r |= (1 << i); - } - } - - fd_sampler_states_bind(pctx, shader, start, nr, hwcso); - - if (shader == PIPE_SHADER_FRAGMENT) { - fd6_ctx->fsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd6_ctx->fsaturate_s = saturate_s; - fd6_ctx->fsaturate_t = saturate_t; - fd6_ctx->fsaturate_r = saturate_r; - } else if (shader == PIPE_SHADER_VERTEX) { - fd6_ctx->vsaturate = - (saturate_s != 0) || - (saturate_t != 0) || - (saturate_r != 0); - fd6_ctx->vsaturate_s = saturate_s; - fd6_ctx->vsaturate_t = saturate_t; - fd6_ctx->vsaturate_r = saturate_r; - } -} - static struct pipe_sampler_view * fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, const struct pipe_sampler_view *cso) @@ -528,7 +459,7 @@ fd6_texture_init(struct pipe_context *pctx) pctx->create_sampler_state = fd6_sampler_state_create; pctx->delete_sampler_state = fd6_sampler_state_delete; - pctx->bind_sampler_states = fd6_sampler_states_bind; + pctx->bind_sampler_states = fd_sampler_states_bind; pctx->create_sampler_view = fd6_sampler_view_create; pctx->sampler_view_destroy = fd6_sampler_view_destroy; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h index 0e900d292a7..3ce43d5633b 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h @@ -39,7 +39,6 @@ struct fd6_sampler_stateobj { struct pipe_sampler_state base; uint32_t texsamp0, texsamp1, texsamp2, texsamp3; - bool saturate_s, saturate_t, saturate_r; bool needs_border; uint16_t seqno; }; diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 30369501f56..133e774791b 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -398,6 +398,12 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_MAX_GS_INVOCATIONS: return 32; + /* Only a2xx has the half-border clamp mode in HW, just have mesa/st lower + * it for later HW. + */ + case PIPE_CAP_GL_CLAMP: + return is_a2xx(screen); + /* Stream output. */ case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: if (is_ir3(screen)) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 65d5846eb84..8926f7bca9b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -142,11 +142,9 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key, if (created) { if (shader->initial_variants_done) { pipe_debug_message(debug, SHADER_INFO, - "%s shader: recompiling at draw time: global 0x%08x, vsats %x/%x/%x, fsats %x/%x/%x, vfsamples %x/%x, astc %x/%x\n", + "%s shader: recompiling at draw time: global 0x%08x, vfsamples %x/%x, astc %x/%x\n", ir3_shader_stage(v), key.global, - key.vsaturate_s, key.vsaturate_t, key.vsaturate_r, - key.fsaturate_s, key.fsaturate_t, key.fsaturate_r, key.vsamples, key.fsamples, key.vastc_srgb, key.fastc_srgb);