Expose a function to create textures from a native handle in the compatibility renderer

This commit is contained in:
David Snopek 2024-09-12 12:54:57 -05:00
parent 83d54ab2ad
commit 7d56b09f23
12 changed files with 255 additions and 15 deletions

View file

@ -729,7 +729,7 @@ void TextureStorage::texture_free(RID p_texture) {
}
}
} else {
must_free_data = t->tex_id != 0 && !t->is_external;
must_free_data = t->tex_id != 0 && !t->is_from_native_handle;
}
if (must_free_data) {
GLES3::Utilities::get_singleton()->texture_free_data(t->tex_id);
@ -874,26 +874,28 @@ void TextureStorage::texture_proxy_initialize(RID p_texture, RID p_base) {
texture_owner.initialize_rid(p_texture, proxy_tex);
}
RID TextureStorage::texture_create_external(GLES3::Texture::Type p_type, Image::Format p_format, unsigned int p_image, int p_width, int p_height, int p_depth, int p_layers, RS::TextureLayeredType p_layered_type) {
RID TextureStorage::texture_create_from_native_handle(RS::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers, RS::TextureLayeredType p_layered_type) {
Texture texture;
texture.active = true;
texture.is_external = true;
texture.type = p_type;
texture.is_from_native_handle = true;
switch (p_type) {
case Texture::TYPE_2D: {
case RS::TEXTURE_TYPE_2D: {
texture.type = Texture::TYPE_2D;
texture.target = GL_TEXTURE_2D;
} break;
case Texture::TYPE_3D: {
case RS::TEXTURE_TYPE_3D: {
texture.type = Texture::TYPE_3D;
texture.target = GL_TEXTURE_3D;
} break;
case Texture::TYPE_LAYERED: {
case RS::TEXTURE_TYPE_LAYERED: {
texture.type = Texture::TYPE_LAYERED;
texture.target = GL_TEXTURE_2D_ARRAY;
} break;
}
texture.real_format = texture.format = p_format;
texture.tex_id = p_image;
texture.tex_id = p_native_handle;
texture.alloc_width = texture.width = p_width;
texture.alloc_height = texture.height = p_height;
texture.depth = p_depth;