1
0
forked from 0ad/0ad

Makes AcquireNextBackbuffer returns true in case of successful backbuffer acquirement.

This was SVN commit r27184.
This commit is contained in:
Vladislav Belov 2022-10-30 00:38:45 +00:00
parent b54ace20ea
commit 3a4c8342a0
9 changed files with 25 additions and 18 deletions

View File

@ -420,7 +420,11 @@ void CRenderer::RenderFrame(const bool needsPresent)
else
{
if (needsPresent)
g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer();
{
// In case of no acquired backbuffer we have nothing render to.
if (!g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer())
return;
}
if (m_ShouldPreloadResourcesBeforeNextFrame)
{
@ -545,8 +549,8 @@ void CRenderer::RenderScreenShot(const bool needsPresent)
const size_t width = static_cast<size_t>(g_xres), height = static_cast<size_t>(g_yres);
const size_t bpp = 24;
if (needsPresent)
g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer();
if (needsPresent && !g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer())
return;
// Hide log messages and re-render
RenderFrameImpl(true, false);
@ -655,15 +659,14 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
}
g_Game->GetView()->GetCamera()->SetProjection(projection);
if (needsPresent)
g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer();
if (needsPresent && g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer())
{
RenderFrameImpl(false, false);
RenderFrameImpl(false, false);
m->deviceCommandContext->ReadbackFramebufferSync(0, 0, tileWidth, tileHeight, tileData);
m->deviceCommandContext->Flush();
if (needsPresent)
m->deviceCommandContext->ReadbackFramebufferSync(0, 0, tileWidth, tileHeight, tileData);
m->deviceCommandContext->Flush();
g_VideoMode.GetBackendDevice()->Present();
}
// Copy the tile pixels into the main image
for (int y = 0; y < tileHeight; ++y)

View File

@ -100,7 +100,7 @@ public:
virtual std::unique_ptr<IShaderProgram> CreateShaderProgram(
const CStr& name, const CShaderDefines& defines) = 0;
virtual void AcquireNextBackbuffer() = 0;
virtual bool AcquireNextBackbuffer() = 0;
virtual void Present() = 0;
virtual bool IsTextureFormatSupported(const Format format) const = 0;

View File

@ -114,9 +114,10 @@ std::unique_ptr<IShaderProgram> CDevice::CreateShaderProgram(
return CShaderProgram::Create(this);
}
void CDevice::AcquireNextBackbuffer()
bool CDevice::AcquireNextBackbuffer()
{
// We have nothing to acquire.
return true;
}
void CDevice::Present()

View File

@ -77,7 +77,7 @@ public:
std::unique_ptr<IShaderProgram> CreateShaderProgram(
const CStr& name, const CShaderDefines& defines) override;
void AcquireNextBackbuffer() override;
bool AcquireNextBackbuffer() override;
void Present() override;
bool IsTextureFormatSupported(const Format format) const override;

View File

@ -906,10 +906,11 @@ std::unique_ptr<IShaderProgram> CDevice::CreateShaderProgram(
return CShaderProgram::Create(this, name, defines);
}
void CDevice::AcquireNextBackbuffer()
bool CDevice::AcquireNextBackbuffer()
{
ENSURE(!m_BackbufferAcquired);
m_BackbufferAcquired = true;
return true;
}
void CDevice::Present()

View File

@ -94,7 +94,7 @@ public:
std::unique_ptr<IShaderProgram> CreateShaderProgram(
const CStr& name, const CShaderDefines& defines) override;
void AcquireNextBackbuffer() override;
bool AcquireNextBackbuffer() override;
void Present() override;
bool IsTextureFormatSupported(const Format format) const override;

View File

@ -150,8 +150,9 @@ std::unique_ptr<IShaderProgram> CDevice::CreateShaderProgram(
return nullptr;
}
void CDevice::AcquireNextBackbuffer()
bool CDevice::AcquireNextBackbuffer()
{
return false;
}
void CDevice::Present()

View File

@ -82,7 +82,7 @@ public:
std::unique_ptr<IShaderProgram> CreateShaderProgram(
const CStr& name, const CShaderDefines& defines) override;
void AcquireNextBackbuffer() override;
bool AcquireNextBackbuffer() override;
void Present() override;
bool IsTextureFormatSupported(const Format format) const override;

View File

@ -223,7 +223,8 @@ void AtlasViewGame::Update(float realFrameLength)
void AtlasViewGame::Render()
{
g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer();
if (!g_VideoMode.GetBackendDevice()->AcquireNextBackbuffer())
return;
SViewPort vp = { 0, 0, g_xres, g_yres };
CCamera& camera = GetCamera();