{
struct i830_context *i830 = i830_context(&intel->ctx);
struct i830_hw_state *state = i830->current;
- int i, ret, count;
+ int i, count;
GLuint dirty;
GET_CURRENT_CONTEXT(ctx);
BATCH_LOCALS;
+ dri_bo *aper_array[3 + I830_TEX_UNITS];
+ int aper_count;
/* We don't hold the lock at this point, so want to make sure that
* there won't be a buffer wrap between the state emits and the primitive
LOOP_CLIPRECTS);
count = 0;
again:
+ aper_count = 0;
dirty = get_dirty(state);
- ret = 0;
+ aper_array[aper_count++] = intel->batch->buf;
if (dirty & I830_UPLOAD_BUFFERS) {
- ret |= dri_bufmgr_check_aperture_space(state->draw_region->buffer);
- ret |= dri_bufmgr_check_aperture_space(state->depth_region->buffer);
+ aper_array[aper_count++] = state->draw_region->buffer;
+ aper_array[aper_count++] = state->depth_region->buffer;
}
-
+
for (i = 0; i < I830_TEX_UNITS; i++)
if (dirty & I830_UPLOAD_TEX(i)) {
if (state->tex_buffer[i]) {
- ret |= dri_bufmgr_check_aperture_space(state->tex_buffer[i]);
+ aper_array[aper_count++] = state->tex_buffer[i];
}
}
- if (ret) {
+ if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) {
if (count == 0) {
count++;
intel_batchbuffer_flush(intel->batch);
{
struct i915_context *i915 = i915_context(&intel->ctx);
struct i915_hw_state *state = i915->current;
- int i;
- int ret, count;
+ int i, count, aper_count;
GLuint dirty;
+ dri_bo *aper_array[3 + I915_TEX_UNITS];
GET_CURRENT_CONTEXT(ctx);
BATCH_LOCALS;
LOOP_CLIPRECTS);
count = 0;
again:
+ aper_count = 0;
dirty = get_dirty(state);
- ret = 0;
+ aper_array[aper_count++] = intel->batch->buf;
if (dirty & I915_UPLOAD_BUFFERS) {
- ret |= dri_bufmgr_check_aperture_space(state->draw_region->buffer);
- if (state->depth_region)
- ret |= dri_bufmgr_check_aperture_space(state->depth_region->buffer);
+ aper_array[aper_count++] = state->draw_region->buffer;
+ if (state->depth_region)
+ aper_array[aper_count++] = state->depth_region->buffer;
}
if (dirty & I915_UPLOAD_TEX_ALL) {
- for (i = 0; i < I915_TEX_UNITS; i++)
- if (dirty & I915_UPLOAD_TEX(i)) {
- if (state->tex_buffer[i]) {
- ret |= dri_bufmgr_check_aperture_space(state->tex_buffer[i]);
- }
- }
+ for (i = 0; i < I915_TEX_UNITS; i++) {
+ if (dirty & I915_UPLOAD_TEX(i)) {
+ if (state->tex_buffer[i]) {
+ aper_array[aper_count++] = state->tex_buffer[i];
+ }
+ }
+ }
}
- if (ret) {
+
+ if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) {
if (count == 0) {
count++;
intel_batchbuffer_flush(intel->batch);
INTEL_VB_SIZE, 4);
intel->prim.start_offset = 0;
intel->prim.current_offset = 0;
-
- dri_bufmgr_check_aperture_space(intel->prim.vb_bo);
}
intel->prim.flush = intel_flush_prim;
void intel_flush_prim(struct intel_context *intel)
{
BATCH_LOCALS;
+ dri_bo *aper_array[2];
dri_bo *vb_bo;
/* Must be called after an intel_start_prim. */
intel->vtbl.emit_state(intel);
+ aper_array[0] = intel->batch->buf;
+ aper_array[1] = vb_bo;
+ if (dri_bufmgr_check_aperture_space(aper_array, 2)) {
+ intel_batchbuffer_flush(intel->batch);
+ intel->vtbl.emit_state(intel);
+ }
+
/* Ensure that we don't start a new batch for the following emit, which
* depends on the state just emitted. emit_state should be making sure we
* have the space for this.
#include "macros.h"
#include "enums.h"
-static int prepare_cc_vp( struct brw_context *brw )
+static void prepare_cc_vp( struct brw_context *brw )
{
struct brw_cc_viewport ccv;
dri_bo_unreference(brw->cc.vp_bo);
brw->cc.vp_bo = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0 );
- return dri_bufmgr_check_aperture_space(brw->cc.vp_bo);
}
const struct brw_tracked_state brw_cc_vp = {
return bo;
}
-static int prepare_cc_unit( struct brw_context *brw )
+static void prepare_cc_unit( struct brw_context *brw )
{
struct brw_cc_unit_key key;
if (brw->cc.state_bo == NULL)
brw->cc.state_bo = cc_unit_create_from_key(brw, &key);
- return dri_bufmgr_check_aperture_space(brw->cc.state_bo);
}
const struct brw_tracked_state brw_cc_unit = {
/* Calculate interpolants for triangle and line rasterization.
*/
-static int upload_clip_prog( struct brw_context *brw )
+static void upload_clip_prog(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
struct brw_clip_prog_key key;
&brw->clip.prog_data);
if (brw->clip.prog_bo == NULL)
compile_clip_prog( brw, &key );
-
- return dri_bufmgr_check_aperture_space(brw->clip.prog_bo);
}
return bo;
}
-static int upload_clip_unit( struct brw_context *brw )
+static void upload_clip_unit( struct brw_context *brw )
{
struct brw_clip_unit_key key;
- int ret = 0;
clip_unit_populate_key(brw, &key);
if (brw->clip.state_bo == NULL) {
brw->clip.state_bo = clip_unit_create_from_key(brw, &key);
}
-
- ret = dri_bufmgr_check_aperture_space(brw->clip.state_bo);
- return ret;
}
const struct brw_tracked_state brw_clip_unit = {
#define BRW_NEW_METAOPS 0x1000
#define BRW_NEW_FENCE 0x2000
#define BRW_NEW_LOCK 0x4000
+#define BRW_NEW_INDICES 0x8000
+#define BRW_NEW_VERTICES 0x10000
/**
* Used for any batch entry with a relocated pointer that will be used
* by any 3D rendering.
*/
struct brw_tracked_state {
struct brw_state_flags dirty;
- int (*prepare)( struct brw_context *brw );
+ void (*prepare)( struct brw_context *brw );
void (*emit)( struct brw_context *brw );
};
* for changes to this state:
*/
struct brw_vertex_info info;
+ unsigned int min_index, max_index;
} vb;
+ struct {
+ /**
+ * Index buffer for this draw_prims call.
+ *
+ * Updates are signaled by BRW_NEW_INDICES.
+ */
+ const struct _mesa_index_buffer *ib;
+
+ dri_bo *bo;
+ unsigned int offset;
+ } ib;
+
struct {
/* Will be allocated on demand if needed.
*/
/*======================================================================
* brw_state.c
*/
-int brw_validate_state( struct brw_context *brw );
+void brw_validate_state( struct brw_context *brw );
void brw_init_state( struct brw_context *brw );
void brw_destroy_state( struct brw_context *brw );
/* Partition the CURBE between the various users of constant values:
*/
-static int calculate_curbe_offsets( struct brw_context *brw )
+static void calculate_curbe_offsets( struct brw_context *brw )
{
/* CACHE_NEW_WM_PROG */
GLuint nr_fp_regs = (brw->wm.prog_data->nr_params + 15) / 16;
brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS;
}
- return 0;
}
* cache mechanism, but maybe would benefit from a comparison against
* the current uploaded set of constants.
*/
-static int prepare_constant_buffer(struct brw_context *brw)
+static void prepare_constant_buffer(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
struct brw_vertex_program *vp = (struct brw_vertex_program *)brw->vertex_program;
brw->curbe.last_buf = NULL;
brw->curbe.last_bufsz = 0;
}
-
- return 0;
+
+ return;
}
buf = (GLfloat *)malloc(bufsz);
* flushes as necessary when doublebuffering of CURBEs isn't
* possible.
*/
-
- /* check aperture space for this bo */
- return dri_bufmgr_check_aperture_space(brw->curbe.curbe_bo);
}
{
struct intel_context *intel = &brw->intel;
GLuint sz = brw->curbe.total_size;
+ dri_bo *aper_array[] = {
+ brw->intel.batch->buf,
+ brw->curbe.curbe_bo,
+ };
+
+ if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+ intel_batchbuffer_flush(intel->batch);
BEGIN_BATCH(2, IGNORE_CLIPRECTS);
if (sz == 0) {
* programs be immune to the active primitive (ie. cope with all
* possibilities). That may not be realistic however.
*/
-static GLuint brw_set_prim(struct brw_context *brw, GLenum prim, GLboolean *need_flush)
+static GLuint brw_set_prim(struct brw_context *brw, GLenum prim)
{
- int ret;
if (INTEL_DEBUG & DEBUG_PRIMS)
_mesa_printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim));
brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE;
}
- ret = brw_validate_state(brw);
- if (ret)
- *need_flush = GL_TRUE;
+ brw_validate_state(brw);
}
return hw_prim[prim];
{
struct brw_3d_primitive prim_packet;
- GLboolean need_flush = GL_FALSE;
if (INTEL_DEBUG & DEBUG_PRIMS)
_mesa_printf("PRIM: %s %d %d\n", _mesa_lookup_enum_by_nr(prim->mode),
prim_packet.header.opcode = CMD_3D_PRIM;
prim_packet.header.length = sizeof(prim_packet)/4 - 2;
prim_packet.header.pad = 0;
- prim_packet.header.topology = brw_set_prim(brw, prim->mode, &need_flush);
+ prim_packet.header.topology = brw_set_prim(brw, prim->mode);
prim_packet.header.indexed = prim->indexed;
prim_packet.verts_per_instance = trim(prim->mode, prim->count);
prim_packet.start_instance_location = 0;
prim_packet.base_vert_location = 0;
+ /* Can't wrap here, since we rely on the validated state. */
+ brw->no_batch_wrap = GL_TRUE;
if (prim_packet.verts_per_instance) {
intel_batchbuffer_data( brw->intel.batch, &prim_packet,
sizeof(prim_packet), LOOP_CLIPRECTS);
}
-
- assert(need_flush == GL_FALSE);
+ brw->no_batch_wrap = GL_FALSE;
}
static void brw_merge_inputs( struct brw_context *brw,
struct brw_context *brw = brw_context(ctx);
GLboolean retval = GL_FALSE;
GLuint i;
- GLuint ib_offset;
- dri_bo *ib_bo;
- GLboolean force_flush = GL_FALSE;
- int ret;
if (ctx->NewState)
_mesa_update_state( ctx );
/* Bind all inputs, derive varying and size information:
*/
brw_merge_inputs( brw, arrays );
-
+
+ brw->ib.ib = ib;
+ brw->state.dirty.brw |= BRW_NEW_INDICES;
+
+ brw->vb.min_index = min_index;
+ brw->vb.max_index = max_index;
+ brw->state.dirty.brw |= BRW_NEW_VERTICES;
/* Have to validate state quite late. Will rebuild tnl_program,
* which depends on varying information.
*
* an upper bound of how much we might emit in a single
* brw_try_draw_prims().
*/
- flush:
- if (force_flush)
- brw->no_batch_wrap = GL_FALSE;
-
if (intel->batch->ptr - intel->batch->map > intel->batch->size * 3 / 4
/* brw_emit_prim may change the cliprect_mode to LOOP_CLIPRECTS */
- || intel->batch->cliprect_mode != LOOP_CLIPRECTS || (force_flush == GL_TRUE))
+ || intel->batch->cliprect_mode != LOOP_CLIPRECTS)
intel_batchbuffer_flush(intel->batch);
- force_flush = GL_FALSE;
- brw->no_batch_wrap = GL_TRUE;
-
/* Set the first primitive early, ahead of validate_state:
*/
- brw_set_prim(brw, prim[0].mode, &force_flush);
+ brw_set_prim(brw, prim[0].mode);
/* XXX: Need to separate validate and upload of state.
*/
- ret = brw_validate_state( brw );
- if (ret) {
- force_flush = GL_TRUE;
- goto flush;
- }
+ brw_validate_state( brw );
/* Various fallback checks:
*/
if (check_fallbacks( brw, prim, nr_prims ))
goto out;
- /* need to account for index buffer and vertex buffer */
- if (ib) {
- ret = brw_prepare_indices( brw, ib , &ib_bo, &ib_offset);
- if (ret) {
- force_flush = GL_TRUE;
- goto flush;
- }
- }
-
- ret = brw_prepare_vertices( brw, min_index, max_index);
- if (ret < 0)
- goto out;
-
- if (ret > 0) {
- force_flush = GL_TRUE;
- goto flush;
- }
-
- /* Upload index, vertex data:
- */
- if (ib)
- brw_emit_indices( brw, ib, ib_bo, ib_offset);
-
- brw_emit_vertices( brw, min_index, max_index);
-
for (i = 0; i < nr_prims; i++) {
brw_emit_prim(brw, &prim[i]);
}
}
out:
-
- brw->no_batch_wrap = GL_FALSE;
-
UNLOCK_HARDWARE(intel);
if (!retval)
void brw_init_current_values(GLcontext *ctx,
struct gl_client_array *arrays);
-
-/* brw_draw_upload.c
- */
-int brw_prepare_indices( struct brw_context *brw,
- const struct _mesa_index_buffer *index_buffer,
- dri_bo **bo_return,
- GLuint *offset_return);
-
-void brw_emit_indices( struct brw_context *brw,
- const struct _mesa_index_buffer *index_buffer,
- dri_bo *bo,
- GLuint offset);
-
-int brw_prepare_vertices( struct brw_context *brw,
- GLuint min_index,
- GLuint max_index );
-
-void brw_emit_vertices( struct brw_context *brw,
- GLuint min_index,
- GLuint max_index );
-
-
-
#endif
dri_bo_unmap(element->bo);
}
-int brw_prepare_vertices( struct brw_context *brw,
- GLuint min_index,
- GLuint max_index )
+static void brw_prepare_vertices(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = intel_context(ctx);
GLuint i;
const unsigned char *ptr = NULL;
GLuint interleave = 0;
- int ret = 0;
+ unsigned int min_index = brw->vb.min_index;
+ unsigned int max_index = brw->vb.max_index;
struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
GLuint nr_enabled = 0;
* cases with > 17 vertex attributes enabled, so it probably
* isn't an issue at this point.
*/
- if (nr_enabled >= BRW_VEP_MAX)
- return -1;
+ if (nr_enabled >= BRW_VEP_MAX) {
+ intel->Fallback = 1;
+ return;
+ }
for (i = 0; i < nr_enabled; i++) {
struct brw_vertex_element *input = enabled[i];
dri_bo_reference(input->bo);
input->offset = (unsigned long)input->glarray->Ptr;
input->stride = input->glarray->StrideB;
-
- ret |= dri_bufmgr_check_aperture_space(input->bo);
} else {
/* Queue the buffer object up to be uploaded in the next pass,
* when we've decided if we're doing interleaved or not.
/* Position array not properly enabled:
*/
if (input->glarray->StrideB == 0)
- return -1;
+ return;
interleave = input->glarray->StrideB;
ptr = input->glarray->Ptr;
*/
copy_array_to_vbo_array(brw, upload[0], interleave);
- ret |= dri_bufmgr_check_aperture_space(upload[0]->bo);
for (i = 1; i < nr_uploads; i++) {
/* Then, just point upload[i] at upload[0]'s buffer. */
upload[i]->stride = interleave;
/* Upload non-interleaved arrays */
for (i = 0; i < nr_uploads; i++) {
copy_array_to_vbo_array(brw, upload[i], upload[i]->element_size);
- if (upload[i]->bo) {
- ret |= dri_bufmgr_check_aperture_space(upload[i]->bo);
- }
}
}
-
-
- if (ret)
- return 1;
-
-
- return 0;
}
-void brw_emit_vertices( struct brw_context *brw,
- GLuint min_index,
- GLuint max_index )
+static void brw_emit_vertices(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = intel_context(ctx);
OUT_RELOC(input->bo,
I915_GEM_DOMAIN_VERTEX, 0,
input->offset);
- OUT_BATCH(max_index);
+ OUT_BATCH(brw->vb.max_index);
OUT_BATCH(0); /* Instance data step rate */
/* Unreference the buffer so it can get freed, now that we won't
ADVANCE_BATCH();
}
-int brw_prepare_indices( struct brw_context *brw,
- const struct _mesa_index_buffer *index_buffer,
- dri_bo **bo_return,
- GLuint *offset_return)
+const struct brw_tracked_state brw_vertices = {
+ .dirty = {
+ .mesa = 0,
+ .brw = BRW_NEW_BATCH | BRW_NEW_VERTICES,
+ .cache = 0,
+ },
+ .prepare = brw_prepare_vertices,
+ .emit = brw_emit_vertices,
+};
+
+static void brw_prepare_indices(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = &brw->intel;
- GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
+ const struct _mesa_index_buffer *index_buffer = brw->ib.ib;
+ GLuint ib_size;
dri_bo *bo;
- struct gl_buffer_object *bufferobj = index_buffer->obj;
- GLuint offset = (GLuint)index_buffer->ptr;
- int ret;
+ struct gl_buffer_object *bufferobj;
+ GLuint offset;
+
+ if (index_buffer == NULL)
+ return;
+
+ ib_size = get_size(index_buffer->type) * index_buffer->count;
+ bufferobj = index_buffer->obj;;
/* Turn into a proper VBO:
*/
*/
dri_bo_subdata(bo, offset, ib_size, index_buffer->ptr);
} else {
+ offset = (GLuint)index_buffer->ptr;
+
/* If the index buffer isn't aligned to its element size, we have to
* rebase it into a temporary.
*/
}
}
- *bo_return = bo;
- *offset_return = offset;
- ret = dri_bufmgr_check_aperture_space(bo);
- return ret;
+ dri_bo_unreference(brw->ib.bo);
+ brw->ib.bo = bo;
+ brw->ib.offset = offset;
}
-void brw_emit_indices(struct brw_context *brw,
- const struct _mesa_index_buffer *index_buffer,
- dri_bo *bo,
- GLuint offset)
+static void brw_emit_indices(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
- GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
+ const struct _mesa_index_buffer *index_buffer = brw->ib.ib;
+ GLuint ib_size;
+
+ if (index_buffer == NULL)
+ return;
+
+ ib_size = get_size(index_buffer->type) * index_buffer->count;
+
/* Emit the indexbuffer packet:
*/
{
BEGIN_BATCH(4, IGNORE_CLIPRECTS);
OUT_BATCH( ib.header.dword );
- OUT_RELOC( bo,
- I915_GEM_DOMAIN_VERTEX, 0,
- offset);
- OUT_RELOC( bo,
- I915_GEM_DOMAIN_VERTEX, 0,
- offset + ib_size);
+ OUT_RELOC(brw->ib.bo,
+ I915_GEM_DOMAIN_VERTEX, 0,
+ brw->ib.offset);
+ OUT_RELOC(brw->ib.bo,
+ I915_GEM_DOMAIN_VERTEX, 0,
+ brw->ib.offset + ib_size);
OUT_BATCH( 0 );
ADVANCE_BATCH();
-
- dri_bo_unreference(bo);
}
}
+const struct brw_tracked_state brw_indices = {
+ .dirty = {
+ .mesa = 0,
+ .brw = BRW_NEW_BATCH | BRW_NEW_INDICES,
+ .cache = 0,
+ },
+ .prepare = brw_prepare_indices,
+ .emit = brw_emit_indices,
+};
return GL_FALSE;
}
-static int check_fallback(struct brw_context *brw)
+static void check_fallback(struct brw_context *brw)
{
brw->intel.Fallback = do_check_fallback(brw);
- return 0;
}
const struct brw_tracked_state brw_check_fallback = {
/* Calculate interpolants for triangle and line rasterization.
*/
-static int prepare_gs_prog( struct brw_context *brw )
+static void prepare_gs_prog(struct brw_context *brw)
{
struct brw_gs_prog_key key;
- int ret = 0;
/* Populate the key:
*/
populate_key(brw, &key);
&brw->gs.prog_data);
if (brw->gs.prog_bo == NULL)
compile_gs_prog( brw, &key );
-
- ret |= dri_bufmgr_check_aperture_space(brw->gs.prog_bo);
}
-
- return ret;
}
return bo;
}
-static int prepare_gs_unit( struct brw_context *brw )
+static void prepare_gs_unit(struct brw_context *brw)
{
struct brw_gs_unit_key key;
if (brw->gs.state_bo == NULL) {
brw->gs.state_bo = gs_unit_create_from_key(brw, &key);
}
- return dri_bufmgr_check_aperture_space(brw->gs.state_bo);
}
const struct brw_tracked_state brw_gs_unit = {
static void upload_binding_table_pointers(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
+ dri_bo *aper_array[] = {
+ intel->batch->buf,
+ brw->wm.bind_bo,
+ };
+
+ if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+ intel_batchbuffer_flush(intel->batch);
BEGIN_BATCH(6, IGNORE_CLIPRECTS);
OUT_BATCH(CMD_BINDING_TABLE_PTRS << 16 | (6 - 2));
static void upload_psp_urb_cbs(struct brw_context *brw )
{
+ struct intel_context *intel = &brw->intel;
+ dri_bo *aper_array[] = {
+ intel->batch->buf,
+ brw->vs.state_bo,
+ brw->gs.state_bo,
+ brw->clip.state_bo,
+ brw->wm.state_bo,
+ brw->cc.state_bo,
+ };
+
+ if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+ intel_batchbuffer_flush(intel->batch);
+
upload_pipelined_state_pointers(brw);
brw_upload_urb_fence(brw);
brw_upload_constant_buffer_state(brw);
.emit = upload_psp_urb_cbs,
};
-/**
- * Upload the depthbuffer offset and format.
- *
- * We have to do this per state validation as we need to emit the relocation
- * in the batch buffer.
- */
-
-static int prepare_depthbuffer(struct brw_context *brw)
-{
- struct intel_region *region = brw->state.depth_region;
-
- if (!region || !region->buffer)
- return 0;
- return dri_bufmgr_check_aperture_space(region->buffer);
-}
-
static void emit_depthbuffer(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
ADVANCE_BATCH();
} else {
unsigned int format;
+ dri_bo *aper_array[] = {
+ intel->batch->buf,
+ region->buffer
+ };
switch (region->cpp) {
case 2:
return;
}
+ if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+ intel_batchbuffer_flush(intel->batch);
+
BEGIN_BATCH(len, IGNORE_CLIPRECTS);
OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
OUT_BATCH(((region->pitch * region->cpp) - 1) |
.brw = BRW_NEW_DEPTH_BUFFER | BRW_NEW_BATCH,
.cache = 0,
},
- .prepare = prepare_depthbuffer,
.emit = emit_depthbuffer,
};
/* Calculate interpolants for triangle and line rasterization.
*/
-static int upload_sf_prog( struct brw_context *brw )
+static void upload_sf_prog(struct brw_context *brw)
{
struct brw_sf_prog_key key;
&brw->sf.prog_data);
if (brw->sf.prog_bo == NULL)
compile_sf_prog( brw, &key );
- return dri_bufmgr_check_aperture_space(brw->sf.prog_bo);
}
#include "macros.h"
#include "intel_fbo.h"
-static int upload_sf_vp(struct brw_context *brw)
+static void upload_sf_vp(struct brw_context *brw)
{
GLcontext *ctx = &brw->intel.ctx;
const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
dri_bo_unreference(brw->sf.vp_bo);
brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
-
- return dri_bufmgr_check_aperture_space(brw->sf.vp_bo);
}
const struct brw_tracked_state brw_sf_vp = {
return bo;
}
-static int upload_sf_unit( struct brw_context *brw )
+static void upload_sf_unit( struct brw_context *brw )
{
struct brw_sf_unit_key key;
dri_bo *reloc_bufs[2];
- int ret = 0;
sf_unit_populate_key(brw, &key);
if (brw->sf.state_bo == NULL) {
brw->sf.state_bo = sf_unit_create_from_key(brw, &key, reloc_bufs);
}
-
- if (reloc_bufs[0])
- ret |= dri_bufmgr_check_aperture_space(reloc_bufs[0]);
-
- if (reloc_bufs[1])
- ret |= dri_bufmgr_check_aperture_space(reloc_bufs[1]);
-
- ret |= dri_bufmgr_check_aperture_space(brw->sf.state_bo);
- return ret;
}
const struct brw_tracked_state brw_sf_unit = {
const struct brw_tracked_state brw_clear_surface_cache;
const struct brw_tracked_state brw_clear_batch_cache;
+const struct brw_tracked_state brw_indices;
+const struct brw_tracked_state brw_vertices;
+
/***********************************************************************
* brw_state_cache.c
*/
&brw_psp_urb_cbs,
#endif
+ &brw_indices,
+ &brw_vertices,
NULL, /* brw_constant_buffer */
};
/***********************************************************************
* Emit all state:
*/
-int brw_validate_state( struct brw_context *brw )
+void brw_validate_state( struct brw_context *brw )
{
+ struct intel_context *intel = &brw->intel;
struct brw_state_flags *state = &brw->state.dirty;
- GLuint i, ret, count;
+ GLuint i, count, pass = 0;
+ dri_bo *last_batch_bo = NULL;
state->mesa |= brw->intel.NewGLState;
brw->intel.NewGLState = 0;
if (state->mesa == 0 &&
state->cache == 0 &&
state->brw == 0)
- return 0;
+ return;
if (brw->state.dirty.brw & BRW_NEW_CONTEXT)
brw_clear_batch_cache_flush(brw);
if (check_state(state, &atom->dirty)) {
if (atom->prepare) {
- ret = atom->prepare(brw);
- if (ret)
- return ret;
+ atom->prepare(brw);
}
}
}
if (brw->intel.Fallback)
- return 0;
+ return;
+
+ /* We're about to try to set up a coherent state in the batchbuffer for
+ * the emission of primitives. If we exceed the aperture size in any of the
+ * emit() calls, we need to go back to square 1 and try setting up again.
+ */
+got_flushed:
+ dri_bo_unreference(last_batch_bo);
+ last_batch_bo = intel->batch->buf;
+ dri_bo_reference(last_batch_bo);
+ assert(pass++ <= 2);
if (INTEL_DEBUG) {
/* Debug version which enforces various sanity checks on the
break;
if (check_state(state, &atom->dirty)) {
- if (atom->emit)
+ if (atom->emit) {
atom->emit( brw );
+ if (intel->batch->buf != last_batch_bo)
+ goto got_flushed;
+ }
}
accumulate_state(&examined, &atom->dirty);
break;
if (check_state(state, &atom->dirty)) {
- if (atom->emit)
+ if (atom->emit) {
atom->emit( brw );
+ if (intel->batch->buf != last_batch_bo)
+ goto got_flushed;
+ }
}
}
}
+ dri_bo_unreference(last_batch_bo);
+
if (!brw->intel.Fallback)
memset(state, 0, sizeof(*state));
- return 0;
}
/* Most minimal update, forces re-emit of URB fence packet after GS
* unit turned on/off.
*/
-static int recalculate_urb_fence( struct brw_context *brw )
+static void recalculate_urb_fence( struct brw_context *brw )
{
GLuint csize = brw->curbe.total_size;
GLuint vsize = brw->vs.prog_data->urb_entry_size;
brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
}
- return 0;
}
}
-static int brw_upload_vs_prog( struct brw_context *brw )
+static void brw_upload_vs_prog(struct brw_context *brw)
{
struct brw_vs_prog_key key;
struct brw_vertex_program *vp =
&brw->vs.prog_data);
if (brw->vs.prog_bo == NULL)
do_vs_prog(brw, vp, &key);
- return dri_bufmgr_check_aperture_space(brw->vs.prog_bo);
}
/* Calculate sizes of vertex program outputs. Size is the largest
* component index which might vary from [0,0,0,1]
*/
-static int calc_wm_input_sizes( struct brw_context *brw )
+static void calc_wm_input_sizes( struct brw_context *brw )
{
/* BRW_NEW_VERTEX_PROGRAM */
struct brw_vertex_program *vp =
memcpy(brw->wm.input_size_masks, t.size_masks, sizeof(t.size_masks));
brw->state.dirty.brw |= BRW_NEW_WM_INPUT_DIMENSIONS;
}
- return 0;
}
const struct brw_tracked_state brw_wm_input_sizes = {
return bo;
}
-static int prepare_vs_unit( struct brw_context *brw )
+static void prepare_vs_unit(struct brw_context *brw)
{
struct brw_vs_unit_key key;
if (brw->vs.state_bo == NULL) {
brw->vs.state_bo = vs_unit_create_from_key(brw, &key);
}
- return dri_bufmgr_check_aperture_space(brw->vs.state_bo);
}
const struct brw_tracked_state brw_vs_unit = {
return hash;
}
-static int prepare_tnl_program( struct brw_context *brw )
+static void prepare_tnl_program( struct brw_context *brw )
{
GLcontext *ctx = &brw->intel.ctx;
struct state_key key;
/* _NEW_PROGRAM */
if (brw->attribs.VertexProgram->_Current)
- return 0;
+ return;
/* Grab all the relevent state and put it in a single structure:
*/
if (old != brw->tnl_program)
brw->state.dirty.brw |= BRW_NEW_TNL_PROGRAM;
- return 0;
+ return;
}
/* Note: See brw_draw.c - the vertex program must not rely on
-static int prepare_active_vertprog( struct brw_context *brw )
+static void prepare_active_vertprog( struct brw_context *brw )
{
const struct gl_vertex_program *prev = brw->vertex_program;
if (brw->vertex_program != prev)
brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM;
-
- return 0;
}
}
-static int brw_prepare_wm_prog( struct brw_context *brw )
+static void brw_prepare_wm_prog(struct brw_context *brw)
{
struct brw_wm_prog_key key;
struct brw_fragment_program *fp = (struct brw_fragment_program *)
&brw->wm.prog_data);
if (brw->wm.prog_bo == NULL)
do_wm_prog(brw, fp, &key);
-
- return dri_bufmgr_check_aperture_space(brw->wm.prog_bo);
}
* complicates various things. However, this is still too confusing -
* FIXME: simplify all the different new texture state flags.
*/
-static int upload_wm_samplers( struct brw_context *brw )
+static void upload_wm_samplers( struct brw_context *brw )
{
struct wm_sampler_key key;
int i;
- int ret = 0;
brw_wm_sampler_populate_key(brw, &key);
dri_bo_unreference(brw->wm.sampler_bo);
brw->wm.sampler_bo = NULL;
if (brw->wm.sampler_count == 0)
- return 0;
+ return;
brw->wm.sampler_bo = brw_search_cache(&brw->cache, BRW_SAMPLER,
&key, sizeof(key),
if (!brw->attribs.Texture->Unit[i]._ReallyEnabled)
continue;
- ret |= dri_bufmgr_check_aperture_space(brw->wm.sdc_bo[i]);
intel_bo_emit_reloc(brw->wm.sampler_bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
0,
brw->wm.sdc_bo[i]);
}
}
-
- ret |= dri_bufmgr_check_aperture_space(brw->wm.sampler_bo);
- return ret;
-
}
const struct brw_tracked_state brw_wm_samplers = {
}
-static int upload_wm_unit( struct brw_context *brw )
+static void upload_wm_unit( struct brw_context *brw )
{
struct intel_context *intel = &brw->intel;
struct brw_wm_unit_key key;
dri_bo *reloc_bufs[3];
- int ret = 0, i;
wm_unit_populate_key(brw, &key);
/* Allocate the necessary scratch space if we haven't already. Don't
if (brw->wm.state_bo == NULL) {
brw->wm.state_bo = wm_unit_create_from_key(brw, &key, reloc_bufs);
}
-
- for (i = 0; i < 3; i++)
- if (reloc_bufs[i])
- ret |= dri_bufmgr_check_aperture_space(reloc_bufs[i]);
- ret |= dri_bufmgr_check_aperture_space(brw->wm.state_bo);
- return ret;
}
const struct brw_tracked_state brw_wm_unit = {
return bo;
}
-static int
+static void
brw_update_texture_surface( GLcontext *ctx, GLuint unit )
{
struct brw_context *brw = brw_context(ctx);
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage = tObj->Image[0][intelObj->firstLevel];
struct brw_wm_surface_key key;
- int ret = 0;
memset(&key, 0, sizeof(key));
key.target = tObj->Target;
key.depth = firstImage->Depth;
key.tiling = intelObj->mt->region->tiling;
- ret |= dri_bufmgr_check_aperture_space(key.bo);
-
dri_bo_unreference(brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS]);
brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
&key, sizeof(key),
if (brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] == NULL) {
brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_create_texture_surface(brw, &key);
}
-
- ret |= dri_bufmgr_check_aperture_space(brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS]);
- return ret;
}
/**
* While it is only used for the front/back buffer currently, it should be
* usable for further buffers when doing ARB_draw_buffer support.
*/
-static int
+static void
brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
unsigned int unit, GLboolean cached)
{
dri_bo *region_bo = NULL;
- int ret = 0;
struct {
unsigned int surface_type;
unsigned int surface_format;
key.width = region->pitch; /* XXX: not really! */
key.height = region->height;
key.cpp = region->cpp;
-
- ret |= dri_bufmgr_check_aperture_space(region->buffer);
} else {
key.surface_type = BRW_SURFACE_NULL;
key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
region_bo);
}
}
-
- ret |= dri_bufmgr_check_aperture_space(brw->wm.surf_bo[unit]);
-
- return ret;
}
return bind_bo;
}
-static int prepare_wm_surfaces(struct brw_context *brw )
+static void prepare_wm_surfaces(struct brw_context *brw )
{
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = &brw->intel;
- GLuint i, ret;
+ GLuint i;
if (brw->state.nr_draw_regions > 1) {
for (i = 0; i < brw->state.nr_draw_regions; i++) {
- ret = brw_update_region_surface(brw, brw->state.draw_regions[i], i,
- GL_FALSE);
- if (ret)
- return ret;
+ brw_update_region_surface(brw, brw->state.draw_regions[i], i,
+ GL_FALSE);
}
}else {
- ret = brw_update_region_surface(brw, brw->state.draw_regions[0], 0, GL_TRUE);
- if (ret)
- return ret;
+ brw_update_region_surface(brw, brw->state.draw_regions[0], 0, GL_TRUE);
}
brw->wm.nr_surfaces = MAX_DRAW_BUFFERS;
dri_bo_reference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]);
brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1;
} else {
- ret = brw_update_texture_surface(ctx, i);
+ brw_update_texture_surface(ctx, i);
brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1;
-
- if (ret)
- return ret;
}
} else {
dri_bo_unreference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]);
dri_bo_unreference(brw->wm.bind_bo);
brw->wm.bind_bo = brw_wm_get_binding_table(brw);
-
- return dri_bufmgr_check_aperture_space(brw->wm.bind_bo);
}
batch->ptr = batch->map;
batch->dirty_state = ~0;
batch->cliprect_mode = IGNORE_CLIPRECTS;
-
- /* account batchbuffer in aperture */
- dri_bufmgr_check_aperture_space(batch->buf);
-
}
struct intel_batchbuffer *
struct intel_context *intel;
const intelScreenPrivate *intelScreen;
- int ret;
DBG("%s\n", __FUNCTION__);
unsigned short src_x, src_y;
int BR13, CMD;
int i;
+ dri_bo *aper_array[3];
src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
dst = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
}
#endif
/* do space/cliprects check before going any further */
- intel_batchbuffer_require_space(intel->batch, 8 * 4, REFERENCES_CLIPRECTS);
+ intel_batchbuffer_require_space(intel->batch, 8 * 4,
+ REFERENCES_CLIPRECTS);
again:
- ret = dri_bufmgr_check_aperture_space(dst->buffer);
- ret |= dri_bufmgr_check_aperture_space(src->buffer);
-
- if (ret) {
+ aper_array[0] = intel->batch->buf;
+ aper_array[1] = dst->buffer;
+ aper_array[2] = src->buffer;
+
+ if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
intel_batchbuffer_flush(intel->batch);
goto again;
}
-
+
for (i = 0; i < nbox; i++, pbox++) {
drm_clip_rect_t box = *pbox;
GLuint CMD, BR13;
int dst_y2 = dst_y + h;
int dst_x2 = dst_x + w;
- int ret;
+ dri_bo *aper_array[3];
BATCH_LOCALS;
/* do space/cliprects check before going any further */
intel_batchbuffer_require_space(intel->batch, 8 * 4, NO_LOOP_CLIPRECTS);
again:
- ret = dri_bufmgr_check_aperture_space(dst_buffer);
- ret |= dri_bufmgr_check_aperture_space(src_buffer);
- if (ret) {
- intel_batchbuffer_flush(intel->batch);
- goto again;
+ aper_array[0] = intel->batch->buf;
+ aper_array[1] = dst_buffer;
+ aper_array[2] = src_buffer;
+
+ if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
+ intel_batchbuffer_flush(intel->batch);
+ goto again;
}
DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
#define SUBPIXEL_X 0.125
#define SUBPIXEL_Y 0.125
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))
#define INTEL_FIREVERTICES(intel) \