Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Bound TEXTURE_SLICE_2D_ARRAY enum to ClassDB

Fluxx7bd55090c2c8c
diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml
index 8fc95b270c6..8573a6669d2 100644
--- a/doc/classes/RenderingDevice.xml
+++ b/doc/classes/RenderingDevice.xml
@@ -1170,10 +1170,10 @@
<param index="3" name="mipmap" type="int" />
<param index="4" name="mipmaps" type="int" default="1" />
<param index="5" name="slice_type" type="int" enum="RenderingDevice.TextureSliceType" default="0" />
+ <param index="6" name="layers" type="int" default="0" />
<description>
- Creates a shared texture using the specified [param view] and the texture information from [param with_texture]'s [param layer] and [param mipmap]. The number of included mipmaps from the original texture can be controlled using the [param mipmaps] parameter. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use [method texture_create_shared].
+ Creates a shared texture using the specified [param view] and the texture information from [param with_texture]'s [param layer] and [param mipmap]. The number of included mipmaps from the original texture can be controlled using the [param mipmaps] parameter. The [param layers] parameter controls the number of included layers from the original texture for 2D texture arrays, and must be [code]0[/code] for all other texture types. If [param layers] is [code]0[/code] for a 2D texture array, [param layer] must also be [code]0[/code], and all available layers will be included. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use [method texture_create_shared].
For 2D textures (which only have one layer), [param layer] must be [code]0[/code].
- [b]Note:[/b] Layer slicing is only supported for 2D texture arrays, not 3D textures or cubemaps.
This will be freed automatically when the [param with_texture] is freed.
</description>
</method>
@@ -2290,6 +2290,9 @@
<constant name="TEXTURE_SLICE_3D" value="2" enum="TextureSliceType">
3-dimensional texture slice.
</constant>
+ <constant name="TEXTURE_SLICE_2D_ARRAY" value="3" enum="TextureSliceType">
+ 2-dimensional texture array slice.
+ </constant>
<constant name="SAMPLER_FILTER_NEAREST" value="0" enum="SamplerFilter">
Nearest-neighbor sampler filtering. Sampling at higher resolutions than the source will result in a pixelated look.
</constant>
diff --git a/misc/extension_api_validation/4.7-stable/GH-121937.txt b/misc/extension_api_validation/4.7-stable/GH-121937.txt
new file mode 100644
index 00000000000..71ddc2b78be
--- /dev/null
+++ b/misc/extension_api_validation/4.7-stable/GH-121937.txt
@@ -0,0 +1,7 @@
+GH-121937
+--------------
+
+Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/texture_create_shared_from_slice/arguments': size changed value in new API, from 6 to 7.
+
+Added optional "layers" argument to texture_create_shared_from_slice in RenderingDevice.
+Compatibility method registered.
diff --git a/servers/rendering/rendering_device.compat.inc b/servers/rendering/rendering_device.compat.inc
index 1e25efbacaa..085242e395e 100644
--- a/servers/rendering/rendering_device.compat.inc
+++ b/servers/rendering/rendering_device.compat.inc
@@ -167,6 +167,10 @@ RID RenderingDevice::_texture_create_from_extension_bind_compat_105570(TextureTy
return texture_create_from_extension(p_type, p_format, p_samples, p_usage, p_image, p_width, p_height, p_depth, p_layers, 1);
}
+RID RenderingDevice::_texture_create_shared_from_slice_bind_compat_121937(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type) {
+ return _texture_create_shared_from_slice(p_view, p_with_texture, p_layer, p_mipmap, p_mipmaps, p_slice_type, 0);
+}
+
void RenderingDevice::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("shader_create_from_bytecode", "binary_data"), &RenderingDevice::_shader_create_from_bytecode_bind_compat_79606);
@@ -196,6 +200,7 @@ void RenderingDevice::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("vertex_buffer_create", "size_bytes", "data", "use_as_storage"), &RenderingDevice::_vertex_buffer_create_bind_compat_101561, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
ClassDB::bind_compatibility_method(D_METHOD("index_buffer_create", "size_indices", "format", "data", "use_restart_indices"), &RenderingDevice::_index_buffer_create_bind_compat_101561, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
+ ClassDB::bind_compatibility_method(D_METHOD("texture_create_shared_from_slice", "view", "with_texture", "layer", "mipmap", "mipmaps", "slice_type"), &RenderingDevice::_texture_create_shared_from_slice_bind_compat_121937, DEFVAL(1), DEFVAL(TEXTURE_SLICE_2D));
ClassDB::bind_compatibility_method(D_METHOD("texture_create_from_extension", "type", "format", "samples", "usage_flags", "image", "width", "height", "depth", "layers"), &RenderingDevice::_texture_create_from_extension_bind_compat_105570);
}
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 645cb8eef93..f6de94f693c 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -9051,7 +9051,7 @@ bool RenderingDevice::has_feature(const Features p_feature) const {
void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_create", "format", "view", "data"), &RenderingDevice::_texture_create, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("texture_create_shared", "view", "with_texture"), &RenderingDevice::_texture_create_shared);
- ClassDB::bind_method(D_METHOD("texture_create_shared_from_slice", "view", "with_texture", "layer", "mipmap", "mipmaps", "slice_type"), &RenderingDevice::_texture_create_shared_from_slice, DEFVAL(1), DEFVAL(TEXTURE_SLICE_2D));
+ ClassDB::bind_method(D_METHOD("texture_create_shared_from_slice", "view", "with_texture", "layer", "mipmap", "mipmaps", "slice_type", "layers"), &RenderingDevice::_texture_create_shared_from_slice, DEFVAL(1), DEFVAL(TEXTURE_SLICE_2D), DEFVAL(0));
ClassDB::bind_method(D_METHOD("texture_create_from_extension", "type", "format", "samples", "usage_flags", "image", "width", "height", "depth", "layers", "mipmaps"), &RenderingDevice::texture_create_from_extension, DEFVAL(1));
ClassDB::bind_method(D_METHOD("texture_update", "texture", "layer", "data"), &RenderingDevice::texture_update);
@@ -9560,6 +9560,7 @@ void RenderingDevice::_bind_methods() {
BIND_ENUM_CONSTANT(TEXTURE_SLICE_2D);
BIND_ENUM_CONSTANT(TEXTURE_SLICE_CUBEMAP);
BIND_ENUM_CONSTANT(TEXTURE_SLICE_3D);
+ BIND_ENUM_CONSTANT(TEXTURE_SLICE_2D_ARRAY);
BIND_ENUM_CONSTANT(SAMPLER_FILTER_NEAREST);
BIND_ENUM_CONSTANT(SAMPLER_FILTER_LINEAR);
@@ -9902,10 +9903,10 @@ RID RenderingDevice::_texture_create_shared(const Ref<RDTextureView> &p_view, RI
return texture_create_shared(p_view->base, p_with_texture);
}
-RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type) {
+RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type, uint32_t p_layers) {
ERR_FAIL_COND_V(p_view.is_null(), RID());
- return texture_create_shared_from_slice(p_view->base, p_with_texture, p_layer, p_mipmap, p_mipmaps, p_slice_type);
+ return texture_create_shared_from_slice(p_view->base, p_with_texture, p_layer, p_mipmap, p_mipmaps, p_slice_type, p_layers);
}
Ref<RDTextureFormat> RenderingDevice::_texture_get_format(RID p_rd_texture) {
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index 13fd1d5f7b2..063e2838197 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -95,6 +95,7 @@ protected:
#ifndef DISABLE_DEPRECATED
RID _shader_create_from_bytecode_bind_compat_79606(const Vector<uint8_t> &p_shader_binary);
RID _texture_create_from_extension_bind_compat_105570(TextureType p_type, DataFormat p_format, TextureSamples p_samples, BitField<RenderingDevice::TextureUsageBits> p_usage, uint64_t p_image, uint64_t p_width, uint64_t p_height, uint64_t p_depth, uint64_t p_layers);
+ RID _texture_create_shared_from_slice_bind_compat_121937(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
static void _bind_compatibility_methods();
#endif
@@ -1985,7 +1986,7 @@ private:
RID _texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data = Array());
RID _texture_create_shared(const Ref<RDTextureView> &p_view, RID p_with_texture);
- RID _texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
+ RID _texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D, uint32_t p_layers = 0);
Ref<RDTextureFormat> _texture_get_format(RID p_rd_texture);
FramebufferFormatID _framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments, uint32_t p_view_count);