From 16dd382f0648b1486a2a9d1c68ef3baa768ba7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 17 Mar 2022 14:39:03 +0100 Subject: GPUTexture: Add Cube view as 2D array This is useful to read/write to the textures directly using compute shaders and imageLoad/Store. --- source/blender/gpu/intern/gpu_texture.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/gpu/intern/gpu_texture.cc') diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 0d2ec43533f..b41193f12fa 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -136,7 +136,8 @@ bool Texture::init_view(const GPUTexture *src_, int mip_start, int mip_len, int layer_start, - int layer_len) + int layer_len, + bool cube_as_array) { const Texture *src = unwrap(src_); w_ = src->w_; @@ -165,6 +166,10 @@ bool Texture::init_view(const GPUTexture *src_, format_flag_ = to_format_flag(format); /* For now always copy the target. Target aliasing could be exposed later. */ type_ = src->type_; + if (cube_as_array) { + BLI_assert(type_ & GPU_TEXTURE_CUBE); + type_ = (type_ & ~GPU_TEXTURE_CUBE) | GPU_TEXTURE_2D_ARRAY; + } sampler_state = src->sampler_state; return this->init_internal(src_, mip_start, layer_start); } @@ -387,12 +392,13 @@ GPUTexture *GPU_texture_create_view(const char *name, int mip_start, int mip_len, int layer_start, - int layer_len) + int layer_len, + bool cube_as_array) { BLI_assert(mip_len > 0); BLI_assert(layer_len > 0); Texture *view = GPUBackend::get()->texture_alloc(name); - view->init_view(src, format, mip_start, mip_len, layer_start, layer_len); + view->init_view(src, format, mip_start, mip_len, layer_start, layer_len, cube_as_array); return wrap(view); } -- cgit v1.2.3