1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

FrameBufferInfo API extension. Initial dummy implementation.

This commit is contained in:
Sergey Lipskiy 2015-11-23 18:36:03 +06:00
parent 5d8ea5dda1
commit b9ee15bfb6
13 changed files with 237 additions and 0 deletions

View File

@ -224,6 +224,7 @@
<ClCompile Include="..\..\src\F3DEX2CBFD.cpp" />
<ClCompile Include="..\..\src\F3DSWSE.cpp" />
<ClCompile Include="..\..\src\FrameBuffer.cpp" />
<ClCompile Include="..\..\src\FrameBufferInfo.cpp" />
<ClCompile Include="..\..\src\GBI.cpp" />
<ClCompile Include="..\..\src\gDP.cpp" />
<ClCompile Include="..\..\src\GLideN64.cpp" />
@ -311,6 +312,8 @@
<ClInclude Include="..\..\src\F3DEX2CBFD.h" />
<ClInclude Include="..\..\src\F3DSWSE.h" />
<ClInclude Include="..\..\src\FrameBuffer.h" />
<ClInclude Include="..\..\src\FrameBufferInfo.h" />
<ClInclude Include="..\..\src\FrameBufferInfoAPI.h" />
<ClInclude Include="..\..\src\GBI.h" />
<ClInclude Include="..\..\src\gDP.h" />
<ClInclude Include="..\..\src\glext.h" />

View File

@ -194,6 +194,9 @@
<ClCompile Include="..\..\src\OGL3X\GLSLCombiner_ogl3x.cpp">
<Filter>Source Files\OGL3X</Filter>
</ClCompile>
<ClCompile Include="..\..\src\FrameBufferInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\3DMath.h">
@ -349,5 +352,11 @@
<ClInclude Include="..\..\src\wst.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\FrameBufferInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\FrameBufferInfoAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -22,6 +22,7 @@ set(GLideN64_SOURCES
F3DEX2.cpp
F3DEX2CBFD.cpp
FrameBuffer.cpp
FrameBufferInfo.cpp
GBI.cpp
gDP.cpp
GLideN64.cpp

View File

@ -58,4 +58,24 @@ EXPORT void CALL ChangeWindow(void)
api().ChangeWindow();
}
EXPORT void CALL FBWrite(unsigned int addr, unsigned int size)
{
api().FBWrite(addr, size);
}
EXPORT void CALL FBWList(FrameBufferModifyEntry *plist, unsigned int size)
{
api().FBWList(plist, size);
}
EXPORT void CALL FBRead(unsigned int addr)
{
api().FBRead(addr);
}
EXPORT void CALL FBGetFrameBufferInfo(void *pinfo)
{
api().FBGetFrameBufferInfo(pinfo);
}
}

View File

