From 55401fbb3d0daa82c999e388c2b5b87e7113b091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 30 Jul 2020 16:40:20 +0200 Subject: IMB: Refactor util_gpu.c to not expose enum getters This was causing compiler error on MSVC and is not a good idea in general. --- source/blender/blenkernel/intern/image_gpu.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel/intern/image_gpu.c') diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c index 56351a6f93c..e3ed7cdc8de 100644 --- a/source/blender/blenkernel/intern/image_gpu.c +++ b/source/blender/blenkernel/intern/image_gpu.c @@ -178,12 +178,9 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) } const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH); - eGPUDataFormat data_format; - eGPUTextureFormat tex_format; - IMB_gpu_get_format(main_ibuf, use_high_bitdepth, &data_format, &tex_format); - /* Create Texture. */ - GPUTexture *tex = GPU_texture_create_nD( - arraywidth, arrayheight, arraylayers, 2, NULL, tex_format, data_format, 0, false, NULL); + /* Create Texture without content. */ + GPUTexture *tex = IMB_touch_gpu_texture( + main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth); GPU_texture_bind(tex, 0); @@ -203,20 +200,15 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); if (ibuf) { - const bool needs_scale = (ibuf->x != tilesize[0] || ibuf->y != tilesize[1]); - const bool compress_as_srgb = (tex_format == GPU_SRGB8_A8); const bool store_premultiplied = ibuf->rect_float ? (ima->alpha_mode != IMA_ALPHA_STRAIGHT) : (ima->alpha_mode == IMA_ALPHA_PREMUL); - bool freebuf = false; - - void *pixeldata = IMB_gpu_get_data( - ibuf, needs_scale, tilesize, compress_as_srgb, store_premultiplied, &freebuf); - GPU_texture_update_sub( - tex, data_format, pixeldata, UNPACK2(tileoffset), tilelayer, UNPACK2(tilesize), 1); - - if (freebuf) { - MEM_SAFE_FREE(pixeldata); - } + IMB_update_gpu_texture_sub(tex, + ibuf, + UNPACK2(tileoffset), + tilelayer, + UNPACK2(tilesize), + use_high_bitdepth, + store_premultiplied); } BKE_image_release_ibuf(ima, ibuf, NULL); -- cgit v1.2.3