mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Move HUD update and rendering into swapchain blitter
This commit is contained in:
parent
c1ed8cd1f3
commit
5134a4b3c5
@ -68,7 +68,6 @@ namespace dxvk {
|
|||||||
CreatePresenter();
|
CreatePresenter();
|
||||||
CreateBackBuffers();
|
CreateBackBuffers();
|
||||||
CreateBlitter();
|
CreateBlitter();
|
||||||
CreateHud();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -416,7 +415,6 @@ namespace dxvk {
|
|||||||
cBackBuffer = backBuffer->createView(viewInfo),
|
cBackBuffer = backBuffer->createView(viewInfo),
|
||||||
cSwapImage = GetBackBufferView(),
|
cSwapImage = GetBackBufferView(),
|
||||||
cSync = sync,
|
cSync = sync,
|
||||||
cHud = m_hud,
|
|
||||||
cPresenter = m_presenter,
|
cPresenter = m_presenter,
|
||||||
cColorSpace = m_colorSpace,
|
cColorSpace = m_colorSpace,
|
||||||
cFrameId = m_frameId
|
cFrameId = m_frameId
|
||||||
@ -433,17 +431,10 @@ namespace dxvk {
|
|||||||
// swap chain and render the HUD if we have one.
|
// swap chain and render the HUD if we have one.
|
||||||
auto contextObjects = ctx->beginExternalRendering();
|
auto contextObjects = ctx->beginExternalRendering();
|
||||||
|
|
||||||
cBlitter->beginPresent(contextObjects,
|
cBlitter->present(contextObjects,
|
||||||
cBackBuffer, VkRect2D(),
|
cBackBuffer, VkRect2D(),
|
||||||
cSwapImage, VkRect2D());
|
cSwapImage, VkRect2D());
|
||||||
|
|
||||||
if (cHud != nullptr) {
|
|
||||||
cHud->update();
|
|
||||||
cHud->render(contextObjects, cBackBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
cBlitter->endPresent(contextObjects, cBackBuffer);
|
|
||||||
|
|
||||||
// Submit current command list and present
|
// Submit current command list and present
|
||||||
ctx->synchronizeWsi(cSync);
|
ctx->synchronizeWsi(cSync);
|
||||||
ctx->flushCommandList(nullptr);
|
ctx->flushCommandList(nullptr);
|
||||||
@ -582,15 +573,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void D3D11SwapChain::CreateBlitter() {
|
void D3D11SwapChain::CreateBlitter() {
|
||||||
m_blitter = new DxvkSwapchainBlitter(m_device);
|
Rc<hud::Hud> hud = hud::Hud::createHud(m_device);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (hud)
|
||||||
|
hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
|
||||||
|
|
||||||
void D3D11SwapChain::CreateHud() {
|
m_blitter = new DxvkSwapchainBlitter(m_device, std::move(hud));
|
||||||
m_hud = hud::Hud::createHud(m_device);
|
|
||||||
|
|
||||||
if (m_hud != nullptr)
|
|
||||||
m_hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +108,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkSwapchainBlitter> m_blitter;
|
Rc<DxvkSwapchainBlitter> m_blitter;
|
||||||
|
|
||||||
Rc<hud::Hud> m_hud;
|
|
||||||
|
|
||||||
small_vector<Com<D3D11Texture2D, false>, 4> m_backBuffers;
|
small_vector<Com<D3D11Texture2D, false>, 4> m_backBuffers;
|
||||||
DxvkSubmitStatus m_presentStatus;
|
DxvkSubmitStatus m_presentStatus;
|
||||||
|
|
||||||
@ -142,8 +140,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
void CreateBlitter();
|
void CreateBlitter();
|
||||||
|
|
||||||
void CreateHud();
|
|
||||||
|
|
||||||
void DestroyFrameLatencyEvent();
|
void DestroyFrameLatencyEvent();
|
||||||
|
|
||||||
void SyncFrameLatency();
|
void SyncFrameLatency();
|
||||||
|
@ -43,7 +43,6 @@ namespace dxvk {
|
|||||||
throw DxvkError("D3D9: Failed to create swapchain backbuffers");
|
throw DxvkError("D3D9: Failed to create swapchain backbuffers");
|
||||||
|
|
||||||
CreateBlitter();
|
CreateBlitter();
|
||||||
CreateHud();
|
|
||||||
|
|
||||||
InitRamp();
|
InitRamp();
|
||||||
|
|
||||||
@ -863,7 +862,6 @@ namespace dxvk {
|
|||||||
cDstRect = dstRect,
|
cDstRect = dstRect,
|
||||||
cRepeat = i,
|
cRepeat = i,
|
||||||
cSync = sync,
|
cSync = sync,
|
||||||
cHud = m_hud,
|
|
||||||
cFrameId = m_wctx->frameId
|
cFrameId = m_wctx->frameId
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
// Update back buffer color space as necessary
|
// Update back buffer color space as necessary
|
||||||
@ -877,18 +875,9 @@ namespace dxvk {
|
|||||||
// Blit back buffer onto Vulkan swap chain
|
// Blit back buffer onto Vulkan swap chain
|
||||||
auto contextObjects = ctx->beginExternalRendering();
|
auto contextObjects = ctx->beginExternalRendering();
|
||||||
|
|
||||||
cBlitter->beginPresent(contextObjects,
|
cBlitter->present(contextObjects,
|
||||||
cDstView, cDstRect, cSrcView, cSrcRect);
|
cDstView, cDstRect, cSrcView, cSrcRect);
|
||||||
|
|
||||||
if (cHud) {
|
|
||||||
if (!cRepeat)
|
|
||||||
cHud->update();
|
|
||||||
|
|
||||||
cHud->render(contextObjects, cDstView);
|
|
||||||
}
|
|
||||||
|
|
||||||
cBlitter->endPresent(contextObjects, cDstView);
|
|
||||||
|
|
||||||
// Submit command list and present
|
// Submit command list and present
|
||||||
ctx->synchronizeWsi(cSync);
|
ctx->synchronizeWsi(cSync);
|
||||||
ctx->flushCommandList(nullptr);
|
ctx->flushCommandList(nullptr);
|
||||||
@ -1047,23 +1036,20 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void D3D9SwapChainEx::CreateBlitter() {
|
void D3D9SwapChainEx::CreateBlitter() {
|
||||||
m_blitter = new DxvkSwapchainBlitter(m_device);
|
Rc<hud::Hud> hud = hud::Hud::createHud(m_device);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (hud) {
|
||||||
void D3D9SwapChainEx::CreateHud() {
|
m_apiHud = hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
|
||||||
m_hud = hud::Hud::createHud(m_device);
|
hud->addItem<hud::HudSamplerCount>("samplers", -1, m_parent);
|
||||||
|
hud->addItem<hud::HudFixedFunctionShaders>("ffshaders", -1, m_parent);
|
||||||
if (m_hud != nullptr) {
|
hud->addItem<hud::HudSWVPState>("swvp", -1, m_parent);
|
||||||
m_hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
|
|
||||||
m_hud->addItem<hud::HudSamplerCount>("samplers", -1, m_parent);
|
|
||||||
m_hud->addItem<hud::HudFixedFunctionShaders>("ffshaders", -1, m_parent);
|
|
||||||
m_hud->addItem<hud::HudSWVPState>("swvp", -1, m_parent);
|
|
||||||
|
|
||||||
#ifdef D3D9_ALLOW_UNMAPPING
|
#ifdef D3D9_ALLOW_UNMAPPING
|
||||||
m_hud->addItem<hud::HudTextureMemory>("memory", -1, m_parent);
|
hud->addItem<hud::HudTextureMemory>("memory", -1, m_parent);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_blitter = new DxvkSwapchainBlitter(m_device, std::move(hud));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1095,8 +1081,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void D3D9SwapChainEx::SetApiName(const char* name) {
|
void D3D9SwapChainEx::SetApiName(const char* name) {
|
||||||
m_apiName = name;
|
if (m_apiHud && name)
|
||||||
CreateHud();
|
m_apiHud->setApiName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t D3D9SwapChainEx::GetActualFrameLatency() {
|
uint32_t D3D9SwapChainEx::GetActualFrameLatency() {
|
||||||
@ -1306,11 +1292,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
std::string D3D9SwapChainEx::GetApiName() {
|
std::string D3D9SwapChainEx::GetApiName() {
|
||||||
if (m_apiName == nullptr) {
|
return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9";
|
||||||
return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9";
|
|
||||||
} else {
|
|
||||||
return m_apiName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D9VkExtSwapchain::D3D9VkExtSwapchain(D3D9SwapChainEx *pSwapChain)
|
D3D9VkExtSwapchain::D3D9VkExtSwapchain(D3D9SwapChainEx *pSwapChain)
|
||||||
|
@ -156,8 +156,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
D3D9WindowContext* m_wctx = nullptr;
|
D3D9WindowContext* m_wctx = nullptr;
|
||||||
|
|
||||||
Rc<hud::Hud> m_hud;
|
|
||||||
|
|
||||||
std::vector<Com<D3D9Surface, false>> m_backBuffers;
|
std::vector<Com<D3D9Surface, false>> m_backBuffers;
|
||||||
|
|
||||||
RECT m_srcRect;
|
RECT m_srcRect;
|
||||||
@ -176,12 +174,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
double m_displayRefreshRate = 0.0;
|
double m_displayRefreshRate = 0.0;
|
||||||
|
|
||||||
const char* m_apiName = nullptr;
|
|
||||||
|
|
||||||
bool m_warnedAboutGDIFallback = false;
|
bool m_warnedAboutGDIFallback = false;
|
||||||
|
|
||||||
VkColorSpaceKHR m_colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
VkColorSpaceKHR m_colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||||
|
|
||||||
|
Rc<hud::HudClientApiItem> m_apiHud;
|
||||||
|
|
||||||
std::optional<VkHdrMetadataEXT> m_hdrMetadata;
|
std::optional<VkHdrMetadataEXT> m_hdrMetadata;
|
||||||
bool m_unlockAdditionalFormats = false;
|
bool m_unlockAdditionalFormats = false;
|
||||||
|
|
||||||
@ -201,8 +199,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
void CreateBlitter();
|
void CreateBlitter();
|
||||||
|
|
||||||
void CreateHud();
|
|
||||||
|
|
||||||
void InitRamp();
|
void InitRamp();
|
||||||
|
|
||||||
void UpdateTargetFrameRate(uint32_t SyncInterval);
|
void UpdateTargetFrameRate(uint32_t SyncInterval);
|
||||||
|
@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxvkSwapchainBlitter::DxvkSwapchainBlitter(const Rc<DxvkDevice>& device)
|
DxvkSwapchainBlitter::DxvkSwapchainBlitter(
|
||||||
: m_device(device),
|
const Rc<DxvkDevice>& device,
|
||||||
|
const Rc<hud::Hud>& hud)
|
||||||
|
: m_device(device), m_hud(hud),
|
||||||
m_setLayout(createSetLayout()),
|
m_setLayout(createSetLayout()),
|
||||||
m_pipelineLayout(createPipelineLayout()) {
|
m_pipelineLayout(createPipelineLayout()) {
|
||||||
this->createSampler();
|
this->createSampler();
|
||||||
@ -35,7 +37,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkSwapchainBlitter::beginPresent(
|
void DxvkSwapchainBlitter::present(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
@ -43,6 +45,10 @@ namespace dxvk {
|
|||||||
VkRect2D srcRect) {
|
VkRect2D srcRect) {
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
|
// Update HUD, if we have one
|
||||||
|
if (m_hud)
|
||||||
|
m_hud->update();
|
||||||
|
|
||||||
// Fix up default present areas if necessary
|
// Fix up default present areas if necessary
|
||||||
if (!dstRect.extent.width || !dstRect.extent.height) {
|
if (!dstRect.extent.width || !dstRect.extent.height) {
|
||||||
dstRect.offset = { 0, 0 };
|
dstRect.offset = { 0, 0 };
|
||||||
@ -102,13 +108,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
performDraw(ctx, dstView, dstRect,
|
performDraw(ctx, dstView, dstRect,
|
||||||
srcView, srcRect, VK_FALSE);
|
srcView, srcRect, VK_FALSE);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (m_hud)
|
||||||
void DxvkSwapchainBlitter::endPresent(
|
m_hud->render(ctx, dstView);
|
||||||
const DxvkContextObjects& ctx,
|
|
||||||
const Rc<DxvkImageView>& dstView) {
|
|
||||||
std::unique_lock lock(m_mutex);
|
|
||||||
|
|
||||||
if (m_cursorView) {
|
if (m_cursorView) {
|
||||||
VkRect2D cursorArea = { };
|
VkRect2D cursorArea = { };
|
||||||
@ -121,7 +123,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
ctx.cmd->cmdEndRendering();
|
ctx.cmd->cmdEndRendering();
|
||||||
|
|
||||||
VkImageMemoryBarrier2 barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 };
|
barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 };
|
||||||
barrier.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT;
|
barrier.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
barrier.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT;
|
barrier.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
barrier.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT;
|
barrier.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT;
|
||||||
@ -133,7 +135,7 @@ namespace dxvk {
|
|||||||
barrier.image = dstView->image()->handle();
|
barrier.image = dstView->image()->handle();
|
||||||
barrier.subresourceRange = dstView->imageSubresources();
|
barrier.subresourceRange = dstView->imageSubresources();
|
||||||
|
|
||||||
VkDependencyInfo depInfo = { VK_STRUCTURE_TYPE_DEPENDENCY_INFO };
|
depInfo = { VK_STRUCTURE_TYPE_DEPENDENCY_INFO };
|
||||||
depInfo.imageMemoryBarrierCount = 1;
|
depInfo.imageMemoryBarrierCount = 1;
|
||||||
depInfo.pImageMemoryBarriers = &barrier;
|
depInfo.pImageMemoryBarriers = &barrier;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "./hud/dxvk_hud.h"
|
||||||
|
|
||||||
#include "../util/thread.h"
|
#include "../util/thread.h"
|
||||||
|
|
||||||
#include "../dxvk/dxvk_device.h"
|
#include "../dxvk/dxvk_device.h"
|
||||||
@ -82,7 +84,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DxvkSwapchainBlitter(const Rc<DxvkDevice>& device);
|
DxvkSwapchainBlitter(
|
||||||
|
const Rc<DxvkDevice>& device,
|
||||||
|
const Rc<hud::Hud>& hud);
|
||||||
~DxvkSwapchainBlitter();
|
~DxvkSwapchainBlitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,24 +102,13 @@ namespace dxvk {
|
|||||||
* \param [in] srcColorSpace Image color space
|
* \param [in] srcColorSpace Image color space
|
||||||
* \param [in] srcRect Source rectangle to present
|
* \param [in] srcRect Source rectangle to present
|
||||||
*/
|
*/
|
||||||
void beginPresent(
|
void present(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
const Rc<DxvkImageView>& srcView,
|
const Rc<DxvkImageView>& srcView,
|
||||||
VkRect2D srcRect);
|
VkRect2D srcRect);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Finalizes presentation commands
|
|
||||||
*
|
|
||||||
* Finishes rendering and prepares the image for presentation.
|
|
||||||
* \param [in] ctx Context objects
|
|
||||||
* \param [in] dstView Swap chain image view
|
|
||||||
*/
|
|
||||||
void endPresent(
|
|
||||||
const DxvkContextObjects& ctx,
|
|
||||||
const Rc<DxvkImageView>& dstView);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets gamma ramp
|
* \brief Sets gamma ramp
|
||||||
*
|
*
|
||||||
@ -176,6 +169,7 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Rc<DxvkDevice> m_device;
|
Rc<DxvkDevice> m_device;
|
||||||
|
Rc<hud::Hud> m_hud;
|
||||||
|
|
||||||
ShaderModule m_shaderVsBlit;
|
ShaderModule m_shaderVsBlit;
|
||||||
ShaderModule m_shaderFsCopy;
|
ShaderModule m_shaderFsCopy;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user