Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
From 18e184e504d9f55dbba3f02c87f96410b2ce04ab Mon Sep 17 00:00:00 2001
|
||||
From 483ce192460569020fa57522ee2bea99198dac2e 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/10] c/multi: early wake of compositor
|
||||
Subject: [PATCH 01/13] c/multi: early wake of compositor
|
||||
|
||||
---
|
||||
.../compositor/multi/comp_multi_compositor.c | 14 +++++++++
|
||||
@@ -10,10 +10,10 @@ Subject: [PATCH 01/10] c/multi: early wake of compositor
|
||||
3 files changed, 41 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/multi/comp_multi_compositor.c b/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
index 553565db4..789a2d042 100644
|
||||
index 94cea110e..88347a092 100644
|
||||
--- a/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
+++ b/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
@@ -232,7 +232,21 @@ wait_for_scheduled_free(struct multi_compositor *mc)
|
||||
@@ -236,7 +236,21 @@ wait_for_scheduled_free(struct multi_compositor *mc)
|
||||
os_mutex_lock(&mc->slot_lock);
|
||||
slot_move_and_clear_locked(mc, &mc->scheduled, &mc->progress);
|
||||
os_mutex_unlock(&mc->slot_lock);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From b31b5aa4e7e890ae079ae2953a1ce3fc2e47b954 Mon Sep 17 00:00:00 2001
|
||||
From 642f328ff08872289082f591b393aa72cdfffe0a 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/10] ipc/server: Always listen to stdin
|
||||
Subject: [PATCH 02/13] ipc/server: Always listen to stdin
|
||||
|
||||
---
|
||||
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 2 +-
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 46cacda03c5552ffb70601dd89e0abe38e97c1d3 Mon Sep 17 00:00:00 2001
|
||||
From a06da2ceeddf3f7760501114efa35bd168ba74bc 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/10] Use extern socket fd
|
||||
Subject: [PATCH 03/13] Use extern socket fd
|
||||
|
||||
---
|
||||
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 8 ++++++++
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 90c3842f38985e0f8f06bb51d0e58cccf437526f Mon Sep 17 00:00:00 2001
|
||||
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/10] c/render: Add storage usage to distortion mesh
|
||||
Subject: [PATCH 04/13] c/render: Add storage usage to distortion mesh
|
||||
|
||||
---
|
||||
src/xrt/compositor/render/render_distortion.c | 2 +-
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 9e2288bc85a5be9bb0228a42dc5a9419c4357eb8 Mon Sep 17 00:00:00 2001
|
||||
From a28d3e6a3e85b7c04392137b30958e8b1d13c591 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/10] change environment blend mode selection logic
|
||||
Subject: [PATCH 05/13] change environment blend mode selection logic
|
||||
|
||||
---
|
||||
src/xrt/compositor/multi/comp_multi_system.c | 26 +++++++++++++-------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 437469e6a4de72ab69719cce92b841e4de19156f Mon Sep 17 00:00:00 2001
|
||||
From ec28b5726922e300dc05085a30150223c6a2183a Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Wed, 11 Sep 2024 22:56:29 +0200
|
||||
Subject: [PATCH 06/10] Convert to YCbCr in Monado
|
||||
Subject: [PATCH 06/13] Convert to YCbCr in Monado
|
||||
|
||||
---
|
||||
src/xrt/compositor/main/comp_renderer.c | 6 +-
|
||||
@@ -17,10 +17,10 @@ Subject: [PATCH 06/10] Convert to YCbCr in Monado
|
||||
10 files changed, 184 insertions(+), 86 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/main/comp_renderer.c b/src/xrt/compositor/main/comp_renderer.c
|
||||
index c6f589466..0895ff694 100644
|
||||
index e45d33e22..d2518585c 100644
|
||||
--- a/src/xrt/compositor/main/comp_renderer.c
|
||||
+++ b/src/xrt/compositor/main/comp_renderer.c
|
||||
@@ -933,7 +933,8 @@ dispatch_compute(struct comp_renderer *r,
|
||||
@@ -936,7 +936,8 @@ dispatch_compute(struct comp_renderer *r,
|
||||
|
||||
// Target Vulkan resources..
|
||||
VkImage target_image = r->c->target->images[r->acquired_buffer].handle;
|
||||
@@ -30,7 +30,7 @@ index c6f589466..0895ff694 100644
|
||||
|
||||
// Target view information.
|
||||
struct render_viewport_data target_viewport_datas[XRT_MAX_VIEWS];
|
||||
@@ -949,7 +950,8 @@ dispatch_compute(struct comp_renderer *r,
|
||||
@@ -952,7 +953,8 @@ dispatch_compute(struct comp_renderer *r,
|
||||
eye_poses, //
|
||||
fovs, //
|
||||
target_image, //
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 5a791919ce1e01f2cb0034e4055bf22767a41121 Mon Sep 17 00:00:00 2001
|
||||
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/10] store alpha channel in layer 1
|
||||
Subject: [PATCH 07/13] store alpha channel in layer 1
|
||||
|
||||
---
|
||||
src/xrt/compositor/shaders/clear.comp | 4 ++--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 877709160be24c4bd504b8d8cd04197cc2bf2b69 Mon Sep 17 00:00:00 2001
|
||||
From 0d2ae2efb84f1479151c096e26f3295eded3b170 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/10] c/main: allow custom pacing app factory
|
||||
Subject: [PATCH 08/13] c/main: allow custom pacing app factory
|
||||
|
||||
---
|
||||
src/xrt/compositor/main/comp_compositor.c | 10 ++++++----
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 53d8509dff69caccecdc38b443864b1a755486dd Mon Sep 17 00:00:00 2001
|
||||
From 1a9b288475830fc1caf9bbf340ea370677b239a5 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/10] st/oxr: forward 0 refresh rate
|
||||
Subject: [PATCH 09/13] st/oxr: forward 0 refresh rate
|
||||
|
||||
---
|
||||
src/xrt/state_trackers/oxr/oxr_api_session.c | 6 +-----
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
From 1bc74f74b613cce9d32c0f4bf16de70ddb7fb482 Mon Sep 17 00:00:00 2001
|
||||
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/10] Replace distortion with pixel-aligned foveation
|
||||
Subject: [PATCH 10/13] Replace distortion with pixel-aligned foveation
|
||||
|
||||
---
|
||||
src/xrt/compositor/CMakeLists.txt | 2 +-
|
||||
src/xrt/compositor/render/render_compute.c | 181 ++-----------------
|
||||
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 | 134 ++++----------
|
||||
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, 76 insertions(+), 378 deletions(-)
|
||||
6 files changed, 101 insertions(+), 392 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt
|
||||
index 1ba5ec438..f1defe77a 100644
|
||||
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
|
||||
@@ -26,9 +35,20 @@ index 1ba5ec438..f1defe77a 100644
|
||||
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..5cd5a1726 100644
|
||||
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],
|
||||
@@ -478,10 +498,15 @@ index 5b9addd59..7d4d9cddb 100644
|
||||
|
||||
D(Pipeline, r->compute.clear.pipeline);
|
||||
diff --git a/src/xrt/compositor/shaders/distortion.comp b/src/xrt/compositor/shaders/distortion.comp
|
||||
index 9ce46fe6f..f3be617bd 100644
|
||||
index 9ce46fe6f..cd1828ac9 100644
|
||||
--- a/src/xrt/compositor/shaders/distortion.comp
|
||||
+++ b/src/xrt/compositor/shaders/distortion.comp
|
||||
@@ -7,17 +7,17 @@
|
||||
@@ -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"
|
||||
|
||||
@@ -507,7 +532,7 @@ index 9ce46fe6f..f3be617bd 100644
|
||||
layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
|
||||
layout(set = 0, binding = 3, std140) uniform restrict Config
|
||||
{
|
||||
@@ -41,109 +41,40 @@ vec3 rgb_to_ycbcr(vec3 color)
|
||||
@@ -41,122 +43,59 @@ vec3 rgb_to_ycbcr(vec3 color)
|
||||
return transpose(color_space) * color + vec3(0, 0.5, 0.5);
|
||||
}
|
||||
|
||||
@@ -593,24 +618,13 @@ index 9ce46fe6f..f3be617bd 100644
|
||||
ivec2 extent = ivec2(ubo.views[iz].zw);
|
||||
- vec2 cbcrs[4];
|
||||
- vec4 alpha;
|
||||
+ vec3 cbcra = vec3(0);
|
||||
for (int k = 0; k < 2; k += 1) {
|
||||
uint iy = gl_GlobalInvocationID.y * 2 + k;
|
||||
+ uint ymin = foveation.y[MAX_DIM * iz + iy];
|
||||
+ uint ymax = foveation.y[MAX_DIM * iz + iy + 1];
|
||||
+ if (ymin > ymax)
|
||||
+ {
|
||||
+ uint tmp = ymin;
|
||||
+ ymin = ymax;
|
||||
+ ymax = tmp;
|
||||
+ }
|
||||
for (int j = 0; j < 2; j += 1) {
|
||||
uint ix = gl_GlobalInvocationID.x * 2 + j;
|
||||
|
||||
- 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);
|
||||
+ uint xmin = foveation.x[MAX_DIM * iz + ix];
|
||||
+ uint xmax = foveation.x[MAX_DIM * iz + ix + 1];
|
||||
|
||||
-
|
||||
- vec2 uv = texture(distortion[iz + 0], dist_uv).xy;
|
||||
- vec2 lod = texture(distortion[iz + 2], dist_uv).xy;
|
||||
-
|
||||
@@ -621,35 +635,68 @@ index 9ce46fe6f..f3be617bd 100644
|
||||
- vec4 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5));
|
||||
-
|
||||
- colour.rgb = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
|
||||
+ 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);
|
||||
+ }
|
||||
+ }
|
||||
+ colour /= (xmax - xmin) * (ymax - ymin);
|
||||
+ colour.xyz = 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;
|
||||
+ cbcra.xy += colour.yz;
|
||||
+ cbcra.z += 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));
|
||||
@@ -153,10 +84,7 @@ void main()
|
||||
if (gl_GlobalInvocationID.x >= extent.x || gl_GlobalInvocationID.y >= extent.y) {
|
||||
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, 0), vec4(cbcra.x, cbcra.y, 0, 0) / 4);
|
||||
+ imageStore(luma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), vec4(cbcra.z, 0, 0, 0) / 4);
|
||||
imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), vec4(0.5, 0.5, 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 4905a1bd2a32d0cef4ade575021b17cf453632f0 Mon Sep 17 00:00:00 2001
|
||||
From 34699c38c4ebb5c968b4e1053ddbf48b31dbe72d Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 5 Aug 2025 15:51:48 +0200
|
||||
Subject: [PATCH 1/3] a/vk: Track VK_KHR_video_maintenance1
|
||||
Subject: [PATCH 11/13] a/vk: Track VK_KHR_video_maintenance1
|
||||
|
||||
---
|
||||
scripts/generate_vk_helpers.py | 1 +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 26d9345724a868304b9d3ca5b58fecef02493df3 Mon Sep 17 00:00:00 2001
|
||||
From 2300c7509699db2a59e4bd0eee33890a2d906156 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 5 Aug 2025 16:00:59 +0200
|
||||
Subject: [PATCH 2/3] a/vk: Expose video_maintenance_1 device feature
|
||||
Subject: [PATCH 12/13] a/vk: Expose video_maintenance_1 device feature
|
||||
|
||||
---
|
||||
src/xrt/auxiliary/vk/vk_bundle_init.c | 40 +++++++++++++++++++++++++--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From b8e23426ec5ac97efdceaf2a319b9d5921e7b412 Mon Sep 17 00:00:00 2001
|
||||
From 8c874368dfaa363e088e91c05adf2a96f921671d Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 5 Aug 2025 16:01:59 +0200
|
||||
Subject: [PATCH 3/3] c/util: Request video_maintenance_1 feature
|
||||
Subject: [PATCH 13/13] c/util: Request video_maintenance_1 feature
|
||||
|
||||
This will only be enabled if the VK_KHR_maintenance1 extension was
|
||||
requested.
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "render/render_interface.h"
|
||||
#include "vk/vk_mini_helpers.h"
|
||||
|
||||
#include "wivrn_foveation.h"
|
||||
|
||||
@@ -44,22 +43,13 @@ bool render_distortion_images_ensure(struct render_resources * r,
|
||||
bool pre_rotate)
|
||||
{
|
||||
if (r->distortion.buffer == VK_NULL_HANDLE)
|
||||
{
|
||||
return vk_buffer_init(vk,
|
||||
sizeof(render_compute_distortion_foveation_data),
|
||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
&r->distortion.buffer,
|
||||
&r->distortion.device_memory);
|
||||
}
|
||||
r->distortion.buffer = wivrn::wivrn_foveation::instance().get_gpu_buffer();
|
||||
return true;
|
||||
}
|
||||
|
||||
void render_distortion_images_fini(struct render_resources * r)
|
||||
{
|
||||
auto * vk = r->vk;
|
||||
D(Buffer, r->distortion.buffer);
|
||||
DF(Memory, r->distortion.device_memory);
|
||||
r->distortion.buffer = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
// a, b: parameters computed by solve_foveation
|
||||
@@ -320,20 +310,35 @@ wivrn_foveation::wivrn_foveation(wivrn_vk_bundle & bundle, const xrt_hmd_parts &
|
||||
.commandPool = *command_pool,
|
||||
.commandBufferCount = 1,
|
||||
})[0])),
|
||||
host_buffer(
|
||||
gpu_buffer(
|
||||
bundle.device,
|
||||
{
|
||||
.size = sizeof(render_compute_distortion_foveation_data),
|
||||
.usage = vk::BufferUsageFlagBits::eTransferSrc,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eStorageBuffer,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
})
|
||||
},
|
||||
"foveation storage buffer")
|
||||
{
|
||||
if (not(gpu_buffer.properties() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
|
||||
{
|
||||
host_buffer = buffer_allocation(
|
||||
bundle.device,
|
||||
{
|
||||
.size = gpu_buffer.info().size,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferSrc,
|
||||
},
|
||||
{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST,
|
||||
},
|
||||
"foveation staging buffer");
|
||||
bundle.name(vk::Buffer(host_buffer), "foveation staging buffer");
|
||||
}
|
||||
bundle.name(command_pool, "foveation command pool");
|
||||
bundle.name(cmd, "foveation command buffer");
|
||||
bundle.name(vk::Buffer(host_buffer), "foveation staging buffer");
|
||||
}
|
||||
|
||||
void wivrn_foveation::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
@@ -389,7 +394,7 @@ std::array<to_headset::foveation_parameter, 2> wivrn_foveation::get_parameters()
|
||||
}
|
||||
|
||||
static void fill_ubo(
|
||||
uint32_t * ubo,
|
||||
std::span<uint32_t> ubo,
|
||||
const std::vector<uint16_t> & params,
|
||||
bool flip,
|
||||
size_t offset,
|
||||
@@ -398,9 +403,9 @@ static void fill_ubo(
|
||||
{
|
||||
assert(params.size() % 2 == 1);
|
||||
const int n_ratio = (params.size() - 1) / 2;
|
||||
*ubo = offset;
|
||||
ubo[0] = offset;
|
||||
if (flip)
|
||||
*ubo += size;
|
||||
ubo[0] += size;
|
||||
for (auto [i, n]: std::ranges::enumerate_view(params))
|
||||
{
|
||||
const int n_source = std::abs(n_ratio - int(i)) + 1;
|
||||
@@ -411,12 +416,12 @@ static void fill_ubo(
|
||||
ubo[1] = ubo[0] - n_source;
|
||||
else
|
||||
ubo[1] = ubo[0] + n_source;
|
||||
++ubo;
|
||||
ubo = ubo.subspan(1);
|
||||
--count;
|
||||
}
|
||||
}
|
||||
if (count > 0)
|
||||
std::fill(ubo + 1, ubo + count + 1, *ubo);
|
||||
if (not ubo.empty())
|
||||
std::ranges::fill(ubo, ubo[0]);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -434,6 +439,11 @@ static bool operator==(const xrt_fov & a, const xrt_fov & b)
|
||||
return a.angle_left == b.angle_left and a.angle_right == b.angle_right and a.angle_up == b.angle_up and a.angle_down == b.angle_down;
|
||||
}
|
||||
|
||||
vk::Buffer wivrn_foveation::get_gpu_buffer()
|
||||
{
|
||||
return gpu_buffer;
|
||||
}
|
||||
|
||||
vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
vk::Buffer target,
|
||||
bool flip_y,
|
||||
@@ -443,14 +453,6 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
if (not target)
|
||||
return nullptr;
|
||||
|
||||
if (target != gpu_buffer)
|
||||
{
|
||||
command_pool.reset();
|
||||
cmd.begin({});
|
||||
cmd.copyBuffer(host_buffer, target, vk::BufferCopy{.size = sizeof(render_compute_distortion_foveation_data)});
|
||||
cmd.end();
|
||||
}
|
||||
|
||||
// Check if the last value is still valid
|
||||
std::lock_guard lock(mutex);
|
||||
if (last.flip_y == flip_y //
|
||||
@@ -467,6 +469,15 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
)
|
||||
return nullptr;
|
||||
|
||||
assert(target == gpu_buffer);
|
||||
if (host_buffer)
|
||||
{
|
||||
command_pool.reset();
|
||||
cmd.begin({});
|
||||
cmd.copyBuffer(host_buffer, target, vk::BufferCopy{.size = sizeof(render_compute_distortion_foveation_data)});
|
||||
cmd.end();
|
||||
}
|
||||
|
||||
last = {
|
||||
.gaze = gaze,
|
||||
.flip_y = flip_y,
|
||||
@@ -478,7 +489,7 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
|
||||
compute_params(source, fovs);
|
||||
|
||||
auto ubo = (render_compute_distortion_foveation_data *)host_buffer.map();
|
||||
auto ubo = host_buffer ? host_buffer.data<render_compute_distortion_foveation_data>() : gpu_buffer.data<render_compute_distortion_foveation_data>();
|
||||
for (size_t view = 0; view < 2; ++view)
|
||||
{
|
||||
bool flip = false;
|
||||
@@ -495,7 +506,7 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
offset = source[view].offset.w;
|
||||
extent = source[view].extent.w;
|
||||
}
|
||||
fill_ubo(ubo->x + view * RENDER_FOVEATION_BUFFER_DIMENSIONS, params[view].x, flip, offset, extent, foveated_width);
|
||||
fill_ubo(std::span(ubo->x + view * RENDER_FOVEATION_BUFFER_DIMENSIONS, RENDER_FOVEATION_BUFFER_DIMENSIONS), params[view].x, flip, offset, extent, foveated_width);
|
||||
|
||||
if (source[view].extent.h < 0)
|
||||
{
|
||||
@@ -509,8 +520,10 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
offset = source[view].offset.h;
|
||||
extent = source[view].extent.h;
|
||||
}
|
||||
fill_ubo(ubo->y + view * RENDER_FOVEATION_BUFFER_DIMENSIONS, params[view].y, flip, offset, extent, foveated_height);
|
||||
fill_ubo(std::span(ubo->y + view * RENDER_FOVEATION_BUFFER_DIMENSIONS, RENDER_FOVEATION_BUFFER_DIMENSIONS), params[view].y, flip, offset, extent, foveated_height);
|
||||
}
|
||||
return *cmd;
|
||||
if (host_buffer)
|
||||
return *cmd;
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_device.h"
|
||||
|
||||
#include "utils/singleton.h"
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
struct render_resources;
|
||||
@@ -34,7 +35,7 @@ namespace wivrn
|
||||
struct clock_offset;
|
||||
struct wivrn_vk_bundle;
|
||||
|
||||
class wivrn_foveation
|
||||
class wivrn_foveation : public singleton<wivrn_foveation>
|
||||
{
|
||||
std::mutex mutex;
|
||||
|
||||
@@ -53,8 +54,8 @@ class wivrn_foveation
|
||||
|
||||
vk::raii::CommandPool command_pool;
|
||||
vk::raii::CommandBuffer cmd;
|
||||
buffer_allocation gpu_buffer;
|
||||
buffer_allocation host_buffer;
|
||||
vk::Buffer gpu_buffer = nullptr;
|
||||
|
||||
// parameters used for last computation
|
||||
struct P
|
||||
@@ -81,6 +82,8 @@ public:
|
||||
void update_foveation_center_override(const from_headset::override_foveation_center &);
|
||||
std::array<to_headset::foveation_parameter, 2> get_parameters();
|
||||
|
||||
vk::Buffer get_gpu_buffer();
|
||||
|
||||
vk::CommandBuffer update_foveation_buffer(
|
||||
vk::Buffer target,
|
||||
bool flip_y,
|
||||
|
||||
Reference in New Issue
Block a user