mirror of
https://github.com/mitch030504/Wiicompiled_VR_Frame.git
synced 2026-10-06 09:00:28 +02:00
- Eyes render under a VK_EXT_fragment_density_map: full rate around each eye's forward direction, 2x2 then 4x4 pixel blocks towards the edges ([vr] foveation = off|low|medium|high, default off). XR_FB_foveation cannot help here: the runtime's maps only shape passes drawing into its swapchain, and the eyes reach it through a copy. - aurora-main/patches/dawn/aurora_fdm.inc: Dawn enables the extension only on request and for dynamic rendering, flags every render pipeline, and chains an immutable RG8 map into any pass whose first color attachment is a view bound to one (ABI: include/aurora/dawn_fdm_abi.h). - android/Build-QuestDawn.ps1 builds the pinned Dawn revision with those patches for arm64 (dawn-build CI flags, protobuf off) into a cached package; Build-Quest.ps1 links it (-StockDawn opts out) and AuroraDawnProvider.cmake enables the ABI from its manifest. - lib/gfx/foveation.hpp generates the maps (32 px per texel, densities 255/127/63); an eye is foveated only when single_pass_eyes draws it in one render pass. Menus never are. - Live level from the headset panel's VR tab and the launcher; the launch decides whether the device has maps. debug.wiicompiled.foveation and debug.wiicompiled.fdm for A/B. - Tests: Foveation cases in gx_fifo_tests, mkw_vr_config_tests. Docs: OPENXR.md, quest-port.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
3.1 KiB
C++
108 lines
3.1 KiB
C++
#include "fdm.hpp"
|
|
|
|
#include "../internal.hpp"
|
|
#include "gpu.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <bit>
|
|
|
|
// AURORA_DAWN_FDM carries the ABI version of the Dawn package's patches (AuroraDawnProvider.cmake).
|
|
#if defined(__ANDROID__) && defined(AURORA_DAWN_FDM)
|
|
#include <aurora/dawn_fdm_abi.h>
|
|
static_assert(AURORA_DAWN_FDM == AURORA_DAWN_FDM_ABI,
|
|
"The Dawn package's fragment density map ABI does not match include/aurora/dawn_fdm_abi.h");
|
|
#define AURORA_FDM_SUPPORTED 1
|
|
#endif
|
|
|
|
namespace aurora::webgpu::fdm {
|
|
namespace {
|
|
Module Log("aurora::webgpu::fdm");
|
|
|
|
bool g_requested = false;
|
|
bool g_available = false;
|
|
uint32_t g_texelSize = 0;
|
|
|
|
// Meta's own maps use 32: rings smooth enough, in a map of a few hundred texels.
|
|
constexpr uint32_t kPreferredTexelSize = 32;
|
|
} // namespace
|
|
|
|
void request(bool wanted) noexcept {
|
|
g_requested = wanted;
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
AuroraDawnFdmRequest(wanted ? 1 : 0);
|
|
#endif
|
|
}
|
|
|
|
void device_created() noexcept {
|
|
g_available = false;
|
|
g_texelSize = 0;
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
AuroraDawnFdmCaps caps{};
|
|
if (AuroraDawnFdmQuery(g_device.Get(), &caps) != 0) {
|
|
// Density texels cover a power-of-two area within the device's range in each direction.
|
|
const uint32_t smallest = std::max({caps.minTexelWidth, caps.minTexelHeight, 1u});
|
|
const uint32_t largest = std::max(std::min(caps.maxTexelWidth, caps.maxTexelHeight), smallest);
|
|
g_texelSize = std::bit_ceil(std::clamp(kPreferredTexelSize, smallest, largest));
|
|
g_available = true;
|
|
Log.info("Fragment density maps: enabled, {}x{} to {}x{} pixels per texel, using {}", caps.minTexelWidth,
|
|
caps.minTexelHeight, caps.maxTexelWidth, caps.maxTexelHeight, g_texelSize);
|
|
} else if (g_requested) {
|
|
Log.warn("Fragment density maps: unavailable; the device lacks VK_EXT_fragment_density_map for "
|
|
"non-subsampled images, or Dawn does not render through dynamic rendering");
|
|
}
|
|
#else
|
|
if (g_requested) {
|
|
Log.warn("Fragment density maps: unavailable; this build links a Dawn without Aurora's patches "
|
|
"(android/Build-QuestDawn.ps1)");
|
|
}
|
|
#endif
|
|
}
|
|
|
|
bool available() noexcept { return g_available; }
|
|
|
|
uint32_t texel_size() noexcept { return g_texelSize; }
|
|
|
|
uint64_t create_map(uint32_t width, uint32_t height, const uint8_t* rg8) noexcept {
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
if (g_available) {
|
|
return AuroraDawnFdmCreateMap(g_device.Get(), width, height, rg8);
|
|
}
|
|
#endif
|
|
(void)width;
|
|
(void)height;
|
|
(void)rg8;
|
|
return 0;
|
|
}
|
|
|
|
bool map_ready(uint64_t map) noexcept {
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
if (g_available && map != 0) {
|
|
return AuroraDawnFdmMapReady(g_device.Get(), map) != 0;
|
|
}
|
|
#endif
|
|
(void)map;
|
|
return false;
|
|
}
|
|
|
|
void release_map(uint64_t map) noexcept {
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
if (g_available && map != 0) {
|
|
AuroraDawnFdmReleaseMap(g_device.Get(), map);
|
|
}
|
|
#endif
|
|
(void)map;
|
|
}
|
|
|
|
bool bind(const wgpu::TextureView& view, uint64_t map) noexcept {
|
|
#ifdef AURORA_FDM_SUPPORTED
|
|
if (g_available && view) {
|
|
return AuroraDawnFdmBind(g_device.Get(), view.Get(), map) != 0;
|
|
}
|
|
#endif
|
|
(void)view;
|
|
(void)map;
|
|
return false;
|
|
}
|
|
|
|
} // namespace aurora::webgpu::fdm
|