[Bf-blender-cvs] [ea70687dd5b] master: Image: Display GPU layout in `uiTemplateImageInfo`

Angus Stanton noreply at git.blender.org
Wed Aug 3 08:15:13 CEST 2022


Commit: ea70687dd5b9474ce183b7de12e42ec5201864e0
Author: Angus Stanton
Date:   Wed Aug 3 08:14:58 2022 +0200
Branches: master
https://developer.blender.org/rBea70687dd5b9474ce183b7de12e42ec5201864e0

Image: Display GPU layout in `uiTemplateImageInfo`

Add IMB_gpu_get_texture_format and GPU_texture_format_description to
retrieve and 'stringify' an eGPUTextureFormat. These are then used in the
image info panel used in several areas across blender.

New Information:
{F13330937}

Reviewed By: jbakker

Maniphest Tasks: T99998

Differential Revision: https://developer.blender.org/D15575

===================================================================

M	intern/ghost/CMakeLists.txt
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/gpu/GPU_texture.h
M	source/blender/gpu/intern/gpu_texture.cc
M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/util_gpu.c

===================================================================

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index c681dc368bb..cf0d4b1e35d 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -5,6 +5,7 @@ set(INC
   .
   ../clog
   ../glew-mx
+  ../../source/blender/blenlib
   ../../source/blender/imbuf
   ../../source/blender/makesdna
 )
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 0a774ee679c..baaa521fc94 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1211,6 +1211,12 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
       ofs += BLI_strncpy_rlen(str + ofs, TIP_(" + Z"), len - ofs);
     }
 
+    eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(ibuf,
+                                                                  ima->flag & IMA_HIGH_BITDEPTH);
+    const char *texture_format_description = GPU_texture_format_description(
+        texture_format);
+    ofs += BLI_snprintf_rlen(str + ofs, len - ofs, TIP_(",  %s"), texture_format_description);
+
     uiItemL(col, str, ICON_NONE);
   }
 
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 5bd20b7be98..6e31b1b69f6 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -331,6 +331,7 @@ int GPU_texture_orig_width(const GPUTexture *tex);
 int GPU_texture_orig_height(const GPUTexture *tex);
 void GPU_texture_orig_size_set(GPUTexture *tex, int w, int h);
 eGPUTextureFormat GPU_texture_format(const GPUTexture *tex);
+const char *GPU_texture_format_description(eGPUTextureFormat texture_format);
 bool GPU_texture_array(const GPUTexture *tex);
 bool GPU_texture_cube(const GPUTexture *tex);
 bool GPU_texture_depth(const GPUTexture *tex);
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 218d22ddf53..6ce60c6a0be 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -641,6 +641,112 @@ eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
   return reinterpret_cast<const Texture *>(tex)->format_get();
 }
 
