···697697 */
698698699699/*!
700700- * A render pass while not depending on a @p VkFramebuffer does depend on the
700700+ * A render pass, while not depending on a @p VkFramebuffer, does depend on the
701701 * format of the target image(s), and other options for the render pass. These
702702 * are used to create a @p VkRenderPass, all @p VkFramebuffer(s) and
703703 * @p VkPipeline depends on the @p VkRenderPass so hang off this struct.
···824824 */
825825826826/*!
827827- * A rendering is used to create command buffers needed to do one frame of
828828- * compositor rendering, it holds onto resources used by the command buffer.
827827+ * The low-level resources and operations to perform layer squashing and/or
828828+ * mesh distortion for a single frame using graphics shaders.
829829+ *
830830+ * It uses a two-stage process to render a frame. This means
831831+ * consumers iterate layers (or other operations) **twice**, within each target and view.
832832+ * There is a preparation stage, where the uniform buffer is sub-allocated and written.
833833+ * This must be completed for all layers before the actual draw stage begins.
834834+ * The second stage is recording the draw commands into a command buffer.
835835+ *
836836+ * You must make equivalent calls in the same order between the two stages. The second stage
837837+ * additionally has @ref render_gfx_begin_target, @ref render_gfx_end_target,
838838+ * @ref render_gfx_begin_view, and @ref render_gfx_end_view lacked by the first stage,
839839+ * but if you exclude those functions, the others must line up.
840840+ *
841841+ * Furthermore, the struct needs to be kept alive until the work has been waited on,
842842+ * or you get validation warnings. Either wait on the `VkFence` for the submit, or call
843843+ * `vkDeviceWaitIdle`/`vkQueueWaitIdle` on the device/queue.
829844 *
830845 * @see comp_render_gfx
831846 */
···837852 //! Shared buffer that we sub-allocate UBOs from.
838853 struct render_sub_alloc_tracker ubo_tracker;
839854840840- //! The current target we are rendering too, can change during command building.
855855+ //! The current target we are rendering to, can change during command building.
841856 struct render_gfx_target_resources *rtr;
842857};
843858···883898884899/*!
885900 * UBO data that is sent to the mesh shaders.
901901+ *
902902+ * @relates render_gfx
886903 */
887904struct render_gfx_mesh_ubo_data
888905{
···896913897914/*!
898915 * UBO data that is sent to the layer cylinder shader.
916916+ *
917917+ * @relates render_gfx
899918 */
900919struct render_gfx_layer_cylinder_data
901920{
···909928910929/*!
911930 * UBO data that is sent to the layer equirect2 shader.
931931+ *
932932+ * @relates render_gfx
912933 */
913934struct render_gfx_layer_equirect2_data
914935{
···926947927948/*!
928949 * UBO data that is sent to the layer projection shader.
950950+ *
951951+ * @relates render_gfx
929952 */
930953struct render_gfx_layer_projection_data
931954{
···936959937960/*!
938961 * UBO data that is sent to the layer quad shader.
962962+ *
963963+ * @relates render_gfx
939964 */
940965struct render_gfx_layer_quad_data
941966{
···943968 struct xrt_matrix_4x4 mvp;
944969};
945970946946-947971/*!
948948- * @name Drawing functions
972972+ * @name Preparation functions - first stage
949973 * @{
950974 */
951975952976/*!
953953- * This function allocates everything to start a single rendering. This is the
954954- * first function you call when you start rendering, you follow up with a call
955955- * to render_gfx_begin_view.
956956- *
957957- * @public @memberof render_gfx
958958- */
959959-bool
960960-render_gfx_begin_target(struct render_gfx *render,
961961- struct render_gfx_target_resources *rtr,
962962- const VkClearColorValue *color);
963963-964964-/*!
965965- * @public @memberof render_gfx
966966- */
967967-void
968968-render_gfx_end_target(struct render_gfx *render);
969969-970970-/*!
971971- * @public @memberof render_gfx
972972- */
973973-void
974974-render_gfx_begin_view(struct render_gfx *render, uint32_t view, const struct render_viewport_data *viewport_data);
975975-976976-/*!
977977- * @public @memberof render_gfx
978978- */
979979-void
980980-render_gfx_end_view(struct render_gfx *render);
981981-982982-/*!
983977 * Allocate needed resources for one mesh shader dispatch, will also update the
984978 * descriptor set, UBO will be filled out with the given @p data argument.
985979 *
···995989 VkSampler src_sampler,
996990 VkImageView src_image_view,
997991 VkDescriptorSet *out_descriptor_set);
998998-999999-/*!
10001000- * Dispatch one mesh shader instance, using the give @p mesh_index as source for
10011001- * mesh geometry, timewarp selectable via @p do_timewarp.
10021002- *
10031003- * @public @memberof render_gfx
10041004- */
10051005-void
10061006-render_gfx_mesh_draw(struct render_gfx *render, uint32_t mesh_index, VkDescriptorSet descriptor_set, bool do_timewarp);
10079921008993/*!
1009994 * Allocate and write a UBO and descriptor_set to be used for cylinder layer
···10571042 VkImageView src_image_view,
10581043 VkDescriptorSet *out_descriptor_set);
1059104410451045+10601046/*!
10611061- * Dispatch a cylinder layer shader into the current target and view,
10621062- * allocate @p descriptor_set and ubo with
10631063- * @ref render_gfx_layer_cylinder_alloc_and_write.
10471047+ * @}
10481048+ */
10491049+10501050+/*!
10511051+ * @name Drawing functions - second stage
10521052+ * @{
10531053+ */
10541054+10551055+/*!
10561056+ * This function allocates everything to start a single rendering. This is the
10571057+ * first function you call when you start the drawiing stage, you follow up with a call
10581058+ * to @ref render_gfx_begin_view.
10591059+ *
10601060+ * @public @memberof render_gfx
10611061+ */
10621062+bool
10631063+render_gfx_begin_target(struct render_gfx *render,
10641064+ struct render_gfx_target_resources *rtr,
10651065+ const VkClearColorValue *color);
10661066+10671067+/*!
10681068+ * @pre successful @ref render_gfx_begin_target call,
10691069+ * no @ref render_gfx_begin_view without matching @ref render_gfx_end_view
10701070+ * @public @memberof render_gfx
10711071+ */
10721072+void
10731073+render_gfx_end_target(struct render_gfx *render);
10741074+10751075+/*!
10761076+ * @pre successful @ref render_gfx_begin_target call
10771077+ * @public @memberof render_gfx
10781078+ */
10791079+void
10801080+render_gfx_begin_view(struct render_gfx *render, uint32_t view, const struct render_viewport_data *viewport_data);
10811081+10821082+/*!
10831083+ * @pre successful @ref render_gfx_begin_view call without a matching call to this function
10841084+ * @public @memberof render_gfx
10851085+ */
10861086+void
10871087+render_gfx_end_view(struct render_gfx *render);
10881088+10891089+/*!
10901090+ * Dispatch one mesh shader instance, using the give @p mesh_index as source for
10911091+ * mesh geometry, timewarp selectable via @p do_timewarp.
10921092+ *
10931093+ * Must have successfully called @ref render_gfx_mesh_alloc_and_write
10941094+ * before @ref render_gfx_begin_target to allocate @p descriptor_set and UBO.
10951095+ *
10961096+ * @pre successful @ref render_gfx_mesh_alloc_and_write call, successful @ref render_gfx_begin_view call
10971097+ * @public @memberof render_gfx
10981098+ */
10991099+void
11001100+render_gfx_mesh_draw(struct render_gfx *render, uint32_t mesh_index, VkDescriptorSet descriptor_set, bool do_timewarp);
11011101+11021102+/*!
11031103+ * Dispatch a cylinder layer shader into the current target and view.
11041104+ *
11051105+ * Must have successfully called @ref render_gfx_layer_cylinder_alloc_and_write
11061106+ * before @ref render_gfx_begin_target to allocate @p descriptor_set and UBO.
10641107 *
10651108 * @public @memberof render_gfx
10661109 */
···10681111render_gfx_layer_cylinder(struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1069111210701113/*!
10711071- * Dispatch a equirect2 layer shader into the current target and view,
10721072- * allocate @p descriptor_set and ubo with
10731073- * @ref render_gfx_layer_equirect2_alloc_and_write.
11141114+ * Dispatch a equirect2 layer shader into the current target and view.
11151115+ *
11161116+ * Must have successfully called @ref render_gfx_layer_equirect2_alloc_and_write
11171117+ * before @ref render_gfx_begin_target to allocate @p descriptor_set and UBO.
10741118 *
10751119 * @public @memberof render_gfx
10761120 */
···10781122render_gfx_layer_equirect2(struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1079112310801124/*!
10811081- * Dispatch a projection layer shader into the current target and view,
10821082- * allocate @p descriptor_set and ubo with
10831083- * @ref render_gfx_layer_projection_alloc_and_write.
11251125+ * Dispatch a projection layer shader into the current target and view.
11261126+ *
11271127+ * Must have successfully called @ref render_gfx_layer_projection_alloc_and_write
11281128+ * before @ref render_gfx_begin_target to allocate @p descriptor_set and UBO.
10841129 *
10851130 * @public @memberof render_gfx
10861131 */
···10881133render_gfx_layer_projection(struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1089113410901135/*!
10911091- * Dispatch a quad layer shader into the current target and view, allocate
10921092- * @p descriptor_set and ubo with @ref render_gfx_layer_quad_alloc_and_write.
11361136+ * Dispatch a quad layer shader into the current target and view.
11371137+ *
11381138+ * Must have successfully called @ref render_gfx_layer_quad_alloc_and_write
11391139+ * before @ref render_gfx_begin_target to allocate @p descriptor_set and UBO.
10931140 *
10941141 * @public @memberof render_gfx
10951142 */
···11081155 */
1109115611101157/*!
11111111- * A compute rendering is used to create command buffers needed to do one frame
11121112- * of compositor rendering using compute shaders, it holds onto resources used
11131113- * by the command buffer.
11581158+ * The semi-low level resources and operations required to squash layers and/or
11591159+ * apply distortion for a single frame using compute shaders.
11601160+ *
11611161+ * Unlike @ref render_gfx, this is a single stage process, and you pass all layers at a single time.
11141162 *
11151163 * @see comp_render_cs
11161164 */
···1132118011331181/*!
11341182 * Push data that is sent to the blit shader.
11831183+ *
11841184+ * @relates render_compute
11351185 */
11361186struct render_compute_blit_push_data
11371187{
···11421192/*!
11431193 * UBO data that is sent to the compute layer shaders.
11441194 *
11451145- * Used in @ref render_compute
11951195+ * @relates render_compute
11461196 */
11471197struct render_compute_layer_ubo_data
11481198{
···12371287/*!
12381288 * UBO data that is sent to the compute distortion shaders.
12391289 *
12401240- * Used in @ref render_compute
12901290+ * @relates render_compute
12411291 */
12421292struct render_compute_distortion_ubo_data
12431293{