drm/i965: Merge the constants into the surface stream.

As we can use an offset from the surface base for the constant buffers,
we need to fold the constants into the surface stream.
This commit is contained in:
Chris Wilson 2010-03-03 13:56:48 +00:00
parent cc58594757
commit 3692597567
3 changed files with 14 additions and 93 deletions

View file

@ -339,9 +339,8 @@ struct i965_stream {
};
#define I965_BATCH_SIZE (16 * 4096)
#define I965_SURFACE_SIZE (16 * 4096)
#define I965_GENERAL_SIZE (16 * 4096)
#define I965_CONSTANT_SIZE (16 * 4096)
#define I965_SURFACE_SIZE (32 * 4096)
#define I965_VERTEX_SIZE (128 * 4096)
#define I965_TILING_DEFAULT I915_TILING_Y
@ -402,12 +401,12 @@ struct i965_device {
i965_stream_t batch;
uint8_t batch_base[I965_BATCH_SIZE];
struct drm_i915_gem_relocation_entry batch_relocations[1024];
struct drm_i915_gem_relocation_entry batch_relocations[2048];
i965_stream_t surface;
uint8_t surface_base[I965_SURFACE_SIZE];
struct i965_pending_relocation surface_pending_relocations[1];
struct drm_i915_gem_relocation_entry surface_relocations[512];
struct drm_i915_gem_relocation_entry surface_relocations[1024];
i965_stream_t general;
uint8_t general_base[I965_GENERAL_SIZE];
@ -417,10 +416,6 @@ struct i965_device {
uint8_t vertex_base[I965_VERTEX_SIZE];
struct i965_pending_relocation vertex_pending_relocations[512];
i965_stream_t constant;
uint8_t constant_base[I965_CONSTANT_SIZE];
struct i965_pending_relocation constant_pending_relocations[512];
struct {
size_t gtt_size;

View file

@ -2572,17 +2572,12 @@ i965_emit_composite (i965_device_t *device,
assert (size <= 64 * URB_CS_ENTRY_SIZE);
assert (((sizeof (float) * shader->constants_size + 31) & -32) == 32 * i965_shader_const_urb_length (shader));
OUT_BATCH (BRW_CONSTANT_BUFFER | (1 << 8));
assert ((device->constant.used & 63) == 0);
i965_stream_add_pending_relocation (&device->constant,
device->batch.used,
I915_GEM_DOMAIN_INSTRUCTION, 0,
device->constant.used + size / 64 - 1);
OUT_BATCH (0); /* pending relocation */
device->constants = i965_stream_alloc (&device->constant, 0, size);
device->constants = i965_stream_alloc (&device->surface, 64, size);
memcpy (device->constants, shader->constants, size);
device->constants_size = shader->constants_size;
OUT_BATCH (BRW_CONSTANT_BUFFER | (1 << 8));
OUT_BATCH (i965_stream_offsetof (&device->surface, device->constants) + size / 64 - 1);
}
i965_emit_vertex_element (device, shader);
@ -2596,6 +2591,8 @@ i965_flush_vertices (i965_device_t *device)
if (device->vertex.used == device->vertex.committed)
return;
assert (device->vertex.used > device->vertex.committed);
vertex_start = device->vertex.committed / device->vertex_size;
vertex_count =
(device->vertex.used - device->vertex.committed) / device->vertex_size;
@ -2630,10 +2627,6 @@ i965_flush_vertices (i965_device_t *device)
OUT_BATCH (0);
device->vertex.committed = device->vertex.used;
#if 1
OUT_BATCH (MI_FLUSH);
#endif
}
void
@ -2726,13 +2719,6 @@ recheck:
goto recheck;
}
if (unlikely (device->constant.used + sizeof (device->constants) > device->constant.size ||
device->constant.num_pending_relocations == device->constant.max_pending_relocations))
{
i965_stream_commit (device, &device->constant);
goto recheck;
}
if (unlikely (device->general.used + 512 > device->general.size)) {
i965_stream_commit (device, &device->general);
i965_general_state_reset (device);

View file

@ -290,8 +290,7 @@ static void
i965_device_reset (i965_device_t *device)
{
device->exec.count = 0;
device->exec.gtt_size = I965_CONSTANT_SIZE +
I965_VERTEX_SIZE +
device->exec.gtt_size = I965_VERTEX_SIZE +
I965_SURFACE_SIZE +
I965_GENERAL_SIZE +
I965_BATCH_SIZE;
@ -532,14 +531,8 @@ i965_device_flush (i965_device_t *device)
/* Combine vertex+constant+surface+batch streams? */
max = aligned = device->vertex.used;
if (device->constant.used) {
aligned = (aligned + 63) & -64;
aligned += device->constant.used;
if (device->constant.used > max)
max = device->constant.used;
}
if (device->surface.used) {
aligned = (aligned + 31) & -32;
aligned = (aligned + 63) & -64;
aligned += device->surface.used;
if (device->surface.used > max)
max = device->surface.used;
@ -564,15 +557,10 @@ i965_device_flush (i965_device_t *device)
_copy_to_bo_and_apply_relocations (device, bo, &device->vertex, 0);
aligned = device->vertex.used;
if (device->constant.used) {
aligned = (aligned + 63) & -64;
_copy_to_bo_and_apply_relocations (device, bo, &device->constant, aligned);
aligned += device->constant.used;
}
batch_num_relocations = device->batch.num_relocations;
if (device->surface.used) {
aligned = (aligned + 31) & -32;
aligned = (aligned + 63) & -64;
_copy_to_bo_and_apply_relocations (device, bo, &device->surface, aligned);
batch_num_relocations = device->batch.num_relocations;
@ -624,49 +612,8 @@ i965_device_flush (i965_device_t *device)
}
} else {
i965_stream_commit (device, &device->vertex);
if (device->constant.used && device->surface.used){
aligned = (device->constant.used + 31) & -32;
aligned += device->surface.used;
max = MAX (device->constant.used, device->surface.used);
if (aligned <= next_bo_size (max)) {
if (aligned <= 8192)
max = aligned;
bo = intel_bo_create (&device->intel, max, FALSE);
if (unlikely (bo == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
assert (aligned <= bo->base.size);
_copy_to_bo_and_apply_relocations (device, bo, &device->constant, 0);
aligned = (device->constant.used + 31) & -32;
_copy_to_bo_and_apply_relocations (device, bo, &device->surface, aligned);
if (device->surface.num_relocations) {
assert (bo->exec != NULL);
for (n = 0; n < device->surface.num_relocations; n++)
device->surface.relocations[n].offset += aligned;
bo->exec->relocs_ptr = (uintptr_t) device->surface.relocations;
bo->exec->relocation_count = device->surface.num_relocations;
}
i965_stream_reset (&device->surface);
i965_stream_reset (&device->constant);
intel_bo_destroy (&device->intel, bo);
}
} else {
if (device->constant.used)
i965_stream_commit (device, &device->constant);
if (device->surface.used)
i965_stream_commit (device, &device->surface);
}
if (device->surface.used)
i965_stream_commit (device, &device->surface);
bo = intel_bo_create (&device->intel, device->batch.used, FALSE);
if (unlikely (bo == NULL))
@ -697,7 +644,6 @@ i965_device_flush (i965_device_t *device)
i965_stream_reset (&device->vertex);
i965_stream_reset (&device->surface);
i965_stream_reset (&device->constant);
i965_stream_reset (&device->batch);
intel_glyph_cache_unpin (&device->intel);
@ -1873,12 +1819,6 @@ _cairo_drm_i965_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
ARRAY_LENGTH (device->vertex_pending_relocations),
NULL, 0);
i965_stream_init (&device->constant,
device->constant_base, sizeof (device->constant_base),
device->constant_pending_relocations,
ARRAY_LENGTH (device->constant_pending_relocations),
NULL, 0);
cairo_list_init (&device->flush);
i965_device_reset (device);
device->vs_offset = (uint32_t) -1;