Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/renderer/PostprocManager.cpp
Show All 23 Lines | |||||
#include "graphics/ShaderManager.h" | #include "graphics/ShaderManager.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/CStrInternStatic.h" | #include "ps/CStrInternStatic.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/VideoMode.h" | |||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "renderer/backend/IDevice.h" | #include "renderer/backend/IDevice.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/RenderingOptions.h" | #include "renderer/RenderingOptions.h" | ||||
#include "tools/atlas/GameInterface/GameLoop.h" | #include "tools/atlas/GameInterface/GameLoop.h" | ||||
#include <string_view> | #include <string_view> | ||||
Show All 36 Lines | void DrawFullscreenQuad( | ||||
deviceCommandContext->SetVertexBufferData( | deviceCommandContext->SetVertexBufferData( | ||||
1, quadTex, std::size(quadTex) * sizeof(quadTex[0])); | 1, quadTex, std::size(quadTex) * sizeof(quadTex[0])); | ||||
deviceCommandContext->Draw(0, 6); | deviceCommandContext->Draw(0, 6); | ||||
} | } | ||||
} // anonymous namespace | } // anonymous namespace | ||||
CPostprocManager::CPostprocManager() | CPostprocManager::CPostprocManager(Renderer::Backend::IDevice* device) | ||||
: m_IsInitialized(false), m_PostProcEffect(L"default"), m_WhichBuffer(true), | : m_Device(device), m_IsInitialized(false), m_PostProcEffect(L"default"), | ||||
m_Sharpness(0.3f), m_UsingMultisampleBuffer(false), m_MultisampleCount(0) | m_WhichBuffer(true), m_Sharpness(0.3f), m_UsingMultisampleBuffer(false), | ||||
m_MultisampleCount(0) | |||||
{ | { | ||||
} | } | ||||
CPostprocManager::~CPostprocManager() | CPostprocManager::~CPostprocManager() | ||||
{ | { | ||||
Cleanup(); | Cleanup(); | ||||
} | } | ||||
bool CPostprocManager::IsEnabled() const | bool CPostprocManager::IsEnabled() const | ||||
{ | { | ||||
Renderer::Backend::IDevice* device = g_VideoMode.GetBackendDevice(); | |||||
const bool isDepthStencilFormatPresent = | const bool isDepthStencilFormatPresent = | ||||
device->GetPreferredDepthStencilFormat( | m_Device->GetPreferredDepthStencilFormat( | ||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, true, true) | Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, true, true) | ||||
!= Renderer::Backend::Format::UNDEFINED; | != Renderer::Backend::Format::UNDEFINED; | ||||
return | return | ||||
g_RenderingOptions.GetPostProc() && | g_RenderingOptions.GetPostProc() && | ||||
device->GetBackend() != Renderer::Backend::Backend::GL_ARB && | m_Device->GetBackend() != Renderer::Backend::Backend::GL_ARB && | ||||
isDepthStencilFormatPresent; | isDepthStencilFormatPresent; | ||||
} | } | ||||
void CPostprocManager::Cleanup() | void CPostprocManager::Cleanup() | ||||
{ | { | ||||
if (!m_IsInitialized) // Only cleanup if previously used | if (!m_IsInitialized) // Only cleanup if previously used | ||||
return; | return; | ||||
Show All 26 Lines | const std::array<Renderer::Backend::SVertexAttributeFormat, 2> attributes{{ | ||||
Renderer::Backend::Format::R32G32_SFLOAT, 0, sizeof(float) * 2, | Renderer::Backend::Format::R32G32_SFLOAT, 0, sizeof(float) * 2, | ||||
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0}, | Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0}, | ||||
{Renderer::Backend::VertexAttributeStream::UV0, | {Renderer::Backend::VertexAttributeStream::UV0, | ||||
Renderer::Backend::Format::R32G32_SFLOAT, 0, sizeof(float) * 2, | Renderer::Backend::Format::R32G32_SFLOAT, 0, sizeof(float) * 2, | ||||
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 1}, | Renderer::Backend::VertexAttributeRate::PER_VERTEX, 1}, | ||||
}}; | }}; | ||||
m_VertexInputLayout = g_Renderer.GetVertexInputLayout(attributes); | m_VertexInputLayout = g_Renderer.GetVertexInputLayout(attributes); | ||||
const uint32_t maxSamples = g_VideoMode.GetBackendDevice()->GetCapabilities().maxSampleCount; | const uint32_t maxSamples = m_Device->GetCapabilities().maxSampleCount; | ||||
const uint32_t possibleSampleCounts[] = {2, 4, 8, 16}; | const uint32_t possibleSampleCounts[] = {2, 4, 8, 16}; | ||||
std::copy_if( | std::copy_if( | ||||
std::begin(possibleSampleCounts), std::end(possibleSampleCounts), | std::begin(possibleSampleCounts), std::end(possibleSampleCounts), | ||||
std::back_inserter(m_AllowedSampleCounts), | std::back_inserter(m_AllowedSampleCounts), | ||||
[maxSamples](const uint32_t sampleCount) { return sampleCount <= maxSamples; } ); | [maxSamples](const uint32_t sampleCount) { return sampleCount <= maxSamples; } ); | ||||
// The screen size starts out correct and then must be updated with Resize() | // The screen size starts out correct and then must be updated with Resize() | ||||
m_Width = g_Renderer.GetWidth(); | m_Width = g_Renderer.GetWidth(); | ||||
Show All 20 Lines | void CPostprocManager::Resize() | ||||
if (m_IsInitialized) | if (m_IsInitialized) | ||||
RecreateBuffers(); | RecreateBuffers(); | ||||
} | } | ||||
void CPostprocManager::RecreateBuffers() | void CPostprocManager::RecreateBuffers() | ||||
{ | { | ||||
Cleanup(); | Cleanup(); | ||||
Renderer::Backend::IDevice* backendDevice = g_VideoMode.GetBackendDevice(); | |||||
#define GEN_BUFFER_RGBA(name, w, h) \ | #define GEN_BUFFER_RGBA(name, w, h) \ | ||||
name = backendDevice->CreateTexture2D( \ | name = m_Device->CreateTexture2D( \ | ||||
"PostProc" #name, \ | "PostProc" #name, \ | ||||
Renderer::Backend::ITexture::Usage::SAMPLED | \ | Renderer::Backend::ITexture::Usage::SAMPLED | \ | ||||
Renderer::Backend::ITexture::Usage::COLOR_ATTACHMENT | \ | Renderer::Backend::ITexture::Usage::COLOR_ATTACHMENT | \ | ||||
Renderer::Backend::ITexture::Usage::TRANSFER_SRC | \ | Renderer::Backend::ITexture::Usage::TRANSFER_SRC | \ | ||||
Renderer::Backend::ITexture::Usage::TRANSFER_DST, \ | Renderer::Backend::ITexture::Usage::TRANSFER_DST, \ | ||||
Renderer::Backend::Format::R8G8B8A8_UNORM, w, h, \ | Renderer::Backend::Format::R8G8B8A8_UNORM, w, h, \ | ||||
Renderer::Backend::Sampler::MakeDefaultSampler( \ | Renderer::Backend::Sampler::MakeDefaultSampler( \ | ||||
Renderer::Backend::Sampler::Filter::LINEAR, \ | Renderer::Backend::Sampler::Filter::LINEAR, \ | ||||
Show All 13 Lines | for (BlurScale& scale : m_BlurScales) | ||||
for (BlurScale::Step& step : scale.steps) | for (BlurScale::Step& step : scale.steps) | ||||
{ | { | ||||
GEN_BUFFER_RGBA(step.texture, width, height); | GEN_BUFFER_RGBA(step.texture, width, height); | ||||
Renderer::Backend::SColorAttachment colorAttachment{}; | Renderer::Backend::SColorAttachment colorAttachment{}; | ||||
colorAttachment.texture = step.texture.get(); | colorAttachment.texture = step.texture.get(); | ||||
colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::LOAD; | colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::LOAD; | ||||
colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | ||||
step.framebuffer = backendDevice->CreateFramebuffer( | step.framebuffer = m_Device->CreateFramebuffer( | ||||
"BlurScaleSteoFramebuffer", &colorAttachment, nullptr); | "BlurScaleSteoFramebuffer", &colorAttachment, nullptr); | ||||
} | } | ||||
width /= 2; | width /= 2; | ||||
height /= 2; | height /= 2; | ||||
} | } | ||||
#undef GEN_BUFFER_RGBA | #undef GEN_BUFFER_RGBA | ||||
// Allocate the Depth/Stencil texture. | // Allocate the Depth/Stencil texture. | ||||
m_DepthTex = backendDevice->CreateTexture2D("PostProcDepthTexture", | m_DepthTex = m_Device->CreateTexture2D("PostProcDepthTexture", | ||||
Renderer::Backend::ITexture::Usage::SAMPLED | | Renderer::Backend::ITexture::Usage::SAMPLED | | ||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, | Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, | ||||
backendDevice->GetPreferredDepthStencilFormat( | m_Device->GetPreferredDepthStencilFormat( | ||||
Renderer::Backend::ITexture::Usage::SAMPLED | | Renderer::Backend::ITexture::Usage::SAMPLED | | ||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, | Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT, | ||||
true, true), | true, true), | ||||
m_Width, m_Height, | m_Width, m_Height, | ||||
Renderer::Backend::Sampler::MakeDefaultSampler( | Renderer::Backend::Sampler::MakeDefaultSampler( | ||||
Renderer::Backend::Sampler::Filter::LINEAR, | Renderer::Backend::Sampler::Filter::LINEAR, | ||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE)); | Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE)); | ||||
// Set up the framebuffers with some initial textures. | // Set up the framebuffers with some initial textures. | ||||
Renderer::Backend::SColorAttachment colorAttachment{}; | Renderer::Backend::SColorAttachment colorAttachment{}; | ||||
colorAttachment.texture = m_ColorTex1.get(); | colorAttachment.texture = m_ColorTex1.get(); | ||||
colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::DONT_CARE; | colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::DONT_CARE; | ||||
colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | ||||
Renderer::Backend::SDepthStencilAttachment depthStencilAttachment{}; | Renderer::Backend::SDepthStencilAttachment depthStencilAttachment{}; | ||||
depthStencilAttachment.texture = m_DepthTex.get(); | depthStencilAttachment.texture = m_DepthTex.get(); | ||||
depthStencilAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::CLEAR; | depthStencilAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::CLEAR; | ||||
depthStencilAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | depthStencilAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
m_CaptureFramebuffer = backendDevice->CreateFramebuffer("PostprocCaptureFramebuffer", | m_CaptureFramebuffer = m_Device->CreateFramebuffer("PostprocCaptureFramebuffer", | ||||
&colorAttachment, &depthStencilAttachment); | &colorAttachment, &depthStencilAttachment); | ||||
colorAttachment.texture = m_ColorTex1.get(); | colorAttachment.texture = m_ColorTex1.get(); | ||||
colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::LOAD; | colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::LOAD; | ||||
colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
m_PingFramebuffer = backendDevice->CreateFramebuffer("PostprocPingFramebuffer", | m_PingFramebuffer = m_Device->CreateFramebuffer("PostprocPingFramebuffer", | ||||
&colorAttachment, nullptr); | &colorAttachment, nullptr); | ||||
colorAttachment.texture = m_ColorTex2.get(); | colorAttachment.texture = m_ColorTex2.get(); | ||||
m_PongFramebuffer = backendDevice->CreateFramebuffer("PostprocPongFramebuffer", | m_PongFramebuffer = m_Device->CreateFramebuffer("PostprocPongFramebuffer", | ||||
&colorAttachment, nullptr); | &colorAttachment, nullptr); | ||||
if (!m_CaptureFramebuffer || !m_PingFramebuffer || !m_PongFramebuffer) | if (!m_CaptureFramebuffer || !m_PingFramebuffer || !m_PongFramebuffer) | ||||
{ | { | ||||
LOGWARNING("Failed to create postproc framebuffers"); | LOGWARNING("Failed to create postproc framebuffers"); | ||||
g_RenderingOptions.SetPostProc(false); | g_RenderingOptions.SetPostProc(false); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | |||||
void CPostprocManager::ApplyPostproc( | void CPostprocManager::ApplyPostproc( | ||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext) | Renderer::Backend::IDeviceCommandContext* deviceCommandContext) | ||||
{ | { | ||||
ENSURE(m_IsInitialized); | ENSURE(m_IsInitialized); | ||||
// Don't do anything if we are using the default effect and no AA. | // Don't do anything if we are using the default effect and no AA. | ||||
const bool hasEffects = m_PostProcEffect != L"default"; | const bool hasEffects = m_PostProcEffect != L"default"; | ||||
const bool hasARB = g_VideoMode.GetBackendDevice()->GetBackend() == Renderer::Backend::Backend::GL_ARB; | const bool hasARB = m_Device->GetBackend() == Renderer::Backend::Backend::GL_ARB; | ||||
const bool hasAA = m_AATech && !hasARB; | const bool hasAA = m_AATech && !hasARB; | ||||
const bool hasSharp = m_SharpTech && !hasARB; | const bool hasSharp = m_SharpTech && !hasARB; | ||||
if (!hasEffects && !hasAA && !hasSharp) | if (!hasEffects && !hasAA && !hasSharp) | ||||
return; | return; | ||||
GPU_SCOPED_LABEL(deviceCommandContext, "Render postproc"); | GPU_SCOPED_LABEL(deviceCommandContext, "Render postproc"); | ||||
if (hasEffects) | if (hasEffects) | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (m_IsInitialized) | ||||
} | } | ||||
} | } | ||||
m_PostProcEffect = name; | m_PostProcEffect = name; | ||||
} | } | ||||
void CPostprocManager::UpdateAntiAliasingTechnique() | void CPostprocManager::UpdateAntiAliasingTechnique() | ||||
{ | { | ||||
Renderer::Backend::IDevice* device = g_VideoMode.GetBackendDevice(); | if (m_Device->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized) | ||||
if (device->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized) | |||||
return; | return; | ||||
CStr newAAName; | CStr newAAName; | ||||
CFG_GET_VAL("antialiasing", newAAName); | CFG_GET_VAL("antialiasing", newAAName); | ||||
if (m_AAName == newAAName) | if (m_AAName == newAAName) | ||||
return; | return; | ||||
m_AAName = newAAName; | m_AAName = newAAName; | ||||
m_AATech.reset(); | m_AATech.reset(); | ||||
Show All 13 Lines | if (m_AAName == str_fxaa.string()) | ||||
m_AATech = g_Renderer.GetShaderManager().LoadEffect(str_fxaa); | m_AATech = g_Renderer.GetShaderManager().LoadEffect(str_fxaa); | ||||
} | } | ||||
else if (m_AAName.size() > msaaPrefix.size() && | else if (m_AAName.size() > msaaPrefix.size() && | ||||
std::string_view{m_AAName}.substr(0, msaaPrefix.size()) == msaaPrefix) | std::string_view{m_AAName}.substr(0, msaaPrefix.size()) == msaaPrefix) | ||||
{ | { | ||||
// We don't want to enable MSAA in Atlas, because it uses wxWidgets and its canvas. | // We don't want to enable MSAA in Atlas, because it uses wxWidgets and its canvas. | ||||
if (g_AtlasGameLoop && g_AtlasGameLoop->running) | if (g_AtlasGameLoop && g_AtlasGameLoop->running) | ||||
return; | return; | ||||
if (!device->GetCapabilities().multisampling || m_AllowedSampleCounts.empty()) | if (!m_Device->GetCapabilities().multisampling || m_AllowedSampleCounts.empty()) | ||||
{ | { | ||||
LOGWARNING("MSAA is unsupported."); | LOGWARNING("MSAA is unsupported."); | ||||
return; | return; | ||||
} | } | ||||
std::stringstream ss(m_AAName.substr(msaaPrefix.size())); | std::stringstream ss(m_AAName.substr(msaaPrefix.size())); | ||||
ss >> m_MultisampleCount; | ss >> m_MultisampleCount; | ||||
if (std::find(std::begin(m_AllowedSampleCounts), std::end(m_AllowedSampleCounts), m_MultisampleCount) == | if (std::find(std::begin(m_AllowedSampleCounts), std::end(m_AllowedSampleCounts), m_MultisampleCount) == | ||||
std::end(m_AllowedSampleCounts)) | std::end(m_AllowedSampleCounts)) | ||||
{ | { | ||||
m_MultisampleCount = std::min(4u, device->GetCapabilities().maxSampleCount); | m_MultisampleCount = std::min(4u, m_Device->GetCapabilities().maxSampleCount); | ||||
LOGWARNING("Wrong MSAA sample count: %s.", m_AAName.EscapeToPrintableASCII().c_str()); | LOGWARNING("Wrong MSAA sample count: %s.", m_AAName.EscapeToPrintableASCII().c_str()); | ||||
} | } | ||||
m_UsingMultisampleBuffer = true; | m_UsingMultisampleBuffer = true; | ||||
CreateMultisampleBuffer(); | CreateMultisampleBuffer(); | ||||
} | } | ||||
} | } | ||||
void CPostprocManager::UpdateSharpeningTechnique() | void CPostprocManager::UpdateSharpeningTechnique() | ||||
{ | { | ||||
if (g_VideoMode.GetBackendDevice()->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized) | if (m_Device->GetBackend() == Renderer::Backend::Backend::GL_ARB || !m_IsInitialized) | ||||
return; | return; | ||||
CStr newSharpName; | CStr newSharpName; | ||||
CFG_GET_VAL("sharpening", newSharpName); | CFG_GET_VAL("sharpening", newSharpName); | ||||
if (m_SharpName == newSharpName) | if (m_SharpName == newSharpName) | ||||
return; | return; | ||||
m_SharpName = newSharpName; | m_SharpName = newSharpName; | ||||
m_SharpTech.reset(); | m_SharpTech.reset(); | ||||
Show All 12 Lines | |||||
void CPostprocManager::SetDepthBufferClipPlanes(float nearPlane, float farPlane) | void CPostprocManager::SetDepthBufferClipPlanes(float nearPlane, float farPlane) | ||||
{ | { | ||||
m_NearPlane = nearPlane; | m_NearPlane = nearPlane; | ||||
m_FarPlane = farPlane; | m_FarPlane = farPlane; | ||||
} | } | ||||
void CPostprocManager::CreateMultisampleBuffer() | void CPostprocManager::CreateMultisampleBuffer() | ||||
{ | { | ||||
Renderer::Backend::IDevice* backendDevice = g_VideoMode.GetBackendDevice(); | m_MultisampleColorTex = m_Device->CreateTexture("PostProcColorMS", | ||||
m_MultisampleColorTex = backendDevice->CreateTexture("PostProcColorMS", | |||||
Renderer::Backend::ITexture::Type::TEXTURE_2D_MULTISAMPLE, | Renderer::Backend::ITexture::Type::TEXTURE_2D_MULTISAMPLE, | ||||
Renderer::Backend::ITexture::Usage::COLOR_ATTACHMENT | | Renderer::Backend::ITexture::Usage::COLOR_ATTACHMENT | | ||||
Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | ||||
Renderer::Backend::Format::R8G8B8A8_UNORM, m_Width, m_Height, | Renderer::Backend::Format::R8G8B8A8_UNORM, m_Width, m_Height, | ||||
Renderer::Backend::Sampler::MakeDefaultSampler( | Renderer::Backend::Sampler::MakeDefaultSampler( | ||||
Renderer::Backend::Sampler::Filter::LINEAR, | Renderer::Backend::Sampler::Filter::LINEAR, | ||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, m_MultisampleCount); | Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, m_MultisampleCount); | ||||
// Allocate the Depth/Stencil texture. | // Allocate the Depth/Stencil texture. | ||||
m_MultisampleDepthTex = backendDevice->CreateTexture("PostProcDepthMS", | m_MultisampleDepthTex = m_Device->CreateTexture("PostProcDepthMS", | ||||
Renderer::Backend::ITexture::Type::TEXTURE_2D_MULTISAMPLE, | Renderer::Backend::ITexture::Type::TEXTURE_2D_MULTISAMPLE, | ||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT | | Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT | | ||||
Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | ||||
backendDevice->GetPreferredDepthStencilFormat( | m_Device->GetPreferredDepthStencilFormat( | ||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT | | Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT | | ||||
Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | Renderer::Backend::ITexture::Usage::TRANSFER_SRC, | ||||
true, true), | true, true), | ||||
m_Width, m_Height, | m_Width, m_Height, | ||||
Renderer::Backend::Sampler::MakeDefaultSampler( | Renderer::Backend::Sampler::MakeDefaultSampler( | ||||
Renderer::Backend::Sampler::Filter::LINEAR, | Renderer::Backend::Sampler::Filter::LINEAR, | ||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, m_MultisampleCount); | Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, m_MultisampleCount); | ||||
// Set up the framebuffers with some initial textures. | // Set up the framebuffers with some initial textures. | ||||
Renderer::Backend::SColorAttachment colorAttachment{}; | Renderer::Backend::SColorAttachment colorAttachment{}; | ||||
colorAttachment.texture = m_MultisampleColorTex.get(); | colorAttachment.texture = m_MultisampleColorTex.get(); | ||||
colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::DONT_CARE; | colorAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::DONT_CARE; | ||||
colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | colorAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | colorAttachment.clearColor = CColor{0.0f, 0.0f, 0.0f, 0.0f}; | ||||
Renderer::Backend::SDepthStencilAttachment depthStencilAttachment{}; | Renderer::Backend::SDepthStencilAttachment depthStencilAttachment{}; | ||||
depthStencilAttachment.texture = m_MultisampleDepthTex.get(); | depthStencilAttachment.texture = m_MultisampleDepthTex.get(); | ||||
depthStencilAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::CLEAR; | depthStencilAttachment.loadOp = Renderer::Backend::AttachmentLoadOp::CLEAR; | ||||
depthStencilAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | depthStencilAttachment.storeOp = Renderer::Backend::AttachmentStoreOp::STORE; | ||||
m_MultisampleFramebuffer = backendDevice->CreateFramebuffer( | m_MultisampleFramebuffer = m_Device->CreateFramebuffer( | ||||
"PostprocMultisampleFramebuffer", &colorAttachment, &depthStencilAttachment); | "PostprocMultisampleFramebuffer", &colorAttachment, &depthStencilAttachment); | ||||
if (!m_MultisampleFramebuffer) | if (!m_MultisampleFramebuffer) | ||||
{ | { | ||||
LOGERROR("Failed to create postproc multisample framebuffer"); | LOGERROR("Failed to create postproc multisample framebuffer"); | ||||
m_UsingMultisampleBuffer = false; | m_UsingMultisampleBuffer = false; | ||||
DestroyMultisampleBuffer(); | DestroyMultisampleBuffer(); | ||||
} | } | ||||
Show All 26 Lines |
Wildfire Games · Phabricator