X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fnouveau%2Fnv20_state_tex.c;h=b0a4c9fb0976edfe40a108a2494ff7fb19b067e4;hb=da9e6fdfe27065b8ede8b2fe30c8cccc3b573245;hp=c362aca0fdb5b8936aa936086dd21809fef03246;hpb=69f54d2a7e06210f28b46d20f74a906d9750a36e;p=mesa.git diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index c362aca0fdb..b0a4c9fb097 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -31,14 +31,14 @@ #include "nv20_3d.xml.h" #include "nouveau_util.h" #include "nv20_driver.h" +#include "main/samplerobj.h" void nv20_emit_tex_gen(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_GEN0; struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_texture_unit *unit = &ctx->Texture.Unit[i]; int j; @@ -48,17 +48,16 @@ nv20_emit_tex_gen(struct gl_context *ctx, int emit) float *k = get_texgen_coeff(coord); if (k) { - BEGIN_RING(chan, kelvin, - NV20_3D_TEX_GEN_COEFF(i, j), 4); - OUT_RINGp(chan, k, 4); + BEGIN_NV04(push, NV20_3D(TEX_GEN_COEFF(i, j)), 4); + PUSH_DATAp(push, k, 4); } - BEGIN_RING(chan, kelvin, NV20_3D_TEX_GEN_MODE(i, j), 1); - OUT_RING(chan, nvgl_texgen_mode(coord->Mode)); + BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1); + PUSH_DATA (push, nvgl_texgen_mode(coord->Mode)); } else { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_GEN_MODE(i, j), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(i, j)), 1); + PUSH_DATA (push, 0); } } } @@ -68,20 +67,19 @@ nv20_emit_tex_mat(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_MAT0; struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); if (nctx->fallback == HWTNL && (ctx->Texture._TexMatEnabled & 1 << i)) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX_ENABLE(i), 1); - OUT_RING(chan, 1); + BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1); + PUSH_DATA (push, 1); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX(i,0), 16); - OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m); + BEGIN_NV04(push, NV20_3D(TEX_MATRIX(i,0)), 16); + PUSH_DATAm(push, ctx->TextureMatrixStack[i].Top->m); } else { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_MATRIX_ENABLE(i), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1); + PUSH_DATA (push, 0); } } @@ -89,30 +87,37 @@ static uint32_t get_tex_format_pot(struct gl_texture_image *ti) { switch (ti->TexFormat) { - case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_B8G8R8A8_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A8R8G8B8; - case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_B5G5R5A1_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A1R5G5B5; - case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_B4G4R4A4_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A4R4G4B4; - case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_B8G8R8X8_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_X8R8G8B8; - case MESA_FORMAT_RGB565: + case MESA_FORMAT_B5G6R5_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_R5G6B5; - case MESA_FORMAT_A8: - case MESA_FORMAT_I8: + case MESA_FORMAT_A_UNORM8: + case MESA_FORMAT_I_UNORM8: return NV20_3D_TEX_FORMAT_FORMAT_I8; - case MESA_FORMAT_L8: + case MESA_FORMAT_L_UNORM8: return NV20_3D_TEX_FORMAT_FORMAT_L8; - case MESA_FORMAT_CI8: - return NV20_3D_TEX_FORMAT_FORMAT_INDEX8; + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + return NV20_3D_TEX_FORMAT_FORMAT_DXT1; + + case MESA_FORMAT_RGBA_DXT3: + return NV20_3D_TEX_FORMAT_FORMAT_DXT3; + + case MESA_FORMAT_RGBA_DXT5: + return NV20_3D_TEX_FORMAT_FORMAT_DXT5; default: assert(0); @@ -123,26 +128,26 @@ static uint32_t get_tex_format_rect(struct gl_texture_image *ti) { switch (ti->TexFormat) { - case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_B8G8R8A8_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A8R8G8B8_RECT; - case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_B5G5R5A1_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A1R5G5B5_RECT; - case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_B4G4R4A4_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_A4R4G4B4_RECT; - case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_B8G8R8X8_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_R8G8B8_RECT; - case MESA_FORMAT_RGB565: + case MESA_FORMAT_B5G6R5_UNORM: return NV20_3D_TEX_FORMAT_FORMAT_R5G6B5_RECT; - case MESA_FORMAT_L8: + case MESA_FORMAT_L_UNORM8: return NV20_3D_TEX_FORMAT_FORMAT_L8_RECT; - case MESA_FORMAT_A8: - case MESA_FORMAT_I8: + case MESA_FORMAT_A_UNORM8: + case MESA_FORMAT_I_UNORM8: return NV20_3D_TEX_FORMAT_FORMAT_I8_RECT; default: @@ -154,18 +159,19 @@ void nv20_emit_tex_obj(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_OBJ0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); - struct nouveau_bo_context *bctx = context_bctx_i(ctx, TEXTURE, i); + struct nouveau_pushbuf *push = context_push(ctx); const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM; struct gl_texture_object *t; struct nouveau_surface *s; struct gl_texture_image *ti; + const struct gl_sampler_object *sa; uint32_t tx_format, tx_filter, tx_wrap, tx_enable; - if (!ctx->Texture.Unit[i]._ReallyEnabled) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1); - OUT_RING(chan, 0); + PUSH_RESET(push, BUFCTX_TEX(i)); + + if (!ctx->Texture.Unit[i]._Current) { + BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, 0); context_dirty(ctx, TEX_SHADER); return; @@ -174,6 +180,7 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit) t = ctx->Texture.Unit[i]._Current; s = &to_nouveau_texture(t)->surfaces[t->BaseLevel]; ti = t->Image[0][t->BaseLevel]; + sa = _mesa_get_samplerobj(ctx, i); if (!nouveau_texture_validate(ctx, t)) return; @@ -186,33 +193,33 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit) | NV20_3D_TEX_FORMAT_NO_BORDER | 1 << 16; - tx_wrap = nvgl_wrap_mode(t->WrapR) << 16 - | nvgl_wrap_mode(t->WrapT) << 8 - | nvgl_wrap_mode(t->WrapS) << 0; + tx_wrap = nvgl_wrap_mode(sa->WrapR) << 16 + | nvgl_wrap_mode(sa->WrapT) << 8 + | nvgl_wrap_mode(sa->WrapS) << 0; - tx_filter = nvgl_filter_mode(t->MagFilter) << 24 - | nvgl_filter_mode(t->MinFilter) << 16 + tx_filter = nvgl_filter_mode(sa->MagFilter) << 24 + | nvgl_filter_mode(sa->MinFilter) << 16 | 2 << 12; tx_enable = NV20_3D_TEX_ENABLE_ENABLE - | log2i(t->MaxAnisotropy) << 4; + | log2i(sa->MaxAnisotropy) << 4; if (t->Target == GL_TEXTURE_RECTANGLE) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_NPOT_PITCH(i), 1); - OUT_RING(chan, s->pitch << 16); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_NPOT_SIZE(i), 1); - OUT_RING(chan, s->width << 16 | s->height); + BEGIN_NV04(push, NV20_3D(TEX_NPOT_PITCH(i)), 1); + PUSH_DATA (push, s->pitch << 16); + BEGIN_NV04(push, NV20_3D(TEX_NPOT_SIZE(i)), 1); + PUSH_DATA (push, s->width << 16 | s->height); tx_format |= get_tex_format_rect(ti); } else { tx_format |= get_tex_format_pot(ti); } - if (t->MinFilter != GL_NEAREST && - t->MinFilter != GL_LINEAR) { - int lod_min = t->MinLod; - int lod_max = MIN2(t->MaxLod, t->_MaxLambda); - int lod_bias = t->LodBias + if (sa->MinFilter != GL_NEAREST && + sa->MinFilter != GL_LINEAR) { + int lod_min = sa->MinLod; + int lod_max = MIN2(sa->MaxLod, t->_MaxLambda); + int lod_bias = sa->LodBias + ctx->Texture.Unit[i].LodBias; lod_max = CLAMP(lod_max, 0, 15); @@ -226,23 +233,24 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit) } /* Write it to the hardware. */ - nouveau_bo_mark(bctx, kelvin, NV20_3D_TEX_FORMAT(i), - s->bo, tx_format, 0, - NV20_3D_TEX_FORMAT_DMA0, - NV20_3D_TEX_FORMAT_DMA1, - bo_flags | NOUVEAU_BO_OR); - - nouveau_bo_markl(bctx, kelvin, NV20_3D_TEX_OFFSET(i), + BEGIN_NV04(push, NV20_3D(TEX_FORMAT(i)), 1); + PUSH_MTHD (push, NV20_3D(TEX_FORMAT(i)), BUFCTX_TEX(i), + s->bo, tx_format, bo_flags | NOUVEAU_BO_OR, + NV20_3D_TEX_FORMAT_DMA0, + NV20_3D_TEX_FORMAT_DMA1); + + BEGIN_NV04(push, NV20_3D(TEX_OFFSET(i)), 1); + PUSH_MTHDl(push, NV20_3D(TEX_OFFSET(i)), BUFCTX_TEX(i), s->bo, s->offset, bo_flags); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_WRAP(i), 1); - OUT_RING(chan, tx_wrap); + BEGIN_NV04(push, NV20_3D(TEX_WRAP(i)), 1); + PUSH_DATA (push, tx_wrap); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_FILTER(i), 1); - OUT_RING(chan, tx_filter); + BEGIN_NV04(push, NV20_3D(TEX_FILTER(i)), 1); + PUSH_DATA (push, tx_filter); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1); - OUT_RING(chan, tx_enable); + BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, tx_enable); context_dirty(ctx, TEX_SHADER); } @@ -250,18 +258,17 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit) void nv20_emit_tex_shader(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); uint32_t tx_shader_op = 0; int i; for (i = 0; i < NV20_TEXTURE_UNITS; i++) { - if (!ctx->Texture.Unit[i]._ReallyEnabled) + if (!ctx->Texture.Unit[i]._Current) continue; tx_shader_op |= NV20_3D_TEX_SHADER_OP_TX0_TEXTURE_2D << 5 * i; } - BEGIN_RING(chan, kelvin, NV20_3D_TEX_SHADER_OP, 1); - OUT_RING(chan, tx_shader_op); + BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1); + PUSH_DATA (push, tx_shader_op); }