diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-09 19:28:26 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-09 19:28:26 +0200 |
commit | 564d1b34e06bea9d3541fe059f906e98af927cb0 (patch) | |
tree | 359d6b3fbf7b113b1d6ac7ee815b0ee52dd8e290 /drivers | |
parent | de14109862edd8f8e27fa0f6ec92f5d7f2b9df7f (diff) | |
parent | c328676d960897abe6f00aaceee4c34801415940 (diff) | |
download | redot-engine-564d1b34e06bea9d3541fe059f906e98af927cb0.tar.gz |
Merge pull request #74711 from BastiaanOlij/add_texture_native_handle
Provide access to internal graphics handles for textures
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 7 | ||||
-rw-r--r-- | drivers/gles3/storage/texture_storage.h | 1 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 9 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.h | 1 |
4 files changed, 18 insertions, 0 deletions
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index d147cee54f..3fd54e9180 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1140,6 +1140,13 @@ RID TextureStorage::texture_get_rd_texture(RID p_texture, bool p_srgb) const { return RID(); } +uint64_t TextureStorage::texture_get_native_handle(RID p_texture, bool p_srgb) const { + const Texture *texture = texture_owner.get_or_null(p_texture); + ERR_FAIL_COND_V(!texture, 0); + + return texture->tex_id; +} + void TextureStorage::texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer) { Texture *texture = texture_owner.get_or_null(p_texture); diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 85d2ae0314..c6bdd39dbd 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -537,6 +537,7 @@ public: virtual Size2 texture_size_with_proxy(RID p_proxy) override; virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override; + virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const override; void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0); void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer = 0); diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 6e62f833a5..e7dc2fabe1 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -2881,6 +2881,15 @@ Size2i RenderingDeviceVulkan::texture_size(RID p_texture) { return Size2i(tex->width, tex->height); } +uint64_t RenderingDeviceVulkan::texture_native_handle(RID p_texture) { + _THREAD_SAFE_METHOD_ + + Texture *tex = texture_owner.get_or_null(p_texture); + ERR_FAIL_COND_V(!tex, 0); + + return (uint64_t)tex->image; +} + Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, BitField<BarrierMask> p_post_barrier) { _THREAD_SAFE_METHOD_ diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 2ec1574955..4150e0a8e6 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -1057,6 +1057,7 @@ public: virtual bool texture_is_shared(RID p_texture); virtual bool texture_is_valid(RID p_texture); virtual Size2i texture_size(RID p_texture); + virtual uint64_t texture_native_handle(RID p_texture); virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS); virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS); |