Cleanup: style

This commit is contained in:
Campbell Barton
2018-07-19 16:06:37 +10:00
parent 34a45c54e0
commit 9df1e54079
31 changed files with 136 additions and 126 deletions

View File

@@ -35,7 +35,7 @@
#include <stdlib.h>
#if GPU_VERT_ATTR_MAX_LEN != 16
#error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
# error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
#endif
void AttribBinding_clear(GPUAttrBinding *binding)

View File

@@ -35,9 +35,11 @@
#include "GPU_vertex_format.h"
#include "GPU_shader_interface.h"
void AttribBinding_clear(GPUAttrBinding*);
void AttribBinding_clear(GPUAttrBinding *binding);
void get_attrib_locations(const GPUVertFormat*, GPUAttrBinding*, const GPUShaderInterface*);
unsigned read_attrib_location(const GPUAttrBinding*, unsigned a_idx);
void get_attrib_locations(
const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface);
unsigned read_attrib_location(
const GPUAttrBinding *binding, unsigned a_idx);
#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */

View File

@@ -41,10 +41,10 @@ extern "C" {
#include "GPU_context.h"
#include "GPU_shader_interface.h"
void gpu_batch_remove_interface_ref(GPUBatch*, const GPUShaderInterface*);
void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface);
void gpu_context_add_batch(GPUContext*, GPUBatch*);
void gpu_context_remove_batch(GPUContext*, GPUBatch*);
void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch);
void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch);
#ifdef __cplusplus
}

View File

@@ -37,7 +37,7 @@
#define ORPHAN_DEBUG 0
#if ORPHAN_DEBUG
#include <cstdio>
# include <cstdio>
#endif
static std::vector<GLuint> orphaned_buffer_ids;

View File

@@ -701,17 +701,17 @@ void immVertex2iv(uint attrib_id, const int data[2])
/* --- generic uniform functions --- */
#if 0
#if TRUST_NO_ONE
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
#else
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name);
#endif
# if TRUST_NO_ONE
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
# else
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name);
# endif
#else
/* NOTE: It is possible to have uniform fully optimized out from the shader.
* In this case we can't assert failure or allow NULL-pointer dereference.
* TODO(sergey): How can we detect existing-but-optimized-out uniform but still
* catch typos in uniform names passed to immUniform*() functions? */
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
#endif
void immUniform1f(const char *name, float x)

View File

@@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/gpu/intern/gpu_imm_util.c
/** \file blender/gpu/intern/gpu_immediate_util.c
* \ingroup gpu
*
* GPU immediate mode drawing utilities

View File

@@ -39,7 +39,7 @@
#define DEBUG_SHADER_INTERFACE 0
#if DEBUG_SHADER_INTERFACE
#include <stdio.h>
# include <stdio.h>
#endif
static const char *BuiltinUniform_name(GPUUniformBuiltin u)

View File

@@ -23,7 +23,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/gpu/gpu_vertex_array_id.cpp
/** \file blender/gpu/intern/gpu_vertex_array_id.cpp
* \ingroup gpu
*
* Manage GL vertex array IDs in a thread-safe way
@@ -58,7 +58,7 @@ static bool thread_is_main() {
struct GPUContext {
GLuint default_vao;
std::unordered_set<GPUBatch*> batches; /* Batches that have VAOs from this context */
std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
std::vector<GLuint> orphaned_vertarray_ids;
std::mutex orphans_mutex; /* todo: try spinlock instead */
#if TRUST_NO_ONE
@@ -73,12 +73,12 @@ struct GPUContext {
#if defined(_MSC_VER) && (_MSC_VER == 1800)
#define thread_local __declspec(thread)
thread_local GPUContext* active_ctx = NULL;
thread_local GPUContext *active_ctx = NULL;
#else
static thread_local GPUContext* active_ctx = NULL;
static thread_local GPUContext *active_ctx = NULL;
#endif
static void clear_orphans(GPUContext* ctx)
static void clear_orphans(GPUContext *ctx)
{
ctx->orphans_mutex.lock();
if (!ctx->orphaned_vertarray_ids.empty()) {
@@ -89,19 +89,19 @@ static void clear_orphans(GPUContext* ctx)
ctx->orphans_mutex.unlock();
}
GPUContext* GPU_context_create(void)
GPUContext *GPU_context_create(void)
{
#if TRUST_NO_ONE
/* assert(thread_is_main()); */
#endif
GPUContext* ctx = new GPUContext;
GPUContext *ctx = new GPUContext;
glGenVertexArrays(1, &ctx->default_vao);
GPU_context_active_set(ctx);
return ctx;
}
/* to be called after GPU_context_active_set(ctx_to_destroy) */
void GPU_context_discard(GPUContext* ctx)
void GPU_context_discard(GPUContext *ctx)
{
#if TRUST_NO_ONE
/* Make sure no other thread has locked it. */
@@ -120,7 +120,7 @@ void GPU_context_discard(GPUContext* ctx)
}
/* ctx can be NULL */
void GPU_context_active_set(GPUContext* ctx)
void GPU_context_active_set(GPUContext *ctx)
{
#if TRUST_NO_ONE
if (active_ctx) {
@@ -140,7 +140,7 @@ void GPU_context_active_set(GPUContext* ctx)
active_ctx = ctx;
}
GPUContext* GPU_context_active_get(void)
GPUContext *GPU_context_active_get(void)
{
return active_ctx;
}
@@ -168,7 +168,7 @@ GLuint GPU_vao_alloc(void)
}
/* this can be called from multiple thread */
void GPU_vao_free(GLuint vao_id, GPUContext* ctx)
void GPU_vao_free(GLuint vao_id, GPUContext *ctx)
{
#if TRUST_NO_ONE
assert(ctx);
@@ -183,12 +183,12 @@ void GPU_vao_free(GLuint vao_id, GPUContext* ctx)
}
}
void gpu_context_add_batch(GPUContext* ctx, GPUBatch* batch)
void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch)
{
ctx->batches.emplace(batch);
}
void gpu_context_remove_batch(GPUContext* ctx, GPUBatch* batch)
void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch)
{
ctx->orphans_mutex.lock();
ctx->batches.erase(batch);

View File

@@ -37,7 +37,7 @@
#define PACK_DEBUG 0
#if PACK_DEBUG
#include <stdio.h>
# include <stdio.h>
#endif
void GPU_vertformat_clear(GPUVertFormat *format)

View File

@@ -32,8 +32,8 @@
#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__
#define __GPU_VERTEX_FORMAT_PRIVATE_H__
void VertexFormat_pack(GPUVertFormat*);
void VertexFormat_pack(GPUVertFormat *format);
uint padding(uint offset, uint alignment);
uint vertex_buffer_size(const GPUVertFormat*, uint vertex_len);
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len);
#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */