Renderer: Add pipeline and texture sampler info validation

This commit is contained in:
Jérôme Leclercq
2021-07-09 12:34:38 +02:00
parent 8458301a64
commit 552dfbc01e
19 changed files with 103 additions and 10 deletions

View File

@@ -71,6 +71,7 @@ namespace Nz
OpenGLDevice::~OpenGLDevice()
{
// Free context first as it will unregister itself from m_contexts
m_referenceContext.reset();
}
@@ -95,6 +96,12 @@ namespace Nz
return m_deviceInfo;
}
const RenderDeviceFeatures& OpenGLDevice::GetEnabledFeatures() const
{
//FIXME
return m_deviceInfo.features;
}
std::shared_ptr<AbstractBuffer> OpenGLDevice::InstantiateBuffer(BufferType type)
{
return std::make_shared<OpenGLBuffer>(*this, type);

View File

@@ -19,6 +19,8 @@ namespace Nz
m_pipelineInfo(std::move(pipelineInfo)),
m_isViewportFlipped(false)
{
ValidatePipelineInfo(device, m_pipelineInfo);
OpenGLRenderPipelineLayout& pipelineLayout = static_cast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout);
if (!m_program.Create(device))

View File

@@ -47,9 +47,16 @@ namespace Nz
return std::make_unique<OpenGLRenderWindow>(owner);
}
std::shared_ptr<RenderDevice> OpenGLRenderer::InstanciateRenderDevice(std::size_t deviceIndex, const RenderDeviceFeatures& /*enabledFeatures*/)
std::shared_ptr<RenderDevice> OpenGLRenderer::InstanciateRenderDevice(std::size_t deviceIndex, const RenderDeviceFeatures& enabledFeatures)
{
assert(deviceIndex == 0);
// For now, since we have to create a device to know its features, supported features are always reported as enabled
// We still call ValidateFeatures in order to trigger warnings if requested features are not supported
// TODO: Report disabled features as disabled (make OpenGLDeviceProxy?)
RenderDeviceFeatures validatedFeatures = enabledFeatures;
OpenGLDevice::ValidateFeatures(m_device->GetEnabledFeatures(), validatedFeatures);
return m_device;
}

View File

@@ -9,8 +9,10 @@
namespace Nz
{
OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, const TextureSamplerInfo& samplerInfo)
OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo)
{
ValidateSamplerInfo(device, samplerInfo);
BuildSampler(device, m_samplerWithMipmaps, samplerInfo, true);
BuildSampler(device, m_samplerWithoutMipmaps, samplerInfo, false);
}