@ -4,6 +4,7 @@
#include "Types.h"
#include "Textures.h"
struct FrameBuffer;
struct DepthBuffer
{
DepthBuffer();

View File

@ -15,6 +15,7 @@
#include "Config.h"
#include "Debug.h"
#include "PostProcessor.h"
#include "FrameBufferInfo.h"
using namespace std;
@ -629,6 +630,21 @@ void FrameBufferList::removeBuffers(u32 _width)
}
}
void FrameBufferList::fillBufferInfo(FrameBufferInfo * _pinfo, u32 _size)
{
u32 idx = 0;
for (FrameBuffers::iterator iter = m_list.begin(); iter != m_list.end(); ++iter) {
if (iter->m_width == VI.width && !iter->m_cfb) {
_pinfo[idx].addr = iter->m_startAddress;
_pinfo[idx].width = iter->m_width;
_pinfo[idx].height = iter->m_height;
_pinfo[idx++].size = iter->m_size;
if (idx >= _size)
return;
}
}
}
void FrameBufferList::attachDepthBuffer()
{
if (m_pCurrent == NULL)
@ -880,6 +896,8 @@ void FrameBufferList::renderBuffer(u32 _address)
}
#endif
void FrameBuffer_ActivateBufferTexture(s16 t, FrameBuffer *pBuffer)
{
if (pBuffer == NULL || pBuffer->m_pTexture == NULL)

View File

@ -10,6 +10,7 @@ struct gDPTile;
struct DepthBuffer;
const int fingerprint[4] = { 2, 6, 4, 3 };
struct FrameBufferInfo;
struct FrameBuffer
{
@ -76,6 +77,8 @@ public:
FrameBuffer * getCopyBuffer() const { return m_pCopy; }
void setCopyBuffer(FrameBuffer * _pBuffer) { m_pCopy = _pBuffer; }
void fillBufferInfo(FrameBufferInfo * _pinfo, u32 _size);
static FrameBufferList & get();
private:

39
src/FrameBufferInfo.cpp Normal file
View File

@ -0,0 +1,39 @@
#include "FrameBufferInfoAPI.h"
#include "FrameBufferInfo.h"
#include "OpenGL.h"
#include "FrameBuffer.h"
#include "DepthBuffer.h"
#include "VI.h"
#include "Log.h"
void FrameBufferWrite(u32 addr, u32 size)
{
debugPrint("FBWrite addr=%08lx size=%u\n", addr, size);
}
void FrameBufferWriteList(FrameBufferModifyEntry *plist, u32 size)
{
debugPrint("FBWList size=%u\n", size);
for (u32 i = 0; i < size; ++i)
debugPrint(" plist[%u] addr=%08lx val=%08lx size=%u\n", i, plist[i].addr, plist[i].val, plist[i].size);
}
void FrameBufferRead(u32 addr)
{
debugPrint("FBRead addr=%08lx \n", addr);
}
void FrameBufferGetInfo(void *pinfo)
{
FrameBufferInfo * pFBInfo = (FrameBufferInfo*)pinfo;
memset(pFBInfo, 0, sizeof(FrameBufferInfo)* 6);
u32 idx = 0;
DepthBuffer * pDepthBuffer = depthBufferList().getCurrent();
if (pDepthBuffer != nullptr) {
pFBInfo[idx].addr = pDepthBuffer->m_address;
pFBInfo[idx].width = pDepthBuffer->m_width;
pFBInfo[idx].height = VI.real_height;
pFBInfo[idx++].size = 2;
}
frameBufferList().fillBufferInfo(&pFBInfo[idx], 6 - idx);
}

29
src/FrameBufferInfo.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef _FRAME_BUFFER_INFO_H_
#define _FRAME_BUFFER_INFO_H_
#ifdef OS_WINDOWS
# include <windows.h>
#else
# include "winlnxdefs.h"
#endif // OS_WINDOWS
#include "Types.h"
#include "PluginAPI.h"
struct FrameBufferInfo
{
unsigned int addr;
unsigned int size;
unsigned int width;
unsigned int height;
};
void FrameBufferWrite(u32 addr, u32 size);
void FrameBufferWriteList(FrameBufferModifyEntry *plist, u32 size);
void FrameBufferRead(u32 addr);
void FrameBufferGetInfo(void *pinfo);
#endif // _FRAME_BUFFER_INFO_H_

84
src/FrameBufferInfoAPI.h Normal file
View File

@ -0,0 +1,84 @@
#ifndef _FRAME_BUFFER_INFO_API_H_
#define _FRAME_BUFFER_INFO_API_H_
#if defined(__cplusplus)
extern "C" {
#endif
#ifdef OS_WINDOWS
#define EXPORT __declspec(dllexport)
#define CALL __cdecl
#else
#define EXPORT __attribute__((visibility("default")))
#define CALL _cdecl
#endif
/******************************************************************
Function: FrameBufferWrite
Purpose: This function is called to notify the dll that the
frame buffer has been modified by CPU at the given address.
input: addr rdram address
size 1 = unsigned char, 2 = unsigned short, 4=unsigned int
output: none
*******************************************************************/
EXPORT void CALL FBWrite(unsigned int addr, unsigned int size);
typedef struct
{
unsigned int addr;
unsigned int val;
unsigned int size;
} FrameBufferModifyEntry;
/******************************************************************
Function: FrameBufferWriteList
Purpose: This function is called to notify the dll that the
frame buffer has been modified by CPU at the given address.
input: FrameBufferModifyEntry *plist
size = size of the plist, max = 1024
output: none
*******************************************************************/
EXPORT void CALL FBWList(FrameBufferModifyEntry *plist, unsigned int size);
/******************************************************************
Function: FrameBufferRead
Purpose: This function is called to notify the dll that the
frame buffer memory is beening read at the given address.
DLL should copy content from its render buffer to the frame buffer
in N64 RDRAM
DLL is responsible to maintain its own frame buffer memory addr list
DLL should copy 4KB block content back to RDRAM frame buffer.
Emulator should not call this function again if other memory
is read within the same 4KB range
input: addr rdram address
output: none
*******************************************************************/
EXPORT void CALL FBRead(unsigned int addr);
/************************************************************************
Function: FBGetFrameBufferInfo
Purpose: This function is called by the emulator core to retrieve depth
buffer information from the video plugin in order to be able
to notify the video plugin about CPU depth buffer read/write
operations
size:
= 1 byte
= 2 word (16 bit) <-- this is N64 default depth buffer format
= 4 dword (32 bit)
when depth buffer information is not available yet, set all values
in the FrameBufferInfo structure to 0
input: FrameBufferInfo *pinfo
pinfo is pointed to a FrameBufferInfo structure which to be
filled in by this function
output: Values are return in the FrameBufferInfo structure
************************************************************************/
EXPORT void CALL FBGetFrameBufferInfo(void *pinfo);
#if defined(__cplusplus)
}
#endif
#endif // _FRAME_BUFFER_INFO_API_H_

View File

@ -54,6 +54,8 @@ inline void debugPrint(const char * format, ...) {
OutputDebugString(wtext);
va_end(va);
}
#else
#define debugPrint(A, ...)
#endif
#endif

View File

@ -10,6 +10,7 @@
#include "ZilmarGFX_1_3.h"
#define RSPTHREAD
#endif
#include "FrameBufferInfoAPI.h"
enum API_COMMAND {
acNone = 0,
@ -48,6 +49,12 @@ public:
void GetUserDataPath(wchar_t * _strPath);
void GetUserCachePath(wchar_t * _strPath);
// FrameBufferInfo extension
void FBWrite(unsigned int addr, unsigned int size);
void FBWList(FrameBufferModifyEntry *plist, unsigned int size);
void FBRead(unsigned int addr);
void FBGetFrameBufferInfo(void *pinfo);
#ifndef MUPENPLUSAPI
// Zilmar
void DllTest(HWND /*_hParent*/) {}

View File

@ -15,6 +15,7 @@
#include "../VI.h"
#include "../Config.h"
#include "../Debug.h"
#include "../FrameBufferInfo.h"
#include "../Log.h"
PluginAPI & PluginAPI::get()
@ -188,3 +189,23 @@ void PluginAPI::ChangeWindow()
{
video().setToggleFullscreen();
}
void PluginAPI::FBWrite(unsigned int addr, unsigned int size)
{
FrameBufferWrite(addr, size);
}
void PluginAPI::FBWList(FrameBufferModifyEntry *plist, unsigned int size)
{
FrameBufferWriteList(plist, size);
}
void PluginAPI::FBRead(unsigned int addr)
{
FrameBufferRead(addr);
}
void PluginAPI::FBGetFrameBufferInfo(void *pinfo)
{
FrameBufferGetInfo(pinfo);
}