diff options
author | Dave Airlie <airlied@redhat.com> | 2009-01-31 01:59:57 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-01-31 01:59:57 +1000 |
commit | e45213d89bf26c68c9f4c9074eaec9ab3311de7d (patch) | |
tree | f4ca6a1fdec732dc2d5faba6d700ea54b14ff995 /src/mesa/drivers/dri/r200 | |
parent | 08bb7eedfbba839676ab63fb20dd22e4f27722cb (diff) |
r200/r300: add aperture space checks
Diffstat (limited to 'src/mesa/drivers/dri/r200')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_ioctl.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_state.c | 71 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_state.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_tcl.c | 3 |
4 files changed, 73 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.h b/src/mesa/drivers/dri/r200/r200_ioctl.h index 0410fdf3c3..3e39a9124d 100644 --- a/src/mesa/drivers/dri/r200/r200_ioctl.h +++ b/src/mesa/drivers/dri/r200/r200_ioctl.h @@ -43,6 +43,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "drm.h" #include "radeon_drm.h" +#include "common_cmdbuf.h" + extern void r200EmitState( r200ContextPtr rmesa ); extern void r200EmitVertexAOS( r200ContextPtr rmesa, GLuint vertex_size, diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index f2e62d1bf7..f3d809d62c 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -48,6 +48,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast_setup/swrast_setup.h" #include "radeon_buffer.h" +#include "radeon_cs.h" +#include "radeon_mipmap_tree.h" #include "r200_context.h" #include "r200_ioctl.h" #include "r200_state.h" @@ -2347,9 +2349,66 @@ r200UpdateDrawBuffer(GLcontext *ctx) #endif } +static GLboolean r200ValidateBuffers(GLcontext *ctx) +{ + r200ContextPtr rmesa = R200_CONTEXT(ctx); + struct radeon_cs_space_check bos[8]; + struct radeon_renderbuffer *rrb; + int num_bo = 0; + int i; + int flushed = 0, ret; +again: + num_bo = 0; + + rrb = radeon_get_colorbuffer(&rmesa->radeon); + /* color buffer */ + if (rrb && rrb->bo) { + bos[num_bo].bo = rrb->bo; + bos[num_bo].read_domains = 0; + bos[num_bo].write_domain = RADEON_GEM_DOMAIN_VRAM; + bos[num_bo].new_accounted = 0; + num_bo++; + } + + /* depth buffer */ + rrb = radeon_get_depthbuffer(&rmesa->radeon); + /* color buffer */ + if (rrb && rrb->bo) { + bos[num_bo].bo = rrb->bo; + bos[num_bo].read_domains = 0; + bos[num_bo].write_domain = RADEON_GEM_DOMAIN_VRAM; + bos[num_bo].new_accounted = 0; + num_bo++; + } + + for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) { + radeonTexObj *t; + + if (!ctx->Texture.Unit[i]._ReallyEnabled) + continue; + + t = radeon_tex_obj(ctx->Texture.Unit[i]._Current); + bos[num_bo].bo = t->mt->bo; + bos[num_bo].read_domains = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; + bos[num_bo].write_domain = 0; + bos[num_bo].new_accounted = 0; + num_bo++; + } + + ret = radeon_cs_space_check(rmesa->radeon.cmdbuf.cs, bos, num_bo); + if (ret == RADEON_CS_SPACE_OP_TO_BIG) + return GL_FALSE; + if (ret == RADEON_CS_SPACE_FLUSH) { + r200Flush(ctx); + if (flushed) + return GL_FALSE; + flushed = 1; + goto again; + } + return GL_TRUE; +} - -void r200ValidateState( GLcontext *ctx ) +GLboolean r200ValidateState( GLcontext *ctx ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); GLuint new_state = rmesa->radeon.NewGLState; @@ -2364,6 +2423,10 @@ void r200ValidateState( GLcontext *ctx ) r200UpdateLocalViewer( ctx ); } + /* we need to do a space check here */ + if (!r200ValidateBuffers(ctx)) + return GL_FALSE; + /* FIXME: don't really need most of these when vertex progs are enabled */ /* Need an event driven matrix update? @@ -2408,6 +2471,7 @@ void r200ValidateState( GLcontext *ctx ) } rmesa->radeon.NewGLState = 0; + return GL_TRUE; } @@ -2452,7 +2516,8 @@ static void r200WrapRunPipeline( GLcontext *ctx ) /* Validate state: */ if (rmesa->radeon.NewGLState) - r200ValidateState( ctx ); + if (!r200ValidateState( ctx )) + FALLBACK(rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE); has_material = !ctx->VertexProgram._Enabled && ctx->Light.Enabled && check_material( ctx ); diff --git a/src/mesa/drivers/dri/r200/r200_state.h b/src/mesa/drivers/dri/r200/r200_state.h index 741bf88e9c..1dddbfdbfe 100644 --- a/src/mesa/drivers/dri/r200/r200_state.h +++ b/src/mesa/drivers/dri/r200/r200_state.h @@ -47,7 +47,7 @@ extern void r200UpdateViewportOffset( GLcontext *ctx ); extern void r200UpdateWindow( GLcontext *ctx ); extern void r200UpdateDrawBuffer(GLcontext *ctx); -extern void r200ValidateState( GLcontext *ctx ); +extern GLboolean r200ValidateState( GLcontext *ctx ); extern void r200PrintDirty( r200ContextPtr rmesa, const char *msg ); diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index 5bb25bc53a..3c19e330f5 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -406,7 +406,8 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx, /* Validate state: */ if (rmesa->radeon.NewGLState) - r200ValidateState( ctx ); + if (!r200ValidateState( ctx )) + return GL_TRUE; /* fallback to sw t&l */ if (!ctx->VertexProgram._Enabled) { /* NOTE: inputs != tnl->render_inputs - these are the untransformed |