mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/render: Move shaders to render
This commit is contained in:
parent
8c8d72647b
commit
56f4466ffa
|
@ -25,7 +25,6 @@ set(MAIN_SOURCE_FILES
|
|||
main/comp_renderer.h
|
||||
main/comp_settings.c
|
||||
main/comp_settings.h
|
||||
main/comp_shaders.c
|
||||
main/comp_swapchain.c
|
||||
main/comp_sync.c
|
||||
main/comp_target.h
|
||||
|
@ -41,6 +40,7 @@ set(MAIN_SOURCE_FILES
|
|||
render/comp_render.h
|
||||
render/comp_rendering.c
|
||||
render/comp_resources.c
|
||||
render/comp_shaders.c
|
||||
render/comp_util.c
|
||||
)
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ compositor_destroy(struct xrt_compositor *xc)
|
|||
|
||||
comp_renderer_destroy(&c->r);
|
||||
|
||||
comp_resources_close(c, &c->nr);
|
||||
comp_resources_close(&c->nr, c);
|
||||
|
||||
// As long as vk_bundle is valid it's safe to call this function.
|
||||
comp_shaders_close(vk, &c->shaders);
|
||||
|
@ -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, &c->nr)) {
|
||||
if (!comp_resources_init(&c->nr, c, &c->shaders)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,24 +137,6 @@ enum comp_state
|
|||
COMP_STATE_FOCUSED = 4,
|
||||
};
|
||||
|
||||
struct comp_shaders
|
||||
{
|
||||
VkShaderModule clear_comp;
|
||||
VkShaderModule distortion_comp;
|
||||
VkShaderModule distortion_timewarp_comp;
|
||||
|
||||
VkShaderModule mesh_vert;
|
||||
VkShaderModule mesh_frag;
|
||||
|
||||
VkShaderModule equirect1_vert;
|
||||
VkShaderModule equirect1_frag;
|
||||
|
||||
VkShaderModule equirect2_vert;
|
||||
VkShaderModule equirect2_frag;
|
||||
|
||||
VkShaderModule layer_vert;
|
||||
VkShaderModule layer_frag;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Tracking frame state.
|
||||
|
@ -339,18 +321,6 @@ comp_compositor_import_fence(struct xrt_compositor *xc,
|
|||
xrt_graphics_sync_handle_t handle,
|
||||
struct xrt_compositor_fence **out_xcf);
|
||||
|
||||
/*!
|
||||
* Loads all of the shaders that the compositor uses.
|
||||
*/
|
||||
bool
|
||||
comp_shaders_load(struct vk_bundle *vk, struct comp_shaders *s);
|
||||
|
||||
/*!
|
||||
* Unload and cleanup shaders.
|
||||
*/
|
||||
void
|
||||
comp_shaders_close(struct vk_bundle *vk, struct comp_shaders *s);
|
||||
|
||||
/*!
|
||||
* Spew level logging.
|
||||
*
|
||||
|
|
|
@ -20,7 +20,6 @@ compositor_srcs = [
|
|||
'main/comp_renderer.h',
|
||||
'main/comp_settings.c',
|
||||
'main/comp_settings.h',
|
||||
'main/comp_shaders.c',
|
||||
'main/comp_swapchain.c',
|
||||
'main/comp_sync.c',
|
||||
'main/comp_target.h',
|
||||
|
@ -38,6 +37,7 @@ compositor_srcs = [
|
|||
'render/comp_render.h',
|
||||
'render/comp_rendering.c',
|
||||
'render/comp_resources.c',
|
||||
'render/comp_shaders.c',
|
||||
'render/comp_util.c',
|
||||
]
|
||||
|
||||
|
|
|
@ -60,6 +60,47 @@ comp_calc_time_warp_matrix(const struct xrt_pose *src_pose,
|
|||
bool disable_atw);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Shaders.
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Holds all shaders.
|
||||
*/
|
||||
struct comp_shaders
|
||||
{
|
||||
VkShaderModule clear_comp;
|
||||
VkShaderModule distortion_comp;
|
||||
VkShaderModule distortion_timewarp_comp;
|
||||
|
||||
VkShaderModule mesh_vert;
|
||||
VkShaderModule mesh_frag;
|
||||
|
||||
VkShaderModule equirect1_vert;
|
||||
VkShaderModule equirect1_frag;
|
||||
|
||||
VkShaderModule equirect2_vert;
|
||||
VkShaderModule equirect2_frag;
|
||||
|
||||
VkShaderModule layer_vert;
|
||||
VkShaderModule layer_frag;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Loads all of the shaders that the compositor uses.
|
||||
*/
|
||||
bool
|
||||
comp_shaders_load(struct vk_bundle *vk, struct comp_shaders *s);
|
||||
|
||||
/*!
|
||||
* Unload and cleanup shaders.
|
||||
*/
|
||||
void
|
||||
comp_shaders_close(struct vk_bundle *vk, struct comp_shaders *s);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Buffer
|
||||
|
@ -141,6 +182,14 @@ comp_buffer_write(struct vk_bundle *vk, struct comp_buffer *buffer, void *data,
|
|||
*/
|
||||
struct comp_resources
|
||||
{
|
||||
/*
|
||||
* Loaded resources.
|
||||
*/
|
||||
|
||||
//! All shaders loaded.
|
||||
struct comp_shaders *shaders;
|
||||
|
||||
|
||||
/*
|
||||
* Shared pools and caches.
|
||||
*/
|
||||
|
@ -244,13 +293,13 @@ struct comp_resources
|
|||
* @ingroup comp_main
|
||||
*/
|
||||
bool
|
||||
comp_resources_init(struct comp_compositor *c, struct comp_resources *r);
|
||||
comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct comp_shaders *shaders);
|
||||
|
||||
/*!
|
||||
* Free all pools and static resources, does not free the struct itself.
|
||||
*/
|
||||
void
|
||||
comp_resources_close(struct comp_compositor *c, struct comp_resources *r);
|
||||
comp_resources_close(struct comp_resources *r, struct comp_compositor *c);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -634,11 +634,18 @@ create_and_file_in_distortion_buffer_for_view(struct vk_bundle *vk,
|
|||
*/
|
||||
|
||||
bool
|
||||
comp_resources_init(struct comp_compositor *c, struct comp_resources *r)
|
||||
comp_resources_init(struct comp_resources *r, struct comp_compositor *c, struct comp_shaders *shaders)
|
||||
{
|
||||
struct vk_bundle *vk = &c->vk;
|
||||
struct xrt_device *xdev = c->xdev;
|
||||
|
||||
/*
|
||||
* Shaders
|
||||
*/
|
||||
|
||||
r->shaders = shaders;
|
||||
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
@ -740,21 +747,21 @@ comp_resources_init(struct comp_compositor *c, struct comp_resources *r)
|
|||
C(create_compute_pipeline( //
|
||||
vk, // vk_bundle
|
||||
r->pipeline_cache, // pipeline_cache
|
||||
c->shaders.clear_comp, // shader
|
||||
r->shaders->clear_comp, // shader
|
||||
r->compute.pipeline_layout, // pipeline_layout
|
||||
&r->compute.clear_pipeline)); // out_compute_pipeline
|
||||
|
||||
C(create_compute_pipeline( //
|
||||
vk, // vk_bundle
|
||||
r->pipeline_cache, // pipeline_cache
|
||||
c->shaders.distortion_comp, // shader
|
||||
r->shaders->distortion_comp, // shader
|
||||
r->compute.pipeline_layout, // pipeline_layout
|
||||
&r->compute.distortion_pipeline)); // out_compute_pipeline
|
||||
|
||||
C(create_compute_pipeline( //
|
||||
vk, // vk_bundle
|
||||
r->pipeline_cache, // pipeline_cache
|
||||
c->shaders.distortion_timewarp_comp, // shader
|
||||
r->shaders->distortion_timewarp_comp, // shader
|
||||
r->compute.pipeline_layout, // pipeline_layout
|
||||
&r->compute.distortion_timewarp_pipeline)); // out_compute_pipeline
|
||||
|
||||
|
@ -818,7 +825,7 @@ comp_resources_init(struct comp_compositor *c, struct comp_resources *r)
|
|||
}
|
||||
|
||||
void
|
||||
comp_resources_close(struct comp_compositor *c, struct comp_resources *r)
|
||||
comp_resources_close(struct comp_resources *r, struct comp_compositor *c)
|
||||
{
|
||||
struct vk_bundle *vk = &c->vk;
|
||||
|
||||
|
|
Loading…
Reference in a new issue