Path: blob/master/libmupen64plus/mupen64plus-video-rice/src/FrameBuffer.h
2 views
/*1Copyright (C) 2002 Rice196423This program is free software; you can redistribute it and/or4modify it under the terms of the GNU General Public License5as published by the Free Software Foundation; either version 26of the License, or (at your option) any later version.78This program is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.1213You should have received a copy of the GNU General Public License14along with this program; if not, write to the Free Software15Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.1617*/1819#ifndef _FRAME_BUFFER_H_20#define _FRAME_BUFFER_H_2122#include "typedefs.h"23#include "RenderTexture.h"24#include "TextureManager.h"2526typedef int SURFFORMAT;2728extern void TexRectToN64FrameBuffer_16b(uint32 x0, uint32 y0, uint32 width, uint32 height, uint32 dwTile);29extern void TexRectToFrameBuffer_8b(uint32 dwXL, uint32 dwYL, uint32 dwXH, uint32 dwYH, float t0u0, float t0v0, float t0u1, float t0v1, uint32 dwTile);3031class FrameBufferManager32{33friend class CGraphicsContext;34friend class CDXGraphicsContext;35public:36FrameBufferManager();37virtual ~FrameBufferManager();3839void Initialize();40void CloseUp();41void Set_CI_addr(SetImgInfo &newCI);42void UpdateRecentCIAddr(SetImgInfo &ciinfo);43void SetAddrBeDisplayed(uint32 addr);44bool HasAddrBeenDisplayed(uint32 addr, uint32 width);45int FindRecentCIInfoIndex(uint32 addr);46bool IsDIaRenderTexture();4748int CheckAddrInRenderTextures(uint32 addr, bool checkcrc = true);49uint32 ComputeRenderTextureCRCInRDRAM(int infoIdx);50void CheckRenderTextureCRCInRDRAM(void);51int CheckRenderTexturesWithNewCI(SetImgInfo &CIinfo, uint32 height, bool byNewTxtrBuf);52virtual void ClearN64FrameBufferToBlack(uint32 left=0, uint32 top=0, uint32 width=0, uint32 height=0);53virtual int SetBackBufferAsRenderTexture(SetImgInfo &CIinfo, int ciInfoIdx);54void LoadTextureFromRenderTexture(TxtrCacheEntry* pEntry, int infoIdx);55void UpdateFrameBufferBeforeUpdateFrame();56virtual void RestoreNormalBackBuffer(); // restore the normal back buffer57virtual void CopyBackToFrameBufferIfReadByCPU(uint32 addr);58virtual void SetRenderTexture(void);59virtual void CloseRenderTexture(bool toSave);60virtual void ActiveTextureBuffer(void);6162int IsAddrInRecentFrameBuffers(uint32 addr);63int CheckAddrInBackBuffers(uint32 addr, uint32 memsize, bool copyToRDRAM = false);6465uint8 CIFindIndex(uint16 val);66uint32 ComputeCImgHeight(SetImgInfo &info, uint32 &height);6768int FindASlot(void);6970bool ProcessFrameWriteRecord();71void FrameBufferWriteByCPU(uint32 addr, uint32 size);72void FrameBufferReadByCPU( uint32 addr );73bool FrameBufferInRDRAMCheckCRC();74void StoreRenderTextureToRDRAM(int infoIdx = -1);7576virtual bool IsRenderingToTexture() {return m_isRenderingToTexture;}7778// Device dependent functions79virtual void SaveBackBuffer(int ciInfoIdx, RECT* pRect=NULL, bool forceToSaveToRDRAM = false); // Copy the current back buffer to temp buffer80virtual void CopyBackBufferToRenderTexture(int idx, RecentCIInfo &ciInfo, RECT* pRect=NULL) {} // Copy the current back buffer to temp buffer81virtual void CopyBufferToRDRAM(uint32 addr, uint32 fmt, uint32 siz, uint32 width,82uint32 height, uint32 bufWidth, uint32 bufHeight, uint32 startaddr,83uint32 memsize, uint32 pitch, TextureFmt bufFmt, void *surf, uint32 bufPitch);84virtual void StoreBackBufferToRDRAM(uint32 addr, uint32 fmt, uint32 siz, uint32 width,85uint32 height, uint32 bufWidth, uint32 bufHeight, uint32 startaddr=0xFFFFFFFF,86uint32 memsize=0xFFFFFFFF, uint32 pitch=0, SURFFORMAT surf_fmt=SURFFMT_A8R8G8B8) {}87#ifdef DEBUGGER88virtual void DisplayRenderTexture(int infoIdx = -1);89#endif9091protected:92bool m_isRenderingToTexture;93int m_curRenderTextureIndex;94int m_lastTextureBufferIndex;95};9697class DXFrameBufferManager : public FrameBufferManager98{99virtual ~DXFrameBufferManager() {}100101public:102// Device dependent functions103virtual void CopyBackBufferToRenderTexture(int idx, RecentCIInfo &ciInfo, RECT* pRect=NULL); // Copy the current back buffer to temp buffer104virtual void StoreBackBufferToRDRAM(uint32 addr, uint32 fmt, uint32 siz, uint32 width,105uint32 height, uint32 bufWidth, uint32 bufHeight, uint32 startaddr=0xFFFFFFFF,106uint32 memsize=0xFFFFFFFF, uint32 pitch=0, SURFFORMAT surf_fmt=SURFFMT_A8R8G8B8);107};108109class OGLFrameBufferManager : public FrameBufferManager110{111virtual ~OGLFrameBufferManager() {}112113public:114// Device dependent functions115virtual void CopyBackBufferToRenderTexture(int idx, RecentCIInfo &ciInfo, RECT* pRect=NULL); // Copy the current back buffer to temp buffer116virtual void StoreBackBufferToRDRAM(uint32 addr, uint32 fmt, uint32 siz, uint32 width,117uint32 height, uint32 bufWidth, uint32 bufHeight, uint32 startaddr=0xFFFFFFFF,118uint32 memsize=0xFFFFFFFF, uint32 pitch=0, SURFFORMAT surf_fmt=SURFFMT_A8R8G8B8);119};120121extern RenderTextureInfo gRenderTextureInfos[];122extern RenderTextureInfo newRenderTextureInfo;123124#define NEW_TEXTURE_BUFFER125126extern RenderTextureInfo g_ZI_saves[2];127extern RenderTextureInfo *g_pRenderTextureInfo;128129130extern FrameBufferManager* g_pFrameBufferManager;131132extern RecentCIInfo g_RecentCIInfo[];133extern RecentViOriginInfo g_RecentVIOriginInfo[];134extern RenderTextureInfo gRenderTextureInfos[];135extern int numOfTxtBufInfos;136extern RecentCIInfo *g_uRecentCIInfoPtrs[5];137extern uint8 RevTlutTable[0x10000];138139extern uint32 CalculateRDRAMCRC(void *pAddr, uint32 left, uint32 top, uint32 width, uint32 height, uint32 size, uint32 pitchInBytes );140extern uint16 ConvertRGBATo555(uint8 r, uint8 g, uint8 b, uint8 a);141extern uint16 ConvertRGBATo555(uint32 color32);142extern void InitTlutReverseLookup(void);143144#endif145146147148