Add magic sequence to prevent ClearBuffer from locking up.
authorVladimir Dergachev <volodya@freedesktop.org>
Mon, 31 Jan 2005 06:41:55 +0000 (06:41 +0000)
committerVladimir Dergachev <volodya@freedesktop.org>
Mon, 31 Jan 2005 06:41:55 +0000 (06:41 +0000)
Change Polygon.OffsetFill from fallback to warn once.
Quake demo now works, modulo texture rendering issues due to absent pixel shader pipeline.

src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_texmem.c

index 57a258487e4567811ace62bdbfc1988f72471736..8c8a8bfc71e61183551951dec63a625dd48f1f17 100644 (file)
@@ -54,6 +54,15 @@ typedef struct r300_context *r300ContextPtr;
 #include "radeon_lock.h"
 #include "mm.h"
 
+/* Checkpoint.. for convenience */
+#define CPT    { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }
+#define WARN_ONCE(a)   { \
+       static int warn=1; \
+       if(warn){ \
+               fprintf(stderr, (a)); \
+               warn=0;\
+               } \
+       }
 
 typedef GLuint uint32_t;
 typedef GLubyte uint8_t;
index 2bf70783f9d7648e97db60fea9f4c25a3cfa8d1e..b0222a129d7cf998003258de8ee82b1768ccb52e 100644 (file)
@@ -51,6 +51,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_state.h"
 #include "r300_program.h"
 #include "radeon_reg.h"
+#include "r300_emit.h"
 
 #include "vblank.h"
 
@@ -61,12 +62,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
 {
        GLcontext* ctx = r300->radeon.glCtx;
+       r300ContextPtr rmesa=r300;
        __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
        int i;
        GLuint cboffset, cbpitch;
-       drm_r300_cmd_header_t* cmd;
+       drm_r300_cmd_header_t* cmd2;
+       LOCAL_VARS;
 
-       if (RADEON_DEBUG & DEBUG_IOCTL)
+       if (1 || RADEON_DEBUG & DEBUG_IOCTL)
                fprintf(stderr, "%s: %s buffer (%i,%i %ix%i)\n",
                        __FUNCTION__, buffer ? "back" : "front",
                        dPriv->x, dPriv->y, dPriv->w, dPriv->h);
@@ -219,21 +222,38 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
        }
 
        /* Make sure we have enough space */
-       r300EnsureCmdBufSpace(r300, r300->hw.max_state_size + 9, __FUNCTION__);
-
+       r300EnsureCmdBufSpace(r300, r300->hw.max_state_size + 9+8, __FUNCTION__);
+
+   /* needed before starting 3d operation .. */
+   reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+       e32(0x0000000a);
+   
+   reg_start(0x4f18,0);
+       e32(0x00000003);
+       
        r300EmitState(r300);
 
-       cmd = (drm_r300_cmd_header_t*)r300AllocCmdBuf(r300, 9, __FUNCTION__);
-       cmd[0].packet3.cmd_type = R300_CMD_PACKET3;
-       cmd[0].packet3.packet = R300_CMD_PACKET3_CLEAR;
-       cmd[1].u = r300PackFloat32(dPriv->w / 2.0);
-       cmd[2].u = r300PackFloat32(dPriv->h / 2.0);
-       cmd[3].u = r300PackFloat32(ctx->Depth.Clear);
-       cmd[4].u = r300PackFloat32(1.0);
-       cmd[5].u = r300PackFloat32(ctx->Color.ClearColor[0]);
-       cmd[6].u = r300PackFloat32(ctx->Color.ClearColor[1]);
-       cmd[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
-       cmd[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
+       cmd2 = (drm_r300_cmd_header_t*)r300AllocCmdBuf(r300, 9, __FUNCTION__);
+       cmd2[0].packet3.cmd_type = R300_CMD_PACKET3;
+       cmd2[0].packet3.packet = R300_CMD_PACKET3_CLEAR;
+       cmd2[1].u = r300PackFloat32(dPriv->w / 2.0);
+       cmd2[2].u = r300PackFloat32(dPriv->h / 2.0);
+       cmd2[3].u = r300PackFloat32(ctx->Depth.Clear);
+       cmd2[4].u = r300PackFloat32(1.0);
+       cmd2[5].u = r300PackFloat32(ctx->Color.ClearColor[0]);
+       cmd2[6].u = r300PackFloat32(ctx->Color.ClearColor[1]);
+       cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
+       cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
+
+    /* This sequence is required after any 3d drawing packet
+      I suspect it work arounds a bug (or deficiency) in hardware */
+  
+   reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+       e32(0x0000000a);
+   
+   reg_start(0x4f18,0);
+       e32(0x00000003);
+         
 }
 
 
index f4596aad6395f5afe1d07f61fb3aa87d92e1fbfd..436b80bc83584e9cc8afbb003a699d6a793d89be 100644 (file)
@@ -213,7 +213,7 @@ static void r300_render_immediate_primitive(r300ContextPtr rmesa,
        return;
    }
    /* A packet cannot have more than 16383 data words.. */
-   if(((end-start)*8+4*rmesa->state.texture.tc_count)>16380){
+   if(((end-start)*4*rmesa->state.aos_count)>16380){
        fprintf(stderr, "%s:%s: Too many vertices to paint. Fix me !\n");
        return;         
        }
@@ -615,7 +615,8 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
                FALLBACK_IF(ctx->Point.PointSprite); // GL_POINT_SPRITE_NV
        FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT
        FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE
-       FALLBACK_IF(ctx->Polygon.OffsetFill); // GL_POLYGON_OFFSET_FILL
+       //FALLBACK_IF(ctx->Polygon.OffsetFill); // GL_POLYGON_OFFSET_FILL
+       if(ctx->Polygon.OffsetFill)WARN_ONCE("Polygon.OffsetFill not implemented, ignoring\n");
        FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH
        FALLBACK_IF(ctx->Polygon.StippleFlag); // GL_POLYGON_STIPPLE
        //FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
index 3e7a4653e5b7666265afff9dd1510cfcefb0f8b8..4662a08b9522b9fcc34e5583d28ab00696b5c907 100644 (file)
@@ -60,6 +60,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_emit.h"
 #include "r300_fixed_pipelines.h"
 
+
 static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
index 49631d6b9ff25ed787c72cc1be60a24afee1761e..fd66c3e0af9a48e3996e836e12cdc3625feb54e9 100644 (file)
@@ -393,6 +393,19 @@ static void uploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
        tex.image->width /=4;
        #endif
 
+       #if 0   
+       sleep(1);
+       
+       fprintf(stderr, "*** Uploading texture\n");
+               fprintf(stderr, "   offset=0x%08x\n", offset);
+               fprintf(stderr, "   image width=%d height=%d\n",
+                       imageWidth, imageHeight);
+               fprintf(stderr, "    blit width=%d height=%d data=%p\n",
+                       t->image[face][hwlevel].width,
+                       t->image[face][hwlevel].height,
+                       t->image[face][hwlevel].data);
+       #endif
+
        LOCK_HARDWARE(&rmesa->radeon);
        do {
                ret = drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_TEXTURE,