diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-02-25 00:45:00 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-02-25 00:51:19 +0300 |
commit | 7d7dd66ba78fc97795edeb7c1a0221e4bb676c85 (patch) | |
tree | 06622b61fe95999935aefda6bd7b9fbe745dbbfc /source/blender/gpu/opengl | |
parent | e59f754c169d855110296a365d93c33e82333385 (diff) |
GPUTexture: Add support for texture view
This is an OpenGL 4.3 feature that enables creating a texture using a range
of the same data as another texture.
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r-- | source/blender/gpu/opengl/gl_texture.cc | 22 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_texture.hh | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc index 37bf2f6b8b3..0a5c7f8e79e 100644 --- a/source/blender/gpu/opengl/gl_texture.cc +++ b/source/blender/gpu/opengl/gl_texture.cc @@ -175,6 +175,28 @@ bool GLTexture::init_internal(GPUVertBuf *vbo) return true; } +bool GLTexture::init_internal(const GPUTexture *src, int mip_offset, int layer_offset) +{ + BLI_assert(GLContext::texture_storage_support); + + const GLTexture *gl_src = static_cast<const GLTexture *>(unwrap(src)); + GLenum internal_format = to_gl_internal_format(format_); + target_ = to_gl_target(type_); + + glTextureView(tex_id_, + target_, + gl_src->tex_id_, + internal_format, + mip_offset, + mipmaps_, + layer_offset, + this->layer_count()); + + debug::object_label(GL_TEXTURE, tex_id_, name_); + + return true; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/gpu/opengl/gl_texture.hh b/source/blender/gpu/opengl/gl_texture.hh index 9e128da90e8..d4d024f5e3e 100644 --- a/source/blender/gpu/opengl/gl_texture.hh +++ b/source/blender/gpu/opengl/gl_texture.hh @@ -74,6 +74,8 @@ class GLTexture : public Texture { bool init_internal() override; /** Return true on success. */ bool init_internal(GPUVertBuf *vbo) override; + /** Return true on success. */ + bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset) override; private: bool proxy_check(int mip); |