From e61c8a5c6305d67ede3f69fd3ac83b3d196908ff Mon Sep 17 00:00:00 2001 From: Vladimir Dergachev Date: Mon, 31 Jan 2005 06:41:55 +0000 Subject: [PATCH] Add magic sequence to prevent ClearBuffer from locking up. 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 | 9 +++++ src/mesa/drivers/dri/r300/r300_ioctl.c | 50 +++++++++++++++++------- src/mesa/drivers/dri/r300/r300_render.c | 5 ++- src/mesa/drivers/dri/r300/r300_state.c | 1 + src/mesa/drivers/dri/r300/r300_texmem.c | 13 ++++++ 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 57a258487e4..8c8a8bfc71e 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -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; diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 2bf70783f9d..b0222a129d7 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -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); + } diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index f4596aad639..436b80bc835 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -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 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 3e7a4653e5b..4662a08b952 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -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); diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c index 49631d6b9ff..fd66c3e0af9 100644 --- a/src/mesa/drivers/dri/r300/r300_texmem.c +++ b/src/mesa/drivers/dri/r300/r300_texmem.c @@ -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, -- 2.30.2