mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 23:21:41 +00:00
- apply present shader on screenshots
This commit is contained in:
parent
61ead74492
commit
2a15f65065
3 changed files with 26 additions and 8 deletions
|
@ -169,7 +169,7 @@ void VkPostprocess::BlitCurrentToImage(VkTextureImage *dstimage, VkImageLayout f
|
||||||
imageTransition1.execute(cmdbuffer);
|
imageTransition1.execute(cmdbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool clearBorders)
|
void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool screenshot)
|
||||||
{
|
{
|
||||||
auto fb = GetVulkanFrameBuffer();
|
auto fb = GetVulkanFrameBuffer();
|
||||||
|
|
||||||
|
@ -193,10 +193,19 @@ void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool
|
||||||
uniforms.GrayFormula = static_cast<int>(gl_satformula);
|
uniforms.GrayFormula = static_cast<int>(gl_satformula);
|
||||||
}
|
}
|
||||||
uniforms.ColorScale = (gl_dither_bpc == -1) ? 255.0f : (float)((1 << gl_dither_bpc) - 1);
|
uniforms.ColorScale = (gl_dither_bpc == -1) ? 255.0f : (float)((1 << gl_dither_bpc) - 1);
|
||||||
uniforms.Scale = { screen->mScreenViewport.width / (float)fb->GetBuffers()->GetWidth(), -screen->mScreenViewport.height / (float)fb->GetBuffers()->GetHeight() };
|
|
||||||
uniforms.Offset = { 0.0f, 1.0f };
|
|
||||||
|
|
||||||
if (applyGamma && fb->swapChain->swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT)
|
if (screenshot)
|
||||||
|
{
|
||||||
|
uniforms.Scale = { screen->mScreenViewport.width / (float)fb->GetBuffers()->GetWidth(), screen->mScreenViewport.height / (float)fb->GetBuffers()->GetHeight() };
|
||||||
|
uniforms.Offset = { 0.0f, 0.0f };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uniforms.Scale = { screen->mScreenViewport.width / (float)fb->GetBuffers()->GetWidth(), -screen->mScreenViewport.height / (float)fb->GetBuffers()->GetHeight() };
|
||||||
|
uniforms.Offset = { 0.0f, 1.0f };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applyGamma && fb->swapChain->swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT && !screenshot)
|
||||||
{
|
{
|
||||||
uniforms.HdrMode = 1;
|
uniforms.HdrMode = 1;
|
||||||
}
|
}
|
||||||
|
@ -211,9 +220,11 @@ void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool
|
||||||
renderstate.Viewport = box;
|
renderstate.Viewport = box;
|
||||||
renderstate.SetInputCurrent(0, ViewportLinearScale() ? PPFilterMode::Linear : PPFilterMode::Nearest);
|
renderstate.SetInputCurrent(0, ViewportLinearScale() ? PPFilterMode::Linear : PPFilterMode::Nearest);
|
||||||
renderstate.SetInputTexture(1, &hw_postprocess.present.Dither, PPFilterMode::Nearest, PPWrapMode::Repeat);
|
renderstate.SetInputTexture(1, &hw_postprocess.present.Dither, PPFilterMode::Nearest, PPWrapMode::Repeat);
|
||||||
renderstate.SetOutputSwapChain();
|
if (screenshot)
|
||||||
|
renderstate.SetOutputNext();
|
||||||
|
else
|
||||||
|
renderstate.SetOutputSwapChain();
|
||||||
renderstate.SetNoBlend();
|
renderstate.SetNoBlend();
|
||||||
//if (clearBorders) renderstate.SetClearBorders();
|
|
||||||
renderstate.Draw();
|
renderstate.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
void BlitSceneToPostprocess();
|
void BlitSceneToPostprocess();
|
||||||
void BlitCurrentToImage(VkTextureImage *image, VkImageLayout finallayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
void BlitCurrentToImage(VkTextureImage *image, VkImageLayout finallayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
void DrawPresentTexture(const IntRect &box, bool applyGamma, bool clearBorders);
|
void DrawPresentTexture(const IntRect &box, bool applyGamma, bool screenshot);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void NextEye(int eyeCount);
|
void NextEye(int eyeCount);
|
||||||
|
|
|
@ -272,7 +272,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
||||||
|
|
||||||
presentImageIndex = swapChain->AcquireImage(GetClientWidth(), GetClientHeight(), mSwapChainImageAvailableSemaphore.get());
|
presentImageIndex = swapChain->AcquireImage(GetClientWidth(), GetClientHeight(), mSwapChainImageAvailableSemaphore.get());
|
||||||
if (presentImageIndex != 0xffffffff)
|
if (presentImageIndex != 0xffffffff)
|
||||||
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, true);
|
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlushCommands(finish, true);
|
FlushCommands(finish, true);
|
||||||
|
@ -787,6 +787,13 @@ TArray<uint8_t> VulkanFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo
|
||||||
int w = SCREENWIDTH;
|
int w = SCREENWIDTH;
|
||||||
int h = SCREENHEIGHT;
|
int h = SCREENHEIGHT;
|
||||||
|
|
||||||
|
IntRect box;
|
||||||
|
box.left = 0;
|
||||||
|
box.top = 0;
|
||||||
|
box.width = w;
|
||||||
|
box.height = h;
|
||||||
|
mPostprocess->DrawPresentTexture(box, true, true);
|
||||||
|
|
||||||
TArray<uint8_t> ScreenshotBuffer(w * h * 3, true);
|
TArray<uint8_t> ScreenshotBuffer(w * h * 3, true);
|
||||||
CopyScreenToBuffer(w, h, ScreenshotBuffer.Data());
|
CopyScreenToBuffer(w, h, ScreenshotBuffer.Data());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue