Graphics/Graphics: Create default depth texture in preferred depth format
This commit is contained in:
parent
4749e6ec80
commit
c80e06226f
|
|
@ -89,9 +89,9 @@ namespace Nz
|
||||||
void BuildBlitPipeline();
|
void BuildBlitPipeline();
|
||||||
void BuildDefaultMaterials();
|
void BuildDefaultMaterials();
|
||||||
void BuildDefaultTextures();
|
void BuildDefaultTextures();
|
||||||
|
template<std::size_t N> void RegisterEmbedShaderModule(const UInt8(&content)[N]);
|
||||||
void RegisterMaterialPasses();
|
void RegisterMaterialPasses();
|
||||||
void RegisterShaderModules();
|
void RegisterShaderModules();
|
||||||
template<std::size_t N> void RegisterEmbedShaderModule(const UInt8(&content)[N]);
|
|
||||||
void SelectDepthStencilFormats();
|
void SelectDepthStencilFormats();
|
||||||
|
|
||||||
std::optional<RenderPassCache> m_renderPassCache;
|
std::optional<RenderPassCache> m_renderPassCache;
|
||||||
|
|
|
||||||
|
|
@ -139,11 +139,12 @@ namespace Nz
|
||||||
m_renderPassCache.emplace(*m_renderDevice);
|
m_renderPassCache.emplace(*m_renderDevice);
|
||||||
m_samplerCache.emplace(m_renderDevice);
|
m_samplerCache.emplace(m_renderDevice);
|
||||||
|
|
||||||
|
SelectDepthStencilFormats();
|
||||||
|
|
||||||
BuildDefaultTextures();
|
BuildDefaultTextures();
|
||||||
RegisterShaderModules();
|
RegisterShaderModules();
|
||||||
BuildBlitPipeline();
|
BuildBlitPipeline();
|
||||||
RegisterMaterialPasses();
|
RegisterMaterialPasses();
|
||||||
SelectDepthStencilFormats();
|
|
||||||
|
|
||||||
MaterialPipeline::Initialize();
|
MaterialPipeline::Initialize();
|
||||||
BuildDefaultMaterials();
|
BuildDefaultMaterials();
|
||||||
|
|
@ -367,22 +368,9 @@ namespace Nz
|
||||||
{
|
{
|
||||||
// Depth textures (white but with a depth format)
|
// Depth textures (white but with a depth format)
|
||||||
{
|
{
|
||||||
PixelFormat depthFormat = PixelFormat::Undefined;
|
|
||||||
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth16, PixelFormat::Depth24, PixelFormat::Depth32F })
|
|
||||||
{
|
|
||||||
if (m_renderDevice->IsTextureFormatSupported(depthStencilCandidate, TextureUsage::ShaderSampling))
|
|
||||||
{
|
|
||||||
depthFormat = depthStencilCandidate;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (depthFormat == PixelFormat::Undefined)
|
|
||||||
throw std::runtime_error("couldn't find a sampling-compatible depth pixel format");
|
|
||||||
|
|
||||||
TextureInfo texInfo;
|
TextureInfo texInfo;
|
||||||
texInfo.width = texInfo.height = texInfo.depth = texInfo.levelCount = 1;
|
texInfo.width = texInfo.height = texInfo.depth = texInfo.levelCount = 1;
|
||||||
texInfo.pixelFormat = depthFormat;
|
texInfo.pixelFormat = m_preferredDepthFormat;
|
||||||
|
|
||||||
std::array<UInt8, 6> whitePixels = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
std::array<UInt8, 6> whitePixels = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
|
||||||
|
|
@ -416,6 +404,13 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<std::size_t N>
|
||||||
|
void Graphics::RegisterEmbedShaderModule(const UInt8(&content)[N])
|
||||||
|
{
|
||||||
|
nzsl::Unserializer unserializer(content, N);
|
||||||
|
m_shaderModuleResolver->RegisterModule(nzsl::Ast::UnserializeShader(unserializer));
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::RegisterMaterialPasses()
|
void Graphics::RegisterMaterialPasses()
|
||||||
{
|
{
|
||||||
m_materialPassRegistry.RegisterPass("ForwardPass");
|
m_materialPassRegistry.RegisterPass("ForwardPass");
|
||||||
|
|
@ -455,13 +450,6 @@ namespace Nz
|
||||||
m_shaderModuleResolver->RegisterModuleDirectory(shaderPath);
|
m_shaderModuleResolver->RegisterModuleDirectory(shaderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t N>
|
|
||||||
void Graphics::RegisterEmbedShaderModule(const UInt8(&content)[N])
|
|
||||||
{
|
|
||||||
nzsl::Unserializer unserializer(content, N);
|
|
||||||
m_shaderModuleResolver->RegisterModule(nzsl::Ast::UnserializeShader(unserializer));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::SelectDepthStencilFormats()
|
void Graphics::SelectDepthStencilFormats()
|
||||||
{
|
{
|
||||||
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth24, PixelFormat::Depth32F, PixelFormat::Depth16 })
|
for (PixelFormat depthStencilCandidate : { PixelFormat::Depth24, PixelFormat::Depth32F, PixelFormat::Depth16 })
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue