diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-02-16 00:20:25 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-02-16 00:20:49 +0300 |
commit | d3b1cce4000b4b530d3ac8e2aa6b86b79b94cca0 (patch) | |
tree | f905a28a8d4c3683a1a42d88d047bf2c9bd567a8 /source/blender/gpu/intern | |
parent | cbdd57864049f6f300494d56b623934a4134fa2b (diff) |
GPUTexture: Add dimensions getter
Pretty straight forward. Returns the texture dimensions count. This is
different from the size.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 19c7c5d78ff..da5f08f003e 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -507,6 +507,25 @@ void GPU_texture_ref(GPUTexture *tex) reinterpret_cast<Texture *>(tex)->refcount++; } +int GPU_texture_dimensions(const GPUTexture *tex_) +{ + eGPUTextureType type = reinterpret_cast<const Texture *>(tex_)->type_get(); + if (type & GPU_TEXTURE_1D) { + return 1; + } + else if (type & GPU_TEXTURE_2D) { + return 2; + } + else if (type & GPU_TEXTURE_3D) { + return 3; + } + else if (type & GPU_TEXTURE_CUBE) { + return 2; + } + /* GPU_TEXTURE_BUFFER */ + return 1; +} + int GPU_texture_width(const GPUTexture *tex) { return reinterpret_cast<const Texture *>(tex)->width_get(); |