mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-12 13:54:14 +01:00
[dxvk] Infer swap chain color space from image views
This commit is contained in:
parent
1d790970d5
commit
d85d07c0ec
@ -434,15 +434,15 @@ namespace dxvk {
|
|||||||
auto contextObjects = ctx->beginExternalRendering();
|
auto contextObjects = ctx->beginExternalRendering();
|
||||||
|
|
||||||
cBlitter->beginPresent(contextObjects,
|
cBlitter->beginPresent(contextObjects,
|
||||||
cBackBuffer, cColorSpace, VkRect2D(),
|
cBackBuffer, VkRect2D(),
|
||||||
cSwapImage, cColorSpace, VkRect2D());
|
cSwapImage, VkRect2D());
|
||||||
|
|
||||||
if (cHud != nullptr) {
|
if (cHud != nullptr) {
|
||||||
cHud->update();
|
cHud->update();
|
||||||
cHud->render(contextObjects, cBackBuffer, cColorSpace);
|
cHud->render(contextObjects, cBackBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
cBlitter->endPresent(contextObjects, cBackBuffer, cColorSpace);
|
cBlitter->endPresent(contextObjects, cBackBuffer);
|
||||||
|
|
||||||
// Submit current command list and present
|
// Submit current command list and present
|
||||||
ctx->synchronizeWsi(cSync);
|
ctx->synchronizeWsi(cSync);
|
||||||
|
@ -878,17 +878,16 @@ namespace dxvk {
|
|||||||
auto contextObjects = ctx->beginExternalRendering();
|
auto contextObjects = ctx->beginExternalRendering();
|
||||||
|
|
||||||
cBlitter->beginPresent(contextObjects,
|
cBlitter->beginPresent(contextObjects,
|
||||||
cDstView, cColorSpace, cDstRect,
|
cDstView, cDstRect, cSrcView, cSrcRect);
|
||||||
cSrcView, cColorSpace, cSrcRect);
|
|
||||||
|
|
||||||
if (cHud) {
|
if (cHud) {
|
||||||
if (!cRepeat)
|
if (!cRepeat)
|
||||||
cHud->update();
|
cHud->update();
|
||||||
|
|
||||||
cHud->render(contextObjects, cDstView, cColorSpace);
|
cHud->render(contextObjects, cDstView);
|
||||||
}
|
}
|
||||||
|
|
||||||
cBlitter->endPresent(contextObjects, cDstView, cColorSpace);
|
cBlitter->endPresent(contextObjects, cDstView);
|
||||||
|
|
||||||
// Submit command list and present
|
// Submit command list and present
|
||||||
ctx->synchronizeWsi(cSync);
|
ctx->synchronizeWsi(cSync);
|
||||||
|
@ -38,10 +38,8 @@ namespace dxvk {
|
|||||||
void DxvkSwapchainBlitter::beginPresent(
|
void DxvkSwapchainBlitter::beginPresent(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
const Rc<DxvkImageView>& srcView,
|
const Rc<DxvkImageView>& srcView,
|
||||||
VkColorSpaceKHR srcColorSpace,
|
|
||||||
VkRect2D srcRect) {
|
VkRect2D srcRect) {
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
@ -102,17 +100,14 @@ namespace dxvk {
|
|||||||
|
|
||||||
ctx.cmd->cmdBeginRendering(&renderInfo);
|
ctx.cmd->cmdBeginRendering(&renderInfo);
|
||||||
|
|
||||||
performDraw(ctx,
|
performDraw(ctx, dstView, dstRect,
|
||||||
dstView, dstColorSpace, dstRect,
|
srcView, srcRect, VK_FALSE);
|
||||||
srcView, srcColorSpace, srcRect,
|
|
||||||
VK_FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkSwapchainBlitter::endPresent(
|
void DxvkSwapchainBlitter::endPresent(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView) {
|
||||||
VkColorSpaceKHR dstColorSpace) {
|
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
if (m_cursorView) {
|
if (m_cursorView) {
|
||||||
@ -120,9 +115,8 @@ namespace dxvk {
|
|||||||
cursorArea.extent.width = m_cursorImage->info().extent.width;
|
cursorArea.extent.width = m_cursorImage->info().extent.width;
|
||||||
cursorArea.extent.height = m_cursorImage->info().extent.height;
|
cursorArea.extent.height = m_cursorImage->info().extent.height;
|
||||||
|
|
||||||
performDraw(ctx, dstView, dstColorSpace, m_cursorRect,
|
performDraw(ctx, dstView, m_cursorRect,
|
||||||
m_cursorView, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, cursorArea,
|
m_cursorView, cursorArea, VK_TRUE);
|
||||||
VK_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.cmd->cmdEndRendering();
|
ctx.cmd->cmdEndRendering();
|
||||||
@ -212,6 +206,7 @@ namespace dxvk {
|
|||||||
| VK_ACCESS_SHADER_READ_BIT;
|
| VK_ACCESS_SHADER_READ_BIT;
|
||||||
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
imageInfo.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
imageInfo.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
imageInfo.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||||
imageInfo.debugName = "Swapchain cursor";
|
imageInfo.debugName = "Swapchain cursor";
|
||||||
|
|
||||||
m_cursorImage = m_device->createImage(imageInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
m_cursorImage = m_device->createImage(imageInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
@ -246,12 +241,13 @@ namespace dxvk {
|
|||||||
void DxvkSwapchainBlitter::performDraw(
|
void DxvkSwapchainBlitter::performDraw(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
const Rc<DxvkImageView>& srcView,
|
const Rc<DxvkImageView>& srcView,
|
||||||
VkColorSpaceKHR srcColorSpace,
|
|
||||||
VkRect2D srcRect,
|
VkRect2D srcRect,
|
||||||
VkBool32 enableBlending) {
|
VkBool32 enableBlending) {
|
||||||
|
VkColorSpaceKHR dstColorSpace = dstView->image()->info().colorSpace;
|
||||||
|
VkColorSpaceKHR srcColorSpace = srcView->image()->info().colorSpace;
|
||||||
|
|
||||||
if (unlikely(m_device->isDebugEnabled())) {
|
if (unlikely(m_device->isDebugEnabled())) {
|
||||||
ctx.cmd->cmdInsertDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer,
|
ctx.cmd->cmdInsertDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer,
|
||||||
vk::makeLabel(0xdcc0f0, "Swapchain blit"));
|
vk::makeLabel(0xdcc0f0, "Swapchain blit"));
|
||||||
|
@ -93,7 +93,6 @@ namespace dxvk {
|
|||||||
* The swap chain image will remain bound for rendering.
|
* The swap chain image will remain bound for rendering.
|
||||||
* \param [in] ctx Context objects
|
* \param [in] ctx Context objects
|
||||||
* \param [in] dstView Swap chain image view
|
* \param [in] dstView Swap chain image view
|
||||||
* \param [in] dstColorSpace Swap chain color space
|
|
||||||
* \param [in] dstRect Destination rectangle
|
* \param [in] dstRect Destination rectangle
|
||||||
* \param [in] srcView Image to present
|
* \param [in] srcView Image to present
|
||||||
* \param [in] srcColorSpace Image color space
|
* \param [in] srcColorSpace Image color space
|
||||||
@ -102,10 +101,8 @@ namespace dxvk {
|
|||||||
void beginPresent(
|
void beginPresent(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
const Rc<DxvkImageView>& srcView,
|
const Rc<DxvkImageView>& srcView,
|
||||||
VkColorSpaceKHR srcColorSpace,
|
|
||||||
VkRect2D srcRect);
|
VkRect2D srcRect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,12 +111,10 @@ namespace dxvk {
|
|||||||
* Finishes rendering and prepares the image for presentation.
|
* Finishes rendering and prepares the image for presentation.
|
||||||
* \param [in] ctx Context objects
|
* \param [in] ctx Context objects
|
||||||
* \param [in] dstView Swap chain image view
|
* \param [in] dstView Swap chain image view
|
||||||
* \param [in] dstColorSpace Swap chain color space
|
|
||||||
*/
|
*/
|
||||||
void endPresent(
|
void endPresent(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView);
|
||||||
VkColorSpaceKHR dstColorSpace);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets gamma ramp
|
* \brief Sets gamma ramp
|
||||||
@ -211,10 +206,8 @@ namespace dxvk {
|
|||||||
void performDraw(
|
void performDraw(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
VkRect2D dstRect,
|
VkRect2D dstRect,
|
||||||
const Rc<DxvkImageView>& srcView,
|
const Rc<DxvkImageView>& srcView,
|
||||||
VkColorSpaceKHR srcColorSpace,
|
|
||||||
VkRect2D srcRect,
|
VkRect2D srcRect,
|
||||||
VkBool32 enableBlending);
|
VkBool32 enableBlending);
|
||||||
|
|
||||||
|
@ -41,13 +41,12 @@ namespace dxvk::hud {
|
|||||||
|
|
||||||
void Hud::render(
|
void Hud::render(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView) {
|
||||||
VkColorSpaceKHR dstColorSpace) {
|
auto key = m_renderer.getPipelineKey(dstView);
|
||||||
auto key = m_renderer.getPipelineKey(dstView, dstColorSpace);
|
|
||||||
|
|
||||||
m_renderer.beginFrame(ctx, dstView, dstColorSpace, m_options);
|
m_renderer.beginFrame(ctx, dstView, m_options);
|
||||||
m_hudItems.render(ctx, key, m_options, m_renderer);
|
m_hudItems.render(ctx, key, m_options, m_renderer);
|
||||||
m_renderer.flushDraws(ctx, dstView, dstColorSpace, m_options);
|
m_renderer.flushDraws(ctx, dstView, m_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,12 +35,10 @@ namespace dxvk::hud {
|
|||||||
* Renders the HUD to the given context.
|
* Renders the HUD to the given context.
|
||||||
* \param [in] ctx Context objects for rendering
|
* \param [in] ctx Context objects for rendering
|
||||||
* \param [in] dstView Swap chain image view
|
* \param [in] dstView Swap chain image view
|
||||||
* \param [in] dstColorSpace Color space
|
|
||||||
*/
|
*/
|
||||||
void render(
|
void render(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView);
|
||||||
VkColorSpaceKHR dstColorSpace);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Adds a HUD item if enabled
|
* \brief Adds a HUD item if enabled
|
||||||
|
@ -57,7 +57,6 @@ namespace dxvk::hud {
|
|||||||
void HudRenderer::beginFrame(
|
void HudRenderer::beginFrame(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
const HudOptions& options) {
|
const HudOptions& options) {
|
||||||
if (unlikely(m_device->isDebugEnabled())) {
|
if (unlikely(m_device->isDebugEnabled())) {
|
||||||
ctx.cmd->cmdInsertDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer,
|
ctx.cmd->cmdInsertDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer,
|
||||||
@ -116,7 +115,6 @@ namespace dxvk::hud {
|
|||||||
void HudRenderer::flushDraws(
|
void HudRenderer::flushDraws(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
const HudOptions& options) {
|
const HudOptions& options) {
|
||||||
if (m_textDraws.empty())
|
if (m_textDraws.empty())
|
||||||
return;
|
return;
|
||||||
@ -192,7 +190,7 @@ namespace dxvk::hud {
|
|||||||
VkDescriptorBufferInfo textBufferDescriptor = m_textBuffer->getDescriptor(textSizeAligned, drawInfoSize).buffer;
|
VkDescriptorBufferInfo textBufferDescriptor = m_textBuffer->getDescriptor(textSizeAligned, drawInfoSize).buffer;
|
||||||
VkDescriptorBufferInfo drawBufferDescriptor = m_textBuffer->getDescriptor(drawArgOffset, drawArgWriteSize).buffer;
|
VkDescriptorBufferInfo drawBufferDescriptor = m_textBuffer->getDescriptor(drawArgOffset, drawArgWriteSize).buffer;
|
||||||
|
|
||||||
drawTextIndirect(ctx, getPipelineKey(dstView, dstColorSpace),
|
drawTextIndirect(ctx, getPipelineKey(dstView),
|
||||||
drawBufferDescriptor, textBufferDescriptor,
|
drawBufferDescriptor, textBufferDescriptor,
|
||||||
m_textBufferView->handle(), m_textDraws.size());
|
m_textBufferView->handle(), m_textDraws.size());
|
||||||
|
|
||||||
@ -261,11 +259,10 @@ namespace dxvk::hud {
|
|||||||
|
|
||||||
|
|
||||||
HudPipelineKey HudRenderer::getPipelineKey(
|
HudPipelineKey HudRenderer::getPipelineKey(
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView) const {
|
||||||
VkColorSpaceKHR dstColorSpace) const {
|
|
||||||
HudPipelineKey key;
|
HudPipelineKey key;
|
||||||
key.format = dstView->info().format;
|
key.format = dstView->info().format;
|
||||||
key.colorSpace = dstColorSpace;
|
key.colorSpace = dstView->image()->info().colorSpace;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,6 @@ namespace dxvk::hud {
|
|||||||
void beginFrame(
|
void beginFrame(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
const HudOptions& options);
|
const HudOptions& options);
|
||||||
|
|
||||||
void drawText(
|
void drawText(
|
||||||
@ -123,12 +122,10 @@ namespace dxvk::hud {
|
|||||||
void flushDraws(
|
void flushDraws(
|
||||||
const DxvkContextObjects& ctx,
|
const DxvkContextObjects& ctx,
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView,
|
||||||
VkColorSpaceKHR dstColorSpace,
|
|
||||||
const HudOptions& options);
|
const HudOptions& options);
|
||||||
|
|
||||||
HudPipelineKey getPipelineKey(
|
HudPipelineKey getPipelineKey(
|
||||||
const Rc<DxvkImageView>& dstView,
|
const Rc<DxvkImageView>& dstView) const;
|
||||||
VkColorSpaceKHR dstColorSpace) const;
|
|
||||||
|
|
||||||
HudSpecConstants getSpecConstants(
|
HudSpecConstants getSpecConstants(
|
||||||
const HudPipelineKey& key) const;
|
const HudPipelineKey& key) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user