Adds preferred depth stencil format to renderer backend.
This was SVN commit r27379.
This commit is contained in:
parent
0641d3660f
commit
7dca5d23ad
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2022 Wildfire Games.
|
/* Copyright (C) 2023 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -518,7 +518,13 @@ void ShadowMapInternals::CreateTexture()
|
|||||||
case 16: formatName = "Format::D16"; backendFormat = Renderer::Backend::Format::D16; break;
|
case 16: formatName = "Format::D16"; backendFormat = Renderer::Backend::Format::D16; break;
|
||||||
case 24: formatName = "Format::D24"; backendFormat = Renderer::Backend::Format::D24; break;
|
case 24: formatName = "Format::D24"; backendFormat = Renderer::Backend::Format::D24; break;
|
||||||
case 32: formatName = "Format::D32"; backendFormat = Renderer::Backend::Format::D32; break;
|
case 32: formatName = "Format::D32"; backendFormat = Renderer::Backend::Format::D32; break;
|
||||||
default: formatName = "Format::D24"; backendFormat = Renderer::Backend::Format::D24; break;
|
default:
|
||||||
|
formatName = "Default";
|
||||||
|
backendFormat = backendDevice->GetPreferredDepthStencilFormat(
|
||||||
|
Renderer::Backend::ITexture::Usage::SAMPLED |
|
||||||
|
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
||||||
|
true, false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ENSURE(formatName);
|
ENSURE(formatName);
|
||||||
|
@ -235,6 +235,12 @@ void WaterManager::RecreateOrLoadTexturesIfNeeded()
|
|||||||
m_RefTextureSize = newRefTextureSize;
|
m_RefTextureSize = newRefTextureSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Renderer::Backend::Format depthFormat =
|
||||||
|
backendDevice->GetPreferredDepthStencilFormat(
|
||||||
|
Renderer::Backend::ITexture::Usage::SAMPLED |
|
||||||
|
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
||||||
|
true, false);
|
||||||
|
|
||||||
// Create reflection textures.
|
// Create reflection textures.
|
||||||
const bool needsReflectionTextures =
|
const bool needsReflectionTextures =
|
||||||
g_RenderingOptions.GetWaterEffects() &&
|
g_RenderingOptions.GetWaterEffects() &&
|
||||||
@ -252,7 +258,7 @@ void WaterManager::RecreateOrLoadTexturesIfNeeded()
|
|||||||
m_ReflFboDepthTexture = backendDevice->CreateTexture2D("WaterReflectionDepthTexture",
|
m_ReflFboDepthTexture = backendDevice->CreateTexture2D("WaterReflectionDepthTexture",
|
||||||
Renderer::Backend::ITexture::Usage::SAMPLED |
|
Renderer::Backend::ITexture::Usage::SAMPLED |
|
||||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
||||||
Renderer::Backend::Format::D24, m_RefTextureSize, m_RefTextureSize,
|
depthFormat, m_RefTextureSize, m_RefTextureSize,
|
||||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||||
@ -294,7 +300,7 @@ void WaterManager::RecreateOrLoadTexturesIfNeeded()
|
|||||||
m_RefrFboDepthTexture = backendDevice->CreateTexture2D("WaterRefractionDepthTexture",
|
m_RefrFboDepthTexture = backendDevice->CreateTexture2D("WaterRefractionDepthTexture",
|
||||||
Renderer::Backend::ITexture::Usage::SAMPLED |
|
Renderer::Backend::ITexture::Usage::SAMPLED |
|
||||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
||||||
Renderer::Backend::Format::D24, m_RefTextureSize, m_RefTextureSize,
|
depthFormat, m_RefTextureSize, m_RefTextureSize,
|
||||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||||
@ -345,7 +351,7 @@ void WaterManager::RecreateOrLoadTexturesIfNeeded()
|
|||||||
|
|
||||||
m_FancyTextureDepth = backendDevice->CreateTexture2D("WaterFancyDepthTexture",
|
m_FancyTextureDepth = backendDevice->CreateTexture2D("WaterFancyDepthTexture",
|
||||||
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
Renderer::Backend::ITexture::Usage::DEPTH_STENCIL_ATTACHMENT,
|
||||||
Renderer::Backend::Format::D24, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
depthFormat, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
||||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||||
|
@ -163,6 +163,13 @@ public:
|
|||||||
|
|
||||||
virtual bool IsFramebufferFormatSupported(const Format format) const = 0;
|
virtual bool IsFramebufferFormatSupported(const Format format) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the most suitable format for the usage. Returns
|
||||||
|
* Format::UNDEFINED if there is no such format.
|
||||||
|
*/
|
||||||
|
virtual Format GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t usage, const bool depth, const bool stencil) const = 0;
|
||||||
|
|
||||||
virtual const Capabilities& GetCapabilities() const = 0;
|
virtual const Capabilities& GetCapabilities() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,6 +153,12 @@ bool CDevice::IsFramebufferFormatSupported(const Format UNUSED(format)) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Format CDevice::GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t, const bool, const bool) const
|
||||||
|
{
|
||||||
|
return Format::D24_S8;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<IDevice> CreateDevice(SDL_Window* UNUSED(window))
|
std::unique_ptr<IDevice> CreateDevice(SDL_Window* UNUSED(window))
|
||||||
{
|
{
|
||||||
return std::make_unique<Dummy::CDevice>();
|
return std::make_unique<Dummy::CDevice>();
|
||||||
|
@ -95,6 +95,9 @@ public:
|
|||||||
|
|
||||||
bool IsFramebufferFormatSupported(const Format format) const override;
|
bool IsFramebufferFormatSupported(const Format format) const override;
|
||||||
|
|
||||||
|
Format GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t usage, const bool depth, const bool stencil) const override;
|
||||||
|
|
||||||
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1055,6 +1055,20 @@ bool CDevice::IsFramebufferFormatSupported(const Format format) const
|
|||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Format CDevice::GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t UNUSED(usage), const bool depth, const bool stencil) const
|
||||||
|
{
|
||||||
|
ENSURE(depth || stencil);
|
||||||
|
if (stencil)
|
||||||
|
#if CONFIG2_GLES
|
||||||
|
return Format::UNDEFINED;
|
||||||
|
#else
|
||||||
|
return Format::D24_S8;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
return Format::D24;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<IDevice> CreateDevice(SDL_Window* window, const bool arb)
|
std::unique_ptr<IDevice> CreateDevice(SDL_Window* window, const bool arb)
|
||||||
{
|
{
|
||||||
return GL::CDevice::Create(window, arb);
|
return GL::CDevice::Create(window, arb);
|
||||||
|
@ -114,6 +114,9 @@ public:
|
|||||||
|
|
||||||
bool IsFramebufferFormatSupported(const Format format) const override;
|
bool IsFramebufferFormatSupported(const Format format) const override;
|
||||||
|
|
||||||
|
Format GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t usage, const bool depth, const bool stencil) const override;
|
||||||
|
|
||||||
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -188,6 +188,15 @@ bool CDevice::IsFramebufferFormatSupported(const Format format) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Format CDevice::GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t usage, const bool depth, const bool stencil) const
|
||||||
|
{
|
||||||
|
UNUSED2(usage);
|
||||||
|
UNUSED2(depth);
|
||||||
|
UNUSED2(stencil);
|
||||||
|
return Format::UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<IDevice> CreateDevice(SDL_Window* window)
|
std::unique_ptr<IDevice> CreateDevice(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return Vulkan::CDevice::Create(window);
|
return Vulkan::CDevice::Create(window);
|
||||||
|
@ -98,6 +98,9 @@ public:
|
|||||||
|
|
||||||
bool IsFramebufferFormatSupported(const Format format) const override;
|
bool IsFramebufferFormatSupported(const Format format) const override;
|
||||||
|
|
||||||
|
Format GetPreferredDepthStencilFormat(
|
||||||
|
const uint32_t usage, const bool depth, const bool stencil) const override;
|
||||||
|
|
||||||
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
const Capabilities& GetCapabilities() const override { return m_Capabilities; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user