0);
}
-/**
- * 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).
.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,
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 =
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;
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;