[Libva] [PATCH 4/5] Allow to create batchbuffer based on the expected buffer size
yakui.zhao at intel.com
yakui.zhao at intel.com
Mon Oct 29 23:50:35 PDT 2012
From: Zhao Yakui <yakui.zhao at intel.com>
This is to support the 4Kx4K encoding on Haswell. Otherwise the default batch
buffer size can't hold the encoding command for 4Kx4K encoding.
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
src/gen6_mfc_common.c | 2 +-
src/gen6_mfd.c | 2 +-
src/gen75_mfc.c | 11 +++++++++--
src/gen75_mfd.c | 2 +-
src/gen75_vpp_vebox.c | 2 +-
src/gen7_mfd.c | 2 +-
src/i965_drv_video.c | 2 +-
src/i965_encoder.c | 6 +++---
src/i965_media.c | 4 ++--
src/i965_post_processing.c | 2 +-
src/intel_batchbuffer.c | 21 ++++++++++++++++-----
src/intel_batchbuffer.h | 2 +-
12 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 3621e9e..aaa5e7f 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -569,7 +569,7 @@ void intel_mfc_avc_init(VADriverContextP ctx,
if (mfc_context->aux_batchbuffer)
intel_batchbuffer_free(mfc_context->aux_batchbuffer);
- mfc_context->aux_batchbuffer = intel_batchbuffer_new(&i965->intel, I915_EXEC_BSD);
+ mfc_context->aux_batchbuffer = intel_batchbuffer_new(&i965->intel, I915_EXEC_BSD, 0);
mfc_context->aux_batchbuffer_surface.bo = mfc_context->aux_batchbuffer->buffer;
dri_bo_reference(mfc_context->aux_batchbuffer_surface.bo);
mfc_context->aux_batchbuffer_surface.pitch = 16;
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index 7329d8f..37bbfd0 100755
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -2056,7 +2056,7 @@ gen6_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
gen6_mfd_context->base.destroy = gen6_mfd_context_destroy;
gen6_mfd_context->base.run = gen6_mfd_decode_picture;
- gen6_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ gen6_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
diff --git a/src/gen75_mfc.c b/src/gen75_mfc.c
index 72001d0..ee4a266 100644
--- a/src/gen75_mfc.c
+++ b/src/gen75_mfc.c
@@ -1129,10 +1129,17 @@ gen75_mfc_avc_software_batchbuffer(VADriverContextP ctx,
struct intel_encoder_context *encoder_context)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
- struct intel_batchbuffer *batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_BSD);
- dri_bo *batch_bo = batch->buffer;
+ struct intel_batchbuffer *batch;
+ dri_bo *batch_bo;
int i;
+ int buffer_size;
+ VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
+ int width_in_mbs = pSequenceParameter->picture_width_in_mbs;
+ int height_in_mbs = pSequenceParameter->picture_height_in_mbs;
+ buffer_size = width_in_mbs * height_in_mbs * 64;
+ batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_BSD, buffer_size);
+ batch_bo = batch->buffer;
for (i = 0; i < encode_state->num_slice_params_ext; i++) {
gen75_mfc_avc_pipeline_slice_programing(ctx, encode_state, encoder_context, i, batch);
}
diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c
index 1aa41bc..d293fbd 100644
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -3411,7 +3411,7 @@ gen75_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config
gen7_mfd_context->base.destroy = gen75_mfd_context_destroy;
gen7_mfd_context->base.run = gen75_mfd_decode_picture;
- gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
diff --git a/src/gen75_vpp_vebox.c b/src/gen75_vpp_vebox.c
index 692ccbb..a6b61fd 100644
--- a/src/gen75_vpp_vebox.c
+++ b/src/gen75_vpp_vebox.c
@@ -1235,7 +1235,7 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx)
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_vebox_context *proc_context = calloc(1, sizeof(struct intel_vebox_context));
- proc_context->batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX);
+ proc_context->batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX, 0);
memset(proc_context->frame_store, 0, sizeof(VEBFrameStore)*FRAME_STORE_SUM);
proc_context->filters_mask = 0;
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index f2cabdb..f48b41b 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -2844,7 +2844,7 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
gen7_mfd_context->base.destroy = gen7_mfd_context_destroy;
gen7_mfd_context->base.run = gen7_mfd_decode_picture;
- gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 16f0343..37707e8 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2122,7 +2122,7 @@ i965_Init(VADriverContextP ctx)
else
return VA_STATUS_ERROR_UNKNOWN;
- i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER);
+ i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER, 0);
if (!i965_display_attributes_init(ctx))
return VA_STATUS_ERROR_UNKNOWN;
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index b37915b..d71a59c 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -161,7 +161,7 @@ gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
encoder_context->base.destroy = intel_encoder_context_destroy;
encoder_context->base.run = intel_encoder_end_picture;
- encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
encoder_context->rate_control_mode = VA_RC_NONE;
for (i = 0; i < obj_config->num_attribs; i++) {
@@ -193,7 +193,7 @@ gen7_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
encoder_context->base.destroy = intel_encoder_context_destroy;
encoder_context->base.run = intel_encoder_end_picture;
- encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
encoder_context->input_yuv_surface = VA_INVALID_SURFACE;
encoder_context->is_tmp_id = 0;
encoder_context->rate_control_mode = VA_RC_NONE;
@@ -227,7 +227,7 @@ gen75_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config
encoder_context->base.destroy = intel_encoder_context_destroy;
encoder_context->base.run = intel_encoder_end_picture;
- encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
encoder_context->input_yuv_surface = VA_INVALID_SURFACE;
encoder_context->is_tmp_id = 0;
encoder_context->rate_control_mode = VA_RC_NONE;
diff --git a/src/i965_media.c b/src/i965_media.c
index 2b940c7..d1764c0 100644
--- a/src/i965_media.c
+++ b/src/i965_media.c
@@ -328,7 +328,7 @@ g4x_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
media_context->base.destroy = i965_media_context_destroy;
media_context->base.run = i965_media_decode_picture;
- media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
switch (obj_config->profile) {
case VAProfileMPEG2Simple:
@@ -358,7 +358,7 @@ ironlake_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_con
media_context->base.destroy = i965_media_context_destroy;
media_context->base.run = i965_media_decode_picture;
- media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
switch (obj_config->profile) {
case VAProfileMPEG2Simple:
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index d6c99ad..7c77494 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -5128,7 +5128,7 @@ i965_proc_context_init(VADriverContextP ctx, struct object_config *obj_config)
proc_context->base.destroy = i965_proc_context_destroy;
proc_context->base.run = i965_proc_picture;
- proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
+ proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
i965_post_processing_context_init(ctx, &proc_context->pp_context, proc_context->base.batch);
return (struct hw_context *)proc_context;
diff --git a/src/intel_batchbuffer.c b/src/intel_batchbuffer.c
index 6ae1a35..94d968c 100644
--- a/src/intel_batchbuffer.c
+++ b/src/intel_batchbuffer.c
@@ -31,11 +31,13 @@
#include "intel_batchbuffer.h"
+#define MAX_BATCH_SIZE 0x400000
+
static void
-intel_batchbuffer_reset(struct intel_batchbuffer *batch)
+intel_batchbuffer_reset(struct intel_batchbuffer *batch, int buffer_size)
{
struct intel_driver_data *intel = batch->intel;
- int batch_size = BATCH_SIZE;
+ int batch_size = buffer_size;
assert(batch->flag == I915_EXEC_RENDER ||
batch->flag == I915_EXEC_BLT ||
@@ -64,7 +66,7 @@ intel_batchbuffer_space(struct intel_batchbuffer *batch)
struct intel_batchbuffer *
-intel_batchbuffer_new(struct intel_driver_data *intel, int flag)
+intel_batchbuffer_new(struct intel_driver_data *intel, int flag, int buffer_size)
{
struct intel_batchbuffer *batch = calloc(1, sizeof(*batch));
assert(flag == I915_EXEC_RENDER ||
@@ -72,10 +74,19 @@ intel_batchbuffer_new(struct intel_driver_data *intel, int flag)
flag == I915_EXEC_BLT ||
flag == I915_EXEC_VEBOX);
+ if (!buffer_size || buffer_size < BATCH_SIZE) {
+ buffer_size = BATCH_SIZE;
+ }
+
+ /* the buffer size can't exceed 4M */
+ if (buffer_size > MAX_BATCH_SIZE) {
+ buffer_size = MAX_BATCH_SIZE;
+ }
+
batch->intel = intel;
batch->flag = flag;
batch->run = drm_intel_bo_mrb_exec;
- intel_batchbuffer_reset(batch);
+ intel_batchbuffer_reset(batch, buffer_size);
return batch;
}
@@ -110,7 +121,7 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch)
dri_bo_unmap(batch->buffer);
used = batch->ptr - batch->map;
batch->run(batch->buffer, used, 0, 0, 0, batch->flag);
- intel_batchbuffer_reset(batch);
+ intel_batchbuffer_reset(batch, batch->size);
}
void
diff --git a/src/intel_batchbuffer.h b/src/intel_batchbuffer.h
index 25d817b..825aded 100644
--- a/src/intel_batchbuffer.h
+++ b/src/intel_batchbuffer.h
@@ -26,7 +26,7 @@ struct intel_batchbuffer
int DR4, unsigned int ring_flag);
};
-struct intel_batchbuffer *intel_batchbuffer_new(struct intel_driver_data *intel, int flag);
+struct intel_batchbuffer *intel_batchbuffer_new(struct intel_driver_data *intel, int flag, int buffer_size);
void intel_batchbuffer_free(struct intel_batchbuffer *batch);
void intel_batchbuffer_start_atomic(struct intel_batchbuffer *batch, unsigned int size);
void intel_batchbuffer_start_atomic_bcs(struct intel_batchbuffer *batch, unsigned int size);
--
1.7.12-rc1
More information about the Libva
mailing list