rendercopy: Pass context to rendercopy functions

rendercopy does the batch buffer flush internally, so if we want
to use it with multiple contexts, we need to pass the context
in from caller.

v2: Modify rendercopy_gen8 as well

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
This commit is contained in:
Ville Syrjälä 2013-11-21 19:05:17 +02:00
parent 3d371a7284
commit 725da6ee74
14 changed files with 43 additions and 28 deletions

View File

@ -62,6 +62,7 @@ static inline unsigned buf_height(struct scratch_buf *buf)
} }
typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch, typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
@ -69,22 +70,27 @@ typedef void (*render_copyfunc_t)(struct intel_batchbuffer *batch,
render_copyfunc_t get_render_copyfunc(int devid); render_copyfunc_t get_render_copyfunc(int devid);
void gen8_render_copyfunc(struct intel_batchbuffer *batch, void gen8_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
void gen7_render_copyfunc(struct intel_batchbuffer *batch, void gen7_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
void gen6_render_copyfunc(struct intel_batchbuffer *batch, void gen6_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
void gen3_render_copyfunc(struct intel_batchbuffer *batch, void gen3_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
void gen2_render_copyfunc(struct intel_batchbuffer *batch, void gen2_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);

View File

@ -78,14 +78,15 @@ batch_copy(struct intel_batchbuffer *batch, const void *ptr, uint32_t size, uint
} }
static void static void
gen6_render_flush(struct intel_batchbuffer *batch, uint32_t batch_end) gen6_render_flush(struct intel_batchbuffer *batch,
drm_intel_context *context, uint32_t batch_end)
{ {
int ret; int ret;
ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
if (ret == 0) if (ret == 0)
ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, ret = drm_intel_gem_bo_context_exec(batch->bo, context,
NULL, 0, 0, 0); batch_end, 0);
assert(ret == 0); assert(ret == 0);
} }
@ -529,6 +530,7 @@ static uint32_t gen6_emit_primitive(struct intel_batchbuffer *batch)
} }
void gen6_render_copyfunc(struct intel_batchbuffer *batch, void gen6_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
@ -537,7 +539,7 @@ void gen6_render_copyfunc(struct intel_batchbuffer *batch,
uint32_t cc_vp, cc_blend, offset; uint32_t cc_vp, cc_blend, offset;
uint32_t batch_end; uint32_t batch_end;
intel_batchbuffer_flush(batch); intel_batchbuffer_flush_with_context(batch, context);
batch->ptr = batch->buffer + 1024; batch->ptr = batch->buffer + 1024;
batch_alloc(batch, 64, 64); batch_alloc(batch, 64, 64);
@ -594,6 +596,6 @@ void gen6_render_copyfunc(struct intel_batchbuffer *batch,
emit_vertex_normalized(batch, src_x, buf_width(src)); emit_vertex_normalized(batch, src_x, buf_width(src));
emit_vertex_normalized(batch, src_y, buf_height(src)); emit_vertex_normalized(batch, src_y, buf_height(src));
gen6_render_flush(batch, batch_end); gen6_render_flush(batch, context, batch_end);
intel_batchbuffer_reset(batch); intel_batchbuffer_reset(batch);
} }

View File

@ -52,14 +52,15 @@ batch_copy(struct intel_batchbuffer *batch, const void *ptr, uint32_t size, uint
} }
static void static void
gen7_render_flush(struct intel_batchbuffer *batch, uint32_t batch_end) gen7_render_flush(struct intel_batchbuffer *batch,
drm_intel_context *context, uint32_t batch_end)
{ {
int ret; int ret;
ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
if (ret == 0) if (ret == 0)
ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, ret = drm_intel_gem_bo_context_exec(batch->bo, context,
NULL, 0, 0, 0); batch_end, 0);
assert(ret == 0); assert(ret == 0);
} }
@ -513,13 +514,14 @@ gen7_emit_null_depth_buffer(struct intel_batchbuffer *batch)
#define BATCH_STATE_SPLIT 2048 #define BATCH_STATE_SPLIT 2048
void gen7_render_copyfunc(struct intel_batchbuffer *batch, void gen7_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
{ {
uint32_t batch_end; uint32_t batch_end;
intel_batchbuffer_flush(batch); intel_batchbuffer_flush_with_context(batch, context);
batch->state = &batch->buffer[BATCH_STATE_SPLIT]; batch->state = &batch->buffer[BATCH_STATE_SPLIT];
@ -563,6 +565,6 @@ void gen7_render_copyfunc(struct intel_batchbuffer *batch,
batch_end = ALIGN(batch_end, 8); batch_end = ALIGN(batch_end, 8);
assert(batch_end < BATCH_STATE_SPLIT); assert(batch_end < BATCH_STATE_SPLIT);
gen7_render_flush(batch, batch_end); gen7_render_flush(batch, context, batch_end);
intel_batchbuffer_reset(batch); intel_batchbuffer_reset(batch);
} }

View File

@ -147,14 +147,15 @@ batch_copy(struct intel_batchbuffer *batch, const void *ptr, uint32_t size, uint
} }
static void static void
gen6_render_flush(struct intel_batchbuffer *batch, uint32_t batch_end) gen6_render_flush(struct intel_batchbuffer *batch,
drm_intel_context *context, uint32_t batch_end)
{ {
int ret; int ret;
ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
if (ret == 0) if (ret == 0)
ret = drm_intel_bo_mrb_exec(batch->bo, batch_end, ret = drm_intel_gem_bo_context_exec(batch->bo, context,
NULL, 0, 0, 0); batch_end, 0);
assert(ret == 0); assert(ret == 0);
} }
@ -848,6 +849,7 @@ static void gen8_emit_primitive(struct intel_batchbuffer *batch, uint32_t offset
#define BATCH_STATE_SPLIT 2048 #define BATCH_STATE_SPLIT 2048
void gen8_render_copyfunc(struct intel_batchbuffer *batch, void gen8_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)
@ -857,7 +859,7 @@ void gen8_render_copyfunc(struct intel_batchbuffer *batch,
uint32_t vertex_buffer; uint32_t vertex_buffer;
uint32_t batch_end; uint32_t batch_end;
intel_batchbuffer_flush(batch); intel_batchbuffer_flush_with_context(batch, context);
batch_align(batch, 8); batch_align(batch, 8);
@ -947,6 +949,6 @@ void gen8_render_copyfunc(struct intel_batchbuffer *batch,
annotation_flush(&aub_annotations, batch); annotation_flush(&aub_annotations, batch);
gen6_render_flush(batch, batch_end); gen6_render_flush(batch, context, batch_end);
intel_batchbuffer_reset(batch); intel_batchbuffer_reset(batch);
} }

View File

@ -191,6 +191,7 @@ static void gen2_emit_copy_pipeline(struct intel_batchbuffer *batch)
} }
void gen2_render_copyfunc(struct intel_batchbuffer *batch, void gen2_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)

