Move some code out of the plugins into VideoCommon. No functional change.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@255 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-08-21 17:49:06 +00:00
parent 5e4da92d42
commit 3ef0eb979d
17 changed files with 52 additions and 297 deletions

View File

@ -542,6 +542,10 @@
RelativePath=".\src\RegisterWindow.h"
>
</File>
<File
RelativePath=".\src\SConscript"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -13,6 +13,7 @@ files = ["LogWindow.cpp",
"MemoryWindow.cpp",
"RegisterWindow.cpp",
"RegisterView.cpp",
"JitWindow.cpp",
]
wxenv = env.Copy(CXXFLAGS = "`wx-config --cppflags` -DUSE_XPM_BITMAPS -DwxNEEDS_CHARPP",
LINKFLAGS = "-L/usr/local/lib -pthread `wx-config --libs --debug`")

View File

@ -17,11 +17,12 @@
#include <string.h>
#include "Globals.h"
#include "MemoryUtil.h"
#include "Fifo.h"
#include "Thread.h"
#include "OpcodeDecoding.h"
#include "pluginspecs_video.h"
#include "Fifo.h"
#define FIFO_SIZE (1024*1024)
@ -98,11 +99,9 @@ void Video_SendFifoData(BYTE *_uData)
{
if (FAKE_GetFifoSize() > readptr)
{
SysMessage("out of bounds");
exit(1);
PanicAlert("FIFO out of bounds (sz = %i, at %08x)", FAKE_GetFifoSize(), readptr);
}
DebugLog("FAKE BUFFER LOOPS");
// DebugLog("FAKE BUFFER LOOPS");
memmove(&videoBuffer[0], &videoBuffer[readptr], FAKE_GetFifoSize());
// memset(&videoBuffer[FAKE_GetFifoSize()], 0, FIFO_SIZE - FAKE_GetFifoSize());
size = FAKE_GetFifoSize();
@ -114,12 +113,12 @@ void Video_SendFifoData(BYTE *_uData)
//TODO - turn inside out, have the "reader" ask for bytes instead
// See Core.cpp for threading idea
void Video_EnterLoop()
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
{
SCPFifoStruct &fifo = *g_VideoInitialize.pCPFifo;
SCPFifoStruct &fifo = *video_initialize.pCPFifo;
// TODO(ector): Don't peek so often!
while (g_VideoInitialize.pPeekMessages())
while (video_initialize.pPeekMessages())
{
if (fifo.CPReadWriteDistance < 1) //fifo.CPLoWatermark)
Common::SleepCurrentThread(1);
@ -137,14 +136,13 @@ void Video_EnterLoop()
if (fifo.CPReadPointer == fifo.CPBreakpoint)
{
fifo.bFF_Breakpoint = 1;
g_VideoInitialize.pUpdateInterrupts();
video_initialize.pUpdateInterrupts();
break;
}
}
// read the data and send it to the VideoPlugin
u8 *uData = Memory_GetPtr(fifo.CPReadPointer);
u8 *uData = video_initialize.pGetMemoryPointer(fifo.CPReadPointer);
#ifdef _WIN32
EnterCriticalSection(&fifo.sync);
#endif

View File

@ -52,6 +52,7 @@ extern FifoReader fifo;
void Fifo_Init();
void Fifo_Shutdown();
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);
#endif

View File

@ -6,6 +6,7 @@ files = ["BPMemory.cpp",
"TextureDecoder.cpp",
"XFMemory.cpp",
"XFBConvert.cpp",
"Fifo.cpp",
]
env_common = env.Copy(CXXFLAGS = " -fPIC ")

View File

@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -106,7 +106,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -168,7 +168,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@ -229,7 +229,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@ -289,7 +289,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@ -350,7 +350,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../Core/Common/Src;"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@ -405,6 +405,14 @@
RelativePath=".\Src\CPMemory.h"
>
</File>
<File
RelativePath=".\Src\Fifo.cpp"
>
</File>
<File
RelativePath=".\Src\Fifo.h"
>
</File>
<File
RelativePath=".\Src\LookUpTables.cpp"
>
@ -413,6 +421,10 @@
RelativePath=".\Src\LookUpTables.h"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.h"
>
</File>
<File
RelativePath=".\Src\SConscript"
>

View File

@ -1270,10 +1270,6 @@
RelativePath=".\Src\OpcodeDecoding.cpp"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.h"
>
</File>
<File
RelativePath=".\Src\VertexHandler.cpp"
>
@ -1451,14 +1447,6 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\Fifo.cpp"
>
</File>
<File
RelativePath=".\Src\Fifo.h"
>
</File>
<File
RelativePath=".\Src\Globals.cpp"
>

View File

@ -1,171 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <stdio.h>
#include <stdlib.h>
#include "Common.h"
#include "Utils.h"
#include "Fifo.h"
#include "main.h"
#include "OpcodeDecoding.h"
#define FIFO_SIZE (1024*1024)
FifoReader fifo;
static u8 *videoBuffer;
int size = 0;
int readptr = 0;
void Fifo_Init()
{
//VirtualFree((LPVOID)buffer,CMDBUFFER_SIZE,MEM_RELEASE);
videoBuffer = (u8*)VirtualAlloc(0, FIFO_SIZE, MEM_COMMIT, PAGE_READWRITE);
fifo.Init(videoBuffer, videoBuffer); //zero length. there is no data yet.
}
void Fifo_Shutdown()
{
VirtualFree(videoBuffer, FIFO_SIZE, MEM_RELEASE);
}
int FAKE_GetFifoSize()
{
if (size < readptr)
{
PanicAlert("GFX Fifo underrun encountered (size = %i, readptr = %i)", size, readptr);
}
return (size - readptr);
}
u8 FAKE_PeekFifo8(u32 _uOffset)
{
return videoBuffer[readptr + _uOffset];
}
u16 FAKE_PeekFifo16(u32 _uOffset)
{
return _byteswap_ushort(*(u16*)&videoBuffer[readptr + _uOffset]);
}
u32 FAKE_PeekFifo32(u32 _uOffset)
{
return _byteswap_ulong(*(u32*)&videoBuffer[readptr + _uOffset]);
}
u8 FAKE_ReadFifo8()
{
return videoBuffer[readptr++];
}
u16 FAKE_ReadFifo16()
{
u16 val = _byteswap_ushort(*(u16*)(videoBuffer+readptr));
readptr += 2;
return val;
}
u32 FAKE_ReadFifo32()
{
u32 val = _byteswap_ulong(*(u32*)(videoBuffer+readptr));
readptr += 4;
return val;
}
void FAKE_SkipFifo(u32 skip)
{
readptr += skip;
}
void Video_SendFifoData(BYTE *_uData)
{
memcpy(videoBuffer + size, _uData, 32);
size += 32;
if (size + 32 >= FIFO_SIZE)
{
if (FAKE_GetFifoSize() > readptr)
{
PanicAlert("FIFO out of bounds", "video-plugin", MB_OK);
exit(1);
}
DebugLog("FAKE BUFFER LOOPS");
memmove(&videoBuffer[0], &videoBuffer[readptr], FAKE_GetFifoSize());
// memset(&videoBuffer[FAKE_GetFifoSize()], 0, FIFO_SIZE - FAKE_GetFifoSize());
size = FAKE_GetFifoSize();
readptr = 0;
}
OpcodeDecoder_Run();
}
//TODO - turn inside out, have the "reader" ask for bytes instead
// See Core.cpp for threading idea
void Video_EnterLoop()
{
SCPFifoStruct &fifo = *g_VideoInitialize.pCPFifo;
// TODO(ector): Don't peek so often!
while (g_VideoInitialize.pPeekMessages())
{
if (fifo.CPReadWriteDistance < 1) //fifo.CPLoWatermark)
Sleep(1);
//etc...
// check if we are able to run this buffer
if ((fifo.bFF_GPReadEnable) && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint))
{
int count = 200;
while(fifo.CPReadWriteDistance > 0 && count)
{
// check if we are on a breakpoint
if (fifo.bFF_BPEnable)
{
//MessageBox(0,"Breakpoint enabled",0,0);
if (fifo.CPReadPointer == fifo.CPBreakpoint)
{
fifo.bFF_Breakpoint = 1;
g_VideoInitialize.pUpdateInterrupts();
break;
}
}
// read the data and send it to the VideoPlugin
u8 *uData = Memory_GetPtr(fifo.CPReadPointer);
EnterCriticalSection(&fifo.sync);
fifo.CPReadPointer += 32;
Video_SendFifoData(uData);
InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, -32);
LeaveCriticalSection(&fifo.sync);
// increase the ReadPtr
if (fifo.CPReadPointer >= fifo.CPEnd)
{
fifo.CPReadPointer = fifo.CPBase;
//LOG(COMMANDPROCESSOR, "BUFFER LOOP");
// MessageBox(NULL, "loop", "now", MB_OK);
}
count--;
}
}
}
}

