diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2007-05-30 20:40:19 +0100 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2007-05-30 20:40:19 +0100 |
commit | 5837d01edbcf5f76b457dfc2539908cd7e79e296 (patch) | |
tree | 2e0aefa2dc0cd006a5a8202a560b2e3fab54200e | |
parent | 9fda7c6df0f142f8762e97a76249a479a2cc0371 (diff) |
Prelocate the batch and state buffers, avoid most SWZ relocs.
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_differencer.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_batchbuffer.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_swz.h | 5 |
4 files changed, 48 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i915tex/i915_differencer.c b/src/mesa/drivers/dri/i915tex/i915_differencer.c index 90c404fc4b..d95526ad48 100644 --- a/src/mesa/drivers/dri/i915tex/i915_differencer.c +++ b/src/mesa/drivers/dri/i915tex/i915_differencer.c @@ -138,12 +138,18 @@ static void emit_indirect( struct intel_context *intel, for (i = 0; i < I915_MAX_CACHE; i++) { if (dirty & (1<<i)) { if (i != I915_CACHE_DYNAMIC) { +#if DO_PRELOC + EMIT_DWORD( ptr, ((intel->batch->state_offset + state->offsets[i]) | + flag | + SIS0_BUFFER_VALID) ); +#else EMIT_RELOC( intel, ptr, intel->batch->state_buffer, intel->batch->state_memflags, DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, ( state->offsets[i] | flag | SIS0_BUFFER_VALID ) ); +#endif /* No state size dword for dynamic state: */ @@ -156,13 +162,18 @@ static void emit_indirect( struct intel_context *intel, } else { assert( (state->offsets[i] & 4095) >= 4 ); - +#if DO_PRELOC + EMIT_DWORD( ptr, ((intel->batch->state_offset + state->offsets[i] - 4) | + flag | + SIS0_BUFFER_VALID) ); +#else EMIT_RELOC( intel, ptr, intel->batch->state_buffer, intel->batch->state_memflags, DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, ( (state->offsets[i] - 4) | flag | SIS0_BUFFER_VALID ) ); +#endif assert(intel->batch->segment_start_offset[1] <= state->offsets[i]); assert(intel->batch->segment_finish_offset[1] >= state->offsets[i]); diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index 1c36fc12f2..c4fdefda74 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -205,6 +205,29 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch) batch->state_map = driBOMap(batch->state_buffer, DRM_BO_FLAG_WRITE, 0); } + + if (DO_PRELOC) { + GLboolean was_locked = batch->intel->locked; + if (!was_locked) + LOCK_HARDWARE(batch->intel); + + driBOValidate(batch->intel->driFd, batch->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE | DRM_BO_FLAG_NO_MOVE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE | DRM_BO_FLAG_NO_MOVE, + DRM_BO_HINT_DONT_FENCE); + + driBOValidate(batch->intel->driFd, batch->state_buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE | DRM_BO_FLAG_NO_MOVE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE | DRM_BO_FLAG_NO_MOVE, + DRM_BO_HINT_DONT_FENCE); + + if (!was_locked) + UNLOCK_HARDWARE(batch->intel); + + batch->state_offset = driBOOffset(batch->state_buffer); + batch->batch_offset = driBOOffset(batch->buffer); + } + batch->segment_finish_offset[0] = batch->segment_start_offset[0]; batch->segment_finish_offset[1] = batch->segment_start_offset[1]; batch->segment_finish_offset[2] = batch->segment_start_offset[2]; diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h index 06973d82d3..7ea1c3dc86 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h @@ -14,6 +14,11 @@ struct intel_context; #define INTEL_BATCH_CLIPRECTS 0x2 #define INTEL_BATCH_HWZ 0x4 +/* Prelocations - pre-assign an offset to the batch and state buffers + * to eliminate most of the relocation overhead on zone rendering. + */ +#define DO_PRELOC 1 + struct buffer_reloc { GLuint slot; @@ -41,6 +46,9 @@ struct intel_batchbuffer GLuint state_memtype; GLuint state_memflags; + GLuint batch_offset; /* DO_PRELOC only */ + GLuint state_offset; /* DO_PRELOC only */ + struct _DriBufferList *list; GLuint list_count; GLubyte *map; diff --git a/src/mesa/drivers/dri/i915tex/intel_swz.h b/src/mesa/drivers/dri/i915tex/intel_swz.h index 9d3308fce6..6bc8fb3bbf 100644 --- a/src/mesa/drivers/dri/i915tex/intel_swz.h +++ b/src/mesa/drivers/dri/i915tex/intel_swz.h @@ -261,6 +261,10 @@ static INLINE void zone_begin_batch( struct swz_render *swz, /* Both out and newptr are assumed to be in the batchbuffer!! */ +#if DO_PRELOC + *out++ = (swz->intel->batch->batch_offset + + newptr - swz->intel->batch->map); +#else intel_batchbuffer_set_reloc( swz->intel->batch, SEGMENT_IMMEDIATE, ((GLubyte *)out) - swz->intel->batch->map, @@ -268,6 +272,7 @@ static INLINE void zone_begin_batch( struct swz_render *swz, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, newptr - swz->intel->batch->map ); +#endif } |