Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2022-08-23 15:26:01 +0300
committerJeroen Bakker <jeroen@blender.org>2022-08-23 15:35:39 +0300
commit37533cd6cb0fcd6e92906cfcec911330df27f52c (patch)
treeddbf044535261cba972bb32e5e945fdbd608ab76 /source/blender/imbuf/IMB_imbuf.h
parent13b2716e1cf9447ebab2fcd4b157d6d232490334 (diff)
ImBuf: Optimize GPU memory by using 1 component format for grayscale images
This is done by checking the number of bitplanes from the image buffer. We assume that for float buffer to use the same bitplanes as it was a byte buffer. Then, the data of the image buffer is packed at the start of the `rect` or `float_rect` before upload. **Statistics - einar.v004.blend ** Note that not all grayscale textures have been stored as BW images so the amount of memory that can be reduced would be more. Without patch ``` 104 Textures - 3294.99 MB (3294.47 MB over 32x32), 37 RTs - 192.52 MB. Avg. tex dimension: 2201.88x1253.51 (2283.53x2202.13 over 32x32) 464 Buffers - 25.01 MB total 1.24 MB IBs 23.50 MB VBs. 3512.52 MB - Grand total GPU buffer + texture load ``` Patch applied ``` 104 Textures - 2917.66 MB (2917.14 MB over 32x32), 39 RTs - 215.45 MB. Avg. tex dimension: 2221.38x1252.75 (2323.28x2253.47 over 32x32) 467 Buffers - 25.01 MB total 1.24 MB IBs 23.51 MB VBs. 3158.13 MB - Grand total GPU buffer + texture load. ``` Reviewed By: fclem Differential Revision: https://developer.blender.org/D15484
Diffstat (limited to 'source/blender/imbuf/IMB_imbuf.h')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 3a770c9a2b7..6881916d1d2 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -890,14 +890,22 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
bool use_high_bitdepth,
bool use_premult);
-eGPUTextureFormat IMB_gpu_get_texture_format(const struct ImBuf *ibuf, bool high_bitdepth);
+eGPUTextureFormat IMB_gpu_get_texture_format(const struct ImBuf *ibuf,
+ bool high_bitdepth,
+ bool use_grayscale);
/**
* The `ibuf` is only here to detect the storage type. The produced texture will have undefined
* content. It will need to be populated by using #IMB_update_gpu_texture_sub().
*/
-GPUTexture *IMB_touch_gpu_texture(
- const char *name, struct ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth);
+GPUTexture *IMB_touch_gpu_texture(const char *name,
+ struct ImBuf *ibuf,
+ int w,
+ int h,
+ int layers,
+ bool use_high_bitdepth,
+ bool use_grayscale);
+
/**
* Will update a #GPUTexture using the content of the #ImBuf. Only one layer will be updated.
* Will resize the ibuf if needed.
@@ -911,6 +919,7 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex,
int w,
int h,
bool use_high_bitdepth,
+ bool use_grayscale,
bool use_premult);
/**