[Mesa-dev] [PATCH 2/3] nv20: Fix GL_CLAMP
Ilia Mirkin
imirkin at alum.mit.edu
Fri Jul 14 01:50:46 UTC 2017
According to rnndb, GL_CLAMP with value 0x5 is actually supported on
nv10+. I'd name the function *_nv10.
I have, at various times, tried to solve some issues by using the 0x5
clamp on my nv1x hardware (nv17 and nv18), with no positive effect.
This is a piglit run I have around from some time back:
https://people.freedesktop.org/~imirkin/nv10-comparison/problems.html
in case you're curious. I guess this is consistent with your results -
no change from doing this, until we get to borders.
With or without that function name change, this is
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
[apologies this took me a while to get to]
On Tue, Jun 27, 2017 at 1:09 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> v2: Force T and R wrap modes to GL_CLAMP_TO_EDGE for 1D textures.
> This fixes a regression in tex1d-2dborder. The test uses a 1D texture
> but it provides S and T texture coordinates. Since the T wrap mode
> would (correctly) be set to GL_CLAMP, the texture would gradually
> blend (incorrectly) with the border color.
>
> I also tried setting NV20_3D_TEX_FORMAT_DIMS_1D instead of
> NV20_3D_TEX_FORMAT_DIMS_2D for 1D textures, but that did not help.
>
> It is possible that the same problem exists for 2D textures with the
> R-wrap mode, but I don't think there are any piglit tests for that.
>
> No test changes on NV20 (10de:0201).
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/mesa/drivers/dri/nouveau/nouveau_gldefs.h | 19 +++++++++++++++++++
> src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 16 +++++++++++++---
> 2 files changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
> index 46ec14e..7df04c1 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
> @@ -239,6 +239,25 @@ nvgl_wrap_mode(unsigned wrap)
> }
>
> static inline unsigned
> +nvgl_wrap_mode_nv20(unsigned wrap)
> +{
> + switch (wrap) {
> + case GL_REPEAT:
> + return 0x1;
> + case GL_MIRRORED_REPEAT:
> + return 0x2;
> + case GL_CLAMP:
> + return 0x5;
> + case GL_CLAMP_TO_EDGE:
> + return 0x3;
> + case GL_CLAMP_TO_BORDER:
> + return 0x4;
> + default:
> + unreachable("Bad GL texture wrap mode");
> + }
> +}
> +
> +static inline unsigned
> nvgl_filter_mode(unsigned filter)
> {
> switch (filter) {
> diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
> index b0a4c9f..7972069 100644
> --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
> +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
> @@ -193,9 +193,19 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
> | NV20_3D_TEX_FORMAT_NO_BORDER
> | 1 << 16;
>
> - tx_wrap = nvgl_wrap_mode(sa->WrapR) << 16
> - | nvgl_wrap_mode(sa->WrapT) << 8
> - | nvgl_wrap_mode(sa->WrapS) << 0;
> + switch (t->Target) {
> + case GL_TEXTURE_1D:
> + tx_wrap = NV20_3D_TEX_WRAP_R_CLAMP_TO_EDGE
> + | NV20_3D_TEX_WRAP_T_CLAMP_TO_EDGE
> + | nvgl_wrap_mode_nv20(sa->WrapS) << 0;
> + break;
> +
> + default:
> + tx_wrap = nvgl_wrap_mode_nv20(sa->WrapR) << 16
> + | nvgl_wrap_mode_nv20(sa->WrapT) << 8
> + | nvgl_wrap_mode_nv20(sa->WrapS) << 0;
> + break;
> + }
>
> tx_filter = nvgl_filter_mode(sa->MagFilter) << 24
> | nvgl_filter_mode(sa->MinFilter) << 16
> --
> 2.9.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list