Graphics/Graphics: Add preferred depth format
This commit is contained in:
parent
ea3c363b58
commit
ad1f3bc321
|
|
@ -48,6 +48,7 @@ namespace Nz
|
||||||
inline const MaterialInstanceLoader& GetMaterialInstanceLoader() const;
|
inline const MaterialInstanceLoader& GetMaterialInstanceLoader() const;
|
||||||
inline MaterialLoader& GetMaterialLoader();
|
inline MaterialLoader& GetMaterialLoader();
|
||||||
inline const MaterialLoader& GetMaterialLoader() const;
|
inline const MaterialLoader& GetMaterialLoader() const;
|
||||||
|
inline PixelFormat GetPreferredDepthFormat() const;
|
||||||
inline PixelFormat GetPreferredDepthStencilFormat() const;
|
inline PixelFormat GetPreferredDepthStencilFormat() const;
|
||||||
inline const std::shared_ptr<RenderDevice>& GetRenderDevice() const;
|
inline const std::shared_ptr<RenderDevice>& GetRenderDevice() const;
|
||||||
inline const RenderPassCache& GetRenderPassCache() const;
|
inline const RenderPassCache& GetRenderPassCache() const;
|
||||||
|
|
@ -97,6 +98,7 @@ namespace Nz
|
||||||
MaterialInstanceLoader m_materialInstanceLoader;
|
MaterialInstanceLoader m_materialInstanceLoader;
|
||||||
MaterialLoader m_materialLoader;
|
MaterialLoader m_materialLoader;
|
||||||
MaterialPassRegistry m_materialPassRegistry;
|
MaterialPassRegistry m_materialPassRegistry;
|
||||||
|
PixelFormat m_preferredDepthFormat;
|
||||||
PixelFormat m_preferredDepthStencilFormat;
|
PixelFormat m_preferredDepthStencilFormat;
|
||||||
|
|
||||||
static Graphics* s_instance;
|
static Graphics* s_instance;
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ namespace Nz
|
||||||
return m_materialLoader;
|
return m_materialLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline PixelFormat Graphics::GetPreferredDepthFormat() const
|
||||||
|
{
|
||||||
|
return m_preferredDepthFormat;
|
||||||
|
}
|
||||||
|
|
||||||
inline PixelFormat Graphics::GetPreferredDepthStencilFormat() const
|
inline PixelFormat Graphics::GetPreferredDepthStencilFormat() const
|
||||||
{
|
{
|
||||||
return m_preferredDepthStencilFormat;
|
return m_preferredDepthStencilFormat;
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,18 @@ namespace Nz
|
||||||
|
|
||||||
void Graphics::SelectDepthStencilFormats()
|
void Graphics::SelectDepthStencilFormats()
|
||||||
{
|
{
|
||||||
|
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth24, PixelFormat::Depth32F, PixelFormat::Depth16 })
|
||||||
|
{
|
||||||
|
if (m_renderDevice->IsTextureFormatSupported(depthStencilCandidate, TextureUsage::DepthStencilAttachment))
|
||||||
|
{
|
||||||
|
m_preferredDepthFormat = depthStencilCandidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_preferredDepthFormat == PixelFormat::Undefined)
|
||||||
|
throw std::runtime_error("no supported depth format found");
|
||||||
|
|
||||||
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth24Stencil8, PixelFormat::Depth32FStencil8, PixelFormat::Depth16Stencil8 })
|
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth24Stencil8, PixelFormat::Depth32FStencil8, PixelFormat::Depth16Stencil8 })
|
||||||
{
|
{
|
||||||
if (m_renderDevice->IsTextureFormatSupported(depthStencilCandidate, TextureUsage::DepthStencilAttachment))
|
if (m_renderDevice->IsTextureFormatSupported(depthStencilCandidate, TextureUsage::DepthStencilAttachment))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue