From 7e764ec692fda4c8a5080dbd7f3bd0e57022b1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 13 Apr 2023 14:06:41 +0200 Subject: [PATCH] GPU: Texture: Expose depth dimension extent This function was not exposed outside of internal GPU module. Renaming `draw::Texture::depth()` to `is_depth` for consistency and removing the ambiguity. --- source/blender/draw/intern/DRW_gpu_wrapper.hh | 7 ++++++- source/blender/gpu/GPU_texture.h | 6 ++++++ source/blender/gpu/intern/gpu_texture.cc | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 67e7616eb04..82288a5fe86 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -766,12 +766,17 @@ class Texture : NonCopyable { return GPU_texture_height(tx_); } + int depth() const + { + return GPU_texture_depth(tx_); + } + int pixel_count() const { return GPU_texture_width(tx_) * GPU_texture_height(tx_); } - bool depth() const + bool is_depth() const { return GPU_texture_has_depth_format(tx_); } diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 0dc9485cc7c..d7a826b9a03 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -940,6 +940,12 @@ int GPU_texture_width(const GPUTexture *texture); */ int GPU_texture_height(const GPUTexture *texture); +/** + * Return the depth of \a tex . Correspond to number of layers for 2D array texture. + * NOTE: return 0 for 1D & 2D textures. + */ +int GPU_texture_depth(const GPUTexture *texture); + /** * Return the number of layers of \a tex . Return 1 if the texture is not layered. */ diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 9b4a23f9b39..4a3254d9feb 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -716,6 +716,11 @@ int GPU_texture_height(const GPUTexture *tex) return reinterpret_cast(tex)->height_get(); } +int GPU_texture_depth(const GPUTexture *tex) +{ + return reinterpret_cast(tex)->depth_get(); +} + int GPU_texture_layer_count(const GPUTexture *tex) { return reinterpret_cast(tex)->layer_count();