[Bf-blender-cvs] [7eecc940741] blender2.8: Cleanup: use uint/uchar types in GPU
Campbell Barton
noreply at git.blender.org
Wed Sep 12 04:09:38 CEST 2018
Commit: 7eecc9407415e18eaab2ded2fcc883edbf58c633
Author: Campbell Barton
Date: Wed Sep 12 12:18:35 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB7eecc9407415e18eaab2ded2fcc883edbf58c633
Cleanup: use uint/uchar types in GPU
===================================================================
M source/blender/gpu/intern/gpu_attr_binding_private.h
M source/blender/gpu/intern/gpu_buffers.c
M source/blender/gpu/intern/gpu_codegen.c
M source/blender/gpu/intern/gpu_codegen.h
M source/blender/gpu/intern/gpu_draw.c
M source/blender/gpu/intern/gpu_framebuffer.c
M source/blender/gpu/intern/gpu_immediate.c
M source/blender/gpu/intern/gpu_immediate_util.c
M source/blender/gpu/intern/gpu_matrix.c
M source/blender/gpu/intern/gpu_select_private.h
M source/blender/gpu/intern/gpu_shader.c
M source/blender/gpu/intern/gpu_texture.c
M source/blender/gpu/intern/gpu_vertex_format.c
M source/blender/gpu/intern/gpu_viewport.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h
index cb338b10aa4..c545983637c 100644
--- a/source/blender/gpu/intern/gpu_attr_binding_private.h
+++ b/source/blender/gpu/intern/gpu_attr_binding_private.h
@@ -39,7 +39,7 @@ void AttribBinding_clear(GPUAttrBinding *binding);
void get_attrib_locations(
const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface);
-unsigned read_attrib_location(
- const GPUAttrBinding *binding, unsigned a_idx);
+uint read_attrib_location(
+ const GPUAttrBinding *binding, uint a_idx);
#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 6da7deece32..cd3290d1901 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -89,7 +89,7 @@ struct GPU_PBVH_Buffers {
bool use_bmesh;
- unsigned int tot_tri, tot_quad;
+ uint tot_tri, tot_quad;
/* The PBVH ensures that either all faces in the node are
* smooth-shaded or all faces are flat-shaded */
@@ -104,7 +104,7 @@ static struct {
/* Allocates a non-initialized buffer to be sent to GPU.
* Return is false it indicates that the memory map failed. */
-static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_len)
+static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
{
if (buffers->vert_buf == NULL) {
/* Initialize vertex buffer */
@@ -192,13 +192,13 @@ void GPU_pbvh_mesh_buffers_update(
}
else {
/* calculate normal for each polygon only once */
- unsigned int mpoly_prev = UINT_MAX;
+ uint mpoly_prev = UINT_MAX;
short no[3];
int vbo_index = 0;
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
- const unsigned int vtri[3] = {
+ const uint vtri[3] = {
buffers->mloop[lt->tri[0]].v,
buffers->mloop[lt->tri[1]].v,
buffers->mloop[lt->tri[2]].v,
@@ -433,7 +433,7 @@ void GPU_pbvh_grid_buffers_update(
}
/* Build the element array buffer of grid indices using either
- * unsigned shorts or unsigned ints. */
+ * ushorts or uints. */
#define FILL_QUAD_BUFFER(max_vert_, tot_quad_, buffer_) \
{ \
int offset = 0; \
@@ -474,7 +474,7 @@ void GPU_pbvh_grid_buffers_update(
/* end FILL_QUAD_BUFFER */
static GPUIndexBuf *gpu_get_grid_buffer(
- int gridsize, unsigned *totquad,
+ int gridsize, uint *totquad,
/* remove this arg when GPU gets base-vertex support! */
int totgrid)
{
@@ -845,7 +845,7 @@ void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
}
/* debug function, draws the pbvh BB */
-void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos)
+void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
{
if (leaf)
immUniformColor4f(0.0, 1.0, 0.0, 0.5);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 678c3019dc7..2b81ec02c9c 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -82,15 +82,15 @@ static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertexA
{
BLI_HashMurmur2A hm2a;
BLI_hash_mm2a_init(&hm2a, 0);
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)frag_gen, strlen(frag_gen));
+ 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;
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)name, strlen(name));
+ BLI_hash_mm2a_add(&hm2a, (uchar *)name, strlen(name));
}
}
if (defs)
- BLI_hash_mm2a_add(&hm2a, (unsigned char *)defs, strlen(defs));
+ BLI_hash_mm2a_add(&hm2a, (uchar *)defs, strlen(defs));
return BLI_hash_mm2a_end(&hm2a);
}
@@ -923,7 +923,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(ds, "#define att%d %s\n", input->attribid, attrib_prefix_get(input->attribtype));
}
else {
- unsigned int hash = BLI_ghashutil_strhash_p(input->attribname);
+ uint hash = BLI_ghashutil_strhash_p(input->attribname);
BLI_dynstr_appendf(
ds, "DEFINE_ATTRIB(%s, %s%u);\n",
GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 7a86bed55de..a6cb2468f2f 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -169,7 +169,7 @@ struct GPUPass {
char *geometrycode;
char *vertexcode;
char *defines;
- unsigned int refcount; /* Orphaned GPUPasses gets freed by the garbage collector. */
+ uint refcount; /* Orphaned GPUPasses gets freed by the garbage collector. */
uint32_t hash; /* Identity hash generated from all GLSL code. */
bool compiled; /* Did we already tried to compile the attached GPUShader. */
};
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 325ade776de..92539fc2fb3 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -309,7 +309,7 @@ GPUTexture *GPU_texture_from_blender(
/* Check if we have a valid image. If not, we return a dummy
* texture with zero bindcode so we don't keep trying. */
- unsigned int bindcode = 0;
+ uint bindcode = 0;
if (ima->ok == 0) {
*tex = GPU_texture_from_bindcode(textarget, bindcode);
return *tex;
@@ -353,7 +353,7 @@ GPUTexture *GPU_texture_from_blender(
const int rectw = ibuf->x;
const int recth = ibuf->y;
- unsigned int *rect = ibuf->rect;
+ uint *rect = ibuf->rect;
float *frect = NULL;
float *srgb_frect = NULL;
@@ -397,9 +397,9 @@ GPUTexture *GPU_texture_from_blender(
return *tex;
}
-static void **gpu_gen_cube_map(unsigned int *rect, float *frect, int rectw, int recth, bool use_high_bit_depth)
+static void **gpu_gen_cube_map(uint *rect, float *frect, int rectw, int recth, bool use_high_bit_depth)
{
- size_t block_size = use_high_bit_depth ? sizeof(float) * 4 : sizeof(unsigned char) * 4;
+ size_t block_size = use_high_bit_depth ? sizeof(float[4]) : sizeof(uchar[4]);
void **sides = NULL;
int h = recth / 2;
int w = rectw / 3;
@@ -437,7 +437,7 @@ static void **gpu_gen_cube_map(unsigned int *rect, float *frect, int rectw, int
}
}
else {
- unsigned int **isides = (unsigned int **)sides;
+ uint **isides = (uint **)sides;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
@@ -466,7 +466,7 @@ static void gpu_del_cube_map(void **cube_map)
/* Image *ima can be NULL */
void GPU_create_gl_tex(
- unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
+ uint *bind, uint *rect, float *frect, int rectw, int recth,
int textarget, bool mipmap, bool use_high_bit_depth, Image *ima)
{
ImBuf *ibuf = NULL;
@@ -670,7 +670,7 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
}
void GPU_create_gl_tex_compressed(
- unsigned int *bind, unsigned int *pix, int x, int y,
+ uint *bind, uint *pix, int x, int y,
int textarget, int mipmap, Image *ima, ImBuf *ibuf)
{
#ifndef WITH_DDS
@@ -775,8 +775,8 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x,
}
/* byte images are not continuous in memory so do manual interpolation */
else {
- unsigned char *scalerect = MEM_mallocN(rectw * recth * sizeof(*scalerect) * 4, "scalerect");
- unsigned int *p = (unsigned int *)scalerect;
+ uchar *scalerect = MEM_mallocN(rectw * recth * sizeof(*scalerect) * 4, "scalerect");
+ uint *p = (uint *)scalerect;
int i, j;
float inv_xratio = 1.0f / xratio;
float inv_yratio = 1.0f / yratio;
@@ -784,7 +784,7 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x,
float u = (x + i) * inv_xratio;
for (j = 0; j < recth; j++) {
float v = (y + j) * inv_yratio;
- bilinear_interpolation_color_wrap(ibuf, (unsigned char *)(p + i + j * (rectw)), NULL, u, v);
+ bilinear_interpolation_color_wrap(ibuf, (uchar *)(p + i + j * (rectw)), NULL, u, v);
}
}
@@ -1215,9 +1215,9 @@ void GPU_disable_program_point_size(void)
/* apple seems to round colors to below and up on some configs */
-static unsigned int index_to_framebuffer(int index)
+static uint index_to_framebuffer(int index)
{
- unsigned int i = index;
+ uint i = index;
switch (GPU_color_depth()) {
case 12:
@@ -1245,9 +1245,9 @@ static unsigned int index_to_framebuffer(int index)
/* this is the old method as being in use for ages.... seems to work? colors are rounded to lower values */
-static unsigned int index_to_framebuffer(int index)
+static uint index_to_framebuffer(int index)
{
- unsigned int i = index;
+ uint i = index;
switch (GPU_color_depth()) {
case 8:
@@ -1303,7 +1303,7 @@ void GPU_select_index_get(int index, int *r_col)
#define INDEX_FROM_BUF_18(col) ((((col) & 0xFC0000) >> 6) + (((col) & 0xFC00) >> 4) + (((col) & 0xFC) >> 2))
#define INDEX_FROM_BUF_24(col) ((col) & 0xFFFFFF)
-int GPU_select_to_index(unsigned int col)
+int GPU_select_to_index(uint col)
{
if (col == 0) {
return 0;
@@ -1319,7 +1319,7 @@ int GPU_select_to_index(unsigned int col)
}
}
-void GPU_select_to_index_array(unsigned int *col, const unsigned int size)
+void GPU_select_to_index_array(uint *col, const uint size)
{
#define INDEX_BUF_ARRAY(INDEX_FROM_BUF_BITS) \
for (i = size; i--; col++) { \
@@ -1329,7 +1329,7 @@ void GPU_select_to_index_array(unsigned int *col, const unsigned int size)
} ((void)0)
if (size > 0) {
- unsigned int i, c;
+ uint i, c;
switch (GPU_color_depth()) {
case 8:
@@ -1360,32 +1360,32 @@ typedef struct {
eGPUAttribMask mask;
/* GL_ENABLE_BIT */
- unsigned int is_blend : 1;
- unsi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list