From 8c8ee4961682a8f69fc9d91844f4284bcd4bf710 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 8 Apr 2015 16:10:25 +0800 Subject: Move sampler state related settings to the inner structure in i965_gpe_context User can set sampler entry size and the number of sampler entries now. sampler.bo is always set even if the sampler state is a part of the dynamic state buffer, hence we can use the corresponding settings no matter sampler state is a part of the dynamic state buffer or not. Signed-off-by: Xiang, Haihao Reviewed-by: Zhao Yakui --- src/gen8_mfc.c | 3 ++- src/gen8_vme.c | 4 ++-- src/gen9_post_processing.c | 13 +++++++------ src/gen9_vme.c | 4 ++-- src/gen9_vp9_encoder.c | 15 +++++++++------ src/i965_gpe_utils.c | 21 ++++++++++++++++----- src/i965_gpe_utils.h | 11 +++++++---- 7 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c index c4e46fb..b0ee6fb 100644 --- a/src/gen8_mfc.c +++ b/src/gen8_mfc.c @@ -4611,7 +4611,8 @@ Bool gen8_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *e mfc_context->gpe_context.idrt.entry_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64); mfc_context->gpe_context.idrt.max_entries = MAX_INTERFACE_DESC_GEN6; mfc_context->gpe_context.curbe.length = 32 * 4; - mfc_context->gpe_context.sampler_size = 0; + mfc_context->gpe_context.sampler.entry_size = 0; + mfc_context->gpe_context.sampler.max_entries = 0; mfc_context->gpe_context.vfe_state.max_num_threads = 60 - 1; mfc_context->gpe_context.vfe_state.num_urb_entries = 16; diff --git a/src/gen8_vme.c b/src/gen8_vme.c index 5184ef1..b14d60a 100644 --- a/src/gen8_vme.c +++ b/src/gen8_vme.c @@ -1382,8 +1382,8 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e vme_context->gpe_context.idrt.max_entries = MAX_INTERFACE_DESC_GEN6; vme_context->gpe_context.curbe.length = CURBE_TOTAL_DATA_LENGTH; - vme_context->gpe_context.sampler_size = 0; - + vme_context->gpe_context.sampler.entry_size = 0; + vme_context->gpe_context.sampler.max_entries = 0; vme_context->gpe_context.vfe_state.max_num_threads = 60 - 1; vme_context->gpe_context.vfe_state.num_urb_entries = 64; diff --git a/src/gen9_post_processing.c b/src/gen9_post_processing.c index 2473803..c0ae791 100644 --- a/src/gen9_post_processing.c +++ b/src/gen9_post_processing.c @@ -488,15 +488,15 @@ gen9_p010_scaling_sample_state(VADriverContextP ctx, if (gpe_context == NULL || !src_rect || !dst_rect) return; - dri_bo_map(gpe_context->dynamic_state.bo, 1); + dri_bo_map(gpe_context->sampler.bo, 1); - if (gpe_context->dynamic_state.bo->virtual == NULL) + if (gpe_context->sampler.bo->virtual == NULL) return; - assert(gpe_context->dynamic_state.bo->virtual); + assert(gpe_context->sampler.bo->virtual); sampler_state = (struct gen8_sampler_state *) - (gpe_context->dynamic_state.bo->virtual + gpe_context->sampler_offset); + (gpe_context->sampler.bo->virtual + gpe_context->sampler.offset); memset(sampler_state, 0, sizeof(*sampler_state)); @@ -513,7 +513,7 @@ gen9_p010_scaling_sample_state(VADriverContextP ctx, sampler_state->ss3.s_wrap_mode = I965_TEXCOORDMODE_CLAMP; sampler_state->ss3.t_wrap_mode = I965_TEXCOORDMODE_CLAMP; - dri_bo_unmap(gpe_context->dynamic_state.bo); + dri_bo_unmap(gpe_context->sampler.bo); } void @@ -538,7 +538,8 @@ gen9_post_processing_context_init(VADriverContextP ctx, gen8_gpe_load_kernels(ctx, gpe_context, &scaling_kernel, 1); gpe_context->idrt.entry_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64); gpe_context->idrt.max_entries = 1; - gpe_context->sampler_size = ALIGN(sizeof(struct gen8_sampler_state), 64); + gpe_context->sampler.entry_size = ALIGN(sizeof(struct gen8_sampler_state), 64); + gpe_context->sampler.max_entries = 1; gpe_context->curbe.length = ALIGN(sizeof(struct scaling_input_parameter), 64); gpe_context->surface_state_binding_table.max_entries = MAX_SCALING_SURFACES; diff --git a/src/gen9_vme.c b/src/gen9_vme.c index 33bf8aa..fab80ce 100644 --- a/src/gen9_vme.c +++ b/src/gen9_vme.c @@ -2034,8 +2034,8 @@ Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e vme_context->gpe_context.idrt.entry_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64); vme_context->gpe_context.idrt.max_entries = MAX_INTERFACE_DESC_GEN6; vme_context->gpe_context.curbe.length = CURBE_TOTAL_DATA_LENGTH; - vme_context->gpe_context.sampler_size = 0; - + vme_context->gpe_context.sampler.entry_size = 0; + vme_context->gpe_context.sampler.max_entries = 0; vme_context->gpe_context.vfe_state.max_num_threads = 60 - 1; vme_context->gpe_context.vfe_state.num_urb_entries = 64; diff --git a/src/gen9_vp9_encoder.c b/src/gen9_vp9_encoder.c index 5d4a4a8..1badd88 100644 --- a/src/gen9_vp9_encoder.c +++ b/src/gen9_vp9_encoder.c @@ -2594,13 +2594,13 @@ gen9_vp9_dys_set_sampler_state(struct i965_gpe_context *gpe_context) if (!gpe_context) return; - dri_bo_map(gpe_context->dynamic_state.bo, 1); + dri_bo_map(gpe_context->sampler.bo, 1); - if (!gpe_context->dynamic_state.bo->virtual) + if (!gpe_context->sampler.bo->virtual) return; sampler_cmd = (struct gen9_sampler_8x8_avs *) - (gpe_context->dynamic_state.bo->virtual + gpe_context->sampler_offset); + (gpe_context->sampler.bo->virtual + gpe_context->sampler.offset); memset(sampler_cmd, 0, sizeof(struct gen9_sampler_8x8_avs)); @@ -2658,7 +2658,7 @@ gen9_vp9_dys_set_sampler_state(struct i965_gpe_context *gpe_context) &gen9_vp9_avs_coeffs[17 * 8], 15 * sizeof(struct gen8_sampler_8x8_avs_coefficients)); - dri_bo_unmap(gpe_context->dynamic_state.bo); + dri_bo_unmap(gpe_context->sampler.bo); } static void @@ -3684,9 +3684,12 @@ gen9_init_gpe_context_vp9(struct i965_gpe_context *gpe_context, { gpe_context->curbe.length = kernel_param->curbe_size; // in bytes - gpe_context->sampler_size = 0; + gpe_context->sampler.entry_size = 0; + gpe_context->sampler.max_entries = 0; + if (kernel_param->sampler_size) { - gpe_context->sampler_size = ALIGN(kernel_param->sampler_size, 64); + gpe_context->sampler.entry_size = ALIGN(kernel_param->sampler_size, 64); + gpe_context->sampler.max_entries = 1; } gpe_context->idrt.entry_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64); // 8 dws, 1 register diff --git a/src/i965_gpe_utils.c b/src/i965_gpe_utils.c index 2d7cfaf..d7286fc 100644 --- a/src/i965_gpe_utils.c +++ b/src/i965_gpe_utils.c @@ -1122,7 +1122,8 @@ gen8_gpe_context_init(VADriverContextP ctx, assert(bo); gpe_context->surface_state_binding_table.bo = bo; - bo_size = gpe_context->idrt.max_entries * gpe_context->idrt.entry_size + gpe_context->curbe.length + gpe_context->sampler_size + 192; + bo_size = gpe_context->idrt.max_entries * gpe_context->idrt.entry_size + gpe_context->curbe.length + + gpe_context->sampler.max_entries * gpe_context->sampler.entry_size + 192; dri_bo_unreference(gpe_context->dynamic_state.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "surface state & binding table", @@ -1153,8 +1154,11 @@ gen8_gpe_context_init(VADriverContextP ctx, /* Sampler state offset */ start_offset = ALIGN(end_offset, 64); - gpe_context->sampler_offset = start_offset; - end_offset = start_offset + gpe_context->sampler_size; + dri_bo_unreference(gpe_context->sampler.bo); + gpe_context->sampler.bo = bo; + dri_bo_reference(gpe_context->sampler.bo); + gpe_context->sampler.offset = start_offset; + end_offset = start_offset + gpe_context->sampler.entry_size * gpe_context->sampler.max_entries; /* update the end offset of dynamic_state */ gpe_context->dynamic_state.end_offset = end_offset; @@ -1181,6 +1185,9 @@ gen8_gpe_context_destroy(struct i965_gpe_context *gpe_context) dri_bo_unreference(gpe_context->idrt.bo); gpe_context->idrt.bo = NULL; + + dri_bo_unreference(gpe_context->sampler.bo); + gpe_context->sampler.bo = NULL; } @@ -1642,7 +1649,11 @@ gen8_gpe_context_set_dynamic_buffer(VADriverContextP ctx, dri_bo_reference(gpe_context->idrt.bo); gpe_context->idrt.offset = ds->idrt_offset; - gpe_context->sampler_offset = ds->sampler_offset; + /* sampler buffer is a part of the dynamic buffer */ + dri_bo_unreference(gpe_context->sampler.bo); + gpe_context->sampler.bo = ds->bo; + dri_bo_reference(gpe_context->sampler.bo); + gpe_context->sampler.offset = ds->sampler_offset; return; } @@ -1704,7 +1715,7 @@ gen8_gpe_setup_interface_data(VADriverContextP ctx, memset(desc, 0, sizeof(*desc)); desc->desc0.kernel_start_pointer = kernel->kernel_offset >> 6; desc->desc3.sampler_count = 0; - desc->desc3.sampler_state_pointer = (gpe_context->sampler_offset >> 5); + desc->desc3.sampler_state_pointer = (gpe_context->sampler.offset >> 5); desc->desc4.binding_table_entry_count = 0; desc->desc4.binding_table_pointer = (gpe_context->surface_state_binding_table.binding_table_offset >> 5); desc->desc5.constant_urb_entry_read_offset = 0; diff --git a/src/i965_gpe_utils.h b/src/i965_gpe_utils.h index c3b8c79..e19e107 100644 --- a/src/i965_gpe_utils.h +++ b/src/i965_gpe_utils.h @@ -96,6 +96,13 @@ struct i965_gpe_context unsigned int offset; } curbe; + struct { + dri_bo *bo; + unsigned int max_entries; + unsigned int entry_size; /* in bytes */ + unsigned int offset; + } sampler; + struct { unsigned int gpgpu_mode : 1; unsigned int pad0 : 7; @@ -164,10 +171,6 @@ struct i965_gpe_context int bo_size; unsigned int end_offset; } dynamic_state; - - unsigned int sampler_offset; - int sampler_entries; - int sampler_size; }; struct gpe_mi_flush_dw_parameter -- cgit v1.2.3