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