Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-28 23:46:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-29 00:32:25 +0300
commit68cab3aff63aea95830aa082a160200768d0e826 (patch)
tree3a042217ce34d84387cdfcca97316597800396db /source/blender/gpu
parenta9c297165878b3c427a20f787cc90a6ada4df253 (diff)
Cleanup: replace attrib w/ attr
Also rename GPUVertexAttribs to GPUVertAttrLayers, avoids confusion with GPUVertAttr which isn't closely related.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_attr_binding.h6
-rw-r--r--source/blender/gpu/GPU_batch.h19
-rw-r--r--source/blender/gpu/GPU_draw.h8
-rw-r--r--source/blender/gpu/GPU_immediate.h19
-rw-r--r--source/blender/gpu/GPU_material.h8
-rw-r--r--source/blender/gpu/GPU_shader.h10
-rw-r--r--source/blender/gpu/GPU_shader_interface.h11
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h8
-rw-r--r--source/blender/gpu/GPU_vertex_format.h14
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding.c20
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding_private.h6
-rw-r--r--source/blender/gpu/intern/gpu_batch.c4
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c174
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h30
-rw-r--r--source/blender/gpu/intern/gpu_draw.c126
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c10
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c180
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c2
-rw-r--r--source/blender/gpu/intern/gpu_material.c12
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c4
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.c4
-rw-r--r--source/blender/gpu/intern/gpu_shader.c4
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c14
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.h19
-rw-r--r--source/blender/gpu/intern/gpu_texture.c2
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c8
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c92
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl2
38 files changed, 441 insertions, 413 deletions
diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h
index 186acacb71d..0364e8cf3cf 100644
--- a/source/blender/gpu/GPU_attr_binding.h
+++ b/source/blender/gpu/GPU_attr_binding.h
@@ -35,8 +35,10 @@
#include "GPU_common.h"
typedef struct GPUAttrBinding {
- uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */
- uint16_t enabled_bits; /* 1 bit for each attrib */
+ /** Store 4 bits for each of the 16 attributes. */
+ uint64_t loc_bits;
+ /** 1 bit for each attribute. */
+ uint16_t enabled_bits;
} GPUAttrBinding;
#endif /* __GPU_ATTR_BINDING_H__ */
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 0ef7e57a026..73930cd8e9d 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -51,9 +51,13 @@ typedef enum {
typedef struct GPUBatch {
/* geometry */
- GPUVertBuf *verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */
- GPUVertBuf *inst; /* instance attribs */
- GPUIndexBuf *elem; /* NULL if element list not needed */
+
+ /** verts[0] is required, others can be NULL */
+ GPUVertBuf *verts[GPU_BATCH_VBO_MAX_LEN];
+ /** Instance attributes. */
+ GPUVertBuf *inst;
+ /** NULL if element list not needed */
+ GPUIndexBuf *elem;
uint32_t gl_prim_type;
/* cached values (avoid dereferencing later) */
@@ -63,21 +67,22 @@ typedef struct GPUBatch {
/* book-keeping */
uint owns_flag;
- struct GPUContext *context; /* used to free all vaos. this implies all vaos were created under the same context. */
+ /** used to free all vaos. this implies all vaos were created under the same context. */
+ struct GPUContext *context;
GPUBatchPhase phase;
bool program_in_use;
- /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer)
+ /* Vao management: remembers all geometry state (vertex attribute bindings & element buffer)
* for each shader interface. Start with a static number of vaos and fallback to dynamic count
* if necessary. Once a batch goes dynamic it does not go back. */
bool is_dynamic_vao_count;
union {
- /* Static handle count */
+ /** Static handle count */
struct {
const struct GPUShaderInterface *interfaces[GPU_BATCH_VAO_STATIC_LEN];
uint32_t vao_ids[GPU_BATCH_VAO_STATIC_LEN];
} static_vaos;
- /* Dynamic handle count */
+ /** Dynamic handle count */
struct {
uint count;
const struct GPUShaderInterface **interfaces;
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 17fbebdcfc9..dc5f55ccf17 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -112,16 +112,16 @@ void GPU_select_index_get(int index, int *r_col);
int GPU_select_to_index(unsigned int col);
void GPU_select_to_index_array(unsigned int *col, const unsigned int size);
-typedef enum eGPUAttribMask {
+typedef enum eGPUAttrMask {
GPU_DEPTH_BUFFER_BIT = (1 << 0),
GPU_ENABLE_BIT = (1 << 1),
GPU_SCISSOR_BIT = (1 << 2),
GPU_VIEWPORT_BIT = (1 << 3),
GPU_BLEND_BIT = (1 << 4),
-} eGPUAttribMask;
+} eGPUAttrMask;
-void gpuPushAttrib(eGPUAttribMask mask);
-void gpuPopAttrib(void);
+void gpuPushAttr(eGPUAttrMask mask);
+void gpuPopAttr(void);
#ifdef __cplusplus
}
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index a04be7a03ae..90d97501e15 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -40,13 +40,18 @@
#include "GPU_immediate_util.h"
#include "GPU_shader.h"
-GPUVertFormat *immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */
-
-void immBindProgram(uint32_t program, const GPUShaderInterface *); /* every immBegin must have a program bound first. */
-void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */
-
-void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */
-void immBeginAtMost(GPUPrimType, uint max_vertex_len); /* can supply fewer vertices. */
+/** Returns a cleared vertex format, ready for #add_attr. */
+GPUVertFormat *immVertexFormat(void);
+
+/** Every immBegin must have a program bound first. */
+void immBindProgram(uint32_t program, const GPUShaderInterface *);
+/** Call after your last immEnd, or before binding another program. */
+void immUnbindProgram(void);
+
+/** Must supply exactly vertex_len vertices. */
+void immBegin(GPUPrimType, uint vertex_len);
+/** Can supply fewer vertices. */
+void immBeginAtMost(GPUPrimType, uint max_vertex_len);
void immEnd(void); /* finishes and draws. */
/* ImmBegin a batch, then use standard immFunctions as usual. */
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 58dec24bea8..db88e659ea1 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -47,7 +47,7 @@ struct GPUNodeLink;
struct GPUNodeStack;
struct GPUTexture;
struct GPUUniformBuffer;
-struct GPUVertexAttribs;
+struct GPUVertAttrLayers;
struct Image;
struct ImageUser;
struct ListBase;
@@ -90,7 +90,7 @@ typedef enum eGPUType {
GPU_CLOSURE = 1006,
/* Opengl Attributes */
- GPU_ATTRIB = 3001,
+ GPU_ATTR = 3001,
} eGPUType;
typedef enum eGPUBuiltin {
@@ -189,9 +189,9 @@ struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material);
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void);
-void GPU_material_vertex_attributes(
+void GPU_material_vertex_attrs(
GPUMaterial *material,
- struct GPUVertexAttribs *attrib);
+ struct GPUVertAttrLayers *attrs);
bool GPU_material_do_color_management(GPUMaterial *mat);
bool GPU_material_use_domain_surface(GPUMaterial *mat);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 0004642ea5b..093f1178672 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -383,20 +383,20 @@ void GPU_shader_free_builtin_shaders(void);
/* Vertex attributes for shaders */
-#define GPU_MAX_ATTRIB 32
+#define GPU_MAX_ATTR 32
-typedef struct GPUVertexAttribs {
+typedef struct GPUVertAttrLayers {
struct {
int type;
int glindex;
int glinfoindoex;
int gltexco;
- int attribid;
+ int attr_id;
char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
- } layer[GPU_MAX_ATTRIB];
+ } layer[GPU_MAX_ATTR];
int totlayer;
-} GPUVertexAttribs;
+} GPUVertAttrLayers;
#ifdef __cplusplus
}
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 0559a72e52c..8d94c07a019 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -69,9 +69,12 @@ typedef struct GPUShaderInput {
struct GPUShaderInput *next;
uint32_t name_offset;
uint name_hash;
- GPUUniformBuiltin builtin_type; /* only for uniform inputs */
- uint32_t gl_type; /* only for attrib inputs */
- int32_t size; /* only for attrib inputs */
+ /** Only for uniform inputs. */
+ GPUUniformBuiltin builtin_type;
+ /** Only for attribute inputs. */
+ uint32_t gl_type;
+ /** Only for attribute inputs. */
+ int32_t size;
int32_t location;
} GPUShaderInput;
@@ -81,7 +84,7 @@ typedef struct GPUShaderInput {
typedef struct GPUShaderInterface {
int32_t program;
uint32_t name_buffer_offset;
- GPUShaderInput *attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
+ GPUShaderInput *attr_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
GPUShaderInput *uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
GPUShaderInput *ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS];
GPUShaderInput *builtin_uniforms[GPU_NUM_UNIFORMS];
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index cc508de2f00..721a455a6e2 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -79,10 +79,10 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len);
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len);
void GPU_vertbuf_data_len_set(GPUVertBuf *, uint v_len);
-/* The most important set_attrib variant is the untyped one. Get it right first. */
-/* It takes a void* so the app developer is responsible for matching their app data types */
-/* to the vertex attribute's type and component count. They're in control of both, so this */
-/* should not be a problem. */
+/* The most important #set_attr variant is the untyped one. Get it right first.
+ * It takes a void* so the app developer is responsible for matching their app data types
+ * to the vertex attribute's type and component count. They're in control of both, so this
+ * should not be a problem. */
void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data);
void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data); /* tightly packed, non interleaved input data */
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 7a271caf079..ed8feb1587c 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -71,13 +71,17 @@ typedef struct GPUVertAttr {
} GPUVertAttr;
typedef struct GPUVertFormat {
- uint attr_len; /* 0 to 16 (GPU_VERT_ATTR_MAX_LEN) */
- uint name_len; /* total count of active vertex attrib */
- uint stride; /* stride in bytes, 1 to 256 */
+ /** 0 to 16 (GPU_VERT_ATTR_MAX_LEN). */
+ uint attr_len;
+ /** Total count of active vertex attribute. */
+ uint name_len;
+ /** Stride in bytes, 1 to 256. */
+ uint stride;
uint name_offset;
bool packed;
char names[GPU_VERT_ATTR_NAMES_BUF_LEN];
- GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */
+ /** TODO: variable-size array */
+ GPUVertAttr attrs[GPU_VERT_ATTR_MAX_LEN];
} GPUVertFormat;
struct GPUShaderInterface;
@@ -93,7 +97,7 @@ void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias);
int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name);
/**
- * This makes the "virtual" attribs with suffixes "0", "1", "2" to access triangle data in the vertex
+ * This makes the "virtual" attributes with suffixes "0", "1", "2" to access triangle data in the vertex
* shader.
*
* IMPORTANT:
diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c
index 398b97c7f9d..2cf6516cd1b 100644
--- a/source/blender/gpu/intern/gpu_attr_binding.c
+++ b/source/blender/gpu/intern/gpu_attr_binding.c
@@ -35,16 +35,16 @@
#include <stdlib.h>
#if GPU_VERT_ATTR_MAX_LEN != 16
-# error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
+# error "attribute binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
#endif
-void AttribBinding_clear(GPUAttrBinding *binding)
+void AttrBinding_clear(GPUAttrBinding *binding)
{
binding->loc_bits = 0;
binding->enabled_bits = 0;
}
-uint read_attrib_location(const GPUAttrBinding *binding, uint a_idx)
+uint read_attr_location(const GPUAttrBinding *binding, uint a_idx)
{
#if TRUST_NO_ONE
assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
@@ -53,7 +53,7 @@ uint read_attrib_location(const GPUAttrBinding *binding, uint a_idx)
return (binding->loc_bits >> (4 * a_idx)) & 0xF;
}
-static void write_attrib_location(GPUAttrBinding *binding, uint a_idx, uint location)
+static void write_attr_location(GPUAttrBinding *binding, uint a_idx, uint location)
{
#if TRUST_NO_ONE
assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
@@ -61,25 +61,25 @@ static void write_attrib_location(GPUAttrBinding *binding, uint a_idx, uint loca
#endif
const uint shift = 4 * a_idx;
const uint64_t mask = ((uint64_t)0xF) << shift;
- /* overwrite this attrib's previous location */
+ /* overwrite this attr's previous location */
binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift);
- /* mark this attrib as enabled */
+ /* mark this attr as enabled */
binding->enabled_bits |= 1 << a_idx;
}
-void get_attrib_locations(const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface)
+void get_attr_locations(const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface)
{
- AttribBinding_clear(binding);
+ AttrBinding_clear(binding);
for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) {
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
const GPUShaderInput *input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]);
#if TRUST_NO_ONE
assert(input != NULL);
/* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */
#endif
- write_attrib_location(binding, a_idx, input->location);
+ write_attr_location(binding, a_idx, input->location);
}
}
}
diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h
index c545983637c..a42e80b537e 100644
--- a/source/blender/gpu/intern/gpu_attr_binding_private.h
+++ b/source/blender/gpu/intern/gpu_attr_binding_private.h
@@ -35,11 +35,11 @@
#include "GPU_vertex_format.h"
#include "GPU_shader_interface.h"
-void AttribBinding_clear(GPUAttrBinding *binding);
+void AttrBinding_clear(GPUAttrBinding *binding);
-void get_attrib_locations(
+void get_attr_locations(
const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface);
-uint read_attrib_location(
+uint read_attr_location(
const GPUAttrBinding *binding, uint a_idx);
#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 8bd93b5254d..eaa618298f1 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -197,7 +197,7 @@ int GPU_batch_vertbuf_add_ex(
assert(verts->vertex_len == batch->verts[0]->vertex_len);
#endif
batch->verts[v] = verts;
- /* TODO: mark dirty so we can keep attrib bindings up-to-date */
+ /* TODO: mark dirty so we can keep attribute bindings up-to-date */
if (own_vbo)
batch->owns_flag |= (1 << v);
return v;
@@ -351,7 +351,7 @@ static void create_bindings(
GPU_vertbuf_use(verts);
for (uint a_idx = 0; a_idx < attr_len; ++a_idx) {
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
const GLvoid *pointer = (const GLubyte *)0 + a->offset + v_first * stride;
for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 78dc0ce37ff..c216069bc95 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -78,14 +78,14 @@ static char *glsl_material_library = NULL;
static GPUPass *pass_cache = NULL;
static SpinLock pass_cache_spin;
-static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertexAttribs *attribs)
+static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertAttrLayers *attrs)
{
BLI_HashMurmur2A hm2a;
BLI_hash_mm2a_init(&hm2a, 0);
BLI_hash_mm2a_add(&hm2a, (uchar *)frag_gen, strlen(frag_gen));
- if (attribs) {
- for (int att_idx = 0; att_idx < attribs->totlayer; att_idx++) {
- char *name = attribs->layer[att_idx].name;
+ if (attrs) {
+ for (int att_idx = 0; att_idx < attrs->totlayer; att_idx++) {
+ char *name = attrs->layer[att_idx].name;
BLI_hash_mm2a_add(&hm2a, (uchar *)name, strlen(name));
}
}
@@ -636,10 +636,10 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds,
codegen_print_datatype(ds, input->type, input->vec);
BLI_dynstr_append(ds, ";\n");
}
- else if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ else if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
BLI_dynstr_appendf(
ds, "in %s var%d;\n",
- GPU_DATATYPE_STR[input->type], input->attribid);
+ GPU_DATATYPE_STR[input->type], input->attr_id);
}
}
}
@@ -743,8 +743,8 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
else if (input->source == GPU_SOURCE_CONSTANT) {
BLI_dynstr_appendf(ds, "cons%d", input->id);
}
- else if (input->source == GPU_SOURCE_ATTRIB) {
- BLI_dynstr_appendf(ds, "var%d", input->attribid);
+ else if (input->source == GPU_SOURCE_ATTR) {
+ BLI_dynstr_appendf(ds, "var%d", input->attr_id);
}
BLI_dynstr_append(ds, ", ");
@@ -841,7 +841,7 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
return code;
}
-static const char *attrib_prefix_get(CustomDataType type)
+static const char *attr_prefix_get(CustomDataType type)
{
switch (type) {
case CD_ORCO: return "orco";
@@ -861,13 +861,13 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
char *code;
int builtins = 0;
- /* Hairs uv and col attribs are passed by bufferTextures. */
+ /* Hairs uv and col attributes are passed by bufferTextures. */
BLI_dynstr_append(
ds,
"#ifdef HAIR_SHADER\n"
- "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n"
+ "#define DEFINE_ATTR(type, attr) uniform samplerBuffer attr\n"
"#else\n"
- "#define DEFINE_ATTRIB(type, attr) in type attr\n"
+ "#define DEFINE_ATTR(type, attr) in type attr\n"
"#endif\n"
);
@@ -876,35 +876,35 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
if (input->source == GPU_SOURCE_BUILTIN) {
builtins |= input->builtin;
}
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
/* XXX FIXME : see notes in mesh_render_data_create() */
/* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
- if (input->attribtype == CD_ORCO) {
+ if (input->attr_type == CD_ORCO) {
/* orco is computed from local positions, see below */
BLI_dynstr_appendf(ds, "uniform vec3 OrcoTexCoFactors[2];\n");
}
- else if (input->attribname[0] == '\0') {
- BLI_dynstr_appendf(ds, "DEFINE_ATTRIB(%s, %s);\n", GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype));
- BLI_dynstr_appendf(ds, "#define att%d %s\n", input->attribid, attrib_prefix_get(input->attribtype));
+ else if (input->attr_name[0] == '\0') {
+ BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s);\n", GPU_DATATYPE_STR[input->type], attr_prefix_get(input->attr_type));
+ BLI_dynstr_appendf(ds, "#define att%d %s\n", input->attr_id, attr_prefix_get(input->attr_type));
}
else {
- uint hash = BLI_ghashutil_strhash_p(input->attribname);
+ uint hash = BLI_ghashutil_strhash_p(input->attr_name);
BLI_dynstr_appendf(
- ds, "DEFINE_ATTRIB(%s, %s%u);\n",
- GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash);
+ ds, "DEFINE_ATTR(%s, %s%u);\n",
+ GPU_DATATYPE_STR[input->type], attr_prefix_get(input->attr_type), hash);
BLI_dynstr_appendf(
ds, "#define att%d %s%u\n",
- input->attribid, attrib_prefix_get(input->attribtype), hash);
- /* Auto attrib can be vertex color byte buffer.
+ input->attr_id, attr_prefix_get(input->attr_type), hash);
+ /* Auto attribute can be vertex color byte buffer.
* We need to know and convert them to linear space in VS. */
- if (!use_geom && input->attribtype == CD_AUTO_FROM_NAME) {
+ if (!use_geom && input->attr_type == CD_AUTO_FROM_NAME) {
BLI_dynstr_appendf(ds, "uniform bool ba%u;\n", hash);
- BLI_dynstr_appendf(ds, "#define att%d_is_srgb ba%u\n", input->attribid, hash);
+ BLI_dynstr_appendf(ds, "#define att%d_is_srgb ba%u\n", input->attr_id, hash);
}
}
BLI_dynstr_appendf(
ds, "out %s var%d%s;\n",
- GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : "");
+ GPU_DATATYPE_STR[input->type], input->attr_id, use_geom ? "g" : "");
}
}
}
@@ -924,11 +924,11 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_append(
ds,
- "#define ATTRIB\n"
+ "#define USE_ATTR\n"
"uniform mat3 NormalMatrix;\n"
"uniform mat4 ModelMatrixInverse;\n"
"uniform mat4 ModelMatrix;\n"
- "vec3 srgb_to_linear_attrib(vec3 c) {\n"
+ "vec3 srgb_to_linear_attr(vec3 c) {\n"
"\tc = max(c, vec3(0.0));\n"
"\tvec3 c1 = c * (1.0 / 12.92);\n"
"\tvec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));\n"
@@ -947,7 +947,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
"\n"
);
- BLI_dynstr_append(ds, "void pass_attrib(in vec3 position) {\n");
+ BLI_dynstr_append(ds, "void pass_attr(in vec3 position) {\n");
BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
@@ -971,22 +971,22 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- if (input->attribtype == CD_TANGENT) {
+ if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
+ if (input->attr_type == CD_TANGENT) {
/* Not supported by hairs */
BLI_dynstr_appendf(
ds, "\tvar%d%s = vec4(0.0);\n",
- input->attribid, use_geom ? "g" : "");
+ input->attr_id, use_geom ? "g" : "");
}
- else if (input->attribtype == CD_ORCO) {
+ else if (input->attr_type == CD_ORCO) {
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
- input->attribid, use_geom ? "g" : "");
+ input->attr_id, use_geom ? "g" : "");
}
else {
BLI_dynstr_appendf(
ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n",
- input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid);
+ input->attr_id, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attr_id);
}
}
}
@@ -1009,35 +1009,35 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- if (input->attribtype == CD_TANGENT) { /* silly exception */
+ if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
+ if (input->attr_type == CD_TANGENT) { /* silly exception */
BLI_dynstr_appendf(
ds, "\tvar%d%s.xyz = normalize(NormalMatrix * att%d.xyz);\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ input->attr_id, use_geom ? "g" : "", input->attr_id);
BLI_dynstr_appendf(
ds, "\tvar%d%s.w = att%d.w;\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ input->attr_id, use_geom ? "g" : "", input->attr_id);
}
- else if (input->attribtype == CD_ORCO) {
+ else if (input->attr_type == CD_ORCO) {
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
- input->attribid, use_geom ? "g" : "");
+ input->attr_id, use_geom ? "g" : "");
}
- else if (input->attribtype == CD_MCOL) {
+ else if (input->attr_type == CD_MCOL) {
BLI_dynstr_appendf(
- ds, "\tvar%d%s = srgb_to_linear_attrib(att%d);\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ ds, "\tvar%d%s = srgb_to_linear_attr(att%d);\n",
+ input->attr_id, use_geom ? "g" : "", input->attr_id);
}
- else if (input->attribtype == CD_AUTO_FROM_NAME) {
+ else if (input->attr_type == CD_AUTO_FROM_NAME) {
BLI_dynstr_appendf(
- ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attrib(att%d) : att%d;\n",
- input->attribid, use_geom ? "g" : "",
- input->attribid, input->attribid, input->attribid);
+ ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attr(att%d) : att%d;\n",
+ input->attr_id, use_geom ? "g" : "",
+ input->attr_id, input->attr_id, input->attr_id);
}
else {
BLI_dynstr_appendf(
ds, "\tvar%d%s = att%d;\n",
- input->attribid, use_geom ? "g" : "", input->attribid);
+ input->attr_id, use_geom ? "g" : "", input->attr_id);
}
}
}
@@ -1088,9 +1088,9 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
int builtins = 0;
/* Create prototype because attributes cannot be declared before layout. */
- BLI_dynstr_appendf(ds, "void pass_attrib(in int vert);\n");
+ BLI_dynstr_appendf(ds, "void pass_attr(in int vert);\n");
BLI_dynstr_appendf(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2);\n");
- BLI_dynstr_append(ds, "#define ATTRIB\n");
+ BLI_dynstr_append(ds, "#define USE_ATTR\n");
/* Generate varying declarations. */
for (node = nodes->first; node; node = node->next) {
@@ -1098,15 +1098,15 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
if (input->source == GPU_SOURCE_BUILTIN) {
builtins |= input->builtin;
}
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
BLI_dynstr_appendf(
ds, "in %s var%dg[];\n",
GPU_DATATYPE_STR[input->type],
- input->attribid);
+ input->attr_id);
BLI_dynstr_appendf(
ds, "out %s var%d;\n",
GPU_DATATYPE_STR[input->type],
- input->attribid);
+ input->attr_id);
}
}
}
@@ -1150,15 +1150,15 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
}
BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[0].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attrib(0);\n");
+ BLI_dynstr_appendf(ds, "\tpass_attr(0);\n");
BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[1].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attrib(1);\n");
+ BLI_dynstr_appendf(ds, "\tpass_attr(1);\n");
BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[2].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attrib(2);\n");
+ BLI_dynstr_appendf(ds, "\tpass_attr(2);\n");
BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
BLI_dynstr_appendf(ds, "};\n");
}
@@ -1186,7 +1186,7 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
}
/* Generate varying assignments. */
- BLI_dynstr_appendf(ds, "void pass_attrib(in int vert) {\n");
+ BLI_dynstr_appendf(ds, "void pass_attr(in int vert) {\n");
/* XXX HACK: Eevee specific. */
if (geom_code == NULL) {
@@ -1202,9 +1202,9 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- /* TODO let shader choose what to do depending on what the attrib is. */
- BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", input->attribid, input->attribid);
+ if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
+ /* TODO let shader choose what to do depending on what the attribute is. */
+ BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", input->attr_id, input->attr_id);
}
}
}
@@ -1262,7 +1262,7 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
/* attributes don't need to be bound, they already have
* an id that the drawing functions will use. Builtins have
* constant names. */
- if (ELEM(input->source, GPU_SOURCE_ATTRIB, GPU_SOURCE_BUILTIN)) {
+ if (ELEM(input->source, GPU_SOURCE_ATTR, GPU_SOURCE_BUILTIN)) {
continue;
}
@@ -1367,10 +1367,10 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
input->iuser = link->iuser;
input->image_isdata = link->image_isdata;
break;
- case GPU_NODE_LINK_ATTRIB:
- input->source = GPU_SOURCE_ATTRIB;
- input->attribtype = link->attribtype;
- BLI_strncpy(input->attribname, link->attribname, sizeof(input->attribname));
+ case GPU_NODE_LINK_ATTR:
+ input->source = GPU_SOURCE_ATTR;
+ input->attr_type = link->attr_type;
+ BLI_strncpy(input->attr_name, link->attr_name, sizeof(input->attr_name));
break;
case GPU_NODE_LINK_CONSTANT:
input->source = (type == GPU_CLOSURE) ? GPU_SOURCE_STRUCT : GPU_SOURCE_CONSTANT;
@@ -1533,7 +1533,7 @@ static void gpu_nodes_free(ListBase *nodes)
/* vertex attributes */
-void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs)
+void GPU_nodes_get_vertex_attrs(ListBase *nodes, GPUVertAttrLayers *attrs)
{
GPUNode *node;
GPUInput *input;
@@ -1542,32 +1542,32 @@ void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs)
/* convert attributes requested by node inputs to an array of layers,
* checking for duplicates and assigning id's starting from zero. */
- memset(attribs, 0, sizeof(*attribs));
+ memset(attrs, 0, sizeof(*attrs));
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB) {
- for (a = 0; a < attribs->totlayer; a++) {
- if (attribs->layer[a].type == input->attribtype &&
- STREQ(attribs->layer[a].name, input->attribname))
+ if (input->source == GPU_SOURCE_ATTR) {
+ for (a = 0; a < attrs->totlayer; a++) {
+ if (attrs->layer[a].type == input->attr_type &&
+ STREQ(attrs->layer[a].name, input->attr_name))
{
break;
}
}
- if (a < GPU_MAX_ATTRIB) {
- if (a == attribs->totlayer) {
- input->attribid = attribs->totlayer++;
- input->attribfirst = true;
+ if (a < GPU_MAX_ATTR) {
+ if (a == attrs->totlayer) {
+ input->attr_id = attrs->totlayer++;
+ input->attr_first = true;
- attribs->layer[a].type = input->attribtype;
- attribs->layer[a].attribid = input->attribid;
+ attrs->layer[a].type = input->attr_type;
+ attrs->layer[a].attr_id = input->attr_id;
BLI_strncpy(
- attribs->layer[a].name, input->attribname,
- sizeof(attribs->layer[a].name));
+ attrs->layer[a].name, input->attr_name,
+ sizeof(attrs->layer[a].name));
}
else {
- input->attribid = attribs->layer[a].attribid;
+ input->attr_id = attrs->layer[a].attr_id;
}
}
}
@@ -1580,14 +1580,14 @@ void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs)
GPUNodeLink *GPU_attribute(const CustomDataType type, const char *name)
{
GPUNodeLink *link = GPU_node_link_create();
- link->link_type = GPU_NODE_LINK_ATTRIB;
- link->attribname = name;
+ link->link_type = GPU_NODE_LINK_ATTR;
+ link->attr_name = name;
/* Fall back to the UV layer, which matches old behavior. */
if (type == CD_AUTO_FROM_NAME && name[0] == '\0') {
- link->attribtype = CD_MTFACE;
+ link->attr_type = CD_MTFACE;
}
else {
- link->attribtype = type;
+ link->attr_type = type;
}
return link;
}
@@ -1787,7 +1787,7 @@ static bool gpu_pass_is_valid(GPUPass *pass)
GPUPass *GPU_generate_pass(
GPUMaterial *material,
GPUNodeLink *frag_outlink,
- struct GPUVertexAttribs *attribs,
+ struct GPUVertAttrLayers *attrs,
ListBase *nodes,
int *builtins,
const char *vert_code,
@@ -1801,13 +1801,13 @@ GPUPass *GPU_generate_pass(
/* prune unused nodes */
GPU_nodes_prune(nodes, frag_outlink);
- GPU_nodes_get_vertex_attributes(nodes, attribs);
+ GPU_nodes_get_vertex_attrs(nodes, attrs);
/* generate code */
char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output, builtins);
/* Cache lookup: Reuse shaders already compiled */
- uint32_t hash = gpu_pass_hash(fragmentgen, defines, attribs);
+ uint32_t hash = gpu_pass_hash(fragmentgen, defines, attrs);
pass_hash = gpu_pass_cache_lookup(hash);
if (pass_hash && (pass_hash->next == NULL || pass_hash->next->hash != hash)) {
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 2325fb564ab..9c306cbd855 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -41,7 +41,7 @@
struct GPUNode;
struct GPUOutput;
struct GPUShader;
-struct GPUVertexAttribs;
+struct GPUVertAttrLayers;
struct ListBase;
struct PreviewImage;
@@ -55,7 +55,7 @@ typedef enum eGPUDataSource {
GPU_SOURCE_OUTPUT,
GPU_SOURCE_CONSTANT,
GPU_SOURCE_UNIFORM,
- GPU_SOURCE_ATTRIB,
+ GPU_SOURCE_ATTR,
GPU_SOURCE_BUILTIN,
GPU_SOURCE_STRUCT,
GPU_SOURCE_TEX,
@@ -63,7 +63,7 @@ typedef enum eGPUDataSource {
typedef enum {
GPU_NODE_LINK_NONE = 0,
- GPU_NODE_LINK_ATTRIB,
+ GPU_NODE_LINK_ATTR,
GPU_NODE_LINK_BUILTIN,
GPU_NODE_LINK_COLORBAND,
GPU_NODE_LINK_CONSTANT,
@@ -99,10 +99,10 @@ struct GPUNodeLink {
struct GPUTexture **coba;
/* GPU_NODE_LINK_OUTPUT */
struct GPUOutput *output;
- /* GPU_NODE_LINK_ATTRIB */
+ /* GPU_NODE_LINK_ATTR */
struct {
- const char *attribname;
- CustomDataType attribtype;
+ const char *attr_name;
+ CustomDataType attr_type;
};
/* GPU_NODE_LINK_IMAGE_BLENDER */
struct {
@@ -151,12 +151,16 @@ typedef struct GPUInput {
int texid; /* number for multitexture, starting from zero */
eGPUType textype; /* texture type (2D, 1D Array ...) */
};
- /* GPU_SOURCE_ATTRIB */
+ /* GPU_SOURCE_ATTR */
struct {
- char attribname[MAX_CUSTOMDATA_LAYER_NAME]; /* attribute name */
- int attribid; /* id for vertex attributes */
- bool attribfirst; /* this is the first one that is bound */
- CustomDataType attribtype; /* attribute type */
+ /** Attribute name. */
+ char attr_name[MAX_CUSTOMDATA_LAYER_NAME];
+ /** ID for vertex attributes. */
+ int attr_id;
+ /** This is the first one that is bound. */
+ bool attr_first;
+ /** Attribute type. */
+ CustomDataType attr_type;
};
};
} GPUInput;
@@ -178,7 +182,7 @@ typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass(
GPUMaterial *material,
- GPUNodeLink *frag_outlink, struct GPUVertexAttribs *attribs,
+ GPUNodeLink *frag_outlink, struct GPUVertAttrLayers *attrs,
ListBase *nodes, int *builtins,
const char *vert_code, const char *geom_code,
const char *frag_lib, const char *defines);
@@ -186,7 +190,7 @@ GPUPass *GPU_generate_pass(
struct GPUShader *GPU_pass_shader_get(GPUPass *pass);
void GPU_nodes_extract_dynamic_inputs(struct GPUShader *shader, ListBase *inputs, ListBase *nodes);
-void GPU_nodes_get_vertex_attributes(ListBase *nodes, struct GPUVertexAttribs *attribs);
+void GPU_nodes_get_vertex_attrs(ListBase *nodes, struct GPUVertAttrLayers *attrs);
void GPU_nodes_prune(ListBase *nodes, struct GPUNodeLink *outlink);
void GPU_pass_compile(GPUPass *pass, const char *shname);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 0937b6078fe..4cbcaf51802 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -1423,7 +1423,7 @@ void GPU_select_to_index_array(uint *col, const uint size)
#define STATE_STACK_DEPTH 16
typedef struct {
- eGPUAttribMask mask;
+ eGPUAttrMask mask;
/* GL_ENABLE_BIT */
uint is_blend : 1;
@@ -1456,19 +1456,19 @@ typedef struct {
/* GL_VIEWPORT_BIT */
int viewport[4];
double near_far[2];
-} GPUAttribValues;
+} GPUAttrValues;
typedef struct {
- GPUAttribValues attrib_stack[STATE_STACK_DEPTH];
+ GPUAttrValues attr_stack[STATE_STACK_DEPTH];
uint top;
-} GPUAttribStack;
+} GPUAttrStack;
-static GPUAttribStack state = {
+static GPUAttrStack state = {
.top = 0,
};
-#define AttribStack state
-#define Attrib state.attrib_stack[state.top]
+#define AttrStack state
+#define Attr state.attr_stack[state.top]
/**
* Replacement for glPush/PopAttributes
@@ -1476,54 +1476,54 @@ static GPUAttribStack state = {
* We don't need to cover all the options of legacy OpenGL
* but simply the ones used by Blender.
*/
-void gpuPushAttrib(eGPUAttribMask mask)
+void gpuPushAttr(eGPUAttrMask mask)
{
- Attrib.mask = mask;
+ Attr.mask = mask;
if ((mask & GPU_DEPTH_BUFFER_BIT) != 0) {
- Attrib.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
- glGetIntegerv(GL_DEPTH_FUNC, &Attrib.depth_func);
- glGetDoublev(GL_DEPTH_CLEAR_VALUE, &Attrib.depth_clear_value);
- glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&Attrib.depth_write_mask);
+ Attr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
+ glGetIntegerv(GL_DEPTH_FUNC, &Attr.depth_func);
+ glGetDoublev(GL_DEPTH_CLEAR_VALUE, &Attr.depth_clear_value);
+ glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&Attr.depth_write_mask);
}
if ((mask & GPU_ENABLE_BIT) != 0) {
- Attrib.is_blend = glIsEnabled(GL_BLEND);
+ Attr.is_blend = glIsEnabled(GL_BLEND);
for (int i = 0; i < 6; i++) {
- Attrib.is_clip_plane[i] = glIsEnabled(GL_CLIP_PLANE0 + i);
+ Attr.is_clip_plane[i] = glIsEnabled(GL_CLIP_PLANE0 + i);
}
- Attrib.is_cull_face = glIsEnabled(GL_CULL_FACE);
- Attrib.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
- Attrib.is_dither = glIsEnabled(GL_DITHER);
- Attrib.is_line_smooth = glIsEnabled(GL_LINE_SMOOTH);
- Attrib.is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
- Attrib.is_multisample = glIsEnabled(GL_MULTISAMPLE);
- Attrib.is_polygon_offset_line = glIsEnabled(GL_POLYGON_OFFSET_LINE);
- Attrib.is_polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
- Attrib.is_polygon_smooth = glIsEnabled(GL_POLYGON_SMOOTH);
- Attrib.is_sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
- Attrib.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
- Attrib.is_stencil_test = glIsEnabled(GL_STENCIL_TEST);
+ Attr.is_cull_face = glIsEnabled(GL_CULL_FACE);
+ Attr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
+ Attr.is_dither = glIsEnabled(GL_DITHER);
+ Attr.is_line_smooth = glIsEnabled(GL_LINE_SMOOTH);
+ Attr.is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
+ Attr.is_multisample = glIsEnabled(GL_MULTISAMPLE);
+ Attr.is_polygon_offset_line = glIsEnabled(GL_POLYGON_OFFSET_LINE);
+ Attr.is_polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
+ Attr.is_polygon_smooth = glIsEnabled(GL_POLYGON_SMOOTH);
+ Attr.is_sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ Attr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
+ Attr.is_stencil_test = glIsEnabled(GL_STENCIL_TEST);
}
if ((mask & GPU_SCISSOR_BIT) != 0) {
- Attrib.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
- glGetIntegerv(GL_SCISSOR_BOX, (GLint *)&Attrib.scissor_box);
+ Attr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
+ glGetIntegerv(GL_SCISSOR_BOX, (GLint *)&Attr.scissor_box);
}
if ((mask & GPU_VIEWPORT_BIT) != 0) {
- glGetDoublev(GL_DEPTH_RANGE, (GLdouble *)&Attrib.near_far);
- glGetIntegerv(GL_VIEWPORT, (GLint *)&Attrib.viewport);
+ glGetDoublev(GL_DEPTH_RANGE, (GLdouble *)&Attr.near_far);
+ glGetIntegerv(GL_VIEWPORT, (GLint *)&Attr.viewport);
}
if ((mask & GPU_BLEND_BIT) != 0) {
- Attrib.is_blend = glIsEnabled(GL_BLEND);
+ Attr.is_blend = glIsEnabled(GL_BLEND);
}
- BLI_assert(AttribStack.top < STATE_STACK_DEPTH);
- AttribStack.top++;
+ BLI_assert(AttrStack.top < STATE_STACK_DEPTH);
+ AttrStack.top++;
}
static void restore_mask(GLenum cap, const bool value)
@@ -1536,57 +1536,57 @@ static void restore_mask(GLenum cap, const bool value)
}
}
-void gpuPopAttrib(void)
+void gpuPopAttr(void)
{
- BLI_assert(AttribStack.top > 0);
- AttribStack.top--;
+ BLI_assert(AttrStack.top > 0);
+ AttrStack.top--;
- GLint mask = Attrib.mask;
+ GLint mask = Attr.mask;
if ((mask & GPU_DEPTH_BUFFER_BIT) != 0) {
- restore_mask(GL_DEPTH_TEST, Attrib.is_depth_test);
- glDepthFunc(Attrib.depth_func);
- glClearDepth(Attrib.depth_clear_value);
- glDepthMask(Attrib.depth_write_mask);
+ restore_mask(GL_DEPTH_TEST, Attr.is_depth_test);
+ glDepthFunc(Attr.depth_func);
+ glClearDepth(Attr.depth_clear_value);
+ glDepthMask(Attr.depth_write_mask);
}
if ((mask & GPU_ENABLE_BIT) != 0) {
- restore_mask(GL_BLEND, Attrib.is_blend);
+ restore_mask(GL_BLEND, Attr.is_blend);
for (int i = 0; i < 6; i++) {
- restore_mask(GL_CLIP_PLANE0 + i, Attrib.is_clip_plane[i]);
+ restore_mask(GL_CLIP_PLANE0 + i, Attr.is_clip_plane[i]);
}
- restore_mask(GL_CULL_FACE, Attrib.is_cull_face);
- restore_mask(GL_DEPTH_TEST, Attrib.is_depth_test);
- restore_mask(GL_DITHER, Attrib.is_dither);
- restore_mask(GL_LINE_SMOOTH, Attrib.is_line_smooth);
- restore_mask(GL_COLOR_LOGIC_OP, Attrib.is_color_logic_op);
- restore_mask(GL_MULTISAMPLE, Attrib.is_multisample);
- restore_mask(GL_POLYGON_OFFSET_LINE, Attrib.is_polygon_offset_line);
- restore_mask(GL_POLYGON_OFFSET_FILL, Attrib.is_polygon_offset_fill);
- restore_mask(GL_POLYGON_SMOOTH, Attrib.is_polygon_smooth);
- restore_mask(GL_SAMPLE_ALPHA_TO_COVERAGE, Attrib.is_sample_alpha_to_coverage);
- restore_mask(GL_SCISSOR_TEST, Attrib.is_scissor_test);
- restore_mask(GL_STENCIL_TEST, Attrib.is_stencil_test);
+ restore_mask(GL_CULL_FACE, Attr.is_cull_face);
+ restore_mask(GL_DEPTH_TEST, Attr.is_depth_test);
+ restore_mask(GL_DITHER, Attr.is_dither);
+ restore_mask(GL_LINE_SMOOTH, Attr.is_line_smooth);
+ restore_mask(GL_COLOR_LOGIC_OP, Attr.is_color_logic_op);
+ restore_mask(GL_MULTISAMPLE, Attr.is_multisample);
+ restore_mask(GL_POLYGON_OFFSET_LINE, Attr.is_polygon_offset_line);
+ restore_mask(GL_POLYGON_OFFSET_FILL, Attr.is_polygon_offset_fill);
+ restore_mask(GL_POLYGON_SMOOTH, Attr.is_polygon_smooth);
+ restore_mask(GL_SAMPLE_ALPHA_TO_COVERAGE, Attr.is_sample_alpha_to_coverage);
+ restore_mask(GL_SCISSOR_TEST, Attr.is_scissor_test);
+ restore_mask(GL_STENCIL_TEST, Attr.is_stencil_test);
}
if ((mask & GPU_VIEWPORT_BIT) != 0) {
- glViewport(Attrib.viewport[0], Attrib.viewport[1], Attrib.viewport[2], Attrib.viewport[3]);
- glDepthRange(Attrib.near_far[0], Attrib.near_far[1]);
+ glViewport(Attr.viewport[0], Attr.viewport[1], Attr.viewport[2], Attr.viewport[3]);
+ glDepthRange(Attr.near_far[0], Attr.near_far[1]);
}
if ((mask & GPU_SCISSOR_BIT) != 0) {
- restore_mask(GL_SCISSOR_TEST, Attrib.is_scissor_test);
- glScissor(Attrib.scissor_box[0], Attrib.scissor_box[1], Attrib.scissor_box[2], Attrib.scissor_box[3]);
+ restore_mask(GL_SCISSOR_TEST, Attr.is_scissor_test);
+ glScissor(Attr.scissor_box[0], Attr.scissor_box[1], Attr.scissor_box[2], Attr.scissor_box[3]);
}
if ((mask & GPU_BLEND_BIT) != 0) {
- restore_mask(GL_BLEND, Attrib.is_blend);
+ restore_mask(GL_BLEND, Attr.is_blend);
}
}
-#undef Attrib
-#undef AttribStack
+#undef Attr
+#undef AttrStack
/** \} */
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index a3436b09093..50eb0e88675 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -808,7 +808,7 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
return NULL;
}
- gpuPushAttrib(GPU_VIEWPORT_BIT);
+ gpuPushAttr(GPU_VIEWPORT_BIT);
GPU_framebuffer_ensure_config(&ofs->fb, {
GPU_ATTACHMENT_TEXTURE(ofs->depth),
@@ -818,13 +818,13 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
/* check validity at the very end! */
if (!GPU_framebuffer_check_valid(ofs->fb, err_out)) {
GPU_offscreen_free(ofs);
- gpuPopAttrib();
+ gpuPopAttr();
return NULL;
}
GPU_framebuffer_restore();
- gpuPopAttrib();
+ gpuPopAttr();
return ofs;
}
@@ -844,7 +844,7 @@ void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
{
if (save) {
- gpuPushAttrib(GPU_SCISSOR_BIT | GPU_VIEWPORT_BIT);
+ gpuPushAttr(GPU_SCISSOR_BIT | GPU_VIEWPORT_BIT);
GPUFrameBuffer *fb = GPU_framebuffer_active_get();
gpuPushFrameBuffer(fb);
}
@@ -857,7 +857,7 @@ void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
GPUFrameBuffer *fb = NULL;
if (restore) {
- gpuPopAttrib();
+ gpuPopAttr();
fb = gpuPopFrameBuffer();
}
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index def75fdfa2d..9a0b1e59862 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -66,15 +66,15 @@ typedef struct {
/* current vertex */
uint vertex_idx;
GLubyte *vertex_data;
- uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */
+ uint16_t unassigned_attr_bits; /* which attributes of current vertex have not been given values? */
GLuint vbo_id;
GLuint vao_id;
GLuint bound_program;
const GPUShaderInterface *shader_interface;
- GPUAttrBinding attrib_binding;
- uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */
+ GPUAttrBinding attr_binding;
+ uint16_t prev_enabled_attr_bits; /* <-- only affects this VAO, so we're ok */
} Immediate;
/* size of internal buffer -- make this adjustable? */
@@ -121,7 +121,7 @@ void immDeactivate(void)
#endif
GPU_vao_free(imm.vao_id, imm.context);
imm.vao_id = 0;
- imm.prev_enabled_attrib_bits = 0;
+ imm.prev_enabled_attr_bits = 0;
}
void immDestroy(void)
@@ -150,7 +150,7 @@ void immBindProgram(GLuint program, const GPUShaderInterface *shaderface)
VertexFormat_pack(&imm.vertex_format);
glUseProgram(program);
- get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface);
+ get_attr_locations(&imm.vertex_format, &imm.attr_binding, shaderface);
GPU_matrix_bind(shaderface);
}
@@ -210,7 +210,7 @@ void immBegin(GPUPrimType prim_type, uint vertex_len)
imm.prim_type = prim_type;
imm.vertex_len = vertex_len;
imm.vertex_idx = 0;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+ imm.unassigned_attr_bits = imm.attr_binding.enabled_bits;
/* how many bytes do we need for this draw call? */
const uint bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len);
@@ -270,7 +270,7 @@ GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
imm.prim_type = prim_type;
imm.vertex_len = vertex_len;
imm.vertex_idx = 0;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+ imm.unassigned_attr_bits = imm.attr_binding.enabled_bits;
GPUVertBuf *verts = GPU_vertbuf_create_with_format(&imm.vertex_format);
GPU_vertbuf_data_alloc(verts, vertex_len);
@@ -295,11 +295,11 @@ static void immDrawSetup(void)
/* set up VAO -- can be done during Begin or End really */
glBindVertexArray(imm.vao_id);
- /* enable/disable vertex attribs as needed */
- if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) {
+ /* Enable/Disable vertex attributes as needed. */
+ if (imm.attr_binding.enabled_bits != imm.prev_enabled_attr_bits) {
for (uint loc = 0; loc < GPU_VERT_ATTR_MAX_LEN; ++loc) {
- bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc);
- bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc);
+ bool is_enabled = imm.attr_binding.enabled_bits & (1 << loc);
+ bool was_enabled = imm.prev_enabled_attr_bits & (1 << loc);
if (is_enabled && !was_enabled) {
glEnableVertexAttribArray(loc);
@@ -309,18 +309,18 @@ static void immDrawSetup(void)
}
}
- imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits;
+ imm.prev_enabled_attr_bits = imm.attr_binding.enabled_bits;
}
const uint stride = imm.vertex_format.stride;
for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) {
- const GPUVertAttr *a = imm.vertex_format.attribs + a_idx;
+ const GPUVertAttr *a = &imm.vertex_format.attrs[a_idx];
const uint offset = imm.buffer_offset + a->offset;
const GLvoid *pointer = (const GLubyte *)0 + offset;
- const uint loc = read_attrib_location(&imm.attrib_binding, a_idx);
+ const uint loc = read_attr_location(&imm.attr_binding, a_idx);
switch (a->fetch_mode) {
case GPU_FETCH_FLOAT:
@@ -400,29 +400,29 @@ void immEnd(void)
imm.strict_vertex_len = true;
}
-static void setAttribValueBit(uint attrib_id)
+static void setAttrValueBit(uint attr_id)
{
- uint16_t mask = 1 << attrib_id;
+ uint16_t mask = 1 << attr_id;
#if TRUST_NO_ONE
- assert(imm.unassigned_attrib_bits & mask); /* not already set */
+ assert(imm.unassigned_attr_bits & mask); /* not already set */
#endif
- imm.unassigned_attrib_bits &= ~mask;
+ imm.unassigned_attr_bits &= ~mask;
}
/* --- generic attribute functions --- */
-void immAttr1f(uint attrib_id, float x)
+void immAttr1f(uint attr_id, float x)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_F32);
assert(attr->comp_len == 1);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
@@ -430,17 +430,17 @@ void immAttr1f(uint attrib_id, float x)
data[0] = x;
}
-void immAttr2f(uint attrib_id, float x, float y)
+void immAttr2f(uint attr_id, float x, float y)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_F32);
assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
@@ -449,17 +449,17 @@ void immAttr2f(uint attrib_id, float x, float y)
data[1] = y;
}
-void immAttr3f(uint attrib_id, float x, float y, float z)
+void immAttr3f(uint attr_id, float x, float y, float z)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_F32);
assert(attr->comp_len == 3);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
@@ -469,17 +469,17 @@ void immAttr3f(uint attrib_id, float x, float y, float z)
data[2] = z;
}
-void immAttr4f(uint attrib_id, float x, float y, float z, float w)
+void immAttr4f(uint attr_id, float x, float y, float z, float w)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_F32);
assert(attr->comp_len == 4);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
@@ -490,34 +490,34 @@ void immAttr4f(uint attrib_id, float x, float y, float z, float w)
data[3] = w;
}
-void immAttr1u(uint attrib_id, uint x)
+void immAttr1u(uint attr_id, uint x)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_U32);
assert(attr->comp_len == 1);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
uint *data = (uint *)(imm.vertex_data + attr->offset);
data[0] = x;
}
-void immAttr2i(uint attrib_id, int x, int y)
+void immAttr2i(uint attr_id, int x, int y)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_I32);
assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
int *data = (int *)(imm.vertex_data + attr->offset);
@@ -525,17 +525,17 @@ void immAttr2i(uint attrib_id, int x, int y)
data[1] = y;
}
-void immAttr2s(uint attrib_id, short x, short y)
+void immAttr2s(uint attr_id, short x, short y)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_I16);
assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
short *data = (short *)(imm.vertex_data + attr->offset);
@@ -543,32 +543,32 @@ void immAttr2s(uint attrib_id, short x, short y)
data[1] = y;
}
-void immAttr2fv(uint attrib_id, const float data[2])
+void immAttr2fv(uint attr_id, const float data[2])
{
- immAttr2f(attrib_id, data[0], data[1]);
+ immAttr2f(attr_id, data[0], data[1]);
}
-void immAttr3fv(uint attrib_id, const float data[3])
+void immAttr3fv(uint attr_id, const float data[3])
{
- immAttr3f(attrib_id, data[0], data[1], data[2]);
+ immAttr3f(attr_id, data[0], data[1], data[2]);
}
-void immAttr4fv(uint attrib_id, const float data[4])
+void immAttr4fv(uint attr_id, const float data[4])
{
- immAttr4f(attrib_id, data[0], data[1], data[2], data[3]);
+ immAttr4f(attr_id, data[0], data[1], data[2], data[3]);
}
-void immAttr3ub(uint attrib_id, uchar r, uchar g, uchar b)
+void immAttr3ub(uint attr_id, uchar r, uchar g, uchar b)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_U8);
assert(attr->comp_len == 3);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
GLubyte *data = imm.vertex_data + attr->offset;
/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
@@ -578,17 +578,17 @@ void immAttr3ub(uint attrib_id, uchar r, uchar g, uchar b)
data[2] = b;
}
-void immAttr4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
+void immAttr4ub(uint attr_id, uchar r, uchar g, uchar b, uchar a)
{
- GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = &imm.vertex_format.attrs[attr_id];
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(attr->comp_type == GPU_COMP_U8);
assert(attr->comp_len == 4);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
GLubyte *data = imm.vertex_data + attr->offset;
/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
@@ -599,24 +599,24 @@ void immAttr4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
data[3] = a;
}
-void immAttr3ubv(uint attrib_id, const uchar data[3])
+void immAttr3ubv(uint attr_id, const uchar data[3])
{
- immAttr3ub(attrib_id, data[0], data[1], data[2]);
+ immAttr3ub(attr_id, data[0], data[1], data[2]);
}
-void immAttr4ubv(uint attrib_id, const uchar data[4])
+void immAttr4ubv(uint attr_id, const uchar data[4])
{
- immAttr4ub(attrib_id, data[0], data[1], data[2], data[3]);
+ immAttr4ub(attr_id, data[0], data[1], data[2], data[3]);
}
-void immAttrSkip(uint attrib_id)
+void immAttrSkip(uint attr_id)
{
#if TRUST_NO_ONE
- assert(attrib_id < imm.vertex_format.attr_len);
+ assert(attr_id < imm.vertex_format.attr_len);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
- setAttribValueBit(attrib_id);
+ setAttrValueBit(attr_id);
}
static void immEndVertex(void) /* and move on to the next vertex */
@@ -626,15 +626,15 @@ static void immEndVertex(void) /* and move on to the next vertex */
assert(imm.vertex_idx < imm.vertex_len);
#endif
- /* have all attribs been assigned values?
- * if not, copy value from previous vertex */
- if (imm.unassigned_attrib_bits) {
+ /* Have all attributes been assigned values?
+ * If not, copy value from previous vertex. */
+ if (imm.unassigned_attr_bits) {
#if TRUST_NO_ONE
- assert(imm.vertex_idx > 0); /* first vertex must have all attribs specified */
+ assert(imm.vertex_idx > 0); /* first vertex must have all attributes specified */
#endif
for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) {
- if ((imm.unassigned_attrib_bits >> a_idx) & 1) {
- const GPUVertAttr *a = imm.vertex_format.attribs + a_idx;
+ if ((imm.unassigned_attr_bits >> a_idx) & 1) {
+ const GPUVertAttr *a = &imm.vertex_format.attrs[a_idx];
/* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */
@@ -647,54 +647,54 @@ static void immEndVertex(void) /* and move on to the next vertex */
imm.vertex_idx++;
imm.vertex_data += imm.vertex_format.stride;
- imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
+ imm.unassigned_attr_bits = imm.attr_binding.enabled_bits;
}
-void immVertex2f(uint attrib_id, float x, float y)
+void immVertex2f(uint attr_id, float x, float y)
{
- immAttr2f(attrib_id, x, y);
+ immAttr2f(attr_id, x, y);
immEndVertex();
}
-void immVertex3f(uint attrib_id, float x, float y, float z)
+void immVertex3f(uint attr_id, float x, float y, float z)
{
- immAttr3f(attrib_id, x, y, z);
+ immAttr3f(attr_id, x, y, z);
immEndVertex();
}
-void immVertex4f(uint attrib_id, float x, float y, float z, float w)
+void immVertex4f(uint attr_id, float x, float y, float z, float w)
{
- immAttr4f(attrib_id, x, y, z, w);
+ immAttr4f(attr_id, x, y, z, w);
immEndVertex();
}
-void immVertex2i(uint attrib_id, int x, int y)
+void immVertex2i(uint attr_id, int x, int y)
{
- immAttr2i(attrib_id, x, y);
+ immAttr2i(attr_id, x, y);
immEndVertex();
}
-void immVertex2s(uint attrib_id, short x, short y)
+void immVertex2s(uint attr_id, short x, short y)
{
- immAttr2s(attrib_id, x, y);
+ immAttr2s(attr_id, x, y);
immEndVertex();
}
-void immVertex2fv(uint attrib_id, const float data[2])
+void immVertex2fv(uint attr_id, const float data[2])
{
- immAttr2f(attrib_id, data[0], data[1]);
+ immAttr2f(attr_id, data[0], data[1]);
immEndVertex();
}
-void immVertex3fv(uint attrib_id, const float data[3])
+void immVertex3fv(uint attr_id, const float data[3])
{
- immAttr3f(attrib_id, data[0], data[1], data[2]);
+ immAttr3f(attr_id, data[0], data[1], data[2]);
immEndVertex();
}
-void immVertex2iv(uint attrib_id, const int data[2])
+void immVertex2iv(uint attr_id, const int data[2])
{
- immAttr2i(attrib_id, data[0], data[1]);
+ immAttr2i(attr_id, data[0], data[1]);
immEndVertex();
}
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index a9e98314014..68678354209 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -136,7 +136,7 @@ void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2
void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
{
GPUVertFormat *format = immVertexFormat();
- uint pos = add_attrib(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint pos = add_attr(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
immRecti(pos, x1, y1, x2, y2);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index d1062f70c24..91f50d961d5 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -82,7 +82,7 @@ struct GPUMaterial {
/* for binding the material */
GPUPass *pass;
ListBase inputs; /* GPUInput */
- GPUVertexAttribs attribs;
+ GPUVertAttrLayers attrs;
int builtins;
int alpha, obcolalpha;
int dynproperty;
@@ -569,9 +569,9 @@ struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void)
#undef SSS_EXPONENT
#undef SSS_SAMPLES
-void GPU_material_vertex_attributes(GPUMaterial *material, GPUVertexAttribs *attribs)
+void GPU_material_vertex_attrs(GPUMaterial *material, GPUVertAttrLayers *r_attrs)
{
- *attribs = material->attribs;
+ *r_attrs = material->attrs;
}
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
@@ -676,15 +676,15 @@ GPUMaterial *GPU_material_from_nodetree(
}
if (mat->outlink) {
- /* Prune the unused nodes and extract attribs before compiling so the
+ /* Prune the unused nodes and extract attributes before compiling so the
* generated VBOs are ready to accept the future shader. */
GPU_nodes_prune(&mat->nodes, mat->outlink);
- GPU_nodes_get_vertex_attributes(&mat->nodes, &mat->attribs);
+ GPU_nodes_get_vertex_attrs(&mat->nodes, &mat->attrs);
/* Create source code and search pass cache for an already compiled version. */
mat->pass = GPU_generate_pass(
mat,
mat->outlink,
- &mat->attribs,
+ &mat->attrs,
&mat->nodes,
&mat->builtins,
vert_code,
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 363baa41a6d..ecd49d3e4d8 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -317,7 +317,7 @@ void gpu_select_pick_begin(
/* Restrict OpenGL operations for when we don't have cache */
if (ps->is_cached == false) {
- gpuPushAttrib(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT);
+ gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT);
/* disable writing to the framebuffer */
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
@@ -539,7 +539,7 @@ uint gpu_select_pick_end(void)
/* force finishing last pass */
gpu_select_pick_load_id(ps->gl.prev_id);
}
- gpuPopAttrib();
+ gpuPopAttr();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c
index 4520025ea7f..e81e6f10253 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.c
+++ b/source/blender/gpu/intern/gpu_select_sample_query.c
@@ -98,7 +98,7 @@ void gpu_select_query_begin(
g_query_state.id = MEM_mallocN(g_query_state.num_of_queries * sizeof(*g_query_state.id), "gpu selection ids");
glGenQueries(g_query_state.num_of_queries, g_query_state.queries);
- gpuPushAttrib(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT | GPU_SCISSOR_BIT);
+ gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT | GPU_SCISSOR_BIT);
/* disable writing to the framebuffer */
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
@@ -219,7 +219,7 @@ uint gpu_select_query_end(void)
glDeleteQueries(g_query_state.num_of_queries, g_query_state.queries);
MEM_freeN(g_query_state.queries);
MEM_freeN(g_query_state.id);
- gpuPopAttrib();
+ gpuPopAttr();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
return hits;
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 6f6dbb04d28..24ee8330466 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -674,8 +674,8 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText
int GPU_shader_get_attribute(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
- const GPUShaderInput *attrib = GPU_shaderinterface_attr(shader->interface, name);
- return attrib ? attrib->location : -1;
+ const GPUShaderInput *attr = GPU_shaderinterface_attr(shader->interface, name);
+ return attr ? attr->location : -1;
}
static const GPUShaderStages builtin_shader_stages[GPU_NUM_BUILTIN_SHADERS] = {
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
index 6e05609a3ae..65e9cf4d59d 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -221,15 +221,15 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
printf("GPUShaderInterface %p, program %d\n", shaderface, program);
#endif
- GLint max_attrib_name_len, attr_len;
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
+ GLint max_attr_name_len, attr_len;
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attr_name_len);
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len);
GLint max_ubo_name_len, ubo_len;
glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len);
- const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len;
+ const uint32_t name_buffer_len = attr_len * max_attr_name_len + ubo_len * max_ubo_name_len;
shaderface->name_buffer = MEM_mallocN(name_buffer_len, "name_buffer");
/* Attributes */
@@ -253,10 +253,10 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
set_input_name(shaderface, input, name, name_len);
- shader_input_to_bucket(input, shaderface->attrib_buckets);
+ shader_input_to_bucket(input, shaderface->attr_buckets);
#if DEBUG_SHADER_INTERFACE
- printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
+ printf("attr[%u] '%s' at location %d\n", i, name, input->location);
#endif
}
/* Uniform Blocks */
@@ -296,7 +296,7 @@ void GPU_shaderinterface_discard(GPUShaderInterface *shaderface)
{
/* Free memory used by buckets and has entries. */
buckets_free(shaderface->uniform_buckets);
- buckets_free(shaderface->attrib_buckets);
+ buckets_free(shaderface->attr_buckets);
buckets_free(shaderface->ubo_buckets);
/* Free memory used by name_buffer. */
MEM_freeN(shaderface->name_buffer);
@@ -358,7 +358,7 @@ const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *shaderfa
const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *shaderface, const char *name)
{
- return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name);
+ return buckets_lookup(shaderface->attr_buckets, shaderface->name_buffer, name);
}
void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch)
diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h
index 69c0c41cef4..01a7f38efed 100644
--- a/source/blender/gpu/intern/gpu_shader_private.h
+++ b/source/blender/gpu/intern/gpu_shader_private.h
@@ -29,13 +29,18 @@
#include "GPU_shader_interface.h"
struct GPUShader {
- GLuint program; /* handle for full program (links shader stages below) */
-
- GLuint vertex; /* handle for vertex shader */
- GLuint geometry; /* handle for geometry shader */
- GLuint fragment; /* handle for fragment shader */
-
- GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */
+ /** Handle for full program (links shader stages below). */
+ GLuint program;
+
+ /** Handle for vertex shader. */
+ GLuint vertex;
+ /** Handle for geometry shader. */
+ GLuint geometry;
+ /** Handle for fragment shader. */
+ GLuint fragment;
+
+ /** Cached uniform & attribute interface for shader. */
+ GPUShaderInterface *interface;
int feedback_transform_type;
#ifndef NDEBUG
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 23e3519c6d9..453a85139f9 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -1064,7 +1064,7 @@ GPUTexture *GPU_texture_create_cube(
GPUTexture *GPU_texture_create_from_vertbuf(GPUVertBuf *vert)
{
GPUVertFormat *format = &vert->format;
- GPUVertAttr *attr = &format->attribs[0];
+ GPUVertAttr *attr = &format->attrs[0];
/* Detect incompatible cases (not supported by texture buffers) */
BLI_assert(format->attr_len == 1 && vert->vbo_id != 0);
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
index cf6ff1769ce..371b250a1cd 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -169,7 +169,7 @@ void GPU_vertbuf_data_len_set(GPUVertBuf *verts, uint v_len)
void GPU_vertbuf_attr_set(GPUVertBuf *verts, uint a_idx, uint v_idx, const void *data)
{
const GPUVertFormat *format = &verts->format;
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
#if TRUST_NO_ONE
assert(a_idx < format->attr_len);
@@ -183,7 +183,7 @@ void GPU_vertbuf_attr_set(GPUVertBuf *verts, uint a_idx, uint v_idx, const void
void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data)
{
const GPUVertFormat *format = &verts->format;
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
#if TRUST_NO_ONE
assert(a_idx < format->attr_len);
@@ -196,7 +196,7 @@ void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data)
void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts, uint a_idx, uint stride, const void *data)
{
const GPUVertFormat *format = &verts->format;
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
#if TRUST_NO_ONE
assert(a_idx < format->attr_len);
@@ -220,7 +220,7 @@ void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts, uint a_idx, uint stride, co
void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts, uint a_idx, GPUVertBufRaw *access)
{
const GPUVertFormat *format = &verts->format;
- const GPUVertAttr *a = format->attribs + a_idx;
+ const GPUVertAttr *a = &format->attrs[a_idx];
#if TRUST_NO_ONE
assert(a_idx < format->attr_len);
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index 91060fd2d30..9c0da4fb6b4 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -55,7 +55,7 @@ void GPU_vertformat_clear(GPUVertFormat *format)
format->name_len = 0;
for (uint i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) {
- format->attribs[i].name_len = 0;
+ format->attrs[i].name_len = 0;
}
#endif
}
@@ -66,8 +66,8 @@ void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src)
memcpy(dest, src, sizeof(GPUVertFormat));
for (uint i = 0; i < dest->attr_len; i++) {
- for (uint j = 0; j < dest->attribs[i].name_len; j++) {
- dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src));
+ for (uint j = 0; j < dest->attrs[i].name_len; j++) {
+ dest->attrs[i].name[j] = (char *)dest + (src->attrs[i].name[j] - ((char *)src));
}
}
}
@@ -98,7 +98,7 @@ static uint comp_sz(GPUVertCompType type)
return sizes[type];
}
-static uint attrib_sz(const GPUVertAttr *a)
+static uint attr_sz(const GPUVertAttr *a)
{
if (a->comp_type == GPU_COMP_I10) {
return 4; /* always packed as 10_10_10_2 */
@@ -106,7 +106,7 @@ static uint attrib_sz(const GPUVertAttr *a)
return a->comp_len * comp_sz(a->comp_type);
}
-static uint attrib_align(const GPUVertAttr *a)
+static uint attr_align(const GPUVertAttr *a)
{
if (a->comp_type == GPU_COMP_I10) {
return 4; /* always packed as 10_10_10_2 */
@@ -128,7 +128,7 @@ uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len)
return format->stride * vertex_len;
}
-static const char *copy_attrib_name(GPUVertFormat *format, const char *name, const char *suffix)
+static const char *copy_attr_name(GPUVertFormat *format, const char *name, const char *suffix)
{
/* strncpy does 110% of what we need; let's do exactly 100% */
char *name_copy = format->names + format->name_offset;
@@ -196,37 +196,37 @@ uint GPU_vertformat_attr_add(
#endif
format->name_len++; /* multiname support */
- const uint attrib_id = format->attr_len++;
- GPUVertAttr *attrib = format->attribs + attrib_id;
+ const uint attr_id = format->attr_len++;
+ GPUVertAttr *attr = &format->attrs[attr_id];
- attrib->name[attrib->name_len++] = copy_attrib_name(format, name, NULL);
- attrib->comp_type = comp_type;
- attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
- attrib->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */
- attrib->sz = attrib_sz(attrib);
- attrib->offset = 0; /* offsets & stride are calculated later (during pack) */
- attrib->fetch_mode = fetch_mode;
+ attr->name[attr->name_len++] = copy_attr_name(format, name, NULL);
+ attr->comp_type = comp_type;
+ attr->gl_comp_type = convert_comp_type_to_gl(comp_type);
+ attr->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */
+ attr->sz = attr_sz(attr);
+ attr->offset = 0; /* offsets & stride are calculated later (during pack) */
+ attr->fetch_mode = fetch_mode;
- return attrib_id;
+ return attr_id;
}
void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias)
{
- GPUVertAttr *attrib = format->attribs + (format->attr_len - 1);
+ GPUVertAttr *attr = &format->attrs[format->attr_len - 1];
#if TRUST_NO_ONE
assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */
- assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES);
+ assert(attr->name_len < GPU_VERT_ATTR_MAX_NAMES);
#endif
format->name_len++; /* multiname support */
- attrib->name[attrib->name_len++] = copy_attrib_name(format, alias, NULL);
+ attr->name[attr->name_len++] = copy_attr_name(format, alias, NULL);
}
int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
{
for (int i = 0; i < format->attr_len; i++) {
- const GPUVertAttr *attrib = format->attribs + i;
- for (int j = 0; j < attrib->name_len; j++) {
- if (STREQ(name, attrib->name[j])) {
+ const GPUVertAttr *attr = &format->attrs[i];
+ for (int j = 0; j < attr->name_len; j++) {
+ if (STREQ(name, attr->name[j])) {
return i;
}
}
@@ -246,25 +246,25 @@ void GPU_vertformat_triple_load(GPUVertFormat *format)
uint old_attr_len = format->attr_len;
for (uint a_idx = 0; a_idx < old_attr_len; ++a_idx) {
- GPUVertAttr *attrib = format->attribs + a_idx;
- /* Duplicate attrib twice */
+ GPUVertAttr *attr = &format->attrs[a_idx];
+ /* Duplicate attr twice */
for (int i = 1; i < 3; ++i) {
- GPUVertAttr *dst_attrib = format->attribs + format->attr_len;
- memcpy(dst_attrib, attrib, sizeof(GPUVertAttr));
+ GPUVertAttr *dst_attr = &format->attrs[format->attr_len];
+ memcpy(dst_attr, attr, sizeof(GPUVertAttr));
/* Increase offset to the next vertex. */
- dst_attrib->offset += format->stride * i;
+ dst_attr->offset += format->stride * i;
/* Only copy first name for now. */
- dst_attrib->name_len = 0;
- dst_attrib->name[dst_attrib->name_len++] = copy_attrib_name(format, attrib->name[0], (i == 1) ? "1" : "2");
+ dst_attr->name_len = 0;
+ dst_attr->name[dst_attr->name_len++] = copy_attr_name(format, attr->name[0], (i == 1) ? "1" : "2");
format->attr_len++;
}
#if TRUST_NO_ONE
- assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES);
+ assert(attr->name_len < GPU_VERT_ATTR_MAX_NAMES);
#endif
- /* Add alias to first attrib. */
+ /* Add alias to first attr. */
format->name_len++;
- attrib->name[attrib->name_len++] = copy_attrib_name(format, attrib->name[0], "0");
+ attr->name[attr->name_len++] = copy_attr_name(format, attr->name[0], "0");
}
}
@@ -290,14 +290,14 @@ static void show_pack(uint a_idx, uint sz, uint pad)
void VertexFormat_pack(GPUVertFormat *format)
{
/* For now, attributes are packed in the order they were added,
- * making sure each attrib is naturally aligned (add padding where necessary)
+ * making sure each attribute is naturally aligned (add padding where necessary)
* Later we can implement more efficient packing w/ reordering
- * (keep attrib ID order, adjust their offsets to reorder in buffer). */
+ * (keep attribute ID order, adjust their offsets to reorder in buffer). */
/* TODO: realloc just enough to hold the final combo string. And just enough to
- * hold used attribs, not all 16. */
+ * hold used attributes, not all 16. */
- GPUVertAttr *a0 = format->attribs + 0;
+ GPUVertAttr *a0 = &format->attrs[0];
a0->offset = 0;
uint offset = a0->sz;
@@ -306,8 +306,8 @@ void VertexFormat_pack(GPUVertFormat *format)
#endif
for (uint a_idx = 1; a_idx < format->attr_len; ++a_idx) {
- GPUVertAttr *a = format->attribs + a_idx;
- uint mid_padding = padding(offset, attrib_align(a));
+ GPUVertAttr *a = &format->attrs[a_idx];
+ uint mid_padding = padding(offset, attr_align(a));
offset += mid_padding;
a->offset = offset;
offset += a->sz;
@@ -317,7 +317,7 @@ void VertexFormat_pack(GPUVertFormat *format)
#endif
}
- uint end_padding = padding(offset, attrib_align(a0));
+ uint end_padding = padding(offset, attr_align(a0));
#if PACK_DEBUG
show_pack(0, 0, end_padding);
@@ -412,7 +412,7 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa
const char *name_buffer = shaderface->name_buffer;
for (int i = 0; i < GPU_NUM_SHADERINTERFACE_BUCKETS; i++) {
- const GPUShaderInput *input = shaderface->attrib_buckets[i];
+ const GPUShaderInput *input = shaderface->attr_buckets[i];
if (input == NULL) {
continue;
}
@@ -425,13 +425,13 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa
format->name_len++; /* multiname support */
format->attr_len++;
- GPUVertAttr *attrib = format->attribs + input->location;
+ GPUVertAttr *attr = &format->attrs[input->location];
- attrib->name[attrib->name_len++] = copy_attrib_name(format, name_buffer + input->name_offset, NULL);
- attrib->offset = 0; /* offsets & stride are calculated later (during pack) */
- attrib->comp_len = calc_input_component_size(input);
- attrib->sz = attrib->comp_len * 4;
- get_fetch_mode_and_comp_type(input->gl_type, &attrib->comp_type, &attrib->gl_comp_type, &attrib->fetch_mode);
+ attr->name[attr->name_len++] = copy_attr_name(format, name_buffer + input->name_offset, NULL);
+ attr->offset = 0; /* offsets & stride are calculated later (during pack) */
+ attr->comp_len = calc_input_component_size(input);
+ attr->sz = attr->comp_len * 4;
+ get_fetch_mode_and_comp_type(input->gl_type, &attr->comp_type, &attr->gl_comp_type, &attr->fetch_mode);
}
}
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
index 4a9f5f94321..ea8d57b5eea 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
@@ -11,7 +11,7 @@ in vec2 pos; /* verts position in the curve tangent space */
in vec2 expand;
#ifdef USE_INSTANCE
-/* Instance attrib */
+/* Instance attrs. */
in vec2 P0;
in vec2 P1;
in vec2 P2;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl
index 9a7815cc9d7..6a6da3dd104 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl
@@ -4,10 +4,10 @@ uniform mat4 ViewProjectionMatrix;
uniform mat4 ModelMatrix;
#endif
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in float pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in vec3 color;
in vec4 corners[2]; /* trouble fetching vec2 */
in float depth;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl
index 255eeb9baf1..432b6cac049 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl
@@ -1,10 +1,10 @@
uniform mat4 ViewProjectionMatrix;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in vec3 color;
in float start;
in float end;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
index fa30c9fb1ed..9de50246a40 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
@@ -16,7 +16,7 @@ uniform mat4 ProjectionMatrix;
in vec3 pos;
in vec3 N1, N2; // normals of faces this edge joins (object coords)
-/* instance attrib */
+/* Instance attrs */
in vec3 color;
in mat4 InstanceModelMatrix;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl
index d2b64608eaa..087fec80537 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl
@@ -2,11 +2,11 @@
uniform mat4 ViewMatrix;
uniform mat4 ViewProjectionMatrix;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos;
in vec3 nor;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
in vec4 color;
@@ -17,7 +17,7 @@ void main()
{
mat4 ModelViewProjectionMatrix = ViewProjectionMatrix * InstanceModelMatrix;
/* This is slow and run per vertex, but it's still faster than
- * doing it per instance on CPU and sending it on via instance attrib */
+ * doing it per instance on CPU and sending it on via instance attr. */
mat3 NormalMatrix = transpose(inverse(mat3(ViewMatrix * InstanceModelMatrix)));
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_vert.glsl
index f4f5b269b96..17799281f32 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_vert.glsl
@@ -5,10 +5,10 @@ uniform mat4 ModelMatrix;
#endif
uniform vec3 screen_vecs[2];
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos; /* using Z as axis id */
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
in vec3 color;
in float size;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl
index 3baea763790..d2b85976d73 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl
@@ -4,10 +4,10 @@ uniform vec3 screen_vecs[2];
uniform float size;
uniform float pixel_size;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec2 pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in vec3 world_pos;
in vec3 color;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl
index fed00389fc1..6a55684c93c 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl
@@ -2,10 +2,10 @@
uniform mat4 ViewProjectionMatrix;
uniform mat4 ModelMatrix;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
in vec4 color;
#ifdef UNIFORM_SCALE
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl
index f265bf9fc01..777c1498eec 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl
@@ -2,10 +2,10 @@
uniform mat4 ViewProjectionMatrix;
uniform int baseId;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
#ifdef UNIFORM_SCALE
in float size;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_vert.glsl
index a4facae435e..803dc4b3bcf 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_vert.glsl
@@ -1,10 +1,10 @@
uniform mat4 ViewProjectionMatrix;
-/* ---- Instantiated Attribs ---- */
+/* ---- Instantiated Attrs ---- */
in vec3 pos;
-/* ---- Per instance Attribs ---- */
+/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
void main()
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 26529dce08a..13b98080feb 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -3,7 +3,7 @@ uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewMatrixInverse;
uniform mat3 NormalMatrix;
-#ifndef ATTRIB
+#ifndef USE_ATTR
uniform mat4 ModelMatrix;
uniform mat4 ModelMatrixInverse;
#endif