В сообщении от Thursday 09 September 2010 07:18:26 Francisco Jerez написал(а): > OK, here it is, it was easier to code than to explain :)
--------- Thanks, here is my patch series, updated to current (commit 5ecd9c70cecc05eaa1fef05f9bd4e8cf50f2c03a) Mesa. Patch 0004 obviously collides with yours. I'll really leave it up to you, as driver author.
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index f481161..a852042 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -58,8 +58,10 @@ static const struct dri_extension nouveau_extensions[] = { { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, { "GL_EXT_stencil_wrap", NULL }, + { "GL_EXT_texture_env_combine", NULL }, { "GL_EXT_texture_lod_bias", NULL }, { "GL_NV_blend_square", NULL }, + { "GL_NV_texture_env_combine4", NULL }, { "GL_SGIS_generate_mipmap", NULL }, { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 6834f7c..1d34c86 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -39,6 +39,7 @@ nv04_context_engine(GLcontext *ctx) struct nouveau_grobj *fahrenheit; if (ctx->Texture.Unit[0].EnvMode == GL_COMBINE || + ctx->Texture.Unit[0].EnvMode == GL_COMBINE4_NV || ctx->Texture.Unit[0].EnvMode == GL_BLEND || ctx->Texture.Unit[0].EnvMode == GL_ADD || ctx->Texture.Unit[1]._ReallyEnabled || diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c index d7c86d4..bb5d7dc 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c @@ -44,6 +44,7 @@ struct combiner_state { GLcontext *ctx; int unit; GLboolean alpha; + GLboolean premodulate; /* GL state */ GLenum mode; @@ -66,6 +67,7 @@ struct combiner_state { (rc)->ctx = ctx; \ (rc)->unit = i; \ (rc)->alpha = __INIT_COMBINER_ALPHA_##chan; \ + (rc)->premodulate = c->_NumArgs##chan == 4; \ (rc)->mode = c->Mode##chan; \ (rc)->source = c->Source##chan; \ (rc)->operand = c->Operand##chan; \ @@ -79,6 +81,9 @@ static uint32_t get_input_source(struct combiner_state *rc, int source) { switch (source) { + case GL_ZERO: + return COMBINER_SOURCE(ZERO); + case GL_TEXTURE: return rc->unit ? COMBINER_SOURCE(TEXTURE1) : COMBINER_SOURCE(TEXTURE0); @@ -195,11 +200,24 @@ setup_combiner(struct combiner_state *rc) break; case GL_ADD: - INPUT_ARG(rc, 0, 0, 0); - INPUT_SRC(rc, 1, ZERO, INVERT); - INPUT_ARG(rc, 2, 1, 0); - INPUT_SRC(rc, 3, ZERO, INVERT); - UNSIGNED_OP(rc); + case GL_ADD_SIGNED: + if (rc->premodulate) { + INPUT_ARG(rc, 0, 0, 0); + INPUT_ARG(rc, 1, 1, 0); + INPUT_ARG(rc, 2, 2, 0); + INPUT_ARG(rc, 3, 3, 0); + } else { + INPUT_ARG(rc, 0, 0, 0); + INPUT_SRC(rc, 1, ZERO, INVERT); + INPUT_ARG(rc, 2, 1, 0); + INPUT_SRC(rc, 3, ZERO, INVERT); + } + + if (rc->mode == GL_ADD_SIGNED) + SIGNED_OP(rc); + else + UNSIGNED_OP(rc); + break; case GL_INTERPOLATE: @@ -210,14 +228,6 @@ setup_combiner(struct combiner_state *rc) UNSIGNED_OP(rc); break; - case GL_ADD_SIGNED: - INPUT_ARG(rc, 0, 0, 0); - INPUT_SRC(rc, 1, ZERO, INVERT); - INPUT_ARG(rc, 2, 1, 0); - INPUT_SRC(rc, 3, ZERO, INVERT); - SIGNED_OP(rc); - break; - default: assert(0); }
From 92c19bdd1101da592fc4c8346c01333aaad8d16d Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <randrianas...@gmail.com> Date: Thu, 9 Sep 2010 07:22:32 +0400 Subject: [PATCH 1/4] nv0x: Add workaround for small sifm transfers, eliminating some noise from dmesg during texenv run --- src/mesa/drivers/dri/nouveau/nv04_surface.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c b/src/mesa/drivers/dri/nouveau/nv04_surface.c index e3febf7..48078f9 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_surface.c +++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c @@ -410,10 +410,19 @@ nv04_surface_copy(GLcontext *ctx, nv04_surface_copy_m2mf(ctx, dst, src, dx, dy, sx, sy, w, h); return; } + + /* TNT2 seems to be upset if we use sifm with small region, + add workaround */ + int sifm_allowed = 0; + if (context_chipset(ctx) < 0x10) { + if (w > 8 && h > 8) + sifm_allowed = 1; + } else { sifm_allowed = 1; } + /* Swizzle using sifm+swzsurf. */ if (src->layout == LINEAR && dst->layout == SWIZZLED && - dst->cpp != 1 && !(dst->offset & 63)) { + dst->cpp != 1 && !(dst->offset & 63) && (sifm_allowed == 1)) { nv04_surface_copy_swizzle(ctx, dst, src, dx, dy, sx, sy, w, h); return; } -- 1.7.0.2
From 0751c686413690a2673486234bf9cb7d7956b8a5 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <randrianas...@gmail.com> Date: Thu, 9 Sep 2010 07:29:18 +0400 Subject: [PATCH 2/4] nv0x: enable eng3dm for A8/L8 textures and all non-basic texenv modes --- src/mesa/drivers/dri/nouveau/nv04_context.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 6834f7c..bacab57 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -38,14 +38,23 @@ nv04_context_engine(GLcontext *ctx) struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; struct nouveau_grobj *fahrenheit; - if (ctx->Texture.Unit[0].EnvMode == GL_COMBINE || - ctx->Texture.Unit[0].EnvMode == GL_BLEND || - ctx->Texture.Unit[0].EnvMode == GL_ADD || + + if ((ctx->Texture.Unit[0].EnvMode != GL_DECAL && + ctx->Texture.Unit[0].EnvMode != GL_MODULATE && + ctx->Texture.Unit[0].EnvMode != GL_REPLACE ) || ctx->Texture.Unit[1]._ReallyEnabled || ctx->Stencil.Enabled) fahrenheit = hw->eng3dm; else fahrenheit = hw->eng3d; + + if (ctx->Texture.Unit[0]._ReallyEnabled) { + struct gl_texture_object *t = ctx->Texture.Unit[0]._Current; + struct gl_texture_image *ti = t->Image[0][t->BaseLevel]; + if (ti->TexFormat == MESA_FORMAT_A8 || + ti->TexFormat == MESA_FORMAT_L8 ) + fahrenheit = hw->eng3dm; + } if (fahrenheit != nctx->eng3d) { nctx->eng3d = fahrenheit; -- 1.7.0.2
From 8414fc6ecb0fac9d381fc9896929dd255f780256 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <randrianas...@gmail.com> Date: Thu, 9 Sep 2010 07:34:19 +0400 Subject: [PATCH 3/4] nouveau: Trivially move GL_ARB_texture_env_dot3 and GL_ARB_texture_env_combine from common extension list into nv10 and nv20 specific extension lists, so they will not show up on nv0x. --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 -- src/mesa/drivers/dri/nouveau/nv10_context.c | 2 ++ src/mesa/drivers/dri/nouveau/nv20_context.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index b1d4152..b9a4328 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -50,8 +50,6 @@ static const struct dri_extension nouveau_extensions[] = { { "GL_ARB_multitexture", NULL }, { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_env_combine", NULL }, - { "GL_ARB_texture_env_dot3", NULL }, { "GL_ARB_texture_mirrored_repeat", NULL }, { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, { "GL_EXT_framebuffer_blit", NULL }, diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index b6d1036..7f00002 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -34,6 +34,8 @@ static const struct dri_extension nv10_extensions[] = { { "GL_EXT_texture_rectangle", NULL }, + { "GL_ARB_texture_env_combine", NULL }, + { "GL_ARB_texture_env_dot3", NULL }, { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index 789dcaa..03cb14a 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -33,6 +33,8 @@ static const struct dri_extension nv20_extensions[] = { { "GL_EXT_texture_rectangle", NULL }, + { "GL_ARB_texture_env_combine", NULL }, + { "GL_ARB_texture_env_dot3", NULL }, { NULL, NULL } }; -- 1.7.0.2
From 469f6fbb320d24add5f0e53da173ccedbb623e0c Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <randrianas...@gmail.com> Date: Thu, 9 Sep 2010 07:45:08 +0400 Subject: [PATCH 4/4] nouveau: Start adding support for GL_EXT_texture_env_combine and GL_NV_texture_env_combine4, move them into common extension list, add GL_ZERO as possible combiner input source for nv0x/nv1x, currently fail piglit testing! --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 ++ src/mesa/drivers/dri/nouveau/nv04_state_frag.c | 2 ++ src/mesa/drivers/dri/nouveau/nv10_state_frag.c | 2 ++ 3 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index b9a4328..69c9df2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -56,8 +56,10 @@ static const struct dri_extension nouveau_extensions[] = { { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, { "GL_EXT_stencil_wrap", NULL }, + { "GL_EXT_texture_env_combine", NULL }, { "GL_EXT_texture_lod_bias", NULL }, { "GL_NV_blend_square", NULL }, + { "GL_NV_texture_env_combine4", NULL }, { "GL_SGIS_generate_mipmap", NULL }, { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c index d7c86d4..bff7383 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c @@ -79,6 +79,8 @@ static uint32_t get_input_source(struct combiner_state *rc, int source) { switch (source) { + case GL_ZERO: + return COMBINER_SOURCE(ZERO); case GL_TEXTURE: return rc->unit ? COMBINER_SOURCE(TEXTURE1) : COMBINER_SOURCE(TEXTURE0); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c index 76b95fd..497e9d8 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c @@ -95,6 +95,8 @@ static uint32_t get_input_source(struct combiner_state *rc, int source) { switch (source) { + case GL_ZERO: + return RC_IN_SOURCE(ZERO); case GL_TEXTURE: return RC_IN_SOURCE(TEXTURE0) + rc->unit; -- 1.7.0.2
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev