Merge pull request #52864 from BastiaanOlij/xr_extension_return_buffers

Fix access to render target texture for XR interfaces
This commit is contained in:
Bastiaan Olij 2021-09-28 20:19:20 +10:00 committed by GitHub
commit 0320532876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View file

@ -2415,6 +2415,13 @@ RID RendererSceneRenderRD::render_buffers_get_back_depth_texture(RID p_render_bu
return rb->depth_back_texture;
}
RID RendererSceneRenderRD::render_buffers_get_depth_texture(RID p_render_buffers) {
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->depth_texture;
}
RID RendererSceneRenderRD::render_buffers_get_ao_texture(RID p_render_buffers) {
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());

View file

@ -1197,6 +1197,7 @@ public:
virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override;
virtual void gi_set_use_half_resolution(bool p_enable) override;
RID render_buffers_get_depth_texture(RID p_render_buffers);
RID render_buffers_get_ao_texture(RID p_render_buffers);
RID render_buffers_get_back_buffer_texture(RID p_render_buffers);
RID render_buffers_get_back_depth_texture(RID p_render_buffers);

View file

@ -29,6 +29,7 @@
/*************************************************************************/
#include "xr_interface_extension.h"
#include "servers/rendering/renderer_rd/renderer_storage_rd.h"
#include "servers/rendering/renderer_storage.h"
#include "servers/rendering/rendering_server_globals.h"
@ -246,17 +247,21 @@ void XRInterfaceExtension::notification(int p_what) {
}
RID XRInterfaceExtension::get_render_target_texture(RID p_render_target) {
RendererStorage *storage = RSG::storage;
ERR_FAIL_NULL_V_MSG(storage, RID(), "Renderer storage not setup");
// In due time this will need to be enhance to return the correct INTERNAL RID for the chosen rendering engine.
// So once a GLES driver is implemented we'll return that and the implemented plugin needs to handle this correctly too.
RendererStorageRD *rd_storage = RendererStorageRD::base_singleton;
ERR_FAIL_NULL_V_MSG(rd_storage, RID(), "Renderer storage not setup");
return storage->render_target_get_texture(p_render_target);
return rd_storage->render_target_get_rd_texture(p_render_target);
}
/*
RID XRInterfaceExtension::get_render_target_depth(RID p_render_target) {
RendererStorage *storage = RSG::storage;
ERR_FAIL_NULL_V_MSG(storage, RID(), "Renderer storage not setup");
// TODO implement this, the problem is that our depth texture isn't part of our render target as it is used for 3D rendering only
// but we don't have access to our render buffers from here....
RendererSceneRenderRD * rd_scene = ?????;
ERR_FAIL_NULL_V_MSG(rd_scene, RID(), "Renderer scene render not setup");
return storage->render_target_get_depth(p_render_target);
return rd_scene->render_buffers_get_depth_texture(????????????);
}
*/