diff options
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
20 files changed, 195 insertions, 220 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c index 684ed7b017..fc14060c04 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c @@ -41,7 +41,7 @@ nouveau_bo_download_from_screen(GLcontext *ctx, GLuint offset, GLuint size, DEBUG("..sys_mem\n"); in_mem = nouveau_mem_alloc(ctx, NOUVEAU_MEM_AGP, size, 0); if (in_mem) { - DEBUG("....via AGP\n"); + DEBUG("....via GART\n"); /* otherwise, try blitting to faster memory and * copying from there */ @@ -86,7 +86,7 @@ nouveau_bo_upload_to_screen(GLcontext *ctx, GLuint offset, GLuint size, NOUVEAU_MEM_MAPPED, size, 0); if (out_mem) { - DEBUG("....via AGP\n"); + DEBUG("....via GART\n"); _mesa_memcpy(out_mem->map, nbo->cpu_mem_sys + offset, size); nouveau_memformat_flat_emit(ctx, nbo->gpu_mem, out_mem, @@ -511,7 +511,7 @@ nouveauBufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size, gpu_flags = 0; break; default: - gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_AGP_OK; + gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_GART_OK; break; } nouveau_bo_init_storage(ctx, gpu_flags, size, data, usage, obj); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h index 932450fd87..3439a35e7c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h @@ -5,7 +5,7 @@ #include "nouveau_buffers.h" #define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE) -#define NOUVEAU_BO_AGP_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE) +#define NOUVEAU_BO_GART_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE) typedef struct nouveau_bufferobj_region_t { uint32_t start; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index b54f68f402..d498f616c9 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -32,8 +32,8 @@ nouveau_memformat_flat_emit(GLcontext *ctx, return GL_FALSE; } - src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP; - dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP; + src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; src_offset += nouveau_mem_gpu_offset_get(ctx, src); dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); @@ -69,7 +69,7 @@ void nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - drm_nouveau_mem_free_t memf; + struct drm_nouveau_mem_free memf; if (NOUVEAU_DEBUG & DEBUG_MEM) { fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", @@ -78,8 +78,8 @@ nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem) if (mem->map) drmUnmap(mem->map, mem->size); - memf.flags = mem->type; - memf.region_offset = mem->offset; + memf.flags = mem->type; + memf.offset = mem->offset; drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, sizeof(memf)); FREE(mem); } @@ -88,7 +88,7 @@ nouveau_mem * nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - drm_nouveau_mem_alloc_t mema; + struct drm_nouveau_mem_alloc mema; nouveau_mem *mem; int ret; @@ -111,7 +111,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) FREE(mem); return NULL; } - mem->offset = mema.region_offset; + mem->offset = mema.offset; mem->type = mema.flags; if (NOUVEAU_DEBUG & DEBUG_MEM) { @@ -120,7 +120,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) } if (type & NOUVEAU_MEM_MAPPED) - ret = drmMap(nmesa->driFd, mem->offset, mem->size, &mem->map); + ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, &mem->map); if (ret) { mem->map = NULL; nouveau_mem_free(ctx, mem); @@ -135,12 +135,7 @@ nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - if (mem->type & NOUVEAU_MEM_FB) - return (uint32_t)mem->offset - nmesa->vram_phys; - else if (mem->type & NOUVEAU_MEM_AGP) - return (uint32_t)mem->offset - nmesa->agp_phys; - else - return 0xDEADF00D; + return mem->offset; } static GLboolean @@ -299,6 +294,8 @@ nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, nmesa->pClipRects = dPriv->pClipRects; nmesa->drawX = dPriv->x; nmesa->drawY = dPriv->y; + nmesa->drawW = dPriv->w; + nmesa->drawH = dPriv->h; } static void @@ -313,6 +310,8 @@ nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, nmesa->osClipRect.y2 = nrb->mesa.Height; nmesa->drawX = 0; nmesa->drawY = 0; + nmesa->drawW = nrb->mesa.Width; + nmesa->drawH = nrb->mesa.Height; } void @@ -391,9 +390,12 @@ nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) } static void -nouveauBindFramebuffer(GLcontext *ctx, GLenum target, struct gl_framebuffer *fb) +nouveauBindFramebuffer(GLcontext *ctx, GLenum target, + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { - nouveau_build_framebuffer(ctx, fb); + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } } static void diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 8e11eb6134..44392c0267 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -145,10 +145,10 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, &nmesa->vram_size)) return GL_FALSE; if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL, - &nmesa->agp_phys)) + &nmesa->gart_phys)) return GL_FALSE; if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE, - &nmesa->agp_size)) + &nmesa->gart_size)) return GL_FALSE; if (!nouveauFifoInit(nmesa)) return GL_FALSE; @@ -180,7 +180,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, driParseConfigFiles (&nmesa->optionCache, &screen->optionCache, screen->driScreen->myNum, "nouveau"); - nmesa->sarea = (drm_nouveau_sarea_t *)((char *)sPriv->pSAREA + + nmesa->sarea = (struct drm_nouveau_sarea *)((char *)sPriv->pSAREA + screen->sarea_priv_offset); /* Enable any supported extensions */ @@ -224,6 +224,8 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, nv04TriInitFunctions( ctx ); break; case NV_10: + case NV_11: + case NV_17: case NV_20: case NV_30: case NV_40: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 87e4479da3..9a0be2cb2a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -99,19 +99,22 @@ typedef struct nouveau_context { /* The read-only regs */ volatile unsigned char* mmio; + /* The per-channel notifier block */ + volatile void *notifier_block; + /* Physical addresses of AGP/VRAM apertures */ uint64_t vram_phys; uint64_t vram_size; - uint64_t agp_phys; - uint64_t agp_size; + uint64_t gart_phys; + uint64_t gart_size; /* Channel synchronisation */ - nouveau_notifier *syncNotifier; + struct drm_nouveau_notifier_alloc *syncNotifier; /* ARB_occlusion_query / EXT_timer_query */ GLuint query_object_max; GLboolean * query_alloc; - nouveau_notifier *queryNotifier; + struct drm_nouveau_notifier_alloc *queryNotifier; /* Additional hw-specific functions */ nouveau_hw_func hw_func; @@ -150,7 +153,7 @@ typedef struct nouveau_context { GLuint numClipRects; drm_clip_rect_t *pClipRects; drm_clip_rect_t osClipRect; - GLuint drawX, drawY; + GLuint drawX, drawY, drawW, drawH; /* The rendering context information */ GLenum current_primitive; /* the current primitive enum */ @@ -165,7 +168,7 @@ typedef struct nouveau_context { nouveauShader *passthrough_fp; nouveauScreenRec *screen; - drm_nouveau_sarea_t *sarea; + struct drm_nouveau_sarea *sarea; __DRIcontextPrivate *driContext; /* DRI context */ __DRIscreenPrivate *driScreen; /* DRI screen */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index 00956aa8f8..ddc9535624 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -41,7 +41,7 @@ GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa, unsigned int param, uint64_t* value) { - drm_nouveau_getparam_t getp; + struct drm_nouveau_getparam getp; getp.param = param; if (!value || drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_GETPARAM, @@ -56,7 +56,7 @@ GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa, unsigned int param, uint64_t value) { - drm_nouveau_setparam_t setp; + struct drm_nouveau_setparam setp; setp.param = param; setp.value = value; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c index bd2b2eddd0..7b5e96b4c2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c @@ -98,14 +98,15 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa) // here we call the fifo initialization ioctl and fill in stuff accordingly GLboolean nouveauFifoInit(nouveauContextPtr nmesa) { - drm_nouveau_fifo_alloc_t fifo_init; - int i; + struct drm_nouveau_fifo_alloc fifo_init; + int i, ret; #ifdef NOUVEAU_RING_DEBUG return GL_TRUE; #endif - int ret; + fifo_init.fb_ctxdma_handle = NvDmaFB; + fifo_init.tt_ctxdma_handle = NvDmaTT; ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_FIFO_ALLOC, &fifo_init, sizeof(fifo_init)); if (ret) { FATAL("Fifo initialization ioctl failed (returned %d)\n",ret); @@ -117,12 +118,21 @@ GLboolean nouveauFifoInit(nouveauContextPtr nmesa) FATAL("Unable to map the fifo (returned %d)\n",ret); return GL_FALSE; } + ret = drmMap(nmesa->driFd, fifo_init.ctrl, fifo_init.ctrl_size, &nmesa->fifo.mmio); if (ret) { FATAL("Unable to map the control regs (returned %d)\n",ret); return GL_FALSE; } + ret = drmMap(nmesa->driFd, fifo_init.notifier, + fifo_init.notifier_size, + &nmesa->notifier_block); + if (ret) { + FATAL("Unable to map the notifier block (returned %d)\n",ret); + return GL_FALSE; + } + /* Setup our initial FIFO tracking params */ nmesa->fifo.channel = fifo_init.channel; nmesa->fifo.put_base = fifo_init.put_base; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_lock.c b/src/mesa/drivers/dri/nouveau/nouveau_lock.c index c119d14dd7..aa86c9e783 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_lock.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_lock.c @@ -44,7 +44,7 @@ void nouveauGetLock( nouveauContextPtr nmesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = nmesa->driDrawable; __DRIscreenPrivate *sPriv = nmesa->driScreen; - drm_nouveau_sarea_t *sarea = nmesa->sarea; + struct drm_nouveau_sarea *sarea = nmesa->sarea; drmGetLock( nmesa->driFd, nmesa->hHWContext, flags ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index b71acff430..a143488e8d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -7,61 +7,18 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, uint32_t handle, int class) { - drm_nouveau_object_init_t cto; + struct drm_nouveau_grobj_alloc cto; int ret; cto.channel = nmesa->fifo.channel; cto.handle = handle; cto.class = class; - ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_OBJECT_INIT, &cto, sizeof(cto)); + ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_GROBJ_ALLOC, + &cto, sizeof(cto)); return ret == 0; } -GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, - uint32_t handle, - int class, - uint32_t offset, - uint32_t size, - int target, - int access) -{ - drm_nouveau_dma_object_init_t dma; - int ret; - - dma.channel = nmesa->fifo.channel; - dma.class = class; - dma.handle = handle; - dma.target = target; - dma.access = access; - dma.offset = offset; - dma.size = size; - ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_DMA_OBJECT_INIT, - &dma, sizeof(dma)); - return ret == 0; -} - -GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, - uint32_t handle, int class, - nouveau_mem *mem, - int access) -{ - uint32_t offset = mem->offset; - int target = mem->type & (NOUVEAU_MEM_FB | NOUVEAU_MEM_AGP); - - if (!target) - return GL_FALSE; - - if (target & NOUVEAU_MEM_FB) - offset -= nmesa->vram_phys; - else if (target & NOUVEAU_MEM_AGP) - offset -= nmesa->agp_phys; - - return nouveauCreateDmaObject(nmesa, handle, class, - offset, mem->size, - target, access); -} - void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle) { BEGIN_RING_SIZE(subchannel, 0, 1); @@ -74,23 +31,16 @@ void nouveauObjectInit(nouveauContextPtr nmesa) return; #endif -/* We need to know vram size.. and AGP size (and even if the card is AGP..) */ - nouveauCreateDmaObject( nmesa, NvDmaFB, NV_DMA_IN_MEMORY, - 0, nmesa->vram_size, - NOUVEAU_MEM_FB, - NOUVEAU_MEM_ACCESS_RW); - nouveauCreateDmaObject( nmesa, NvDmaAGP, NV_DMA_IN_MEMORY, - 0, nmesa->agp_size, - NOUVEAU_MEM_AGP, - NOUVEAU_MEM_ACCESS_RW); - nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d); if (nmesa->screen->card->type>=NV_10) { nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D); - nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); } else { nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D); nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D); + } + if (nmesa->screen->card->type>=NV_11) { + nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); + } else { nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT); } nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.h b/src/mesa/drivers/dri/nouveau/nouveau_object.h index 0be9b4309c..8c72d014da 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.h @@ -14,7 +14,7 @@ enum DMAObjects { NvMemFormat = 0x80000022, NvCtxSurf3D = 0x80000023, NvDmaFB = 0xD0FB0001, - NvDmaAGP = 0xD0AA0001, + NvDmaTT = 0xD0AA0001, NvSyncNotify = 0xD0000001, NvQueryNotify = 0xD0000002 }; @@ -31,17 +31,5 @@ extern void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, i extern GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, uint32_t handle, int class); -extern GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, - uint32_t handle, - int class, - uint32_t offset, - uint32_t size, - int target, - int access); -extern GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, - uint32_t handle, - int class, - nouveau_mem *mem, - int access); #endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_query.c b/src/mesa/drivers/dri/nouveau/nouveau_query.c index de3f5b0378..0154140069 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_query.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_query.c @@ -68,7 +68,7 @@ nouveauBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); nouveau_query_object *nq = (nouveau_query_object *)q; - nouveau_notifier_reset(nmesa->queryNotifier, nq->notifier_id); + nouveau_notifier_reset(ctx, nmesa->queryNotifier, nq->notifier_id); switch (nmesa->screen->card->type) { case NV_20: @@ -105,12 +105,13 @@ nouveauUpdateQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveau_query_object *nq = (nouveau_query_object *)q; int status; - status = nouveau_notifier_status(nmesa->queryNotifier, + status = nouveau_notifier_status(ctx, nmesa->queryNotifier, nq->notifier_id); q->Ready = (status == NV_NOTIFY_STATE_STATUS_COMPLETED); if (q->Ready) - q->Result = nouveau_notifier_return_val(nmesa->queryNotifier, + q->Result = nouveau_notifier_return_val(ctx, + nmesa->queryNotifier, nq->notifier_id); } @@ -120,7 +121,7 @@ nouveauWaitQueryResult(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); nouveau_query_object *nq = (nouveau_query_object *)q; - nouveau_notifier_wait_status(nmesa->queryNotifier, nq->notifier_id, + nouveau_notifier_wait_status(ctx, nmesa->queryNotifier, nq->notifier_id, NV_NOTIFY_STATE_STATUS_COMPLETED, 0); nouveauUpdateQuery(ctx, target, q); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 7a4b9f1cd0..69b0691bb7 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 6 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 9 #error nouveau_drm.h version doesn't match expected version #endif dri_interface = interface; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index 74dec66afc..6e3f9fadf4 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -37,6 +37,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define HAVE_HW_STENCIL_SPANS 0 #define HAVE_HW_STENCIL_PIXELS 0 +static char *fake_span[1280*1024*4]; + #define HW_CLIPLOOP() \ do { \ int _nc = nmesa->numClipRects; \ @@ -52,6 +54,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. GLuint height = nrb->mesa.Height; \ GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \ (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \ + map = fake_span; \ GLuint p; \ (void) p; @@ -120,6 +123,6 @@ nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis) { if (nrb->mesa._ActualFormat == GL_RGBA8) nouveauInitPointers_ARGB8888(&nrb->mesa); - else if (nrb->mesa._ActualFormat == GL_RGB5) + else // if (nrb->mesa._ActualFormat == GL_RGB5) nouveauInitPointers_RGB565(&nrb->mesa); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index e9fd188d73..f618dcfc99 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -60,14 +60,14 @@ static void nouveauCalcViewport(GLcontext *ctx) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); const GLfloat *v = ctx->Viewport._WindowMap.m; GLfloat *m = nmesa->viewport.m; - GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY; + GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY + nmesa->drawH; nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF; m[MAT_SX] = v[MAT_SX]; m[MAT_TX] = v[MAT_TX] + xoffset + SUBPIXEL_X; m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = v[MAT_TY] + yoffset + SUBPIXEL_Y; + m[MAT_TY] = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y; m[MAT_SZ] = v[MAT_SZ] * nmesa->depth_scale; m[MAT_TZ] = v[MAT_TZ] * nmesa->depth_scale; @@ -162,6 +162,8 @@ void nouveauDDInitState(nouveauContextPtr nmesa) nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; case NV_10: + case NV_11: + case NV_17: nv10InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; case NV_20: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 30e6696269..8abc847e1e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -35,53 +35,53 @@ #include "nouveau_msg.h" #include "nouveau_sync.h" -nouveau_notifier * +#define NOTIFIER(__v) \ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ + volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset + +struct drm_nouveau_notifier_alloc * nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_notifier *notifier; + struct drm_nouveau_notifier_alloc *notifier; + int ret; #ifdef NOUVEAU_RING_DEBUG return NULL; #endif - notifier = CALLOC_STRUCT(nouveau_notifier_t); + notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc); if (!notifier) return NULL; - notifier->mem = nouveau_mem_alloc(ctx, - NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED, - count * NV_NOTIFIER_SIZE, - 0); - if (!notifier->mem) { - FREE(notifier); - return NULL; - } - - if (!nouveauCreateDmaObjectFromMem(nmesa, handle, NV_DMA_IN_MEMORY, - notifier->mem, - NOUVEAU_MEM_ACCESS_RW)) { - nouveau_mem_free(ctx, notifier->mem); + notifier->channel = nmesa->fifo.channel; + notifier->handle = handle; + notifier->count = count; + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC, + notifier, sizeof(*notifier)); + if (ret) { + MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret); FREE(notifier); return NULL; } - notifier->handle = handle; return notifier; } void -nouveau_notifier_destroy(GLcontext *ctx, nouveau_notifier *notifier) +nouveau_notifier_destroy(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier) { - /*XXX: free DMA object.. */ - nouveau_mem_free(ctx, notifier->mem); + /*XXX: free notifier object.. */ FREE(notifier); } void -nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_reset(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, + GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); #ifdef NOUVEAU_RING_DEBUG return; @@ -95,26 +95,31 @@ nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id) } GLuint -nouveau_notifier_status(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_status(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, + GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT; } GLuint -nouveau_notifier_return_val(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_return_val(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, + GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); return n[NV_NOTIFY_RETURN_VALUE/4]; } GLboolean -nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id, - GLuint status, GLuint timeout) +nouveau_notifier_wait_status(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, + GLuint id, GLuint status, GLuint timeout) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); unsigned int time = 0; #ifdef NOUVEAU_RING_DEBUG @@ -144,13 +149,14 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id, } void -nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier, - GLuint subc) +nouveau_notifier_wait_nop(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, + GLuint subc) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + NOTIFIER(n); GLboolean ret; - nouveau_notifier_reset(notifier, 0); + nouveau_notifier_reset(ctx, notifier, 0); BEGIN_RING_SIZE(subc, NV_NOTIFY, 1); OUT_RING (NV_NOTIFY_STYLE_WRITE_ONLY); @@ -158,7 +164,7 @@ nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier, OUT_RING (0); FIRE_RING(); - ret = nouveau_notifier_wait_status(notifier, 0, + ret = nouveau_notifier_wait_status(ctx, notifier, 0, NV_NOTIFY_STATE_STATUS_COMPLETED, 0 /* no timeout */); if (ret == GL_FALSE) MESSAGE("wait on notifier failed\n"); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h index 019d5f6629..b76af17276 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h @@ -47,21 +47,25 @@ #define NV_NOTIFY 0x00000104 #define NV_NOTIFY_STYLE_WRITE_ONLY 0 -typedef struct nouveau_notifier_t { - GLuint handle; - nouveau_mem *mem; -} nouveau_notifier; - -extern nouveau_notifier *nouveau_notifier_new(GLcontext *, GLuint handle, - GLuint count); -extern void nouveau_notifier_destroy(GLcontext *, nouveau_notifier *); -extern void nouveau_notifier_reset(nouveau_notifier *, GLuint id); -extern GLuint nouveau_notifier_status(nouveau_notifier *, GLuint id); -extern GLuint nouveau_notifier_return_val(nouveau_notifier *, GLuint id); -extern GLboolean nouveau_notifier_wait_status(nouveau_notifier *r, GLuint id, - GLuint status, GLuint timeout); -extern void nouveau_notifier_wait_nop(GLcontext *ctx, - nouveau_notifier *, GLuint subc); +extern struct drm_nouveau_notifier_alloc * +nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count); +extern void +nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifier_alloc *); +extern void +nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id); +extern GLuint +nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id); +extern GLuint +nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id); +extern GLboolean +nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id, GLuint status, GLuint timeout); +extern void +nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifier_alloc *, + GLuint subc); extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx); #endif diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 5f304ccab9..47c4b14ba6 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -697,8 +697,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) BEGIN_RING_SIZE(NvSub3D, 0x03f4, 1); OUT_RING(0); - /* not for nv10, only for >= nv11 */ - if ((nmesa->screen->card->id>>4) >= 0x11) { + if (nmesa->screen->card->type >= NV_11) { BEGIN_RING_SIZE(NvSub3D, 0x120, 3); OUT_RING(0); OUT_RING(1); @@ -739,11 +738,11 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, OUT_RING_CACHE(depth ? depth->offset : color[0]->offset); /* Always set to bottom left of buffer */ - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); + /*BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); OUT_RING_CACHEf (0.0); OUT_RING_CACHEf ((GLfloat) h); OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf (0.0); + OUT_RING_CACHEf (0.0);*/ return GL_TRUE; } diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 3bc84d862d..611469b6e4 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -58,7 +58,7 @@ static void nv10ResetLineStipple( GLcontext *ctx ); static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size) { - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -66,7 +66,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1); OUT_RING(primitive); - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA|NONINC_METHOD,size); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size); @@ -76,7 +76,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri inline void nv10FinishPrimitive(struct nouveau_context *nmesa) { - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -392,15 +392,6 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) int i; int slots=0; int total_size=0; - /* t_vertex_generic dereferences a NULL pointer if we - * pass NULL as the vp transform... - */ - const GLfloat ident_vp[16] = { - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 - }; nmesa->vertex_attr_count = 0; RENDERINPUTS_COPY(index, nmesa->render_inputs_bitset); @@ -431,28 +422,20 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) if (RENDERINPUTS_TEST(index, i)) { slots=i+1; - if (i==_TNL_ATTRIB_POS) - { - /* special-case POS */ - EMIT_ATTR(_TNL_ATTRIB_POS,EMIT_3F_VIEWPORT); - } - else + switch(attr_size[i]) { - switch(attr_size[i]) - { - case 1: - EMIT_ATTR(i,EMIT_1F); - break; - case 2: - EMIT_ATTR(i,EMIT_2F); - break; - case 3: - EMIT_ATTR(i,EMIT_3F); - break; - case 4: - EMIT_ATTR(i,EMIT_4F); - break; - } + case 1: + EMIT_ATTR(i,EMIT_1F); + break; + case 2: + EMIT_ATTR(i,EMIT_2F); + break; + case 3: + EMIT_ATTR(i,EMIT_3F); + break; + case 4: + EMIT_ATTR(i,EMIT_4F); + break; } if (i==_TNL_ATTRIB_COLOR0) nmesa->color_offset=total_size; @@ -465,13 +448,13 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) nmesa->vertex_size=_tnl_install_attrs( ctx, nmesa->vertex_attrs, nmesa->vertex_attr_count, - ident_vp, 0 ); + NULL, 0 ); assert(nmesa->vertex_size==total_size*4); /* * Tell the hardware about the vertex format */ - if (nmesa->screen->card->type==NV_10) { + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { int size; #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2 diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index 3d8d83a865..ccf2f6148b 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -568,10 +568,10 @@ static void nv20Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) y += nmesa->drawY; } - BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1); + /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1); OUT_RING_CACHE((w << 16) | x ); BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1, 1); - OUT_RING_CACHE((h << 16) | y ); + OUT_RING_CACHE((h << 16) | y );*/ } @@ -764,11 +764,11 @@ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color, } /* Always set to bottom left of buffer */ - BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); + /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); OUT_RING_CACHEf (0.0); OUT_RING_CACHEf ((GLfloat) h); OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf (0.0); + OUT_RING_CACHEf (0.0);*/ return GL_TRUE; } diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index ad21fa2730..9b010954b3 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -639,25 +639,45 @@ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer ); /** Set rasterization mode */ void (*RenderMode)(GLcontext *ctx, GLenum mode ); +/* Translate GL coords to window coords, clamping w/h to the + * dimensions of the window. + */ +static void nv30WindowCoords(nouveauContextPtr nmesa, + GLuint x, GLuint y, GLuint w, GLuint h, + GLuint *wX, GLuint *wY, GLuint *wW, GLuint *wH) +{ + if ((x+w) > nmesa->drawW) + w = nmesa->drawW - x; + (*wX) = x + nmesa->drawX; + (*wW) = w; + + if ((y+h) > nmesa->drawH) + h = nmesa->drawH - y; + (*wY) = (nmesa->drawH - y) - h + nmesa->drawY; + (*wH) = h; +} + /** Define the scissor box */ static void nv30Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + GLuint wX, wY, wW, wH; /* There's no scissor enable bit, so adjust the scissor to cover the * maximum draw buffer bounds */ if (!ctx->Scissor.Enabled) { - x = y = 0; - w = h = 4095; + wX = nmesa->drawX; + wY = nmesa->drawY; + wW = nmesa->drawW; + wH = nmesa->drawH; } else { - x += nmesa->drawX; - y += nmesa->drawY; + nv30WindowCoords(nmesa, x, y, w, h, &wX, &wY, &wW, &wH); } BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2); - OUT_RING_CACHE(((w) << 16) | x); - OUT_RING_CACHE(((h) << 16) | y); + OUT_RING_CACHE ((wW << 16) | wX); + OUT_RING_CACHE ((wH << 16) | wY); } /** Select flat or smooth shading */ @@ -751,19 +771,21 @@ static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; GLfloat *v = nmesa->viewport.m; - GLuint w = ctx->Viewport.Width; - GLuint h = ctx->Viewport.Height; - GLuint x = ctx->Viewport.X + nmesa->drawX; - GLuint y = ctx->Viewport.Y + nmesa->drawY; + GLuint wX, wY, wW, wH; + nv30WindowCoords(nmesa, ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + &wX, &wY, &wW, &wH); BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0, 2); - OUT_RING_CACHE((w << 16) | x); - OUT_RING_CACHE((h << 16) | y); + OUT_RING_CACHE ((wW << 16) | wX); + OUT_RING_CACHE ((wH << 16) | wY); + /* something to do with clears, possibly doesn't belong here */ BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS0, 2); - OUT_RING_CACHE(((w+x) << 16) | x); - OUT_RING_CACHE(((h+y) << 16) | y); + OUT_RING_CACHE(((nmesa->drawX + nmesa->drawW) << 16) | nmesa->drawX); + OUT_RING_CACHE(((nmesa->drawY + nmesa->drawH) << 16) | nmesa->drawY); + /* viewport transform */ BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OX, 8); OUT_RING_CACHEf (v[MAT_TX]); @@ -786,7 +808,7 @@ static GLboolean nv30InitCard(nouveauContextPtr nmesa) BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT1, 3); OUT_RING(NvDmaFB); - OUT_RING(NvDmaAGP); + OUT_RING(NvDmaTT); OUT_RING(NvDmaFB); BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT8, 1); OUT_RING(NvDmaFB); |