View File

@ -1,40 +0,0 @@
#ifndef _FIFO_H
#define _FIFO_H
#include "Common.h"
// inline for speed!
class FifoReader
{
u8 *ptr;
u8 *end;
u8 *tempPtr; //single element stack :P
u8 *tempEnd;
bool pushed;
public:
void Init(u8 *_ptr, u8 *_end)
{
ptr = _ptr; end = _end; pushed = false;
}
bool IsPushed() {return pushed;}
void Push(u8 *_ptr, u8 *_end) {pushed = true; tempPtr = ptr; tempEnd = end; ptr = _ptr; end = _end;}
void Pop() {pushed = false; ptr = tempPtr; end = tempEnd;}
u8 Peek8 (int offset) { return ptr[offset]; }
u16 Peek16(int offset) { return _byteswap_ushort(*(u16*)(ptr+offset)); }
u32 Peek32(int offset) { return _byteswap_ulong(*(u32*)(ptr+offset)); }
u8 Read8 () {return *ptr++;}
u16 Read16() {const u16 value = _byteswap_ushort(*((u16*)ptr)); ptr+=2; return value;}
u32 Read32() {const u32 value = _byteswap_ulong(*((u32*)ptr)); ptr+=4; return value;}
float Read32F() {const u32 value = _byteswap_ulong(*((u32*)ptr)); ptr+=4; return *(float*)&value;}
size_t GetRemainSize() const { return (int)(end - ptr); }
u8 *GetPtr() const { return ptr; }
void MoveEndForward() { end += 32; }
u8 *GetEnd() const { return end; }
};
extern FifoReader fifo;
void Fifo_Init();
void Fifo_Shutdown();
#endif

