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
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)
{
/* 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 */
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];
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);
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);
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;