23struct render_distortion_pipeline_cache;
58#define RENDER_ALWAYS_SAFE_UBO_ALIGNMENT (256)
65#define RENDER_MAX_LAYERS (128)
71#define RENDER_CS_MAX_SAMPLERS_PER_VIEW 2
77#define RENDER_MAX_IMAGES_SIZE (RENDER_MAX_LAYERS * RENDER_CS_MAX_SAMPLERS_PER_VIEW)
86#define RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS)
87#define RENDER_MAX_LAYER_RUNS_COUNT(RENDER_RESOURCES) (RENDER_RESOURCES->view_count)
90#define RENDER_DISTORTION_IMAGE_DIMENSIONS (128)
93#define RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS)
94#define RENDER_DISTORTION_IMAGES_COUNT(RENDER_RESOURCES) (3 * RENDER_RESOURCES->view_count)
97#define RENDER_BINDING_LAYER_SHARED_UBO 0
100#define RENDER_BINDING_LAYER_SHARED_SRC 1
106#define RENDER_CS_MAX_SAMPLERS_PER_VIEW 2
197 VkBufferUsageFlags usage_flags,
198 VkMemoryPropertyFlags memory_property_flags,
207 VkBufferUsageFlags usage_flags,
208 VkMemoryPropertyFlags memory_property_flags,
311XRT_CHECK_RESULT VkResult
322XRT_CHECK_RESULT VkResult
365 VkCommandPool cmd_pool;
367 VkQueryPool query_pool;
436 uint32_t vertex_count;
437 uint32_t index_counts[XRT_MAX_VIEWS];
439 uint32_t index_offsets[XRT_MAX_VIEWS];
440 uint32_t index_count_total;
455 VkImageView image_view;
456 VkDeviceMemory memory;
607render_resources_get_timestamps(
struct render_resources *r, uint64_t *out_gpu_start_ns, uint64_t *out_gpu_end_ns);
620render_resources_get_duration(
struct render_resources *r, uint64_t *out_gpu_duration_ns);
635 VkDeviceMemory device_memory;
637 VkImageView srgb_view;
638 VkImageView unorm_view;
727 VkPipeline cylinder_premultiplied_alpha;
728 VkPipeline cylinder_unpremultiplied_alpha;
730 VkPipeline equirect2_premultiplied_alpha;
731 VkPipeline equirect2_unpremultiplied_alpha;
733 VkPipeline proj_premultiplied_alpha;
734 VkPipeline proj_unpremultiplied_alpha;
736 VkPipeline quad_premultiplied_alpha;
737 VkPipeline quad_unpremultiplied_alpha;
750 VkAttachmentLoadOp load_op,
751 VkImageLayout final_layout);
938 float central_horizontal_angle;
939 float upper_vertical_angle;
940 float lower_vertical_angle;
987XRT_CHECK_RESULT VkResult
988render_gfx_mesh_alloc_and_write(
struct render_gfx *render,
990 VkSampler src_sampler,
991 VkImageView src_image_view,
992 VkDescriptorSet *out_descriptor_set);
1000XRT_CHECK_RESULT VkResult
1001render_gfx_layer_cylinder_alloc_and_write(
struct render_gfx *render,
1003 VkSampler src_sampler,
1004 VkImageView src_image_view,
1005 VkDescriptorSet *out_descriptor_set);
1013XRT_CHECK_RESULT VkResult
1014render_gfx_layer_equirect2_alloc_and_write(
struct render_gfx *render,
1016 VkSampler src_sampler,
1017 VkImageView src_image_view,
1018 VkDescriptorSet *out_descriptor_set);
1026XRT_CHECK_RESULT VkResult
1027render_gfx_layer_projection_alloc_and_write(
struct render_gfx *render,
1029 VkSampler src_sampler,
1030 VkImageView src_image_view,
1031 VkDescriptorSet *out_descriptor_set);
1039XRT_CHECK_RESULT VkResult
1040render_gfx_layer_quad_alloc_and_write(
struct render_gfx *render,
1042 VkSampler src_sampler,
1043 VkImageView src_image_view,
1044 VkDescriptorSet *out_descriptor_set);
1064render_gfx_begin_target(
struct render_gfx *render,
1066 const VkClearColorValue *color);
1074render_gfx_end_target(
struct render_gfx *render);
1081render_gfx_clear_color_attachment(
struct render_gfx *render,
const VkClearColorValue *color);
1088render_gfx_begin_view(
struct render_gfx *render,
1111render_gfx_mesh_draw(
struct render_gfx *render, uint32_t mesh_index, VkDescriptorSet descriptor_set,
bool do_timewarp);
1122render_gfx_layer_cylinder(
struct render_gfx *render,
bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1133render_gfx_layer_equirect2(
struct render_gfx *render,
bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1144render_gfx_layer_projection(
struct render_gfx *render,
bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1155render_gfx_layer_quad(
struct render_gfx *render,
bool premultiplied_alpha, VkDescriptorSet descriptor_set);
1215 RENDER_BLIT_RESOLVE_COLOR_MODE_COUNT = 2,
1277 uint32_t layer_type;
1278 uint32_t unpremultiplied_alpha;
1279 uint32_t inverted_alpha;
1290 uint32_t color_image_index;
1291 uint32_t depth_image_index;
1308 float central_angle;
1320 float central_horizontal_angle;
1321 float upper_vertical_angle;
1322 float lower_vertical_angle;
1379 struct xrt_matrix_4x4 transform_timewarp_scanout_begin[XRT_MAX_VIEWS];
1380 struct xrt_matrix_4x4 transform_timewarp_scanout_end[XRT_MAX_VIEWS];
1431 VkDescriptorSet descriptor_set,
1436 VkImageView target_image_view,
1445 VkSampler src_samplers[XRT_MAX_VIEWS],
1446 VkImageView src_image_views[XRT_MAX_VIEWS],
1448 const struct xrt_pose src_poses[XRT_MAX_VIEWS],
1449 const struct xrt_fov src_fovs[XRT_MAX_VIEWS],
1450 const struct xrt_pose new_poses_scanout_begin[XRT_MAX_VIEWS],
1451 const struct xrt_pose new_poses_scanout_end[XRT_MAX_VIEWS],
1452 VkImage target_image,
1453 VkImageView target_image_view,
1454 VkImageLayout target_final_layout,
1461render_compute_projection_scanout_compensation(
struct render_compute *render,
1462 VkSampler src_samplers[XRT_MAX_VIEWS],
1463 VkImageView src_image_views[XRT_MAX_VIEWS],
1465 const struct xrt_fov src_fovs[XRT_MAX_VIEWS],
1466 const struct xrt_pose new_poses_scanout_begin[XRT_MAX_VIEWS],
1467 const struct xrt_pose new_poses_scanout_end[XRT_MAX_VIEWS],
1468 VkImage target_image,
1469 VkImageView target_image_view,
1470 VkImageLayout target_final_layout,
1477render_compute_projection_no_timewarp(
struct render_compute *render,
1478 VkSampler src_samplers[XRT_MAX_VIEWS],
1479 VkImageView src_image_views[XRT_MAX_VIEWS],
1481 VkImage target_image,
1482 VkImageView target_image_view,
1483 VkImageLayout target_final_layout,
1491 VkImage target_image,
1492 VkImageView target_image_view,
1493 VkImageLayout target_final_layout,
void render_compute_layers(struct render_compute *render, VkDescriptorSet descriptor_set, VkBuffer ubo, VkSampler src_samplers[((128) *2)], VkImageView src_image_views[((128) *2)], uint32_t num_srcs, VkImageView target_image_view, const struct render_viewport_data *view, bool timewarp)
Updates the given descriptor_set and dispatches the layer shader.
VkResult render_buffer_map_and_write(struct vk_bundle *vk, struct render_buffer *buffer, void *data, VkDeviceSize size)
Maps the buffer, and copies the given data to the buffer.
Definition render_buffer.c:211
#define RENDER_MAX_LAYER_RUNS_SIZE
Maximum number of times that the layer squasher shader can run per render_compute.
Definition render_interface.h:86
VkResult render_buffer_write(struct vk_bundle *vk, struct render_buffer *buffer, void *data, VkDeviceSize size)
Writes the given data to the buffer, will map it temporarily if not mapped.
Definition render_buffer.c:233
void render_calc_time_warp_matrix(const struct xrt_pose *src_pose, const struct xrt_fov *src_fov, const struct xrt_pose *new_pose, struct xrt_matrix_4x4 *matrix)
Calculates a timewarp matrix which takes in NDC coords and gives out results in [-1,...
Definition render_util.c:140
void render_calc_time_warp_projection(const struct xrt_fov *fov, struct xrt_matrix_4x4 *result)
Create a simplified projection matrix for timewarp.
Definition render_util.c:176
#define RENDER_MAX_LAYERS
Max number of layers for layer squasher, can be different from XRT_MAX_LAYERS as the render module is...
Definition render_interface.h:65
#define RENDER_DISTORTION_IMAGES_SIZE
How many distortion images we have, one for each channel (3 rgb) and per view.
Definition render_interface.h:93
void render_calc_uv_to_tangent_lengths_rect(const struct xrt_fov *fov, struct xrt_normalized_rect *out_rect)
This function constructs a transformation in the form of a normalized rect that lets you go from a UV...
Definition render_util.c:187
#define RENDER_MAX_IMAGES_SIZE
Max number of images that can be given at a single time to the layer squasher in a single dispatch.
Definition render_interface.h:77
VkResult render_buffer_init(struct vk_bundle *vk, struct render_buffer *buffer, VkBufferUsageFlags usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceSize size)
Initialize a buffer.
Definition render_buffer.c:120
render_compute_blit_resolve_color_mode
Color mode for blit/resolve operations, used to select the correct shader variant for the source and ...
Definition render_interface.h:1210
uint32_t render_max_layers_capable(const struct vk_bundle *vk, bool use_compute, uint32_t desired_max_layers)
Determines the maximum number of compositor layers supported based on Vulkan device limits and the co...
Definition render_util.c:91
void render_buffer_unmap(struct vk_bundle *vk, struct render_buffer *buffer)
Unmaps the memory.
Definition render_buffer.c:202
void render_sub_alloc_tracker_init(struct render_sub_alloc_tracker *rsat, struct render_buffer *buffer)
Init a render_sub_alloc_tracker struct from a render_buffer, the caller is responsible for keeping bu...
Definition render_sub_alloc.c:29
VkResult render_buffer_init_exportable(struct vk_bundle *vk, struct render_buffer *buffer, VkBufferUsageFlags usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceSize size)
Initialize a buffer, making it exportable.
Definition render_buffer.c:146
VkResult render_buffer_map(struct vk_bundle *vk, struct render_buffer *buffer)
Maps the memory, sets render_buffer::mapped to the memory.
Definition render_buffer.c:191
XRT_CHECK_RESULT VkResult render_sub_alloc_ubo_alloc_and_get_ptr(struct vk_bundle *vk, struct render_sub_alloc_tracker *rsat, VkDeviceSize size, void **out_ptr, struct render_sub_alloc *out_rsa)
Allocate enough memory (with constraints of UBOs) of size, return the pointer to the mapped memory or...
Definition render_sub_alloc.c:38
XRT_CHECK_RESULT VkResult render_sub_alloc_ubo_alloc_and_write(struct vk_bundle *vk, struct render_sub_alloc_tracker *rsat, const void *ptr, VkDeviceSize size, struct render_sub_alloc *out_rsa)
Allocate enough memory (with constraints of UBOs) to hold the memory in ptr and copy that memory to t...
Definition render_sub_alloc.c:84
void render_buffer_fini(struct vk_bundle *vk, struct render_buffer *buffer)
Frees all resources that this buffer has, but does not free the buffer itself.
Definition render_buffer.c:183
void render_gfx_end_view(struct render_gfx *render)
Definition render_gfx.c:1164
@ RENDER_BLIT_RESOLVE_COLOR_MODE_LINEAR_IN_SRGB_FORMAT
Source is sRGB but the submitted bytes are already linear.
Definition render_interface.h:1214
@ RENDER_BLIT_RESOLVE_COLOR_MODE_GAMMA_IN_LINEAR_FORMAT
Source is UNORM/linear but the submitted bytes are gamma-encoded.
Definition render_interface.h:1212
Shader loading interface.
Definition t_rift_blobwatch.c:112
Helper struct holding a buffer and its memory.
Definition render_interface.h:172
VkDeviceSize alignment
Alignment of the buffer.
Definition render_interface.h:186
VkDeviceSize allocation_size
Size of the memory allocation.
Definition render_interface.h:183
VkDeviceMemory memory
Backing memory.
Definition render_interface.h:174
VkBuffer buffer
Buffer.
Definition render_interface.h:177
VkDeviceSize size
Size requested for the buffer.
Definition render_interface.h:180
Chroma key parameters for std140 layout, using HSV min/max range.
Definition render_interface.h:1236
Push data that is sent to the blit shader.
Definition render_interface.h:1198
Specialization constants for the blit shader, used to select the correct shader variant for the sourc...
Definition render_interface.h:1225
uint32_t color_transform_mode
See render_compute_blit_resolve_color_mode.
Definition render_interface.h:1227
UBO data that is sent to the compute distortion shaders.
Definition render_interface.h:1375
UBO data that is sent to the compute layer shaders.
Definition render_interface.h:1253
struct render_compute_layer_ubo_data::@21::@26 quad_position
For quad layers.
struct xrt_colour_rgba_f32 color_scale
Color scale and bias for all layers.
Definition render_interface.h:1364
struct render_compute_layer_ubo_data::@21::@24 cylinder_data
For cylinder layer.
struct xrt_matrix_4x4 mv_inverse
Shared between cylinder and equirect2.
Definition render_interface.h:1299
struct render_compute_layer_ubo_data::@21::@23 image_info
Which image/sampler(s) correspond to each layer.
struct xrt_matrix_4x4 transforms_timewarp
For projection layers.
Definition render_interface.h:1331
struct render_compute_layer_ubo_data::@21::@28 quad_extent
Quad extent in world scale.
struct render_compute_layer_ubo_data::@21::@25 eq2_data
For equirect2 layers.
uint32_t _padding0
Definition render_interface.h:1280
struct render_chroma_key_info chroma_key
Chroma key parameters (per layer)
Definition render_interface.h:1334
struct render_compute_layer_ubo_data::@21::@22 layer_data
Corresponds to enum xrt_layer_type and unpremultiplied alpha.
The semi-low level resources and operations required to squash layers and/or apply distortion for a s...
Definition render_interface.h:1177
struct render_resources * r
Shared resources.
Definition render_interface.h:1179
VkDescriptorSet shared_descriptor_set
Shared descriptor set, used for the clear and distortion shaders.
Definition render_interface.h:1189
VkDescriptorSet layer_descriptor_sets[(XRT_MAX_VIEWS)]
Layer descriptor set.
Definition render_interface.h:1182
UBO data that is sent to the layer cylinder shader.
Definition render_interface.h:913
UBO data that is sent to the layer equirect2 shader.
Definition render_interface.h:930
struct xrt_normalized_rect to_tangent
See render_calc_uv_to_tangent_lengths_rect.
Definition render_interface.h:935
UBO data that is sent to the layer projection shader.
Definition render_interface.h:951
UBO data that is sent to the layer quad shader.
Definition render_interface.h:965
UBO data that is sent to the mesh shaders.
Definition render_interface.h:897
A render pass, while not depending on a VkFramebuffer, does depend on the format of the target image(...
Definition render_interface.h:698
VkPipeline pipeline
Pipeline layout used for mesh, without timewarp.
Definition render_interface.h:719
VkFormat format
The format of the image(s) we are rendering to.
Definition render_interface.h:702
VkSampleCountFlagBits sample_count
Sample count for this render pass.
Definition render_interface.h:705
VkAttachmentLoadOp load_op
Load op used on the attachment(s).
Definition render_interface.h:708
VkImageLayout final_layout
Final layout of the target image(s).
Definition render_interface.h:711
VkRenderPass render_pass
Render pass used for rendering.
Definition render_interface.h:714
VkPipeline pipeline_timewarp
Pipeline layout used for mesh, with timewarp.
Definition render_interface.h:722
Each rendering (render_gfx) render to one or more targets (render_gfx_target_resources),...
Definition render_interface.h:777
VkRect2D render_area
The offset & extents of the framebuffer.
Definition render_interface.h:785
struct render_resources * r
Collections of static resources.
Definition render_interface.h:779
struct render_gfx_render_pass * rgrp
Render pass.
Definition render_interface.h:782
VkFramebuffer framebuffer
Framebuffer for this target, depends on given VkImageView.
Definition render_interface.h:788
The low-level resources and operations to perform layer squashing and/or mesh distortion for a single...
Definition render_interface.h:840
struct render_resources * r
Resources that we are based on.
Definition render_interface.h:842
struct render_gfx_target_resources * rtr
The current target we are rendering to, can change during command building.
Definition render_interface.h:848
struct render_sub_alloc_tracker ubo_tracker
Shared buffer that we sub-allocate UBOs from.
Definition render_interface.h:845
Holds all pools and static resources for rendering.
Definition render_interface.h:340
uint32_t target_binding
Writing the image out too.
Definition render_interface.h:472
uint32_t ubo_binding
The binding index for the UBO.
Definition render_interface.h:425
VkCommandBuffer cmd
Command buffer for recording everything.
Definition render_interface.h:375
uint32_t image_array_size
Size of combined image sampler array.
Definition render_interface.h:492
uint32_t view_count
The count of views that we are rendering to.
Definition render_interface.h:342
struct render_buffer ubos[XRT_MAX_VIEWS]
Info UBOs.
Definition render_interface.h:443
struct vk_bundle * vk
Vulkan resources.
Definition render_interface.h:345
VkSampler clamp_to_border_black
Sampler that clamps color samples to black in all directions.
Definition render_interface.h:389
bool pre_rotated
Whether distortion images have been pre-rotated 90 degrees.
Definition render_interface.h:546
VkPipeline non_timewarp_pipeline
Doesn't depend on target so is static.
Definition render_interface.h:486
struct render_shaders * shaders
All shaders loaded.
Definition render_interface.h:352
struct render_buffer shared_ubo
Shared UBO buffer that we sub-allocate out of, this is to have fewer buffers that the kernel needs to...
Definition render_interface.h:404
VkDescriptorSetLayout descriptor_set_layout
For projection and quad layer.
Definition render_interface.h:411
struct xrt_normalized_rect uv_to_tanangle[XRT_MAX_VIEWS]
Transform to go from UV to tangle angles.
Definition render_interface.h:534
VkPipeline timewarp_pipeline
Doesn't depend on target so is static.
Definition render_interface.h:489
VkPipeline pipeline
Cached non-timewarp variant from pipeline_cache.
Definition render_interface.h:507
VkImage images[(3 *XRT_MAX_VIEWS)]
Distortion images.
Definition render_interface.h:540
VkDescriptorPool ubo_and_src_descriptor_pool
Pool for shaders that uses one ubo and sampler.
Definition render_interface.h:395
struct vk_cmd_pool distortion_pool
Pool used for distortion image uploads.
Definition render_interface.h:360
VkSampler repeat
Sampler that repeats the texture in all directions.
Definition render_interface.h:383
uint32_t src_binding
The binding index for the source texture.
Definition render_interface.h:422
VkDeviceMemory device_memories[(3 *XRT_MAX_VIEWS)]
Backing memory to distortion images.
Definition render_interface.h:537
VkSampler mock
Sampler for mock/null images.
Definition render_interface.h:380
VkSampler clamp_to_edge
Sampler that clamps the coordinates to the edge in all directions.
Definition render_interface.h:386
struct render_buffer ubo
Target info.
Definition render_interface.h:516
struct render_distortion_pipeline_cache * pipeline_cache
Get-or-create cache for distortion.comp specialization variants.
Definition render_interface.h:513
uint32_t distortion_binding
Image storing the distortion.
Definition render_interface.h:469
VkPipelineLayout pipeline_layout
For projection and quad layer.
Definition render_interface.h:414
VkDescriptorPool descriptor_pool
Descriptor pool for compute work.
Definition render_interface.h:463
VkPipelineCache pipeline_cache
Shared for all rendering.
Definition render_interface.h:363
VkImageView image_views[(3 *XRT_MAX_VIEWS)]
The views into the distortion images.
Definition render_interface.h:543
Small helper struct to hold a scratch image, intended to be used with the compute pipeline where both...
Definition render_interface.h:634
Helper struct to hold scratch images.
Definition render_interface.h:645
Holds all shaders.
Definition render_shaders_interface.h:26
A per-frame tracker of sub-allocation out of a buffer, used to reduce the number of UBO objects we ne...
Definition render_interface.h:282
void * mapped
Start of memory, if buffer was mapped with initialised.
Definition render_interface.h:290
VkBuffer buffer
The buffer to allocate from, it is the caller's responsibility to keep it alive for as long as the su...
Definition render_interface.h:287
VkDeviceSize used
Currently used memory.
Definition render_interface.h:296
VkDeviceSize total_size
Total size of buffer.
Definition render_interface.h:293
Per frame sub-allocation into a buffer, used to reduce the number of UBO objects we need to create.
Definition render_interface.h:257
VkDeviceSize size
Size of sub-allocation.
Definition render_interface.h:265
VkBuffer buffer
The buffer this is allocated from, it is the caller's responsibility to keep it alive for as long as ...
Definition render_interface.h:262
VkDeviceSize offset
Offset into buffer.
Definition render_interface.h:268
The pure data information about a view that the renderer is rendering to.
Definition render_interface.h:678
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition vk_helpers.h:81
Small helper to manage lock around a command pool.
Definition vk_cmd_pool.h:33
A 4 element colour with floating point channels.
Definition xrt_defines.h:423
A single HMD or input device.
Definition xrt_device.h:341
Describes a projection matrix fov.
Definition xrt_defines.h:512
A tightly packed 2x2 matrix of floats.
Definition xrt_defines.h:539
A tightly packed 4x4 matrix of floats.
Definition xrt_defines.h:586
Normalized image rectangle, coordinates and size in 0 .
Definition xrt_defines.h:480
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Image rectangle.
Definition xrt_defines.h:457
A 2 element vector with single floats.
Definition xrt_defines.h:268
A 3 element vector with single floats.
Definition xrt_defines.h:289
Common Vulkan code header.
Header holding common defines.
Common defines and enums for XRT.