- add some classes for managing postprocess and render buffers

This commit is contained in:
Magnus Norddahl 2019-03-05 04:59:17 +01:00
parent 319099fee9
commit d65de299e8
10 changed files with 328 additions and 76 deletions

View file

@ -901,6 +901,8 @@ set( FASTMATH_SOURCES
rendering/vulkan/system/vk_buffers.cpp rendering/vulkan/system/vk_buffers.cpp
rendering/vulkan/renderer/vk_renderstate.cpp rendering/vulkan/renderer/vk_renderstate.cpp
rendering/vulkan/renderer/vk_renderpass.cpp rendering/vulkan/renderer/vk_renderpass.cpp
rendering/vulkan/renderer/vk_postprocess.cpp
rendering/vulkan/renderer/vk_renderbuffers.cpp
rendering/vulkan/shaders/vk_shader.cpp rendering/vulkan/shaders/vk_shader.cpp
rendering/vulkan/textures/vk_samplers.cpp rendering/vulkan/textures/vk_samplers.cpp
rendering/vulkan/textures/vk_hwtexture.cpp rendering/vulkan/textures/vk_hwtexture.cpp

View file

@ -0,0 +1,119 @@
#include "vk_postprocess.h"
#include "vk_renderbuffers.h"
#include "vulkan/shaders/vk_shader.h"
#include "vulkan/system/vk_builders.h"
#include "vulkan/system/vk_framebuffer.h"
#include "vulkan/system/vk_buffers.h"
#include "hwrenderer/utility/hw_cvars.h"
#include "hwrenderer/postprocessing/hw_presentshader.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
#include "hwrenderer/utility/hw_vrmodes.h"
#include "hwrenderer/data/flatvertices.h"
#include "r_videoscale.h"
VkPostprocess::VkPostprocess()
{
}
VkPostprocess::~VkPostprocess()
{
}
void VkPostprocess::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
{
auto fb = GetVulkanFrameBuffer();
hw_postprocess.fixedcm = fixedcm;
hw_postprocess.SceneWidth = fb->GetBuffers()->GetSceneWidth();
hw_postprocess.SceneHeight = fb->GetBuffers()->GetSceneHeight();
hw_postprocess.DeclareShaders();
hw_postprocess.UpdateTextures();
hw_postprocess.UpdateSteps();
CompileEffectShaders();
UpdateEffectTextures();
RenderEffect("UpdateCameraExposure");
//mCustomPostProcessShaders->Run("beforebloom");
RenderEffect("BloomScene");
//BindCurrentFB();
afterBloomDrawEndScene2D();
RenderEffect("TonemapScene");
RenderEffect("ColormapScene");
RenderEffect("LensDistortScene");
RenderEffect("ApplyFXAA");
//mCustomPostProcessShaders->Run("scene");
}
void VkPostprocess::AmbientOccludeScene(float m5)
{
auto fb = GetVulkanFrameBuffer();
hw_postprocess.SceneWidth = fb->GetBuffers()->GetSceneWidth();
hw_postprocess.SceneHeight = fb->GetBuffers()->GetSceneHeight();
hw_postprocess.m5 = m5;
hw_postprocess.DeclareShaders();
hw_postprocess.UpdateTextures();
hw_postprocess.UpdateSteps();
CompileEffectShaders();
UpdateEffectTextures();
RenderEffect("AmbientOccludeScene");
}
void VkPostprocess::BlurScene(float gameinfobluramount)
{
hw_postprocess.gameinfobluramount = gameinfobluramount;
hw_postprocess.DeclareShaders();
hw_postprocess.UpdateTextures();
hw_postprocess.UpdateSteps();
CompileEffectShaders();
UpdateEffectTextures();
auto vrmode = VRMode::GetVRMode(true);
int eyeCount = vrmode->mEyeCount;
for (int i = 0; i < eyeCount; ++i)
{
RenderEffect("BlurScene");
if (eyeCount - i > 1) NextEye(eyeCount);
}
}
void VkPostprocess::ClearTonemapPalette()
{
hw_postprocess.Textures.Remove("Tonemap.Palette");
}
void VkPostprocess::RenderBuffersReset()
{
}
void VkPostprocess::UpdateEffectTextures()
{
}
void VkPostprocess::CompileEffectShaders()
{
}
void VkPostprocess::RenderEffect(const FString &name)
{
}
void VkPostprocess::RenderScreenQuad()
{
//auto buffer = static_cast<VKVertexBuffer *>(screen->mVertexData->GetBufferObjects().first);
//buffer->Bind(nullptr);
//glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
}
void VkPostprocess::NextEye(int eyeCount)
{
}

View file

@ -0,0 +1,28 @@
#pragma once
#include "vulkan/system/vk_objects.h"
class FString;
class VkPostprocess
{
public:
VkPostprocess();
~VkPostprocess();
void RenderBuffersReset();
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
void AmbientOccludeScene(float m5);
void BlurScene(float gameinfobluramount);
void ClearTonemapPalette();
private:
void UpdateEffectTextures();
void CompileEffectShaders();
void RenderEffect(const FString &name);
void NextEye(int eyeCount);
void RenderScreenQuad();
};

View file

@ -0,0 +1,89 @@
#include "vk_renderbuffers.h"
#include "vk_renderpass.h"
#include "vk_postprocess.h"
#include "vulkan/shaders/vk_shader.h"
#include "vulkan/system/vk_builders.h"
#include "vulkan/system/vk_framebuffer.h"
#include "hwrenderer/utility/hw_cvars.h"
VkRenderBuffers::VkRenderBuffers()
{
}
VkRenderBuffers::~VkRenderBuffers()
{
}
void VkRenderBuffers::BeginFrame(int width, int height, int sceneWidth, int sceneHeight)
{
int samples = clamp((int)gl_multisample, 0, mMaxSamples);
if (width != mWidth || height != mHeight || mSamples != samples)
{
auto fb = GetVulkanFrameBuffer();
fb->GetRenderPassManager()->RenderBuffersReset();
fb->GetPostprocess()->RenderBuffersReset();
}
if (width != mWidth || height != mHeight)
CreatePipeline(width, height);
if (width != mWidth || height != mHeight || mSamples != samples)
CreateScene(width, height, samples);
mWidth = width;
mHeight = height;
mSamples = samples;
mSceneWidth = sceneWidth;
mSceneHeight = sceneHeight;
}
void VkRenderBuffers::CreatePipeline(int width, int height)
{
}
void VkRenderBuffers::CreateScene(int width, int height, int samples)
{
auto fb = GetVulkanFrameBuffer();
SceneColorView.reset();
SceneDepthStencilView.reset();
SceneDepthView.reset();
SceneColor.reset();
SceneDepthStencil.reset();
ImageBuilder builder;
builder.setSize(SCREENWIDTH, SCREENHEIGHT);
builder.setFormat(VK_FORMAT_R16G16B16A16_SFLOAT);
builder.setUsage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
SceneColor = builder.create(fb->device);
builder.setFormat(SceneDepthStencilFormat);
builder.setUsage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!builder.isFormatSupported(fb->device))
{
SceneDepthStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
builder.setFormat(SceneDepthStencilFormat);
if (!builder.isFormatSupported(fb->device))
{
I_FatalError("This device does not support any of the required depth stencil image formats.");
}
}
SceneDepthStencil = builder.create(fb->device);
ImageViewBuilder viewbuilder;
viewbuilder.setImage(SceneColor.get(), VK_FORMAT_R16G16B16A16_SFLOAT);
SceneColorView = viewbuilder.create(fb->device);
viewbuilder.setImage(SceneDepthStencil.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
SceneDepthStencilView = viewbuilder.create(fb->device);
viewbuilder.setImage(SceneDepthStencil.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
SceneDepthView = viewbuilder.create(fb->device);
PipelineBarrier barrier;
barrier.addImage(SceneColor.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
barrier.addImage(SceneDepthStencil.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
barrier.execute(fb->GetDrawCommands(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
}

View file

@ -0,0 +1,37 @@
#pragma once
#include "vulkan/system/vk_objects.h"
class VkRenderBuffers
{
public:
VkRenderBuffers();
~VkRenderBuffers();
void BeginFrame(int width, int height, int sceneWidth, int sceneHeight);
int GetWidth() const { return mWidth; }
int GetHeight() const { return mHeight; }
int GetSceneWidth() const { return mSceneWidth; }
int GetSceneHeight() const { return mSceneHeight; }
std::unique_ptr<VulkanImage> SceneColor;
std::unique_ptr<VulkanImage> SceneDepthStencil;
std::unique_ptr<VulkanImageView> SceneColorView;
std::unique_ptr<VulkanImageView> SceneDepthStencilView;
std::unique_ptr<VulkanImageView> SceneDepthView;
VkFormat SceneDepthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
private:
void CreatePipeline(int width, int height);
void CreateScene(int width, int height, int samples);
int mWidth = 0;
int mHeight = 0;
int mSceneWidth = 0;
int mSceneHeight = 0;
int mSamples = 0;
int mMaxSamples = 16;
};

View file

@ -1,5 +1,6 @@
#include "vk_renderpass.h" #include "vk_renderpass.h"
#include "vk_renderbuffers.h"
#include "vulkan/shaders/vk_shader.h" #include "vulkan/shaders/vk_shader.h"
#include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_builders.h"
#include "vulkan/system/vk_framebuffer.h" #include "vulkan/system/vk_framebuffer.h"
@ -21,53 +22,23 @@ void VkRenderPassManager::Init()
CreateDynamicSet(); CreateDynamicSet();
} }
void VkRenderPassManager::BeginFrame() void VkRenderPassManager::RenderBuffersReset()
{ {
if (!SceneColor || SceneColor->width != SCREENWIDTH || SceneColor->height != SCREENHEIGHT)
{
auto fb = GetVulkanFrameBuffer();
RenderPassSetup.clear(); RenderPassSetup.clear();
SceneColorView.reset(); }
SceneDepthStencilView.reset();
SceneDepthView.reset();
SceneColor.reset();
SceneDepthStencil.reset();
ImageBuilder builder; void VkRenderPassManager::BeginRenderPass(const VkRenderPassKey &key, VulkanCommandBuffer *cmdbuffer)
builder.setSize(SCREENWIDTH, SCREENHEIGHT); {
builder.setFormat(VK_FORMAT_R16G16B16A16_SFLOAT); auto buffers = GetVulkanFrameBuffer()->GetBuffers();
builder.setUsage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
SceneColor = builder.create(fb->device);
builder.setFormat(SceneDepthStencilFormat); VkRenderPassSetup *passSetup = GetRenderPass(key);
builder.setUsage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!builder.isFormatSupported(fb->device))
{
SceneDepthStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
builder.setFormat(SceneDepthStencilFormat);
if (!builder.isFormatSupported(fb->device))
{
I_FatalError("This device does not support any of the required depth stencil image formats.");
}
}
SceneDepthStencil = builder.create(fb->device);
ImageViewBuilder viewbuilder; RenderPassBegin beginInfo;
viewbuilder.setImage(SceneColor.get(), VK_FORMAT_R16G16B16A16_SFLOAT); beginInfo.setRenderPass(passSetup->RenderPass.get());
SceneColorView = viewbuilder.create(fb->device); beginInfo.setRenderArea(0, 0, buffers->GetWidth(), buffers->GetHeight());
beginInfo.setFramebuffer(passSetup->Framebuffer.get());
viewbuilder.setImage(SceneDepthStencil.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); cmdbuffer->beginRenderPass(beginInfo);
SceneDepthStencilView = viewbuilder.create(fb->device); cmdbuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get());
viewbuilder.setImage(SceneDepthStencil.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
SceneDepthView = viewbuilder.create(fb->device);
PipelineBarrier barrier;
barrier.addImage(SceneColor.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
barrier.addImage(SceneDepthStencil.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
barrier.execute(fb->GetDrawCommands(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
}
} }
VkRenderPassSetup *VkRenderPassManager::GetRenderPass(const VkRenderPassKey &key) VkRenderPassSetup *VkRenderPassManager::GetRenderPass(const VkRenderPassKey &key)
@ -181,7 +152,7 @@ void VkRenderPassSetup::CreateRenderPass(const VkRenderPassKey &key)
RenderPassBuilder builder; RenderPassBuilder builder;
builder.addRgba16fAttachment(false, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); builder.addRgba16fAttachment(false, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
if (key.DepthTest || key.DepthWrite || key.StencilTest) if (key.DepthTest || key.DepthWrite || key.StencilTest)
builder.addDepthStencilAttachment(false, GetVulkanFrameBuffer()->GetRenderPassManager()->SceneDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); builder.addDepthStencilAttachment(false, GetVulkanFrameBuffer()->GetBuffers()->SceneDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
builder.addSubpass(); builder.addSubpass();
builder.addSubpassColorAttachmentRef(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); builder.addSubpassColorAttachmentRef(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
if (key.DepthTest || key.DepthWrite || key.StencilTest) if (key.DepthTest || key.DepthWrite || key.StencilTest)
@ -319,11 +290,12 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key)
void VkRenderPassSetup::CreateFramebuffer(const VkRenderPassKey &key) void VkRenderPassSetup::CreateFramebuffer(const VkRenderPassKey &key)
{ {
auto fb = GetVulkanFrameBuffer(); auto fb = GetVulkanFrameBuffer();
auto buffers = fb->GetBuffers();
FramebufferBuilder builder; FramebufferBuilder builder;
builder.setRenderPass(RenderPass.get()); builder.setRenderPass(RenderPass.get());
builder.setSize(SCREENWIDTH, SCREENHEIGHT); builder.setSize(buffers->GetWidth(), buffers->GetHeight());
builder.addAttachment(fb->GetRenderPassManager()->SceneColorView.get()); builder.addAttachment(buffers->SceneColorView.get());
if (key.DepthTest || key.DepthWrite || key.StencilTest) if (key.DepthTest || key.DepthWrite || key.StencilTest)
builder.addAttachment(fb->GetRenderPassManager()->SceneDepthStencilView.get()); builder.addAttachment(buffers->SceneDepthStencilView.get());
Framebuffer = builder.create(GetVulkanFrameBuffer()->device); Framebuffer = builder.create(GetVulkanFrameBuffer()->device);
} }

View file

@ -63,8 +63,9 @@ public:
VkRenderPassManager(); VkRenderPassManager();
void Init(); void Init();
void BeginFrame(); void RenderBuffersReset();
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
void BeginRenderPass(const VkRenderPassKey &key, VulkanCommandBuffer *cmdbuffer);
int GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs); int GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs);
@ -74,14 +75,6 @@ public:
std::unique_ptr<VulkanDescriptorPool> DescriptorPool; std::unique_ptr<VulkanDescriptorPool> DescriptorPool;
std::map<VkRenderPassKey, std::unique_ptr<VkRenderPassSetup>> RenderPassSetup; std::map<VkRenderPassKey, std::unique_ptr<VkRenderPassSetup>> RenderPassSetup;
std::unique_ptr<VulkanImage> SceneColor;
std::unique_ptr<VulkanImage> SceneDepthStencil;
std::unique_ptr<VulkanImageView> SceneColorView;
std::unique_ptr<VulkanImageView> SceneDepthStencilView;
std::unique_ptr<VulkanImageView> SceneDepthView;
VkFormat SceneDepthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
std::unique_ptr<VulkanDescriptorSet> DynamicSet; std::unique_ptr<VulkanDescriptorSet> DynamicSet;
std::vector<VkVertexFormat> VertexFormats; std::vector<VkVertexFormat> VertexFormats;
@ -92,4 +85,6 @@ private:
void CreatePipelineLayout(); void CreatePipelineLayout();
void CreateDescriptorPool(); void CreateDescriptorPool();
void CreateDynamicSet(); void CreateDynamicSet();
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
}; };

View file

@ -3,6 +3,7 @@
#include "vulkan/system/vk_framebuffer.h" #include "vulkan/system/vk_framebuffer.h"
#include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_builders.h"
#include "vulkan/renderer/vk_renderpass.h" #include "vulkan/renderer/vk_renderpass.h"
#include "vulkan/renderer/vk_renderbuffers.h"
#include "vulkan/textures/vk_hwtexture.h" #include "vulkan/textures/vk_hwtexture.h"
#include "templates.h" #include "templates.h"
#include "doomstat.h" #include "doomstat.h"
@ -243,9 +244,6 @@ void VkRenderState::ApplyDepthBias()
void VkRenderState::ApplyRenderPass(int dt) void VkRenderState::ApplyRenderPass(int dt)
{ {
auto fb = GetVulkanFrameBuffer();
auto passManager = fb->GetRenderPassManager();
// Find a render pass that matches our state // Find a render pass that matches our state
VkRenderPassKey passKey; VkRenderPassKey passKey;
passKey.DrawType = dt; passKey.DrawType = dt;
@ -279,7 +277,7 @@ void VkRenderState::ApplyRenderPass(int dt)
if (!mCommandBuffer) if (!mCommandBuffer)
{ {
mCommandBuffer = fb->GetDrawCommands(); mCommandBuffer = GetVulkanFrameBuffer()->GetDrawCommands();
changingRenderPass = true; changingRenderPass = true;
mScissorChanged = true; mScissorChanged = true;
mViewportChanged = true; mViewportChanged = true;
@ -293,15 +291,7 @@ void VkRenderState::ApplyRenderPass(int dt)
if (changingRenderPass) if (changingRenderPass)
{ {
VkRenderPassSetup *passSetup = passManager->GetRenderPass(passKey); GetVulkanFrameBuffer()->GetRenderPassManager()->BeginRenderPass(passKey, mCommandBuffer);
RenderPassBegin beginInfo;
beginInfo.setRenderPass(passSetup->RenderPass.get());
beginInfo.setRenderArea(0, 0, SCREENWIDTH, SCREENHEIGHT);
beginInfo.setFramebuffer(passSetup->Framebuffer.get());
mCommandBuffer->beginRenderPass(beginInfo);
mCommandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get());
mRenderPassKey = passKey; mRenderPassKey = passKey;
} }
} }
@ -329,10 +319,11 @@ void VkRenderState::ApplyScissor()
} }
else else
{ {
auto buffers = GetVulkanFrameBuffer()->GetBuffers();
scissor.offset.x = 0; scissor.offset.x = 0;
scissor.offset.y = 0; scissor.offset.y = 0;
scissor.extent.width = SCREENWIDTH; scissor.extent.width = buffers->GetWidth();
scissor.extent.height = SCREENHEIGHT; scissor.extent.height = buffers->GetHeight();
} }
mCommandBuffer->setScissor(0, 1, &scissor); mCommandBuffer->setScissor(0, 1, &scissor);
mScissorChanged = false; mScissorChanged = false;
@ -353,10 +344,11 @@ void VkRenderState::ApplyViewport()
} }
else else
{ {
auto buffers = GetVulkanFrameBuffer()->GetBuffers();
viewport.x = 0.0f; viewport.x = 0.0f;
viewport.y = 0.0f; viewport.y = 0.0f;
viewport.width = (float)SCREENWIDTH; viewport.width = (float)buffers->GetWidth();
viewport.height = (float)SCREENHEIGHT; viewport.height = (float)buffers->GetHeight();
} }
viewport.minDepth = mViewportDepthMin; viewport.minDepth = mViewportDepthMin;
viewport.maxDepth = mViewportDepthMax; viewport.maxDepth = mViewportDepthMax;

View file

@ -28,6 +28,7 @@
#include "r_videoscale.h" #include "r_videoscale.h"
#include "actor.h" #include "actor.h"
#include "i_time.h" #include "i_time.h"
#include "g_game.h"
#include "gamedata/fonts/v_text.h" #include "gamedata/fonts/v_text.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
@ -48,6 +49,8 @@
#include "vk_buffers.h" #include "vk_buffers.h"
#include "vulkan/renderer/vk_renderstate.h" #include "vulkan/renderer/vk_renderstate.h"
#include "vulkan/renderer/vk_renderpass.h" #include "vulkan/renderer/vk_renderpass.h"
#include "vulkan/renderer/vk_postprocess.h"
#include "vulkan/renderer/vk_renderbuffers.h"
#include "vulkan/shaders/vk_shader.h" #include "vulkan/shaders/vk_shader.h"
#include "vulkan/textures/vk_samplers.h" #include "vulkan/textures/vk_samplers.h"
#include "vulkan/textures/vk_hwtexture.h" #include "vulkan/textures/vk_hwtexture.h"
@ -105,6 +108,11 @@ void VulkanFrameBuffer::InitializeState()
mUploadSemaphore.reset(new VulkanSemaphore(device)); mUploadSemaphore.reset(new VulkanSemaphore(device));
mGraphicsCommandPool.reset(new VulkanCommandPool(device, device->graphicsFamily)); mGraphicsCommandPool.reset(new VulkanCommandPool(device, device->graphicsFamily));
mScreenBuffers.reset(new VkRenderBuffers());
mSaveBuffers.reset(new VkRenderBuffers());
mActiveRenderBuffers = mScreenBuffers.get();
mPostprocess.reset(new VkPostprocess());
mRenderPassManager.reset(new VkRenderPassManager()); mRenderPassManager.reset(new VkRenderPassManager());
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight()); mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
@ -149,7 +157,7 @@ void VulkanFrameBuffer::Update()
//DrawPresentTexture(mOutputLetterbox, true); //DrawPresentTexture(mOutputLetterbox, true);
{ {
auto sceneColor = mRenderPassManager->SceneColor.get(); auto sceneColor = mScreenBuffers->SceneColor.get();
PipelineBarrier barrier0; PipelineBarrier barrier0;
barrier0.addImage(sceneColor, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT); barrier0.addImage(sceneColor, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT);
@ -557,7 +565,8 @@ void VulkanFrameBuffer::UpdatePalette()
void VulkanFrameBuffer::BeginFrame() void VulkanFrameBuffer::BeginFrame()
{ {
mRenderPassManager->BeginFrame(); mScreenBuffers->BeginFrame(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
mSaveBuffers->BeginFrame(SAVEPICWIDTH, SAVEPICHEIGHT, SAVEPICWIDTH, SAVEPICHEIGHT);
} }
void VulkanFrameBuffer::Draw2D() void VulkanFrameBuffer::Draw2D()

View file

@ -11,6 +11,8 @@ class VkRenderPassManager;
class VkRenderState; class VkRenderState;
class VKDataBuffer; class VKDataBuffer;
class VkHardwareTexture; class VkHardwareTexture;
class VkRenderBuffers;
class VkPostprocess;
class SWSceneDrawer; class SWSceneDrawer;
class VulkanFrameBuffer : public SystemBaseFrameBuffer class VulkanFrameBuffer : public SystemBaseFrameBuffer
@ -27,6 +29,8 @@ public:
VkSamplerManager *GetSamplerManager() { return mSamplerManager.get(); } VkSamplerManager *GetSamplerManager() { return mSamplerManager.get(); }
VkRenderPassManager *GetRenderPassManager() { return mRenderPassManager.get(); } VkRenderPassManager *GetRenderPassManager() { return mRenderPassManager.get(); }
VkRenderState *GetRenderState() { return mRenderState.get(); } VkRenderState *GetRenderState() { return mRenderState.get(); }
VkPostprocess *GetPostprocess() { return mPostprocess.get(); }
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
unsigned int GetLightBufferBlockSize() const; unsigned int GetLightBufferBlockSize() const;
@ -84,6 +88,9 @@ private:
std::unique_ptr<VkShaderManager> mShaderManager; std::unique_ptr<VkShaderManager> mShaderManager;
std::unique_ptr<VkSamplerManager> mSamplerManager; std::unique_ptr<VkSamplerManager> mSamplerManager;
std::unique_ptr<VkRenderBuffers> mScreenBuffers;
std::unique_ptr<VkRenderBuffers> mSaveBuffers;
std::unique_ptr<VkPostprocess> mPostprocess;
std::unique_ptr<VkRenderPassManager> mRenderPassManager; std::unique_ptr<VkRenderPassManager> mRenderPassManager;
std::unique_ptr<VulkanCommandPool> mGraphicsCommandPool; std::unique_ptr<VulkanCommandPool> mGraphicsCommandPool;
std::unique_ptr<VulkanCommandBuffer> mUploadCommands; std::unique_ptr<VulkanCommandBuffer> mUploadCommands;
@ -91,6 +98,8 @@ private:
std::unique_ptr<VulkanSemaphore> mUploadSemaphore; std::unique_ptr<VulkanSemaphore> mUploadSemaphore;
std::unique_ptr<VkRenderState> mRenderState; std::unique_ptr<VkRenderState> mRenderState;
VkRenderBuffers *mActiveRenderBuffers = nullptr;
int camtexcount = 0; int camtexcount = 0;
int lastSwapWidth = 0; int lastSwapWidth = 0;