Cleanup: use uint/uchar types in GPU
This commit is contained in:
parent
baca8344d9
commit
7eecc94074
|
@ -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__ */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
unsigned int is_cull_face : 1;
|
||||
unsigned int is_depth_test : 1;
|
||||
unsigned int is_dither : 1;
|
||||
unsigned int is_lighting : 1;
|
||||
unsigned int is_line_smooth : 1;
|
||||
unsigned int is_color_logic_op : 1;
|
||||
unsigned int is_multisample : 1;
|
||||
unsigned int is_polygon_offset_line : 1;
|
||||
unsigned int is_polygon_offset_fill : 1;
|
||||
unsigned int is_polygon_smooth : 1;
|
||||
unsigned int is_sample_alpha_to_coverage : 1;
|
||||
unsigned int is_scissor_test : 1;
|
||||
unsigned int is_stencil_test : 1;
|
||||
uint is_blend : 1;
|
||||
uint is_cull_face : 1;
|
||||
uint is_depth_test : 1;
|
||||
uint is_dither : 1;
|
||||
uint is_lighting : 1;
|
||||
uint is_line_smooth : 1;
|
||||
uint is_color_logic_op : 1;
|
||||
uint is_multisample : 1;
|
||||
uint is_polygon_offset_line : 1;
|
||||
uint is_polygon_offset_fill : 1;
|
||||
uint is_polygon_smooth : 1;
|
||||
uint is_sample_alpha_to_coverage : 1;
|
||||
uint is_scissor_test : 1;
|
||||
uint is_stencil_test : 1;
|
||||
|
||||
bool is_clip_plane[6];
|
||||
|
||||
/* GL_DEPTH_BUFFER_BIT */
|
||||
/* unsigned int is_depth_test : 1; */
|
||||
/* uint is_depth_test : 1; */
|
||||
int depth_func;
|
||||
double depth_clear_value;
|
||||
bool depth_write_mask;
|
||||
|
||||
/* GL_SCISSOR_BIT */
|
||||
int scissor_box[4];
|
||||
/* unsigned int is_scissor_test : 1; */
|
||||
/* uint is_scissor_test : 1; */
|
||||
|
||||
/* GL_VIEWPORT_BIT */
|
||||
int viewport[4];
|
||||
|
@ -1394,7 +1394,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
GPUAttribValues attrib_stack[STATE_STACK_DEPTH];
|
||||
unsigned int top;
|
||||
uint top;
|
||||
} GPUAttribStack;
|
||||
|
||||
static GPUAttribStack state = {
|
||||
|
|
|
@ -487,7 +487,7 @@ void GPU_framebuffer_viewport_set(GPUFrameBuffer *fb, int x, int y, int w, int h
|
|||
|
||||
void GPU_framebuffer_clear(
|
||||
GPUFrameBuffer *fb, GPUFrameBufferBits buffers,
|
||||
const float clear_col[4], float clear_depth, unsigned int clear_stencil)
|
||||
const float clear_col[4], float clear_depth, uint clear_stencil)
|
||||
{
|
||||
CHECK_FRAMEBUFFER_IS_BOUND(fb);
|
||||
|
||||
|
|
|
@ -558,7 +558,7 @@ void immAttrib4fv(uint attrib_id, const float data[4])
|
|||
immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
|
||||
}
|
||||
|
||||
void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b)
|
||||
void immAttrib3ub(uint attrib_id, uchar r, uchar g, uchar b)
|
||||
{
|
||||
GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
|
||||
#if TRUST_NO_ONE
|
||||
|
@ -578,7 +578,7 @@ void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha
|
|||
data[2] = b;
|
||||
}
|
||||
|
||||
void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
void immAttrib4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
|
||||
{
|
||||
GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
|
||||
#if TRUST_NO_ONE
|
||||
|
@ -599,12 +599,12 @@ void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha
|
|||
data[3] = a;
|
||||
}
|
||||
|
||||
void immAttrib3ubv(uint attrib_id, const unsigned char data[3])
|
||||
void immAttrib3ubv(uint attrib_id, const uchar data[3])
|
||||
{
|
||||
immAttrib3ub(attrib_id, data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
void immAttrib4ubv(uint attrib_id, const unsigned char data[4])
|
||||
void immAttrib4ubv(uint attrib_id, const uchar data[4])
|
||||
{
|
||||
immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
|
||||
}
|
||||
|
@ -847,29 +847,29 @@ void immUniformColor3fvAlpha(const float rgb[3], float a)
|
|||
|
||||
/* TODO: v-- treat as sRGB? --v */
|
||||
|
||||
void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
|
||||
void immUniformColor3ub(uchar r, uchar g, uchar b)
|
||||
{
|
||||
const float scale = 1.0f / 255.0f;
|
||||
immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
|
||||
}
|
||||
|
||||
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
void immUniformColor4ub(uchar r, uchar g, uchar b, uchar a)
|
||||
{
|
||||
const float scale = 1.0f / 255.0f;
|
||||
immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
|
||||
}
|
||||
|
||||
void immUniformColor3ubv(const unsigned char rgb[3])
|
||||
void immUniformColor3ubv(const uchar rgb[3])
|
||||
{
|
||||
immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
|
||||
void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha)
|
||||
void immUniformColor3ubvAlpha(const uchar rgb[3], uchar alpha)
|
||||
{
|
||||
immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
|
||||
}
|
||||
|
||||
void immUniformColor4ubv(const unsigned char rgba[4])
|
||||
void immUniformColor4ubv(const uchar rgba[4])
|
||||
{
|
||||
immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ void immUniformThemeColorBlend(int color_id1, int color_id2, float fac)
|
|||
|
||||
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
|
||||
{
|
||||
unsigned char col[4];
|
||||
uchar col[4];
|
||||
UI_GetThemeColorShadeAlpha4ubv(colorid, coloffset, alphaoffset, col);
|
||||
immUniformColor4ub(col[0], col[1], col[2], col[3]);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
|
|||
*
|
||||
* \param x color.
|
||||
*/
|
||||
void imm_cpack(unsigned int x)
|
||||
void imm_cpack(uint x)
|
||||
{
|
||||
immUniformColor3ub(((x) & 0xFF),
|
||||
(((x) >> 8) & 0xFF),
|
||||
|
@ -205,7 +205,7 @@ void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x
|
|||
* \note We could have `imm_draw_lined_disk_partial` but currently there is no need.
|
||||
*/
|
||||
static void imm_draw_disk_partial(
|
||||
GPUPrimType prim_type, unsigned pos, float x, float y,
|
||||
GPUPrimType prim_type, uint pos, float x, float y,
|
||||
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
|
||||
{
|
||||
/* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
|
||||
|
@ -239,14 +239,14 @@ static void imm_draw_disk_partial(
|
|||
* \param sweep: Specifies the sweep angle, in degrees, of the disk portion.
|
||||
*/
|
||||
void imm_draw_disk_partial_fill_2d(
|
||||
unsigned pos, float x, float y,
|
||||
uint pos, float x, float y,
|
||||
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
|
||||
{
|
||||
imm_draw_disk_partial(GPU_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
|
||||
}
|
||||
|
||||
static void imm_draw_circle_3D(
|
||||
GPUPrimType prim_type, unsigned pos, float x, float y,
|
||||
GPUPrimType prim_type, uint pos, float x, float y,
|
||||
float rad, int nsegments)
|
||||
{
|
||||
immBegin(prim_type, nsegments);
|
||||
|
@ -257,12 +257,12 @@ static void imm_draw_circle_3D(
|
|||
immEnd();
|
||||
}
|
||||
|
||||
void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments)
|
||||
void imm_draw_circle_wire_3d(uint pos, float x, float y, float rad, int nsegments)
|
||||
{
|
||||
imm_draw_circle_3D(GPU_PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
|
||||
}
|
||||
|
||||
void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments)
|
||||
void imm_draw_circle_fill_3d(uint pos, float x, float y, float rad, int nsegments)
|
||||
{
|
||||
imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, rad, nsegments);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nseg
|
|||
* \param x2 right.
|
||||
* \param y2 top.
|
||||
*/
|
||||
void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2)
|
||||
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
immBegin(GPU_PRIM_LINE_LOOP, 4);
|
||||
immVertex2f(pos, x1, y1);
|
||||
|
@ -286,7 +286,7 @@ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2)
|
|||
immEnd();
|
||||
}
|
||||
|
||||
void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2)
|
||||
void imm_draw_box_wire_3d(uint pos, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
/* use this version when GPUVertFormat has a vec3 position */
|
||||
immBegin(GPU_PRIM_LINE_LOOP, 4);
|
||||
|
@ -364,7 +364,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
|
|||
* \param stacks Specifies the number of subdivisions along the z axis.
|
||||
*/
|
||||
void imm_draw_cylinder_fill_normal_3d(
|
||||
unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
|
||||
uint pos, uint nor, float base, float top, float height, int slices, int stacks)
|
||||
{
|
||||
immBegin(GPU_PRIM_TRIS, 6 * slices * stacks);
|
||||
for (int i = 0; i < slices; ++i) {
|
||||
|
@ -415,7 +415,7 @@ void imm_draw_cylinder_fill_normal_3d(
|
|||
immEnd();
|
||||
}
|
||||
|
||||
void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
|
||||
void imm_draw_cylinder_wire_3d(uint pos, float base, float top, float height, int slices, int stacks)
|
||||
{
|
||||
immBegin(GPU_PRIM_LINES, 6 * slices * stacks);
|
||||
for (int i = 0; i < slices; ++i) {
|
||||
|
@ -452,7 +452,7 @@ void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float he
|
|||
immEnd();
|
||||
}
|
||||
|
||||
void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
|
||||
void imm_draw_cylinder_fill_3d(uint pos, float base, float top, float height, int slices, int stacks)
|
||||
{
|
||||
immBegin(GPU_PRIM_TRIS, 6 * slices * stacks);
|
||||
for (int i = 0; i < slices; ++i) {
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef float Mat3[3][3];
|
|||
|
||||
typedef struct MatrixStack {
|
||||
Mat4 stack[MATRIX_STACK_DEPTH];
|
||||
unsigned int top;
|
||||
uint top;
|
||||
} MatrixStack;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#define __GPU_SELECT_PRIVATE_H__
|
||||
|
||||
/* gpu_select_pick */
|
||||
void gpu_select_pick_begin(unsigned int (*buffer)[4], unsigned int bufsize, const rcti *input, char mode);
|
||||
bool gpu_select_pick_load_id(unsigned int id);
|
||||
unsigned int gpu_select_pick_end(void);
|
||||
void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode);
|
||||
bool gpu_select_pick_load_id(uint id);
|
||||
uint gpu_select_pick_end(void);
|
||||
|
||||
void gpu_select_pick_cache_begin(void);
|
||||
void gpu_select_pick_cache_end(void);
|
||||
|
@ -43,11 +43,11 @@ bool gpu_select_pick_is_cached(void);
|
|||
void gpu_select_pick_cache_load_id(void);
|
||||
|
||||
/* gpu_select_sample_query */
|
||||
void gpu_select_query_begin(unsigned int (*buffer)[4], unsigned int bufsize, const rcti *input, char mode, int oldhits);
|
||||
bool gpu_select_query_load_id(unsigned int id);
|
||||
unsigned int gpu_select_query_end(void);
|
||||
void gpu_select_query_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode, int oldhits);
|
||||
bool gpu_select_query_load_id(uint id);
|
||||
uint gpu_select_query_end(void);
|
||||
|
||||
|
||||
#define SELECT_ID_NONE ((unsigned int)0xffffffff)
|
||||
#define SELECT_ID_NONE ((uint)0xffffffff)
|
||||
|
||||
#endif /* __GPU_SELECT_PRIVATE_H__ */
|
||||
|
|
|
@ -582,7 +582,7 @@ void GPU_shader_unbind(void)
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
bool GPU_shader_transform_feedback_enable(GPUShader *shader, unsigned int vbo_id)
|
||||
bool GPU_shader_transform_feedback_enable(GPUShader *shader, uint vbo_id)
|
||||
{
|
||||
if (shader->feedback_transform_type == GPU_SHADER_TFB_NONE) {
|
||||
return false;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct GPUTexture {
|
|||
GPUTextureFormat format;
|
||||
GPUTextureFormatFlag format_flag;
|
||||
|
||||
unsigned int bytesize; /* number of byte for one pixel */
|
||||
uint bytesize; /* number of byte for one pixel */
|
||||
int components; /* number of color/alpha channels */
|
||||
int samples; /* number of samples for multisamples textures. 0 if not multisample target */
|
||||
|
||||
|
@ -94,9 +94,9 @@ struct GPUTexture {
|
|||
/* ------ Memory Management ------- */
|
||||
/* Records every texture allocation / free
|
||||
* to estimate the Texture Pool Memory consumption */
|
||||
static unsigned int memory_usage;
|
||||
static uint memory_usage;
|
||||
|
||||
static unsigned int gpu_texture_memory_footprint_compute(GPUTexture *tex)
|
||||
static uint gpu_texture_memory_footprint_compute(GPUTexture *tex)
|
||||
{
|
||||
int samp = max_ii(tex->samples, 1);
|
||||
switch (tex->target) {
|
||||
|
@ -127,7 +127,7 @@ static void gpu_texture_memory_footprint_remove(GPUTexture *tex)
|
|||
memory_usage -= gpu_texture_memory_footprint_compute(tex);
|
||||
}
|
||||
|
||||
unsigned int GPU_texture_memory_usage_get(void)
|
||||
uint GPU_texture_memory_usage_get(void)
|
||||
{
|
||||
return memory_usage;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ static GLenum gpu_get_gl_dataformat(GPUTextureFormat data_type, GPUTextureFormat
|
|||
return GL_RGBA;
|
||||
}
|
||||
|
||||
static unsigned int gpu_get_bytesize(GPUTextureFormat data_type)
|
||||
static uint gpu_get_bytesize(GPUTextureFormat data_type)
|
||||
{
|
||||
switch (data_type) {
|
||||
case GPU_RGBA32F:
|
||||
|
@ -384,22 +384,22 @@ static GLenum gpu_get_gl_datatype(GPUDataFormat format)
|
|||
|
||||
static float *GPU_texture_3D_rescale(GPUTexture *tex, int w, int h, int d, int channels, const float *fpixels)
|
||||
{
|
||||
const unsigned int xf = w / tex->w, yf = h / tex->h, zf = d / tex->d;
|
||||
const uint xf = w / tex->w, yf = h / tex->h, zf = d / tex->d;
|
||||
float *nfpixels = MEM_mallocN(channels * sizeof(float) * tex->w * tex->h * tex->d, "GPUTexture Rescaled 3Dtex");
|
||||
|
||||
if (nfpixels) {
|
||||
GPU_print_error_debug("You need to scale a 3D texture, feel the pain!");
|
||||
|
||||
for (unsigned k = 0; k < tex->d; k++) {
|
||||
for (unsigned j = 0; j < tex->h; j++) {
|
||||
for (unsigned i = 0; i < tex->w; i++) {
|
||||
for (uint k = 0; k < tex->d; k++) {
|
||||
for (uint j = 0; j < tex->h; j++) {
|
||||
for (uint i = 0; i < tex->w; i++) {
|
||||
/* obviously doing nearest filtering here,
|
||||
* it's going to be slow in any case, let's not make it worse */
|
||||
float xb = i * xf;
|
||||
float yb = j * yf;
|
||||
float zb = k * zf;
|
||||
unsigned int offset = k * (tex->w * tex->h) + i * tex->h + j;
|
||||
unsigned int offset_orig = (zb) * (w * h) + (xb) * h + (yb);
|
||||
uint offset = k * (tex->w * tex->h) + i * tex->h + j;
|
||||
uint offset_orig = (zb) * (w * h) + (xb) * h + (yb);
|
||||
|
||||
if (channels == 4) {
|
||||
nfpixels[offset * 4] = fpixels[offset_orig * 4];
|
||||
|
@ -939,7 +939,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(GPUVertBuf *vert)
|
|||
BLI_assert(attr->comp_type != GPU_COMP_I10);
|
||||
BLI_assert(attr->fetch_mode != GPU_FETCH_INT_TO_FLOAT);
|
||||
|
||||
unsigned int byte_per_comp = attr->sz / attr->comp_len;
|
||||
uint byte_per_comp = attr->sz / attr->comp_len;
|
||||
bool is_uint = ELEM(attr->comp_type, GPU_COMP_U8, GPU_COMP_U16, GPU_COMP_U32);
|
||||
|
||||
/* Cannot fetch signed int or 32bit ints as normalized float. */
|
||||
|
|
|
@ -50,7 +50,7 @@ void GPU_vertformat_clear(GPUVertFormat *format)
|
|||
format->name_offset = 0;
|
||||
format->name_len = 0;
|
||||
|
||||
for (unsigned i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) {
|
||||
for (uint i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) {
|
||||
format->attribs[i].name_len = 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -61,8 +61,8 @@ void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src)
|
|||
/* copy regular struct fields */
|
||||
memcpy(dest, src, sizeof(GPUVertFormat));
|
||||
|
||||
for (unsigned i = 0; i < dest->attr_len; i++) {
|
||||
for (unsigned j = 0; j < dest->attribs[i].name_len; j++) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ static GLenum convert_comp_type_to_gl(GPUVertCompType type)
|
|||
return table[type];
|
||||
}
|
||||
|
||||
static unsigned comp_sz(GPUVertCompType type)
|
||||
static uint comp_sz(GPUVertCompType type)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */
|
||||
|
@ -94,7 +94,7 @@ static unsigned comp_sz(GPUVertCompType type)
|
|||
return sizes[type];
|
||||
}
|
||||
|
||||
static unsigned attrib_sz(const GPUVertAttr *a)
|
||||
static uint attrib_sz(const GPUVertAttr *a)
|
||||
{
|
||||
if (a->comp_type == GPU_COMP_I10) {
|
||||
return 4; /* always packed as 10_10_10_2 */
|
||||
|
@ -102,12 +102,12 @@ static unsigned attrib_sz(const GPUVertAttr *a)
|
|||
return a->comp_len * comp_sz(a->comp_type);
|
||||
}
|
||||
|
||||
static unsigned attrib_align(const GPUVertAttr *a)
|
||||
static uint attrib_align(const GPUVertAttr *a)
|
||||
{
|
||||
if (a->comp_type == GPU_COMP_I10) {
|
||||
return 4; /* always packed as 10_10_10_2 */
|
||||
}
|
||||
unsigned c = comp_sz(a->comp_type);
|
||||
uint c = comp_sz(a->comp_type);
|
||||
if (a->comp_len == 3 && c <= 2) {
|
||||
return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static unsigned attrib_align(const GPUVertAttr *a)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned vertex_buffer_size(const GPUVertFormat *format, unsigned vertex_len)
|
||||
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(format->packed && format->stride > 0);
|
||||
|
@ -128,10 +128,10 @@ static const char *copy_attrib_name(GPUVertFormat *format, const char *name)
|
|||
{
|
||||
/* strncpy does 110% of what we need; let's do exactly 100% */
|
||||
char *name_copy = format->names + format->name_offset;
|
||||
unsigned available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset;
|
||||
uint available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset;
|
||||
bool terminated = false;
|
||||
|
||||
for (unsigned i = 0; i < available; ++i) {
|
||||
for (uint i = 0; i < available; ++i) {
|
||||
const char c = name[i];
|
||||
name_copy[i] = c;
|
||||
if (c == '\0') {
|
||||
|
@ -149,9 +149,9 @@ static const char *copy_attrib_name(GPUVertFormat *format, const char *name)
|
|||
return name_copy;
|
||||
}
|
||||
|
||||
unsigned GPU_vertformat_attr_add(
|
||||
uint GPU_vertformat_attr_add(
|
||||
GPUVertFormat *format, const char *name,
|
||||
GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode)
|
||||
GPUVertCompType comp_type, uint comp_len, GPUVertFetchMode fetch_mode)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */
|
||||
|
@ -179,7 +179,7 @@ unsigned GPU_vertformat_attr_add(
|
|||
#endif
|
||||
format->name_len++; /* multiname support */
|
||||
|
||||
const unsigned attrib_id = format->attr_len++;
|
||||
const uint attrib_id = format->attr_len++;
|
||||
GPUVertAttr *attrib = format->attribs + attrib_id;
|
||||
|
||||
attrib->name[attrib->name_len++] = copy_attrib_name(format, name);
|
||||
|
@ -204,20 +204,20 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias)
|
|||
attrib->name[attrib->name_len++] = copy_attrib_name(format, alias);
|
||||
}
|
||||
|
||||
unsigned padding(unsigned offset, unsigned alignment)
|
||||
uint padding(uint offset, uint alignment)
|
||||
{
|
||||
const unsigned mod = offset % alignment;
|
||||
const uint mod = offset % alignment;
|
||||
return (mod == 0) ? 0 : (alignment - mod);
|
||||
}
|
||||
|
||||
#if PACK_DEBUG
|
||||
static void show_pack(unsigned a_idx, unsigned sz, unsigned pad)
|
||||
static void show_pack(uint a_idx, uint sz, uint pad)
|
||||
{
|
||||
const char c = 'A' + a_idx;
|
||||
for (unsigned i = 0; i < pad; ++i) {
|
||||
for (uint i = 0; i < pad; ++i) {
|
||||
putchar('-');
|
||||
}
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
for (uint i = 0; i < sz; ++i) {
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
@ -235,15 +235,15 @@ void VertexFormat_pack(GPUVertFormat *format)
|
|||
|
||||
GPUVertAttr *a0 = format->attribs + 0;
|
||||
a0->offset = 0;
|
||||
unsigned offset = a0->sz;
|
||||
uint offset = a0->sz;
|
||||
|
||||
#if PACK_DEBUG
|
||||
show_pack(0, a0->sz, 0);
|
||||
#endif
|
||||
|
||||
for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) {
|
||||
for (uint a_idx = 1; a_idx < format->attr_len; ++a_idx) {
|
||||
GPUVertAttr *a = format->attribs + a_idx;
|
||||
unsigned mid_padding = padding(offset, attrib_align(a));
|
||||
uint mid_padding = padding(offset, attrib_align(a));
|
||||
offset += mid_padding;
|
||||
a->offset = offset;
|
||||
offset += a->sz;
|
||||
|
@ -253,7 +253,7 @@ void VertexFormat_pack(GPUVertFormat *format)
|
|||
#endif
|
||||
}
|
||||
|
||||
unsigned end_padding = padding(offset, attrib_align(a0));
|
||||
uint end_padding = padding(offset, attrib_align(a0));
|
||||
|
||||
#if PACK_DEBUG
|
||||
show_pack(0, 0, end_padding);
|
||||
|
|
|
@ -76,7 +76,7 @@ struct GPUViewport {
|
|||
int flag;
|
||||
|
||||
ListBase data; /* ViewportEngineData wrapped in LinkData */
|
||||
unsigned int data_hash; /* If hash mismatch we free all ViewportEngineData in this viewport */
|
||||
uint data_hash; /* If hash mismatch we free all ViewportEngineData in this viewport */
|
||||
|
||||
DefaultFramebufferList *fbl;
|
||||
DefaultTextureList *txl;
|
||||
|
@ -360,7 +360,7 @@ static void gpu_viewport_texture_pool_free(GPUViewport *viewport)
|
|||
BLI_freelistN(&viewport->tex_pool);
|
||||
}
|
||||
|
||||
bool GPU_viewport_engines_data_validate(GPUViewport *viewport, unsigned int hash)
|
||||
bool GPU_viewport_engines_data_validate(GPUViewport *viewport, uint hash)
|
||||
{
|
||||
bool dirty = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue