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;
+
+ radeon_validate_reset_bos(&rmesa->radeon);
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++;
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
}
/* 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++;
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
}
for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
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++;
+ if (t->image_override && t->bo)
+ radeon_validate_bo(&rmesa->radeon, t->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ else if (t->mt->bo)
+ radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
}
-
- 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) {
- radeonFlush(ctx);
- if (flushed)
- return GL_FALSE;
- flushed = 1;
- goto again;
- }
- return GL_TRUE;
+
+ return radeon_revalidate_bos(ctx);
}
GLboolean r200ValidateState( GLcontext *ctx )
{
BATCH_LOCALS(&rmesa->radeon);
- BEGIN_BATCH(4);
+ BEGIN_BATCH_NO_AUTOSTATE(4);
OUT_BATCH_REGVAL(R300_RB3D_DSTCACHE_CTLSTAT,
R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
return GL_TRUE;
}
-
/**
* Ensure all enabled and complete textures are uploaded along with any buffers being used.
*/
GLboolean r300ValidateBuffers(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct radeon_cs_space_check bos[16];
struct radeon_renderbuffer *rrb;
- int num_bo = 0;
int i;
- int flushed = 0, ret;
-again:
- num_bo = 0;
+
+ radeon_validate_reset_bos(&rmesa->radeon);
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++;
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
}
/* 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++;
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
}
for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
}
t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
if (t->image_override && t->bo)
- bos[num_bo].bo = t->bo;
+ radeon_validate_bo(&rmesa->radeon, t->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+
else if (t->mt->bo)
- 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++;
+ radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
}
- 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) {
- radeonFlush(ctx);
- if (flushed)
- return GL_FALSE;
- flushed = 1;
- goto again;
- }
- return GL_TRUE;
+ return radeon_revalidate_bos(ctx);
}
void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
COMMIT_BATCH();
}
+GLboolean radeon_revalidate_bos(GLcontext *ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ int flushed = 0;
+ int ret;
+again:
+ ret = radeon_cs_space_check(radeon->cmdbuf.cs, radeon->state.bos, radeon->state.validated_bo_count);
+ if (ret == RADEON_CS_SPACE_OP_TO_BIG)
+ return GL_FALSE;
+ if (ret == RADEON_CS_SPACE_FLUSH) {
+ radeonFlush(ctx);
+ if (flushed)
+ return GL_FALSE;
+ flushed = 1;
+ goto again;
+ }
+ return GL_TRUE;
+}
+
+void radeon_validate_reset_bos(radeonContextPtr radeon)
+{
+ int i;
+
+ for (i = 0; i < radeon->state.validated_bo_count; i++) {
+ radeon->state.bos[i].bo = NULL;
+ radeon->state.bos[i].read_domains = 0;
+ radeon->state.bos[i].write_domain = 0;
+ radeon->state.bos[i].new_accounted = 0;
+ }
+ radeon->state.validated_bo_count = 0;
+}
+
+void radeon_validate_bo(radeonContextPtr radeon, struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain)
+{
+ radeon->state.bos[radeon->state.validated_bo_count].bo = bo;
+ radeon->state.bos[radeon->state.validated_bo_count].read_domains = read_domains;
+ radeon->state.bos[radeon->state.validated_bo_count].write_domain = write_domain;
+ radeon->state.bos[radeon->state.validated_bo_count].new_accounted = 0;
+ radeon->state.validated_bo_count++;
+
+ assert(radeon->state.validated_bo_count < RADEON_MAX_BOS);
+}
+
void radeonEmitState(radeonContextPtr radeon)
{
if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d\n", __FUNCTION__, radeon->cmdbuf.cs->cdw);
+ /* okay if we have no cmds in the buffer &&
+ we have no DMA flush &&
+ we have no DMA buffer allocated.
+ then no point flushing anything at all.
+ */
+ if (!radeon->dma.flush && !radeon->cmdbuf.cs->cdw && !radeon->dma.current)
+ return;
+
if (radeon->dma.flush)
radeon->dma.flush( ctx );
}
radeon_cs_erase(rmesa->cmdbuf.cs);
rmesa->cmdbuf.flushing = 0;
+
+ if (radeon_revalidate_bos(rmesa->glCtx) == GL_FALSE) {
+ fprintf(stderr,"failed to revalidate buffers\n");
+ }
+
return ret;
}
struct drm_clip_rect **cliprects,
unsigned int *num_cliprects,
int *x_off, int *y_off);
+GLboolean radeon_revalidate_bos(GLcontext *ctx);
+void radeon_validate_bo(radeonContextPtr radeon, struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain);
+void radeon_validate_reset_bos(radeonContextPtr radeon);
void radeon_fbo_init(struct radeon_context *radeon);
void
if (radeon) {
if (radeon->dma.current) {
- radeonReleaseDmaRegion( radeon );
rcommonFlushCmdBuf( radeon, __FUNCTION__ );
}
#include "dri_util.h"
#include "tnl/t_vertex.h"
+struct radeon_context;
+
+#include "radeon_bocs_wrapper.h"
+
/* This union is used to avoid warnings/miscompilation
with float to uint32_t casts due to strict-aliasing */
typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
+#define RADEON_MAX_BOS 24
struct radeon_state {
struct radeon_colorbuffer_state color;
struct radeon_depthbuffer_state depth;
struct radeon_scissor_state scissor;
struct radeon_stencilbuffer_state stencil;
+
+ struct radeon_cs_space_check bos[RADEON_MAX_BOS];
+ int validated_bo_count;
};
/**
void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
{
- struct radeon_cs_space_check bos[1];
- int flushed = 0, ret;
size = MAX2(size, MAX_DMA_BUF_SZ * 16);
rmesa->dma.current_used = 0;
rmesa->dma.current_vertexptr = 0;
- bos[0].bo = rmesa->dma.current;
- bos[0].read_domains = RADEON_GEM_DOMAIN_GTT;
- bos[0].write_domain =0 ;
- bos[0].new_accounted = 0;
-
- ret = radeon_cs_space_check(rmesa->cmdbuf.cs, bos, 1);
- if (ret == RADEON_CS_SPACE_OP_TO_BIG) {
- fprintf(stderr,"Got OPEARTION TO BIG ILLEGAL - this cannot happen");
- assert(0);
- } else if (ret == RADEON_CS_SPACE_FLUSH) {
- rcommonFlushCmdBuf(rmesa, __FUNCTION__);
- if (flushed) {
- fprintf(stderr,"flushed but still no space\n");
- assert(0);
- }
- flushed = 1;
- goto again_alloc;
- }
+ radeon_validate_bo(rmesa, rmesa->dma.current, RADEON_GEM_DOMAIN_GTT, 0);
+
+ if (radeon_revalidate_bos(rmesa->glCtx) == GL_FALSE)
+ fprintf(stderr,"failure to revalidate BOs - badness\n");
+
radeon_bo_map(rmesa->dma.current, 1);
}
#include "swrast_setup/swrast_setup.h"
#include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "radeon_tcl.h"
}
}
+static GLboolean r100ValidateBuffers(GLcontext *ctx)
+{
+ r100ContextPtr rmesa = R100_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrb;
+ int i;
+
+ radeon_validate_reset_bos(&rmesa->radeon);
+
+ rrb = radeon_get_colorbuffer(&rmesa->radeon);
+ /* color buffer */
+ if (rrb && rrb->bo) {
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
+ }
+
+ /* depth buffer */
+ rrb = radeon_get_depthbuffer(&rmesa->radeon);
+ /* color buffer */
+ if (rrb && rrb->bo) {
+ radeon_validate_bo(&rmesa->radeon, rrb->bo,
+ 0, RADEON_GEM_DOMAIN_VRAM);
+ }
-void radeonValidateState( GLcontext *ctx )
+ 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);
+ if (t->image_override && t->bo)
+ radeon_validate_bo(&rmesa->radeon, t->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ else if (t->mt->bo)
+ radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ }
+
+ return radeon_revalidate_bos(ctx);
+}
+
+GLboolean radeonValidateState( GLcontext *ctx )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
GLuint new_state = rmesa->radeon.NewGLState;
new_state |= rmesa->radeon.NewGLState; /* may add TEXTURE_MATRIX */
}
+ /* we need to do a space check here */
+ if (!r100ValidateBuffers(ctx))
+ return GL_FALSE;
+
/* Need an event driven matrix update?
*/
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
/* Validate state:
*/
if (rmesa->radeon.NewGLState)
- radeonValidateState( ctx );
+ if (!radeonValidateState( ctx ))
+ FALLBACK(rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE);
has_material = (ctx->Light.Enabled && check_material( ctx ));
extern void radeonUploadTexMatrix( r100ContextPtr rmesa,
int unit, GLboolean swapcols );
-extern void radeonValidateState( GLcontext *ctx );
+extern GLboolean radeonValidateState( GLcontext *ctx );
extern void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode );