Cleanup: Remove unused r_data_format parameter
The r_data_format parameter from imb_gpu_get_format is always ignored or overwritten by the r_data_format parameter from imb_gpu_get_data. It makes more sense to just use the result from the imb_gpu_get_data function for to determine the data format. Pull Request: https://projects.blender.org/blender/blender/pulls/114662
This commit is contained in:
@@ -59,7 +59,6 @@ static bool imb_is_grayscale_texture_format_compatible(const ImBuf *ibuf)
|
||||
static void imb_gpu_get_format(const ImBuf *ibuf,
|
||||
bool high_bitdepth,
|
||||
bool use_grayscale,
|
||||
eGPUDataFormat *r_data_format,
|
||||
eGPUTextureFormat *r_texture_format)
|
||||
{
|
||||
const bool float_rect = (ibuf->float_buffer.data != nullptr);
|
||||
@@ -68,7 +67,6 @@ static void imb_gpu_get_format(const ImBuf *ibuf,
|
||||
if (float_rect) {
|
||||
/* Float. */
|
||||
const bool use_high_bitdepth = (!(ibuf->flags & IB_halffloat) && high_bitdepth);
|
||||
*r_data_format = GPU_DATA_FLOAT;
|
||||
*r_texture_format = is_grayscale ? (use_high_bitdepth ? GPU_R32F : GPU_R16F) :
|
||||
(use_high_bitdepth ? GPU_RGBA32F : GPU_RGBA16F);
|
||||
}
|
||||
@@ -77,17 +75,14 @@ static void imb_gpu_get_format(const ImBuf *ibuf,
|
||||
IMB_colormanagement_space_is_scene_linear(ibuf->byte_buffer.colorspace))
|
||||
{
|
||||
/* Non-color data or scene linear, just store buffer as is. */
|
||||
*r_data_format = GPU_DATA_UBYTE;
|
||||
*r_texture_format = (is_grayscale) ? GPU_R8 : GPU_RGBA8;
|
||||
}
|
||||
else if (IMB_colormanagement_space_is_srgb(ibuf->byte_buffer.colorspace)) {
|
||||
/* sRGB, store as byte texture that the GPU can decode directly. */
|
||||
*r_data_format = (is_grayscale) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;
|
||||
*r_texture_format = (is_grayscale) ? GPU_R16F : GPU_SRGB8_A8;
|
||||
}
|
||||
else {
|
||||
/* Other colorspace, store as half float texture to avoid precision loss. */
|
||||
*r_data_format = GPU_DATA_FLOAT;
|
||||
*r_texture_format = (is_grayscale) ? GPU_R16F : GPU_RGBA16F;
|
||||
}
|
||||
}
|
||||
@@ -269,9 +264,8 @@ GPUTexture *IMB_touch_gpu_texture(const char *name,
|
||||
bool use_high_bitdepth,
|
||||
bool use_grayscale)
|
||||
{
|
||||
eGPUDataFormat data_format;
|
||||
eGPUTextureFormat tex_format;
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, use_grayscale, &data_format, &tex_format);
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, use_grayscale, &tex_format);
|
||||
|
||||
GPUTexture *tex;
|
||||
if (layers > 0) {
|
||||
@@ -314,12 +308,12 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex,
|
||||
const bool do_rescale = (ibuf->x != w || ibuf->y != h);
|
||||
const int size[2] = {w, h};
|
||||
|
||||
eGPUDataFormat data_format;
|
||||
eGPUTextureFormat tex_format;
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, use_grayscale, &data_format, &tex_format);
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, use_grayscale, &tex_format);
|
||||
|
||||
bool freebuf = false;
|
||||
|
||||
eGPUDataFormat data_format;
|
||||
void *data = imb_gpu_get_data(ibuf, do_rescale, size, use_premult, &freebuf, &data_format);
|
||||
|
||||
/* Update Texture. */
|
||||
@@ -379,9 +373,8 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
|
||||
fprintf(stderr, " falling back to uncompressed.\n");
|
||||
}
|
||||
|
||||
eGPUDataFormat data_format;
|
||||
eGPUTextureFormat tex_format;
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, true, &data_format, &tex_format);
|
||||
imb_gpu_get_format(ibuf, use_high_bitdepth, true, &tex_format);
|
||||
|
||||
bool freebuf = false;
|
||||
|
||||
@@ -404,6 +397,7 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
|
||||
do_rescale = true;
|
||||
}
|
||||
BLI_assert(tex != nullptr);
|
||||
eGPUDataFormat data_format;
|
||||
void *data = imb_gpu_get_data(ibuf, do_rescale, size, use_premult, &freebuf, &data_format);
|
||||
GPU_texture_update(tex, data_format, data);
|
||||
|
||||
@@ -422,10 +416,7 @@ eGPUTextureFormat IMB_gpu_get_texture_format(const ImBuf *ibuf,
|
||||
bool use_grayscale)
|
||||
{
|
||||
eGPUTextureFormat gpu_texture_format;
|
||||
eGPUDataFormat gpu_data_format;
|
||||
|
||||
imb_gpu_get_format(ibuf, high_bitdepth, use_grayscale, &gpu_data_format, &gpu_texture_format);
|
||||
|
||||
imb_gpu_get_format(ibuf, high_bitdepth, use_grayscale, &gpu_texture_format);
|
||||
return gpu_texture_format;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user