[Mesa-dev] [PATCH 16/18] mesa: some C99 tidy ups
Timothy Arceri
tarceri at itsqueeze.com
Thu May 4 07:41:41 UTC 2017
---
src/mesa/main/bufferobj.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index f4597ed..44618a3 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1176,23 +1176,21 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
/* GL_ARB_copy_buffer */
driver->CopyBufferSubData = copy_buffer_sub_data_fallback;
}
void
_mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
struct gl_buffer_object *bufObj)
{
- int i;
-
- for (i = 0; i < MAP_COUNT; i++) {
+ for (int i = 0; i < MAP_COUNT; i++) {
if (_mesa_bufferobj_mapped(bufObj, i)) {
ctx->Driver.UnmapBuffer(ctx, bufObj, i);
assert(bufObj->Mappings[i].Pointer == NULL);
bufObj->Mappings[i].AccessFlags = 0;
}
}
}
/**********************************************************************/
@@ -1374,21 +1372,20 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
/**
* This is the implementation for glGenBuffers and glCreateBuffers. It is not
* exposed to the rest of Mesa to encourage the use of nameless buffers in
* driver internals.
*/
static void
create_buffers(GLsizei n, GLuint *buffers, bool dsa)
{
GET_CURRENT_CONTEXT(ctx);
GLuint first;
- GLint i;
struct gl_buffer_object *buf;
const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s(%d)\n", func, n);
if (n < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n);
return;
@@ -1402,21 +1399,21 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa)
* This must be atomic (generation and allocation of buffer object IDs)
*/
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n);
/* Insert the ID and pointer into the hash table. If non-DSA, insert a
* DummyBufferObject. Otherwise, create a new buffer object and insert
* it.
*/
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
buffers[i] = first + i;
if (dsa) {
assert(ctx->Driver.NewBufferObject);
buf = ctx->Driver.NewBufferObject(ctx, buffers[i]);
if (!buf) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
return;
}
}
@@ -3272,52 +3269,48 @@ error_check_bind_shader_storage_buffers(struct gl_context *ctx,
}
/**
* Unbind all uniform buffers in the range
* <first> through <first>+<count>-1
*/
static void
unbind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count)
{
struct gl_buffer_object *bufObj = ctx->Shared->NullBufferObj;
- GLint i;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
set_ubo_binding(ctx, &ctx->UniformBufferBindings[first + i],
bufObj, -1, -1, GL_TRUE);
}
/**
* Unbind all shader storage buffers in the range
* <first> through <first>+<count>-1
*/
static void
unbind_shader_storage_buffers(struct gl_context *ctx, GLuint first,
GLsizei count)
{
struct gl_buffer_object *bufObj = ctx->Shared->NullBufferObj;
- GLint i;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
set_ssbo_binding(ctx, &ctx->ShaderStorageBufferBindings[first + i],
bufObj, -1, -1, GL_TRUE);
}
static void
bind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count,
const GLuint *buffers,
bool range,
const GLintptr *offsets, const GLsizeiptr *sizes,
const char *caller)
{
- GLint i;
-
if (!error_check_bind_uniform_buffers(ctx, first, count, caller))
return;
/* Assume that at least one binding will be changed */
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
if (!buffers) {
/* The ARB_multi_bind spec says:
*
@@ -3345,21 +3338,21 @@ bind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count,
*
* RESOLVED: Yes. In this specification, when the parameters for
* one of the <count> binding points are invalid, that binding point
* is not updated and an error will be generated. However, other
* binding points in the same command will be updated if their
* parameters are valid and no other error occurs."
*/
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
struct gl_uniform_buffer_binding *binding =
&ctx->UniformBufferBindings[first + i];
struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
if (range) {
if (!bind_buffers_check_offset_and_size(ctx, i, offsets, sizes))
continue;
@@ -3414,22 +3407,20 @@ bind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count,
}
static void
bind_shader_storage_buffers(struct gl_context *ctx, GLuint first,
GLsizei count, const GLuint *buffers,
bool range,
const GLintptr *offsets,
const GLsizeiptr *sizes,
const char *caller)
{
- GLint i;
-
if (!error_check_bind_shader_storage_buffers(ctx, first, count, caller))
return;
/* Assume that at least one binding will be changed */
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
if (!buffers) {
/* The ARB_multi_bind spec says:
*
@@ -3457,21 +3448,21 @@ bind_shader_storage_buffers(struct gl_context *ctx, GLuint first,
*
* RESOLVED: Yes. In this specification, when the parameters for
* one of the <count> binding points are invalid, that binding point
* is not updated and an error will be generated. However, other
* binding points in the same command will be updated if their
* parameters are valid and no other error occurs."
*/
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
struct gl_shader_storage_buffer_binding *binding =
&ctx->ShaderStorageBufferBindings[first + i];
struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
if (range) {
if (!bind_buffers_check_offset_and_size(ctx, i, offsets, sizes))
continue;
@@ -3575,39 +3566,37 @@ error_check_bind_xfb_buffers(struct gl_context *ctx,
/**
* Unbind all transform feedback buffers in the range
* <first> through <first>+<count>-1
*/
static void
unbind_xfb_buffers(struct gl_context *ctx,
struct gl_transform_feedback_object *tfObj,
GLuint first, GLsizei count)
{
struct gl_buffer_object * const bufObj = ctx->Shared->NullBufferObj;
- GLint i;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
_mesa_set_transform_feedback_binding(ctx, tfObj, first + i,
bufObj, 0, 0);
}
static void
bind_xfb_buffers(struct gl_context *ctx,
GLuint first, GLsizei count,
const GLuint *buffers,
bool range,
const GLintptr *offsets,
const GLsizeiptr *sizes,
const char *caller)
{
struct gl_transform_feedback_object *tfObj =
ctx->TransformFeedback.CurrentObject;
- GLint i;
if (!error_check_bind_xfb_buffers(ctx, tfObj, first, count, caller))
return;
/* Assume that at least one binding will be changed */
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedback;
if (!buffers) {
/* The ARB_multi_bind spec says:
@@ -3636,21 +3625,21 @@ bind_xfb_buffers(struct gl_context *ctx,
*
* RESOLVED: Yes. In this specification, when the parameters for
* one of the <count> binding points are invalid, that binding point
* is not updated and an error will be generated. However, other
* binding points in the same command will be updated if their
* parameters are valid and no other error occurs."
*/
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
const GLuint index = first + i;
struct gl_buffer_object * const boundBufObj = tfObj->Buffers[index];
struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
if (range) {
offset = offsets[i];
size = sizes[i];
@@ -3739,39 +3728,36 @@ error_check_bind_atomic_buffers(struct gl_context *ctx,
}
/**
* Unbind all atomic counter buffers in the range
* <first> through <first>+<count>-1
*/
static void
unbind_atomic_buffers(struct gl_context *ctx, GLuint first, GLsizei count)
{
struct gl_buffer_object * const bufObj = ctx->Shared->NullBufferObj;
- GLint i;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
set_atomic_buffer_binding(ctx, &ctx->AtomicBufferBindings[first + i],
bufObj, -1, -1);
}
static void
bind_atomic_buffers(struct gl_context *ctx,
GLuint first,
GLsizei count,
const GLuint *buffers,
bool range,
const GLintptr *offsets,
const GLsizeiptr *sizes,
const char *caller)
{
- GLint i;
-
if (!error_check_bind_atomic_buffers(ctx, first, count, caller))
return;
/* Assume that at least one binding will be changed */
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
if (!buffers) {
/* The ARB_multi_bind spec says:
*
@@ -3799,21 +3785,21 @@ bind_atomic_buffers(struct gl_context *ctx,
*
* RESOLVED: Yes. In this specification, when the parameters for
* one of the <count> binding points are invalid, that binding point
* is not updated and an error will be generated. However, other
* binding points in the same command will be updated if their
* parameters are valid and no other error occurs."
*/
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
struct gl_atomic_buffer_binding *binding =
&ctx->AtomicBufferBindings[first + i];
struct gl_buffer_object *bufObj;
GLintptr offset = 0;
GLsizeiptr size = 0;
if (range) {
if (!bind_buffers_check_offset_and_size(ctx, i, offsets, sizes))
continue;
--
2.9.3
More information about the mesa-dev
mailing list