mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +00:00
- add some classes for managing postprocess and render buffers
This commit is contained in:
parent
319099fee9
commit
d65de299e8
10 changed files with 328 additions and 76 deletions
|
@ -901,6 +901,8 @@ set( FASTMATH_SOURCES
|
|||
rendering/vulkan/system/vk_buffers.cpp
|
||||
rendering/vulkan/renderer/vk_renderstate.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/textures/vk_samplers.cpp
|
||||
rendering/vulkan/textures/vk_hwtexture.cpp
|
||||
|
|
119
src/rendering/vulkan/renderer/vk_postprocess.cpp
Normal file
119
src/rendering/vulkan/renderer/vk_postprocess.cpp
Normal 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)
|
||||
{
|
||||
}
|
28
src/rendering/vulkan/renderer/vk_postprocess.h
Normal file
28
src/rendering/vulkan/renderer/vk_postprocess.h
Normal 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();
|
||||
};
|
89
src/rendering/vulkan/renderer/vk_renderbuffers.cpp
Normal file
89
src/rendering/vulkan/renderer/vk_renderbuffers.cpp
Normal 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);
|
||||
}
|
37
src/rendering/vulkan/renderer/vk_renderbuffers.h
Normal file
37
src/rendering/vulkan/renderer/vk_renderbuffers.h
Normal 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;
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include "vk_renderpass.h"
|
||||
#include "vk_renderbuffers.h"
|
||||
#include "vulkan/shaders/vk_shader.h"
|
||||
#include "vulkan/system/vk_builders.h"
|
||||
#include "vulkan/system/vk_framebuffer.h"
|
||||
|
@ -21,53 +22,23 @@ void VkRenderPassManager::Init()
|
|||
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();
|
||||
void VkRenderPassManager::BeginRenderPass(const VkRenderPassKey &key, VulkanCommandBuffer *cmdbuffer)
|
||||
{
|
||||
auto buffers = GetVulkanFrameBuffer()->GetBuffers();
|
||||
|
||||
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);
|
||||
VkRenderPassSetup *passSetup = GetRenderPass(key);
|
||||
|
||||
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);
|
||||
}
|
||||
RenderPassBegin beginInfo;
|
||||
beginInfo.setRenderPass(passSetup->RenderPass.get());
|
||||
beginInfo.setRenderArea(0, 0, buffers->GetWidth(), buffers->GetHeight());
|
||||
beginInfo.setFramebuffer(passSetup->Framebuffer.get());
|
||||
cmdbuffer->beginRenderPass(beginInfo);
|
||||
cmdbuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get());
|
||||
}
|
||||
|
||||
VkRenderPassSetup *VkRenderPassManager::GetRenderPass(const VkRenderPassKey &key)
|
||||
|
@ -181,7 +152,7 @@ void VkRenderPassSetup::CreateRenderPass(const VkRenderPassKey &key)
|
|||
RenderPassBuilder builder;
|
||||
builder.addRgba16fAttachment(false, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
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.addSubpassColorAttachmentRef(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
if (key.DepthTest || key.DepthWrite || key.StencilTest)
|
||||
|
@ -319,11 +290,12 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key)
|
|||
void VkRenderPassSetup::CreateFramebuffer(const VkRenderPassKey &key)
|
||||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
auto buffers = fb->GetBuffers();
|
||||
FramebufferBuilder builder;
|
||||
builder.setRenderPass(RenderPass.get());
|
||||
builder.setSize(SCREENWIDTH, SCREENHEIGHT);
|
||||
builder.addAttachment(fb->GetRenderPassManager()->SceneColorView.get());
|
||||
builder.setSize(buffers->GetWidth(), buffers->GetHeight());
|
||||
builder.addAttachment(buffers->SceneColorView.get());
|
||||
if (key.DepthTest || key.DepthWrite || key.StencilTest)
|
||||
builder.addAttachment(fb->GetRenderPassManager()->SceneDepthStencilView.get());
|
||||
builder.addAttachment(buffers->SceneDepthStencilView.get());
|
||||
Framebuffer = builder.create(GetVulkanFrameBuffer()->device);
|
||||
}
|
||||
|
|
|
@ -63,8 +63,9 @@ public:
|
|||
VkRenderPassManager();
|
||||
|
||||
void Init();
|
||||
void BeginFrame();
|
||||
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
|
||||
void RenderBuffersReset();
|
||||
|
||||
void BeginRenderPass(const VkRenderPassKey &key, VulkanCommandBuffer *cmdbuffer);
|
||||
|
||||
int GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs);
|
||||
|
||||
|
@ -74,14 +75,6 @@ public:
|
|||
std::unique_ptr<VulkanDescriptorPool> DescriptorPool;
|
||||
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::vector<VkVertexFormat> VertexFormats;
|
||||
|
@ -92,4 +85,6 @@ private:
|
|||
void CreatePipelineLayout();
|
||||
void CreateDescriptorPool();
|
||||
void CreateDynamicSet();
|
||||
|
||||
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "vulkan/system/vk_framebuffer.h"
|
||||
#include "vulkan/system/vk_builders.h"
|
||||
#include "vulkan/renderer/vk_renderpass.h"
|
||||
#include "vulkan/renderer/vk_renderbuffers.h"
|
||||
#include "vulkan/textures/vk_hwtexture.h"
|
||||
#include "templates.h"
|
||||
#include "doomstat.h"
|
||||
|
@ -243,9 +244,6 @@ void VkRenderState::ApplyDepthBias()
|
|||
|
||||
void VkRenderState::ApplyRenderPass(int dt)
|
||||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
auto passManager = fb->GetRenderPassManager();
|
||||
|
||||
// Find a render pass that matches our state
|
||||
VkRenderPassKey passKey;
|
||||
passKey.DrawType = dt;
|
||||
|
@ -279,7 +277,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
|||
|
||||
if (!mCommandBuffer)
|
||||
{
|
||||
mCommandBuffer = fb->GetDrawCommands();
|
||||
mCommandBuffer = GetVulkanFrameBuffer()->GetDrawCommands();
|
||||
changingRenderPass = true;
|
||||
mScissorChanged = true;
|
||||
mViewportChanged = true;
|
||||
|
@ -293,15 +291,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
|||
|
||||
if (changingRenderPass)
|
||||
{
|
||||
VkRenderPassSetup *passSetup = passManager->GetRenderPass(passKey);
|
||||
|
||||
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());
|
||||
|
||||
GetVulkanFrameBuffer()->GetRenderPassManager()->BeginRenderPass(passKey, mCommandBuffer);
|
||||
mRenderPassKey = passKey;
|
||||
}
|
||||
}
|
||||
|
@ -329,10 +319,11 @@ void VkRenderState::ApplyScissor()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto buffers = GetVulkanFrameBuffer()->GetBuffers();
|
||||
scissor.offset.x = 0;
|
||||
scissor.offset.y = 0;
|
||||
scissor.extent.width = SCREENWIDTH;
|
||||
scissor.extent.height = SCREENHEIGHT;
|
||||
scissor.extent.width = buffers->GetWidth();
|
||||
scissor.extent.height = buffers->GetHeight();
|
||||
}
|
||||
mCommandBuffer->setScissor(0, 1, &scissor);
|
||||
mScissorChanged = false;
|
||||
|
@ -353,10 +344,11 @@ void VkRenderState::ApplyViewport()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto buffers = GetVulkanFrameBuffer()->GetBuffers();
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
viewport.width = (float)SCREENWIDTH;
|
||||
viewport.height = (float)SCREENHEIGHT;
|
||||
viewport.width = (float)buffers->GetWidth();
|
||||
viewport.height = (float)buffers->GetHeight();
|
||||
}
|
||||
viewport.minDepth = mViewportDepthMin;
|
||||
viewport.maxDepth = mViewportDepthMax;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "r_videoscale.h"
|
||||
#include "actor.h"
|
||||
#include "i_time.h"
|
||||
#include "g_game.h"
|
||||
#include "gamedata/fonts/v_text.h"
|
||||
|
||||
#include "hwrenderer/utility/hw_clock.h"
|
||||
|
@ -48,6 +49,8 @@
|
|||
#include "vk_buffers.h"
|
||||
#include "vulkan/renderer/vk_renderstate.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/textures/vk_samplers.h"
|
||||
#include "vulkan/textures/vk_hwtexture.h"
|
||||
|
@ -105,6 +108,11 @@ void VulkanFrameBuffer::InitializeState()
|
|||
mUploadSemaphore.reset(new VulkanSemaphore(device));
|
||||
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());
|
||||
|
||||
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
|
||||
|
@ -149,7 +157,7 @@ void VulkanFrameBuffer::Update()
|
|||
|
||||
//DrawPresentTexture(mOutputLetterbox, true);
|
||||
{
|
||||
auto sceneColor = mRenderPassManager->SceneColor.get();
|
||||
auto sceneColor = mScreenBuffers->SceneColor.get();
|
||||
|
||||
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);
|
||||
|
@ -557,7 +565,8 @@ void VulkanFrameBuffer::UpdatePalette()
|
|||
|
||||
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()
|
||||
|
|
|
@ -11,6 +11,8 @@ class VkRenderPassManager;
|
|||
class VkRenderState;
|
||||
class VKDataBuffer;
|
||||
class VkHardwareTexture;
|
||||
class VkRenderBuffers;
|
||||
class VkPostprocess;
|
||||
class SWSceneDrawer;
|
||||
|
||||
class VulkanFrameBuffer : public SystemBaseFrameBuffer
|
||||
|
@ -27,6 +29,8 @@ public:
|
|||
VkSamplerManager *GetSamplerManager() { return mSamplerManager.get(); }
|
||||
VkRenderPassManager *GetRenderPassManager() { return mRenderPassManager.get(); }
|
||||
VkRenderState *GetRenderState() { return mRenderState.get(); }
|
||||
VkPostprocess *GetPostprocess() { return mPostprocess.get(); }
|
||||
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
|
||||
|
||||
unsigned int GetLightBufferBlockSize() const;
|
||||
|
||||
|
@ -84,6 +88,9 @@ private:
|
|||
|
||||
std::unique_ptr<VkShaderManager> mShaderManager;
|
||||
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<VulkanCommandPool> mGraphicsCommandPool;
|
||||
std::unique_ptr<VulkanCommandBuffer> mUploadCommands;
|
||||
|
@ -91,6 +98,8 @@ private:
|
|||
std::unique_ptr<VulkanSemaphore> mUploadSemaphore;
|
||||
std::unique_ptr<VkRenderState> mRenderState;
|
||||
|
||||
VkRenderBuffers *mActiveRenderBuffers = nullptr;
|
||||
|
||||
int camtexcount = 0;
|
||||
|
||||
int lastSwapWidth = 0;
|
||||
|
|
Loading…
Reference in a new issue