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
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-02-25 03:05:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-03-18 22:53:17 +0300
commit3b75ca2f60f43d7450f5b1570bfedea4d1ed4b1a (patch)
tree73f9707489c8d980ba033e86d799e27b3a1c180c /source
parent374cb32d4a43b5f959f7fbd96074cfae5f265dab (diff)
GPUTexture: Expose layer & mip count
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/GPU_texture.h2
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc12
-rw-r--r--source/blender/gpu/intern/gpu_texture_private.hh5
3 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 734d407d011..0c7f1c1cbd4 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -308,6 +308,8 @@ int GPU_texture_dimensions(const GPUTexture *tex);
int GPU_texture_width(const GPUTexture *tex);
int GPU_texture_height(const GPUTexture *tex);
+int GPU_texture_layer_count(const GPUTexture *tex);
+int GPU_texture_mip_count(const GPUTexture *tex);
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);
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 9e6a6f75391..285ef87585f 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -142,6 +142,8 @@ bool Texture::init_view(const GPUTexture *src_,
w_ = src->w_;
h_ = src->h_;
d_ = src->d_;
+ layer_start = min_ii(layer_start, src->layer_count() - 1);
+ layer_len = min_ii(layer_len, (src->layer_count() - layer_start));
switch (type_) {
case GPU_TEXTURE_1D_ARRAY:
h_ = layer_len;
@@ -596,6 +598,16 @@ int GPU_texture_height(const GPUTexture *tex)
return reinterpret_cast<const Texture *>(tex)->height_get();
}
+int GPU_texture_layer_count(const GPUTexture *tex)
+{
+ return reinterpret_cast<const Texture *>(tex)->layer_count();
+}
+
+int GPU_texture_mip_count(const GPUTexture *tex)
+{
+ return reinterpret_cast<const Texture *>(tex)->mip_count();
+}
+
int GPU_texture_orig_width(const GPUTexture *tex)
{
return reinterpret_cast<const Texture *>(tex)->src_w;
diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh
index ec11fab421c..2a7fc074046 100644
--- a/source/blender/gpu/intern/gpu_texture_private.hh
+++ b/source/blender/gpu/intern/gpu_texture_private.hh
@@ -208,6 +208,11 @@ class Texture {
}
}
+ int mip_count() const
+ {
+ return mipmaps_;
+ }
+
eGPUTextureFormat format_get() const
{
return format_;