summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2017-11-06 16:05:43 -0800
committerKenneth Graunke <[email protected]>2017-11-15 09:37:32 -0800
commitf48f52b0306e37d4d41dbf6a32970ee468298b2b (patch)
tree28802d078597319d9c902c4a171a5948e3e6f0d8 /src/mesa
parent059d25a06de2bd396bd8d6d2dc1580361d3db915 (diff)
i965: Make a better helper function for UBO/SSBO/ABO surface handling.
This fixes the missing AutomaticSize handling in the ABO code, removes a bunch of duplicated code, and drops an extra layer of wrapping around brw_emit_buffer_surface_state(). Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h10
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c114
-rw-r--r--src/mesa/drivers/dri/i965/gen6_constant_state.c7
3 files changed, 37 insertions, 94 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 7457aba54a3..72a81a0ec1a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1402,16 +1402,6 @@ brw_get_index_type(unsigned index_size)
void brw_prepare_vertices(struct brw_context *brw);
/* brw_wm_surface_state.c */
-void brw_create_constant_surface(struct brw_context *brw,
- struct brw_bo *bo,
- uint32_t offset,
- uint32_t size,
- uint32_t *out_offset);
-void brw_create_buffer_surface(struct brw_context *brw,
- struct brw_bo *bo,
- uint32_t offset,
- uint32_t size,
- uint32_t *out_offset);
void brw_update_buffer_texture_surface(struct gl_context *ctx,
unsigned unit,
uint32_t *surf_offset);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 42ee9a1b252..bcd82d03e7c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -678,44 +678,6 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
}
/**
- * Create the constant buffer surface. Vertex/fragment shader constants will be
- * read from this buffer with Data Port Read instructions/messages.
- */
-void
-brw_create_constant_surface(struct brw_context *brw,
- struct brw_bo *bo,
- uint32_t offset,
- uint32_t size,
- uint32_t *out_offset)
-{
- brw_emit_buffer_surface_state(brw, out_offset, bo, offset,
- ISL_FORMAT_R32G32B32A32_FLOAT,
- size, 1, 0);
-}
-
-/**
- * Create the buffer surface. Shader buffer variables will be
- * read from / write to this buffer with Data Port Read/Write
- * instructions/messages.
- */
-void
-brw_create_buffer_surface(struct brw_context *brw,
- struct brw_bo *bo,
- uint32_t offset,
- uint32_t size,
- uint32_t *out_offset)
-{
- /* Use a raw surface so we can reuse existing untyped read/write/atomic
- * messages. We need these specifically for the fragment shader since they
- * include a pixel mask header that we need to ensure correct behavior
- * with helper invocations, which cannot write to the buffer.
- */
- brw_emit_buffer_surface_state(brw, out_offset, bo, offset,
- ISL_FORMAT_RAW,
- size, 1, RELOC_WRITE);
-}
-
-/**
* Set up a binding table entry for use by stream output logic (transform
* feedback).
*
@@ -1274,6 +1236,32 @@ const struct brw_tracked_state brw_cs_texture_surfaces = {
.emit = brw_update_cs_texture_surfaces,
};
+static void
+upload_buffer_surface(struct brw_context *brw,
+ struct gl_buffer_binding *binding,
+ uint32_t *out_offset,
+ enum isl_format format,
+ unsigned reloc_flags)
+{
+ struct gl_context *ctx = &brw->ctx;
+
+ if (binding->BufferObject == ctx->Shared->NullBufferObj) {
+ emit_null_surface_state(brw, NULL, out_offset);
+ } else {
+ ptrdiff_t size = binding->BufferObject->Size - binding->Offset;
+ if (!binding->AutomaticSize)
+ size = MIN2(size, binding->Size);
+
+ struct intel_buffer_object *iobj =
+ intel_buffer_object(binding->BufferObject);
+ struct brw_bo *bo =
+ intel_bufferobj_buffer(brw, iobj, binding->Offset, size,
+ (reloc_flags & RELOC_WRITE) != 0);
+
+ brw_emit_buffer_surface_state(brw, out_offset, bo, binding->Offset,
+ format, size, 1, reloc_flags);
+ }
+}
void
brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog,
@@ -1291,23 +1279,8 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog,
for (int i = 0; i < prog->info.num_ubos; i++) {
struct gl_buffer_binding *binding =
&ctx->UniformBufferBindings[prog->sh.UniformBlocks[i]->Binding];
-
- if (binding->BufferObject == ctx->Shared->NullBufferObj) {
- emit_null_surface_state(brw, NULL, &ubo_surf_offsets[i]);
- } else {
- struct intel_buffer_object *intel_bo =
- intel_buffer_object(binding->BufferObject);
- GLsizeiptr size = binding->BufferObject->Size - binding->Offset;
- if (!binding->AutomaticSize)
- size = MIN2(size, binding->Size);
- struct brw_bo *bo =
- intel_bufferobj_buffer(brw, intel_bo,
- binding->Offset,
- size, false);
- brw_create_constant_surface(brw, bo, binding->Offset,
- size,
- &ubo_surf_offsets[i]);
- }
+ upload_buffer_surface(brw, binding, &ubo_surf_offsets[i],
+ ISL_FORMAT_R32G32B32A32_FLOAT, 0);
}
uint32_t *ssbo_surf_offsets =
@@ -1317,22 +1290,8 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog,
struct gl_buffer_binding *binding =
&ctx->ShaderStorageBufferBindings[prog->sh.ShaderStorageBlocks[i]->Binding];
- if (binding->BufferObject == ctx->Shared->NullBufferObj) {
- emit_null_surface_state(brw, NULL, &ssbo_surf_offsets[i]);
- } else {
- struct intel_buffer_object *intel_bo =
- intel_buffer_object(binding->BufferObject);
- GLsizeiptr size = binding->BufferObject->Size - binding->Offset;
- if (!binding->AutomaticSize)
- size = MIN2(size, binding->Size);
- struct brw_bo *bo =
- intel_bufferobj_buffer(brw, intel_bo,
- binding->Offset,
- size, true);
- brw_create_buffer_surface(brw, bo, binding->Offset,
- size,
- &ssbo_surf_offsets[i]);
- }
+ upload_buffer_surface(brw, binding, &ssbo_surf_offsets[i],
+ ISL_FORMAT_RAW, RELOC_WRITE);
}
stage_state->push_constants_dirty = true;
@@ -1398,17 +1357,8 @@ brw_upload_abo_surfaces(struct brw_context *brw,
for (unsigned i = 0; i < prog->info.num_abos; i++) {
struct gl_buffer_binding *binding =
&ctx->AtomicBufferBindings[prog->sh.AtomicBuffers[i]->Binding];
- struct intel_buffer_object *intel_bo =
- intel_buffer_object(binding->BufferObject);
- struct brw_bo *bo =
- intel_bufferobj_buffer(brw, intel_bo, binding->Offset,
- intel_bo->Base.Size - binding->Offset,
- true);
-
- brw_emit_buffer_surface_state(brw, &surf_offsets[i], bo,
- binding->Offset, ISL_FORMAT_RAW,
- bo->size - binding->Offset, 1,
- RELOC_WRITE);
+ upload_buffer_surface(brw, binding, &surf_offsets[i],
+ ISL_FORMAT_RAW, RELOC_WRITE);
}
brw->ctx.NewDriverState |= BRW_NEW_SURFACES;
diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
index d89e7bde24b..89b1202dd65 100644
--- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
@@ -266,8 +266,11 @@ brw_upload_pull_constants(struct brw_context *brw,
}
}
- brw_create_constant_surface(brw, const_bo, const_offset, size,
- &stage_state->surf_offset[surf_index]);
+ brw_emit_buffer_surface_state(brw, &stage_state->surf_offset[surf_index],
+ const_bo, const_offset,
+ ISL_FORMAT_R32G32B32A32_FLOAT,
+ size, 1, 0);
+
brw_bo_unreference(const_bo);
brw->ctx.NewDriverState |= brw_new_constbuf;