[UI] Image post-processing and full presentation/window rework

[GPU] Add FXAA post-processing
[UI] Add FidelityFX FSR and CAS post-processing
[UI] Add blue noise dithering from 10bpc to 8bpc
[GPU] Apply the DC PWL gamma ramp closer to the spec, supporting fully white color
[UI] Allow the GPU CP thread to present on the host directly, bypassing the UI thread OS paint event
[UI] Allow variable refresh rate (or tearing)
[UI] Present the newest frame (restart) on DXGI
[UI] Replace GraphicsContext with a far more advanced Presenter with more coherent surface connection and UI overlay state management
[UI] Connect presentation to windows via the Surface class, not native window handles
[Vulkan] Switch to simpler Vulkan setup with no instance/device separation due to interdependencies and to pass fewer objects around
[Vulkan] Lower the minimum required Vulkan version to 1.0
[UI/GPU] Various cleanup, mainly ComPtr usage
[UI] Support per-monitor DPI awareness v2 on Windows
[UI] DPI-scale Dear ImGui
[UI] Replace the remaining non-detachable window delegates with unified window event and input listeners
[UI] Allow listeners to safely destroy or close the window, and to register/unregister listeners without use-after-free and the ABA problem
[UI] Explicit Z ordering of input listeners and UI overlays, top-down for input, bottom-up for drawing
[UI] Add explicit window lifecycle phases
[UI] Replace Window virtual functions with explicit desired state, its application, actual state, its feedback
[UI] GTK: Apply the initial size to the drawing area
[UI] Limit internal UI frame rate to that of the monitor
[UI] Hide the cursor using a timer instead of polling due to no repeated UI thread paints with GPU CP thread presentation, and only within the window
This commit is contained in:
Triang3l
2022-01-29 13:22:03 +03:00
parent 372bdd3ec9
commit fe3f0f26e4
428 changed files with 75942 additions and 18360 deletions

View File

@@ -13,8 +13,7 @@
#include <memory>
#include "xenia/base/assert.h"
#include "xenia/ui/vulkan/vulkan.h"
#include "xenia/ui/vulkan/vulkan_device.h"
#include "xenia/ui/vulkan/vulkan_provider.h"
#include "xenia/ui/vulkan/vulkan_util.h"
namespace xe {
@@ -29,7 +28,7 @@ namespace vulkan {
template <typename T, typename HANDLE>
class BaseFencedPool {
public:
BaseFencedPool(const VulkanDevice& device) : device_(device) {}
BaseFencedPool(const VulkanProvider& provider) : provider_(provider) {}
virtual ~BaseFencedPool() {
// TODO(benvanik): wait on fence until done.
@@ -48,12 +47,13 @@ class BaseFencedPool {
// Checks all pending batches for completion and scavenges their entries.
// This should be called as frequently as reasonable.
void Scavenge() {
const VulkanDevice::DeviceFunctions& dfn = device_.dfn();
const VulkanProvider::DeviceFunctions& dfn = provider_.dfn();
VkDevice device = provider_.device();
while (pending_batch_list_head_) {
auto batch = pending_batch_list_head_;
assert_not_null(batch->fence);
VkResult status = dfn.vkGetFenceStatus(device_, batch->fence);
VkResult status = dfn.vkGetFenceStatus(device, batch->fence);
if (status == VK_SUCCESS || status == VK_ERROR_DEVICE_LOST) {
// Batch has completed. Reclaim.
pending_batch_list_head_ = batch->next;
@@ -82,7 +82,8 @@ class BaseFencedPool {
VkFence BeginBatch(VkFence fence = nullptr) {
assert_null(open_batch_);
Batch* batch = nullptr;
const VulkanDevice::DeviceFunctions& dfn = device_.dfn();
const VulkanProvider::DeviceFunctions& dfn = provider_.dfn();
VkDevice device = provider_.device();
if (free_batch_list_head_) {
// Reuse a batch.
batch = free_batch_list_head_;
@@ -91,10 +92,10 @@ class BaseFencedPool {
if (batch->flags & kBatchOwnsFence && !fence) {
// Reset owned fence.
dfn.vkResetFences(device_, 1, &batch->fence);
dfn.vkResetFences(device, 1, &batch->fence);
} else if ((batch->flags & kBatchOwnsFence) && fence) {
// Transfer owned -> external
dfn.vkDestroyFence(device_, batch->fence, nullptr);
dfn.vkDestroyFence(device, batch->fence, nullptr);
batch->fence = fence;
batch->flags &= ~kBatchOwnsFence;
} else if (!(batch->flags & kBatchOwnsFence) && !fence) {
@@ -103,8 +104,7 @@ class BaseFencedPool {
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
VkResult res =
dfn.vkCreateFence(device_, &info, nullptr, &batch->fence);
VkResult res = dfn.vkCreateFence(device, &info, nullptr, &batch->fence);
if (res != VK_SUCCESS) {
assert_always();
}
@@ -125,8 +125,7 @@ class BaseFencedPool {
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
VkResult res =
dfn.vkCreateFence(device_, &info, nullptr, &batch->fence);
VkResult res = dfn.vkCreateFence(device, &info, nullptr, &batch->fence);
if (res != VK_SUCCESS) {
assert_always();
}
@@ -244,14 +243,15 @@ class BaseFencedPool {
}
void FreeAllEntries() {
const VulkanDevice::DeviceFunctions& dfn = device_.dfn();
const VulkanProvider::DeviceFunctions& dfn = provider_.dfn();
VkDevice device = provider_.device();
// Run down free lists.
while (free_batch_list_head_) {
auto batch = free_batch_list_head_;
free_batch_list_head_ = batch->next;
if (batch->flags & kBatchOwnsFence) {
dfn.vkDestroyFence(device_, batch->fence, nullptr);
dfn.vkDestroyFence(device, batch->fence, nullptr);
batch->fence = nullptr;
}
delete batch;
@@ -264,7 +264,7 @@ class BaseFencedPool {
}
}
const VulkanDevice& device_;
const VulkanProvider& provider_;
private:
struct Entry {
@@ -294,7 +294,8 @@ class CommandBufferPool
public:
typedef BaseFencedPool<CommandBufferPool, VkCommandBuffer> Base;
CommandBufferPool(const VulkanDevice& device, uint32_t queue_family_index);
CommandBufferPool(const VulkanProvider& provider,
uint32_t queue_family_index);
~CommandBufferPool() override;
VkCommandBuffer AcquireEntry(
@@ -314,7 +315,7 @@ class DescriptorPool : public BaseFencedPool<DescriptorPool, VkDescriptorSet> {
public:
typedef BaseFencedPool<DescriptorPool, VkDescriptorSet> Base;
DescriptorPool(const VulkanDevice& device, uint32_t max_count,
DescriptorPool(const VulkanProvider& provider, uint32_t max_count,
std::vector<VkDescriptorPoolSize> pool_sizes);
~DescriptorPool() override;