Squash foveation Monado patches
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
From 483ce192460569020fa57522ee2bea99198dac2e Mon Sep 17 00:00:00 2001
|
||||
From 5a4505efc60c9252176b73775278b6f5b775fe8e Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 22 Oct 2024 15:23:19 +0200
|
||||
Subject: [PATCH 01/13] c/multi: early wake of compositor
|
||||
Subject: [PATCH 1/7] c/multi: early wake of compositor
|
||||
|
||||
---
|
||||
.../compositor/multi/comp_multi_compositor.c | 14 +++++++++
|
||||
@@ -128,5 +128,5 @@ index be763d1c1..22c801f65 100644
|
||||
//! @todo Make the clients not go from IDLE to READY before we have completed a first frame.
|
||||
// Make sure there is at least some sort of valid frame data here.
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 642f328ff08872289082f591b393aa72cdfffe0a Mon Sep 17 00:00:00 2001
|
||||
From e118393925294a3b57cbf149fdc28685b27aec94 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 2 Apr 2024 17:14:42 +0200
|
||||
Subject: [PATCH 02/13] ipc/server: Always listen to stdin
|
||||
Subject: [PATCH 2/7] ipc/server: Always listen to stdin
|
||||
|
||||
---
|
||||
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 2 +-
|
||||
@@ -21,5 +21,5 @@ index d364fbed3..ad6b473b7 100644
|
||||
// default.
|
||||
// This polls stdin.
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From a06da2ceeddf3f7760501114efa35bd168ba74bc Mon Sep 17 00:00:00 2001
|
||||
From d4b4c209e9106edf5e6b1c3efbcac2b88364518b Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 8 Oct 2024 22:13:15 +0200
|
||||
Subject: [PATCH 03/13] Use extern socket fd
|
||||
Subject: [PATCH 3/7] Use extern socket fd
|
||||
|
||||
---
|
||||
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 8 ++++++++
|
||||
@@ -34,5 +34,5 @@ index ad6b473b7..ea6fad65b 100644
|
||||
// We may have been launched with socket activation
|
||||
int num_fds = sd_listen_fds(0);
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
From 4efe5b0e12a92284e46fdeb225102dc63a7eda51 Mon Sep 17 00:00:00 2001
|
||||
From: galister <3123227-galister@users.noreply.gitlab.com>
|
||||
Date: Mon, 19 Aug 2024 18:51:45 +0900
|
||||
Subject: [PATCH 04/13] c/render: Add storage usage to distortion mesh
|
||||
|
||||
---
|
||||
src/xrt/compositor/render/render_distortion.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/render/render_distortion.c b/src/xrt/compositor/render/render_distortion.c
|
||||
index 8ac24db8e..5a7e400c3 100644
|
||||
--- a/src/xrt/compositor/render/render_distortion.c
|
||||
+++ b/src/xrt/compositor/render/render_distortion.c
|
||||
@@ -42,7 +42,7 @@ create_distortion_image_and_view(struct vk_bundle *vk,
|
||||
vk, // vk_bundle
|
||||
extent, // extent
|
||||
format, // format
|
||||
- VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // usage
|
||||
+ VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // usage
|
||||
&device_memory, // out_device_memory
|
||||
&image); // out_image
|
||||
VK_CHK_AND_RET(ret, "vk_create_image_simple");
|
||||
--
|
||||
2.50.1
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
From a28d3e6a3e85b7c04392137b30958e8b1d13c591 Mon Sep 17 00:00:00 2001
|
||||
From 6dc7053efd13536ba81e8261c183ac0ae54321e2 Mon Sep 17 00:00:00 2001
|
||||
From: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
|
||||
Date: Sat, 23 Nov 2024 02:42:12 +0900
|
||||
Subject: [PATCH 05/13] change environment blend mode selection logic
|
||||
Subject: [PATCH 4/7] change environment blend mode selection logic
|
||||
|
||||
---
|
||||
src/xrt/compositor/multi/comp_multi_system.c | 26 +++++++++++++-------
|
||||
@@ -53,5 +53,5 @@ index 22c801f65..1155bc67e 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
From 0d2ae2efb84f1479151c096e26f3295eded3b170 Mon Sep 17 00:00:00 2001
|
||||
From b9be14a7b106595ac1e6e350dcaaf93c906d0d0b Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Thu, 27 Feb 2025 22:45:36 +0100
|
||||
Subject: [PATCH 08/13] c/main: allow custom pacing app factory
|
||||
Subject: [PATCH 5/7] c/main: allow custom pacing app factory
|
||||
|
||||
---
|
||||
src/xrt/compositor/main/comp_compositor.c | 10 ++++++----
|
||||
@@ -10,7 +10,7 @@ Subject: [PATCH 08/13] c/main: allow custom pacing app factory
|
||||
3 files changed, 11 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c
|
||||
index 819c2c8b3..a42d25869 100644
|
||||
index 805683d70..8220808ff 100644
|
||||
--- a/src/xrt/compositor/main/comp_compositor.c
|
||||
+++ b/src/xrt/compositor/main/comp_compositor.c
|
||||
@@ -987,6 +987,7 @@ compositor_init_renderer(struct comp_compositor *c)
|
||||
@@ -21,7 +21,7 @@ index 819c2c8b3..a42d25869 100644
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
@@ -1185,10 +1186,11 @@ comp_main_create_system_compositor(struct xrt_device *xdev,
|
||||
@@ -1187,10 +1188,11 @@ comp_main_create_system_compositor(struct xrt_device *xdev,
|
||||
}
|
||||
|
||||
// Standard app pacer.
|
||||
@@ -78,5 +78,5 @@ index 617561c37..e10ba8358 100644
|
||||
#else
|
||||
if (!use_null) {
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
From 1a9b288475830fc1caf9bbf340ea370677b239a5 Mon Sep 17 00:00:00 2001
|
||||
From bbf1e184d62cfb0dbafe5cfa1c1851baebf6be58 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Sat, 15 Mar 2025 22:19:48 +0100
|
||||
Subject: [PATCH 09/13] st/oxr: forward 0 refresh rate
|
||||
Subject: [PATCH 6/7] st/oxr: forward 0 refresh rate
|
||||
|
||||
---
|
||||
src/xrt/state_trackers/oxr/oxr_api_session.c | 6 +-----
|
||||
@@ -29,5 +29,5 @@ index 9c5889f12..c4cdaf8c3 100644
|
||||
if ((int)(displayRefreshRate * 100.0f) == (int)(sess->sys->xsysc->info.refresh_rates_hz[i] * 100.0f)) {
|
||||
found = true;
|
||||
--
|
||||
2.50.1
|
||||
2.51.0
|
||||
|
||||
+676
-145
File diff suppressed because it is too large
Load Diff
@@ -1,94 +0,0 @@
|
||||
From 022835847793c2b97df20a1dc823512a36533d53 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Sun, 3 Nov 2024 13:40:00 +0100
|
||||
Subject: [PATCH 07/13] store alpha channel in layer 1
|
||||
|
||||
---
|
||||
src/xrt/compositor/shaders/clear.comp | 4 ++--
|
||||
src/xrt/compositor/shaders/distortion.comp | 18 ++++++++++++------
|
||||
2 files changed, 14 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/shaders/clear.comp b/src/xrt/compositor/shaders/clear.comp
|
||||
index 036da401a..db8e5178e 100644
|
||||
--- a/src/xrt/compositor/shaders/clear.comp
|
||||
+++ b/src/xrt/compositor/shaders/clear.comp
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
-layout(set = 0, binding = 2) uniform writeonly restrict image2D target;
|
||||
+layout(set = 0, binding = 2) uniform writeonly restrict image2DArray target;
|
||||
layout(set = 0, binding = 3) uniform restrict Config
|
||||
{
|
||||
ivec4 views[2];
|
||||
@@ -35,5 +35,5 @@ void main()
|
||||
|
||||
vec4 colour = vec4(from_linear_to_srgb(vec3(0.1)), 1.0);
|
||||
|
||||
- imageStore(target, ivec2(offset.x + ix, offset.y + iy), colour);
|
||||
+ imageStore(target, ivec3(offset.x + ix, offset.y + iy, 0), colour);
|
||||
}
|
||||
diff --git a/src/xrt/compositor/shaders/distortion.comp b/src/xrt/compositor/shaders/distortion.comp
|
||||
index e1dd1cb58..9ce46fe6f 100644
|
||||
--- a/src/xrt/compositor/shaders/distortion.comp
|
||||
+++ b/src/xrt/compositor/shaders/distortion.comp
|
||||
@@ -18,7 +18,7 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D source[2];
|
||||
layout(set = 0, binding = 1) uniform sampler2D distortion[6];
|
||||
-layout(set = 0, binding = 2) uniform writeonly restrict image2D luma;
|
||||
+layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
|
||||
layout(set = 0, binding = 3, std140) uniform restrict Config
|
||||
{
|
||||
ivec4 views[2];
|
||||
@@ -26,7 +26,7 @@ layout(set = 0, binding = 3, std140) uniform restrict Config
|
||||
vec4 post_transform[2];
|
||||
mat4 transform[2];
|
||||
} ubo;
|
||||
-layout(set = 0, binding = 4) uniform writeonly restrict image2D chroma;
|
||||
+layout(set = 0, binding = 4) uniform writeonly restrict image2DArray chroma;
|
||||
|
||||
const mat3 color_space = mat3(
|
||||
// clang-format off
|
||||
@@ -122,6 +122,7 @@ void main()
|
||||
ivec2 offset = ivec2(ubo.views[iz].xy);
|
||||
ivec2 extent = ivec2(ubo.views[iz].zw);
|
||||
vec2 cbcrs[4];
|
||||
+ vec4 alpha;
|
||||
for (int k = 0; k < 2; k += 1) {
|
||||
uint iy = gl_GlobalInvocationID.y * 2 + k;
|
||||
for (int j = 0; j < 2; j += 1) {
|
||||
@@ -136,15 +137,16 @@ void main()
|
||||
uv = transform_uv(uv, iz);
|
||||
|
||||
// Sample the source
|
||||
- vec3 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5)).rgb;
|
||||
+ vec4 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5));
|
||||
|
||||
- colour = rgb_to_ycbcr(from_linear_to_srgb(colour));
|
||||
+ colour.rgb = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
|
||||
|
||||
int i = k * 2 + j;
|
||||
cbcrs[i] = colour.yz;
|
||||
+ alpha[i] = colour.a;
|
||||
|
||||
if (ix < extent.x && iy < extent.y) {
|
||||
- imageStore(luma, ivec2(offset.x + ix, offset.y + iy), vec4(colour.x));
|
||||
+ imageStore(luma, ivec3(offset.x + ix, offset.y + iy, 0), vec4(colour.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,5 +154,9 @@ void main()
|
||||
return;
|
||||
}
|
||||
vec2 cbcr = mix(mix(cbcrs[0], cbcrs[1], 0.5), mix(cbcrs[2], cbcrs[3], 0.5), 0.5);
|
||||
- imageStore(chroma, ivec2(offset.xy/2 + gl_GlobalInvocationID.xy), vec4(cbcr.x, cbcr.y, 0, 0));
|
||||
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 0), vec4(cbcr.x, cbcr.y, 0, 0));
|
||||
+
|
||||
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), vec4(0.5, 0.5, 0, 0));
|
||||
+ alpha = vec4(mix(mix(alpha[0], alpha[1], 0.5), mix(alpha[2], alpha[3], 0.5), 0.5));
|
||||
+ imageStore(luma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), alpha);
|
||||
}
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@@ -1,747 +0,0 @@
|
||||
From 624849b80a893d073f2315eca909afa823c0a345 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Mon, 2 Jun 2025 14:51:11 +0200
|
||||
Subject: [PATCH 10/13] Replace distortion with pixel-aligned foveation
|
||||
|
||||
---
|
||||
src/xrt/compositor/CMakeLists.txt | 4 +-
|
||||
src/xrt/compositor/render/render_compute.c | 185 ++-----------------
|
||||
src/xrt/compositor/render/render_interface.h | 33 ++--
|
||||
src/xrt/compositor/render/render_resources.c | 71 +------
|
||||
src/xrt/compositor/shaders/distortion.comp | 167 ++++++-----------
|
||||
src/xrt/compositor/util/comp_render_cs.c | 33 +---
|
||||
6 files changed, 101 insertions(+), 392 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt
|
||||
index 1ba5ec438..eb068f5fc 100644
|
||||
--- a/src/xrt/compositor/CMakeLists.txt
|
||||
+++ b/src/xrt/compositor/CMakeLists.txt
|
||||
@@ -105,7 +105,7 @@ if(XRT_HAVE_VULKAN)
|
||||
spirv_shaders(
|
||||
SHADER_HEADERS
|
||||
SPIRV_VERSION
|
||||
- 1.0 # Currently targeting Vulkan 1.0
|
||||
+ 1.3 # Currently targeting Vulkan 1.3
|
||||
SOURCES
|
||||
${SHADERS}
|
||||
)
|
||||
@@ -115,7 +115,7 @@ if(XRT_HAVE_VULKAN)
|
||||
${SHADER_HEADERS}
|
||||
render/render_buffer.c
|
||||
render/render_compute.c
|
||||
- render/render_distortion.c
|
||||
+ # render/render_distortion.c implemented in wivrn
|
||||
render/render_gfx.c
|
||||
render/render_interface.h
|
||||
render/render_resources.c
|
||||
diff --git a/src/xrt/compositor/render/render_compute.c b/src/xrt/compositor/render/render_compute.c
|
||||
index fd04801d4..44c3f0aee 100644
|
||||
--- a/src/xrt/compositor/render/render_compute.c
|
||||
+++ b/src/xrt/compositor/render/render_compute.c
|
||||
@@ -66,8 +66,8 @@ calc_dispatch_dims_views(const struct render_viewport_data views[XRT_MAX_VIEWS],
|
||||
#undef IMAX
|
||||
|
||||
// Power of two divide and round up.
|
||||
- w = uint_divide_and_round_up(w, 16);
|
||||
- h = uint_divide_and_round_up(h, 16);
|
||||
+ w = uint_divide_and_round_up(w, 8);
|
||||
+ h = uint_divide_and_round_up(h, 8);
|
||||
|
||||
*out_w = w;
|
||||
*out_h = h;
|
||||
@@ -167,8 +167,8 @@ update_compute_shared_descriptor_set(struct vk_bundle *vk,
|
||||
VkSampler src_samplers[XRT_MAX_VIEWS],
|
||||
VkImageView src_image_views[XRT_MAX_VIEWS],
|
||||
uint32_t distortion_binding,
|
||||
- VkSampler distortion_samplers[3 * XRT_MAX_VIEWS],
|
||||
- VkImageView distortion_image_views[3 * XRT_MAX_VIEWS],
|
||||
+ VkDeviceSize foveation_size,
|
||||
+ VkBuffer foveation_buffer,
|
||||
uint32_t target_binding_y,
|
||||
uint32_t target_binding_cbcr,
|
||||
VkImageView target_image_view_y,
|
||||
@@ -186,12 +186,11 @@ update_compute_shared_descriptor_set(struct vk_bundle *vk,
|
||||
src_image_info[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
|
||||
- VkDescriptorImageInfo distortion_image_info[3 * XRT_MAX_VIEWS];
|
||||
- for (uint32_t i = 0; i < 3 * view_count; ++i) {
|
||||
- distortion_image_info[i].sampler = distortion_samplers[i];
|
||||
- distortion_image_info[i].imageView = distortion_image_views[i];
|
||||
- distortion_image_info[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
- }
|
||||
+ VkDescriptorBufferInfo foveation_buffer_info = {
|
||||
+ .buffer = foveation_buffer,
|
||||
+ .offset = 0,
|
||||
+ .range = foveation_size,
|
||||
+ };
|
||||
|
||||
VkDescriptorImageInfo target_image_y_info = {
|
||||
.imageView = target_image_view_y,
|
||||
@@ -222,9 +221,9 @@ update_compute_shared_descriptor_set(struct vk_bundle *vk,
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = descriptor_set,
|
||||
.dstBinding = distortion_binding,
|
||||
- .descriptorCount = 3 * view_count,
|
||||
- .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
- .pImageInfo = distortion_image_info,
|
||||
+ .descriptorCount = 1,
|
||||
+ .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
+ .pBufferInfo = &foveation_buffer_info,
|
||||
},
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
@@ -483,146 +482,6 @@ render_compute_layers(struct render_compute *render,
|
||||
1); // groupCountZ
|
||||
}
|
||||
|
||||
-void
|
||||
-render_compute_projection_timewarp(struct render_compute *render,
|
||||
- VkSampler src_samplers[XRT_MAX_VIEWS],
|
||||
- VkImageView src_image_views[XRT_MAX_VIEWS],
|
||||
- const struct xrt_normalized_rect src_norm_rects[XRT_MAX_VIEWS],
|
||||
- const struct xrt_pose src_poses[XRT_MAX_VIEWS],
|
||||
- const struct xrt_fov src_fovs[XRT_MAX_VIEWS],
|
||||
- const struct xrt_pose new_poses[XRT_MAX_VIEWS],
|
||||
- VkImage target_image,
|
||||
- VkImageView target_image_view_y,
|
||||
- VkImageView target_image_view_cbcr,
|
||||
- const struct render_viewport_data views[XRT_MAX_VIEWS])
|
||||
-{
|
||||
- assert(render->r != NULL);
|
||||
-
|
||||
- struct vk_bundle *vk = vk_from_render(render);
|
||||
- struct render_resources *r = render->r;
|
||||
-
|
||||
-
|
||||
- /*
|
||||
- * UBO
|
||||
- */
|
||||
-
|
||||
- struct xrt_matrix_4x4 time_warp_matrix[XRT_MAX_VIEWS];
|
||||
- for (uint32_t i = 0; i < render->r->view_count; ++i) {
|
||||
- render_calc_time_warp_matrix( //
|
||||
- &src_poses[i], //
|
||||
- &src_fovs[i], //
|
||||
- &new_poses[i], //
|
||||
- &time_warp_matrix[i]); //
|
||||
- }
|
||||
-
|
||||
- struct render_compute_distortion_ubo_data *data =
|
||||
- (struct render_compute_distortion_ubo_data *)r->compute.distortion.ubo.mapped;
|
||||
- for (uint32_t i = 0; i < render->r->view_count; ++i) {
|
||||
- data->views[i] = views[i];
|
||||
- data->pre_transforms[i] = r->distortion.uv_to_tanangle[i];
|
||||
- data->transforms[i] = time_warp_matrix[i];
|
||||
- data->post_transforms[i] = src_norm_rects[i];
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * Source, target and distortion images.
|
||||
- */
|
||||
-
|
||||
- VkImageSubresourceRange subresource_range = {
|
||||
- .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
- .baseMipLevel = 0,
|
||||
- .levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
- .baseArrayLayer = 0,
|
||||
- .layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
- };
|
||||
-
|
||||
- vk_cmd_image_barrier_gpu_locked( //
|
||||
- vk, //
|
||||
- r->cmd, //
|
||||
- target_image, //
|
||||
- 0, //
|
||||
- VK_ACCESS_SHADER_WRITE_BIT, //
|
||||
- VK_IMAGE_LAYOUT_UNDEFINED, //
|
||||
- VK_IMAGE_LAYOUT_GENERAL, //
|
||||
- subresource_range); //
|
||||
-
|
||||
- VkSampler sampler = r->samplers.clamp_to_edge;
|
||||
- VkSampler distortion_samplers[3 * XRT_MAX_VIEWS];
|
||||
- for (uint32_t i = 0; i < render->r->view_count; ++i) {
|
||||
- distortion_samplers[3 * i + 0] = sampler;
|
||||
- distortion_samplers[3 * i + 1] = sampler;
|
||||
- distortion_samplers[3 * i + 2] = sampler;
|
||||
- }
|
||||
-
|
||||
- update_compute_shared_descriptor_set( //
|
||||
- vk, //
|
||||
- r->compute.src_binding, //
|
||||
- src_samplers, //
|
||||
- src_image_views, //
|
||||
- r->compute.distortion_binding, //
|
||||
- distortion_samplers, //
|
||||
- r->distortion.image_views, //
|
||||
- r->compute.target_binding_y, //
|
||||
- r->compute.target_binding_cbcr, //
|
||||
- target_image_view_y, //
|
||||
- target_image_view_cbcr, //
|
||||
- r->compute.ubo_binding, //
|
||||
- r->compute.distortion.ubo.buffer, //
|
||||
- VK_WHOLE_SIZE, //
|
||||
- render->shared_descriptor_set, //
|
||||
- render->r->view_count); //
|
||||
-
|
||||
- vk->vkCmdBindPipeline( //
|
||||
- r->cmd, //
|
||||
- VK_PIPELINE_BIND_POINT_COMPUTE, // pipelineBindPoint
|
||||
- r->compute.distortion.timewarp_pipeline); // pipeline
|
||||
-
|
||||
- vk->vkCmdBindDescriptorSets( //
|
||||
- r->cmd, //
|
||||
- VK_PIPELINE_BIND_POINT_COMPUTE, // pipelineBindPoint
|
||||
- r->compute.distortion.pipeline_layout, // layout
|
||||
- 0, // firstSet
|
||||
- 1, // descriptorSetCount
|
||||
- &render->shared_descriptor_set, // pDescriptorSets
|
||||
- 0, // dynamicOffsetCount
|
||||
- NULL); // pDynamicOffsets
|
||||
-
|
||||
-
|
||||
- uint32_t w = 0, h = 0;
|
||||
- calc_dispatch_dims_views(views, render->r->view_count, &w, &h);
|
||||
- assert(w != 0 && h != 0);
|
||||
-
|
||||
- vk->vkCmdDispatch( //
|
||||
- r->cmd, //
|
||||
- w, // groupCountX
|
||||
- h, // groupCountY
|
||||
- 2); // groupCountZ
|
||||
-
|
||||
- VkImageMemoryBarrier memoryBarrier = {
|
||||
- .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
- .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
||||
- .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT,
|
||||
- .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
- .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
- .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
- .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
- .image = target_image,
|
||||
- .subresourceRange = subresource_range,
|
||||
- };
|
||||
-
|
||||
- vk->vkCmdPipelineBarrier( //
|
||||
- r->cmd, //
|
||||
- VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, //
|
||||
- VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, //
|
||||
- 0, //
|
||||
- 0, //
|
||||
- NULL, //
|
||||
- 0, //
|
||||
- NULL, //
|
||||
- 1, //
|
||||
- &memoryBarrier); //
|
||||
-}
|
||||
-
|
||||
void
|
||||
render_compute_projection(struct render_compute *render,
|
||||
VkSampler src_samplers[XRT_MAX_VIEWS],
|
||||
@@ -673,22 +532,14 @@ render_compute_projection(struct render_compute *render,
|
||||
VK_IMAGE_LAYOUT_GENERAL, //
|
||||
subresource_range); //
|
||||
|
||||
- VkSampler sampler = r->samplers.clamp_to_edge;
|
||||
- VkSampler distortion_samplers[3 * XRT_MAX_VIEWS];
|
||||
- for (uint32_t i = 0; i < render->r->view_count; ++i) {
|
||||
- distortion_samplers[3 * i + 0] = sampler;
|
||||
- distortion_samplers[3 * i + 1] = sampler;
|
||||
- distortion_samplers[3 * i + 2] = sampler;
|
||||
- }
|
||||
-
|
||||
update_compute_shared_descriptor_set( //
|
||||
vk, //
|
||||
r->compute.src_binding, //
|
||||
src_samplers, //
|
||||
src_image_views, //
|
||||
r->compute.distortion_binding, //
|
||||
- distortion_samplers, //
|
||||
- r->distortion.image_views, //
|
||||
+ VK_WHOLE_SIZE, //
|
||||
+ r->distortion.buffer, //
|
||||
r->compute.target_binding_y, //
|
||||
r->compute.target_binding_cbcr, //
|
||||
target_image_view_y, //
|
||||
@@ -804,13 +655,9 @@ render_compute_clear(struct render_compute *render,
|
||||
VkSampler sampler = r->samplers.mock;
|
||||
VkSampler src_samplers[XRT_MAX_VIEWS];
|
||||
VkImageView src_image_views[XRT_MAX_VIEWS];
|
||||
- VkSampler distortion_samplers[3 * XRT_MAX_VIEWS];
|
||||
for (uint32_t i = 0; i < render->r->view_count; ++i) {
|
||||
src_samplers[i] = sampler;
|
||||
src_image_views[i] = r->mock.color.image_view;
|
||||
- distortion_samplers[3 * i + 0] = sampler;
|
||||
- distortion_samplers[3 * i + 1] = sampler;
|
||||
- distortion_samplers[3 * i + 2] = sampler;
|
||||
}
|
||||
|
||||
update_compute_shared_descriptor_set( //
|
||||
@@ -819,8 +666,8 @@ render_compute_clear(struct render_compute *render,
|
||||
src_samplers, //
|
||||
src_image_views, //
|
||||
r->compute.distortion_binding, //
|
||||
- distortion_samplers, //
|
||||
- r->distortion.image_views, //
|
||||
+ VK_WHOLE_SIZE, //
|
||||
+ r->distortion.buffer, //
|
||||
r->compute.target_binding_y, //
|
||||
r->compute.target_binding_cbcr, //
|
||||
target_image_view_y, //
|
||||
diff --git a/src/xrt/compositor/render/render_interface.h b/src/xrt/compositor/render/render_interface.h
|
||||
index 2f8ce5287..d74ec78dd 100644
|
||||
--- a/src/xrt/compositor/render/render_interface.h
|
||||
+++ b/src/xrt/compositor/render/render_interface.h
|
||||
@@ -74,12 +74,8 @@ extern "C" {
|
||||
#define RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS)
|
||||
#define RENDER_MAX_LAYER_RUNS_COUNT(RENDER_RESOURCES) (RENDER_RESOURCES->view_count)
|
||||
|
||||
-//! Distortion image dimension in pixels
|
||||
-#define RENDER_DISTORTION_IMAGE_DIMENSIONS (128)
|
||||
-
|
||||
-//! How many distortion images we have, one for each channel (3 rgb) and per view.
|
||||
-#define RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS)
|
||||
-#define RENDER_DISTORTION_IMAGES_COUNT(RENDER_RESOURCES) (3 * RENDER_RESOURCES->view_count)
|
||||
+//! Foveation buffer dimension in pixels (including past-the end pixel)
|
||||
+#define RENDER_FOVEATION_BUFFER_DIMENSIONS (4096 + 1)
|
||||
|
||||
//! The binding that the layer projection and quad shader have their UBO on.
|
||||
#define RENDER_BINDING_LAYER_SHARED_UBO 0
|
||||
@@ -519,9 +515,6 @@ struct render_resources
|
||||
//! Doesn't depend on target so is static.
|
||||
VkPipeline pipeline;
|
||||
|
||||
- //! Doesn't depend on target so is static.
|
||||
- VkPipeline timewarp_pipeline;
|
||||
-
|
||||
//! Target info.
|
||||
struct render_buffer ubo;
|
||||
} distortion;
|
||||
@@ -543,17 +536,11 @@ struct render_resources
|
||||
//! Transform to go from UV to tangle angles.
|
||||
struct xrt_normalized_rect uv_to_tanangle[XRT_MAX_VIEWS];
|
||||
|
||||
- //! Backing memory to distortion images.
|
||||
- VkDeviceMemory device_memories[RENDER_DISTORTION_IMAGES_SIZE];
|
||||
-
|
||||
- //! Distortion images.
|
||||
- VkImage images[RENDER_DISTORTION_IMAGES_SIZE];
|
||||
+ //! Backing memory to foveation buffers.
|
||||
+ VkDeviceMemory device_memory;
|
||||
|
||||
- //! The views into the distortion images.
|
||||
- VkImageView image_views[RENDER_DISTORTION_IMAGES_SIZE];
|
||||
-
|
||||
- //! Whether distortion images have been pre-rotated 90 degrees.
|
||||
- bool pre_rotated;
|
||||
+ //! Foveation buffer.
|
||||
+ VkBuffer buffer;
|
||||
} distortion;
|
||||
};
|
||||
|
||||
@@ -1298,6 +1285,14 @@ struct render_compute_distortion_ubo_data
|
||||
struct xrt_matrix_4x4 transforms[XRT_MAX_VIEWS];
|
||||
};
|
||||
|
||||
+struct render_compute_distortion_foveation_data
|
||||
+{
|
||||
+ // For each output pixel: index of the first pixel to read.
|
||||
+ // contains 1 additional value at the end for past-the end pixel
|
||||
+ uint32_t x[XRT_MAX_VIEWS * RENDER_FOVEATION_BUFFER_DIMENSIONS];
|
||||
+ uint32_t y[XRT_MAX_VIEWS * RENDER_FOVEATION_BUFFER_DIMENSIONS];
|
||||
+};
|
||||
+
|
||||
/*!
|
||||
* Init struct and create resources needed for compute rendering.
|
||||
*
|
||||
diff --git a/src/xrt/compositor/render/render_resources.c b/src/xrt/compositor/render/render_resources.c
|
||||
index 5b9addd59..7d4d9cddb 100644
|
||||
--- a/src/xrt/compositor/render/render_resources.c
|
||||
+++ b/src/xrt/compositor/render/render_resources.c
|
||||
@@ -258,8 +258,8 @@ create_compute_distortion_descriptor_set_layout(struct vk_bundle *vk,
|
||||
},
|
||||
{
|
||||
.binding = distortion_binding,
|
||||
- .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
- .descriptorCount = 6,
|
||||
+ .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
+ .descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
},
|
||||
{
|
||||
@@ -309,12 +309,6 @@ struct compute_layer_params
|
||||
uint32_t image_array_size;
|
||||
};
|
||||
|
||||
-struct compute_distortion_params
|
||||
-{
|
||||
- uint32_t distortion_texel_count;
|
||||
- VkBool32 do_timewarp;
|
||||
-};
|
||||
-
|
||||
XRT_CHECK_RESULT static VkResult
|
||||
create_compute_layer_pipeline(struct vk_bundle *vk,
|
||||
VkPipelineCache pipeline_cache,
|
||||
@@ -359,35 +353,15 @@ create_compute_distortion_pipeline(struct vk_bundle *vk,
|
||||
VkPipelineCache pipeline_cache,
|
||||
VkShaderModule shader,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
- const struct compute_distortion_params *params,
|
||||
VkPipeline *out_compute_pipeline)
|
||||
{
|
||||
-#define ENTRY(ID, FIELD) \
|
||||
- { \
|
||||
- .constantID = ID, \
|
||||
- .offset = offsetof(struct compute_distortion_params, FIELD), \
|
||||
- sizeof(params->FIELD), \
|
||||
- }
|
||||
-
|
||||
- VkSpecializationMapEntry entries[2] = {
|
||||
- ENTRY(0, distortion_texel_count),
|
||||
- ENTRY(1, do_timewarp),
|
||||
- };
|
||||
-#undef ENTRY
|
||||
-
|
||||
- VkSpecializationInfo specialization_info = {
|
||||
- .mapEntryCount = ARRAY_SIZE(entries),
|
||||
- .pMapEntries = entries,
|
||||
- .dataSize = sizeof(*params),
|
||||
- .pData = params,
|
||||
- };
|
||||
|
||||
return vk_create_compute_pipeline( //
|
||||
vk, // vk_bundle
|
||||
pipeline_cache, // pipeline_cache
|
||||
shader, // shader
|
||||
pipeline_layout, // pipeline_layout
|
||||
- &specialization_info, // specialization_info
|
||||
+ NULL, // specialization_info
|
||||
out_compute_pipeline); // out_compute_pipeline
|
||||
}
|
||||
|
||||
@@ -849,9 +823,9 @@ render_resources_init(struct render_resources *r,
|
||||
struct vk_descriptor_pool_info compute_pool_info = {
|
||||
.uniform_per_descriptor_count = 1,
|
||||
// layer images
|
||||
- .sampler_per_descriptor_count = r->compute.layer.image_array_size + RENDER_DISTORTION_IMAGES_COUNT(r),
|
||||
+ .sampler_per_descriptor_count = r->compute.layer.image_array_size,
|
||||
.storage_image_per_descriptor_count = 1,
|
||||
- .storage_buffer_per_descriptor_count = 0,
|
||||
+ .storage_buffer_per_descriptor_count = 1,
|
||||
.descriptor_count = compute_descriptor_count,
|
||||
.freeable = false,
|
||||
};
|
||||
@@ -971,39 +945,16 @@ render_resources_init(struct render_resources *r,
|
||||
VK_NAME_PIPELINE_LAYOUT(vk, r->compute.distortion.pipeline_layout,
|
||||
"render_resources compute distortion pipeline layout");
|
||||
|
||||
- struct compute_distortion_params distortion_params = {
|
||||
- .distortion_texel_count = RENDER_DISTORTION_IMAGE_DIMENSIONS,
|
||||
- .do_timewarp = false,
|
||||
- };
|
||||
-
|
||||
ret = create_compute_distortion_pipeline( //
|
||||
vk, // vk_bundle
|
||||
r->pipeline_cache, // pipeline_cache
|
||||
r->shaders->distortion_comp, // shader
|
||||
r->compute.distortion.pipeline_layout, // pipeline_layout
|
||||
- &distortion_params, // params
|
||||
&r->compute.distortion.pipeline); // out_compute_pipeline
|
||||
VK_CHK_WITH_RET(ret, "create_compute_distortion_pipeline", false);
|
||||
|
||||
VK_NAME_PIPELINE(vk, r->compute.distortion.pipeline, "render_resources compute distortion pipeline");
|
||||
|
||||
- struct compute_distortion_params distortion_timewarp_params = {
|
||||
- .distortion_texel_count = RENDER_DISTORTION_IMAGE_DIMENSIONS,
|
||||
- .do_timewarp = true,
|
||||
- };
|
||||
-
|
||||
- ret = create_compute_distortion_pipeline( //
|
||||
- vk, // vk_bundle
|
||||
- r->pipeline_cache, // pipeline_cache
|
||||
- r->shaders->distortion_comp, // shader
|
||||
- r->compute.distortion.pipeline_layout, // pipeline_layout
|
||||
- &distortion_timewarp_params, // params
|
||||
- &r->compute.distortion.timewarp_pipeline); // out_compute_pipeline
|
||||
- VK_CHK_WITH_RET(ret, "create_compute_distortion_pipeline", false);
|
||||
-
|
||||
- VK_NAME_PIPELINE(vk, r->compute.distortion.timewarp_pipeline,
|
||||
- "render_resources compute distortion timewarp pipeline");
|
||||
-
|
||||
size_t distortion_ubo_size = sizeof(struct render_compute_distortion_ubo_data);
|
||||
|
||||
ret = render_buffer_init( //
|
||||
@@ -1056,15 +1007,8 @@ render_resources_init(struct render_resources *r,
|
||||
* Compute distortion textures, not created until later.
|
||||
*/
|
||||
|
||||
- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
|
||||
- r->distortion.image_views[i] = VK_NULL_HANDLE;
|
||||
- }
|
||||
- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
|
||||
- r->distortion.images[i] = VK_NULL_HANDLE;
|
||||
- }
|
||||
- for (uint32_t i = 0; i < RENDER_DISTORTION_IMAGES_COUNT(r); i++) {
|
||||
- r->distortion.device_memories[i] = VK_NULL_HANDLE;
|
||||
- }
|
||||
+ r->distortion.buffer = VK_NULL_HANDLE;
|
||||
+ r->distortion.device_memory = VK_NULL_HANDLE;
|
||||
|
||||
|
||||
/*
|
||||
@@ -1141,7 +1085,6 @@ render_resources_fini(struct render_resources *r)
|
||||
|
||||
D(DescriptorSetLayout, r->compute.distortion.descriptor_set_layout);
|
||||
D(Pipeline, r->compute.distortion.pipeline);
|
||||
- D(Pipeline, r->compute.distortion.timewarp_pipeline);
|
||||
D(PipelineLayout, r->compute.distortion.pipeline_layout);
|
||||
|
||||
D(Pipeline, r->compute.clear.pipeline);
|
||||
diff --git a/src/xrt/compositor/shaders/distortion.comp b/src/xrt/compositor/shaders/distortion.comp
|
||||
index 9ce46fe6f..cd1828ac9 100644
|
||||
--- a/src/xrt/compositor/shaders/distortion.comp
|
||||
+++ b/src/xrt/compositor/shaders/distortion.comp
|
||||
@@ -4,20 +4,22 @@
|
||||
|
||||
#version 460
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
+#extension GL_KHR_shader_subgroup_basic: require
|
||||
+#extension GL_KHR_shader_subgroup_shuffle: require
|
||||
|
||||
#include "srgb.inc.glsl"
|
||||
|
||||
-
|
||||
-// The size of the distortion texture dimensions in texels.
|
||||
-layout(constant_id = 0) const int distortion_texel_count = 2;
|
||||
-
|
||||
-// Should we do timewarp.
|
||||
-layout(constant_id = 1) const bool do_timewarp = false;
|
||||
-
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
+#define MAX_DIM 4097
|
||||
+
|
||||
layout(set = 0, binding = 0) uniform sampler2D source[2];
|
||||
-layout(set = 0, binding = 1) uniform sampler2D distortion[6];
|
||||
+layout(set = 0, binding = 1, std430) buffer restrict Foveation
|
||||
+{
|
||||
+ uint x[2*MAX_DIM];
|
||||
+ uint y[2*MAX_DIM];
|
||||
+} foveation;
|
||||
+
|
||||
layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
|
||||
layout(set = 0, binding = 3, std140) uniform restrict Config
|
||||
{
|
||||
@@ -41,122 +43,59 @@ vec3 rgb_to_ycbcr(vec3 color)
|
||||
return transpose(color_space) * color + vec3(0, 0.5, 0.5);
|
||||
}
|
||||
|
||||
-vec2 position_to_uv(ivec2 extent, uint ix, uint iy)
|
||||
-{
|
||||
- // Turn the index into floating point.
|
||||
- vec2 xy = vec2(float(ix), float(iy));
|
||||
-
|
||||
- // The inverse of the extent of the target image is the pixel size in [0 .. 1] space.
|
||||
- vec2 extent_pixel_size = vec2(1.0 / float(extent.x), 1.0 / float(extent.y));
|
||||
-
|
||||
- // Per-target pixel we move the size of the pixels.
|
||||
- vec2 dist_uv = xy * extent_pixel_size;
|
||||
-
|
||||
- // Emulate a triangle sample position by offset half target pixel size.
|
||||
- dist_uv = dist_uv + extent_pixel_size / 2.0;
|
||||
-
|
||||
-
|
||||
- // To correctly sample we need to put position (0, 0) in the
|
||||
- // middle of the (0, 0) texel in the distortion textures. That's why we
|
||||
- // offset with half the texel size, pushing all samples into the middle
|
||||
- // of each texels, a kin to a vertex buffer. We need to put uv coord
|
||||
- // (1, 1) in the middle of the last texel, that pixel is (size - 1)
|
||||
- // texels away from the first texel. So we need to scale [0 .. 1] to
|
||||
- // [0 .. size - 1].
|
||||
-
|
||||
-#define DIM (float(distortion_texel_count))
|
||||
-#define STRETCH ((DIM - 1.0) / DIM)
|
||||
-#define OFFSET (1.0 / (DIM * 2.0))
|
||||
-
|
||||
- dist_uv = (dist_uv * STRETCH) + OFFSET;
|
||||
-
|
||||
- return dist_uv;
|
||||
-}
|
||||
-
|
||||
-vec2 transform_uv_subimage(vec2 uv, uint iz)
|
||||
-{
|
||||
- vec2 values = uv;
|
||||
-
|
||||
- // To deal with OpenGL flip and sub image view.
|
||||
- values.xy = values.xy * ubo.post_transform[iz].zw + ubo.post_transform[iz].xy;
|
||||
-
|
||||
- // Ready to be used.
|
||||
- return values.xy;
|
||||
-}
|
||||
-
|
||||
-vec2 transform_uv_timewarp(vec2 uv, uint iz)
|
||||
-{
|
||||
- vec4 values = vec4(uv, -1, 1);
|
||||
-
|
||||
- // From uv to tan angle (tangent space).
|
||||
- values.xy = values.xy * ubo.pre_transform[iz].zw + ubo.pre_transform[iz].xy;
|
||||
- values.y = -values.y; // Flip to OpenXR coordinate system.
|
||||
-
|
||||
- // Timewarp.
|
||||
- values = ubo.transform[iz] * values;
|
||||
- values.xy = values.xy * (1.0 / max(values.w, 0.00001));
|
||||
-
|
||||
- // From [-1, 1] to [0, 1]
|
||||
- values.xy = values.xy * 0.5 + 0.5;
|
||||
-
|
||||
- // To deal with OpenGL flip and sub image view.
|
||||
- values.xy = values.xy * ubo.post_transform[iz].zw + ubo.post_transform[iz].xy;
|
||||
-
|
||||
- // Done.
|
||||
- return values.xy;
|
||||
-}
|
||||
-
|
||||
-vec2 transform_uv(vec2 uv, uint iz)
|
||||
-{
|
||||
- if (do_timewarp) {
|
||||
- return transform_uv_timewarp(uv, iz);
|
||||
- } else {
|
||||
- return transform_uv_subimage(uv, iz);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
void main()
|
||||
{
|
||||
uint iz = gl_GlobalInvocationID.z;
|
||||
|
||||
ivec2 offset = ivec2(ubo.views[iz].xy);
|
||||
ivec2 extent = ivec2(ubo.views[iz].zw);
|
||||
- vec2 cbcrs[4];
|
||||
- vec4 alpha;
|
||||
- for (int k = 0; k < 2; k += 1) {
|
||||
- uint iy = gl_GlobalInvocationID.y * 2 + k;
|
||||
- for (int j = 0; j < 2; j += 1) {
|
||||
- uint ix = gl_GlobalInvocationID.x * 2 + j;
|
||||
-
|
||||
- vec2 dist_uv = position_to_uv(extent, ix, iy);
|
||||
-
|
||||
- vec2 uv = texture(distortion[iz + 0], dist_uv).xy;
|
||||
- vec2 lod = texture(distortion[iz + 2], dist_uv).xy;
|
||||
-
|
||||
- // Do any transformation needed.
|
||||
- uv = transform_uv(uv, iz);
|
||||
-
|
||||
- // Sample the source
|
||||
- vec4 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5));
|
||||
-
|
||||
- colour.rgb = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
|
||||
+ uint iy = gl_GlobalInvocationID.y;
|
||||
+ uint ymin = foveation.y[MAX_DIM * iz + iy];
|
||||
+ uint ymax = foveation.y[MAX_DIM * iz + iy + 1];
|
||||
+ if (ymin == ymax)
|
||||
+ return;
|
||||
+ if (ymin > ymax)
|
||||
+ {
|
||||
+ uint tmp = ymin;
|
||||
+ ymin = ymax;
|
||||
+ ymax = tmp;
|
||||
+ }
|
||||
+ uint ix = gl_GlobalInvocationID.x;
|
||||
|
||||
- int i = k * 2 + j;
|
||||
- cbcrs[i] = colour.yz;
|
||||
- alpha[i] = colour.a;
|
||||
+ uint xmin = foveation.x[MAX_DIM * iz + ix];
|
||||
+ uint xmax = foveation.x[MAX_DIM * iz + ix + 1];
|
||||
+ if (xmin == xmax)
|
||||
+ return;
|
||||
|
||||
- if (ix < extent.x && iy < extent.y) {
|
||||
- imageStore(luma, ivec3(offset.x + ix, offset.y + iy, 0), vec4(colour.x));
|
||||
- }
|
||||
+ vec4 colour = vec4(0);
|
||||
+ for (uint y = ymin ; y < ymax; y += 1) {
|
||||
+ for (uint x = xmin ; x < xmax; x += 1) {
|
||||
+ colour += texelFetch(source[iz], ivec2(x, y), 0);
|
||||
}
|
||||
}
|
||||
- if (gl_GlobalInvocationID.x >= extent.x || gl_GlobalInvocationID.y >= extent.y) {
|
||||
- return;
|
||||
+ colour /= (xmax - xmin) * (ymax - ymin);
|
||||
+ colour.xyz = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
|
||||
+
|
||||
+ imageStore(luma, ivec3(offset.x + ix, offset.y + iy, 0), vec4(colour.x));
|
||||
+
|
||||
+ vec4 sum = colour;
|
||||
+ for (uint i = 0 ; i < gl_SubgroupSize; ++i)
|
||||
+ {
|
||||
+ uvec3 other = subgroupShuffle(gl_GlobalInvocationID, i);
|
||||
+ vec4 c = subgroupShuffle(colour, i);
|
||||
+ if (
|
||||
+ other == gl_GlobalInvocationID + uvec3(1, 0, 0)
|
||||
+ || other == gl_GlobalInvocationID + uvec3(0, 1, 0)
|
||||
+ || other == gl_GlobalInvocationID + uvec3(1, 1, 0))
|
||||
+ {
|
||||
+ sum += c;
|
||||
+ }
|
||||
}
|
||||
- vec2 cbcr = mix(mix(cbcrs[0], cbcrs[1], 0.5), mix(cbcrs[2], cbcrs[3], 0.5), 0.5);
|
||||
- imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 0), vec4(cbcr.x, cbcr.y, 0, 0));
|
||||
|
||||
- imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), vec4(0.5, 0.5, 0, 0));
|
||||
- alpha = vec4(mix(mix(alpha[0], alpha[1], 0.5), mix(alpha[2], alpha[3], 0.5), 0.5));
|
||||
- imageStore(luma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), alpha);
|
||||
+ if (ix %2 == 0 && iy %2 == 0)
|
||||
+ {
|
||||
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy/2, 0), vec4(sum.y, sum.z, 0, 0) / 4);
|
||||
+ imageStore(luma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy/2, 1), vec4(sum.w, 0, 0, 0) / 4);
|
||||
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy/2, 1), vec4(0.5, 0.5, 0, 0));
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/xrt/compositor/util/comp_render_cs.c b/src/xrt/compositor/util/comp_render_cs.c
|
||||
index b2d3ce10d..69429dc97 100644
|
||||
--- a/src/xrt/compositor/util/comp_render_cs.c
|
||||
+++ b/src/xrt/compositor/util/comp_render_cs.c
|
||||
@@ -466,30 +466,15 @@ crc_distortion_fast_path(struct render_compute *render,
|
||||
world_poses[i] = world_pose;
|
||||
}
|
||||
|
||||
- if (!d->do_timewarp) {
|
||||
- render_compute_projection( //
|
||||
- render, //
|
||||
- src_samplers, //
|
||||
- src_image_views, //
|
||||
- src_norm_rects, //
|
||||
- d->target.cs.image, //
|
||||
- d->target.cs.storage_view_y, //
|
||||
- d->target.cs.storage_view_cbcr, //
|
||||
- target_viewport_datas); //
|
||||
- } else {
|
||||
- render_compute_projection_timewarp( //
|
||||
- render, //
|
||||
- src_samplers, //
|
||||
- src_image_views, //
|
||||
- src_norm_rects, //
|
||||
- src_poses, //
|
||||
- src_fovs, //
|
||||
- world_poses, //
|
||||
- d->target.cs.image, //
|
||||
- d->target.cs.storage_view_y, //
|
||||
- d->target.cs.storage_view_cbcr, //
|
||||
- target_viewport_datas); //
|
||||
- }
|
||||
+ render_compute_projection( //
|
||||
+ render, //
|
||||
+ src_samplers, //
|
||||
+ src_image_views, //
|
||||
+ src_norm_rects, //
|
||||
+ d->target.cs.image, //
|
||||
+ d->target.cs.storage_view_y, //
|
||||
+ d->target.cs.storage_view_cbcr, //
|
||||
+ target_viewport_datas); //
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.50.1
|
||||
|
||||
Reference in New Issue
Block a user