diff options
47 files changed, 1846 insertions, 1891 deletions
diff --git a/configure.ac b/configure.ac index 17564f12885..8259253d401 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.24 LIBDRM_RADEON_REQUIRED=2.4.31 LIBDRM_INTEL_REQUIRED=2.4.32 +LIBDRM_NVVIEUX_REQUIRED=2.4.33 LIBDRM_NOUVEAU_REQUIRED=0.6 DRI2PROTO_REQUIRED=2.6 GLPROTO_REQUIRED=1.4.14 @@ -1274,7 +1275,7 @@ esac case $DRI_DIRS in *nouveau*) - PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED]) + PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NVVIEUX_REQUIRED]) HAVE_NOUVEAU_DRI=yes; ;; esac diff --git a/src/mesa/drivers/dri/nouveau/Makefile.sources b/src/mesa/drivers/dri/nouveau/Makefile.sources index aa7f79f7eb4..59b15b3fc2d 100644 --- a/src/mesa/drivers/dri/nouveau/Makefile.sources +++ b/src/mesa/drivers/dri/nouveau/Makefile.sources @@ -6,7 +6,6 @@ NOUVEAU_DRIVER_FILES = \ nouveau_state.c \ nouveau_bufferobj.c \ nouveau_span.c \ - nouveau_bo_state.c \ nouveau_texture.c \ nouveau_surface.c \ nouveau_scratch.c \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_array.c b/src/mesa/drivers/dri/nouveau/nouveau_array.c index d9253b010ff..b77932f9c9c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_array.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_array.c @@ -28,6 +28,7 @@ #include "nouveau_driver.h" #include "nouveau_array.h" #include "nouveau_bufferobj.h" +#include "nouveau_context.h" #define EXTRACT(in_t, out_t) extract_func_##in_t##_to_##out_t @@ -98,8 +99,10 @@ get_array_extract(struct nouveau_array *a, extract_u_t *extract_u, void nouveau_init_array(struct nouveau_array *a, int attr, int stride, int fields, int type, struct gl_buffer_object *obj, - const void *ptr, GLboolean map) + const void *ptr, GLboolean map, struct gl_context *ctx) { + struct nouveau_client *client = context_client(ctx); + a->attr = attr; a->stride = stride; a->fields = fields; @@ -115,7 +118,7 @@ nouveau_init_array(struct nouveau_array *a, int attr, int stride, a->offset = (intptr_t)ptr; if (map) { - nouveau_bo_map(a->bo, NOUVEAU_BO_RD); + nouveau_bo_map(a->bo, NOUVEAU_BO_RD, client); a->buf = a->bo->map + a->offset; } @@ -136,11 +139,6 @@ nouveau_init_array(struct nouveau_array *a, int attr, int stride, void nouveau_deinit_array(struct nouveau_array *a) { - if (a->bo) { - if (a->bo->map) - nouveau_bo_unmap(a->bo); - } - a->buf = NULL; a->fields = 0; } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_array.h b/src/mesa/drivers/dri/nouveau/nouveau_array.h index ad3d69b33d9..8df0785faf2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_array.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_array.h @@ -47,7 +47,7 @@ struct nouveau_array { void nouveau_init_array(struct nouveau_array *a, int attr, int stride, int fields, int type, struct gl_buffer_object *obj, - const void *ptr, GLboolean map); + const void *ptr, GLboolean map, struct gl_context *ctx); void nouveau_deinit_array(struct nouveau_array *a); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bo_state.c b/src/mesa/drivers/dri/nouveau/nouveau_bo_state.c deleted file mode 100644 index 7eef8c1ee81..00000000000 --- a/src/mesa/drivers/dri/nouveau/nouveau_bo_state.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2009 Francisco Jerez. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include "nouveau_driver.h" -#include "nouveau_context.h" - -static GLboolean -nouveau_bo_marker_emit(struct gl_context *ctx, struct nouveau_bo_marker *m, - uint32_t flags) -{ - struct nouveau_channel *chan = context_chan(ctx); - uint32_t packet; - - if (m->gr->bound == NOUVEAU_GROBJ_UNBOUND) - nouveau_grobj_autobind(m->gr); - - if (MARK_RING(chan, 2, 2)) - return GL_FALSE; - - packet = (m->gr->subc << 13) | (1 << 18) | m->mthd; - - if (flags) { - if (nouveau_pushbuf_emit_reloc(chan, chan->cur++, m->bo, - packet, 0, flags | - (m->flags & (NOUVEAU_BO_VRAM | - NOUVEAU_BO_GART | - NOUVEAU_BO_RDWR)), - 0, 0)) - goto fail; - } else { - *(chan->cur++) = packet; - } - - if (nouveau_pushbuf_emit_reloc(chan, chan->cur++, m->bo, m->data, - m->data2, flags | m->flags, - m->vor, m->tor)) - goto fail; - - return GL_TRUE; - -fail: - MARK_UNDO(chan); - return GL_FALSE; -} - -static GLboolean -nouveau_bo_context_grow(struct nouveau_bo_context *bctx) -{ - struct nouveau_bo_marker *marker = bctx->marker; - int allocated = bctx->allocated + 1; - - marker = realloc(marker, allocated * sizeof(struct nouveau_bo_marker)); - if (!marker) - return GL_FALSE; - - bctx->marker = marker; - bctx->allocated = allocated; - - return GL_TRUE; -} - -GLboolean -nouveau_bo_mark(struct nouveau_bo_context *bctx, struct nouveau_grobj *gr, - uint32_t mthd, struct nouveau_bo *bo, - uint32_t data, uint32_t data2, uint32_t vor, uint32_t tor, - uint32_t flags) -{ - struct nouveau_bo_state *s = &to_nouveau_context(bctx->ctx)->bo; - struct nouveau_bo_marker *m; - - if (bctx->count == bctx->allocated) { - if (!nouveau_bo_context_grow(bctx)) - goto fail; - } - - m = &bctx->marker[bctx->count]; - - *m = (struct nouveau_bo_marker) { - .gr = gr, - .mthd = mthd, - .data = data, - .data2 = data2, - .vor = vor, - .tor = tor, - .flags = flags, - }; - nouveau_bo_ref(bo, &m->bo); - - s->count++; - bctx->count++; - - if (!nouveau_bo_marker_emit(bctx->ctx, m, 0)) - goto fail; - - return GL_TRUE; - -fail: - nouveau_bo_context_reset(bctx); - return GL_FALSE; -} - -void -nouveau_bo_context_reset(struct nouveau_bo_context *bctx) -{ - struct nouveau_bo_state *s = &to_nouveau_context(bctx->ctx)->bo; - int i, n = bctx->count; - - s->count -= n; - bctx->count = 0; - - for (i = 0; i < n; i++) - nouveau_bo_ref(NULL, &bctx->marker[i].bo); -} - -GLboolean -nouveau_bo_state_emit(struct gl_context *ctx) -{ - struct nouveau_bo_state *s = &to_nouveau_context(ctx)->bo; - int i, j; - - for (i = 0; i < NUM_NOUVEAU_BO_CONTEXT; i++) { - struct nouveau_bo_context *bctx = &s->context[i]; - - for (j = 0; j < bctx->count; j++) { - if (!nouveau_bo_marker_emit(ctx, &bctx->marker[j], - NOUVEAU_BO_DUMMY)) - return GL_FALSE; - } - } - - return GL_TRUE; -} - -void -nouveau_bo_state_init(struct gl_context *ctx) -{ - struct nouveau_bo_state *s = &to_nouveau_context(ctx)->bo; - int i; - - for (i = 0; i < NUM_NOUVEAU_BO_CONTEXT; i++) - s->context[i].ctx = ctx; -} - -void -nouveau_bo_state_destroy(struct gl_context *ctx) -{ - struct nouveau_bo_state *s = &to_nouveau_context(ctx)->bo; - int i, j; - - for (i = 0; i < NUM_NOUVEAU_BO_CONTEXT; i++) { - struct nouveau_bo_context *bctx = &s->context[i]; - - for (j = 0; j < bctx->count; j++) - nouveau_bo_ref(NULL, &bctx->marker[j].bo); - - if (bctx->marker) - free(bctx->marker); - } -} diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bo_state.h b/src/mesa/drivers/dri/nouveau/nouveau_bo_state.h deleted file mode 100644 index 388a16a56ea..00000000000 --- a/src/mesa/drivers/dri/nouveau/nouveau_bo_state.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2009 Francisco Jerez. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef __NOUVEAU_BO_STATE_H__ -#define __NOUVEAU_BO_STATE_H__ - -enum { - NOUVEAU_BO_CONTEXT_FRAMEBUFFER = 0, - NOUVEAU_BO_CONTEXT_HIERZ, - NOUVEAU_BO_CONTEXT_SURFACE, - NOUVEAU_BO_CONTEXT_TEXTURE0, - NOUVEAU_BO_CONTEXT_TEXTURE1, - NOUVEAU_BO_CONTEXT_TEXTURE2, - NOUVEAU_BO_CONTEXT_TEXTURE3, - NOUVEAU_BO_CONTEXT_VERTEX, - NUM_NOUVEAU_BO_CONTEXT -}; - -struct nouveau_bo_marker { - struct nouveau_grobj *gr; - uint32_t mthd; - - struct nouveau_bo *bo; - uint32_t data; - uint32_t data2; - uint32_t vor; - uint32_t tor; - uint32_t flags; -}; - -struct nouveau_bo_context { - struct gl_context *ctx; - - struct nouveau_bo_marker *marker; - int allocated; - int count; -}; - -struct nouveau_bo_state { - struct nouveau_bo_context context[NUM_NOUVEAU_BO_CONTEXT]; - int count; -}; - -GLboolean -nouveau_bo_mark(struct nouveau_bo_context *bctx, struct nouveau_grobj *gr, - uint32_t mthd, struct nouveau_bo *bo, - uint32_t data, uint32_t data2, uint32_t vor, uint32_t tor, - uint32_t flags); - -#define nouveau_bo_markl(bctx, gr, mthd, bo, data, flags) \ - nouveau_bo_mark(bctx, gr, mthd, bo, data, 0, 0, 0, \ - flags | NOUVEAU_BO_LOW); - -#define nouveau_bo_marko(bctx, gr, mthd, bo, flags) \ - nouveau_bo_mark(bctx, gr, mthd, bo, 0, 0, \ - context_chan(ctx)->vram->handle, \ - context_chan(ctx)->gart->handle, \ - flags | NOUVEAU_BO_OR); - -void -nouveau_bo_context_reset(struct nouveau_bo_context *bctx); - -GLboolean -nouveau_bo_state_emit(struct gl_context *ctx); - -void -nouveau_bo_state_init(struct gl_context *ctx); - -void -nouveau_bo_state_destroy(struct gl_context *ctx); - -#define __context_bctx(ctx, i) \ - ({ \ - struct nouveau_context *nctx = to_nouveau_context(ctx); \ - struct nouveau_bo_context *bctx = &nctx->bo.context[i]; \ - nouveau_bo_context_reset(bctx); \ - bctx; \ - }) -#define context_bctx(ctx, s) \ - __context_bctx(ctx, NOUVEAU_BO_CONTEXT_##s) -#define context_bctx_i(ctx, s, i) \ - __context_bctx(ctx, NOUVEAU_BO_CONTEXT_##s##0 + (i)) - -#endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c index f7ad895ac9a..17827146522 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c @@ -31,7 +31,8 @@ #include "main/bufferobj.h" static inline char * -get_bufferobj_map(struct gl_buffer_object *obj, unsigned flags) +get_bufferobj_map(struct gl_context *ctx, struct gl_buffer_object *obj, + unsigned flags) { struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj); void *map = NULL; @@ -39,9 +40,8 @@ get_bufferobj_map(struct gl_buffer_object *obj, unsigned flags) if (nbo->sys) { map = nbo->sys; } else if (nbo->bo) { - nouveau_bo_map(nbo->bo, flags); + nouveau_bo_map(nbo->bo, flags, context_client(ctx)); map = nbo->bo->map; - nouveau_bo_unmap(nbo->bo); } return map; @@ -96,12 +96,12 @@ nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size /* Get a hardware BO */ ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, - size, &nbo->bo); + size, NULL, &nbo->bo); assert(!ret); } if (data) - memcpy(get_bufferobj_map(obj, NOUVEAU_BO_WR), data, size); + memcpy(get_bufferobj_map(ctx, obj, NOUVEAU_BO_WR), data, size); return GL_TRUE; } @@ -111,7 +111,7 @@ nouveau_bufferobj_subdata(struct gl_context *ctx, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data, struct gl_buffer_object *obj) { - memcpy(get_bufferobj_map(obj, NOUVEAU_BO_WR) + offset, data, size); + memcpy(get_bufferobj_map(ctx, obj, NOUVEAU_BO_WR) + offset, data, size); } static void @@ -119,7 +119,7 @@ nouveau_bufferobj_get_subdata(struct gl_context *ctx, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data, struct gl_buffer_object *obj) { - memcpy(data, get_bufferobj_map(obj, NOUVEAU_BO_RD) + offset, size); + memcpy(data, get_bufferobj_map(ctx, obj, NOUVEAU_BO_RD) + offset, size); } static void * @@ -132,14 +132,14 @@ nouveau_bufferobj_map_range(struct gl_context *ctx, GLintptr offset, assert(!obj->Pointer); - if (access & GL_MAP_READ_BIT) - flags |= NOUVEAU_BO_RD; - if (access & GL_MAP_WRITE_BIT) - flags |= NOUVEAU_BO_WR; - if (access & GL_MAP_UNSYNCHRONIZED_BIT) - flags |= NOUVEAU_BO_NOSYNC; + if (!(access & GL_MAP_UNSYNCHRONIZED_BIT)) { + if (access & GL_MAP_READ_BIT) + flags |= NOUVEAU_BO_RD; + if (access & GL_MAP_WRITE_BIT) + flags |= NOUVEAU_BO_WR; + } - map = get_bufferobj_map(obj, flags); + map = get_bufferobj_map(ctx, obj, flags); if (!map) return NULL; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 0cb918e4111..48457675fc8 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -29,6 +29,7 @@ #include "nouveau_context.h" #include "nouveau_bufferobj.h" #include "nouveau_fbo.h" +#include "nv_object.xml.h" #include "main/dd.h" #include "main/framebuffer.h" @@ -43,16 +44,6 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" -static void -nouveau_channel_flush_notify(struct nouveau_channel *chan) -{ - struct nouveau_context *nctx = chan->user_private; - struct gl_context *ctx = &nctx->base; - - if (nctx->fallback < SWRAST) - nouveau_bo_state_emit(ctx); -} - GLboolean nouveau_context_create(gl_api api, const struct gl_config *visual, __DRIcontext *dri_ctx, @@ -118,7 +109,6 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen, share_ctx, &functions, NULL); nouveau_state_init(ctx); - nouveau_bo_state_init(ctx); nouveau_scratch_init(ctx); _mesa_meta_init(ctx); _swrast_CreateContext(ctx); @@ -128,15 +118,48 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen, _mesa_allow_light_in_model(ctx, GL_FALSE); /* Allocate a hardware channel. */ - ret = nouveau_channel_alloc(context_dev(ctx), 0xbeef0201, 0xbeef0202, - 512*1024, &nctx->hw.chan); + ret = nouveau_object_new(&context_dev(ctx)->object, 0xbeef0000, + NOUVEAU_FIFO_CHANNEL_CLASS, + &(struct nv04_fifo){ + .vram = 0xbeef0201, + .gart = 0xbeef0202 + }, sizeof(struct nv04_fifo), &nctx->hw.chan); if (ret) { nouveau_error("Error initializing the FIFO.\n"); return GL_FALSE; } - nctx->hw.chan->flush_notify = nouveau_channel_flush_notify; - nctx->hw.chan->user_private = nctx; + /* Allocate a client (thread data) */ + ret = nouveau_client_new(context_dev(ctx), &nctx->hw.client); + if (ret) { + nouveau_error("Error creating thread data\n"); + return GL_FALSE; + } + + /* Allocate a push buffer */ + ret = nouveau_pushbuf_new(nctx->hw.client, nctx->hw.chan, 4, + 512 * 1024, true, &nctx->hw.pushbuf); + if (ret) { + nouveau_error("Error allocating DMA push buffer\n"); + return GL_FALSE; + } + + /* Allocate buffer context */ + ret = nouveau_bufctx_new(nctx->hw.client, 16, &nctx->hw.bufctx); + if (ret) { + nouveau_error("Error allocating buffer context\n"); + return GL_FALSE; + } + + nctx->hw.pushbuf->user_priv = nctx->hw.bufctx; + + /* Allocate NULL object */ + ret = nouveau_object_new(nctx->hw.chan, 0x00000000, NV01_NULL_CLASS, + NULL, 0, &nctx->hw.null); + if (ret) { + nouveau_error("Error allocating NULL object\n"); + return GL_FALSE; + } /* Enable any supported extensions. */ ctx->Extensions.EXT_blend_color = true; @@ -170,11 +193,12 @@ nouveau_context_deinit(struct gl_context *ctx) if (ctx->Meta) _mesa_meta_free(ctx); - if (nctx->hw.chan) - nouveau_channel_free(&nctx->hw.chan); + nouveau_bufctx_del(&nctx->hw.bufctx); + nouveau_pushbuf_del(&nctx->hw.pushbuf); + nouveau_client_del(&nctx->hw.client); + nouveau_object_del(&nctx->hw.chan); nouveau_scratch_destroy(ctx); - nouveau_bo_state_destroy(ctx); _mesa_free_context_data(ctx); } @@ -254,7 +278,7 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw) s->cpp = buffers[i].cpp; if (index == BUFFER_DEPTH && s->bo) { - ret = nouveau_bo_handle_get(s->bo, &old_name); + ret = nouveau_bo_name_get(s->bo, &old_name); /* * Disable fast Z clears in the next frame, the * depth buffer contents are undefined. @@ -264,8 +288,8 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw) } nouveau_bo_ref(NULL, &s->bo); - ret = nouveau_bo_handle_ref(context_dev(ctx), - buffers[i].name, &s->bo); + ret = nouveau_bo_name_ref(context_dev(ctx), + buffers[i].name, &s->bo); assert(!ret); } @@ -286,8 +310,8 @@ update_framebuffer(__DRIcontext *dri_ctx, __DRIdrawable *draw, /* Clean up references to the old framebuffer objects. */ context_dirty(ctx, FRAMEBUFFER); - context_bctx(ctx, FRAMEBUFFER); - FIRE_RING(context_chan(ctx)); + nouveau_bufctx_reset(to_nouveau_context(ctx)->hw.bufctx, BUFCTX_FB); + PUSH_KICK(context_push(ctx)); } GLboolean @@ -338,9 +362,11 @@ nouveau_fallback(struct gl_context *ctx, enum nouveau_fallback mode) if (mode < SWRAST) { nouveau_state_emit(ctx); +#if 0 nouveau_bo_state_emit(ctx); +#endif } else { - FIRE_RING(context_chan(ctx)); + PUSH_KICK(context_push(ctx)); } } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index cd4a9fbc0ff..8bba51e8091 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -29,7 +29,6 @@ #include "nouveau_screen.h" #include "nouveau_state.h" -#include "nouveau_bo_state.h" #include "nouveau_scratch.h" #include "nouveau_render.h" @@ -41,20 +40,28 @@ enum nouveau_fallback { SWRAST, }; +#define BUFCTX_FB 0 +#define BUFCTX_VTX 1 +#define BUFCTX_TEX(i) (2 + (i)) + struct nouveau_hw_state { - struct nouveau_channel *chan; - - struct nouveau_notifier *ntfy; - struct nouveau_grobj *eng3d; - struct nouveau_grobj *eng3dm; - struct nouveau_grobj *surf3d; - struct nouveau_grobj *m2mf; - struct nouveau_grobj *surf2d; - struct nouveau_grobj *rop; - struct nouveau_grobj *patt; - struct nouveau_grobj *rect; - struct nouveau_grobj *swzsurf; - struct nouveau_grobj *sifm; + struct nouveau_object *chan; + struct nouveau_client *client; + struct nouveau_pushbuf *pushbuf; + struct nouveau_bufctx *bufctx; + + struct nouveau_object *null; + struct nouveau_object *ntfy; + struct nouveau_object *eng3d; + struct nouveau_object *eng3dm; + struct nouveau_object *surf3d; + struct nouveau_object *m2mf; + struct nouveau_object *surf2d; + struct nouveau_object *rop; + struct nouveau_object *patt; + struct nouveau_object *rect; + struct nouveau_object *swzsurf; + struct nouveau_object *sifm; }; struct nouveau_context { @@ -66,7 +73,6 @@ struct nouveau_context { enum nouveau_fallback fallback; struct nouveau_hw_state hw; - struct nouveau_bo_state bo; struct nouveau_render_state render; struct nouveau_scratch_state scratch; @@ -84,6 +90,10 @@ struct nouveau_context { (context_dev(ctx)->chipset) #define context_chan(ctx) \ (to_nouveau_context(ctx)->hw.chan) +#define context_client(ctx) \ + (to_nouveau_context(ctx)->hw.client) +#define context_push(ctx) \ + (to_nouveau_context(ctx)->hw.pushbuf) #define context_eng3d(ctx) \ (to_nouveau_context(ctx)->hw.eng3d) #define context_drv(ctx) \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index ba818f0030e..7222f68b439 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -57,9 +57,9 @@ static void nouveau_flush(struct gl_context *ctx) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - FIRE_RING(chan); + PUSH_KICK(push); if (ctx->DrawBuffer->Name == 0 && ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h index 0018eec021f..e03b2c1f98d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.h @@ -38,15 +38,11 @@ #undef NDEBUG #include <assert.h> -#include "nouveau_device.h" -#include "nouveau_grobj.h" -#include "nouveau_channel.h" -#include "nouveau_bo.h" -#include "nouveau_notifier.h" +#include <libdrm/nouveau.h> #include "nouveau_screen.h" #include "nouveau_state.h" #include "nouveau_surface.h" -#include "nv04_pushbuf.h" +#include "nouveau_local.h" #define DRIVER_AUTHOR "Nouveau" diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c index 6f4956efe8c..50eb1824354 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c @@ -146,7 +146,7 @@ nouveau_renderbuffer_map(struct gl_context *ctx, if (mode & GL_MAP_WRITE_BIT) flags |= NOUVEAU_BO_WR; - nouveau_bo_map(s->bo, flags); + nouveau_bo_map(s->bo, flags, context_client(ctx)); map = s->bo->map; stride = s->pitch; @@ -167,9 +167,6 @@ static void nouveau_renderbuffer_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb) { - struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface; - - nouveau_bo_unmap(s->bo); } static GLboolean diff --git a/src/mesa/drivers/dri/nouveau/nouveau_local.h b/src/mesa/drivers/dri/nouveau/nouveau_local.h new file mode 100644 index 00000000000..8b3058fa702 --- /dev/null +++ b/src/mesa/drivers/dri/nouveau/nouveau_local.h @@ -0,0 +1,191 @@ +/* + * Copyright 2007 Nouveau Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __NOUVEAU_LOCAL_H__ +#define __NOUVEAU_LOCAL_H__ + +static inline uint32_t +PUSH_AVAIL(struct nouveau_pushbuf *push) +{ + return push->end - push->cur; +} + +static inline int +PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size) +{ + if (PUSH_AVAIL(push) < size) + return nouveau_pushbuf_space(push, size, 0, 0) == 0; + return 1; +} + +static inline void +PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data) +{ + *push->cur++ = data; +} + +static inline void +PUSH_DATAf(struct nouveau_pushbuf *push, float v) +{ + union { float f; uint32_t i; } d = { .f = v }; + PUSH_DATA(push, d.i); +} + +static inline void +PUSH_DATAb(struct nouveau_pushbuf *push, GLboolean x) +{ + PUSH_DATA(push, x ? 1 : 0); +} + +static inline void +PUSH_DATAm(struct nouveau_pushbuf *push, float m[16]) +{ + int i, j; + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + PUSH_DATAf(push, m[4*j + i]); +} + +static inline void +PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size) +{ + memcpy(push->cur, data, size * 4); + push->cur += size; +} + +static inline void +PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset, + uint32_t flags, uint32_t vor, uint32_t tor) +{ + nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor); +} + +static inline void +PUSH_KICK(struct nouveau_pushbuf *push) +{ + nouveau_pushbuf_kick(push, push->channel); +} + +static struct nouveau_bufctx * +BUFCTX(struct nouveau_pushbuf *push) +{ + return push->user_priv; +} + +static inline void +PUSH_RESET(struct nouveau_pushbuf *push, int bin) +{ + nouveau_bufctx_reset(BUFCTX(push), bin); +} + +static inline void +PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd, int bin, + struct nouveau_bo *bo, uint32_t offset, uint32_t access) +{ + nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd, + bo, offset, access | NOUVEAU_BO_LOW, 0, 0); + PUSH_DATA(push, bo->offset + offset); +} + +static inline void +PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd, int bin, + struct nouveau_bo *bo, uint32_t data, uint32_t access, + uint32_t vor, uint32_t tor) +{ + nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd, + bo, data, access | NOUVEAU_BO_OR, vor, tor); + + if (bo->flags & NOUVEAU_BO_VRAM) + PUSH_DATA(push, data | vor); + else + PUSH_DATA(push, data | tor); +} + +static inline void +PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd, int bin, + struct nouveau_bo *bo, uint32_t data, uint32_t access, + uint32_t vor, uint32_t tor) +{ + nouveau_bufctx_mthd(BUFCTX(push), bin, (1 << 18) | (subc << 13) | mthd, + bo, data, access | NOUVEAU_BO_OR, vor, tor); + + if (access & NOUVEAU_BO_LOW) + data += bo->offset; + + if (access & NOUVEAU_BO_OR) { + if (bo->flags & NOUVEAU_BO_VRAM) + data |= vor; + else + data |= tor; + } + + PUSH_DATA(push, data); +} + +static inline void +BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, int size) +{ + PUSH_SPACE(push, size + 1); + PUSH_DATA (push, 0x00000000 | (size << 18) | (subc << 13) | mthd); +} + +static inline void +BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, int size) +{ + PUSH_SPACE(push, size + 1); + PUSH_DATA (push, 0x40000000 | (size << 18) | (subc << 13) | mthd); +} + +/* subchannel assignment */ +#define SUBC_M2MF(mthd) 0, (mthd) +#define NV03_M2MF(mthd) SUBC_M2MF(NV04_M2MF_##mthd) +#define SUBC_NVSW(mthd) 1, (mthd) +#define SUBC_SF2D(mthd) 2, (mthd) +#define NV04_SF2D(mthd) SUBC_SF2D(NV04_CONTEXT_SURFACES_2D_##mthd) +#define NV10_SF2D(mthd) SUBC_SF2D(NV10_CONTEXT_SURFACES_2D_##mthd) +#define SUBC_PATT(mthd) 3, (mthd) +#define NV01_PATT(mthd) SUBC_PATT(NV04_IMAGE_PATTERN_##mthd) +#define NV01_ROP(mthd) SUBC_PATT(NV03_CONTEXT_ROP_##mthd) +#define SUBC_GDI(mthd) 4, (mthd) +#define NV04_GDI(mthd) SUBC_GDI(NV04_GDI_RECTANGLE_TEXT_##mthd) +#define SUBC_SIFM(mthd) 5, (mthd) +#define NV03_SIFM(mthd) SUBC_SIFM(NV03_SCALED_IMAGE_FROM_MEMORY_##mthd) +#define NV05_SIFM(mthd) SUBC_SIFM(NV05_SCALED_IMAGE_FROM_MEMORY_##mthd) +#define SUBC_SURF(mthd) 6, (mthd) +#define NV04_SSWZ(mthd) SUBC_SURF(NV04_SWIZZLED_SURFACE_##mthd) +#define NV04_SF3D(mthd) SUBC_SURF(NV04_CONTEXT_SURFACES_3D_##mthd) +#define SUBC_3D(mthd) 7, (mthd) +#define NV04_TTRI(mthd) SUBC_3D(NV04_TEXTURED_TRIANGLE_##mthd) +#define NV04_MTRI(mthd) SUBC_3D(NV04_MULTITEX_TRIANGLE_##mthd) +#define NV10_3D(mthd) SUBC_3D(NV10_3D_##mthd) +#define NV11_3D(mthd) SUBC_3D(NV11_3D_##mthd) +#define NV17_3D(mthd) SUBC_3D(NV17_3D_##mthd) +#define NV20_3D(mthd) SUBC_3D(NV20_3D_##mthd) +#define NV25_3D(mthd) SUBC_3D(NV25_3D_##mthd) + +#define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd)) +#define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd)) + +#define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd)) + +#endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c index 2afc9fafc66..0063dac2d78 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c @@ -101,7 +101,7 @@ static void dispatch_l(struct gl_context *ctx, unsigned int start, int delta, unsigned int n) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); RENDER_LOCALS(ctx); EMIT_VBO(L, ctx, start, delta, n); @@ -111,7 +111,7 @@ static void dispatch_i32(struct gl_context *ctx, unsigned int start, int delta, unsigned int n) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); RENDER_LOCALS(ctx); EMIT_VBO(I32, ctx, start, delta, n); @@ -121,7 +121,7 @@ static void dispatch_i16(struct gl_context *ctx, unsigned int start, int delta, unsigned int n) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); RENDER_LOCALS(ctx); EMIT_VBO(I32, ctx, start, delta, n & 1); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_scratch.c b/src/mesa/drivers/dri/nouveau/nouveau_scratch.c index ddda67b2f14..b54f90fd775 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_scratch.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_scratch.c @@ -35,6 +35,7 @@ void * nouveau_get_scratch(struct gl_context *ctx, unsigned size, struct nouveau_bo **bo, unsigned *offset) { + struct nouveau_client *client = context_client(ctx); struct nouveau_scratch_state *scratch = &to_nouveau_context(ctx)->scratch; void *buf; @@ -50,20 +51,18 @@ nouveau_get_scratch(struct gl_context *ctx, unsigned size, scratch->index = (scratch->index + 1) % NOUVEAU_SCRATCH_COUNT; nouveau_bo_ref(scratch->bo[scratch->index], bo); - nouveau_bo_map(*bo, NOUVEAU_BO_WR); + nouveau_bo_map(*bo, NOUVEAU_BO_WR, client); buf = scratch->buf = (*bo)->map; - nouveau_bo_unmap(*bo); *offset = 0; scratch->offset = size; } else { - nouveau_bo_new(context_dev(ctx), - NOUVEAU_BO_MAP | NOUVEAU_BO_GART, 0, size, bo); + nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_GART | + NOUVEAU_BO_MAP, 0, size, NULL, bo); - nouveau_bo_map(*bo, NOUVEAU_BO_WR); + nouveau_bo_map(*bo, NOUVEAU_BO_WR, client); buf = (*bo)->map; - nouveau_bo_unmap(*bo); *offset = 0; } @@ -79,9 +78,9 @@ nouveau_scratch_init(struct gl_context *ctx) int ret, i; for (i = 0; i < NOUVEAU_SCRATCH_COUNT; i++) { - ret = nouveau_bo_new(context_dev(ctx), - NOUVEAU_BO_MAP | NOUVEAU_BO_GART, - 0, NOUVEAU_SCRATCH_SIZE, &scratch->bo[i]); + ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_GART | + NOUVEAU_BO_MAP, 0, NOUVEAU_SCRATCH_SIZE, + NULL, &scratch->bo[i]); assert(!ret); } } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 424dfdc1993..7e51b94a2ff 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -28,7 +28,6 @@ #include "nouveau_context.h" #include "nouveau_fbo.h" #include "nouveau_texture.h" -#include "nouveau_drmif.h" #include "nv04_driver.h" #include "nv10_driver.h" #include "nv20_driver.h" @@ -103,8 +102,7 @@ nouveau_init_screen2(__DRIscreen *dri_screen) screen->dri_screen = dri_screen; /* Open the DRM device. */ - ret = nouveau_device_open_existing(&screen->device, 0, dri_screen->fd, - 0); + ret = nouveau_device_wrap(dri_screen->fd, 0, &screen->device); if (ret) { nouveau_error("Error opening the DRM device.\n"); goto fail; @@ -144,8 +142,7 @@ nouveau_destroy_screen(__DRIscreen *dri_screen) if (!screen) return; - if (screen->device) - nouveau_device_close(&screen->device); + nouveau_device_del(&screen->device); FREE(screen); dri_screen->driverPrivate = NULL; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index eb478b7ed88..77a150773d1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -27,7 +27,6 @@ #include "nouveau_driver.h" #include "nouveau_fbo.h" #include "nouveau_context.h" -#include "nouveau_bo.h" #include "swrast/swrast.h" #include "swrast/s_context.h" @@ -35,29 +34,27 @@ static void -renderbuffer_map_unmap(struct gl_renderbuffer *rb, GLboolean map) +renderbuffer_map_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLboolean map) { struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface; - if (map) { - nouveau_bo_map(s->bo, NOUVEAU_BO_RDWR); - } else { - nouveau_bo_unmap(s->bo); - } + if (map) + nouveau_bo_map(s->bo, NOUVEAU_BO_RDWR, context_client(ctx)); } static void -framebuffer_map_unmap(struct gl_framebuffer *fb, GLboolean map) +framebuffer_map_unmap(struct gl_context *ctx, struct gl_framebuffer *fb, GLboolean map) { int i; for (i = 0; i < fb->_NumColorDrawBuffers; i++) - renderbuffer_map_unmap(fb->_ColorDrawBuffers[i], map); + renderbuffer_map_unmap(ctx, fb->_ColorDrawBuffers[i], map); - renderbuffer_map_unmap(fb->_ColorReadBuffer, map); + renderbuffer_map_unmap(ctx, fb->_ColorReadBuffer, map); if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) - renderbuffer_map_unmap(fb->Attachment[BUFFER_DEPTH].Renderbuffer, map); + renderbuffer_map_unmap(ctx, fb->Attachment[BUFFER_DEPTH].Renderbuffer, map); } static void @@ -65,10 +62,10 @@ span_map_unmap(struct gl_context *ctx, GLboolean map) { int i; - framebuffer_map_unmap(ctx->DrawBuffer, map); + framebuffer_map_unmap(ctx, ctx->DrawBuffer, map); if (ctx->ReadBuffer != ctx->DrawBuffer) - framebuffer_map_unmap(ctx->ReadBuffer, map); + framebuffer_map_unmap(ctx, ctx->ReadBuffer, map); for (i = 0; i < ctx->Const.MaxTextureUnits; i++) if (map) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_surface.c b/src/mesa/drivers/dri/nouveau/nouveau_surface.c index e6a712095c6..f2521149088 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_surface.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_surface.c @@ -34,7 +34,7 @@ nouveau_surface_alloc(struct gl_context *ctx, struct nouveau_surface *s, unsigned flags, unsigned format, unsigned width, unsigned height) { - unsigned tile_mode = 0, tile_flags = 0; + union nouveau_bo_config config = {}; int ret, cpp = _mesa_get_format_bytes(format); nouveau_bo_ref(NULL, &s->bo); @@ -50,22 +50,22 @@ nouveau_surface_alloc(struct gl_context *ctx, struct nouveau_surface *s, if (layout == TILED) { s->pitch = align(s->pitch, 256); - tile_mode = s->pitch; + config.nv04.surf_pitch = s->pitch; if (cpp == 4) - tile_flags = NOUVEAU_BO_TILE_32BPP; + config.nv04.surf_flags = NV04_BO_32BPP; else if (cpp == 2) - tile_flags = NOUVEAU_BO_TILE_16BPP; + config.nv04.surf_flags = NV04_BO_16BPP; if (_mesa_get_format_bits(format, GL_DEPTH_BITS)) - tile_flags |= NOUVEAU_BO_TILE_ZETA; + config.nv04.surf_flags |= NV04_BO_ZETA; } else { s->pitch = align(s->pitch, 64); } - ret = nouveau_bo_new_tile(context_dev(ctx), flags, 0, s->pitch * height, - tile_mode, tile_flags, &s->bo); + ret = nouveau_bo_new(context_dev(ctx), flags, 0, s->pitch * height, + &config, &s->bo); assert(!ret); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c index 26c4c7ee2d7..0753c3a0019 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c @@ -185,6 +185,8 @@ swtnl_unbind_vertices(struct gl_context *ctx) struct nouveau_render_state *render = to_render_state(ctx); int i, attr; + TAG(render_release_vertices)(ctx); + FOR_EACH_BOUND_ATTR(render, i, attr) { nouveau_bo_ref(NULL, &render->attrs[attr].bo); render->map[i] = -1; @@ -196,28 +198,28 @@ swtnl_unbind_vertices(struct gl_context *ctx) static void swtnl_flush_vertices(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl; - unsigned push, start = 0, count = swtnl->vertex_count; + unsigned npush, start = 0, count = swtnl->vertex_count; RENDER_LOCALS(ctx); swtnl_bind_vertices(ctx); while (count) { - push = get_max_vertices(ctx, NULL, AVAIL_RING(chan)); - push = MIN2(push / 12 * 12, count); - count -= push; + npush = get_max_vertices(ctx, NULL, PUSH_AVAIL(push)); + npush = MIN2(npush / 12 * 12, count); + count -= npush; - if (!push) { - FIRE_RING(chan); + if (!npush) { + PUSH_KICK(push); continue; } BATCH_BEGIN(nvgl_primitive(swtnl->primitive)); - EMIT_VBO(L, ctx, start, 0, push); + EMIT_VBO(L, ctx, start, 0, npush); BATCH_END(); - FIRE_RING(chan); + PUSH_KICK(push); } swtnl_alloc_vertices(ctx); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 66c3cb25188..eadbeb45d7a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -86,10 +86,11 @@ nouveau_teximage_map(struct gl_context *ctx, struct gl_texture_image *ti, struct nouveau_teximage *nti = to_nouveau_teximage(ti); struct nouveau_surface *s = &nti->surface; struct nouveau_surface *st = &nti->transfer.surface; + struct nouveau_client *client = context_client(ctx); if (s->bo) { if (!(access & GL_MAP_READ_BIT) && - nouveau_bo_pending(s->bo)) { + nouveau_pushbuf_refd(context_push(ctx), s->bo)) { /* * Heuristic: use a bounce buffer to pipeline * teximage transfers. @@ -115,7 +116,7 @@ nouveau_teximage_map(struct gl_context *ctx, struct gl_texture_image *ti, flags |= NOUVEAU_BO_WR; if (!s->bo->map) { - ret = nouveau_bo_map(s->bo, flags); + ret = nouveau_bo_map(s->bo, flags, client); assert(!ret); } @@ -137,10 +138,7 @@ nouveau_teximage_unmap(struct gl_context *ctx, struct gl_texture_image *ti) st->width, st->height); nouveau_surface_ref(NULL, st); - } else if (s->bo) { - nouveau_bo_unmap(s->bo); } - nti->base.Map = NULL; } @@ -157,13 +155,14 @@ nouveau_map_texture_image(struct gl_context *ctx, struct nouveau_teximage *nti = to_nouveau_teximage(ti); struct nouveau_surface *s = &nti->surface; struct nouveau_surface *st = &nti->transfer.surface; + struct nouveau_client *client = context_client(ctx); /* Nouveau has no support for 3D or cubemap textures. */ assert(slice == 0); if (s->bo) { if (!(mode & GL_MAP_READ_BIT) && - nouveau_bo_pending(s->bo)) { + nouveau_pushbuf_refd(context_push(ctx), s->bo)) { /* * Heuristic: use a bounce buffer to pipeline * teximage transfers. @@ -189,7 +188,7 @@ nouveau_map_texture_image(struct gl_context *ctx, flags |= NOUVEAU_BO_WR; if (!s->bo->map) { - ret = nouveau_bo_map(s->bo, flags); + ret = nouveau_bo_map(s->bo, flags, client); assert(!ret); } @@ -216,8 +215,6 @@ nouveau_unmap_texture_image(struct gl_context *ctx, struct gl_texture_image *ti, st->width, st->height); nouveau_surface_ref(NULL, st); - } else if (s->bo) { - nouveau_bo_unmap(s->bo); } nti->base.Map = NULL; @@ -392,7 +389,7 @@ relayout_texture(struct gl_context *ctx, struct gl_texture_object *t) ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_MAP | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM, - 0, size, &ss[last].bo); + 0, size, NULL, &ss[last].bo); assert(!ret); for (i = t->BaseLevel; i < last; i++) @@ -421,7 +418,7 @@ nouveau_texture_validate(struct gl_context *ctx, struct gl_texture_object *t) s->width, s->height, 1); } - FIRE_RING(context_chan(ctx)); + PUSH_KICK(context_push(ctx)); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h index 63566a63abc..d4cc5c4fb9c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h @@ -171,22 +171,6 @@ get_viewport_translate(struct gl_context *ctx, float a[4]) a[2] = fb->_DepthMaxF * (vp->Far + vp->Near) / 2; } -static inline void -OUT_RINGb(struct nouveau_channel *chan, GLboolean x) -{ - OUT_RING(chan, x ? 1 : 0); -} - -static inline void -OUT_RINGm(struct nouveau_channel *chan, float m[16]) -{ - int i, j; - - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - OUT_RINGf(chan, m[4*j + i]); -} - static inline GLboolean is_color_operand(int op) { diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index 59f1542e293..62fee2e1e27 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -24,6 +24,7 @@ * */ +#include "nouveau_driver.h" #include "nouveau_bufferobj.h" #include "nouveau_util.h" @@ -59,7 +60,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, if (ib) nouveau_init_array(&render->ib, 0, 0, ib->count, ib->type, - ib->obj, ib->ptr, GL_TRUE); + ib->obj, ib->ptr, GL_TRUE, ctx); FOR_EACH_BOUND_ATTR(render, i, attr) { const struct gl_client_array *array = arrays[attr]; @@ -68,7 +69,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, get_array_stride(ctx, array), array->Size, array->Type, imm ? array->BufferObj : NULL, - array->Ptr, imm); + array->Ptr, imm, ctx); } } @@ -119,7 +120,7 @@ static void vbo_emit_attr(struct gl_context *ctx, const struct gl_client_array **arrays, int attr) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_render_state *render = to_render_state(ctx); const struct gl_client_array *array = arrays[attr]; struct nouveau_array *a = &render->attrs[attr]; @@ -133,7 +134,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_client_array **arrays, /* Constant attribute. */ nouveau_init_array(a, attr, array->StrideB, array->Size, array->Type, array->BufferObj, array->Ptr, - GL_TRUE); + GL_TRUE, ctx); EMIT_IMM(ctx, a, 0); nouveau_deinit_array(a); @@ -230,7 +231,8 @@ vbo_maybe_split(struct gl_context *ctx, const struct gl_client_array **arrays, { struct nouveau_context *nctx = to_nouveau_context(ctx); struct nouveau_render_state *render = to_render_state(ctx); - unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * (nctx->bo.count + + struct nouveau_bufctx *bufctx = nctx->hw.bufctx; + unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * (bufctx->relocs + render->attr_count), vert_avail = get_max_vertices(ctx, NULL, pushbuf_avail), idx_avail = get_max_vertices(ctx, ib, pushbuf_avail); @@ -286,7 +288,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_client_array **arrays, int base, unsigned min_index, unsigned max_index, int *pdelta) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_bo *bo[NUM_VERTEX_ATTRS]; unsigned offset[NUM_VERTEX_ATTRS]; GLboolean dirty = GL_FALSE; @@ -338,8 +340,8 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_client_array **arrays, a->bo = bo[i]; } + TAG(render_release_vertices)(ctx); TAG(render_bind_vertices)(ctx); - } else { /* Just cleanup. */ FOR_EACH_BOUND_ATTR(render, i, attr) @@ -355,7 +357,8 @@ vbo_draw_vbo(struct gl_context *ctx, const struct gl_client_array **arrays, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_pushbuf *push = context_push(ctx); dispatch_t dispatch = get_array_dispatch(&to_render_state(ctx)->ib); int i, delta = 0, basevertex = 0; RENDER_LOCALS(ctx); @@ -370,15 +373,24 @@ vbo_draw_vbo(struct gl_context *ctx, const struct gl_client_array **arrays, basevertex = prims[i].basevertex; vbo_bind_vertices(ctx, arrays, basevertex, min_index, max_index, &delta); + + nouveau_pushbuf_bufctx(push, nctx->hw.bufctx); + if (nouveau_pushbuf_validate(push)) { + nouveau_pushbuf_bufctx(push, NULL); + return; + } } - if (count > get_max_vertices(ctx, ib, AVAIL_RING(chan))) - WAIT_RING(chan, PUSHBUF_DWORDS); + if (count > get_max_vertices(ctx, ib, PUSH_AVAIL(push))) + PUSH_SPACE(push, PUSHBUF_DWORDS); BATCH_BEGIN(nvgl_primitive(prims[i].mode)); dispatch(ctx, start, delta, count); BATCH_END(); } + + nouveau_pushbuf_bufctx(push, NULL); + TAG(render_release_vertices)(ctx); } /* Immediate rendering path. */ @@ -396,18 +408,25 @@ vbo_draw_imm(struct gl_context *ctx, const struct gl_client_array **arrays, GLuint max_index) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_pushbuf *push = context_push(ctx); extract_u_t extract = ib ? render->ib.extract_u : extract_id; int i, j, k, attr; RENDER_LOCALS(ctx); + nouveau_pushbuf_bufctx(push, nctx->hw.bufctx); + if (nouveau_pushbuf_validate(push)) { + nouveau_pushbuf_bufctx(push, NULL); + return; + } + for (i = 0; i < nr_prims; i++) { unsigned start = prims[i].start, end = start + prims[i].count; if (prims[i].count > get_max_vertices(ctx, ib, - AVAIL_RING(chan))) - WAIT_RING(chan, PUSHBUF_DWORDS); + PUSH_AVAIL(push))) + PUSH_SPACE(push, PUSHBUF_DWORDS); BATCH_BEGIN(nvgl_primitive(prims[i].mode)); @@ -421,6 +440,8 @@ vbo_draw_imm(struct gl_context *ctx, const struct gl_client_array **arrays, BATCH_END(); } + + nouveau_pushbuf_bufctx(push, NULL); } /* draw_prims entry point when we're doing hw-tnl. */ diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 3140af56fdd..921f474ce7e 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -45,12 +45,13 @@ texunit_needs_combiners(struct gl_texture_unit *u) u->EnvMode == GL_ADD; } -struct nouveau_grobj * +struct nouveau_object * nv04_context_engine(struct gl_context *ctx) { struct nv04_context *nctx = to_nv04_context(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *fahrenheit; + struct nouveau_pushbuf *push = context_push(ctx); + struct nouveau_object *fahrenheit; if ((ctx->Texture.Unit[0]._ReallyEnabled && texunit_needs_combiners(&ctx->Texture.Unit[0])) || @@ -67,6 +68,9 @@ nv04_context_engine(struct gl_context *ctx) if (fahrenheit != nctx->eng3d) { nctx->eng3d = fahrenheit; + BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); + PUSH_DATA (push, fahrenheit->handle); + if (nv04_mtex_engine(fahrenheit)) { context_dirty_i(ctx, TEX_ENV, 0); context_dirty_i(ctx, TEX_ENV, 1); @@ -75,7 +79,8 @@ nv04_context_engine(struct gl_context *ctx) context_dirty(ctx, CONTROL); context_dirty(ctx, BLEND); } else { - context_bctx_i(ctx, TEXTURE, 1); + nouveau_bufctx_reset(to_nouveau_context(ctx)->hw. + bufctx, BUFCTX_TEX(1)); context_dirty_i(ctx, TEX_ENV, 0); context_dirty_i(ctx, TEX_OBJ, 0); context_dirty(ctx, CONTROL); @@ -87,52 +92,36 @@ nv04_context_engine(struct gl_context *ctx) } static void -nv04_channel_flush_notify(struct nouveau_channel *chan) -{ - struct nouveau_context *nctx = chan->user_private; - struct gl_context *ctx = &nctx->base; - - if (nctx->fallback < SWRAST) { - nouveau_bo_state_emit(ctx); - - /* Reemit the engine state. */ - context_emit(ctx, TEX_OBJ0); - context_emit(ctx, TEX_OBJ1); - context_emit(ctx, TEX_ENV0); - context_emit(ctx, TEX_ENV1); - context_emit(ctx, CONTROL); - context_emit(ctx, BLEND); - } -} - -static void nv04_hwctx_init(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *surf3d = hw->surf3d; - struct nouveau_grobj *eng3d = hw->eng3d; - struct nouveau_grobj *eng3dm = hw->eng3dm; - - BIND_RING(chan, surf3d, 7); - BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY, 3); - OUT_RING(chan, hw->ntfy->handle); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->vram->handle); - - BEGIN_RING(chan, eng3d, NV04_TEXTURED_TRIANGLE_DMA_NOTIFY, 4); - OUT_RING(chan, hw->ntfy->handle); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->gart->handle); - OUT_RING(chan, surf3d->handle); - - BEGIN_RING(chan, eng3dm, NV04_MULTITEX_TRIANGLE_DMA_NOTIFY, 4); - OUT_RING(chan, hw->ntfy->handle); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->gart->handle); - OUT_RING(chan, surf3d->handle); - - FIRE_RING(chan); + struct nouveau_pushbuf *push = context_push(ctx); + struct nv04_fifo *fifo = hw->chan->data; + + BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1); + PUSH_DATA (push, hw->surf3d->handle); + BEGIN_NV04(push, NV04_SF3D(DMA_NOTIFY), 3); + PUSH_DATA (push, hw->ntfy->handle); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->vram); + + BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); + PUSH_DATA (push, hw->eng3d->handle); + BEGIN_NV04(push, NV04_TTRI(DMA_NOTIFY), 4); + PUSH_DATA (push, hw->ntfy->handle); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->gart); + PUSH_DATA (push, hw->surf3d->handle); + + BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); + PUSH_DATA (push, hw->eng3dm->handle); + BEGIN_NV04(push, NV04_MTRI(DMA_NOTIFY), 4); + PUSH_DATA (push, hw->ntfy->handle); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->gart); + PUSH_DATA (push, hw->surf3d->handle); + + PUSH_KICK (push); } static void @@ -144,9 +133,8 @@ init_dummy_texture(struct gl_context *ctx) NOUVEAU_BO_MAP | NOUVEAU_BO_VRAM, MESA_FORMAT_ARGB8888, 1, 1); - nouveau_bo_map(s->bo, NOUVEAU_BO_WR); + nouveau_bo_map(s->bo, NOUVEAU_BO_WR, context_client(ctx)); *(uint32_t *)s->bo->map = 0xffffffff; - nouveau_bo_unmap(s->bo); } static void @@ -158,9 +146,9 @@ nv04_context_destroy(struct gl_context *ctx) nv04_render_destroy(ctx); nouveau_surface_ref(NULL, &to_nv04_context(ctx)->dummy_texture); - nouveau_grobj_free(&nctx->hw.eng3d); - nouveau_grobj_free(&nctx->hw.eng3dm); - nouveau_grobj_free(&nctx->hw.surf3d); + nouveau_object_del(&nctx->hw.eng3d); + nouveau_object_del(&nctx->hw.eng3dm); + nouveau_object_del(&nctx->hw.surf3d); nouveau_context_deinit(ctx); FREE(ctx); @@ -185,8 +173,6 @@ nv04_context_create(struct nouveau_screen *screen, const struct gl_config *visua if (!nouveau_context_init(ctx, screen, visual, share_ctx)) goto fail; - hw->chan->flush_notify = nv04_channel_flush_notify; - /* GL constants. */ ctx->Const.MaxTextureLevels = 11; ctx->Const.MaxTextureCoordUnits = NV04_TEXTURE_UNITS; @@ -201,18 +187,21 @@ nv04_context_create(struct nouveau_screen *screen, const struct gl_config *visua goto fail; /* 3D engine. */ - ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001, - NV04_TEXTURED_TRIANGLE, &hw->eng3d); + ret = nouveau_object_new(context_chan(ctx), 0xbeef0001, + NV04_TEXTURED_TRIANGLE_CLASS, NULL, 0, + &hw->eng3d); if (ret) goto fail; - ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0002, - NV04_MULTITEX_TRIANGLE, &hw->eng3dm); + ret = nouveau_object_new(context_chan(ctx), 0xbeef0002, + NV04_MULTITEX_TRIANGLE_CLASS, NULL, 0, + &hw->eng3dm); if (ret) goto fail; - ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0003, - NV04_CONTEXT_SURFACES_3D, &hw->surf3d); + ret = nouveau_object_new(context_chan(ctx), 0xbeef0003, + NV04_SURFACE_3D_CLASS, NULL, 0, + &hw->surf3d); if (ret) goto fail; diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.h b/src/mesa/drivers/dri/nouveau/nv04_context.h index 960a6550dce..589aab27b74 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.h +++ b/src/mesa/drivers/dri/nouveau/nv04_context.h @@ -32,15 +32,15 @@ struct nv04_context { struct nouveau_context base; - struct nouveau_grobj *eng3d; + struct nouveau_object *eng3d; struct nouveau_surface dummy_texture; float viewport[16]; }; #define to_nv04_context(ctx) ((struct nv04_context *)(ctx)) -#define nv04_mtex_engine(obj) ((obj)->grclass == NV04_MULTITEX_TRIANGLE) +#define nv04_mtex_engine(obj) ((obj)->oclass == NV04_MULTITEX_TRIANGLE_CLASS) -struct nouveau_grobj * +struct nouveau_object * nv04_context_engine(struct gl_context *ctx); extern const struct nouveau_driver nv04_driver; diff --git a/src/mesa/drivers/dri/nouveau/nv04_render.c b/src/mesa/drivers/dri/nouveau/nv04_render.c index 3061ae5f552..31b18bc0616 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_render.c +++ b/src/mesa/drivers/dri/nouveau/nv04_render.c @@ -71,7 +71,7 @@ static void swtnl_choose_attrs(struct gl_context *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); struct nv04_context *nctx = to_nv04_context(ctx); static struct tnl_attr_map map[NUM_VERTEX_ATTRS]; int n = 0; @@ -96,13 +96,21 @@ swtnl_choose_attrs(struct gl_context *ctx) static void swtnl_start(struct gl_context *ctx) { + struct nouveau_pushbuf *push = context_push(ctx); + + nouveau_pushbuf_bufctx(push, push->user_priv); + nouveau_pushbuf_validate(push); + swtnl_choose_attrs(ctx); } static void swtnl_finish(struct gl_context *ctx) { - FIRE_RING(context_chan(ctx)); + struct nouveau_pushbuf *push = context_push(ctx); + + nouveau_pushbuf_bufctx(push, NULL); + PUSH_KICK(push); } static void @@ -118,31 +126,27 @@ swtnl_reset_stipple(struct gl_context *ctx) /* Primitive rendering */ #define BEGIN_PRIMITIVE(n) \ - struct nouveau_channel *chan = context_chan(ctx); \ - struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); \ + struct nouveau_pushbuf *push = context_push(ctx); \ + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); \ int vertex_len = TNL_CONTEXT(ctx)->clipspace.vertex_size / 4; \ \ if (nv04_mtex_engine(fahrenheit)) \ - BEGIN_RING(chan, fahrenheit, \ - NV04_MULTITEX_TRIANGLE_TLMTVERTEX_SX(0), \ + BEGIN_NV04(push, NV04_MTRI(TLMTVERTEX_SX(0)), \ n * vertex_len); \ else \ - BEGIN_RING(chan, fahrenheit, \ - NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0), \ + BEGIN_NV04(push, NV04_TTRI(TLVERTEX_SX(0)), \ n * vertex_len); \ -#define OUT_VERTEX(i) \ - OUT_RINGp(chan, _tnl_get_vertex(ctx, i), vertex_len); +#define OUT_VERTEX(i) \ + PUSH_DATAp(push, _tnl_get_vertex(ctx, i), vertex_len); #define END_PRIMITIVE(draw) \ if (nv04_mtex_engine(fahrenheit)) { \ - BEGIN_RING(chan, fahrenheit, \ - NV04_MULTITEX_TRIANGLE_DRAWPRIMITIVE(0), 1); \ - OUT_RING(chan, draw); \ + BEGIN_NV04(push, NV04_MTRI(DRAWPRIMITIVE(0)), 1); \ + PUSH_DATA (push, draw); \ } else { \ - BEGIN_RING(chan, fahrenheit, \ - NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), 1); \ - OUT_RING(chan, draw); \ + BEGIN_NV04(push, NV04_TTRI(DRAWPRIMITIVE(0)), 1); \ + PUSH_DATA (push, draw); \ } static void @@ -158,6 +162,13 @@ swtnl_line(struct gl_context *ctx, GLuint v1, GLuint v2) static void swtnl_triangle(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3) { + context_emit(ctx, TEX_OBJ0); + context_emit(ctx, TEX_OBJ1); + context_emit(ctx, TEX_ENV0); + context_emit(ctx, TEX_ENV1); + context_emit(ctx, CONTROL); + context_emit(ctx, BLEND); + BEGIN_PRIMITIVE(3); OUT_VERTEX(v1); OUT_VERTEX(v2); @@ -168,6 +179,13 @@ swtnl_triangle(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3) static void swtnl_quad(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4) { + context_emit(ctx, TEX_OBJ0); + context_emit(ctx, TEX_OBJ1); + context_emit(ctx, TEX_ENV0); + context_emit(ctx, TEX_ENV1); + context_emit(ctx, CONTROL); + context_emit(ctx, BLEND); + BEGIN_PRIMITIVE(4); OUT_VERTEX(v1); OUT_VERTEX(v2); diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c index cc591a32ed1..91bd0518fa1 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c @@ -49,10 +49,7 @@ get_rt_format(gl_format format) void nv04_emit_framebuffer(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *surf3d = hw->surf3d; - struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; uint32_t rt_format = NV04_CONTEXT_SURFACES_3D_FORMAT_TYPE_PITCH; @@ -62,6 +59,8 @@ nv04_emit_framebuffer(struct gl_context *ctx, int emit) if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; + PUSH_RESET(push, BUFCTX_FB); + /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( @@ -70,8 +69,8 @@ nv04_emit_framebuffer(struct gl_context *ctx, int emit) rt_format |= get_rt_format(s->format); zeta_pitch = rt_pitch = s->pitch; - nouveau_bo_markl(bctx, surf3d, - NV04_CONTEXT_SURFACES_3D_OFFSET_COLOR, + BEGIN_NV04(push, NV04_SF3D(OFFSET_COLOR), 1); + PUSH_MTHDl(push, NV04_SF3D(OFFSET_COLOR), BUFCTX_FB, s->bo, 0, bo_flags); } @@ -82,15 +81,15 @@ nv04_emit_framebuffer(struct gl_context *ctx, int emit) zeta_pitch = s->pitch; - nouveau_bo_markl(bctx, surf3d, - NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, + BEGIN_NV04(push, NV04_SF3D(OFFSET_ZETA), 1); + PUSH_MTHDl(push, NV04_SF3D(OFFSET_ZETA), BUFCTX_FB, s->bo, 0, bo_flags); } - BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1); - OUT_RING(chan, rt_format); - BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_PITCH, 1); - OUT_RING(chan, zeta_pitch << 16 | rt_pitch); + BEGIN_NV04(push, NV04_SF3D(FORMAT), 1); + PUSH_DATA (push, rt_format); + BEGIN_NV04(push, NV04_SF3D(PITCH), 1); + PUSH_DATA (push, zeta_pitch << 16 | rt_pitch); /* Recompute the scissor state. */ context_dirty(ctx, SCISSOR); @@ -99,16 +98,14 @@ nv04_emit_framebuffer(struct gl_context *ctx, int emit) void nv04_emit_scissor(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *surf3d = hw->surf3d; + struct nouveau_pushbuf *push = context_push(ctx); int x, y, w, h; get_scissors(ctx->DrawBuffer, &x, &y, &w, &h); - BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL, 2); - OUT_RING(chan, w << 16 | x); - OUT_RING(chan, h << 16 | y); + BEGIN_NV04(push, NV04_SF3D(CLIP_HORIZONTAL), 2); + PUSH_DATA (push, w << 16 | x); + PUSH_DATA (push, h << 16 | y); /* Messing with surf3d invalidates the engine state. */ context_dirty_i(ctx, TEX_ENV, 0); diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c index 21478de262d..ef4c557cb57 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c @@ -238,8 +238,8 @@ void nv04_emit_tex_env(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_ENV0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); + struct nouveau_pushbuf *push = context_push(ctx); + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); struct combiner_state rc_a = {}, rc_c = {}; if (!nv04_mtex_engine(fahrenheit)) { @@ -276,13 +276,11 @@ nv04_emit_tex_env(struct gl_context *ctx, int emit) } /* Write the register combiner state out to the hardware. */ - BEGIN_RING(chan, fahrenheit, - NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA(i), 2); - OUT_RING(chan, rc_a.hw); - OUT_RING(chan, rc_c.hw); - - BEGIN_RING(chan, fahrenheit, - NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR, 1); - OUT_RING(chan, pack_rgba_f(MESA_FORMAT_ARGB8888, - ctx->Texture.Unit[0].EnvColor)); + BEGIN_NV04(push, NV04_MTRI(COMBINE_ALPHA(i)), 2); + PUSH_DATA (push, rc_a.hw); + PUSH_DATA (push, rc_c.hw); + + BEGIN_NV04(push, NV04_MTRI(COMBINE_FACTOR), 1); + PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_ARGB8888, + ctx->Texture.Unit[0].EnvColor)); } diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c index 78d29fc485b..f8abda1b9cb 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c @@ -136,8 +136,8 @@ nv04_defer_control(struct gl_context *ctx, int emit) void nv04_emit_control(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); + struct nouveau_pushbuf *push = context_push(ctx); + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); if (nv04_mtex_engine(fahrenheit)) { int cull_mode = ctx->Polygon.CullFaceMode; @@ -202,10 +202,10 @@ nv04_emit_control(struct gl_context *ctx, int emit) get_stencil_op(ctx->Stencil.ZFailFunc[0]) << 4 | get_stencil_op(ctx->Stencil.FailFunc[0]); - BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_CONTROL0, 3); - OUT_RING(chan, ctrl0); - OUT_RING(chan, ctrl1); - OUT_RING(chan, ctrl2); + BEGIN_NV04(push, NV04_MTRI(CONTROL0), 3); + PUSH_DATA (push, ctrl0); + PUSH_DATA (push, ctrl1); + PUSH_DATA (push, ctrl2); } else { int cull_mode = ctx->Polygon.CullFaceMode; @@ -242,8 +242,8 @@ nv04_emit_control(struct gl_context *ctx, int emit) ctrl |= get_comparison_op(ctx->Color.AlphaFunc) << 8 | FLOAT_TO_UBYTE(ctx->Color.AlphaRef); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1); - OUT_RING(chan, ctrl); + BEGIN_NV04(push, NV04_TTRI(CONTROL), 1); + PUSH_DATA (push, ctrl); } } @@ -256,8 +256,8 @@ nv04_defer_blend(struct gl_context *ctx, int emit) void nv04_emit_blend(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx); + struct nouveau_pushbuf *push = context_push(ctx); + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); if (nv04_mtex_engine(fahrenheit)) { uint32_t blend = 0x2 << 4 | @@ -284,12 +284,12 @@ nv04_emit_blend(struct gl_context *ctx, int emit) if (ctx->Fog.Enabled) blend |= NV04_MULTITEX_TRIANGLE_BLEND_FOG_ENABLE; - BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_BLEND, 1); - OUT_RING(chan, blend); + BEGIN_NV04(push, NV04_MTRI(BLEND), 1); + PUSH_DATA (push, blend); - BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_FOGCOLOR, 1); - OUT_RING(chan, pack_rgba_f(MESA_FORMAT_ARGB8888, - ctx->Fog.Color)); + BEGIN_NV04(push, NV04_MTRI(FOGCOLOR), 1); + PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_ARGB8888, + ctx->Fog.Color)); } else { uint32_t blend = 0x2 << 4 | @@ -322,11 +322,11 @@ nv04_emit_blend(struct gl_context *ctx, int emit) if (ctx->Fog.Enabled) blend |= NV04_TEXTURED_TRIANGLE_BLEND_FOG_ENABLE; - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1); - OUT_RING(chan, blend); + BEGIN_NV04(push, NV04_TTRI(BLEND), 1); + PUSH_DATA (push, blend); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FOGCOLOR, 1); - OUT_RING(chan, pack_rgba_f(MESA_FORMAT_ARGB8888, - ctx->Fog.Color)); + BEGIN_NV04(push, NV04_TTRI(FOGCOLOR), 1); + PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_ARGB8888, + ctx->Fog.Color)); } } diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c index 648d6b18cf5..cc35d2545e2 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c @@ -60,13 +60,14 @@ void nv04_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 *fahrenheit = nv04_context_engine(ctx); - struct nouveau_bo_context *bctx = context_bctx_i(ctx, TEXTURE, i); + struct nouveau_pushbuf *push = context_push(ctx); + struct nouveau_object *fahrenheit = nv04_context_engine(ctx); const int bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART | NOUVEAU_BO_VRAM; struct nouveau_surface *s; uint32_t format = 0xa0, filter = 0x1010; + PUSH_RESET(push, BUFCTX_TEX(i)); + if (i && !nv04_mtex_engine(fahrenheit)) return; @@ -115,36 +116,34 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit) } if (nv04_mtex_engine(fahrenheit)) { - nouveau_bo_markl(bctx, fahrenheit, - NV04_MULTITEX_TRIANGLE_OFFSET(i), + BEGIN_NV04(push, NV04_MTRI(OFFSET(i)), 1); + PUSH_MTHDl(push, NV04_MTRI(OFFSET(i)), BUFCTX_TEX(i), s->bo, s->offset, bo_flags); - nouveau_bo_mark(bctx, fahrenheit, - NV04_MULTITEX_TRIANGLE_FORMAT(i), - s->bo, format, 0, - NV04_MULTITEX_TRIANGLE_FORMAT_DMA_A, - NV04_MULTITEX_TRIANGLE_FORMAT_DMA_B, - bo_flags | NOUVEAU_BO_OR); + BEGIN_NV04(push, NV04_MTRI(FORMAT(i)), 1); + PUSH_MTHD (push, NV04_MTRI(FORMAT(i)), BUFCTX_TEX(i), + s->bo, format, bo_flags | NOUVEAU_BO_OR, + NV04_MULTITEX_TRIANGLE_FORMAT_DMA_A, + NV04_MULTITEX_TRIANGLE_FORMAT_DMA_B); - BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_FILTER(i), 1); - OUT_RING(chan, filter); + BEGIN_NV04(push, NV04_MTRI(FILTER(i)), 1); + PUSH_DATA (push, filter); } else { - nouveau_bo_markl(bctx, fahrenheit, - NV04_TEXTURED_TRIANGLE_OFFSET, + BEGIN_NV04(push, NV04_TTRI(OFFSET), 1); + PUSH_MTHDl(push, NV04_TTRI(OFFSET), BUFCTX_TEX(0), s->bo, s->offset, bo_flags); - nouveau_bo_mark(bctx, fahrenheit, - NV04_TEXTURED_TRIANGLE_FORMAT, - s->bo, format, 0, - NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A, - NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B, - bo_flags | NOUVEAU_BO_OR); + BEGIN_NV04(push, NV04_TTRI(FORMAT), 1); + PUSH_MTHD (push, NV04_TTRI(FORMAT), BUFCTX_TEX(0), + s->bo, format, bo_flags | NOUVEAU_BO_OR, + NV04_TEXTURED_TRIANGLE_FORMAT_DMA_A, + NV04_TEXTURED_TRIANGLE_FORMAT_DMA_B); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_COLORKEY, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_TTRI(COLORKEY), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FILTER, 1); - OUT_RING(chan, filter); + BEGIN_NV04(push, NV04_TTRI(FILTER), 1); + PUSH_DATA (push, filter); } } diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c b/src/mesa/drivers/dri/nouveau/nv04_surface.c index 4a3000cd4de..239d77039b3 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_surface.c +++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c @@ -196,12 +196,14 @@ nv04_surface_copy_swizzle(struct gl_context *ctx, int dx, int dy, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf_refn refs[] = { + { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART }, + { dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM }, + }; + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *swzsurf = hw->swzsurf; - struct nouveau_grobj *sifm = hw->sifm; - struct nouveau_bo_context *bctx = context_bctx(ctx, SURFACE); - const unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART; + struct nouveau_object *swzsurf = hw->swzsurf; + struct nv04_fifo *fifo = hw->chan->data; /* Max width & height may not be the same on all HW, but must be POT */ const unsigned max_w = 1024; const unsigned max_h = 1024; @@ -213,20 +215,10 @@ nv04_surface_copy_swizzle(struct gl_context *ctx, assert(_mesa_is_pow_two(dst->width) && _mesa_is_pow_two(dst->height)); - nouveau_bo_marko(bctx, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, - src->bo, bo_flags | NOUVEAU_BO_RD); - nouveau_bo_marko(bctx, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, - dst->bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - nouveau_bo_markl(bctx, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, - dst->bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1); - OUT_RING (chan, swzsurf_format(dst->format) | - log2i(dst->width) << 16 | - log2i(dst->height) << 24); - - BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1); - OUT_RING (chan, swzsurf->handle); + if (context_chipset(ctx) < 0x10) { + BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1); + PUSH_DATA (push, swzsurf->handle); + } for (y = 0; y < h; y += sub_h) { sub_h = MIN2(sub_h, h - y); @@ -234,37 +226,49 @@ nv04_surface_copy_swizzle(struct gl_context *ctx, for (x = 0; x < w; x += sub_w) { sub_w = MIN2(sub_w, w - x); - MARK_RING(chan, 15, 1); - - BEGIN_RING(chan, sifm, - NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT, 8); - OUT_RING(chan, sifm_format(src->format)); - OUT_RING(chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); - OUT_RING(chan, (y + dy) << 16 | (x + dx)); - OUT_RING(chan, sub_h << 16 | sub_w); - OUT_RING(chan, (y + dy) << 16 | (x + dx)); - OUT_RING(chan, sub_h << 16 | sub_w); - OUT_RING(chan, 1 << 20); - OUT_RING(chan, 1 << 20); - - BEGIN_RING(chan, sifm, - NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4); - OUT_RING(chan, align(sub_h, 2) << 16 | align(sub_w, 2)); - OUT_RING(chan, src->pitch | - NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER | - NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE); - OUT_RELOCl(chan, src->bo, src->offset + - (y + sy) * src->pitch + - (x + sx) * src->cpp, - bo_flags | NOUVEAU_BO_RD); - OUT_RING(chan, 0); + if (nouveau_pushbuf_space(push, 64, 4, 0) || + nouveau_pushbuf_refn (push, refs, 2)) + return; + + BEGIN_NV04(push, NV04_SSWZ(DMA_IMAGE), 1); + PUSH_DATA (push, fifo->vram); + BEGIN_NV04(push, NV04_SSWZ(FORMAT), 2); + PUSH_DATA (push, swzsurf_format(dst->format) | + log2i(dst->width) << 16 | + log2i(dst->height) << 24); + PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0); + + BEGIN_NV04(push, NV03_SIFM(DMA_IMAGE), 1); + PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart); + BEGIN_NV04(push, NV05_SIFM(SURFACE), 1); + PUSH_DATA (push, swzsurf->handle); + + BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 8); + PUSH_DATA (push, sifm_format(src->format)); + PUSH_DATA (push, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); + PUSH_DATA (push, (y + dy) << 16 | (x + dx)); + PUSH_DATA (push, sub_h << 16 | sub_w); + PUSH_DATA (push, (y + dy) << 16 | (x + dx)); + PUSH_DATA (push, sub_h << 16 | sub_w); + PUSH_DATA (push, 1 << 20); + PUSH_DATA (push, 1 << 20); + + BEGIN_NV04(push, NV03_SIFM(SIZE), 4); + PUSH_DATA (push, align(sub_h, 2) << 16 | align(sub_w, 2)); + PUSH_DATA (push, src->pitch | + NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER | + NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE); + PUSH_RELOC(push, src->bo, src->offset + (y + sy) * src->pitch + + (x + sx) * src->cpp, NOUVEAU_BO_LOW, 0, 0); + PUSH_DATA (push, 0); } } - nouveau_bo_context_reset(bctx); - - if (context_chipset(ctx) < 0x10) - FIRE_RING(chan); + if (context_chipset(ctx) < 0x10) { + BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1); + PUSH_DATA (push, hw->surf3d->handle); + PUSH_KICK(push); + } } static void @@ -274,45 +278,43 @@ nv04_surface_copy_m2mf(struct gl_context *ctx, int dx, int dy, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf_refn refs[] = { + { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART }, + { dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART }, + }; + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *m2mf = hw->m2mf; - struct nouveau_bo_context *bctx = context_bctx(ctx, SURFACE); - const unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART; + struct nv04_fifo *fifo = hw->chan->data; unsigned dst_offset = dst->offset + dy * dst->pitch + dx * dst->cpp; unsigned src_offset = src->offset + sy * src->pitch + sx * src->cpp; - nouveau_bo_marko(bctx, m2mf, NV04_M2MF_DMA_BUFFER_IN, - src->bo, bo_flags | NOUVEAU_BO_RD); - nouveau_bo_marko(bctx, m2mf, NV04_M2MF_DMA_BUFFER_OUT, - dst->bo, bo_flags | NOUVEAU_BO_WR); - while (h) { int count = (h > 2047) ? 2047 : h; - MARK_RING(chan, 9, 2); + if (nouveau_pushbuf_space(push, 16, 4, 0) || + nouveau_pushbuf_refn (push, refs, 2)) + return; + + BEGIN_NV04(push, NV03_M2MF(DMA_BUFFER_IN), 2); + PUSH_RELOC(push, src->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart); + PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart); + BEGIN_NV04(push, NV03_M2MF(OFFSET_IN), 8); + PUSH_RELOC(push, src->bo, src->offset, NOUVEAU_BO_LOW, 0, 0); + PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0); + PUSH_DATA (push, src->pitch); + PUSH_DATA (push, dst->pitch); + PUSH_DATA (push, w * src->cpp); + PUSH_DATA (push, count); + PUSH_DATA (push, 0x0101); + PUSH_DATA (push, 0); - BEGIN_RING(chan, m2mf, NV04_M2MF_OFFSET_IN, 8); - OUT_RELOCl(chan, src->bo, src_offset, - bo_flags | NOUVEAU_BO_RD); - OUT_RELOCl(chan, dst->bo, dst_offset, - bo_flags | NOUVEAU_BO_WR); - OUT_RING (chan, src->pitch); - OUT_RING (chan, dst->pitch); - OUT_RING (chan, w * src->cpp); - OUT_RING (chan, count); - OUT_RING (chan, 0x0101); - OUT_RING (chan, 0); - - h -= count; src_offset += src->pitch * count; dst_offset += dst->pitch * count; + h -= count; } - nouveau_bo_context_reset(bctx); - if (context_chipset(ctx) < 0x10) - FIRE_RING(chan); + PUSH_KICK(push); } typedef unsigned (*get_offset_t)(struct nouveau_surface *s, @@ -374,8 +376,8 @@ nv04_surface_copy_cpu(struct gl_context *ctx, get_swizzled_offset : get_linear_offset); void *dp, *sp; - nouveau_bo_map(dst->bo, NOUVEAU_BO_WR); - nouveau_bo_map(src->bo, NOUVEAU_BO_RD); + nouveau_bo_map(dst->bo, NOUVEAU_BO_WR, context_client(ctx)); + nouveau_bo_map(src->bo, NOUVEAU_BO_RD, context_client(ctx)); dp = dst->bo->map + dst->offset; sp = src->bo->map + src->offset; @@ -386,9 +388,6 @@ nv04_surface_copy_cpu(struct gl_context *ctx, sp + get_src(src, sx + x, sy + y), dst->cpp); } } - - nouveau_bo_unmap(src->bo); - nouveau_bo_unmap(dst->bo); } void @@ -422,40 +421,41 @@ nv04_surface_fill(struct gl_context *ctx, unsigned mask, unsigned value, int dx, int dy, int w, int h) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf_refn refs[] = { + { dst->bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART }, + }; + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - struct nouveau_grobj *surf2d = hw->surf2d; - struct nouveau_grobj *patt = hw->patt; - struct nouveau_grobj *rect = hw->rect; - unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART; - - MARK_RING (chan, 19, 4); - - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); - OUT_RELOCo(chan, dst->bo, bo_flags | NOUVEAU_BO_WR); - OUT_RELOCo(chan, dst->bo, bo_flags | NOUVEAU_BO_WR); - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); - OUT_RING (chan, surf2d_format(dst->format)); - OUT_RING (chan, (dst->pitch << 16) | dst->pitch); - OUT_RELOCl(chan, dst->bo, dst->offset, bo_flags | NOUVEAU_BO_WR); - OUT_RELOCl(chan, dst->bo, dst->offset, bo_flags | NOUVEAU_BO_WR); - - BEGIN_RING(chan, patt, NV04_IMAGE_PATTERN_COLOR_FORMAT, 1); - OUT_RING (chan, rect_format(dst->format)); - BEGIN_RING(chan, patt, NV04_IMAGE_PATTERN_MONOCHROME_COLOR1, 1); - OUT_RING (chan, mask | ~0ll << (8 * dst->cpp)); - - BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1); - OUT_RING (chan, rect_format(dst->format)); - BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1); - OUT_RING (chan, value); - BEGIN_RING(chan, rect, - NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2); - OUT_RING (chan, (dx << 16) | dy); - OUT_RING (chan, ( w << 16) | h); + struct nv04_fifo *fifo = hw->chan->data; + + if (nouveau_pushbuf_space(push, 64, 4, 0) || + nouveau_pushbuf_refn (push, refs, 1)) + return; + + BEGIN_NV04(push, NV04_SF2D(DMA_IMAGE_SOURCE), 2); + PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart); + PUSH_RELOC(push, dst->bo, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart); + BEGIN_NV04(push, NV04_SF2D(FORMAT), 4); + PUSH_DATA (push, surf2d_format(dst->format)); + PUSH_DATA (push, (dst->pitch << 16) | dst->pitch); + PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0); + PUSH_RELOC(push, dst->bo, dst->offset, NOUVEAU_BO_LOW, 0, 0); + + BEGIN_NV04(push, NV01_PATT(COLOR_FORMAT), 1); + PUSH_DATA (push, rect_format(dst->format)); + BEGIN_NV04(push, NV01_PATT(MONOCHROME_COLOR1), 1); + PUSH_DATA (push, mask | ~0ll << (8 * dst->cpp)); + + BEGIN_NV04(push, NV04_GDI(COLOR_FORMAT), 1); + PUSH_DATA (push, rect_format(dst->format)); + BEGIN_NV04(push, NV04_GDI(COLOR1_A), 1); + PUSH_DATA (push, value); + BEGIN_NV04(push, NV04_GDI(UNCLIPPED_RECTANGLE_POINT(0)), 2); + PUSH_DATA (push, (dx << 16) | dy); + PUSH_DATA (push, ( w << 16) | h); if (context_chipset(ctx) < 0x10) - FIRE_RING(chan); + PUSH_KICK(push); } void @@ -463,123 +463,144 @@ nv04_surface_takedown(struct gl_context *ctx) { struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; - nouveau_grobj_free(&hw->swzsurf); - nouveau_grobj_free(&hw->sifm); - nouveau_grobj_free(&hw->rect); - nouveau_grobj_free(&hw->rop); - nouveau_grobj_free(&hw->patt); - nouveau_grobj_free(&hw->surf2d); - nouveau_grobj_free(&hw->m2mf); - nouveau_notifier_free(&hw->ntfy); + nouveau_object_del(&hw->swzsurf); + nouveau_object_del(&hw->sifm); + nouveau_object_del(&hw->rect); + nouveau_object_del(&hw->rop); + nouveau_object_del(&hw->patt); + nouveau_object_del(&hw->surf2d); + nouveau_object_del(&hw->m2mf); + nouveau_object_del(&hw->ntfy); } GLboolean nv04_surface_init(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; + struct nouveau_object *chan = hw->chan; unsigned handle = 0x88000000, class; int ret; /* Notifier object. */ - ret = nouveau_notifier_alloc(chan, handle++, 1, &hw->ntfy); + ret = nouveau_object_new(chan, handle++, NOUVEAU_NOTIFIER_CLASS, + &(struct nv04_notify) { + .length = 32, + }, sizeof(struct nv04_notify), &hw->ntfy); if (ret) goto fail; /* Memory to memory format. */ - ret = nouveau_grobj_alloc(chan, handle++, NV04_M2MF, &hw->m2mf); + ret = nouveau_object_new(chan, handle++, NV03_M2MF_CLASS, + NULL, 0, &hw->m2mf); if (ret) goto fail; - BEGIN_RING(chan, hw->m2mf, NV04_M2MF_DMA_NOTIFY, 1); - OUT_RING (chan, hw->ntfy->handle); + BEGIN_NV04(push, NV01_SUBC(M2MF, OBJECT), 1); + PUSH_DATA (push, hw->m2mf->handle); + BEGIN_NV04(push, NV03_M2MF(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); /* Context surfaces 2D. */ if (context_chipset(ctx) < 0x10) - class = NV04_CONTEXT_SURFACES_2D; + class = NV04_SURFACE_2D_CLASS; else - class = NV10_CONTEXT_SURFACES_2D; + class = NV10_SURFACE_2D_CLASS; - ret = nouveau_grobj_alloc(chan, handle++, class, &hw->surf2d); + ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->surf2d); if (ret) goto fail; + BEGIN_NV04(push, NV01_SUBC(SF2D, OBJECT), 1); + PUSH_DATA (push, hw->surf2d->handle); + /* Raster op. */ - ret = nouveau_grobj_alloc(chan, handle++, NV03_CONTEXT_ROP, &hw->rop); + ret = nouveau_object_new(chan, handle++, NV03_ROP_CLASS, + NULL, 0, &hw->rop); if (ret) goto fail; - BEGIN_RING(chan, hw->rop, NV03_CONTEXT_ROP_DMA_NOTIFY, 1); - OUT_RING (chan, hw->ntfy->handle); + BEGIN_NV04(push, NV01_SUBC(PATT, OBJECT), 1); + PUSH_DATA (push, hw->rop->handle); + BEGIN_NV04(push, NV01_ROP(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); - BEGIN_RING(chan, hw->rop, NV03_CONTEXT_ROP_ROP, 1); - OUT_RING (chan, 0xca); /* DPSDxax in the GDI speech. */ + BEGIN_NV04(push, NV01_ROP(ROP), 1); + PUSH_DATA (push, 0xca); /* DPSDxax in the GDI speech. */ /* Image pattern. */ - ret = nouveau_grobj_alloc(chan, handle++, NV04_IMAGE_PATTERN, - &hw->patt); + ret = nouveau_object_new(chan, handle++, NV04_PATTERN_CLASS, + NULL, 0, &hw->patt); if (ret) goto fail; - BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_DMA_NOTIFY, 1); - OUT_RING (chan, hw->ntfy->handle); + BEGIN_NV04(push, NV01_SUBC(PATT, OBJECT), 1); + PUSH_DATA (push, hw->patt->handle); + BEGIN_NV04(push, NV01_PATT(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); - BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT, 3); - OUT_RING (chan, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE); - OUT_RING (chan, NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8); - OUT_RING (chan, NV04_IMAGE_PATTERN_PATTERN_SELECT_MONO); + BEGIN_NV04(push, NV01_PATT(MONOCHROME_FORMAT), 3); + PUSH_DATA (push, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE); + PUSH_DATA (push, NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8); + PUSH_DATA (push, NV04_IMAGE_PATTERN_PATTERN_SELECT_MONO); - BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_MONOCHROME_COLOR0, 4); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, ~0); - OUT_RING (chan, ~0); + BEGIN_NV04(push, NV01_PATT(MONOCHROME_COLOR0), 4); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, ~0); + PUSH_DATA (push, ~0); /* GDI rectangle text. */ - ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT, - &hw->rect); + ret = nouveau_object_new(chan, handle++, NV04_GDI_CLASS, + NULL, 0, &hw->rect); if (ret) goto fail; - BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1); - OUT_RING (chan, hw->ntfy->handle); - BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1); - OUT_RING (chan, hw->surf2d->handle); - BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_ROP, 1); - OUT_RING (chan, hw->rop->handle); - BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_PATTERN, 1); - OUT_RING (chan, hw->patt->handle); - - BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1); - OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_ROP_AND); - BEGIN_RING(chan, hw->rect, - NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1); - OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE); + BEGIN_NV04(push, NV01_SUBC(GDI, OBJECT), 1); + PUSH_DATA (push, hw->rect->handle); + BEGIN_NV04(push, NV04_GDI(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); + BEGIN_NV04(push, NV04_GDI(SURFACE), 1); + PUSH_DATA (push, hw->surf2d->handle); + BEGIN_NV04(push, NV04_GDI(ROP), 1); + PUSH_DATA (push, hw->rop->handle); + BEGIN_NV04(push, NV04_GDI(PATTERN), 1); + PUSH_DATA (push, hw->patt->handle); + + BEGIN_NV04(push, NV04_GDI(OPERATION), 1); + PUSH_DATA (push, NV04_GDI_RECTANGLE_TEXT_OPERATION_ROP_AND); + BEGIN_NV04(push, NV04_GDI(MONOCHROME_FORMAT), 1); + PUSH_DATA (push, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE); /* Swizzled surface. */ if (context_chipset(ctx) < 0x20) - class = NV04_SWIZZLED_SURFACE; + class = NV04_SURFACE_SWZ_CLASS; else - class = NV20_SWIZZLED_SURFACE; + class = NV20_SURFACE_SWZ_CLASS; - ret = nouveau_grobj_alloc(chan, handle++, class, &hw->swzsurf); + ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->swzsurf); if (ret) goto fail; + BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1); + PUSH_DATA (push, hw->swzsurf->handle); + /* Scaled image from memory. */ if (context_chipset(ctx) < 0x10) - class = NV04_SCALED_IMAGE_FROM_MEMORY; + class = NV04_SIFM_CLASS; else - class = NV10_SCALED_IMAGE_FROM_MEMORY; + class = NV10_SIFM_CLASS; - ret = nouveau_grobj_alloc(chan, handle++, class, &hw->sifm); + ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->sifm); if (ret) goto fail; + BEGIN_NV04(push, NV01_SUBC(SIFM, OBJECT), 1); + PUSH_DATA (push, hw->sifm->handle); + if (context_chipset(ctx) >= 0x10) { - BEGIN_RING(chan, hw->sifm, - NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 1); - OUT_RING(chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE); + BEGIN_NV04(push, NV05_SIFM(COLOR_CONVERSION), 1); + PUSH_DATA (push, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index 0b0d549bf1f..90c1545ce37 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -144,18 +144,17 @@ static void nv17_zclear(struct gl_context *ctx, GLbitfield *buffers) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_framebuffer *nfb = to_nouveau_framebuffer( ctx->DrawBuffer); struct nouveau_surface *s = &to_nouveau_renderbuffer( nfb->base.Attachment[BUFFER_DEPTH].Renderbuffer)->surface; /* Clear the hierarchical depth buffer */ - BEGIN_RING(chan, celsius, NV17_3D_HIERZ_FILL_VALUE, 1); - OUT_RING(chan, pack_zs_f(s->format, ctx->Depth.Clear, 0)); - BEGIN_RING(chan, celsius, NV17_3D_HIERZ_BUFFER_CLEAR, 1); - OUT_RING(chan, 1); + BEGIN_NV04(push, NV17_3D(HIERZ_FILL_VALUE), 1); + PUSH_DATA (push, pack_zs_f(s->format, ctx->Depth.Clear, 0)); + BEGIN_NV04(push, NV17_3D(HIERZ_BUFFER_CLEAR), 1); + PUSH_DATA (push, 1); /* Mark the depth buffer as cleared */ if (use_fast_zclear(ctx, *buffers)) { @@ -173,8 +172,17 @@ nv17_zclear(struct gl_context *ctx, GLbitfield *buffers) static void nv10_clear(struct gl_context *ctx, GLbitfield buffers) { + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_pushbuf *push = context_push(ctx); + nouveau_validate_framebuffer(ctx); + nouveau_pushbuf_bufctx(push, nctx->hw.bufctx); + if (nouveau_pushbuf_validate(push)) { + nouveau_pushbuf_bufctx(push, NULL); + return; + } + if ((buffers & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) { if (context_chipset(ctx) >= 0x17) nv17_zclear(ctx, &buffers); @@ -185,219 +193,222 @@ nv10_clear(struct gl_context *ctx, GLbitfield buffers) _mesa_update_state(ctx); } + nouveau_pushbuf_bufctx(push, NULL); nouveau_clear(ctx, buffers); } static void nv10_hwctx_init(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; + struct nv04_fifo *fifo = hw->chan->data; int i; - BEGIN_RING(chan, celsius, NV10_3D_DMA_NOTIFY, 1); - OUT_RING(chan, hw->ntfy->handle); + BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); + PUSH_DATA (push, hw->eng3d->handle); + BEGIN_NV04(push, NV10_3D(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); - BEGIN_RING(chan, celsius, NV10_3D_DMA_TEXTURE0, 3); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->gart->handle); - OUT_RING(chan, chan->gart->handle); - BEGIN_RING(chan, celsius, NV10_3D_DMA_COLOR, 2); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->vram->handle); + BEGIN_NV04(push, NV10_3D(DMA_TEXTURE0), 3); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->gart); + PUSH_DATA (push, fifo->gart); + BEGIN_NV04(push, NV10_3D(DMA_COLOR), 2); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->vram); - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, celsius, NV10_3D_RT_HORIZ, 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(RT_HORIZ), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING(chan, 0x7ff << 16 | 0x800); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING(chan, 0x7ff << 16 | 0x800); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1); + PUSH_DATA (push, 0x7ff << 16 | 0x800); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1); + PUSH_DATA (push, 0x7ff << 16 | 0x800); for (i = 1; i < 8; i++) { - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_HORIZ(i), 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_VERT(i), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(i)), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(i)), 1); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, celsius, 0x290, 1); - OUT_RING(chan, 0x10 << 16 | 1); - BEGIN_RING(chan, celsius, 0x3f4, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, SUBC_3D(0x290), 1); + PUSH_DATA (push, 0x10 << 16 | 1); + BEGIN_NV04(push, SUBC_3D(0x3f4), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); if (context_chipset(ctx) >= 0x17) { - BEGIN_RING(chan, celsius, NV17_3D_UNK01AC, 2); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->vram->handle); + BEGIN_NV04(push, NV17_3D(UNK01AC), 2); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->vram); - BEGIN_RING(chan, celsius, 0xd84, 1); - OUT_RING(chan, 0x3); + BEGIN_NV04(push, SUBC_3D(0xd84), 1); + PUSH_DATA (push, 0x3); - BEGIN_RING(chan, celsius, NV17_3D_COLOR_MASK_ENABLE, 1); - OUT_RING(chan, 1); + BEGIN_NV04(push, NV17_3D(COLOR_MASK_ENABLE), 1); + PUSH_DATA (push, 1); } if (context_chipset(ctx) >= 0x11) { - BEGIN_RING(chan, celsius, 0x120, 3); - OUT_RING(chan, 0); - OUT_RING(chan, 1); - OUT_RING(chan, 2); + BEGIN_NV04(push, SUBC_3D(0x120), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 1); + PUSH_DATA (push, 2); - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); /* Set state */ - BEGIN_RING(chan, celsius, NV10_3D_FOG_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_FUNC, 2); - OUT_RING(chan, 0x207); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_TEX_ENABLE(0), 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - - BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_DITHER_ENABLE, 2); - OUT_RING(chan, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_LINE_SMOOTH_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_WEIGHT_ENABLE, 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_SRC, 4); - OUT_RING(chan, 1); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - OUT_RING(chan, 0x8006); - BEGIN_RING(chan, celsius, NV10_3D_STENCIL_MASK, 8); - OUT_RING(chan, 0xff); - OUT_RING(chan, 0x207); - OUT_RING(chan, 0); - OUT_RING(chan, 0xff); - OUT_RING(chan, 0x1e00); - OUT_RING(chan, 0x1e00); - OUT_RING(chan, 0x1e00); - OUT_RING(chan, 0x1d01); - BEGIN_RING(chan, celsius, NV10_3D_NORMALIZE_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_FOG_ENABLE, 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_MODEL, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_ENABLED_LIGHTS, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_FUNC, 1); - OUT_RING(chan, 0x201); - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_WRITE_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_TEST_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_FACTOR, 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_POINT_SIZE, 1); - OUT_RING(chan, 8); - BEGIN_RING(chan, celsius, NV10_3D_POINT_PARAMETERS_ENABLE, 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_LINE_WIDTH, 1); - OUT_RING(chan, 8); - BEGIN_RING(chan, celsius, NV10_3D_LINE_SMOOTH_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_MODE_FRONT, 2); - OUT_RING(chan, 0x1b02); - OUT_RING(chan, 0x1b02); - BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE, 2); - OUT_RING(chan, 0x405); - OUT_RING(chan, 0x901); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_SMOOTH_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE_ENABLE, 1); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_TEX_GEN_MODE(0, 0), 8); + BEGIN_NV04(push, NV10_3D(FOG_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_FUNC), 2); + PUSH_DATA (push, 0x207); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(TEX_ENABLE(0)), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(DITHER_ENABLE), 2); + PUSH_DATA (push, 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(VERTEX_WEIGHT_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 4); + PUSH_DATA (push, 1); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0x8006); + BEGIN_NV04(push, NV10_3D(STENCIL_MASK), 8); + PUSH_DATA (push, 0xff); + PUSH_DATA (push, 0x207); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0xff); + PUSH_DATA (push, 0x1e00); + PUSH_DATA (push, 0x1e00); + PUSH_DATA (push, 0x1e00); + PUSH_DATA (push, 0x1d01); + BEGIN_NV04(push, NV10_3D(NORMALIZE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(FOG_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(LIGHT_MODEL), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(SEPARATE_SPECULAR_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(ENABLED_LIGHTS), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_POINT_ENABLE), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(DEPTH_FUNC), 1); + PUSH_DATA (push, 0x201); + BEGIN_NV04(push, NV10_3D(DEPTH_WRITE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(DEPTH_TEST_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_FACTOR), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(POINT_SIZE), 1); + PUSH_DATA (push, 8); + BEGIN_NV04(push, NV10_3D(POINT_PARAMETERS_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(LINE_WIDTH), 1); + PUSH_DATA (push, 8); + BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(POLYGON_MODE_FRONT), 2); + PUSH_DATA (push, 0x1b02); + PUSH_DATA (push, 0x1b02); + BEGIN_NV04(push, NV10_3D(CULL_FACE), 2); + PUSH_DATA (push, 0x405); + PUSH_DATA (push, 0x901); + BEGIN_NV04(push, NV10_3D(POLYGON_SMOOTH_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(CULL_FACE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(0, 0)), 8); for (i = 0; i < 8; i++) - OUT_RING(chan, 0); - - BEGIN_RING(chan, celsius, NV10_3D_TEX_MATRIX_ENABLE(0), 2); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_FOG_COEFF(0), 3); - OUT_RING(chan, 0x3fc00000); /* -1.50 */ - OUT_RING(chan, 0xbdb8aa0a); /* -0.09 */ - OUT_RING(chan, 0); /* 0.00 */ - - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); - - BEGIN_RING(chan, celsius, NV10_3D_FOG_MODE, 2); - OUT_RING(chan, 0x802); - OUT_RING(chan, 2); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(0)), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(FOG_COEFF(0)), 3); + PUSH_DATA (push, 0x3fc00000); /* -1.50 */ + PUSH_DATA (push, 0xbdb8aa0a); /* -0.09 */ + PUSH_DATA (push, 0); /* 0.00 */ + + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV10_3D(FOG_MODE), 2); + PUSH_DATA (push, 0x802); + PUSH_DATA (push, 2); /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when * using texturing, except when using the texture matrix */ - BEGIN_RING(chan, celsius, NV10_3D_VIEW_MATRIX_ENABLE, 1); - OUT_RING(chan, 6); - BEGIN_RING(chan, celsius, NV10_3D_COLOR_MASK, 1); - OUT_RING(chan, 0x01010101); + BEGIN_NV04(push, NV10_3D(VIEW_MATRIX_ENABLE), 1); + PUSH_DATA (push, 6); + BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1); + PUSH_DATA (push, 0x01010101); /* Set vertex component */ - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_COL_4F_R, 4); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_COL2_3F_R, 3); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_NOR_3F_X, 3); - OUT_RING(chan, 0); - OUT_RING(chan, 0); - OUT_RINGf(chan, 1.0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_TX0_4F_S, 4); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_TX1_4F_S, 4); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - BEGIN_RING(chan, celsius, NV10_3D_VERTEX_FOG_1F, 1); - OUT_RINGf(chan, 0.0); - BEGIN_RING(chan, celsius, NV10_3D_EDGEFLAG_ENABLE, 1); - OUT_RING(chan, 1); - - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_RANGE_NEAR, 2); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 16777216.0); - - FIRE_RING(chan); + BEGIN_NV04(push, NV10_3D(VERTEX_COL_4F_R), 4); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + BEGIN_NV04(push, NV10_3D(VERTEX_COL2_3F_R), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV10_3D(VERTEX_NOR_3F_X), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATAf(push, 1.0); + BEGIN_NV04(push, NV10_3D(VERTEX_TX0_4F_S), 4); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + BEGIN_NV04(push, NV10_3D(VERTEX_TX1_4F_S), 4); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + BEGIN_NV04(push, NV10_3D(VERTEX_FOG_1F), 1); + PUSH_DATAf(push, 0.0); + BEGIN_NV04(push, NV10_3D(EDGEFLAG_ENABLE), 1); + PUSH_DATA (push, 1); + + BEGIN_NV04(push, NV10_3D(DEPTH_RANGE_NEAR), 2); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 16777216.0); + + PUSH_KICK (push); } static void @@ -409,7 +420,7 @@ nv10_context_destroy(struct gl_context *ctx) nv10_swtnl_destroy(ctx); nv10_vbo_destroy(ctx); - nouveau_grobj_free(&nctx->hw.eng3d); + nouveau_object_del(&nctx->hw.eng3d); nouveau_context_deinit(ctx); FREE(ctx); @@ -455,14 +466,14 @@ nv10_context_create(struct nouveau_screen *screen, const struct gl_config *visua /* 3D engine. */ if (context_chipset(ctx) >= 0x17) - celsius_class = NV17_3D; + celsius_class = NV17_3D_CLASS; else if (context_chipset(ctx) >= 0x11) - celsius_class = NV11_3D; + celsius_class = NV15_3D_CLASS; else - celsius_class = NV10_3D; + celsius_class = NV10_3D_CLASS; - ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001, celsius_class, - &nctx->hw.eng3d); + ret = nouveau_object_new(context_chan(ctx), 0xbeef0001, celsius_class, + NULL, 0, &nctx->hw.eng3d); if (ret) goto fail; diff --git a/src/mesa/drivers/dri/nouveau/nv10_render.c b/src/mesa/drivers/dri/nouveau/nv10_render.c index 6134650346d..701ba9a87a8 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_render.c +++ b/src/mesa/drivers/dri/nouveau/nv10_render.c @@ -109,8 +109,7 @@ static void nv10_render_set_format(struct gl_context *ctx) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); int i, attr, hw_format; FOR_EACH_ATTR(render, i, attr) { @@ -128,8 +127,8 @@ nv10_render_set_format(struct gl_context *ctx) hw_format = NV10_3D_VTXBUF_FMT_TYPE_V32_FLOAT; } - BEGIN_RING(chan, celsius, NV10_3D_VTXBUF_FMT(i), 1); - OUT_RING(chan, hw_format); + BEGIN_NV04(push, NV10_3D(VTXBUF_FMT(i)), 1); + PUSH_DATA (push, hw_format); } } @@ -137,59 +136,63 @@ static void nv10_render_bind_vertices(struct gl_context *ctx) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, VERTEX); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); int i, attr; FOR_EACH_BOUND_ATTR(render, i, attr) { struct nouveau_array *a = &render->attrs[attr]; - nouveau_bo_markl(bctx, celsius, - NV10_3D_VTXBUF_OFFSET(i), - a->bo, a->offset, - NOUVEAU_BO_GART | NOUVEAU_BO_RD); + BEGIN_NV04(push, NV10_3D(VTXBUF_OFFSET(i)), 1); + PUSH_MTHDl(push, NV10_3D(VTXBUF_OFFSET(i)), BUFCTX_VTX, + a->bo, a->offset, NOUVEAU_BO_GART | + NOUVEAU_BO_RD); } } +static void +nv10_render_release_vertices(struct gl_context *ctx) +{ + PUSH_RESET(context_push(ctx), BUFCTX_VTX); +} + /* Vertex array rendering defs. */ -#define RENDER_LOCALS(ctx) \ - struct nouveau_grobj *celsius = context_eng3d(ctx) +#define RENDER_LOCALS(ctx) #define BATCH_VALIDATE() \ - BEGIN_RING(chan, celsius, NV10_3D_VTXBUF_VALIDATE, 1); \ - OUT_RING(chan, 0) + BEGIN_NV04(push, NV10_3D(VTXBUF_VALIDATE), 1); \ + PUSH_DATA (push, 0) #define BATCH_BEGIN(prim) \ - BEGIN_RING(chan, celsius, NV10_3D_VTXBUF_BEGIN_END, 1); \ - OUT_RING(chan, prim) + BEGIN_NV04(push, NV10_3D(VTXBUF_BEGIN_END), 1); \ + PUSH_DATA (push, prim) #define BATCH_END() \ - BEGIN_RING(chan, celsius, NV10_3D_VTXBUF_BEGIN_END, 1); \ - OUT_RING(chan, 0) + BEGIN_NV04(push, NV10_3D(VTXBUF_BEGIN_END), 1); \ + PUSH_DATA (push, 0) #define MAX_PACKET 0x400 #define MAX_OUT_L 0x100 #define BATCH_PACKET_L(n) \ - BEGIN_RING_NI(chan, celsius, NV10_3D_VTXBUF_BATCH, n) + BEGIN_NI04(push, NV10_3D(VTXBUF_BATCH), n) #define BATCH_OUT_L(i, n) \ - OUT_RING(chan, ((n) - 1) << 24 | (i)) + PUSH_DATA (push, ((n) - 1) << 24 | (i)) #define MAX_OUT_I16 0x2 #define BATCH_PACKET_I16(n) \ - BEGIN_RING_NI(chan, celsius, NV10_3D_VTXBUF_ELEMENT_U16, n) + BEGIN_NI04(push, NV10_3D(VTXBUF_ELEMENT_U16), n) #define BATCH_OUT_I16(i0, i1) \ - OUT_RING(chan, (i1) << 16 | (i0)) + PUSH_DATA (push, (i1) << 16 | (i0)) #define MAX_OUT_I32 0x1 #define BATCH_PACKET_I32(n) \ - BEGIN_RING_NI(chan, celsius, NV10_3D_VTXBUF_ELEMENT_U32, n) + BEGIN_NI04(push, NV10_3D(VTXBUF_ELEMENT_U32), n) #define BATCH_OUT_I32(i) \ - OUT_RING(chan, i) + PUSH_DATA (push, i) #define IMM_PACKET(m, n) \ - BEGIN_RING(chan, celsius, m, n) + BEGIN_NV04(push, SUBC_3D(m), n) #define IMM_OUT(x) \ - OUT_RINGf(chan, x) + PUSH_DATAf(push, x) #define TAG(x) nv10_##x #include "nouveau_render_t.c" diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c index a590bcd30e1..87ae1d6e006 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c @@ -54,9 +54,7 @@ get_rt_format(gl_format format) static void setup_hierz_buffer(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, HIERZ); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb); unsigned pitch = align(fb->Width, 128), @@ -64,34 +62,37 @@ setup_hierz_buffer(struct gl_context *ctx) size = pitch * height; if (!nfb->hierz.bo || nfb->hierz.bo->size != size) { + union nouveau_bo_config config = { + .nv04.surf_flags = NV04_BO_ZETA, + .nv04.surf_pitch = 0 + }; + nouveau_bo_ref(NULL, &nfb->hierz.bo); - nouveau_bo_new_tile(context_dev(ctx), NOUVEAU_BO_VRAM, 0, size, - 0, NOUVEAU_BO_TILE_ZETA, &nfb->hierz.bo); + nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, size, + &config, &nfb->hierz.bo); } - nouveau_bo_markl(bctx, celsius, NV17_3D_HIERZ_OFFSET, + PUSH_SPACE(push, 11); + BEGIN_NV04(push, NV17_3D(HIERZ_OFFSET), 1); + PUSH_MTHDl(push, NV17_3D(HIERZ_OFFSET), BUFCTX_FB, nfb->hierz.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); + BEGIN_NV04(push, NV17_3D(HIERZ_WINDOW_X), 4); + PUSH_DATAf(push, - 1792); + PUSH_DATAf(push, - 2304 + fb->Height); + PUSH_DATAf(push, fb->_DepthMaxF / 2); + PUSH_DATAf(push, 0); - WAIT_RING(chan, 9); - BEGIN_RING(chan, celsius, NV17_3D_HIERZ_WINDOW_X, 4); - OUT_RINGf(chan, - 1792); - OUT_RINGf(chan, - 2304 + fb->Height); - OUT_RINGf(chan, fb->_DepthMaxF / 2); - OUT_RINGf(chan, 0); - - BEGIN_RING(chan, celsius, NV17_3D_HIERZ_PITCH, 1); - OUT_RING(chan, pitch); + BEGIN_NV04(push, NV17_3D(HIERZ_PITCH), 1); + PUSH_DATA (push, pitch); - BEGIN_RING(chan, celsius, NV17_3D_HIERZ_ENABLE, 1); - OUT_RING(chan, 1); + BEGIN_NV04(push, NV17_3D(HIERZ_ENABLE), 1); + PUSH_DATA (push, 1); } void nv10_emit_framebuffer(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; unsigned rt_format = NV10_3D_RT_FORMAT_TYPE_LINEAR; @@ -101,14 +102,16 @@ nv10_emit_framebuffer(struct gl_context *ctx, int emit) if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; + PUSH_RESET(push, BUFCTX_FB); + /* At least nv11 seems to get sad if we don't do this before * swapping RTs.*/ if (context_chipset(ctx) < 0x17) { int i; for (i = 0; i < 6; i++) { - BEGIN_RING(chan, celsius, NV04_GRAPH_NOP, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1); + PUSH_DATA (push, 0); } } @@ -120,7 +123,8 @@ nv10_emit_framebuffer(struct gl_context *ctx, int emit) rt_format |= get_rt_format(s->format); zeta_pitch = rt_pitch = s->pitch; - nouveau_bo_markl(bctx, celsius, NV10_3D_COLOR_OFFSET, + BEGIN_NV04(push, NV10_3D(COLOR_OFFSET), 1); + PUSH_MTHDl(push, NV10_3D(COLOR_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); } @@ -132,7 +136,8 @@ nv10_emit_framebuffer(struct gl_context *ctx, int emit) rt_format |= get_rt_format(s->format); zeta_pitch = s->pitch; - nouveau_bo_markl(bctx, celsius, NV10_3D_ZETA_OFFSET, + BEGIN_NV04(push, NV10_3D(ZETA_OFFSET), 1); + PUSH_MTHDl(push, NV10_3D(ZETA_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); if (context_chipset(ctx) >= 0x17) { @@ -141,9 +146,9 @@ nv10_emit_framebuffer(struct gl_context *ctx, int emit) } } - BEGIN_RING(chan, celsius, NV10_3D_RT_FORMAT, 2); - OUT_RING(chan, rt_format); - OUT_RING(chan, zeta_pitch << 16 | rt_pitch); + BEGIN_NV04(push, NV10_3D(RT_FORMAT), 2); + PUSH_DATA (push, rt_format); + PUSH_DATA (push, zeta_pitch << 16 | rt_pitch); context_dirty(ctx, VIEWPORT); context_dirty(ctx, SCISSOR); @@ -157,22 +162,20 @@ nv10_emit_render_mode(struct gl_context *ctx, int emit) void nv10_emit_scissor(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); int x, y, w, h; get_scissors(ctx->DrawBuffer, &x, &y, &w, &h); - BEGIN_RING(chan, celsius, NV10_3D_RT_HORIZ, 2); - OUT_RING(chan, w << 16 | x); - OUT_RING(chan, h << 16 | y); + BEGIN_NV04(push, NV10_3D(RT_HORIZ), 2); + PUSH_DATA (push, w << 16 | x); + PUSH_DATA (push, h << 16 | y); } void nv10_emit_viewport(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_viewport_attrib *vp = &ctx->Viewport; struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; @@ -183,13 +186,13 @@ nv10_emit_viewport(struct gl_context *ctx, int emit) if (nv10_use_viewport_zclear(ctx)) a[2] = nv10_transform_depth(ctx, (vp->Far + vp->Near) / 2); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGp(chan, a, 4); + BEGIN_NV04(push, NV10_3D(VIEWPORT_TRANSLATE_X), 4); + PUSH_DATAp(push, a, 4); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING(chan, (fb->Width - 1) << 16 | 0x08000800); - BEGIN_RING(chan, celsius, NV10_3D_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING(chan, (fb->Height - 1) << 16 | 0x08000800); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1); + PUSH_DATA (push, (fb->Width - 1) << 16 | 0x08000800); + BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1); + PUSH_DATA (push, (fb->Height - 1) << 16 | 0x08000800); context_dirty(ctx, PROJECTION); } @@ -198,20 +201,19 @@ void nv10_emit_zclear(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(ctx->DrawBuffer); if (nfb->hierz.bo) { - BEGIN_RING(chan, celsius, NV17_3D_ZCLEAR_ENABLE, 2); - OUT_RINGb(chan, !nctx->hierz.clear_blocked); - OUT_RING(chan, nfb->hierz.clear_value | + BEGIN_NV04(push, NV17_3D(ZCLEAR_ENABLE), 2); + PUSH_DATAb(push, !nctx->hierz.clear_blocked); + PUSH_DATA (push, nfb->hierz.clear_value | (nctx->hierz.clear_seq & 0xff)); } else { - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_RANGE_NEAR, 2); - OUT_RINGf(chan, nv10_transform_depth(ctx, 0)); - OUT_RINGf(chan, nv10_transform_depth(ctx, 1)); + BEGIN_NV04(push, NV10_3D(DEPTH_RANGE_NEAR), 2); + PUSH_DATAf(push, nv10_transform_depth(ctx, 0)); + PUSH_DATAf(push, nv10_transform_depth(ctx, 1)); context_dirty(ctx, VIEWPORT); } } diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c index 1adc86086cc..467b762fa03 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c @@ -369,8 +369,7 @@ void nv10_emit_tex_env(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_ENV0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); uint32_t a_in, a_out, c_in, c_out, k; nv10_get_general_combiner(ctx, i, &a_in, &a_out, &c_in, &c_out, &k); @@ -383,16 +382,16 @@ nv10_emit_tex_env(struct gl_context *ctx, int emit) c_out |= 0x3 << 27; } - BEGIN_RING(chan, celsius, NV10_3D_RC_IN_ALPHA(i), 1); - OUT_RING(chan, a_in); - BEGIN_RING(chan, celsius, NV10_3D_RC_IN_RGB(i), 1); - OUT_RING(chan, c_in); - BEGIN_RING(chan, celsius, NV10_3D_RC_COLOR(i), 1); - OUT_RING(chan, k); - BEGIN_RING(chan, celsius, NV10_3D_RC_OUT_ALPHA(i), 1); - OUT_RING(chan, a_out); - BEGIN_RING(chan, celsius, NV10_3D_RC_OUT_RGB(i), 1); - OUT_RING(chan, c_out); + BEGIN_NV04(push, NV10_3D(RC_IN_ALPHA(i)), 1); + PUSH_DATA (push, a_in); + BEGIN_NV04(push, NV10_3D(RC_IN_RGB(i)), 1); + PUSH_DATA (push, c_in); + BEGIN_NV04(push, NV10_3D(RC_COLOR(i)), 1); + PUSH_DATA (push, k); + BEGIN_NV04(push, NV10_3D(RC_OUT_ALPHA(i)), 1); + PUSH_DATA (push, a_out); + BEGIN_NV04(push, NV10_3D(RC_OUT_RGB(i)), 1); + PUSH_DATA (push, c_out); context_dirty(ctx, FRAG); } @@ -400,14 +399,13 @@ nv10_emit_tex_env(struct gl_context *ctx, int emit) void nv10_emit_frag(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); uint64_t in; int n; nv10_get_final_combiner(ctx, &in, &n); - BEGIN_RING(chan, celsius, NV10_3D_RC_FINAL0, 2); - OUT_RING(chan, in); - OUT_RING(chan, in >> 32); + BEGIN_NV04(push, NV10_3D(RC_FINAL0), 2); + PUSH_DATA (push, in); + PUSH_DATA (push, in >> 32); } diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c b/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c index 3f807904835..28e2dce3edf 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c @@ -34,15 +34,14 @@ void nv10_emit_cull_face(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLenum mode = ctx->Polygon.CullFaceMode; - BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE_ENABLE, 1); - OUT_RINGb(chan, ctx->Polygon.CullFlag); + BEGIN_NV04(push, NV10_3D(CULL_FACE_ENABLE), 1); + PUSH_DATAb(push, ctx->Polygon.CullFlag); - BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE, 1); - OUT_RING(chan, (mode == GL_FRONT ? NV10_3D_CULL_FACE_FRONT : + BEGIN_NV04(push, NV10_3D(CULL_FACE), 1); + PUSH_DATA (push, (mode == GL_FRONT ? NV10_3D_CULL_FACE_FRONT : mode == GL_BACK ? NV10_3D_CULL_FACE_BACK : NV10_3D_CULL_FACE_FRONT_AND_BACK)); } @@ -50,27 +49,25 @@ nv10_emit_cull_face(struct gl_context *ctx, int emit) void nv10_emit_front_face(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_FRONT_FACE, 1); - OUT_RING(chan, ctx->Polygon.FrontFace == GL_CW ? + BEGIN_NV04(push, NV10_3D(FRONT_FACE), 1); + PUSH_DATA (push, ctx->Polygon.FrontFace == GL_CW ? NV10_3D_FRONT_FACE_CW : NV10_3D_FRONT_FACE_CCW); } void nv10_emit_line_mode(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLboolean smooth = ctx->Line.SmoothFlag && ctx->Hint.LineSmooth == GL_NICEST; - BEGIN_RING(chan, celsius, NV10_3D_LINE_WIDTH, 1); - OUT_RING(chan, MAX2(smooth ? 0 : 1, + BEGIN_NV04(push, NV10_3D(LINE_WIDTH), 1); + PUSH_DATA (push, MAX2(smooth ? 0 : 1, ctx->Line.Width) * 8); - BEGIN_RING(chan, celsius, NV10_3D_LINE_SMOOTH_ENABLE, 1); - OUT_RINGb(chan, smooth); + BEGIN_NV04(push, NV10_3D(LINE_SMOOTH_ENABLE), 1); + PUSH_DATAb(push, smooth); } void @@ -81,44 +78,41 @@ nv10_emit_line_stipple(struct gl_context *ctx, int emit) void nv10_emit_point_mode(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_POINT_SIZE, 1); - OUT_RING(chan, (uint32_t)(ctx->Point.Size * 8)); + BEGIN_NV04(push, NV10_3D(POINT_SIZE), 1); + PUSH_DATA (push, (uint32_t)(ctx->Point.Size * 8)); - BEGIN_RING(chan, celsius, NV10_3D_POINT_SMOOTH_ENABLE, 1); - OUT_RINGb(chan, ctx->Point.SmoothFlag); + BEGIN_NV04(push, NV10_3D(POINT_SMOOTH_ENABLE), 1); + PUSH_DATAb(push, ctx->Point.SmoothFlag); } void nv10_emit_polygon_mode(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_MODE_FRONT, 2); - OUT_RING(chan, nvgl_polygon_mode(ctx->Polygon.FrontMode)); - OUT_RING(chan, nvgl_polygon_mode(ctx->Polygon.BackMode)); + BEGIN_NV04(push, NV10_3D(POLYGON_MODE_FRONT), 2); + PUSH_DATA (push, nvgl_polygon_mode(ctx->Polygon.FrontMode)); + PUSH_DATA (push, nvgl_polygon_mode(ctx->Polygon.BackMode)); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_SMOOTH_ENABLE, 1); - OUT_RINGb(chan, ctx->Polygon.SmoothFlag); + BEGIN_NV04(push, NV10_3D(POLYGON_SMOOTH_ENABLE), 1); + PUSH_DATAb(push, ctx->Polygon.SmoothFlag); } void nv10_emit_polygon_offset(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RINGb(chan, ctx->Polygon.OffsetPoint); - OUT_RINGb(chan, ctx->Polygon.OffsetLine); - OUT_RINGb(chan, ctx->Polygon.OffsetFill); + BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_POINT_ENABLE), 3); + PUSH_DATAb(push, ctx->Polygon.OffsetPoint); + PUSH_DATAb(push, ctx->Polygon.OffsetLine); + PUSH_DATAb(push, ctx->Polygon.OffsetFill); - BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_FACTOR, 2); - OUT_RINGf(chan, ctx->Polygon.OffsetFactor); - OUT_RINGf(chan, ctx->Polygon.OffsetUnits); + BEGIN_NV04(push, NV10_3D(POLYGON_OFFSET_FACTOR), 2); + PUSH_DATAf(push, ctx->Polygon.OffsetFactor); + PUSH_DATAf(push, ctx->Polygon.OffsetUnits); } void diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c index 50021b0a7bf..8b08c7519d0 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c @@ -34,25 +34,23 @@ void nv10_emit_alpha_func(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_ENABLE, 1); - OUT_RINGb(chan, ctx->Color.AlphaEnabled); + BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_ENABLE), 1); + PUSH_DATAb(push, ctx->Color.AlphaEnabled); - BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_FUNC, 2); - OUT_RING(chan, nvgl_comparison_op(ctx->Color.AlphaFunc)); - OUT_RING(chan, FLOAT_TO_UBYTE(ctx->Color.AlphaRef)); + BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_FUNC), 2); + PUSH_DATA (push, nvgl_comparison_op(ctx->Color.AlphaFunc)); + PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.AlphaRef)); } void nv10_emit_blend_color(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_BLEND_COLOR, 1); - OUT_RING(chan, FLOAT_TO_UBYTE(ctx->Color.BlendColor[3]) << 24 | + BEGIN_NV04(push, NV10_3D(BLEND_COLOR), 1); + PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.BlendColor[3]) << 24 | FLOAT_TO_UBYTE(ctx->Color.BlendColor[0]) << 16 | FLOAT_TO_UBYTE(ctx->Color.BlendColor[1]) << 8 | FLOAT_TO_UBYTE(ctx->Color.BlendColor[2]) << 0); @@ -61,35 +59,32 @@ nv10_emit_blend_color(struct gl_context *ctx, int emit) void nv10_emit_blend_equation(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_ENABLE, 1); - OUT_RINGb(chan, ctx->Color.BlendEnabled); + BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1); + PUSH_DATAb(push, ctx->Color.BlendEnabled); - BEGIN_RING(chan, celsius, NV10_3D_BLEND_EQUATION, 1); - OUT_RING(chan, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB)); + BEGIN_NV04(push, NV10_3D(BLEND_EQUATION), 1); + PUSH_DATA (push, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB)); } void nv10_emit_blend_func(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_SRC, 2); - OUT_RING(chan, nvgl_blend_func(ctx->Color.Blend[0].SrcRGB)); - OUT_RING(chan, nvgl_blend_func(ctx->Color.Blend[0].DstRGB)); + BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 2); + PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].SrcRGB)); + PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].DstRGB)); } void nv10_emit_color_mask(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_COLOR_MASK, 1); - OUT_RING(chan, ((ctx->Color.ColorMask[0][3] ? 1 << 24 : 0) | + BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1); + PUSH_DATA (push, ((ctx->Color.ColorMask[0][3] ? 1 << 24 : 0) | (ctx->Color.ColorMask[0][0] ? 1 << 16 : 0) | (ctx->Color.ColorMask[0][1] ? 1 << 8 : 0) | (ctx->Color.ColorMask[0][2] ? 1 << 0 : 0))); @@ -98,85 +93,78 @@ nv10_emit_color_mask(struct gl_context *ctx, int emit) void nv10_emit_depth(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); - - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_TEST_ENABLE, 1); - OUT_RINGb(chan, ctx->Depth.Test); - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_WRITE_ENABLE, 1); - OUT_RINGb(chan, ctx->Depth.Mask); - BEGIN_RING(chan, celsius, NV10_3D_DEPTH_FUNC, 1); - OUT_RING(chan, nvgl_comparison_op(ctx->Depth.Func)); + struct nouveau_pushbuf *push = context_push(ctx); + + BEGIN_NV04(push, NV10_3D(DEPTH_TEST_ENABLE), 1); + PUSH_DATAb(push, ctx->Depth.Test); + BEGIN_NV04(push, NV10_3D(DEPTH_WRITE_ENABLE), 1); + PUSH_DATAb(push, ctx->Depth.Mask); + BEGIN_NV04(push, NV10_3D(DEPTH_FUNC), 1); + PUSH_DATA (push, nvgl_comparison_op(ctx->Depth.Func)); } void nv10_emit_dither(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_DITHER_ENABLE, 1); - OUT_RINGb(chan, ctx->Color.DitherFlag); + BEGIN_NV04(push, NV10_3D(DITHER_ENABLE), 1); + PUSH_DATAb(push, ctx->Color.DitherFlag); } void nv10_emit_logic_opcode(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); assert(!ctx->Color.ColorLogicOpEnabled || context_chipset(ctx) >= 0x11); - BEGIN_RING(chan, celsius, NV11_3D_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RINGb(chan, ctx->Color.ColorLogicOpEnabled); - OUT_RING(chan, nvgl_logicop_func(ctx->Color.LogicOp)); + BEGIN_NV04(push, NV11_3D(COLOR_LOGIC_OP_ENABLE), 2); + PUSH_DATAb(push, ctx->Color.ColorLogicOpEnabled); + PUSH_DATA (push, nvgl_logicop_func(ctx->Color.LogicOp)); } void nv10_emit_shade_model(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_SHADE_MODEL, 1); - OUT_RING(chan, ctx->Light.ShadeModel == GL_SMOOTH ? + BEGIN_NV04(push, NV10_3D(SHADE_MODEL), 1); + PUSH_DATA (push, ctx->Light.ShadeModel == GL_SMOOTH ? NV10_3D_SHADE_MODEL_SMOOTH : NV10_3D_SHADE_MODEL_FLAT); } void nv10_emit_stencil_func(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_STENCIL_ENABLE, 1); - OUT_RINGb(chan, ctx->Stencil.Enabled); + BEGIN_NV04(push, NV10_3D(STENCIL_ENABLE), 1); + PUSH_DATAb(push, ctx->Stencil.Enabled); - BEGIN_RING(chan, celsius, NV10_3D_STENCIL_FUNC_FUNC, 3); - OUT_RING(chan, nvgl_comparison_op(ctx->Stencil.Function[0])); - OUT_RING(chan, ctx->Stencil.Ref[0]); - OUT_RING(chan, ctx->Stencil.ValueMask[0]); + BEGIN_NV04(push, NV10_3D(STENCIL_FUNC_FUNC), 3); + PUSH_DATA (push, nvgl_comparison_op(ctx->Stencil.Function[0])); + PUSH_DATA (push, ctx->Stencil.Ref[0]); + PUSH_DATA (push, ctx->Stencil.ValueMask[0]); } void nv10_emit_stencil_mask(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_STENCIL_MASK, 1); - OUT_RING(chan, ctx->Stencil.WriteMask[0]); + BEGIN_NV04(push, NV10_3D(STENCIL_MASK), 1); + PUSH_DATA (push, ctx->Stencil.WriteMask[0]); } void nv10_emit_stencil_op(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); - BEGIN_RING(chan, celsius, NV10_3D_STENCIL_OP_FAIL, 3); - OUT_RING(chan, nvgl_stencil_op(ctx->Stencil.FailFunc[0])); - OUT_RING(chan, nvgl_stencil_op(ctx->Stencil.ZFailFunc[0])); - OUT_RING(chan, nvgl_stencil_op(ctx->Stencil.ZPassFunc[0])); + BEGIN_NV04(push, NV10_3D(STENCIL_OP_FAIL), 3); + PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.FailFunc[0])); + PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZFailFunc[0])); + PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZPassFunc[0])); } diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c index a0d64b1b96c..0254341151b 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c @@ -37,8 +37,7 @@ nv10_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 *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_texture_unit *unit = &ctx->Texture.Unit[i]; int j; @@ -48,17 +47,16 @@ nv10_emit_tex_gen(struct gl_context *ctx, int emit) float *k = get_texgen_coeff(coord); if (k) { - BEGIN_RING(chan, celsius, - NV10_3D_TEX_GEN_COEFF(i, j), 4); - OUT_RINGp(chan, k, 4); + BEGIN_NV04(push, NV10_3D(TEX_GEN_COEFF(i, j)), 4); + PUSH_DATAp(push, k, 4); } - BEGIN_RING(chan, celsius, NV10_3D_TEX_GEN_MODE(i,j), 1); - OUT_RING(chan, nvgl_texgen_mode(coord->Mode)); + BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(i,j)), 1); + PUSH_DATA (push, nvgl_texgen_mode(coord->Mode)); } else { - BEGIN_RING(chan, celsius, NV10_3D_TEX_GEN_MODE(i,j), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(TEX_GEN_MODE(i,j)), 1); + PUSH_DATA (push, 0); } } @@ -70,21 +68,20 @@ nv10_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 *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); if (nctx->fallback == HWTNL && ((ctx->Texture._TexMatEnabled & 1 << i) || ctx->Texture.Unit[i]._GenFlags)) { - BEGIN_RING(chan, celsius, NV10_3D_TEX_MATRIX_ENABLE(i), 1); - OUT_RING(chan, 1); + BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(i)), 1); + PUSH_DATA (push, 1); - BEGIN_RING(chan, celsius, NV10_3D_TEX_MATRIX(i, 0), 16); - OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m); + BEGIN_NV04(push, NV10_3D(TEX_MATRIX(i, 0)), 16); + PUSH_DATAm(push, ctx->TextureMatrixStack[i].Top->m); } else { - BEGIN_RING(chan, celsius, NV10_3D_TEX_MATRIX_ENABLE(i), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(i)), 1); + PUSH_DATA (push, 0); } } @@ -147,18 +144,18 @@ void nv10_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 *celsius = 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; uint32_t tx_format, tx_filter, tx_enable; + PUSH_RESET(push, BUFCTX_TEX(i)); + if (!ctx->Texture.Unit[i]._ReallyEnabled) { - BEGIN_RING(chan, celsius, NV10_3D_TEX_ENABLE(i), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, 0); return; } @@ -183,10 +180,10 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit) | log2i(t->Sampler.MaxAnisotropy) << 4; if (t->Target == GL_TEXTURE_RECTANGLE) { - BEGIN_RING(chan, celsius, NV10_3D_TEX_NPOT_PITCH(i), 1); - OUT_RING(chan, s->pitch << 16); - BEGIN_RING(chan, celsius, NV10_3D_TEX_NPOT_SIZE(i), 1); - OUT_RING(chan, align(s->width, 2) << 16 | s->height); + BEGIN_NV04(push, NV10_3D(TEX_NPOT_PITCH(i)), 1); + PUSH_DATA (push, s->pitch << 16); + BEGIN_NV04(push, NV10_3D(TEX_NPOT_SIZE(i)), 1); + PUSH_DATA (push, align(s->width, 2) << 16 | s->height); tx_format |= get_tex_format_rect(ti); } else { @@ -211,19 +208,20 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit) } /* Write it to the hardware. */ - nouveau_bo_mark(bctx, celsius, NV10_3D_TEX_FORMAT(i), - s->bo, tx_format, 0, - NV10_3D_TEX_FORMAT_DMA0, - NV10_3D_TEX_FORMAT_DMA1, - bo_flags | NOUVEAU_BO_OR); - - nouveau_bo_markl(bctx, celsius, NV10_3D_TEX_OFFSET(i), + BEGIN_NV04(push, NV10_3D(TEX_FORMAT(i)), 1); + PUSH_MTHD (push, NV10_3D(TEX_FORMAT(i)), BUFCTX_TEX(i), + s->bo, tx_format, bo_flags | NOUVEAU_BO_OR, + NV10_3D_TEX_FORMAT_DMA0, + NV10_3D_TEX_FORMAT_DMA1); + + BEGIN_NV04(push, NV10_3D(TEX_OFFSET(i)), 1); + PUSH_MTHDl(push, NV10_3D(TEX_OFFSET(i)), BUFCTX_TEX(i), s->bo, s->offset, bo_flags); - BEGIN_RING(chan, celsius, NV10_3D_TEX_FILTER(i), 1); - OUT_RING(chan, tx_filter); + BEGIN_NV04(push, NV10_3D(TEX_FILTER(i)), 1); + PUSH_DATA (push, tx_filter); - BEGIN_RING(chan, celsius, NV10_3D_TEX_ENABLE(i), 1); - OUT_RING(chan, tx_enable); + BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, tx_enable); } diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c index e21d8f12caf..a239f88cdcd 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c @@ -56,12 +56,11 @@ get_material_bitmask(unsigned m) void nv10_emit_color_material(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); unsigned mask = get_material_bitmask(ctx->Light.ColorMaterialBitmask); - BEGIN_RING(chan, celsius, NV10_3D_COLOR_MATERIAL, 1); - OUT_RING(chan, ctx->Light.ColorMaterialEnabled ? mask : 0); + BEGIN_NV04(push, NV10_3D(COLOR_MATERIAL), 1); + PUSH_DATA (push, ctx->Light.ColorMaterialEnabled ? mask : 0); } static unsigned @@ -133,8 +132,7 @@ void nv10_emit_fog(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_fog_attrib *f = &ctx->Fog; unsigned source = nctx->fallback == HWTNL ? f->FogCoordinateSource : GL_FOG_COORDINATE_EXT; @@ -142,14 +140,14 @@ nv10_emit_fog(struct gl_context *ctx, int emit) nv10_get_fog_coeff(ctx, k); - BEGIN_RING(chan, celsius, NV10_3D_FOG_MODE, 4); - OUT_RING(chan, get_fog_mode(f->Mode)); - OUT_RING(chan, get_fog_source(source, f->FogDistanceMode)); - OUT_RINGb(chan, f->Enabled); - OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); + BEGIN_NV04(push, NV10_3D(FOG_MODE), 4); + PUSH_DATA (push, get_fog_mode(f->Mode)); + PUSH_DATA (push, get_fog_source(source, f->FogDistanceMode)); + PUSH_DATAb(push, f->Enabled); + PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); - BEGIN_RING(chan, celsius, NV10_3D_FOG_COEFF(0), 3); - OUT_RINGp(chan, k, 3); + BEGIN_NV04(push, NV10_3D(FOG_COEFF(0)), 3); + PUSH_DATAp(push, k, 3); context_dirty(ctx, FRAG); } @@ -173,40 +171,38 @@ void nv10_emit_light_enable(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); uint32_t en_lights = 0; int i; if (nctx->fallback != HWTNL) { - BEGIN_RING(chan, celsius, NV10_3D_LIGHTING_ENABLE, 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1); + PUSH_DATA (push, 0); return; } for (i = 0; i < MAX_LIGHTS; i++) en_lights |= get_light_mode(&ctx->Light.Light[i]) << 2 * i; - BEGIN_RING(chan, celsius, NV10_3D_ENABLED_LIGHTS, 1); - OUT_RING(chan, en_lights); - BEGIN_RING(chan, celsius, NV10_3D_LIGHTING_ENABLE, 1); - OUT_RINGb(chan, ctx->Light.Enabled); - BEGIN_RING(chan, celsius, NV10_3D_NORMALIZE_ENABLE, 1); - OUT_RINGb(chan, ctx->Transform.Normalize); + BEGIN_NV04(push, NV10_3D(ENABLED_LIGHTS), 1); + PUSH_DATA (push, en_lights); + BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1); + PUSH_DATAb(push, ctx->Light.Enabled); + BEGIN_NV04(push, NV10_3D(NORMALIZE_ENABLE), 1); + PUSH_DATAb(push, ctx->Transform.Normalize); } void nv10_emit_light_model(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_lightmodel *m = &ctx->Light.Model; - BEGIN_RING(chan, celsius, NV10_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RINGb(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); + BEGIN_NV04(push, NV10_3D(SEPARATE_SPECULAR_ENABLE), 1); + PUSH_DATAb(push, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_MODEL, 1); - OUT_RING(chan, ((m->LocalViewer ? + BEGIN_NV04(push, NV10_3D(LIGHT_MODEL), 1); + PUSH_DATA (push, ((m->LocalViewer ? NV10_3D_LIGHT_MODEL_LOCAL_VIEWER : 0) | (_mesa_need_secondary_color(ctx) ? NV10_3D_LIGHT_MODEL_SEPARATE_SPECULAR : 0) | @@ -285,26 +281,24 @@ void nv10_emit_light_source(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_LIGHT_SOURCE0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_light *l = &ctx->Light.Light[i]; if (l->_Flags & LIGHT_POSITIONAL) { - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_POSITION_X(i), 3); - OUT_RINGp(chan, l->_Position, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_POSITION_X(i)), 3); + PUSH_DATAp(push, l->_Position, 3); - BEGIN_RING(chan, celsius, - NV10_3D_LIGHT_ATTENUATION_CONSTANT(i), 3); - OUT_RINGf(chan, l->ConstantAttenuation); - OUT_RINGf(chan, l->LinearAttenuation); - OUT_RINGf(chan, l->QuadraticAttenuation); + BEGIN_NV04(push, NV10_3D(LIGHT_ATTENUATION_CONSTANT(i)), 3); + PUSH_DATAf(push, l->ConstantAttenuation); + PUSH_DATAf(push, l->LinearAttenuation); + PUSH_DATAf(push, l->QuadraticAttenuation); } else { - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_DIRECTION_X(i), 3); - OUT_RINGp(chan, l->_VP_inf_norm, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_DIRECTION_X(i)), 3); + PUSH_DATAp(push, l->_VP_inf_norm, 3); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_HALF_VECTOR_X(i), 3); - OUT_RINGp(chan, l->_h_inf_norm, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_HALF_VECTOR_X(i)), 3); + PUSH_DATAp(push, l->_h_inf_norm, 3); } if (l->_Flags & LIGHT_SPOT) { @@ -312,8 +306,8 @@ nv10_emit_light_source(struct gl_context *ctx, int emit) nv10_get_spot_coeff(l, k); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_SPOT_CUTOFF(i, 0), 7); - OUT_RINGp(chan, k, 7); + BEGIN_NV04(push, NV10_3D(LIGHT_SPOT_CUTOFF(i, 0)), 7); + PUSH_DATAp(push, k, 7); } } @@ -324,8 +318,7 @@ nv10_emit_light_source(struct gl_context *ctx, int emit) void nv10_emit_material_ambient(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); float (*mat)[4] = ctx->Light.Material.Attrib; float c_scene[3], c_factor[3]; struct gl_light *l; @@ -344,12 +337,12 @@ nv10_emit_material_ambient(struct gl_context *ctx, int emit) ZERO_3V(c_factor); } - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_MODEL_AMBIENT_R, 3); - OUT_RINGp(chan, c_scene, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_MODEL_AMBIENT_R), 3); + PUSH_DATAp(push, c_scene, 3); if (ctx->Light.ColorMaterialEnabled) { - BEGIN_RING(chan, celsius, NV10_3D_MATERIAL_FACTOR_R, 3); - OUT_RINGp(chan, c_factor, 3); + BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_R), 3); + PUSH_DATAp(push, c_factor, 3); } foreach(l, &ctx->Light.EnabledList) { @@ -358,21 +351,20 @@ nv10_emit_material_ambient(struct gl_context *ctx, int emit) l->Ambient : l->_MatAmbient[0]); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_AMBIENT_R(i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_AMBIENT_R(i)), 3); + PUSH_DATAp(push, c_light, 3); } } void nv10_emit_material_diffuse(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLfloat (*mat)[4] = ctx->Light.Material.Attrib; struct gl_light *l; - BEGIN_RING(chan, celsius, NV10_3D_MATERIAL_FACTOR_A, 1); - OUT_RINGf(chan, mat[MAT_ATTRIB_FRONT_DIFFUSE][3]); + BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_A), 1); + PUSH_DATAf(push, mat[MAT_ATTRIB_FRONT_DIFFUSE][3]); foreach(l, &ctx->Light.EnabledList) { const int i = l - ctx->Light.Light; @@ -380,16 +372,15 @@ nv10_emit_material_diffuse(struct gl_context *ctx, int emit) l->Diffuse : l->_MatDiffuse[0]); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_DIFFUSE_R(i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_DIFFUSE_R(i)), 3); + PUSH_DATAp(push, c_light, 3); } } void nv10_emit_material_specular(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_light *l; foreach(l, &ctx->Light.EnabledList) { @@ -398,8 +389,8 @@ nv10_emit_material_specular(struct gl_context *ctx, int emit) l->Specular : l->_MatSpecular[0]); - BEGIN_RING(chan, celsius, NV10_3D_LIGHT_SPECULAR_R(i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, NV10_3D(LIGHT_SPECULAR_R(i)), 3); + PUSH_DATAp(push, c_light, 3); } } @@ -430,8 +421,7 @@ nv10_get_shininess_coeff(float s, float k[6]) void nv10_emit_material_shininess(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); float (*mat)[4] = ctx->Light.Material.Attrib; float k[6]; @@ -439,16 +429,15 @@ nv10_emit_material_shininess(struct gl_context *ctx, int emit) CLAMP(mat[MAT_ATTRIB_FRONT_SHININESS][0], 0, 1024), k); - BEGIN_RING(chan, celsius, NV10_3D_MATERIAL_SHININESS(0), 6); - OUT_RINGp(chan, k, 6); + BEGIN_NV04(push, NV10_3D(MATERIAL_SHININESS(0)), 6); + PUSH_DATAp(push, k, 6); } void nv10_emit_modelview(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLmatrix *m = ctx->ModelviewMatrixStack.Top; if (nctx->fallback != HWTNL) @@ -456,19 +445,18 @@ nv10_emit_modelview(struct gl_context *ctx, int emit) if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled || (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { - BEGIN_RING(chan, celsius, NV10_3D_MODELVIEW_MATRIX(0, 0), 16); - OUT_RINGm(chan, m->m); + BEGIN_NV04(push, NV10_3D(MODELVIEW_MATRIX(0, 0)), 16); + PUSH_DATAm(push, m->m); } if (ctx->Light.Enabled || (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { int i, j; - BEGIN_RING(chan, celsius, - NV10_3D_INVERSE_MODELVIEW_MATRIX(0, 0), 12); + BEGIN_NV04(push, NV10_3D(INVERSE_MODELVIEW_MATRIX(0, 0)), 12); for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) - OUT_RINGf(chan, m->inv[4*i + j]); + PUSH_DATAf(push, m->inv[4*i + j]); } } @@ -481,8 +469,7 @@ void nv10_emit_projection(struct gl_context *ctx, int emit) { struct nouveau_context *nctx = to_nouveau_context(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *celsius = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLmatrix m; _math_matrix_ctr(&m); @@ -494,8 +481,8 @@ nv10_emit_projection(struct gl_context *ctx, int emit) if (nctx->fallback == HWTNL) _math_matrix_mul_matrix(&m, &m, &ctx->_ModelProjectMatrix); - BEGIN_RING(chan, celsius, NV10_3D_PROJECTION_MATRIX(0), 16); - OUT_RINGm(chan, m.m); + BEGIN_NV04(push, NV10_3D(PROJECTION_MATRIX(0)), 16); + PUSH_DATAm(push, m.m); _math_matrix_dtr(&m); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index 83091fe8a7b..c91171791cc 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -38,13 +38,19 @@ static void nv20_clear(struct gl_context *ctx, GLbitfield buffers) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; uint32_t clear = 0; nouveau_validate_framebuffer(ctx); + nouveau_pushbuf_bufctx(push, nctx->hw.bufctx); + if (nouveau_pushbuf_validate(push)) { + nouveau_pushbuf_bufctx(push, NULL); + return; + } + if (buffers & BUFFER_BITS_COLOR) { struct nouveau_surface *s = &to_nouveau_renderbuffer( fb->_ColorDrawBuffers[0])->surface; @@ -58,8 +64,8 @@ nv20_clear(struct gl_context *ctx, GLbitfield buffers) if (ctx->Color.ColorMask[0][ACOMP]) clear |= NV20_3D_CLEAR_BUFFERS_COLOR_A; - BEGIN_RING(chan, kelvin, NV20_3D_CLEAR_VALUE, 1); - OUT_RING(chan, pack_rgba_clamp_f(s->format, ctx->Color.ClearColor.f)); + BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1); + PUSH_DATA (push, pack_rgba_clamp_f(s->format, ctx->Color.ClearColor.f)); buffers &= ~BUFFER_BITS_COLOR; } @@ -73,344 +79,347 @@ nv20_clear(struct gl_context *ctx, GLbitfield buffers) if (buffers & BUFFER_BIT_STENCIL && ctx->Stencil.WriteMask[0]) clear |= NV20_3D_CLEAR_BUFFERS_STENCIL; - BEGIN_RING(chan, kelvin, NV20_3D_CLEAR_DEPTH_VALUE, 1); - OUT_RING(chan, pack_zs_f(s->format, ctx->Depth.Clear, + BEGIN_NV04(push, NV20_3D(CLEAR_DEPTH_VALUE), 1); + PUSH_DATA (push, pack_zs_f(s->format, ctx->Depth.Clear, ctx->Stencil.Clear)); buffers &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); } - BEGIN_RING(chan, kelvin, NV20_3D_CLEAR_BUFFERS, 1); - OUT_RING(chan, clear); + BEGIN_NV04(push, NV20_3D(CLEAR_BUFFERS), 1); + PUSH_DATA (push, clear); + nouveau_pushbuf_bufctx(push, NULL); nouveau_clear(ctx, buffers); } static void nv20_hwctx_init(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; + struct nv04_fifo *fifo = hw->chan->data; int i; - BEGIN_RING(chan, kelvin, NV20_3D_DMA_NOTIFY, 1); - OUT_RING (chan, hw->ntfy->handle); - BEGIN_RING(chan, kelvin, NV20_3D_DMA_TEXTURE0, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->gart->handle); - BEGIN_RING(chan, kelvin, NV20_3D_DMA_COLOR, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->vram->handle); - BEGIN_RING(chan, kelvin, NV20_3D_DMA_VTXBUF0, 2); - OUT_RING(chan, chan->vram->handle); - OUT_RING(chan, chan->gart->handle); - - BEGIN_RING(chan, kelvin, NV20_3D_DMA_QUERY, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_RT_HORIZ, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING (chan, 0xfff << 16 | 0x0); - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING (chan, 0xfff << 16 | 0x0); + BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); + PUSH_DATA (push, hw->eng3d->handle); + BEGIN_NV04(push, NV20_3D(DMA_NOTIFY), 1); + PUSH_DATA (push, hw->ntfy->handle); + BEGIN_NV04(push, NV20_3D(DMA_TEXTURE0), 2); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->gart); + BEGIN_NV04(push, NV20_3D(DMA_COLOR), 2); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->vram); + BEGIN_NV04(push, NV20_3D(DMA_VTXBUF0), 2); + PUSH_DATA (push, fifo->vram); + PUSH_DATA (push, fifo->gart); + + BEGIN_NV04(push, NV20_3D(DMA_QUERY), 1); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1); + PUSH_DATA (push, 0xfff << 16 | 0x0); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1); + PUSH_DATA (push, 0xfff << 16 | 0x0); for (i = 1; i < NV20_3D_VIEWPORT_CLIP_HORIZ__LEN; i++) { - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_HORIZ(i), 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_VERT(i), 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(i)), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(i)), 1); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_MODE, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_MODE), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, kelvin, 0x17e0, 3); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); + BEGIN_NV04(push, SUBC_3D(0x17e0), 3); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); if (context_chipset(ctx) >= 0x25) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_RCOMP, 1); - OUT_RING (chan, NV20_3D_TEX_RCOMP_LEQUAL | 0xdb0); + BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1); + PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL | 0xdb0); } else { - BEGIN_RING(chan, kelvin, 0x1e68, 1); - OUT_RING (chan, 0x4b800000); /* 16777216.000000 */ - BEGIN_RING(chan, kelvin, NV20_3D_TEX_RCOMP, 1); - OUT_RING (chan, NV20_3D_TEX_RCOMP_LEQUAL); + BEGIN_NV04(push, SUBC_3D(0x1e68), 1); + PUSH_DATA (push, 0x4b800000); /* 16777216.000000 */ + BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1); + PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL); } - BEGIN_RING(chan, kelvin, 0x290, 1); - OUT_RING (chan, 0x10 << 16 | 1); - BEGIN_RING(chan, kelvin, 0x9fc, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, 0x1d80, 1); - OUT_RING (chan, 1); - BEGIN_RING(chan, kelvin, 0x9f8, 1); - OUT_RING (chan, 4); - BEGIN_RING(chan, kelvin, 0x17ec, 3); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); - OUT_RINGf (chan, 0.0); + BEGIN_NV04(push, SUBC_3D(0x290), 1); + PUSH_DATA (push, 0x10 << 16 | 1); + BEGIN_NV04(push, SUBC_3D(0x9fc), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, SUBC_3D(0x1d80), 1); + PUSH_DATA (push, 1); + BEGIN_NV04(push, SUBC_3D(0x9f8), 1); + PUSH_DATA (push, 4); + BEGIN_NV04(push, SUBC_3D(0x17ec), 3); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 0.0); if (context_chipset(ctx) >= 0x25) { - BEGIN_RING(chan, kelvin, 0x1d88, 1); - OUT_RING (chan, 3); + BEGIN_NV04(push, SUBC_3D(0x1d88), 1); + PUSH_DATA (push, 3); - BEGIN_RING(chan, kelvin, NV25_3D_DMA_HIERZ, 1); - OUT_RING (chan, chan->vram->handle); - BEGIN_RING(chan, kelvin, NV25_3D_UNK01AC, 1); - OUT_RING (chan, chan->vram->handle); + BEGIN_NV04(push, NV25_3D(DMA_HIERZ), 1); + PUSH_DATA (push, fifo->vram); + BEGIN_NV04(push, NV25_3D(UNK01AC), 1); + PUSH_DATA (push, fifo->vram); } - BEGIN_RING(chan, kelvin, NV20_3D_DMA_FENCE, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(DMA_FENCE), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, kelvin, 0x1e98, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, SUBC_3D(0x1e98), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, kelvin, NV01_GRAPH_NOTIFY, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV04_GRAPH(3D, NOTIFY), 1); + PUSH_DATA (push, 0); - BEGIN_RING(chan, kelvin, 0x120, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 1); - OUT_RING (chan, 2); + BEGIN_NV04(push, SUBC_3D(0x120), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 1); + PUSH_DATA (push, 2); if (context_chipset(ctx) >= 0x25) { - BEGIN_RING(chan, kelvin, 0x1da4, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, SUBC_3D(0x1da4), 1); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, kelvin, NV20_3D_RT_HORIZ, 2); - OUT_RING (chan, 0 << 16 | 0); - OUT_RING (chan, 0 << 16 | 0); + BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2); + PUSH_DATA (push, 0 << 16 | 0); + PUSH_DATA (push, 0 << 16 | 0); - BEGIN_RING(chan, kelvin, NV20_3D_ALPHA_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_ALPHA_FUNC_FUNC, 2); - OUT_RING (chan, NV20_3D_ALPHA_FUNC_FUNC_ALWAYS); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_FUNC), 2); + PUSH_DATA (push, NV20_3D_ALPHA_FUNC_FUNC_ALWAYS); + PUSH_DATA (push, 0); for (i = 0; i < NV20_3D_TEX__LEN; i++) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, kelvin, NV20_3D_TEX_SHADER_OP, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_TEX_SHADER_CULL_MODE, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_RC_IN_ALPHA(0), 4); - OUT_RING (chan, 0x30d410d0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_RC_OUT_RGB(0), 4); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_RC_ENABLE, 1); - OUT_RING (chan, 0x00011101); - BEGIN_RING(chan, kelvin, NV20_3D_RC_FINAL0, 2); - OUT_RING (chan, 0x130e0300); - OUT_RING (chan, 0x0c091c80); - BEGIN_RING(chan, kelvin, NV20_3D_RC_OUT_ALPHA(0), 4); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_RC_IN_RGB(0), 4); - OUT_RING (chan, 0x20c400c0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_RC_COLOR0, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_RC_CONSTANT_COLOR0(0), 4); - OUT_RING (chan, 0x035125a0); - OUT_RING (chan, 0); - OUT_RING (chan, 0x40002000); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_MULTISAMPLE_CONTROL, 1); - OUT_RING (chan, 0xffff0000); - BEGIN_RING(chan, kelvin, NV20_3D_BLEND_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_DITHER_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_STENCIL_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_BLEND_FUNC_SRC, 4); - OUT_RING (chan, NV20_3D_BLEND_FUNC_SRC_ONE); - OUT_RING (chan, NV20_3D_BLEND_FUNC_DST_ZERO); - OUT_RING (chan, 0); - OUT_RING (chan, NV20_3D_BLEND_EQUATION_FUNC_ADD); - BEGIN_RING(chan, kelvin, NV20_3D_STENCIL_MASK, 7); - OUT_RING (chan, 0xff); - OUT_RING (chan, NV20_3D_STENCIL_FUNC_FUNC_ALWAYS); - OUT_RING (chan, 0); - OUT_RING (chan, 0xff); - OUT_RING (chan, NV20_3D_STENCIL_OP_FAIL_KEEP); - OUT_RING (chan, NV20_3D_STENCIL_OP_ZFAIL_KEEP); - OUT_RING (chan, NV20_3D_STENCIL_OP_ZPASS_KEEP); - - BEGIN_RING(chan, kelvin, NV20_3D_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, NV20_3D_COLOR_LOGIC_OP_OP_COPY); - BEGIN_RING(chan, kelvin, 0x17cc, 1); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(TEX_SHADER_CULL_MODE), 1); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(RC_IN_ALPHA(0)), 4); + PUSH_DATA (push, 0x30d410d0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(RC_OUT_RGB(0)), 4); + PUSH_DATA (push, 0x00000c00); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1); + PUSH_DATA (push, 0x00011101); + BEGIN_NV04(push, NV20_3D(RC_FINAL0), 2); + PUSH_DATA (push, 0x130e0300); + PUSH_DATA (push, 0x0c091c80); + BEGIN_NV04(push, NV20_3D(RC_OUT_ALPHA(0)), 4); + PUSH_DATA (push, 0x00000c00); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(RC_IN_RGB(0)), 4); + PUSH_DATA (push, 0x20c400c0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(RC_COLOR0), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(RC_CONSTANT_COLOR0(0)), 4); + PUSH_DATA (push, 0x035125a0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0x40002000); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(MULTISAMPLE_CONTROL), 1); + PUSH_DATA (push, 0xffff0000); + BEGIN_NV04(push, NV20_3D(BLEND_FUNC_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(DITHER_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(STENCIL_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(BLEND_FUNC_SRC), 4); + PUSH_DATA (push, NV20_3D_BLEND_FUNC_SRC_ONE); + PUSH_DATA (push, NV20_3D_BLEND_FUNC_DST_ZERO); + PUSH_DATA (push, 0); + PUSH_DATA (push, NV20_3D_BLEND_EQUATION_FUNC_ADD); + BEGIN_NV04(push, NV20_3D(STENCIL_MASK), 7); + PUSH_DATA (push, 0xff); + PUSH_DATA (push, NV20_3D_STENCIL_FUNC_FUNC_ALWAYS); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0xff); + PUSH_DATA (push, NV20_3D_STENCIL_OP_FAIL_KEEP); + PUSH_DATA (push, NV20_3D_STENCIL_OP_ZFAIL_KEEP); + PUSH_DATA (push, NV20_3D_STENCIL_OP_ZPASS_KEEP); + + BEGIN_NV04(push, NV20_3D(COLOR_LOGIC_OP_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, NV20_3D_COLOR_LOGIC_OP_OP_COPY); + BEGIN_NV04(push, SUBC_3D(0x17cc), 1); + PUSH_DATA (push, 0); if (context_chipset(ctx) >= 0x25) { - BEGIN_RING(chan, kelvin, 0x1d84, 1); - OUT_RING (chan, 1); + BEGIN_NV04(push, SUBC_3D(0x1d84), 1); + PUSH_DATA (push, 1); } - BEGIN_RING(chan, kelvin, NV20_3D_LIGHTING_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL, 1); - OUT_RING (chan, NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL); - BEGIN_RING(chan, kelvin, NV20_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL_TWO_SIDE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_ENABLED_LIGHTS, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_NORMALIZE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_STIPPLE_PATTERN(0), + BEGIN_NV04(push, NV20_3D(LIGHTING_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(LIGHT_MODEL), 1); + PUSH_DATA (push, NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL); + BEGIN_NV04(push, NV20_3D(SEPARATE_SPECULAR_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(LIGHT_MODEL_TWO_SIDE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(ENABLED_LIGHTS), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(NORMALIZE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_PATTERN(0)), NV20_3D_POLYGON_STIPPLE_PATTERN__LEN); for (i = 0; i < NV20_3D_POLYGON_STIPPLE_PATTERN__LEN; i++) { - OUT_RING(chan, 0xffffffff); + PUSH_DATA (push, 0xffffffff); } - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_DEPTH_FUNC, 1); - OUT_RING (chan, NV20_3D_DEPTH_FUNC_LESS); - BEGIN_RING(chan, kelvin, NV20_3D_DEPTH_WRITE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_DEPTH_TEST_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_OFFSET_FACTOR, 2); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - BEGIN_RING(chan, kelvin, NV20_3D_DEPTH_CLAMP, 1); - OUT_RING (chan, 1); + BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_POINT_ENABLE), 3); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(DEPTH_FUNC), 1); + PUSH_DATA (push, NV20_3D_DEPTH_FUNC_LESS); + BEGIN_NV04(push, NV20_3D(DEPTH_WRITE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(DEPTH_TEST_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_FACTOR), 2); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + BEGIN_NV04(push, NV20_3D(DEPTH_CLAMP), 1); + PUSH_DATA (push, 1); if (context_chipset(ctx) < 0x25) { - BEGIN_RING(chan, kelvin, 0x1d84, 1); - OUT_RING (chan, 3); + BEGIN_NV04(push, SUBC_3D(0x1d84), 1); + PUSH_DATA (push, 3); } - BEGIN_RING(chan, kelvin, NV20_3D_POINT_SIZE, 1); + BEGIN_NV04(push, NV20_3D(POINT_SIZE), 1); if (context_chipset(ctx) >= 0x25) - OUT_RINGf (chan, 1.0); + PUSH_DATAf(push, 1.0); else - OUT_RING (chan, 8); + PUSH_DATA (push, 8); if (context_chipset(ctx) >= 0x25) { - BEGIN_RING(chan, kelvin, NV20_3D_POINT_PARAMETERS_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, 0x0a1c, 1); - OUT_RING (chan, 0x800); + BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, SUBC_3D(0x0a1c), 1); + PUSH_DATA (push, 0x800); } else { - BEGIN_RING(chan, kelvin, NV20_3D_POINT_PARAMETERS_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); + BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); } - BEGIN_RING(chan, kelvin, NV20_3D_LINE_WIDTH, 1); - OUT_RING (chan, 8); - BEGIN_RING(chan, kelvin, NV20_3D_LINE_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_MODE_FRONT, 2); - OUT_RING (chan, NV20_3D_POLYGON_MODE_FRONT_FILL); - OUT_RING (chan, NV20_3D_POLYGON_MODE_BACK_FILL); - BEGIN_RING(chan, kelvin, NV20_3D_CULL_FACE, 2); - OUT_RING (chan, NV20_3D_CULL_FACE_BACK); - OUT_RING (chan, NV20_3D_FRONT_FACE_CCW); - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_CULL_FACE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20_3D_SHADE_MODEL, 1); - OUT_RING (chan, NV20_3D_SHADE_MODEL_SMOOTH); - BEGIN_RING(chan, kelvin, NV20_3D_POLYGON_STIPPLE_ENABLE, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_TEX_GEN_MODE(0,0), + BEGIN_NV04(push, NV20_3D(LINE_WIDTH), 1); + PUSH_DATA (push, 8); + BEGIN_NV04(push, NV20_3D(LINE_SMOOTH_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(POLYGON_MODE_FRONT), 2); + PUSH_DATA (push, NV20_3D_POLYGON_MODE_FRONT_FILL); + PUSH_DATA (push, NV20_3D_POLYGON_MODE_BACK_FILL); + BEGIN_NV04(push, NV20_3D(CULL_FACE), 2); + PUSH_DATA (push, NV20_3D_CULL_FACE_BACK); + PUSH_DATA (push, NV20_3D_FRONT_FACE_CCW); + BEGIN_NV04(push, NV20_3D(POLYGON_SMOOTH_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(CULL_FACE_ENABLE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV20_3D(SHADE_MODEL), 1); + PUSH_DATA (push, NV20_3D_SHADE_MODEL_SMOOTH); + BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_ENABLE), 1); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(0,0)), 4 * NV20_3D_TEX_GEN_MODE__ESIZE); for (i=0; i < 4 * NV20_3D_TEX_GEN_MODE__LEN; i++) - OUT_RING(chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_FOG_COEFF(0), 3); - OUT_RINGf (chan, 1.5); - OUT_RINGf (chan, -0.090168); - OUT_RINGf (chan, 0.0); - BEGIN_RING(chan, kelvin, NV20_3D_FOG_MODE, 2); - OUT_RING (chan, NV20_3D_FOG_MODE_EXP_SIGNED); - OUT_RING (chan, NV20_3D_FOG_COORD_FOG); - BEGIN_RING(chan, kelvin, NV20_3D_FOG_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_ENGINE, 1); - OUT_RING (chan, NV20_3D_ENGINE_FIXED); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(FOG_COEFF(0)), 3); + PUSH_DATAf(push, 1.5); + PUSH_DATAf(push, -0.090168); + PUSH_DATAf(push, 0.0); + BEGIN_NV04(push, NV20_3D(FOG_MODE), 2); + PUSH_DATA (push, NV20_3D_FOG_MODE_EXP_SIGNED); + PUSH_DATA (push, NV20_3D_FOG_COORD_FOG); + BEGIN_NV04(push, NV20_3D(FOG_ENABLE), 2); + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(ENGINE), 1); + PUSH_DATA (push, NV20_3D_ENGINE_FIXED); for (i = 0; i < NV20_3D_TEX_MATRIX_ENABLE__LEN; i++) { - 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); } - BEGIN_RING(chan, kelvin, NV20_3D_VERTEX_ATTR_4F_X(1), 4 * 15); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); + BEGIN_NV04(push, NV20_3D(VERTEX_ATTR_4F_X(1)), 4 * 15); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 1.0); + PUSH_DATAf(push, 1.0); for (i = 0; i < 12; i++) { - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 1.0); } - BEGIN_RING(chan, kelvin, NV20_3D_EDGEFLAG_ENABLE, 1); - OUT_RING (chan, 1); - BEGIN_RING(chan, kelvin, NV20_3D_COLOR_MASK, 1); - OUT_RING (chan, 0x00010101); - BEGIN_RING(chan, kelvin, NV20_3D_CLEAR_VALUE, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20_3D_DEPTH_RANGE_NEAR, 2); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 16777216.0); - - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 16777215.0); - - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_SCALE_X, 4); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 16777215.0 * 0.5); - OUT_RINGf (chan, 65535.0); - - FIRE_RING(chan); + BEGIN_NV04(push, NV20_3D(EDGEFLAG_ENABLE), 1); + PUSH_DATA (push, 1); + BEGIN_NV04(push, NV20_3D(COLOR_MASK), 1); + PUSH_DATA (push, 0x00010101); + BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1); + PUSH_DATA (push, 0); + + BEGIN_NV04(push, NV20_3D(DEPTH_RANGE_NEAR), 2); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 16777216.0); + + BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 16777215.0); + + BEGIN_NV04(push, NV20_3D(VIEWPORT_SCALE_X), 4); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 0.0); + PUSH_DATAf(push, 16777215.0 * 0.5); + PUSH_DATAf(push, 65535.0); + + PUSH_KICK (push); } static void @@ -422,7 +431,7 @@ nv20_context_destroy(struct gl_context *ctx) nv20_swtnl_destroy(ctx); nv20_vbo_destroy(ctx); - nouveau_grobj_free(&nctx->hw.eng3d); + nouveau_object_del(&nctx->hw.eng3d); nouveau_context_deinit(ctx); FREE(ctx); @@ -467,12 +476,12 @@ nv20_context_create(struct nouveau_screen *screen, const struct gl_config *visua /* 3D engine. */ if (context_chipset(ctx) >= 0x25) - kelvin_class = NV25_3D; + kelvin_class = NV25_3D_CLASS; else - kelvin_class = NV20_3D; + kelvin_class = NV20_3D_CLASS; - ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001, kelvin_class, - &nctx->hw.eng3d); + ret = nouveau_object_new(context_chan(ctx), 0xbeef0001, kelvin_class, + NULL, 0, &nctx->hw.eng3d); if (ret) goto fail; diff --git a/src/mesa/drivers/dri/nouveau/nv20_render.c b/src/mesa/drivers/dri/nouveau/nv20_render.c index 2bdc85cda4e..2627bfa354f 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_render.c +++ b/src/mesa/drivers/dri/nouveau/nv20_render.c @@ -133,8 +133,7 @@ static void nv20_render_set_format(struct gl_context *ctx) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); int i, attr, hw_format; FOR_EACH_ATTR(render, i, attr) { @@ -150,8 +149,8 @@ nv20_render_set_format(struct gl_context *ctx) hw_format = NV20_3D_VTXBUF_FMT_TYPE_FLOAT; } - BEGIN_RING(chan, kelvin, NV20_3D_VTXBUF_FMT(i), 1); - OUT_RING(chan, hw_format); + BEGIN_NV04(push, NV20_3D(VTXBUF_FMT(i)), 1); + PUSH_DATA (push, hw_format); } } @@ -159,61 +158,65 @@ static void nv20_render_bind_vertices(struct gl_context *ctx) { struct nouveau_render_state *render = to_render_state(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, VERTEX); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); int i, attr; FOR_EACH_BOUND_ATTR(render, i, attr) { struct nouveau_array *a = &render->attrs[attr]; - nouveau_bo_mark(bctx, kelvin, - NV20_3D_VTXBUF_OFFSET(i), - a->bo, a->offset, 0, - 0, NV20_3D_VTXBUF_OFFSET_DMA1, - NOUVEAU_BO_LOW | NOUVEAU_BO_OR | - NOUVEAU_BO_GART | NOUVEAU_BO_RD); + BEGIN_NV04(push, NV20_3D(VTXBUF_OFFSET(i)), 1); + PUSH_MTHD (push, NV20_3D(VTXBUF_OFFSET(i)), BUFCTX_VTX, + a->bo, a->offset, NOUVEAU_BO_LOW | + NOUVEAU_BO_OR | NOUVEAU_BO_GART | + NOUVEAU_BO_RD, 0, + NV20_3D_VTXBUF_OFFSET_DMA1); } } +static void +nv20_render_release_vertices(struct gl_context *ctx) +{ + PUSH_RESET(context_push(ctx), BUFCTX_VTX); +} + /* Vertex array rendering defs. */ -#define RENDER_LOCALS(ctx) \ - struct nouveau_grobj *kelvin = context_eng3d(ctx) +#define RENDER_LOCALS(ctx) #define BATCH_VALIDATE() \ - BEGIN_RING(chan, kelvin, NV20_3D_VTXBUF_VALIDATE, 1); \ - OUT_RING(chan, 0) + BEGIN_NV04(push, NV20_3D(VTXBUF_VALIDATE), 1); \ + PUSH_DATA (push, 0) #define BATCH_BEGIN(prim) \ - BEGIN_RING(chan, kelvin, NV20_3D_VERTEX_BEGIN_END, 1); \ - OUT_RING(chan, prim) + BEGIN_NV04(push, NV20_3D(VERTEX_BEGIN_END), 1); \ + PUSH_DATA (push, prim) #define BATCH_END() \ - BEGIN_RING(chan, kelvin, NV20_3D_VERTEX_BEGIN_END, 1); \ - OUT_RING(chan, 0) + BEGIN_NV04(push, NV20_3D(VERTEX_BEGIN_END), 1); \ + PUSH_DATA (push, 0) #define MAX_PACKET 0x400 #define MAX_OUT_L 0x100 #define BATCH_PACKET_L(n) \ - BEGIN_RING_NI(chan, kelvin, NV20_3D_VTXBUF_BATCH, n) + BEGIN_NI04(push, NV20_3D(VTXBUF_BATCH), n) #define BATCH_OUT_L(i, n) \ - OUT_RING(chan, ((n) - 1) << 24 | (i)) + PUSH_DATA (push, ((n) - 1) << 24 | (i)) #define MAX_OUT_I16 0x2 #define BATCH_PACKET_I16(n) \ - BEGIN_RING_NI(chan, kelvin, NV20_3D_VTXBUF_ELEMENT_U16, n) + BEGIN_NI04(push, NV20_3D(VTXBUF_ELEMENT_U16), n) #define BATCH_OUT_I16(i0, i1) \ - OUT_RING(chan, (i1) << 16 | (i0)) + PUSH_DATA (push, (i1) << 16 | (i0)) #define MAX_OUT_I32 0x1 #define BATCH_PACKET_I32(n) \ - BEGIN_RING_NI(chan, kelvin, NV20_3D_VTXBUF_ELEMENT_U32, n) + BEGIN_NI04(push, NV20_3D(VTXBUF_ELEMENT_U32), n) #define BATCH_OUT_I32(i) \ - OUT_RING(chan, i) + PUSH_DATA (push, i) #define IMM_PACKET(m, n) \ - BEGIN_RING(chan, kelvin, m, n) + BEGIN_NV04(push, SUBC_3D(m), n) #define IMM_OUT(x) \ - OUT_RINGf(chan, x) + PUSH_DATAf(push, x) #define TAG(x) nv20_##x #include "nouveau_render_t.c" diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_fb.c b/src/mesa/drivers/dri/nouveau/nv20_state_fb.c index 28f72dcf437..9d8b1d173c8 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_fb.c @@ -54,9 +54,7 @@ get_rt_format(gl_format format) static void setup_hierz_buffer(struct gl_context *ctx) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, HIERZ); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb); unsigned pitch = align(fb->Width, 128), @@ -66,22 +64,20 @@ setup_hierz_buffer(struct gl_context *ctx) if (!nfb->hierz.bo || nfb->hierz.bo->size != size) { nouveau_bo_ref(NULL, &nfb->hierz.bo); nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, size, - &nfb->hierz.bo); + NULL, &nfb->hierz.bo); } - BEGIN_RING(chan, kelvin, NV25_3D_HIERZ_PITCH, 1); - OUT_RING(chan, pitch); - - nouveau_bo_markl(bctx, kelvin, NV25_3D_HIERZ_OFFSET, nfb->hierz.bo, - 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); + BEGIN_NV04(push, NV25_3D(HIERZ_PITCH), 1); + PUSH_DATA (push, pitch); + BEGIN_NV04(push, NV25_3D(HIERZ_OFFSET), 1); + PUSH_MTHDl(push, NV25_3D(HIERZ_OFFSET), BUFCTX_FB, + nfb->hierz.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); } void nv20_emit_framebuffer(struct gl_context *ctx, int emit) { - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); - struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct nouveau_surface *s; unsigned rt_format = NV20_3D_RT_FORMAT_TYPE_LINEAR; @@ -91,6 +87,8 @@ nv20_emit_framebuffer(struct gl_context *ctx, int emit) if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) return; + PUSH_RESET(push, BUFCTX_FB); + /* Render target */ if (fb->_ColorDrawBuffers[0]) { s = &to_nouveau_renderbuffer( @@ -99,7 +97,8 @@ nv20_emit_framebuffer(struct gl_context *ctx, int emit) rt_format |= get_rt_format(s->format); rt_pitch = s->pitch; - nouveau_bo_markl(bctx, kelvin, NV20_3D_COLOR_OFFSET, + BEGIN_NV04(push, NV20_3D(COLOR_OFFSET), 1); + PUSH_MTHDl(push, NV20_3D(COLOR_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); } @@ -111,7 +110,8 @@ nv20_emit_framebuffer(struct gl_context *ctx, int emit) rt_format |= get_rt_format(s->format); zeta_pitch = s->pitch; - nouveau_bo_markl(bctx, kelvin, NV20_3D_ZETA_OFFSET, + BEGIN_NV04(push, NV20_3D(ZETA_OFFSET), 1); + PUSH_MTHDl(push, NV20_3D(ZETA_OFFSET), BUFCTX_FB, s->bo, 0, bo_flags); if (context_chipset(ctx) >= 0x25) @@ -121,9 +121,9 @@ nv20_emit_framebuffer(struct gl_context *ctx, int emit) zeta_pitch = rt_pitch; } - BEGIN_RING(chan, kelvin, NV20_3D_RT_FORMAT, 2); - OUT_RING(chan, rt_format); - OUT_RING(chan, zeta_pitch << 16 | rt_pitch); + BEGIN_NV04(push, NV20_3D(RT_FORMAT), 2); + PUSH_DATA (push, rt_format); + PUSH_DATA (push, zeta_pitch << 16 | rt_pitch); /* Recompute the viewport/scissor state. */ context_dirty(ctx, VIEWPORT); @@ -133,20 +133,19 @@ nv20_emit_framebuffer(struct gl_context *ctx, int emit) void nv20_emit_viewport(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); struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; get_viewport_translate(ctx, a); - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGp(chan, a, 4); + BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4); + PUSH_DATAp(push, a, 4); - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING(chan, (fb->Width - 1) << 16); - BEGIN_RING(chan, kelvin, NV20_3D_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING(chan, (fb->Height - 1) << 16); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1); + PUSH_DATA (push, (fb->Width - 1) << 16); + BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1); + PUSH_DATA (push, (fb->Height - 1) << 16); context_dirty(ctx, PROJECTION); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c index 0624de442b9..492ecdc42fa 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c @@ -34,22 +34,21 @@ void nv20_emit_tex_env(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_TEX_ENV0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); uint32_t a_in, a_out, c_in, c_out, k; nv10_get_general_combiner(ctx, i, &a_in, &a_out, &c_in, &c_out, &k); - BEGIN_RING(chan, kelvin, NV20_3D_RC_IN_ALPHA(i), 1); - OUT_RING(chan, a_in); - BEGIN_RING(chan, kelvin, NV20_3D_RC_OUT_ALPHA(i), 1); - OUT_RING(chan, a_out); - BEGIN_RING(chan, kelvin, NV20_3D_RC_IN_RGB(i), 1); - OUT_RING(chan, c_in); - BEGIN_RING(chan, kelvin, NV20_3D_RC_OUT_RGB(i), 1); - OUT_RING(chan, c_out); - BEGIN_RING(chan, kelvin, NV20_3D_RC_CONSTANT_COLOR0(i), 1); - OUT_RING(chan, k); + BEGIN_NV04(push, NV20_3D(RC_IN_ALPHA(i)), 1); + PUSH_DATA (push, a_in); + BEGIN_NV04(push, NV20_3D(RC_OUT_ALPHA(i)), 1); + PUSH_DATA (push, a_out); + BEGIN_NV04(push, NV20_3D(RC_IN_RGB(i)), 1); + PUSH_DATA (push, c_in); + BEGIN_NV04(push, NV20_3D(RC_OUT_RGB(i)), 1); + PUSH_DATA (push, c_out); + BEGIN_NV04(push, NV20_3D(RC_CONSTANT_COLOR0(i)), 1); + PUSH_DATA (push, k); context_dirty(ctx, FRAG); } @@ -57,17 +56,16 @@ nv20_emit_tex_env(struct gl_context *ctx, int emit) void nv20_emit_frag(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); uint64_t in; int n; nv10_get_final_combiner(ctx, &in, &n); - BEGIN_RING(chan, kelvin, NV20_3D_RC_FINAL0, 2); - OUT_RING(chan, in); - OUT_RING(chan, in >> 32); + BEGIN_NV04(push, NV20_3D(RC_FINAL0), 2); + PUSH_DATA (push, in); + PUSH_DATA (push, in >> 32); - BEGIN_RING(chan, kelvin, NV20_3D_RC_ENABLE, 1); - OUT_RING(chan, n); + BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1); + PUSH_DATA (push, n); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_polygon.c b/src/mesa/drivers/dri/nouveau/nv20_state_polygon.c index 85f30dc4d41..4c562769046 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_polygon.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_polygon.c @@ -33,12 +33,11 @@ void nv20_emit_point_mode(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); - BEGIN_RING(chan, kelvin, NV20_3D_POINT_SIZE, 1); + BEGIN_NV04(push, NV20_3D(POINT_SIZE), 1); if (context_chipset(ctx) >= 0x25) - OUT_RINGf(chan, ctx->Point.Size); + PUSH_DATAf(push, ctx->Point.Size); else - OUT_RING(chan, (uint32_t)(ctx->Point.Size * 8)); + PUSH_DATA (push, (uint32_t)(ctx->Point.Size * 8)); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_raster.c b/src/mesa/drivers/dri/nouveau/nv20_state_raster.c index 3fb4ecae89f..4856053aa60 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_raster.c @@ -34,10 +34,9 @@ void nv20_emit_logic_opcode(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); - BEGIN_RING(chan, kelvin, NV20_3D_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RINGb(chan, ctx->Color.ColorLogicOpEnabled); - OUT_RING(chan, nvgl_logicop_func(ctx->Color.LogicOp)); + BEGIN_NV04(push, NV20_3D(COLOR_LOGIC_OP_ENABLE), 2); + PUSH_DATAb(push, ctx->Color.ColorLogicOpEnabled); + PUSH_DATA (push, nvgl_logicop_func(ctx->Color.LogicOp)); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index 0b1bd856bc3..799510daa69 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -37,8 +37,7 @@ 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 +47,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 +66,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); } } @@ -151,18 +148,18 @@ 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; uint32_t tx_format, tx_filter, tx_wrap, tx_enable; + PUSH_RESET(push, BUFCTX_TEX(i)); + if (!ctx->Texture.Unit[i]._ReallyEnabled) { - BEGIN_RING(chan, kelvin, NV20_3D_TEX_ENABLE(i), 1); - OUT_RING(chan, 0); + BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1); + PUSH_DATA (push, 0); context_dirty(ctx, TEX_SHADER); return; @@ -195,10 +192,10 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit) | log2i(t->Sampler.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 { @@ -223,23 +220,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); } @@ -247,8 +245,7 @@ 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; @@ -259,6 +256,6 @@ nv20_emit_tex_shader(struct gl_context *ctx, int emit) 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); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c index 638c5f0e37f..181f3fe2e02 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c @@ -88,12 +88,11 @@ get_material_bitmask(unsigned m) void nv20_emit_color_material(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); unsigned mask = get_material_bitmask(ctx->Light.ColorMaterialBitmask); - BEGIN_RING(chan, kelvin, NV20_3D_COLOR_MATERIAL, 1); - OUT_RING(chan, ctx->Light.ColorMaterialEnabled ? mask : 0); + BEGIN_NV04(push, NV20_3D(COLOR_MATERIAL), 1); + PUSH_DATA (push, ctx->Light.ColorMaterialEnabled ? mask : 0); } static unsigned @@ -152,8 +151,7 @@ void nv20_emit_fog(struct gl_context *ctx, int emit) { 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_fog_attrib *f = &ctx->Fog; unsigned source = nctx->fallback == HWTNL ? f->FogCoordinateSource : GL_FOG_COORDINATE_EXT; @@ -161,64 +159,62 @@ nv20_emit_fog(struct gl_context *ctx, int emit) nv10_get_fog_coeff(ctx, k); - BEGIN_RING(chan, kelvin, NV20_3D_FOG_MODE, 4); - OUT_RING(chan, ((source == GL_FRAGMENT_DEPTH_EXT && + BEGIN_NV04(push, NV20_3D(FOG_MODE), 4); + PUSH_DATA (push, ((source == GL_FRAGMENT_DEPTH_EXT && f->FogDistanceMode == GL_EYE_PLANE_ABSOLUTE_NV) ? get_fog_mode_unsigned(f->Mode) : get_fog_mode_signed(f->Mode))); - OUT_RING(chan, get_fog_source(source, f->FogDistanceMode)); - OUT_RINGb(chan, f->Enabled); - OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); + PUSH_DATA (push, get_fog_source(source, f->FogDistanceMode)); + PUSH_DATAb(push, f->Enabled); + PUSH_DATA (push, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); - BEGIN_RING(chan, kelvin, NV20_3D_FOG_COEFF(0), 3); - OUT_RINGp(chan, k, 3); + BEGIN_NV04(push, NV20_3D(FOG_COEFF(0)), 3); + PUSH_DATAp(push, k, 3); } void nv20_emit_light_model(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); struct gl_lightmodel *m = &ctx->Light.Model; - BEGIN_RING(chan, kelvin, NV20_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RINGb(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); + BEGIN_NV04(push, NV20_3D(SEPARATE_SPECULAR_ENABLE), 1); + PUSH_DATAb(push, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL, 1); - OUT_RING(chan, ((m->LocalViewer ? + BEGIN_NV04(push, NV20_3D(LIGHT_MODEL), 1); + PUSH_DATA (push, ((m->LocalViewer ? NV20_3D_LIGHT_MODEL_VIEWER_LOCAL : NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL) | (_mesa_need_secondary_color(ctx) ? NV20_3D_LIGHT_MODEL_SEPARATE_SPECULAR : 0))); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL_TWO_SIDE_ENABLE, 1); - OUT_RINGb(chan, ctx->Light.Model.TwoSide); + BEGIN_NV04(push, NV20_3D(LIGHT_MODEL_TWO_SIDE_ENABLE), 1); + PUSH_DATAb(push, ctx->Light.Model.TwoSide); } void nv20_emit_light_source(struct gl_context *ctx, int emit) { const int i = emit - NOUVEAU_STATE_LIGHT_SOURCE0; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_light *l = &ctx->Light.Light[i]; if (l->_Flags & LIGHT_POSITIONAL) { - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_POSITION_X(i), 3); - OUT_RINGp(chan, l->_Position, 3); + BEGIN_NV04(push, NV20_3D(LIGHT_POSITION_X(i)), 3); + PUSH_DATAp(push, l->_Position, 3); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_ATTENUATION_CONSTANT(i), 3); - OUT_RINGf(chan, l->ConstantAttenuation); - OUT_RINGf(chan, l->LinearAttenuation); - OUT_RINGf(chan, l->QuadraticAttenuation); + BEGIN_NV04(push, NV20_3D(LIGHT_ATTENUATION_CONSTANT(i)), 3); + PUSH_DATAf(push, l->ConstantAttenuation); + PUSH_DATAf(push, l->LinearAttenuation); + PUSH_DATAf(push, l->QuadraticAttenuation); } else { - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_DIRECTION_X(i), 3); - OUT_RINGp(chan, l->_VP_inf_norm, 3); + BEGIN_NV04(push, NV20_3D(LIGHT_DIRECTION_X(i)), 3); + PUSH_DATAp(push, l->_VP_inf_norm, 3); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_HALF_VECTOR_X(i), 3); - OUT_RINGp(chan, l->_h_inf_norm, 3); + BEGIN_NV04(push, NV20_3D(LIGHT_HALF_VECTOR_X(i)), 3); + PUSH_DATAp(push, l->_h_inf_norm, 3); } if (l->_Flags & LIGHT_SPOT) { @@ -226,8 +222,8 @@ nv20_emit_light_source(struct gl_context *ctx, int emit) nv10_get_spot_coeff(l, k); - BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_SPOT_CUTOFF(i, 0), 7); - OUT_RINGp(chan, k, 7); + BEGIN_NV04(push, NV20_3D(LIGHT_SPOT_CUTOFF(i, 0)), 7); + PUSH_DATAp(push, k, 7); } } @@ -239,8 +235,7 @@ void nv20_emit_material_ambient(struct gl_context *ctx, int emit) { const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); float (*mat)[4] = ctx->Light.Material.Attrib; float c_scene[3], c_factor[3]; struct gl_light *l; @@ -259,12 +254,12 @@ nv20_emit_material_ambient(struct gl_context *ctx, int emit) ZERO_3V(c_factor); } - BEGIN_RING(chan, kelvin, LIGHT_MODEL_AMBIENT_R(side), 3); - OUT_RINGp(chan, c_scene, 3); + BEGIN_NV04(push, SUBC_3D(LIGHT_MODEL_AMBIENT_R(side)), 3); + PUSH_DATAp(push, c_scene, 3); if (ctx->Light.ColorMaterialEnabled) { - BEGIN_RING(chan, kelvin, MATERIAL_FACTOR_R(side), 3); - OUT_RINGp(chan, c_factor, 3); + BEGIN_NV04(push, SUBC_3D(MATERIAL_FACTOR_R(side)), 3); + PUSH_DATAp(push, c_factor, 3); } foreach(l, &ctx->Light.EnabledList) { @@ -273,8 +268,8 @@ nv20_emit_material_ambient(struct gl_context *ctx, int emit) l->Ambient : l->_MatAmbient[side]); - BEGIN_RING(chan, kelvin, LIGHT_AMBIENT_R(side, i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, SUBC_3D(LIGHT_AMBIENT_R(side, i)), 3); + PUSH_DATAp(push, c_light, 3); } } @@ -282,13 +277,12 @@ void nv20_emit_material_diffuse(struct gl_context *ctx, int emit) { const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); GLfloat (*mat)[4] = ctx->Light.Material.Attrib; struct gl_light *l; - BEGIN_RING(chan, kelvin, MATERIAL_FACTOR_A(side), 1); - OUT_RINGf(chan, mat[MAT_ATTRIB_DIFFUSE(side)][3]); + BEGIN_NV04(push, SUBC_3D(MATERIAL_FACTOR_A(side)), 1); + PUSH_DATAf(push, mat[MAT_ATTRIB_DIFFUSE(side)][3]); foreach(l, &ctx->Light.EnabledList) { const int i = l - ctx->Light.Light; @@ -296,8 +290,8 @@ nv20_emit_material_diffuse(struct gl_context *ctx, int emit) l->Diffuse : l->_MatDiffuse[side]); - BEGIN_RING(chan, kelvin, LIGHT_DIFFUSE_R(side, i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, SUBC_3D(LIGHT_DIFFUSE_R(side, i)), 3); + PUSH_DATAp(push, c_light, 3); } } @@ -305,8 +299,7 @@ void nv20_emit_material_specular(struct gl_context *ctx, int emit) { const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); struct gl_light *l; foreach(l, &ctx->Light.EnabledList) { @@ -315,8 +308,8 @@ nv20_emit_material_specular(struct gl_context *ctx, int emit) l->Specular : l->_MatSpecular[side]); - BEGIN_RING(chan, kelvin, LIGHT_SPECULAR_R(side, i), 3); - OUT_RINGp(chan, c_light, 3); + BEGIN_NV04(push, SUBC_3D(LIGHT_SPECULAR_R(side, i)), 3); + PUSH_DATAp(push, c_light, 3); } } @@ -324,8 +317,7 @@ void nv20_emit_material_shininess(struct gl_context *ctx, int emit) { const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_SHININESS; - struct nouveau_channel *chan = context_chan(ctx); - struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct nouveau_pushbuf *push = context_push(ctx); float (*mat)[4] = ctx->Light.Material.Attrib; float k[6]; @@ -333,16 +325,15 @@ nv20_emit_material_shininess(struct gl_context *ctx, int emit) CLAMP(mat[MAT_ATTRIB_SHININESS(side)][0], 0, 1024), k); - BEGIN_RING(chan, kelvin, MATERIAL_SHININESS(side), 6); - OUT_RINGp(chan, k, 6); + BEGIN_NV04(push, SUBC_3D(MATERIAL_SHININESS(side)), 6); + PUSH_DATAp(push, k, 6); } void nv20_emit_modelview(struct gl_context *ctx, int emit) { 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); GLmatrix *m = ctx->ModelviewMatrixStack.Top; if (nctx->fallback != HWTNL) @@ -350,19 +341,18 @@ nv20_emit_modelview(struct gl_context *ctx, int emit) if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled || (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { - BEGIN_RING(chan, kelvin, NV20_3D_MODELVIEW_MATRIX(0, 0), 16); - OUT_RINGm(chan, m->m); + BEGIN_NV04(push, NV20_3D(MODELVIEW_MATRIX(0, 0)), 16); + PUSH_DATAm(push, m->m); } if (ctx->Light.Enabled || (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { int i, j; - BEGIN_RING(chan, kelvin, - NV20_3D_INVERSE_MODELVIEW_MATRIX(0, 0), 12); + BEGIN_NV04(push, NV20_3D(INVERSE_MODELVIEW_MATRIX(0, 0)), 12); for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) - OUT_RINGf(chan, m->inv[4*i + j]); + PUSH_DATAf(push, m->inv[4*i + j]); } } @@ -370,8 +360,7 @@ void nv20_emit_projection(struct gl_context *ctx, int emit) { 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); GLmatrix m; _math_matrix_ctr(&m); @@ -380,8 +369,8 @@ nv20_emit_projection(struct gl_context *ctx, int emit) if (nctx->fallback == HWTNL) _math_matrix_mul_matrix(&m, &m, &ctx->_ModelProjectMatrix); - BEGIN_RING(chan, kelvin, NV20_3D_PROJECTION_MATRIX(0), 16); - OUT_RINGm(chan, m.m); + BEGIN_NV04(push, NV20_3D(PROJECTION_MATRIX(0)), 16); + PUSH_DATAm(push, m.m); _math_matrix_dtr(&m); } diff --git a/src/mesa/drivers/dri/nouveau/nv_object.xml.h b/src/mesa/drivers/dri/nouveau/nv_object.xml.h index d5ed4bceb55..5d08e999c60 100644 --- a/src/mesa/drivers/dri/nouveau/nv_object.xml.h +++ b/src/mesa/drivers/dri/nouveau/nv_object.xml.h @@ -1,5 +1,10 @@ -#ifndef NV_OBJECT_XML -#define NV_OBJECT_XML +#ifndef _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML +#define _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML + +/* WARNING ABOUT NOT EDITING AUTOGENERATED FILE IGNORED, _CLASS SUFFIX HAS + * BEEN ADDED TO ALL THE OBJECT CLASS DEFINITIONS TO AVOID CONFLICTS WITH + * THE RING MACROS WE WANT TO USE + */ /* Autogenerated file, DO NOT EDIT manually! @@ -8,12 +13,13 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng git clone git://0x04.net/rules-ng-ng The rules-ng-ng source files this header was generated from are: -- nv_object.xml ( 11547 bytes, from 2010-11-13 23:32:57) -- copyright.xml ( 6452 bytes, from 2010-11-15 15:10:58) -- nvchipsets.xml ( 3074 bytes, from 2010-11-13 23:32:57) -- nv_defs.xml ( 4437 bytes, from 2010-11-01 00:28:46) +- /home/skeggsb/git/envytools/rnndb/nv_object.xml ( 12672 bytes, from 2011-10-22 08:01:09) +- /home/skeggsb/git/envytools/rnndb/copyright.xml ( 6452 bytes, from 2011-10-22 08:01:09) +- /home/skeggsb/git/envytools/rnndb/nvchipsets.xml ( 3617 bytes, from 2011-10-22 08:01:09) +- /home/skeggsb/git/envytools/rnndb/nv_defs.xml ( 4437 bytes, from 2011-10-22 08:01:09) +- /home/skeggsb/git/envytools/rnndb/nv50_defs.xml ( 5468 bytes, from 2011-10-22 08:01:09) -Copyright (C) 2006-2010 by the following authors: +Copyright (C) 2006-2011 by the following authors: - Artur Huillet <[email protected]> (ahuillet) - Ben Skeggs (darktama, darktama_) - B. R. <[email protected]> (koala_br) @@ -72,128 +78,146 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define NV01_ROOT 0x00000001 -#define NV01_CONTEXT_DMA 0x00000002 -#define NV01_DEVICE 0x00000003 -#define NV01_TIMER 0x00000004 -#define NV01_NULL 0x00000030 -#define NV01_MEMORY_LOCAL_BANKED 0x0000003d -#define NV01_MAPPING_SYSTEM 0x0000003e -#define NV03_MEMORY_LOCAL_CURSOR 0x0000003f -#define NV01_MEMORY_LOCAL_LINEAR 0x00000040 -#define NV01_MAPPING_LOCAL 0x00000041 -#define NV03_VIDEO_LUT_CURSOR_DAC 0x00000046 -#define NV03_CHANNEL_PIO 0x0000006a -#define NV03_CHANNEL_DMA 0x0000006b -#define NV10_VIDEO_DISPLAY 0x0000007c -#define NV01_CONTEXT_BETA1 0x00000012 -#define NV04_BETA_SOLID 0x00000072 -#define NV01_CONTEXT_COLOR_KEY 0x00000017 -#define NV04_CONTEXT_COLOR_KEY 0x00000057 -#define NV01_CONTEXT_PATTERN 0x00000018 -#define NV01_CONTEXT_CLIP_RECTANGLE 0x00000019 -#define NV03_CONTEXT_ROP 0x00000043 -#define NV04_IMAGE_PATTERN 0x00000044 -#define NV01_RENDER_SOLID_LINE 0x0000001c -#define NV04_RENDER_SOLID_LINE 0x0000005c -#define NV30_RENDER_SOLID_LINE 0x0000035c -#define NV40_RENDER_SOLID_LINE 0x0000305c -#define NV01_RENDER_SOLID_TRIANGLE 0x0000001d -#define NV04_RENDER_SOLID_TRIANGLE 0x0000005d -#define NV01_RENDER_SOLID_RECTANGLE 0x0000001e -#define NV04_RENDER_SOLID_RECTANGLE 0x0000005e -#define NV01_IMAGE_BLIT 0x0000001f -#define NV04_IMAGE_BLIT 0x0000005f -#define NV11_IMAGE_BLIT 0x0000009f -#define NV01_IMAGE_FROM_CPU 0x00000021 -#define NV04_IMAGE_FROM_CPU 0x00000061 -#define NV05_IMAGE_FROM_CPU 0x00000065 -#define NV10_IMAGE_FROM_CPU 0x0000008a -#define NV30_IMAGE_FROM_CPU 0x0000038a -#define NV40_IMAGE_FROM_CPU 0x0000308a -#define NV03_STRETCHED_IMAGE_FROM_CPU 0x00000036 -#define NV04_STRETCHED_IMAGE_FROM_CPU 0x00000076 -#define NV05_STRETCHED_IMAGE_FROM_CPU 0x00000066 -#define NV30_STRETCHED_IMAGE_FROM_CPU 0x00000366 -#define NV40_STRETCHED_IMAGE_FROM_CPU 0x00003066 -#define NV03_SCALED_IMAGE_FROM_MEMORY 0x00000037 -#define NV04_SCALED_IMAGE_FROM_MEMORY 0x00000077 -#define NV05_SCALED_IMAGE_FROM_MEMORY 0x00000063 -#define NV10_SCALED_IMAGE_FROM_MEMORY 0x00000089 -#define NV30_SCALED_IMAGE_FROM_MEMORY 0x00000389 -#define NV40_SCALED_IMAGE_FROM_MEMORY 0x00003089 -#define NV50_SCALED_IMAGE_FROM_MEMORY 0x00005089 -#define NV04_DVD_SUBPICTURE 0x00000038 -#define NV10_DVD_SUBPICTURE 0x00000088 -#define NV03_GDI_RECTANGLE_TEXT 0x0000004b -#define NV04_GDI_RECTANGLE_TEXT 0x0000004a -#define NV04_SWIZZLED_SURFACE 0x00000052 -#define NV20_SWIZZLED_SURFACE 0x0000009e -#define NV30_SWIZZLED_SURFACE 0x0000039e -#define NV40_SWIZZLED_SURFACE 0x0000309e -#define NV03_CONTEXT_SURFACE_DST 0x00000058 -#define NV03_CONTEXT_SURFACE_SRC 0x00000059 -#define NV04_CONTEXT_SURFACES_2D 0x00000042 -#define NV10_CONTEXT_SURFACES_2D 0x00000062 -#define NV30_CONTEXT_SURFACES_2D 0x00000362 -#define NV40_CONTEXT_SURFACES_2D 0x00003062 -#define NV50_CONTEXT_SURFACES_2D 0x00005062 -#define NV04_INDEXED_IMAGE_FROM_CPU 0x00000060 -#define NV05_INDEXED_IMAGE_FROM_CPU 0x00000064 -#define NV30_INDEXED_IMAGE_FROM_CPU 0x00000364 -#define NV40_INDEXED_IMAGE_FROM_CPU 0x00003064 -#define NV10_TEXTURE_FROM_CPU 0x0000007b -#define NV30_TEXTURE_FROM_CPU 0x0000037b -#define NV40_TEXTURE_FROM_CPU 0x0000307b -#define NV04_M2MF 0x00000039 -#define NV50_M2MF 0x00005039 -#define NVC0_M2MF 0x00009039 -#define NV03_TEXTURED_TRIANGLE 0x00000048 -#define NV04_TEXTURED_TRIANGLE 0x00000054 -#define NV10_TEXTURED_TRIANGLE 0x00000094 -#define NV04_MULTITEX_TRIANGLE 0x00000055 -#define NV10_MULTITEX_TRIANGLE 0x00000095 -#define NV03_CONTEXT_SURFACE_COLOR 0x0000005a -#define NV03_CONTEXT_SURFACE_ZETA 0x0000005b -#define NV04_CONTEXT_SURFACES_3D 0x00000053 -#define NV10_CONTEXT_SURFACES_3D 0x00000093 -#define NV10_3D 0x00000056 -#define NV11_3D 0x00000096 -#define NV17_3D 0x00000099 -#define NV20_3D 0x00000097 -#define NV25_3D 0x00000597 -#define NV30_3D 0x00000397 -#define NV35_3D 0x00000497 -#define NV34_3D 0x00000697 -#define NV40_3D 0x00004097 -#define NV44_3D 0x00004497 -#define NV50_3D 0x00005097 -#define NV84_3D 0x00008297 -#define NVA0_3D 0x00008397 -#define NVA3_3D 0x00008597 -#define NVAF_3D 0x00008697 -#define NVC0_3D 0x00009097 -#define NV50_2D 0x0000502d -#define NVC0_2D 0x0000902d -#define NV50_COMPUTE 0x000050c0 -#define NVA3_COMPUTE 0x000085c0 -#define NVC0_COMPUTE 0x000090c0 -#define NV84_CRYPT 0x000074c1 -#define NV01_SUBCHAN__SIZE 0x00002000 +#define NV01_DMA_FROM_MEMORY_CLASS 0x00000002 +#define NV01_DMA_TO_MEMORY_CLASS 0x00000003 +#define NV01_NULL_CLASS 0x00000030 +#define NV03_DMA_IN_MEMORY_CLASS 0x0000003d +#define NV01_OP_CLIP_CLASS 0x00000010 +#define NV01_OP_BLEND_AND_CLASS 0x00000011 +#define NV01_BETA_CLASS 0x00000012 +#define NV04_BETA4_CLASS 0x00000072 +#define NV01_OP_ROP_AND_CLASS 0x00000013 +#define NV01_ROP_CLASS 0x00000014 +#define NV03_ROP_CLASS 0x00000043 +#define NV01_OP_CHROMA_CLASS 0x00000015 +#define NV01_OP_PLANE_SWITCH_CLASS 0x00000016 +#define NV01_CHROMA_CLASS 0x00000017 +#define NV04_CHROMA_CLASS 0x00000057 +#define NV01_PATTERN_CLASS 0x00000018 +#define NV04_PATTERN_CLASS 0x00000044 +#define NV01_CLIP_CLASS 0x00000019 +#define NV01_OP_SRCCOPY_AND_CLASS 0x00000064 +#define NV03_OP_SRCCOPY_CLASS 0x00000065 +#define NV04_OP_SRCCOPY_PREMULT_CLASS 0x00000066 +#define NV04_OP_BLEND_PREMULT_CLASS 0x00000067 +#define NV01_POINT_CLASS 0x0000001a +#define NV01_LINE_CLASS 0x0000001b +#define NV01_LIN_CLASS 0x0000001c +#define NV04_LIN_CLASS 0x0000005c +#define NV30_LIN_CLASS 0x0000035c +#define NV40_LIN_CLASS 0x0000305c +#define NV01_TRI_CLASS 0x0000001d +#define NV04_TRI_CLASS 0x0000005d +#define NV01_RECT_CLASS 0x0000001e +#define NV04_RECT_CLASS 0x0000005e +#define NV01_BLIT_CLASS 0x0000001f +#define NV04_BLIT_CLASS 0x0000005f +#define NV15_BLIT_CLASS 0x0000009f +#define NV01_IFROMMEM_CLASS 0x00000020 +#define NV01_IFC_CLASS 0x00000021 +#define NV04_IFC_CLASS 0x00000061 +#define NV05_IFC_CLASS 0x00000065 +#define NV10_IFC_CLASS 0x0000008a +#define NV30_IFC_CLASS 0x0000038a +#define NV40_IFC_CLASS 0x0000308a +#define NV01_BITMAP_CLASS 0x00000022 +#define NV01_ITOMEM_CLASS 0x00000025 +#define NV03_SIFC_CLASS 0x00000036 +#define NV04_SIFC_CLASS 0x00000076 +#define NV05_SIFC_CLASS 0x00000066 +#define NV30_SIFC_CLASS 0x00000366 +#define NV40_SIFC_CLASS 0x00003066 +#define NV03_SIFM_CLASS 0x00000037 +#define NV04_SIFM_CLASS 0x00000077 +#define NV05_SIFM_CLASS 0x00000063 +#define NV10_SIFM_CLASS 0x00000089 +#define NV30_SIFM_CLASS 0x00000389 +#define NV40_SIFM_CLASS 0x00003089 +#define NV50_SIFM_CLASS 0x00005089 +#define NV03_SYFM_CLASS 0x00000038 +#define NV03_GDI_CLASS 0x0000004b +#define NV04_GDI_CLASS 0x0000004a +#define NV04_SURFACE_SWZ_CLASS 0x00000052 +#define NV20_SURFACE_SWZ_CLASS 0x0000009e +#define NV30_SURFACE_SWZ_CLASS 0x0000039e +#define NV40_SURFACE_SWZ_CLASS 0x0000309e +#define NV03_SURFACE_DST_CLASS 0x00000058 +#define NV03_SURFACE_SRC_CLASS 0x00000059 +#define NV04_SURFACE_2D_CLASS 0x00000042 +#define NV10_SURFACE_2D_CLASS 0x00000062 +#define NV30_SURFACE_2D_CLASS 0x00000362 +#define NV40_SURFACE_2D_CLASS 0x00003062 +#define NV50_SURFACE_2D_CLASS 0x00005062 +#define NV04_INDEX_CLASS 0x00000060 +#define NV05_INDEX_CLASS 0x00000064 +#define NV30_INDEX_CLASS 0x00000364 +#define NV40_INDEX_CLASS 0x00003064 +#define NV10_TEXUPLOAD_CLASS 0x0000007b +#define NV30_TEXUPLOAD_CLASS 0x0000037b +#define NV40_TEXUPLOAD_CLASS 0x0000307b +#define NV04_DVD_SUBPICTURE_CLASS 0x00000038 +#define NV10_DVD_SUBPICTURE_CLASS 0x00000088 +#define NV03_M2MF_CLASS 0x00000039 +#define NV50_M2MF_CLASS 0x00005039 +#define NVC0_M2MF_CLASS 0x00009039 +#define NV03_SURFACE_COLOR_CLASS 0x0000005a +#define NV03_SURFACE_ZETA_CLASS 0x0000005b +#define NV03_TEXTURED_TRIANGLE_CLASS 0x00000048 +#define NV04_TEXTURED_TRIANGLE_CLASS 0x00000054 +#define NV10_TEXTURED_TRIANGLE_CLASS 0x00000094 +#define NV04_SURFACE_3D_CLASS 0x00000053 +#define NV10_SURFACE_3D_CLASS 0x00000093 +#define NV04_MULTITEX_TRIANGLE_CLASS 0x00000055 +#define NV10_MULTITEX_TRIANGLE_CLASS 0x00000095 +#define NV10_3D_CLASS 0x00000056 +#define NV15_3D_CLASS 0x00000096 +#define NV11_3D_CLASS 0x00000098 +#define NV17_3D_CLASS 0x00000099 +#define NV20_3D_CLASS 0x00000097 +#define NV25_3D_CLASS 0x00000597 +#define NV30_3D_CLASS 0x00000397 +#define NV35_3D_CLASS 0x00000497 +#define NV34_3D_CLASS 0x00000697 +#define NV40_3D_CLASS 0x00004097 +#define NV44_3D_CLASS 0x00004497 +#define NV50_3D_CLASS 0x00005097 +#define NV84_3D_CLASS 0x00008297 +#define NVA0_3D_CLASS 0x00008397 +#define NVA3_3D_CLASS 0x00008597 +#define NVAF_3D_CLASS 0x00008697 +#define NVC0_3D_CLASS 0x00009097 +#define NVC1_3D_CLASS 0x00009197 +#define NVC8_3D_CLASS 0x00009297 +#define NV50_2D_CLASS 0x0000502d +#define NVC0_2D_CLASS 0x0000902d +#define NV50_COMPUTE_CLASS 0x000050c0 +#define NVA3_COMPUTE_CLASS 0x000085c0 +#define NVC0_COMPUTE_CLASS 0x000090c0 +#define NVC8_COMPUTE_CLASS 0x000092c0 +#define NV84_CRYPT_CLASS 0x000074c1 +#define BLOB_NVC0_PCOPY1_CLASS 0x000090b8 +#define BLOB_NVC0_PCOPY0_CLASS 0x000090b5 +#define NV31_MPEG_CLASS 0x00003174 +#define NV84_MPEG_CLASS 0x00008274 + +#define NV01_SUBCHAN__SIZE 0x00008000 #define NV01_SUBCHAN 0x00000000 #define NV01_SUBCHAN_OBJECT 0x00000000 -#define NV84_SUBCHAN_QUERY_ADDRESS_HIGH 0x00000010 +#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH 0x00000010 -#define NV84_SUBCHAN_QUERY_ADDRESS_LOW 0x00000014 +#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_LOW 0x00000014 -#define NV84_SUBCHAN_QUERY_COUNTER 0x00000018 +#define NV84_SUBCHAN_SEMAPHORE_SEQUENCE 0x00000018 -#define NV84_SUBCHAN_QUERY_GET 0x0000001c +#define NV84_SUBCHAN_SEMAPHORE_TRIGGER 0x0000001c +#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL 0x00000001 +#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG 0x00000002 +#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL 0x00000004 -#define NV84_SUBCHAN_QUERY_INTR 0x00000020 +#define NV84_SUBCHAN_NOTIFY_INTR 0x00000020 #define NV84_SUBCHAN_WRCACHE_FLUSH 0x00000024 @@ -214,55 +238,64 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV04_GRAPH_NOP 0x00000100 -#define NV01_GRAPH_NOTIFY 0x00000104 -#define NV01_GRAPH_NOTIFY_WRITE 0x00000000 -#define NV01_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001 - -#define NV50_GRAPH_WAIT_FOR_IDLE 0x00000110 +#define NV04_GRAPH_NOTIFY 0x00000104 +#define NV04_GRAPH_NOTIFY_WRITE 0x00000000 +#define NV04_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001 -#define NVA3_GRAPH_UNK0120 0x00000120 +#define NVC0_GRAPH_NOTIFY_ADDRESS_HIGH 0x00000104 -#define NVA3_GRAPH_UNK0124 0x00000124 +#define NVC0_GRAPH_NOTIFY_ADDRESS_LOW 0x00000108 -#define NV40_GRAPH_PM_TRIGGER 0x00000140 +#define NVC0_GRAPH_NOTIFY 0x0000010c +#define NVC0_GRAPH_NOTIFY_WRITE 0x00000000 +#define NVC0_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001 -#define NVC0_SUBCHAN__SIZE 0x00008000 -#define NVC0_SUBCHAN 0x00000000 +#define NV50_GRAPH_SERIALIZE 0x00000110 -#define NVC0_SUBCHAN_OBJECT 0x00000000 +#define NVC0_GRAPH_MACRO_UPLOAD_POS 0x00000114 +#define NVC0_GRAPH_MACRO_UPLOAD_DATA 0x00000118 -#define NVC0_SUBCHAN_QUERY_ADDRESS_HIGH 0x00000010 +#define NVC0_GRAPH_MACRO_ID 0x0000011c -#define NVC0_SUBCHAN_QUERY_ADDRESS_LOW 0x00000014 +#define NVC0_GRAPH_MACRO_POS 0x00000120 -#define NVC0_SUBCHAN_QUERY_SEQUENCE 0x00000018 +#define NVA3_GRAPH_UNK0120 0x00000120 -#define NVC0_SUBCHAN_QUERY_GET 0x0000001c +#define NVA3_GRAPH_UNK0124 0x00000124 -#define NVC0_SUBCHAN_REF_CNT 0x00000050 +#define NVC0_GRAPH_UNK0124 0x00000124 -#define NVC0_GRAPH 0x00000000 +#define NVC0_GRAPH_COND_ADDRESS_HIGH 0x00000130 -#define NVC0_GRAPH_NOP 0x00000100 +#define NVC0_GRAPH_COND_ADDRESS_LOW 0x00000134 -#define NVC0_GRAPH_NOTIFY_ADDRESS_HIGH 0x00000104 +#define NVC0_GRAPH_COND_MODE 0x00000138 +#define NVC0_GRAPH_COND_MODE_NEVER 0x00000000 +#define NVC0_GRAPH_COND_MODE_ALWAYS 0x00000001 +#define NVC0_GRAPH_COND_MODE_RES_NON_ZERO 0x00000002 +#define NVC0_GRAPH_COND_MODE_EQUAL 0x00000003 +#define NVC0_GRAPH_COND_MODE_NOT_EQUAL 0x00000004 -#define NVC0_GRAPH_NOTIFY_ADDRESS_LOW 0x00000108 +#define NVC0_GRAPH_UNK013C 0x0000013c -#define NVC0_GRAPH_NOTIFY 0x0000010c -#define NVC0_GRAPH_NOTIFY_WRITE 0x00000000 -#define NVC0_GRAPH_NOTIFY_WRITE_AND_AWAKEN 0x00000001 +#define NV40_GRAPH_PM_TRIGGER 0x00000140 -#define NVC0_GRAPH_SERIALIZE 0x00000110 +#define NVC0_GRAPH_UNK0150 0x00000150 -#define NVC0_GRAPH_MACRO_UPLOAD_POS 0x00000114 +#define NVC0_GRAPH_UNK0154 0x00000154 -#define NVC0_GRAPH_MACRO_UPLOAD_DATA 0x00000118 +#define NVC0_GRAPH_SCRATCH(i0) (0x00003400 + 0x4*(i0)) +#define NVC0_GRAPH_SCRATCH__ESIZE 0x00000004 +#define NVC0_GRAPH_SCRATCH__LEN 0x00000080 -#define NVC0_GRAPH_MACRO_ID 0x0000011c +#define NVC0_GRAPH_MACRO(i0) (0x00003800 + 0x8*(i0)) +#define NVC0_GRAPH_MACRO__ESIZE 0x00000008 +#define NVC0_GRAPH_MACRO__LEN 0x00000080 -#define NVC0_GRAPH_MACRO_POS 0x00000120 +#define NVC0_GRAPH_MACRO_PARAM(i0) (0x00003804 + 0x8*(i0)) +#define NVC0_GRAPH_MACRO_PARAM__ESIZE 0x00000008 +#define NVC0_GRAPH_MACRO_PARAM__LEN 0x00000080 -#endif /* NV_OBJECT_XML */ +#endif /* _HOME_SKEGGSB_GIT_ENVYTOOLS_RNNDB_NV_OBJECT_XML */ |