View File

@ -15,7 +15,7 @@ void Config::Load()
iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0);
iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0);
iniFile.Get("Hardware", "RenderInMainframe", &renderToMainframe, true);
iniFile.Get("Hardware", "RenderInMainframe", &renderToMainframe, false);
iniFile.Get("Hardware", "VSync", &bVsync, 0);
if (iAdapter == -1)
iAdapter = 0;

View File

@ -1,37 +0,0 @@
#ifndef _OPCODE_DECODING_H
#define _OPCODE_DECODING_H
#include "PluginSpecs_Video.h"
#include "Common.h"
#define GX_NOP 0x00
#define GX_LOAD_BP_REG 0x61
#define GX_LOAD_CP_REG 0x08
#define GX_LOAD_XF_REG 0x10
#define GX_LOAD_INDX_A 0x20
#define GX_LOAD_INDX_B 0x28
#define GX_LOAD_INDX_C 0x30
#define GX_LOAD_INDX_D 0x38
#define GX_CMD_CALL_DL 0x40
#define GX_CMD_INVL_VC 0x48
#define GX_PRIMITIVE_MASK 0x78
#define GX_PRIMITIVE_SHIFT 3
#define GX_VAT_MASK 0x07
//these are defined 1/8th of their real values and without their top bit
#define GX_DRAW_QUADS 0x0 //0x80
#define GX_DRAW_TRIANGLES 0x2 //0x90
#define GX_DRAW_TRIANGLE_STRIP 0x3 //0x98
#define GX_DRAW_TRIANGLE_FAN 0x4 //0xA0
#define GX_DRAW_LINES 0x5 //0xA8
#define GX_DRAW_LINE_STRIP 0x6 //0xB0
#define GX_DRAW_POINTS 0x7 //0xB8
void OpcodeDecoder_Init();
void OpcodeDecoder_Shutdown();
void OpcodeDecoder_Run();
#endif

View File

@ -165,6 +165,11 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
}
void Video_EnterLoop()
{
Fifo_EnterLoop(g_VideoInitialize);
}
void Video_Prepare(void)
{
Renderer::Init(g_VideoInitialize);

View File

@ -737,10 +737,6 @@
RelativePath=".\Src\OpcodeDecoding.cpp"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.h"
>
</File>
<File
RelativePath=".\Src\VertexLoader.cpp"
>
@ -906,14 +902,6 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\Fifo.cpp"
>
</File>
<File
RelativePath=".\Src\Fifo.h"
>
</File>
<File
RelativePath=".\Src\GLInit.cpp"
>

View File

@ -144,11 +144,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
nBackbufferWidth = _twidth;
nBackbufferHeight = _theight;
float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)480 / (float)nBackbufferHeight;
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
MValue = 1 / Max;
MValue = 1.0f / Max;
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
@ -211,8 +211,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW;
}
RECT rc;

View File

@ -3,7 +3,6 @@ import sys
files = ["BPStructs.cpp",
"DataReader.cpp",
"Fifo.cpp",
"Globals.cpp",
"GLInit.cpp",
"main.cpp",

View File

@ -198,6 +198,12 @@ void Video_Shutdown(void)
}
void Video_EnterLoop()
{
Fifo_EnterLoop(g_VideoInitialize);
}
void DebugLog(const char* _fmt, ...)
{
#ifdef _DEBUG