Cleanup: use 'num' / 'size' suffix instead of 'sz'
GPU code used `sz` as an abbreviation for size, as well as a few other places. Use size where this represents a size in bytes, see: T85728.
This commit is contained in:
@@ -502,13 +502,13 @@ BlendThumbnail *BKE_main_thumbnail_from_imbuf(Main *bmain, ImBuf *img)
|
||||
}
|
||||
|
||||
if (img) {
|
||||
const size_t sz = BLEN_THUMB_MEMSIZE(img->x, img->y);
|
||||
data = MEM_mallocN(sz, __func__);
|
||||
const size_t data_size = BLEN_THUMB_MEMSIZE(img->x, img->y);
|
||||
data = MEM_mallocN(data_size, __func__);
|
||||
|
||||
IMB_rect_from_float(img); /* Just in case... */
|
||||
data->width = img->x;
|
||||
data->height = img->y;
|
||||
memcpy(data->rect, img->rect, sz - sizeof(*data));
|
||||
memcpy(data->rect, img->rect, data_size - sizeof(*data));
|
||||
}
|
||||
|
||||
if (bmain) {
|
||||
|
||||
@@ -178,7 +178,7 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries);
|
||||
* Convert given entry's size into human-readable strings.
|
||||
*/
|
||||
void BLI_filelist_entry_size_to_string(const struct stat *st,
|
||||
uint64_t sz,
|
||||
uint64_t st_size_fallback,
|
||||
bool compact,
|
||||
char r_size[FILELIST_DIRENTRY_SIZE_LEN]);
|
||||
/**
|
||||
|
||||
@@ -237,7 +237,7 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_
|
||||
}
|
||||
|
||||
void BLI_filelist_entry_size_to_string(const struct stat *st,
|
||||
const uint64_t sz,
|
||||
const uint64_t st_size_fallback,
|
||||
/* Used to change MB -> M, etc. - is that really useful? */
|
||||
const bool UNUSED(compact),
|
||||
char r_size[FILELIST_DIRENTRY_SIZE_LEN])
|
||||
@@ -247,7 +247,7 @@ void BLI_filelist_entry_size_to_string(const struct stat *st,
|
||||
* will buy us some time until files get bigger than 4GB or until
|
||||
* everyone starts using __USE_FILE_OFFSET64 or equivalent.
|
||||
*/
|
||||
double size = (double)(st ? st->st_size : sz);
|
||||
double size = (double)(st ? st->st_size : st_size_fallback);
|
||||
#ifdef WIN32
|
||||
BLI_str_format_byte_unit(r_size, size, false);
|
||||
#else
|
||||
|
||||
@@ -57,23 +57,23 @@ static void str_ghash_tests(GHash *ghash, const char *id)
|
||||
printf("\n========== STARTING %s ==========\n", id);
|
||||
|
||||
#ifdef TEXT_CORPUS_PATH
|
||||
size_t sz = 0;
|
||||
size_t data_size = 0;
|
||||
char *data;
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(TEXT_CORPUS_PATH, &st) == 0)
|
||||
sz = st.st_size;
|
||||
data_size = st.st_size;
|
||||
}
|
||||
if (sz != 0) {
|
||||
if (data_size != 0) {
|
||||
FILE *f = fopen(TEXT_CORPUS_PATH, "r");
|
||||
|
||||
data = (char *)MEM_mallocN(sz + 1, __func__);
|
||||
if (fread(data, sizeof(*data), sz, f) != sz) {
|
||||
data = (char *)MEM_mallocN(data_size + 1, __func__);
|
||||
if (fread(data, sizeof(*data), data_size, f) != data_size) {
|
||||
printf("ERROR in reading file %s!", TEXT_CORPUS_PATH);
|
||||
MEM_freeN(data);
|
||||
data = BLI_strdup(words10k);
|
||||
}
|
||||
data[sz] = '\0';
|
||||
data[data_size] = '\0';
|
||||
fclose(f);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1477,14 +1477,14 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
|
||||
const int width = fd_data[0];
|
||||
const int height = fd_data[1];
|
||||
if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
|
||||
const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
|
||||
data = MEM_mallocN(sz, __func__);
|
||||
const size_t data_size = BLEN_THUMB_MEMSIZE(width, height);
|
||||
data = MEM_mallocN(data_size, __func__);
|
||||
if (data) {
|
||||
BLI_assert((sz - sizeof(*data)) ==
|
||||
BLI_assert((data_size - sizeof(*data)) ==
|
||||
(BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*fd_data) * 2)));
|
||||
data->width = width;
|
||||
data->height = height;
|
||||
memcpy(data->rect, &fd_data[2], sz - sizeof(*data));
|
||||
memcpy(data->rect, &fd_data[2], data_size - sizeof(*data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3857,14 +3857,14 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
|
||||
const int width = data[0];
|
||||
const int height = data[1];
|
||||
if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
|
||||
const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
|
||||
bfd->main->blen_thumb = MEM_mallocN(sz, __func__);
|
||||
const size_t data_size = BLEN_THUMB_MEMSIZE(width, height);
|
||||
bfd->main->blen_thumb = MEM_mallocN(data_size, __func__);
|
||||
|
||||
BLI_assert((sz - sizeof(*bfd->main->blen_thumb)) ==
|
||||
BLI_assert((data_size - sizeof(*bfd->main->blen_thumb)) ==
|
||||
(BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*data) * 2)));
|
||||
bfd->main->blen_thumb->width = width;
|
||||
bfd->main->blen_thumb->height = height;
|
||||
memcpy(bfd->main->blen_thumb->rect, &data[2], sz - sizeof(*bfd->main->blen_thumb));
|
||||
memcpy(bfd->main->blen_thumb->rect, &data[2], data_size - sizeof(*bfd->main->blen_thumb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
|
||||
double *X, *Y, *W;
|
||||
const unsigned int src_width = src->get_width();
|
||||
const unsigned int src_height = src->get_height();
|
||||
unsigned int x, y, sz;
|
||||
unsigned int x, y, src_dim_max;
|
||||
unsigned int i;
|
||||
float *buffer = src->get_buffer();
|
||||
const uint8_t num_channels = src->get_num_channels();
|
||||
@@ -202,10 +202,10 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
|
||||
(void)0
|
||||
|
||||
/* Intermediate buffers. */
|
||||
sz = MAX2(src_width, src_height);
|
||||
X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
|
||||
Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
|
||||
W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
|
||||
src_dim_max = MAX2(src_width, src_height);
|
||||
X = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss X buf");
|
||||
Y = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss Y buf");
|
||||
W = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss W buf");
|
||||
if (xy & 1) { /* H. */
|
||||
int offset;
|
||||
for (y = 0; y < src_height; y++) {
|
||||
|
||||
@@ -168,11 +168,11 @@ void draw_keyframe_shape(float x,
|
||||
/* Common attributes shared between the draw calls. */
|
||||
typedef struct DrawKeylistUIData {
|
||||
float alpha;
|
||||
float icon_sz;
|
||||
float half_icon_sz;
|
||||
float smaller_sz;
|
||||
float ipo_sz;
|
||||
float gpencil_sz;
|
||||
float icon_size;
|
||||
float half_icon_size;
|
||||
float smaller_size;
|
||||
float ipo_size;
|
||||
float gpencil_size;
|
||||
float screenspace_margin;
|
||||
float sel_color[4];
|
||||
float unsel_color[4];
|
||||
@@ -195,11 +195,11 @@ static void draw_keylist_ui_data_init(DrawKeylistUIData *ctx,
|
||||
/* TODO: allow this opacity factor to be themed? */
|
||||
ctx->alpha = channel_locked ? 0.25f : 1.0f;
|
||||
|
||||
ctx->icon_sz = U.widget_unit * 0.5f * yscale_fac;
|
||||
ctx->half_icon_sz = 0.5f * ctx->icon_sz;
|
||||
ctx->smaller_sz = 0.35f * ctx->icon_sz;
|
||||
ctx->ipo_sz = 0.1f * ctx->icon_sz;
|
||||
ctx->gpencil_sz = ctx->smaller_sz * 0.8f;
|
||||
ctx->icon_size = U.widget_unit * 0.5f * yscale_fac;
|
||||
ctx->half_icon_size = 0.5f * ctx->icon_size;
|
||||
ctx->smaller_size = 0.35f * ctx->icon_size;
|
||||
ctx->ipo_size = 0.1f * ctx->icon_size;
|
||||
ctx->gpencil_size = ctx->smaller_size * 0.8f;
|
||||
ctx->screenspace_margin = (0.35f * (float)UI_UNIT_X) / UI_view2d_scale_get_x(v2d);
|
||||
|
||||
ctx->show_ipo = (saction_flag & SACTION_SHOW_INTERPOLATION) != 0;
|
||||
@@ -242,8 +242,8 @@ static void draw_keylist_block_gpencil(const DrawKeylistUIData *ctx,
|
||||
&(const rctf){
|
||||
.xmin = ab->cfra,
|
||||
.xmax = min_ff(ab->next->cfra - (ctx->screenspace_margin * size), ab->next->cfra),
|
||||
.ymin = ypos - ctx->gpencil_sz,
|
||||
.ymax = ypos + ctx->gpencil_sz,
|
||||
.ymin = ypos - ctx->gpencil_size,
|
||||
.ymax = ypos + ctx->gpencil_size,
|
||||
},
|
||||
true,
|
||||
0.25f * (float)UI_UNIT_X,
|
||||
@@ -259,8 +259,8 @@ static void draw_keylist_block_moving_hold(const DrawKeylistUIData *ctx,
|
||||
&(const rctf){
|
||||
.xmin = ab->cfra,
|
||||
.xmax = ab->next->cfra,
|
||||
.ymin = ypos - ctx->smaller_sz,
|
||||
.ymax = ypos + ctx->smaller_sz,
|
||||
.ymin = ypos - ctx->smaller_size,
|
||||
.ymax = ypos + ctx->smaller_size,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
@@ -275,8 +275,8 @@ static void draw_keylist_block_standard(const DrawKeylistUIData *ctx,
|
||||
&(const rctf){
|
||||
.xmin = ab->cfra,
|
||||
.xmax = ab->next->cfra,
|
||||
.ymin = ypos - ctx->half_icon_sz,
|
||||
.ymax = ypos + ctx->half_icon_sz,
|
||||
.ymin = ypos - ctx->half_icon_size,
|
||||
.ymax = ypos + ctx->half_icon_size,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
@@ -291,8 +291,8 @@ static void draw_keylist_block_interpolation_line(const DrawKeylistUIData *ctx,
|
||||
&(const rctf){
|
||||
.xmin = ab->cfra,
|
||||
.xmax = ab->next->cfra,
|
||||
.ymin = ypos - ctx->ipo_sz,
|
||||
.ymax = ypos + ctx->ipo_sz,
|
||||
.ymin = ypos - ctx->ipo_size,
|
||||
.ymax = ypos + ctx->ipo_size,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
@@ -367,7 +367,7 @@ static void draw_keylist_keys(const DrawKeylistUIData *ctx,
|
||||
|
||||
draw_keyframe_shape(ak->cfra,
|
||||
ypos,
|
||||
ctx->icon_sz,
|
||||
ctx->icon_size,
|
||||
(ak->sel & SELECT),
|
||||
ak->key_type,
|
||||
KEYFRAME_SHAPE_BOTH,
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef struct GPUVertAttr {
|
||||
/* 1 to 4 or 8 or 12 or 16 */
|
||||
uint comp_len : 5;
|
||||
/* size in bytes, 1 to 64 */
|
||||
uint sz : 7;
|
||||
uint size : 7;
|
||||
/* from beginning of vertex, in bytes */
|
||||
uint offset : 11;
|
||||
/* up to GPU_VERT_ATTR_MAX_NAMES */
|
||||
|
||||
@@ -50,11 +50,11 @@ void GPU_debug_get_groups_names(int name_buf_len, char *r_name_buf)
|
||||
r_name_buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
size_t sz = 0;
|
||||
size_t len = 0;
|
||||
for (StringRef &name : stack) {
|
||||
sz += BLI_snprintf_rlen(r_name_buf + sz, name_buf_len - sz, "%s > ", name.data());
|
||||
len += BLI_snprintf_rlen(r_name_buf + len, name_buf_len - len, "%s > ", name.data());
|
||||
}
|
||||
r_name_buf[sz - 3] = '\0';
|
||||
r_name_buf[len - 3] = '\0';
|
||||
}
|
||||
|
||||
bool GPU_debug_group_match(const char *ref)
|
||||
|
||||
@@ -490,7 +490,7 @@ static void immEndVertex() /* and move on to the next vertex */
|
||||
#endif
|
||||
|
||||
uchar *data = imm->vertex_data + a->offset;
|
||||
memcpy(data, data - imm->vertex_format.stride, a->sz);
|
||||
memcpy(data, data - imm->vertex_format.stride, a->size);
|
||||
/* TODO: consolidate copy of adjacent attributes */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void GPU_vertbuf_attr_set(GPUVertBuf *verts_, uint a_idx, uint v_idx, const void
|
||||
BLI_assert(a_idx < format->attr_len);
|
||||
BLI_assert(verts->data != nullptr);
|
||||
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
|
||||
memcpy(verts->data + a->offset + v_idx * format->stride, data, a->sz);
|
||||
memcpy(verts->data + a->offset + v_idx * format->stride, data, a->size);
|
||||
}
|
||||
|
||||
void GPU_vertbuf_attr_fill(GPUVertBuf *verts_, uint a_idx, const void *data)
|
||||
@@ -208,7 +208,7 @@ void GPU_vertbuf_attr_fill(GPUVertBuf *verts_, uint a_idx, const void *data)
|
||||
const GPUVertFormat *format = &verts->format;
|
||||
BLI_assert(a_idx < format->attr_len);
|
||||
const GPUVertAttr *a = &format->attrs[a_idx];
|
||||
const uint stride = a->sz; /* tightly packed input data */
|
||||
const uint stride = a->size; /* tightly packed input data */
|
||||
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
|
||||
GPU_vertbuf_attr_fill_stride(verts_, a_idx, stride, data);
|
||||
}
|
||||
@@ -235,13 +235,13 @@ void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts_, uint a_idx, uint stride, c
|
||||
|
||||
if (format->attr_len == 1 && stride == format->stride) {
|
||||
/* we can copy it all at once */
|
||||
memcpy(verts->data, data, vertex_len * a->sz);
|
||||
memcpy(verts->data, data, vertex_len * a->size);
|
||||
}
|
||||
else {
|
||||
/* we must copy it per vertex */
|
||||
for (uint v = 0; v < vertex_len; v++) {
|
||||
memcpy(
|
||||
verts->data + a->offset + v * format->stride, (const uchar *)data + v * stride, a->sz);
|
||||
verts->data + a->offset + v * format->stride, (const uchar *)data + v * stride, a->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts_, uint a_idx, GPUVertBufRaw
|
||||
|
||||
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
|
||||
verts->flag &= ~GPU_VERTBUF_DATA_UPLOADED;
|
||||
access->size = a->sz;
|
||||
access->size = a->size;
|
||||
access->stride = format->stride;
|
||||
access->data = (uchar *)verts->data + a->offset;
|
||||
access->data_init = access->data;
|
||||
|
||||
@@ -49,7 +49,7 @@ void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src)
|
||||
memcpy(dest, src, sizeof(GPUVertFormat));
|
||||
}
|
||||
|
||||
static uint comp_sz(GPUVertCompType type)
|
||||
static uint comp_size(GPUVertCompType type)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */
|
||||
@@ -58,12 +58,12 @@ static uint comp_sz(GPUVertCompType type)
|
||||
return sizes[type];
|
||||
}
|
||||
|
||||
static uint attr_sz(const GPUVertAttr *a)
|
||||
static uint attr_size(const GPUVertAttr *a)
|
||||
{
|
||||
if (a->comp_type == GPU_COMP_I10) {
|
||||
return 4; /* always packed as 10_10_10_2 */
|
||||
}
|
||||
return a->comp_len * comp_sz(static_cast<GPUVertCompType>(a->comp_type));
|
||||
return a->comp_len * comp_size(static_cast<GPUVertCompType>(a->comp_type));
|
||||
}
|
||||
|
||||
static uint attr_align(const GPUVertAttr *a)
|
||||
@@ -71,7 +71,7 @@ static uint attr_align(const GPUVertAttr *a)
|
||||
if (a->comp_type == GPU_COMP_I10) {
|
||||
return 4; /* always packed as 10_10_10_2 */
|
||||
}
|
||||
uint c = comp_sz(static_cast<GPUVertCompType>(a->comp_type));
|
||||
uint c = comp_size(static_cast<GPUVertCompType>(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?) */
|
||||
}
|
||||
@@ -156,7 +156,7 @@ uint GPU_vertformat_attr_add(GPUVertFormat *format,
|
||||
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->size = attr_size(attr);
|
||||
attr->offset = 0; /* offsets & stride are calculated later (during pack) */
|
||||
attr->fetch_mode = fetch_mode;
|
||||
|
||||
@@ -294,13 +294,13 @@ uint padding(uint offset, uint alignment)
|
||||
}
|
||||
|
||||
#if PACK_DEBUG
|
||||
static void show_pack(uint a_idx, uint sz, uint pad)
|
||||
static void show_pack(uint a_idx, uint size, uint pad)
|
||||
{
|
||||
const char c = 'A' + a_idx;
|
||||
for (uint i = 0; i < pad; i++) {
|
||||
putchar('-');
|
||||
}
|
||||
for (uint i = 0; i < sz; i++) {
|
||||
for (uint i = 0; i < size; i++) {
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
@@ -310,10 +310,10 @@ void VertexFormat_pack(GPUVertFormat *format)
|
||||
{
|
||||
GPUVertAttr *a0 = &format->attrs[0];
|
||||
a0->offset = 0;
|
||||
uint offset = a0->sz;
|
||||
uint offset = a0->size;
|
||||
|
||||
#if PACK_DEBUG
|
||||
show_pack(0, a0->sz, 0);
|
||||
show_pack(0, a0->size, 0);
|
||||
#endif
|
||||
|
||||
for (uint a_idx = 1; a_idx < format->attr_len; a_idx++) {
|
||||
@@ -321,10 +321,10 @@ void VertexFormat_pack(GPUVertFormat *format)
|
||||
uint mid_padding = padding(offset, attr_align(a));
|
||||
offset += mid_padding;
|
||||
a->offset = offset;
|
||||
offset += a->sz;
|
||||
offset += a->size;
|
||||
|
||||
#if PACK_DEBUG
|
||||
show_pack(a_idx, a->sz, mid_padding);
|
||||
show_pack(a_idx, a->size, mid_padding);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ static uint16_t vbo_bind(const ShaderInterface *interface,
|
||||
const GPUVertAttr *a = &format->attrs[a_idx];
|
||||
|
||||
if (format->deinterleaved) {
|
||||
offset += ((a_idx == 0) ? 0 : format->attrs[a_idx - 1].sz) * v_len;
|
||||
stride = a->sz;
|
||||
offset += ((a_idx == 0) ? 0 : format->attrs[a_idx - 1].size) * v_len;
|
||||
stride = a->size;
|
||||
}
|
||||
else {
|
||||
offset = a->offset;
|
||||
|
||||
@@ -49,7 +49,7 @@ static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, sh
|
||||
}
|
||||
}
|
||||
|
||||
static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread)
|
||||
static void tex_input(float *out, int num, bNodeStack *in, TexParams *params, short thread)
|
||||
{
|
||||
TexDelegate *dg = in->data;
|
||||
if (dg) {
|
||||
@@ -59,7 +59,7 @@ static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, sho
|
||||
in->vec[1] = in->vec[2] = in->vec[0];
|
||||
}
|
||||
}
|
||||
memcpy(out, in->vec, sz * sizeof(float));
|
||||
memcpy(out, in->vec, num * sizeof(float));
|
||||
}
|
||||
|
||||
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
|
||||
|
||||
Reference in New Issue
Block a user