diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-12-31 19:18:30 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-12-31 19:18:30 -0600 |
| commit | 1118226f270d2b44d10dd3cebd9f89fd38042680 (patch) | |
| tree | 9dd80995633c70581443d40f58d6ac35837e0bd4 /Source/Core/VideoCommon/FramebufferManagerBase.h | |
| parent | 8d8b0fc884367bc4d433d698a790ef5badee6957 (diff) | |
| parent | 16824d5fd17b43b156706bf02a8063b389604766 (diff) | |
Merge branch 'master' into buffer_storage
Diffstat (limited to 'Source/Core/VideoCommon/FramebufferManagerBase.h')
| -rw-r--r-- | Source/Core/VideoCommon/FramebufferManagerBase.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.h b/Source/Core/VideoCommon/FramebufferManagerBase.h new file mode 100644 index 0000000000..2680f0ced4 --- /dev/null +++ b/Source/Core/VideoCommon/FramebufferManagerBase.h @@ -0,0 +1,102 @@ + +#ifndef _FRAMEBUFFERMANAGERBASE_H +#define _FRAMEBUFFERMANAGERBASE_H + +#include <list> + +#include "VideoCommon.h" + +inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper) +{ + return !((aLower >= bUpper) || (bLower >= aUpper)); +} + +struct XFBSourceBase +{ + virtual ~XFBSourceBase() {} + + virtual void Draw(const MathUtil::Rectangle<float> &sourcerc, + const MathUtil::Rectangle<float> &drawrc) const = 0; + + virtual void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) = 0; + + virtual void CopyEFB(float Gamma) = 0; + + u32 srcAddr; + u32 srcWidth; + u32 srcHeight; + + unsigned int texWidth; + unsigned int texHeight; + + // TODO: only used by OGL + TargetRectangle sourceRc; +}; + +class FramebufferManagerBase +{ +public: + enum + { + // There may be multiple XFBs in GameCube RAM. This is the maximum number to + // virtualize. + MAX_VIRTUAL_XFB = 8 + }; + + FramebufferManagerBase(); + virtual ~FramebufferManagerBase(); + + static void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma); + static const XFBSourceBase* const* GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); + + static void SetLastXfbWidth(unsigned int width) { s_last_xfb_width = width; } + static void SetLastXfbHeight(unsigned int height) { s_last_xfb_height = height; } + static unsigned int LastXfbWidth() { return s_last_xfb_width; } + static unsigned int LastXfbHeight() { return s_last_xfb_height; } + + static int ScaleToVirtualXfbWidth(int x, unsigned int backbuffer_width); + static int ScaleToVirtualXfbHeight(int y, unsigned int backbuffer_height); + +protected: + struct VirtualXFB + { + VirtualXFB() : xfbSource(NULL) {} + + // Address and size in GameCube RAM + u32 xfbAddr; + u32 xfbWidth; + u32 xfbHeight; + + XFBSourceBase *xfbSource; + }; + + typedef std::list<VirtualXFB> VirtualXFBListType; + +private: + virtual XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height) = 0; + // TODO: figure out why OGL is different for this guy + virtual void GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc) = 0; + + static VirtualXFBListType::iterator FindVirtualXFB(u32 xfbAddr, u32 width, u32 height); + + static void ReplaceVirtualXFB(); + + // TODO: merge these virtual funcs, they are nearly all the same + virtual void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f) = 0; + static void CopyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f); + + static const XFBSourceBase* const* GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); + static const XFBSourceBase* const* GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); + + static XFBSourceBase *m_realXFBSource; // Only used in Real XFB mode + static VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode + + static const XFBSourceBase* m_overlappingXFBArray[MAX_VIRTUAL_XFB]; + + static unsigned int s_last_xfb_width; + static unsigned int s_last_xfb_height; +}; + +extern FramebufferManagerBase *g_framebuffer_manager; + +#endif |
