mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
FramebufferManagerBase: Return a std::pair from GetTargetSize
Keeps associated data together. It also eliminates the possibility of out parameters not being initialized properly. For example, consider the following example: -- some FramebufferManager implementation -- void FBMgrImpl::GetTargetSize(u32* width, u32* height) override { // Do nothing } -- somewhere else where the function is used -- u32 width, height; framebuffer_manager_instance->GetTargetSize(&width, &height); if (texture_width != width) <-- Uninitialized variable usage { ... } It makes it much more obvious to spot any initialization issues, because it requires something to be returned, as opposed to allowing an implementation to just not do anything.
This commit is contained in:
@ -2,13 +2,15 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "VideoBackends/D3D/FramebufferManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3D/D3DUtil.h"
|
||||
#include "VideoBackends/D3D/FramebufferManager.h"
|
||||
#include "VideoBackends/D3D/GeometryShaderCache.h"
|
||||
#include "VideoBackends/D3D/PixelShaderCache.h"
|
||||
#include "VideoBackends/D3D/Render.h"
|
||||
@ -292,10 +294,9 @@ std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int
|
||||
layers);
|
||||
}
|
||||
|
||||
void FramebufferManager::GetTargetSize(unsigned int* width, unsigned int* height)
|
||||
std::pair<u32, u32> FramebufferManager::GetTargetSize() const
|
||||
{
|
||||
*width = m_target_width;
|
||||
*height = m_target_height;
|
||||
return std::make_pair(m_target_width, m_target_height);
|
||||
}
|
||||
|
||||
void XFBSource::DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/D3D/D3DTexture.h"
|
||||
#include "VideoCommon/FramebufferManagerBase.h"
|
||||
|
||||
@ -84,7 +86,7 @@ private:
|
||||
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
||||
unsigned int target_height,
|
||||
unsigned int layers) override;
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override;
|
||||
std::pair<u32, u32> GetTargetSize() const override;
|
||||
|
||||
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,
|
||||
float Gamma) override;
|
||||
|
@ -3,7 +3,9 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "VideoBackends/D3D12/FramebufferManager.h"
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "VideoBackends/D3D12/D3DBase.h"
|
||||
#include "VideoBackends/D3D12/D3DCommandListManager.h"
|
||||
@ -218,10 +220,9 @@ std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int
|
||||
layers);
|
||||
}
|
||||
|
||||
void FramebufferManager::GetTargetSize(unsigned int* width, unsigned int* height)
|
||||
std::pair<u32, u32> FramebufferManager::GetTargetSize() const
|
||||
{
|
||||
*width = m_target_width;
|
||||
*height = m_target_height;
|
||||
return std::make_pair(m_target_width, m_target_height);
|
||||
}
|
||||
|
||||
void FramebufferManager::ResolveDepthTexture()
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/D3D12/D3DTexture.h"
|
||||
#include "VideoCommon/FramebufferManagerBase.h"
|
||||
@ -86,7 +88,7 @@ private:
|
||||
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
||||
unsigned int target_height,
|
||||
unsigned int layers) override;
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override;
|
||||
std::pair<u32, u32> GetTargetSize() const override;
|
||||
|
||||
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,
|
||||
float gamma) override;
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoCommon/FramebufferManagerBase.h"
|
||||
|
||||
class XFBSource : public XFBSourceBase
|
||||
@ -23,7 +26,7 @@ public:
|
||||
return std::make_unique<XFBSource>();
|
||||
}
|
||||
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override {}
|
||||
std::pair<u32, u32> GetTargetSize() const override { return std::make_pair(0, 0); }
|
||||
void CopyToRealXFB(u32 xfb_addr, u32 fb_stride, u32 fb_height, const EFBRectangle& source_rc,
|
||||
float gamma = 1.0f) override
|
||||
{
|
||||
|
@ -668,10 +668,9 @@ std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int
|
||||
return std::make_unique<XFBSource>(texture, layers);
|
||||
}
|
||||
|
||||
void FramebufferManager::GetTargetSize(unsigned int* width, unsigned int* height)
|
||||
std::pair<u32, u32> FramebufferManager::GetTargetSize() const
|
||||
{
|
||||
*width = m_targetWidth;
|
||||
*height = m_targetHeight;
|
||||
return std::make_pair(m_targetWidth, m_targetHeight);
|
||||
}
|
||||
|
||||
void FramebufferManager::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points)
|
||||
|
@ -5,8 +5,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/GL/GLUtil.h"
|
||||
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
||||
#include "VideoBackends/OGL/Render.h"
|
||||
@ -103,7 +105,7 @@ private:
|
||||
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
||||
unsigned int target_height,
|
||||
unsigned int layers) override;
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override;
|
||||
std::pair<u32, u32> GetTargetSize() const override;
|
||||
|
||||
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,
|
||||
float Gamma) override;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
@ -101,7 +102,8 @@ class FramebufferManager : public FramebufferManagerBase
|
||||
{
|
||||
return std::make_unique<XFBSource>();
|
||||
}
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override{};
|
||||
|
||||
std::pair<u32, u32> GetTargetSize() const override { return std::make_pair(0, 0); }
|
||||
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,
|
||||
float Gamma = 1.0f) override
|
||||
{
|
||||
|
@ -115,10 +115,9 @@ bool FramebufferManager::Initialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void FramebufferManager::GetTargetSize(unsigned int* width, unsigned int* height)
|
||||
std::pair<u32, u32> FramebufferManager::GetTargetSize() const
|
||||
{
|
||||
*width = m_efb_width;
|
||||
*height = m_efb_height;
|
||||
return std::make_pair(m_efb_width, m_efb_height);
|
||||
}
|
||||
|
||||
bool FramebufferManager::CreateEFBRenderPass()
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/Vulkan/Constants.h"
|
||||
@ -39,7 +40,7 @@ public:
|
||||
Texture2D* GetEFBColorTexture() const { return m_efb_color_texture.get(); }
|
||||
Texture2D* GetEFBDepthTexture() const { return m_efb_depth_texture.get(); }
|
||||
VkFramebuffer GetEFBFramebuffer() const { return m_efb_framebuffer; }
|
||||
void GetTargetSize(unsigned int* width, unsigned int* height) override;
|
||||
std::pair<u32, u32> GetTargetSize() const override;
|
||||
|
||||
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
||||
unsigned int target_height,
|
||||
|
Reference in New Issue
Block a user