Skip to content

Commit

Permalink
Apply device limit of supported multi-sampling in ExampleBase and fix…
Browse files Browse the repository at this point in the history
…ed initialization of rendering caps in debug layer.
  • Loading branch information
LukasBanana committed Aug 15, 2023
1 parent dd5bb47 commit b46428e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions examples/Cpp/ExampleBase/ExampleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ ExampleBase::ExampleBase(
:
profilerObj_ { new LLGL::RenderingProfiler() },
debuggerObj_ { new LLGL::RenderingDebugger() },
samples_ { samples },
profiler { *profilerObj_ }
{
// Set report callback to standard output
Expand Down Expand Up @@ -280,11 +279,17 @@ ExampleBase::ExampleBase(
if (!debugger)
debuggerObj_.reset();

// Apply device limits (not for GL, because we won't have a valid GL context until we create our first swap chain)
if (renderer->GetRendererID() == LLGL::RendererID::OpenGL)
samples_ = samples;
else
samples_ = std::min(samples, renderer->GetRenderingCaps().limits.maxColorBufferSamples);

// Create swap-chain
LLGL::SwapChainDescriptor swapChainDesc;
{
swapChainDesc.resolution = resolution;
swapChainDesc.samples = samples;
swapChainDesc.samples = GetSampleCount();
}
swapChain = renderer->CreateSwapChain(swapChainDesc);

Expand Down
16 changes: 11 additions & 5 deletions sources/Renderer/DebugLayer/DbgRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ DbgRenderSystem::DbgRenderSystem(RenderSystemPtr&& instance, RenderingProfiler*
features_ { caps_.features },
limits_ { caps_.limits }
{
/* Initialize rendering capabilities from wrapped instance */
UpdateRenderingCaps();
}

/* ----- Swap-chain ----- */
Expand All @@ -49,13 +51,10 @@ SwapChain* DbgRenderSystem::CreateSwapChain(const SwapChainDescriptor& swapChain
/* Create primary swap-chain */
auto swapChainInstance = instance_->CreateSwapChain(swapChainDesc, surface);

/* Instantiate command queue if not done and update rendering capabilities from wrapped instance */
if (!commandQueue_)
{
/* Store meta data about render system */
SetRendererInfo(instance_->GetRendererInfo());
SetRenderingCaps(instance_->GetRenderingCaps());

/* Instantiate command queue */
UpdateRenderingCaps();
commandQueue_ = MakeUnique<DbgCommandQueue>(*(instance_->GetCommandQueue()), profiler_, debugger_);
}

Expand Down Expand Up @@ -1823,6 +1822,13 @@ void DbgRenderSystem::ReleaseDbg(HWObjectContainer<T>& cont, TBase& entry)
cont.erase(&entry);
}

void DbgRenderSystem::UpdateRenderingCaps()
{
/* Store meta data about render system */
SetRendererInfo(instance_->GetRendererInfo());
SetRenderingCaps(instance_->GetRenderingCaps());
}


} // /namespace LLGL

Expand Down
2 changes: 2 additions & 0 deletions sources/Renderer/DebugLayer/DbgRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class DbgRenderSystem final : public RenderSystem

std::vector<ResourceViewDescriptor> GetResourceViewInstanceCopy(const ArrayView<ResourceViewDescriptor>& resourceViews);

void UpdateRenderingCaps();

private:

/* ----- Common objects ----- */
Expand Down

0 comments on commit b46428e

Please sign in to comment.