Add some missing hooks. This should fix various little problems with window movement...
authorAapo Tahkola <aet@rasterburn.org>
Sat, 17 Dec 2005 11:39:40 +0000 (11:39 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Sat, 17 Dec 2005 11:39:40 +0000 (11:39 +0000)
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_state.h
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/r300/radeon_lock.c

index 0987735..975213d 100644 (file)
@@ -67,6 +67,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_tex.h"
 #include "r300_maos.h"
 
+#include "drirenderbuffer.h"
+
 static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -826,7 +828,7 @@ static void r300ClearStencil(GLcontext * ctx, GLint s)
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
-static void r300UpdateWindow(GLcontext * ctx)
+void r300UpdateWindow(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
@@ -868,6 +870,88 @@ static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
        r300UpdateWindow(ctx);
 }
 
+void r300UpdateViewportOffset( GLcontext *ctx )
+{
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       __DRIdrawablePrivate *dPriv = ((radeonContextPtr)rmesa)->dri.drawable;
+       GLfloat xoffset = (GLfloat)dPriv->x;
+       GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+       const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+       GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+       GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+
+       if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != *(GLuint *)&tx ||
+               rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != *(GLuint *)&ty )
+       {
+       /* Note: this should also modify whatever data the context reset
+        * code uses...
+        */
+       rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
+       rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
+      
+       }
+
+       radeonUpdateScissor( ctx );
+}
+
+/**
+ * Tell the card where to render (offset, pitch).
+ * Effected by glDrawBuffer, etc
+ */
+void
+r300UpdateDrawBuffer(GLcontext *ctx)
+{
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       r300ContextPtr r300 = rmesa;
+       struct gl_framebuffer *fb = ctx->DrawBuffer;
+       driRenderbuffer *drb;
+
+       if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+               /* draw to front */
+               drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+       }
+       else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+               /* draw to back */
+               drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+       }
+       else {
+               /* drawing to multiple buffers, or none */
+               return;
+       }
+
+       assert(drb);
+       assert(drb->flippedPitch);
+
+
+       R300_STATECHANGE( rmesa, cb );
+       
+       r300->hw.cb.cmd[R300_CB_OFFSET] = drb->flippedOffset + //r300->radeon.state.color.drawOffset +
+               r300->radeon.radeonScreen->fbLocation;
+       r300->hw.cb.cmd[R300_CB_PITCH] = drb->flippedPitch;//r300->radeon.state.color.drawPitch;
+       
+       if (r300->radeon.radeonScreen->cpp == 4)
+               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
+       else
+               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
+       
+       if (r300->radeon.sarea->tiling_enabled)
+               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
+#if 0
+       R200_STATECHANGE( rmesa, ctx );
+
+       /* Note: we used the (possibly) page-flipped values */
+       rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET]
+               = ((drb->flippedOffset + rmesa->r200Screen->fbLocation)
+               & R200_COLOROFFSET_MASK);
+       rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch;
+       
+       if (rmesa->sarea->tiling_enabled) {
+               rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+       }
+#endif
+}
+
 /* =============================================================
  * Polygon state
  */
@@ -1908,6 +1992,9 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
        _tnl_InvalidateState(ctx, new_state);
        _ae_invalidate_state(ctx, new_state);
 
+       if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+               r300UpdateDrawBuffer(ctx);
+       }
 #ifndef CB_DPATH
        /* Go inefficiency! */
        r300ResetHwState(r300);
index 9564c07..9262a14 100644 (file)
@@ -63,6 +63,7 @@ extern void r300ResetHwState(r300ContextPtr r300);
 
 extern void r300InitState(r300ContextPtr r300);
 extern void r300InitStateFuncs(struct dd_function_table* functions);
+extern void r300UpdateWindow(GLcontext * ctx);
 extern void r300SetupVertexShader(r300ContextPtr rmesa);
 extern void r300SetupPixelShader(r300ContextPtr rmesa);
 
index 0c45ce5..1bbe248 100644 (file)
@@ -300,6 +300,7 @@ static void r300SetTexImages(r300ContextPtr rmesa,
 
        /* Setup remaining cube face blits, if needed */
        if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+               WARN_ONCE("Cube map faces arent currently correctly positioned.\n");
                /* Round totalSize up to multiple of BLIT_WIDTH_BYTES */
                const GLuint faceSize =
                    (t->base.totalSize + BLIT_WIDTH_BYTES - 1)
index c045e80..b2abbaf 100644 (file)
@@ -260,6 +260,8 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
                                              radeon->vblank_flags);
                        radeon->dri.drawable = driDrawPriv;
                        
+                       r300UpdateWindow(radeon->glCtx);
+                       r300UpdateViewportOffset(radeon->glCtx);
 #if R200_MERGED
                        if (IS_R200_CLASS(radeon->radeonScreen)) {
                                r200UpdateWindow(radeon->glCtx);
index 2af3890..2209d89 100644 (file)
@@ -125,7 +125,12 @@ static void r300RegainedLock(radeonContextPtr radeon)
                else
                        radeonSetCliprects(radeon, GL_FRONT_LEFT);
 
+#if 1
+               r300UpdateViewportOffset( radeon->glCtx );
+               driUpdateFramebufferSize(radeon->glCtx, dPriv);
+#else
                radeonUpdateScissor(radeon->glCtx);
+#endif
                radeon->lastStamp = dPriv->lastStamp;
        }