View File

@ -3,6 +3,7 @@
#include "rendercopy.h" #include "rendercopy.h"
void gen3_render_copyfunc(struct intel_batchbuffer *batch, void gen3_render_copyfunc(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned width, unsigned height, unsigned width, unsigned height,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)

View File

@ -84,7 +84,7 @@ static void *work(void *arg)
if (uncontexted) { if (uncontexted) {
igt_assert(rendercopy); igt_assert(rendercopy);
rendercopy(batch, &src, 0, 0, 0, 0, &dst, 0, 0); rendercopy(batch, NULL, &src, 0, 0, 0, 0, &dst, 0, 0);
} else { } else {
int ret; int ret;
ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer); ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);

View File

@ -156,7 +156,7 @@ int main(int argc, char **argv)
drm_intel_bufmgr_gem_set_aub_dump(data.bufmgr, true); drm_intel_bufmgr_gem_set_aub_dump(data.bufmgr, true);
} }
render_copy(batch, render_copy(batch, NULL,
&src, 0, 0, WIDTH, HEIGHT, &src, 0, 0, WIDTH, HEIGHT,
&dst, WIDTH / 2, HEIGHT / 2); &dst, WIDTH / 2, HEIGHT / 2);

View File

@ -128,7 +128,7 @@ int main(int argc, char **argv)
dst.tiling = I915_TILING_NONE; dst.tiling = I915_TILING_NONE;
dst.size = SIZE; dst.size = SIZE;
render_copy(batch, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0); render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
start_val[(i + 1) % count] = start_val[i % count]; start_val[(i + 1) % count] = start_val[i % count];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -151,7 +151,7 @@ int main(int argc, char **argv)
dst.tiling = I915_TILING_NONE; dst.tiling = I915_TILING_NONE;
dst.size = SIZE; dst.size = SIZE;
render_copy(batch, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0); render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
start_val[i % count] = start_val[(i + 1) % count]; start_val[i % count] = start_val[(i + 1) % count];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -176,7 +176,7 @@ int main(int argc, char **argv)
dst.tiling = I915_TILING_NONE; dst.tiling = I915_TILING_NONE;
dst.size = SIZE; dst.size = SIZE;
render_copy(batch, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0); render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
start_val[d] = start_val[s]; start_val[d] = start_val[s];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)

