Cleanup: rename 'ct' to 'len' for gpu
This commit is contained in:
@@ -117,7 +117,7 @@ void GPU_framebuffer_texture_detach_slot(
|
||||
GPU_framebuffer_config_array(*(_fb), config, (sizeof(config) / sizeof(GPUAttachment))); \
|
||||
} while (0)
|
||||
|
||||
void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct);
|
||||
void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len);
|
||||
|
||||
#define GPU_ATTACHMENT_NONE \
|
||||
{.tex = NULL, .layer = -1, .mip = 0}
|
||||
|
||||
@@ -241,7 +241,7 @@ GPUBuiltin GPU_get_material_builtins(GPUMaterial *material);
|
||||
|
||||
void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness);
|
||||
struct GPUUniformBuffer *GPU_material_sss_profile_get(
|
||||
GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile);
|
||||
GPUMaterial *material, int sample_len, struct GPUTexture **tex_profile);
|
||||
|
||||
/* High level functions to create and use GPU materials */
|
||||
GPUMaterial *GPU_material_from_nodetree_find(
|
||||
|
||||
@@ -126,7 +126,7 @@ static void gpu_material_diffuse_get(int UNUSED(nr), float diff[4])
|
||||
|
||||
/* 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_ct)
|
||||
static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_len)
|
||||
{
|
||||
if (buffers->vert_buf == NULL) {
|
||||
/* Initialize vertex buffer */
|
||||
@@ -140,15 +140,15 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v
|
||||
}
|
||||
#if 0
|
||||
buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC);
|
||||
GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct);
|
||||
GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len);
|
||||
}
|
||||
else if (vert_ct != buffers->vert_buf->vertex_len) {
|
||||
GWN_vertbuf_data_resize(buffers->vert_buf, vert_ct);
|
||||
else if (vert_len != buffers->vert_buf->vertex_len) {
|
||||
GWN_vertbuf_data_resize(buffers->vert_buf, vert_len);
|
||||
}
|
||||
#else
|
||||
buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC);
|
||||
}
|
||||
GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct);
|
||||
GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len);
|
||||
#endif
|
||||
return buffers->vert_buf->data != NULL;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex)
|
||||
* Setting GPUAttachment.mip to -1 will leave the texture in this slot.
|
||||
* Setting GPUAttachment.tex to NULL will detach the texture in this slot.
|
||||
**/
|
||||
void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct)
|
||||
void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len)
|
||||
{
|
||||
if (config[0].tex) {
|
||||
BLI_assert(GPU_texture_depth(config[0].tex));
|
||||
@@ -317,7 +317,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *confi
|
||||
}
|
||||
|
||||
int slot = 0;
|
||||
for (int i = 1; i < config_ct; ++i, ++slot) {
|
||||
for (int i = 1; i < config_len; ++i, ++slot) {
|
||||
if (config[i].tex != NULL) {
|
||||
BLI_assert(GPU_texture_depth(config[i].tex) == false);
|
||||
gpu_framebuffer_texture_attach_ex(fb, config[i].tex, slot, config[i].layer, config[i].mip);
|
||||
|
||||
@@ -354,7 +354,7 @@ static float eval_integral(float x0, float x1, short falloff_type, float sharpne
|
||||
#undef INTEGRAL_RESOLUTION
|
||||
|
||||
static void compute_sss_kernel(
|
||||
GPUSssKernelData *kd, float radii[3], int sample_ct, int falloff_type, float sharpness)
|
||||
GPUSssKernelData *kd, float radii[3], int sample_len, int falloff_type, float sharpness)
|
||||
{
|
||||
float rad[3];
|
||||
/* Minimum radius */
|
||||
@@ -390,13 +390,13 @@ static void compute_sss_kernel(
|
||||
}
|
||||
|
||||
/* Compute samples locations on the 1d kernel [-1..1] */
|
||||
sss_calculate_offsets(kd, sample_ct, SSS_EXPONENT);
|
||||
sss_calculate_offsets(kd, sample_len, SSS_EXPONENT);
|
||||
|
||||
/* Weights sum for normalization */
|
||||
float sum[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
||||
/* Compute integral of each sample footprint */
|
||||
for (int i = 0; i < sample_ct; i++) {
|
||||
for (int i = 0; i < sample_len; i++) {
|
||||
float x0, x1;
|
||||
|
||||
if (i == 0) {
|
||||
@@ -406,8 +406,8 @@ static void compute_sss_kernel(
|
||||
x0 = (kd->kernel[i - 1][3] + kd->kernel[i][3]) / 2.0f;
|
||||
}
|
||||
|
||||
if (i == sample_ct - 1) {
|
||||
x1 = kd->kernel[sample_ct - 1][3] + fabsf(kd->kernel[sample_ct - 2][3] - kd->kernel[sample_ct - 1][3]) / 2.0f;
|
||||
if (i == sample_len - 1) {
|
||||
x1 = kd->kernel[sample_len - 1][3] + fabsf(kd->kernel[sample_len - 2][3] - kd->kernel[sample_len - 1][3]) / 2.0f;
|
||||
}
|
||||
else {
|
||||
x1 = (kd->kernel[i][3] + kd->kernel[i + 1][3]) / 2.0f;
|
||||
@@ -428,25 +428,25 @@ static void compute_sss_kernel(
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (sum[i] > 0.0f) {
|
||||
/* Normalize */
|
||||
for (int j = 0; j < sample_ct; j++) {
|
||||
for (int j = 0; j < sample_len; j++) {
|
||||
kd->kernel[j][i] /= sum[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Avoid 0 kernel sum. */
|
||||
kd->kernel[sample_ct / 2][i] = 1.0f;
|
||||
kd->kernel[sample_len / 2][i] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put center sample at the start of the array (to sample first) */
|
||||
float tmpv[4];
|
||||
copy_v4_v4(tmpv, kd->kernel[sample_ct / 2]);
|
||||
for (int i = sample_ct / 2; i > 0; i--) {
|
||||
copy_v4_v4(tmpv, kd->kernel[sample_len / 2]);
|
||||
for (int i = sample_len / 2; i > 0; i--) {
|
||||
copy_v4_v4(kd->kernel[i], kd->kernel[i - 1]);
|
||||
}
|
||||
copy_v4_v4(kd->kernel[0], tmpv);
|
||||
|
||||
kd->samples = sample_ct;
|
||||
kd->samples = sample_len;
|
||||
}
|
||||
|
||||
#define INTEGRAL_RESOLUTION 512
|
||||
@@ -523,12 +523,12 @@ void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], shor
|
||||
}
|
||||
}
|
||||
|
||||
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct, GPUTexture **tex_profile)
|
||||
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_len, GPUTexture **tex_profile)
|
||||
{
|
||||
if (!material->sss_enabled)
|
||||
return NULL;
|
||||
|
||||
if (material->sss_dirty || (material->sss_samples != sample_ct)) {
|
||||
if (material->sss_dirty || (material->sss_samples != sample_len)) {
|
||||
GPUSssKernelData kd;
|
||||
|
||||
float sharpness = material->sss_sharpness;
|
||||
@@ -536,7 +536,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
|
||||
/* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */
|
||||
sharpness *= 0.5f;
|
||||
|
||||
compute_sss_kernel(&kd, material->sss_radii, sample_ct, material->sss_falloff, sharpness);
|
||||
compute_sss_kernel(&kd, material->sss_radii, sample_len, material->sss_falloff, sharpness);
|
||||
|
||||
/* Update / Create UBO */
|
||||
GPU_uniformbuffer_update(material->sss_profile, &kd);
|
||||
@@ -553,7 +553,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
|
||||
|
||||
MEM_freeN(translucence_profile);
|
||||
|
||||
material->sss_samples = sample_ct;
|
||||
material->sss_samples = sample_len;
|
||||
material->sss_dirty = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ finally:
|
||||
static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id)
|
||||
{
|
||||
for (int i = 0; i < fmt->attr_len; i++) {
|
||||
for (uint j = 0; j < fmt->name_ct; j++) {
|
||||
for (uint j = 0; j < fmt->name_len; j++) {
|
||||
if (STREQ(fmt->attribs[i].name[j], id)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user