Skip to content

Commit e7ac8e4

Browse files
authored
Merge pull request #103296 from dsnopek/texture-create-from-native-handle-right-rid-type
`texture_create_from_native_handle()` should return `RID` for texture from `RenderingServer`, not `RenderingDevice`
2 parents 6ea7798 + a285d1a commit e7ac8e4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/classes/RenderingServer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3725,7 +3725,7 @@
37253725
<param index="7" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType" default="0" />
37263726
<description>
37273727
Creates a texture based on a native handle that was created outside of Godot's renderer.
3728-
[b]Note:[/b] If using the rendering device renderer, using [method RenderingDevice.texture_create_from_extension] rather than this method is recommended. It will give you much more control over the texture's format and usage.
3728+
[b]Note:[/b] If using only the rendering device renderer, it's recommend to use [method RenderingDevice.texture_create_from_extension] together with [method RenderingServer.texture_rd_create], rather than this method. It will give you much more control over the texture's format and usage.
37293729
</description>
37303730
</method>
37313731
<method name="texture_get_format" qualifiers="const">

servers/rendering/renderer_rd/storage_rd/texture_storage.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,12 @@ RID TextureStorage::texture_create_from_native_handle(RS::TextureType p_type, Im
12921292
// Assumed to be a color attachment - see note above.
12931293
uint64_t usage_flags = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
12941294

1295-
return RD::get_singleton()->texture_create_from_extension(type, format, RD::TEXTURE_SAMPLES_1, usage_flags, p_native_handle, p_width, p_height, p_depth, p_layers);
1295+
RID rd_texture = RD::get_singleton()->texture_create_from_extension(type, format, RD::TEXTURE_SAMPLES_1, usage_flags, p_native_handle, p_width, p_height, p_depth, p_layers);
1296+
1297+
RID texture = texture_allocate();
1298+
texture_rd_initialize(texture, rd_texture, p_layered_type);
1299+
1300+
return texture;
12961301
}
12971302

12981303
void TextureStorage::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {

0 commit comments

Comments
 (0)