View File

@ -130,7 +130,7 @@ int main(int argc, char **argv)
int src = i % count; int src = i % count;
int dst = (i + 1) % count; int dst = (i + 1) % count;
render_copy(batch, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0); render_copy(batch, NULL, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0);
start_val[dst] = start_val[src]; start_val[dst] = start_val[src];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -141,7 +141,7 @@ int main(int argc, char **argv)
int src = (i + 1) % count; int src = (i + 1) % count;
int dst = i % count; int dst = i % count;
render_copy(batch, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0); render_copy(batch, NULL, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0);
start_val[dst] = start_val[src]; start_val[dst] = start_val[src];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -155,7 +155,7 @@ int main(int argc, char **argv)
if (src == dst) if (src == dst)
continue; continue;
render_copy(batch, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0); render_copy(batch, NULL, buf+src, 0, 0, WIDTH, HEIGHT, buf+dst, 0, 0);
start_val[dst] = start_val[src]; start_val[dst] = start_val[src];
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)

View File

@ -159,9 +159,9 @@ static int check_ring(drm_intel_bufmgr *bufmgr,
igt_assert(y < height); igt_assert(y < height);
/* Dummy load to fill the ring */ /* Dummy load to fill the ring */
copy(batch, &src, 0, 0, width, height, &tmp, 0, 0); copy(batch, NULL, &src, 0, 0, width, height, &tmp, 0, 0);
/* And copy the src into dst, pixel by pixel */ /* And copy the src into dst, pixel by pixel */
copy(batch, &src, x, y, 1, 1, &dst, x, y); copy(batch, NULL, &src, x, y, 1, 1, &dst, x, y);
} }
/* verify */ /* verify */
@ -173,6 +173,7 @@ static int check_ring(drm_intel_bufmgr *bufmgr,
} }
static void blt_copy(struct intel_batchbuffer *batch, static void blt_copy(struct intel_batchbuffer *batch,
drm_intel_context *context,
struct scratch_buf *src, unsigned src_x, unsigned src_y, struct scratch_buf *src, unsigned src_x, unsigned src_y,
unsigned w, unsigned h, unsigned w, unsigned h,
struct scratch_buf *dst, unsigned dst_x, unsigned dst_y) struct scratch_buf *dst, unsigned dst_x, unsigned dst_y)

View File

@ -148,7 +148,7 @@ static void render_copyfunc(struct scratch_buf *src,
static int warned = 0; static int warned = 0;
if (rendercopy) { if (rendercopy) {
rendercopy(batch_3d, rendercopy(batch_3d, NULL,
src, src_x, src_y, src, src_x, src_y,
width, height, width, height,
dst, dst_x, dst_y); dst, dst_x, dst_y);

View File

@ -328,7 +328,7 @@ static void render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned sr
keep_gpu_busy(); keep_gpu_busy();
if (rendercopy) if (rendercopy)
rendercopy(batch, src, src_x, src_y, rendercopy(batch, NULL, src, src_x, src_y,
options.tile_size, options.tile_size, options.tile_size, options.tile_size,
dst, dst_x, dst_y); dst, dst_x, dst_y);
else else

View File

@ -234,7 +234,7 @@ static void emit_dummy_load__rcs(struct test_output *o)
for (i = 0; i < limit; i++) { for (i = 0; i < limit; i++) {
struct scratch_buf *tmp; struct scratch_buf *tmp;
copyfunc(batch, copyfunc(batch, NULL,
src, 0, 0, src, 0, 0,
o->fb_width, o->fb_height, o->fb_width, o->fb_height,
dst, 0, 0); dst, 0, 0);