diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index bc3b35117..76366ec8f 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -580,7 +580,7 @@ compositor_destroy(struct xrt_compositor *xc) comp_renderer_destroy(&c->r); - comp_resources_close(&c->nr, c); + comp_resources_close(&c->nr); // As long as vk_bundle is valid it's safe to call this function. comp_shaders_close(&c->shaders, vk); @@ -1368,7 +1368,7 @@ compositor_init_shaders(struct comp_compositor *c) static bool compositor_init_renderer(struct comp_compositor *c) { - if (!comp_resources_init(&c->nr, c, &c->shaders)) { + if (!comp_resources_init(&c->nr, &c->shaders, &c->vk, c->xdev)) { return false; } diff --git a/src/xrt/compositor/main/comp_renderer.c b/src/xrt/compositor/main/comp_renderer.c index 563ef7e27..d6b03caab 100644 --- a/src/xrt/compositor/main/comp_renderer.c +++ b/src/xrt/compositor/main/comp_renderer.c @@ -209,7 +209,7 @@ renderer_build_rendering_target_resources(struct comp_renderer *r, data.width = r->c->target->width; data.height = r->c->target->height; - comp_rendering_target_resources_init(rtr, c, &c->nr, r->c->target->images[index].view, &data); + comp_rendering_target_resources_init(rtr, &c->nr, r->c->target->images[index].view, &data); } //! @pre comp_target_has_images(r->c->target) @@ -250,7 +250,7 @@ renderer_build_rendering(struct comp_renderer *r, * Init */ - comp_rendering_init(rr, c, &c->nr); + comp_rendering_init(rr, &c->nr); /* @@ -982,7 +982,7 @@ dispatch_compute(struct comp_renderer *r, struct comp_rendering_compute *crc) struct comp_compositor *c = r->c; struct comp_target *ct = c->target; - comp_rendering_compute_init(crc, c, &c->nr); + comp_rendering_compute_init(crc, &c->nr); comp_rendering_compute_begin(crc); struct comp_viewport_data views[2]; diff --git a/src/xrt/compositor/render/comp_compute.c b/src/xrt/compositor/render/comp_compute.c index 9c46a0d07..1ca436cc1 100644 --- a/src/xrt/compositor/render/comp_compute.c +++ b/src/xrt/compositor/render/comp_compute.c @@ -10,7 +10,6 @@ #include "math/m_api.h" #include "math/m_matrix_4x4_f64.h" -#include "main/comp_compositor.h" #include "render/comp_render.h" #include @@ -55,7 +54,7 @@ static inline struct vk_bundle * vk_from_crc(struct comp_rendering_compute *crc) { - return &crc->c->vk; + return crc->r->vk; } /* @@ -369,13 +368,11 @@ update_compute_discriptor_set_target(struct vk_bundle *vk, */ bool -comp_rendering_compute_init(struct comp_rendering_compute *crc, struct comp_compositor *c, struct comp_resources *r) +comp_rendering_compute_init(struct comp_rendering_compute *crc, struct comp_resources *r) { - assert(crc->c == NULL); assert(crc->r == NULL); - struct vk_bundle *vk = &c->vk; - crc->c = c; + struct vk_bundle *vk = r->vk; crc->r = r; C(create_command_buffer(vk, &crc->cmd)); @@ -412,7 +409,6 @@ comp_rendering_compute_end(struct comp_rendering_compute *crc) void comp_rendering_compute_close(struct comp_rendering_compute *crc) { - assert(crc->c != NULL); assert(crc->r != NULL); struct vk_bundle *vk = vk_from_crc(crc); @@ -424,7 +420,6 @@ comp_rendering_compute_close(struct comp_rendering_compute *crc) vk->vkResetDescriptorPool(vk->device, crc->r->compute.descriptor_pool, 0); - crc->c = NULL; crc->r = NULL; } @@ -440,7 +435,6 @@ comp_rendering_compute_projection_timewarp(struct comp_rendering_compute *crc, VkImageView target_image_view, const struct comp_viewport_data views[2]) { - assert(crc->c != NULL); assert(crc->r != NULL); struct vk_bundle *vk = vk_from_crc(crc); @@ -576,7 +570,6 @@ comp_rendering_compute_projection(struct comp_rendering_compute *crc, VkImageView target_image_view, const struct comp_viewport_data views[2]) { - assert(crc->c != NULL); assert(crc->r != NULL); struct vk_bundle *vk = vk_from_crc(crc); @@ -693,7 +686,6 @@ comp_rendering_compute_clear(struct comp_rendering_compute *crc, // VkImageView target_image_view, // const struct comp_viewport_data views[2]) // { - assert(crc->c != NULL); assert(crc->r != NULL); struct vk_bundle *vk = vk_from_crc(crc); diff --git a/src/xrt/compositor/render/comp_render.h b/src/xrt/compositor/render/comp_render.h index fba77b230..780d57bda 100644 --- a/src/xrt/compositor/render/comp_render.h +++ b/src/xrt/compositor/render/comp_render.h @@ -21,9 +21,6 @@ extern "C" { #endif -struct comp_compositor; -struct comp_swapchain_image; - /*! * @addtogroup comp_main * @{ @@ -181,6 +178,9 @@ comp_buffer_write(struct vk_bundle *vk, struct comp_buffer *buffer, void *data, */ struct comp_resources { + //! Vulkan resources. + struct vk_bundle *vk; + /* * Loaded resources. */ @@ -292,13 +292,16 @@ struct comp_resources * @ingroup comp_main */ bool -comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct comp_shaders *shaders); +comp_resources_init(struct comp_resources *r, + struct comp_shaders *shaders, + struct vk_bundle *vk, + struct xrt_device *xdev); /*! * Free all pools and static resources, does not free the struct itself. */ void -comp_resources_close(struct comp_resources *r, struct comp_compositor *c); +comp_resources_close(struct comp_resources *r); /* @@ -338,9 +341,6 @@ struct comp_target_data */ struct comp_rendering_target_resources { - //! Owning compositor. - struct comp_compositor *c; - //! Collections of static resources. struct comp_resources *r; @@ -366,7 +366,6 @@ struct comp_rendering_target_resources */ bool comp_rendering_target_resources_init(struct comp_rendering_target_resources *rts, - struct comp_compositor *c, struct comp_resources *r, VkImageView target, struct comp_target_data *data); @@ -404,9 +403,6 @@ struct comp_rendering_view */ struct comp_rendering { - //! Owning compositor. - struct comp_compositor *c; - //! Resources that we are based on. struct comp_resources *r; @@ -427,7 +423,7 @@ struct comp_rendering * Init struct and create resources needed for rendering. */ bool -comp_rendering_init(struct comp_rendering *rr, struct comp_compositor *c, struct comp_resources *r); +comp_rendering_init(struct comp_rendering *rr, struct comp_resources *r); /*! * Frees any unneeded resources and ends the command buffer so it can be used. @@ -516,7 +512,7 @@ comp_draw_update_distortion(struct comp_rendering *rr, */ struct comp_rendering_compute { - struct comp_compositor *c; + //! Shared resources. struct comp_resources *r; //! Command buffer where all commands are recorded. @@ -561,7 +557,7 @@ struct comp_ubo_compute_data * Init struct and create resources needed for compute rendering. */ bool -comp_rendering_compute_init(struct comp_rendering_compute *crc, struct comp_compositor *c, struct comp_resources *r); +comp_rendering_compute_init(struct comp_rendering_compute *crc, struct comp_resources *r); /*! * Frees all resources held by the compute rendering, does not free the struct itself. diff --git a/src/xrt/compositor/render/comp_rendering.c b/src/xrt/compositor/render/comp_rendering.c index 4baa48944..79e230fe6 100644 --- a/src/xrt/compositor/render/comp_rendering.c +++ b/src/xrt/compositor/render/comp_rendering.c @@ -8,7 +8,6 @@ * @ingroup comp_main */ -#include "main/comp_compositor.h" #include "render/comp_render.h" #include @@ -46,7 +45,7 @@ static inline struct vk_bundle * vk_from_rts(struct comp_rendering_target_resources *rts) { - return &rts->c->vk; + return rts->r->vk; } /*! @@ -55,7 +54,7 @@ vk_from_rts(struct comp_rendering_target_resources *rts) static inline struct vk_bundle * vk_from_rr(struct comp_rendering *rr) { - return &rr->c->vk; + return rr->r->vk; } static VkResult @@ -517,13 +516,11 @@ update_mesh_discriptor_set(struct vk_bundle *vk, bool comp_rendering_target_resources_init(struct comp_rendering_target_resources *rts, - struct comp_compositor *c, struct comp_resources *r, VkImageView target, struct comp_target_data *data) { - struct vk_bundle *vk = &c->vk; - rts->c = c; + struct vk_bundle *vk = r->vk; rts->r = r; assert(data->is_external); @@ -542,8 +539,8 @@ comp_rendering_target_resources_init(struct comp_rendering_target_resources *rts r->mesh.src_binding, // src_binding r->mesh.total_num_indices, // mesh_total_num_indices r->mesh.stride, // mesh_stride - rts->c->shaders.mesh_vert, // mesh_vert - rts->c->shaders.mesh_frag, // mesh_frag + r->shaders->mesh_vert, // mesh_vert + r->shaders->mesh_frag, // mesh_frag &rts->mesh.pipeline)); // out_mesh_pipeline C(create_framebuffer(vk, // vk_bundle, @@ -574,10 +571,9 @@ comp_rendering_target_resources_close(struct comp_rendering_target_resources *rt */ bool -comp_rendering_init(struct comp_rendering *rr, struct comp_compositor *c, struct comp_resources *r) +comp_rendering_init(struct comp_rendering *rr, struct comp_resources *r) { - struct vk_bundle *vk = &c->vk; - rr->c = c; + struct vk_bundle *vk = r->vk; rr->r = r; diff --git a/src/xrt/compositor/render/comp_resources.c b/src/xrt/compositor/render/comp_resources.c index 15f0bcf32..ee34b25a5 100644 --- a/src/xrt/compositor/render/comp_resources.c +++ b/src/xrt/compositor/render/comp_resources.c @@ -8,10 +8,9 @@ * @ingroup comp_main */ - -#include "main/comp_compositor.h" -#include "render/comp_render.h" +#include "xrt/xrt_device.h" #include "math/m_vec2.h" +#include "render/comp_render.h" #include @@ -634,15 +633,16 @@ create_and_file_in_distortion_buffer_for_view(struct vk_bundle *vk, */ bool -comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct comp_shaders *shaders) +comp_resources_init(struct comp_resources *r, + struct comp_shaders *shaders, + struct vk_bundle *vk, + struct xrt_device *xdev) { - struct vk_bundle *vk = &c->vk; - struct xrt_device *xdev = c->xdev; - /* - * Shaders + * Main pointers. */ + r->vk = vk; r->shaders = shaders; @@ -785,11 +785,11 @@ comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct struct comp_buffer buffers[COMP_DISTORTION_NUM_IMAGES]; - calc_uv_to_tanangle(c->xdev, 0, &r->distortion.uv_to_tanangle[0]); - calc_uv_to_tanangle(c->xdev, 1, &r->distortion.uv_to_tanangle[1]); + calc_uv_to_tanangle(xdev, 0, &r->distortion.uv_to_tanangle[0]); + calc_uv_to_tanangle(xdev, 1, &r->distortion.uv_to_tanangle[1]); - create_and_file_in_distortion_buffer_for_view(vk, c->xdev, &buffers[0], &buffers[2], &buffers[4], 0); - create_and_file_in_distortion_buffer_for_view(vk, c->xdev, &buffers[1], &buffers[3], &buffers[5], 1); + create_and_file_in_distortion_buffer_for_view(vk, xdev, &buffers[0], &buffers[2], &buffers[4], 0); + create_and_file_in_distortion_buffer_for_view(vk, xdev, &buffers[1], &buffers[3], &buffers[5], 1); VkCommandBuffer upload_buffer = VK_NULL_HANDLE; C(vk_init_cmd_buffer(vk, &upload_buffer)); @@ -825,9 +825,11 @@ comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct } void -comp_resources_close(struct comp_resources *r, struct comp_compositor *c) +comp_resources_close(struct comp_resources *r) { - struct vk_bundle *vk = &c->vk; + assert(r->vk != NULL); + + struct vk_bundle *vk = r->vk; D(DescriptorSetLayout, r->mesh.descriptor_set_layout); D(PipelineLayout, r->mesh.pipeline_layout); diff --git a/src/xrt/compositor/render/comp_shaders.c b/src/xrt/compositor/render/comp_shaders.c index 70f4a441d..1e9adf803 100644 --- a/src/xrt/compositor/render/comp_shaders.c +++ b/src/xrt/compositor/render/comp_shaders.c @@ -8,7 +8,7 @@ * @ingroup comp_main */ -#include "main/comp_compositor.h" +#include "render/comp_render.h" #include #include