summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2006-12-23 23:51:24 +1100
committerBen Skeggs <[email protected]>2006-12-23 23:51:24 +1100
commitcb6a400dcd26089101c8a29a4eee198bd7ad9a58 (patch)
tree5f2b6137442afaad3bff407f2a7f85df36ad27bf /src/mesa
parentae8d8d132600cc544b7295c9554e6531bdbd8094 (diff)
nouveau: maintain numClipRects/pClipRects in context.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_buffers.c56
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_state.c13
-rw-r--r--src/mesa/drivers/dri/nouveau/nv30_state.c32
4 files changed, 46 insertions, 57 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
index 0a5efa8c2e2..e3e2a8099e2 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
@@ -214,10 +214,46 @@ nouveau_renderbuffer_new(GLenum internalFormat, GLvoid *map,
return nrb;
}
+static void
+nouveau_cliprects_drawable_set(nouveauContextPtr nmesa,
+ nouveau_renderbuffer *nrb)
+{
+ __DRIdrawablePrivate *dPriv = nrb->dPriv;
+
+ nmesa->numClipRects = dPriv->numClipRects;
+ nmesa->pClipRects = dPriv->pClipRects;
+ nmesa->drawX = dPriv->x;
+ nmesa->drawY = dPriv->y;
+}
+
+static void
+nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa,
+ nouveau_renderbuffer *nrb)
+{
+ nmesa->numClipRects = 1;
+ nmesa->pClipRects = &nmesa->osClipRect;
+ nmesa->osClipRect.x1 = 0;
+ nmesa->osClipRect.y1 = 0;
+ nmesa->osClipRect.x2 = nrb->mesa.Width;
+ nmesa->osClipRect.y2 = nrb->mesa.Height;
+ nmesa->drawX = 0;
+ nmesa->drawY = 0;
+}
+
void
nouveau_window_moved(GLcontext *ctx)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ nouveau_renderbuffer *nrb;
+
+ nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ if (!nrb)
+ return;
+
+ if (!nrb->dPriv)
+ nouveau_cliprects_renderbuffer_set(nmesa, nrb);
+ else
+ nouveau_cliprects_drawable_set(nmesa, nrb);
/* Viewport depends on window size/position, nouveauCalcViewport
* will take care of calling the hw-specific WindowMoved
@@ -252,26 +288,6 @@ nouveau_build_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
return GL_TRUE;
}
-nouveau_renderbuffer *
-nouveau_current_draw_buffer(GLcontext *ctx)
-{
- struct gl_framebuffer *fb = ctx->DrawBuffer;
- nouveau_renderbuffer *nrb;
-
- if (!fb)
- return NULL;
-
- if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)
- nrb = (nouveau_renderbuffer *)
- fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
- else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
- nrb = (nouveau_renderbuffer *)
- fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
- else
- nrb = NULL;
- return nrb;
-}
-
static struct gl_framebuffer *
nouveauNewFramebuffer(GLcontext *ctx, GLuint name)
{
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index d7730bd7964..ea28506b742 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -134,6 +134,8 @@ typedef struct nouveau_context {
/* Cliprects information */
GLuint numClipRects;
drm_clip_rect_t *pClipRects;
+ drm_clip_rect_t osClipRect;
+ GLuint drawX, drawY;
/* The rendering context information */
GLenum current_primitive; /* the current primitive enum */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index d3c233eb130..8df334d7006 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -62,22 +62,11 @@ static void nouveauCalcViewport(GLcontext *ctx)
nouveau_renderbuffer *nrb;
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat *m = nmesa->viewport.m;
- GLfloat xoffset, yoffset;
+ GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY;
GLint h = 0;
- nrb = nouveau_current_draw_buffer(ctx);
nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF;
- if (nrb && nrb->dPriv) {
- /* Window */
- xoffset = nrb->dPriv->x;
- yoffset = nrb->dPriv->y;
- } else {
- /* Offscreen or back buffer */
- xoffset = 0.0;
- yoffset = 0.0;
- }
-
m[MAT_SX] = v[MAT_SX];
m[MAT_TX] = v[MAT_TX] + xoffset + SUBPIXEL_X;
m[MAT_SY] = - v[MAT_SY];
diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c
index 35b428b37c2..7ccf5f98756 100644
--- a/src/mesa/drivers/dri/nouveau/nv30_state.c
+++ b/src/mesa/drivers/dri/nouveau/nv30_state.c
@@ -575,19 +575,15 @@ static void nv30Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
nouveau_renderbuffer *nrb;
- /* Adjust offsets if drawing to a window */
- nrb = nouveau_current_draw_buffer(ctx);
- if (nrb && nrb->dPriv) {
- x += nrb->dPriv->x;
- y += nrb->dPriv->y;
- }
-
/* 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;
+ } else {
+ x += nmesa->drawX;
+ y += nmesa->drawY;
}
BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2);
@@ -685,15 +681,8 @@ static void nv30WindowMoved(nouveauContextPtr nmesa)
GLfloat *v = nmesa->viewport.m;
GLuint w = ctx->Viewport.Width;
GLuint h = ctx->Viewport.Height;
- GLuint x = ctx->Viewport.X;
- GLuint y = ctx->Viewport.Y;
-
- /* Adjust offsets if drawing to a window */
- nrb = nouveau_current_draw_buffer(ctx);
- if (nrb && nrb->dPriv) {
- x += nrb->dPriv->x;
- y += nrb->dPriv->y;
- }
+ GLuint x = ctx->Viewport.X + nmesa->drawX;
+ GLuint y = ctx->Viewport.Y + nmesa->drawY;
BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0, 2);
OUT_RING_CACHE((w << 16) | x);
@@ -773,17 +762,10 @@ static GLboolean nv30BindBuffers(nouveauContextPtr nmesa, int num_color,
nouveau_renderbuffer *nrb;
GLuint x, y, w, h;
- /* Adjust offsets if drawing to a window */
- nrb = nouveau_current_draw_buffer(nmesa->glCtx);
w = nrb->mesa.Width;
h = nrb->mesa.Height;
- if (nrb && nrb->dPriv) {
- x = nrb->dPriv->x;
- y = nrb->dPriv->y;
- } else {
- x = 0;
- y = 0;
- }
+ x = nmesa->drawX;
+ y = nmesa->drawY;
if (num_color != 1)
return GL_FALSE;