From c4e730e218a5e8fa329bb122b293b456f373b41b Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sun, 22 Sep 2013 15:33:49 -0700 Subject: [PATCH] i965: Define vtbl method that initializes an untyped R/W surface. And add Gen7 implementation. v2: Fix off by one error in buffer size calculation. Reviewed-by: Paul Berry --- src/mesa/drivers/dri/i965/brw_context.h | 7 ++++ .../drivers/dri/i965/gen7_wm_surface_state.c | 35 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 57ed7d601ed..d13a88c9877 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -945,6 +945,13 @@ struct brw_context uint32_t *out_offset, bool dword_pitch); + void (*create_raw_surface)(struct brw_context *brw, + drm_intel_bo *bo, + uint32_t offset, + uint32_t size, + uint32_t *out_offset, + bool rw); + /** Upload a SAMPLER_STATE table. */ void (*upload_sampler_state_table)(struct brw_context *brw, struct gl_program *prog, diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c index 1f0c75fc2ef..cd376421a01 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c @@ -232,7 +232,8 @@ gen7_emit_buffer_surface_state(struct brw_context *brw, unsigned surface_format, unsigned buffer_size, unsigned pitch, - unsigned mocs) + unsigned mocs, + bool rw) { uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 8 * 4, 32, out_offset); @@ -259,7 +260,8 @@ gen7_emit_buffer_surface_state(struct brw_context *brw, /* Emit relocation to surface contents */ if (bo) { drm_intel_bo_emit_reloc(brw->batch.bo, *out_offset + 4, - bo, buffer_offset, I915_GEM_DOMAIN_SAMPLER, 0); + bo, buffer_offset, I915_GEM_DOMAIN_SAMPLER, + (rw ? I915_GEM_DOMAIN_SAMPLER : 0)); } gen7_check_surface_setup(surf, false /* is_render_target */); @@ -299,7 +301,8 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx, surface_format, size / texel_size, texel_size, - 0 /* mocs */); + 0 /* mocs */, + false /* rw */); } static void @@ -416,7 +419,27 @@ gen7_create_constant_surface(struct brw_context *brw, BRW_SURFACEFORMAT_R32G32B32A32_FLOAT, elements, stride, - 0 /* mocs */); + 0 /* mocs */, + false /* rw */); +} + +/** + * Create a raw surface for untyped R/W access. + */ +static void +gen7_create_raw_surface(struct brw_context *brw, drm_intel_bo *bo, + uint32_t offset, uint32_t size, + uint32_t *out_offset, bool rw) +{ + gen7_emit_buffer_surface_state(brw, + out_offset, + bo, + offset, + BRW_SURFACEFORMAT_RAW, + size, + 1, + 0 /* mocs */, + true /* rw */); } /** @@ -432,7 +455,8 @@ gen7_create_shader_time_surface(struct brw_context *brw, uint32_t *out_offset) BRW_SURFACEFORMAT_RAW, brw->shader_time.bo->size, 1, - 0 /* mocs */); + 0 /* mocs */, + true /* rw */); } static void @@ -607,4 +631,5 @@ gen7_init_vtable_surface_functions(struct brw_context *brw) brw->vtbl.update_null_renderbuffer_surface = gen7_update_null_renderbuffer_surface; brw->vtbl.create_constant_surface = gen7_create_constant_surface; + brw->vtbl.create_raw_surface = gen7_create_raw_surface; } -- 2.30.2