+const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
+{
+  switch (texture_format) {
+    case GPU_RGBA8UI:
+      return "RGBA8UI";
+    case GPU_RGBA8I:
+      return "RGBA8I";
+    case GPU_RGBA8:
+      return "RGBA8";
+    case GPU_RGBA32UI:
+      return "RGBA32UI";
+    case GPU_RGBA32I:
+      return "RGBA32I";
+    case GPU_RGBA32F:
+      return "RGBA32F";
+    case GPU_RGBA16UI:
+      return "RGBA16UI";
+    case GPU_RGBA16I:
+      return "RGBA16I";
+    case GPU_RGBA16F:
+      return "RGBA16F";
+    case GPU_RGBA16:
+      return "RGBA16";
+    case GPU_RG8UI:
+      return "RG8UI";
+    case GPU_RG8I:
+      return "RG8I";
+    case GPU_RG8:
+      return "RG8";
+    case GPU_RG32UI:
+      return "RG32UI";
+    case GPU_RG32I:
+      return "RG32I";
+    case GPU_RG32F:
+      return "RG32F";
+    case GPU_RG16UI:
+      return "RG16UI";
+    case GPU_RG16I:
+      return "RG16I";
+    case GPU_RG16F:
+      return "RG16F";
+    case GPU_RG16:
+      return "RG16";
+    case GPU_R8UI:
+      return "R8UI";
+    case GPU_R8I:
+      return "R8I";
+    case GPU_R8:
+      return "R8";
+    case GPU_R32UI:
+      return "R32UI";
+    case GPU_R32I:
+      return "R32I";
+    case GPU_R32F:
+      return "R32F";
+    case GPU_R16UI:
+      return "R16UI";
+    case GPU_R16I:
+      return "R16I";
+    case GPU_R16F:
+      return "R16F";
+    case GPU_R16:
+      return "R16";
+
+
+    /* Special formats texture & render-buffer. */
+    case GPU_RGB10_A2:
+      return "RGB10A2";
+    case GPU_R11F_G11F_B10F:
+      return "R11FG11FB10F";
+    case GPU_DEPTH32F_STENCIL8:
+      return "DEPTH32FSTENCIL8";
+    case GPU_DEPTH24_STENCIL8:
+      return "DEPTH24STENCIL8";
+    case GPU_SRGB8_A8:
+      return "SRGB8A8";
+
+    /* Texture only format */
+    case (GPU_RGB16F):
+      return "RGB16F";
+
+    /* Special formats texture only */
+    case GPU_SRGB8_A8_DXT1:
+      return "SRGB8_A8_DXT1";
+    case GPU_SRGB8_A8_DXT3:
+      return "SRGB8_A8_DXT3";
+    case GPU_SRGB8_A8_DXT5:
+      return "SRGB8_A8_DXT5";
+    case GPU_RGBA8_DXT1:
+      return "RGBA8_DXT1";
+    case GPU_RGBA8_DXT3:
+      return "RGBA8_DXT3";
+    case GPU_RGBA8_DXT5:
+      return "RGBA8_DXT5";
+
+    /* Depth Formats */
+    case GPU_DEPTH_COMPONENT32F:
+      return "DEPTH32F";
+    case GPU_DEPTH_COMPONENT24:
+      return "DEPTH24";
+    case GPU_DEPTH_COMPONENT16:
+      return "DEPTH16";
+  }
+}
+
+
 bool GPU_texture_depth(const GPUTexture *tex)
 {
   return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_DEPTH) != 0;
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 20c414bb1ad..28125c006eb 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -41,6 +41,7 @@
 
 /* for bool */
 #include "../blenlib/BLI_sys_types.h"
+#include "../gpu/GPU_texture.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -72,12 +73,6 @@ struct GSet;
 struct ImageFormatData;
 struct Stereo3dFormat;
 
-/**
- *
- * \attention defined in GPU_texture.h
- */
-struct GPUTexture;
-
 /**
  *
  * \attention Defined in allocimbuf.c
@@ -933,22 +928,25 @@ const char *IMB_ffmpeg_last_error(void);
  *
  * \attention defined in util_gpu.c
  */
-struct GPUTexture *IMB_create_gpu_texture(const char *name,
-                                          struct ImBuf *ibuf,
-                                          bool use_high_bitdepth,
-                                          bool use_premult);
+GPUTexture *IMB_create_gpu_texture(const char *name,
+                                   struct ImBuf *ibuf,
+                                   bool use_high_bitdepth,
+                                   bool use_premult);
+
+eGPUTextureFormat IMB_gpu_get_texture_format(const struct ImBuf *ibuf, bool high_bitdepth);
+
 /**
  * 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().
  */
-struct GPUTexture *IMB_touch_gpu_texture(
+GPUTexture *IMB_touch_gpu_texture(
     const char *name, struct ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth);
 /**
  * Will update a #GPUTexture using the content of the #ImBuf. Only one layer will be updated.
  * Will resize the ibuf if needed.
  * Z is the layer to update. Unused if the texture is 2D.
  */
-void IMB_update_gpu_texture_sub(struct GPUTexture *tex,
+void IMB_update_gpu_texture_sub(GPUTexture *tex,
                                 struct ImBuf *ibuf,
                                 int x,
                                 int y,
diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c
index 5feb0ceb515..727704e27e8 100644
--- a/source/blender/imbuf/intern/util_gpu.c
+++ b/source/blender/imbuf/intern/util_gpu.c
@@ -290,3 +290,13 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
 
   return tex;
 }
+
+eGPUTextureFormat IMB_gpu_get_texture_format(const ImBuf *ibuf, bool high_bitdepth)
+{
+  eGPUTextureFormat gpu_texture_format;
+  eGPUDataFormat gpu_data_format;
+
+  imb_gpu_get_format(ibuf, high_bitdepth, &gpu_data_format, &gpu_texture_format);
+
+  return gpu_texture_format;
+}



More information about the Bf-blender-cvs mailing list