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:
authorClément Foucault <foucault.clem@gmail.com>2020-09-05 18:33:56 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-05 18:49:14 +0300
commitab95cdaba970a30127d804bd1e66ad25ab021ec1 (patch)
treed0da883e11f81253cb7b3e5a75288ca69598e437 /source/blender/gpu/intern/gpu_texture_private.hh
parentbac4606937514405641659d91a30bf3e6832cdf7 (diff)
GPUTexture: Change texture creation API
This is to modernize the API: - Add meaningful name to all textures (except DRW textures). - Remove unused err_out argument: only used for offscreen python. - Add mipmap count to creation functions for future changes. - Clarify the data usage in creation functions. This is a cleanup commit, there is no functional change. # Conflicts: # source/blender/gpu/GPU_texture.h
Diffstat (limited to 'source/blender/gpu/intern/gpu_texture_private.hh')
-rw-r--r--source/blender/gpu/intern/gpu_texture_private.hh79
1 files changed, 79 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh
index 207f3919a50..de639d0c435 100644
--- a/source/blender/gpu/intern/gpu_texture_private.hh
+++ b/source/blender/gpu/intern/gpu_texture_private.hh
@@ -25,6 +25,8 @@
#include "BLI_assert.h"
+#include "GPU_vertex_buffer.h"
+
#include "gpu_framebuffer_private.hh"
namespace blender {
@@ -460,5 +462,82 @@ inline eGPUFrameBufferBits to_framebuffer_bits(eGPUTextureFormat tex_format)
}
}
+static inline eGPUTextureFormat to_texture_format(const GPUVertFormat *format)
+{
+ if (format->attr_len > 1 || format->attr_len == 0) {
+ BLI_assert(!"Incorrect vertex format for buffer texture");
+ return GPU_DEPTH_COMPONENT24;
+ }
+ switch (format->attrs[0].comp_len) {
+ case 1:
+ switch (format->attrs[0].comp_type) {
+ case GPU_COMP_I8:
+ return GPU_R8I;
+ case GPU_COMP_U8:
+ return GPU_R8UI;
+ case GPU_COMP_I16:
+ return GPU_R16I;
+ case GPU_COMP_U16:
+ return GPU_R16UI;
+ case GPU_COMP_I32:
+ return GPU_R32I;
+ case GPU_COMP_U32:
+ return GPU_R32UI;
+ case GPU_COMP_F32:
+ return GPU_R32F;
+ default:
+ break;
+ }
+ break;
+ case 2:
+ switch (format->attrs[0].comp_type) {
+ case GPU_COMP_I8:
+ return GPU_RG8I;
+ case GPU_COMP_U8:
+ return GPU_RG8UI;
+ case GPU_COMP_I16:
+ return GPU_RG16I;
+ case GPU_COMP_U16:
+ return GPU_RG16UI;
+ case GPU_COMP_I32:
+ return GPU_RG32I;
+ case GPU_COMP_U32:
+ return GPU_RG32UI;
+ case GPU_COMP_F32:
+ return GPU_RG32F;
+ default:
+ break;
+ }
+ break;
+ case 3:
+ /* Not supported until GL 4.0 */
+ break;
+ case 4:
+ switch (format->attrs[0].comp_type) {
+ case GPU_COMP_I8:
+ return GPU_RGBA8I;
+ case GPU_COMP_U8:
+ return GPU_RGBA8UI;
+ case GPU_COMP_I16:
+ return GPU_RGBA16I;
+ case GPU_COMP_U16:
+ return GPU_RGBA16UI;
+ case GPU_COMP_I32:
+ return GPU_RGBA32I;
+ case GPU_COMP_U32:
+ return GPU_RGBA32UI;
+ case GPU_COMP_F32:
+ return GPU_RGBA32F;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ BLI_assert(!"Unsupported vertex format for buffer texture");
+ return GPU_DEPTH_COMPONENT24;
+}
+
} // namespace gpu
} // namespace blender