}
/**
- * Binds a buffer object to an atomic buffer binding point.
+ * Binds a buffer object to a binding point.
*
* The caller is responsible for validating the offset,
* flushing the vertices and updating NewDriverState.
*/
static void
-set_atomic_buffer_binding(struct gl_context *ctx,
- struct gl_buffer_binding *binding,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size,
- bool autoSize)
+set_buffer_binding(struct gl_context *ctx,
+ struct gl_buffer_binding *binding,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset,
+ GLsizeiptr size,
+ bool autoSize, gl_buffer_usage usage)
{
_mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
* at some point as an atomic counter buffer.
*/
if (size >= 0)
- bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER;
+ bufObj->UsageHistory |= usage;
}
-/**
- * Binds a buffer object to a uniform buffer binding point.
- *
- * The caller is responsible for flushing vertices and updating
- * NewDriverState.
- */
static void
-set_ubo_binding(struct gl_context *ctx,
- struct gl_buffer_binding *binding,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size,
- GLboolean autoSize)
+set_buffer_multi_binding(struct gl_context *ctx,
+ const GLuint *buffers,
+ int idx,
+ const char *caller,
+ struct gl_buffer_binding *binding,
+ GLintptr offset,
+ GLsizeiptr size,
+ bool range,
+ gl_buffer_usage usage)
{
- _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
-
- binding->Offset = offset;
- binding->Size = size;
- binding->AutomaticSize = autoSize;
-
- /* If this is a real buffer object, mark it has having been used
- * at some point as a UBO.
- */
- if (size >= 0)
- bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER;
-}
-
-/**
- * Binds a buffer object to a shader storage buffer binding point.
- *
- * The caller is responsible for flushing vertices and updating
- * NewDriverState.
- */
-static void
-set_ssbo_binding(struct gl_context *ctx,
- struct gl_buffer_binding *binding,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size,
- GLboolean autoSize)
-{
- _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
-
- binding->Offset = offset;
- binding->Size = size;
- binding->AutomaticSize = autoSize;
+ struct gl_buffer_object *bufObj;
+ if (binding->BufferObject && binding->BufferObject->Name == buffers[idx])
+ bufObj = binding->BufferObject;
+ else
+ bufObj = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, idx, caller);
- /* If this is a real buffer object, mark it has having been used
- * at some point as a SSBO.
- */
- if (size >= 0)
- bufObj->UsageHistory |= USAGE_SHADER_STORAGE_BUFFER;
+ if (bufObj) {
+ if (bufObj == ctx->Shared->NullBufferObj)
+ set_buffer_binding(ctx, binding, bufObj, -1, -1, !range, usage);
+ else
+ set_buffer_binding(ctx, binding, bufObj, offset, size, !range, usage);
+ }
}
/**
* Binds a buffer object to a uniform buffer binding point.
*
- * Unlike set_ubo_binding(), this function also flushes vertices
+ * Unlike set_buffer_binding(), this function also flushes vertices
* and updates NewDriverState. It also checks if the binding
* has actually changed before updating it.
*/
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
- set_ubo_binding(ctx, binding, bufObj, offset, size, autoSize);
+ set_buffer_binding(ctx, binding, bufObj, offset, size, autoSize, USAGE_UNIFORM_BUFFER);
}
/**
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
- set_ssbo_binding(ctx, binding, bufObj, offset, size, autoSize);
+ set_buffer_binding(ctx, binding, bufObj, offset, size, autoSize, USAGE_SHADER_STORAGE_BUFFER);
}
/**
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
- set_atomic_buffer_binding(ctx, binding, bufObj, offset, size, autoSize);
+ set_buffer_binding(ctx, binding, bufObj, offset, size, autoSize, USAGE_ATOMIC_COUNTER_BUFFER);
}
/**
struct gl_buffer_object *bufObj = ctx->Shared->NullBufferObj;
for (int i = 0; i < count; i++)
- set_ubo_binding(ctx, &ctx->UniformBufferBindings[first + i],
- bufObj, -1, -1, GL_TRUE);
+ set_buffer_binding(ctx, &ctx->UniformBufferBindings[first + i],
+ bufObj, -1, -1, GL_TRUE, 0);
}
/**
struct gl_buffer_object *bufObj = ctx->Shared->NullBufferObj;
for (int i = 0; i < count; i++)
- set_ssbo_binding(ctx, &ctx->ShaderStorageBufferBindings[first + i],
- bufObj, -1, -1, GL_TRUE);
+ set_buffer_binding(ctx, &ctx->ShaderStorageBufferBindings[first + i],
+ bufObj, -1, -1, GL_TRUE, 0);
}
static void
for (int i = 0; i < count; i++) {
struct gl_buffer_binding *binding =
&ctx->UniformBufferBindings[first + i];
- struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
size = sizes[i];
}
- if (binding->BufferObject && binding->BufferObject->Name == buffers[i])
- bufObj = binding->BufferObject;
- else
- bufObj = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, caller);
-
- if (bufObj) {
- if (bufObj == ctx->Shared->NullBufferObj)
- set_ubo_binding(ctx, binding, bufObj, -1, -1, !range);
- else
- set_ubo_binding(ctx, binding, bufObj, offset, size, !range);
- }
+ set_buffer_multi_binding(ctx, buffers, i, caller,
+ binding, offset, size, !range,
+ USAGE_UNIFORM_BUFFER);
}
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
for (int i = 0; i < count; i++) {
struct gl_buffer_binding *binding =
&ctx->ShaderStorageBufferBindings[first + i];
- struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
size = sizes[i];
}
- if (binding->BufferObject && binding->BufferObject->Name == buffers[i])
- bufObj = binding->BufferObject;
- else
- bufObj = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, caller);
-
- if (bufObj) {
- if (bufObj == ctx->Shared->NullBufferObj)
- set_ssbo_binding(ctx, binding, bufObj, -1, -1, !range);
- else
- set_ssbo_binding(ctx, binding, bufObj, offset, size, !range);
- }
+ set_buffer_multi_binding(ctx, buffers, i, caller,
+ binding, offset, size, !range,
+ USAGE_SHADER_STORAGE_BUFFER);
}
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
struct gl_buffer_object * const bufObj = ctx->Shared->NullBufferObj;
for (int i = 0; i < count; i++)
- set_atomic_buffer_binding(ctx, &ctx->AtomicBufferBindings[first + i],
- bufObj, -1, -1, GL_TRUE);
+ set_buffer_binding(ctx, &ctx->AtomicBufferBindings[first + i],
+ bufObj, -1, -1, GL_TRUE, 0);
}
static void
for (int i = 0; i < count; i++) {
struct gl_buffer_binding *binding =
&ctx->AtomicBufferBindings[first + i];
- struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
size = sizes[i];
}
- if (binding->BufferObject && binding->BufferObject->Name == buffers[i])
- bufObj = binding->BufferObject;
- else
- bufObj = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, caller);
-
- if (bufObj)
- if (bufObj == ctx->Shared->NullBufferObj)
- set_atomic_buffer_binding(ctx, binding, bufObj, -1, -1, !range);
- else
- set_atomic_buffer_binding(ctx, binding, bufObj, offset, size, !range);
+ set_buffer_multi_binding(ctx, buffers, i, caller,
+ binding, offset, size, !range,
+ USAGE_ATOMIC_COUNTER_BUFFER);
}
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);