Fix the video software backend. (closes issue 4269)

Some warning fixes and cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7361 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s 2011-03-16 22:48:17 +00:00
parent bca4f94b47
commit 571013acd8
32 changed files with 213 additions and 629 deletions

View File

@ -23,9 +23,8 @@
#include "../../../Plugins/Plugin_VideoDX11/Src/VideoBackend.h"
#endif
#include "../../../Plugins/Plugin_VideoOGL/Src/VideoBackend.h"
#ifndef _WIN32
#include "../../../Plugins/Plugin_VideoSoftware/Src/VideoBackend.h"
#endif
std::vector<VideoBackend*> g_available_video_backends;
VideoBackend* g_video_backend = NULL;
@ -37,11 +36,9 @@ void VideoBackend::PopulateList()
g_available_video_backends.push_back(new DX11::VideoBackend);
#endif
g_available_video_backends.push_back(new OGL::VideoBackend);
#ifndef _WIN32
g_available_video_backends.push_back(new SW::VideoBackend);
#endif
g_video_backend = g_available_video_backends.front();
g_available_video_backends.push_back(new SW::VideoSoftware);
g_video_backend = g_available_video_backends.front();
}
void VideoBackend::ClearList()

View File

@ -23,6 +23,11 @@
#include "ChunkFile.h"
typedef void (*writeFn16)(const u16,const u32);
typedef void (*writeFn32)(const u32,const u32);
typedef void (*readFn16)(u16&, const u32);
enum FieldType
{
FIELD_PROGRESSIVE = 0,
@ -97,7 +102,6 @@ public:
virtual void ShowConfig(void*) {}
virtual void Video_Prepare() = 0;
virtual void Video_EnterLoop() = 0;
virtual void Video_ExitLoop() = 0;
@ -112,11 +116,17 @@ public:
virtual void Video_SetRendering(bool bEnabled) = 0;
static void Video_GatherPipeBursted();
virtual void Video_GatherPipeBursted() = 0;
virtual bool Video_IsPossibleWaitingSetDrawDone() = 0;
virtual void Video_AbortFrame() = 0;
virtual readFn16 Video_CPRead16() = 0;
virtual writeFn16 Video_CPWrite16() = 0;
virtual readFn16 Video_PERead16() = 0;
virtual writeFn16 Video_PEWrite16() = 0;
virtual writeFn32 Video_PEWrite32() = 0;
static void PopulateList();
static void ClearList();
static void ActivateBackend(const std::string& name);
@ -126,7 +136,7 @@ extern std::vector<VideoBackend*> g_available_video_backends;
extern VideoBackend* g_video_backend;
// inherited by dx9/dx11/ogl backends
class VideoBackendHLE : public VideoBackend
class VideoBackendHardware : public VideoBackend
{
void DoState(PointerWrap &p);
void RunLoop(bool enable);
@ -145,14 +155,16 @@ class VideoBackendHLE : public VideoBackend
void Video_SetRendering(bool bEnabled);
void Video_GatherPipeBursted();
bool Video_IsPossibleWaitingSetDrawDone();
void Video_AbortFrame();
};
// inherited by software renderer
class VideoBackendLLE : public VideoBackend
{
readFn16 Video_CPRead16();
writeFn16 Video_CPWrite16();
readFn16 Video_PERead16();
writeFn16 Video_PEWrite16();
writeFn32 Video_PEWrite32();
};
#endif

View File

@ -45,8 +45,7 @@ may be redirected here (for example to Read_U32()).
#include "WII_IPC.h"
#include "../ConfigManager.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "CommandProcessor.h"
#include "PixelEngine.h"
#include "VideoBackendBase.h"
namespace Memory
{
@ -180,12 +179,12 @@ void InitHWMemFuncs()
for (int i = 0; i < BLOCKSIZE; i++)
{
hwRead16 [CP_START+i] = CommandProcessor::Read16;
hwWrite16[CP_START+i] = CommandProcessor::Write16;
hwRead16 [CP_START+i] = g_video_backend->Video_CPRead16();
hwWrite16[CP_START+i] = g_video_backend->Video_CPWrite16();
hwRead16 [PE_START+i] = PixelEngine::Read16;
hwWrite16[PE_START+i] = PixelEngine::Write16;
hwWrite32[PE_START+i] = PixelEngine::Write32;
hwRead16 [PE_START+i] = g_video_backend->Video_PERead16();
hwWrite16[PE_START+i] = g_video_backend->Video_PEWrite16();
hwWrite32[PE_START+i] = g_video_backend->Video_PEWrite32();
hwRead8 [VI_START+i] = VideoInterface::Read8;
hwRead16 [VI_START+i] = VideoInterface::Read16;
@ -253,12 +252,12 @@ void InitHWMemFuncsWii()
// MI, PI, DSP are still mapped to 0xCCxxxxxx
for (int i = 0; i < BLOCKSIZE; i++)
{
hwRead16 [CP_START+i] = CommandProcessor::Read16;
hwWrite16[CP_START+i] = CommandProcessor::Write16;
hwRead16 [CP_START+i] = g_video_backend->Video_CPRead16();
hwWrite16[CP_START+i] = g_video_backend->Video_CPWrite16();
hwRead16 [PE_START+i] = PixelEngine::Read16;
hwWrite16[PE_START+i] = PixelEngine::Write16;
hwWrite32[PE_START+i] = PixelEngine::Write32;
hwRead16 [PE_START+i] = g_video_backend->Video_PERead16();
hwWrite16[PE_START+i] = g_video_backend->Video_PEWrite16();
hwWrite32[PE_START+i] = g_video_backend->Video_PEWrite32();
hwRead16 [PI_START+i] = ProcessorInterface::Read16;
hwRead32 [PI_START+i] = ProcessorInterface::Read32;

View File

@ -359,6 +359,9 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<ProjectReference Include="..\..\Plugins\Plugin_VideoOGL\Plugin_VideoOGL.vcxproj">
<Project>{1909cd2d-1707-456f-86ca-0df42a727c99}</Project>
</ProjectReference>
<ProjectReference Include="..\..\Plugins\Plugin_VideoSoftware\Plugin_VideoSoftware.vcxproj">
<Project>{9e9da440-e9ad-413c-b648-91030e792211}</Project>
</ProjectReference>
<ProjectReference Include="..\AudioCommon\AudioCommon.vcxproj">
<Project>{37d007bd-d66c-4eaf-b56c-bd1aac340a05}</Project>
</ProjectReference>
@ -384,4 +387,4 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -199,7 +199,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
if (wParam == WM_USER_KEYDOWN)
{
OnKeyDown(lParam);
FreeLookInput(wParam, lParam);
FreeLookInput((u32)wParam, lParam);
}
else if (wParam == WIIMOTE_DISCONNECT)
{

View File

@ -143,7 +143,7 @@ void RunGpuLoop()
if (!GpuRunningState) break;
fifo.isGpuReadingData = true;
CommandProcessor::isPossibleWaitingSetDrawDone = fifo.bFF_GPLinkEnable;
CommandProcessor::isPossibleWaitingSetDrawDone = fifo.bFF_GPLinkEnable ? true : false;
u32 readPtr = fifo.CPReadPointer;
u8 *uData = Memory::GetPointer(readPtr);

View File

@ -39,24 +39,24 @@ static struct
static u32 s_AccessEFBResult = 0;
void VideoBackendHLE::EmuStateChange(EMUSTATE_CHANGE newState)
void VideoBackendHardware::EmuStateChange(EMUSTATE_CHANGE newState)
{
EmulatorState((newState == EMUSTATE_CHANGE_PLAY) ? true : false);
}
// Enter and exit the video loop
void VideoBackendHLE::Video_EnterLoop()
void VideoBackendHardware::Video_EnterLoop()
{
RunGpuLoop();
}
void VideoBackendHLE::Video_ExitLoop()
void VideoBackendHardware::Video_ExitLoop()
{
ExitGpuLoop();
s_FifoShuttingDown = true;
}
void VideoBackendHLE::Video_SetRendering(bool bEnabled)
void VideoBackendHardware::Video_SetRendering(bool bEnabled)
{
Fifo_SetRendering(bEnabled);
}
@ -94,7 +94,7 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
}
// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackendHLE::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
void VideoBackendHardware::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
if (s_BackendInitialized && g_ActiveConfig.bUseXFB)
{
@ -108,7 +108,7 @@ void VideoBackendHLE::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth
}
// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackendHLE::Video_EndField()
void VideoBackendHardware::Video_EndField()
{
if (s_BackendInitialized)
{
@ -116,18 +116,18 @@ void VideoBackendHLE::Video_EndField()
}
}
void VideoBackendHLE::Video_AddMessage(const char* pstr, u32 milliseconds)
void VideoBackendHardware::Video_AddMessage(const char* pstr, u32 milliseconds)
{
OSD::AddMessage(pstr, milliseconds);
}
void VideoBackendHLE::Video_ClearMessages()
void VideoBackendHardware::Video_ClearMessages()
{
OSD::ClearMessages();
}
// Screenshot
bool VideoBackendHLE::Video_Screenshot(const char *_szFilename)
bool VideoBackendHardware::Video_Screenshot(const char *_szFilename)
{
Renderer::SetScreenshot(_szFilename);
return true;
@ -143,7 +143,7 @@ void VideoFifo_CheckEFBAccess()
}
}
u32 VideoBackendHLE::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
{
if (s_BackendInitialized)
{
@ -202,7 +202,7 @@ void VideoFifo_CheckStateRequest()
}
// Run from the CPU thread
void VideoBackendHLE::DoState(PointerWrap& p)
void VideoBackendHardware::DoState(PointerWrap& p)
{
s_doStateArgs.ptr = p.ptr;
s_doStateArgs.mode = p.mode;
@ -217,7 +217,7 @@ void VideoBackendHLE::DoState(PointerWrap& p)
VideoFifo_CheckStateRequest();
}
void VideoBackendHLE::RunLoop(bool enable)
void VideoBackendHardware::RunLoop(bool enable)
{
VideoCommon_RunLoop(enable);
}
@ -228,17 +228,39 @@ void VideoFifo_CheckAsyncRequest()
VideoFifo_CheckEFBAccess();
}
void VideoBackend::Video_GatherPipeBursted()
void VideoBackendHardware::Video_GatherPipeBursted()
{
CommandProcessor::GatherPipeBursted();
}
bool VideoBackendHLE::Video_IsPossibleWaitingSetDrawDone()
bool VideoBackendHardware::Video_IsPossibleWaitingSetDrawDone()
{
return CommandProcessor::isPossibleWaitingSetDrawDone;
}
void VideoBackendHLE::Video_AbortFrame()
void VideoBackendHardware::Video_AbortFrame()
{
CommandProcessor::AbortFrame();
}
readFn16 VideoBackendHardware::Video_CPRead16()
{
return CommandProcessor::Read16;
}
writeFn16 VideoBackendHardware::Video_CPWrite16()
{
return CommandProcessor::Write16;
}
readFn16 VideoBackendHardware::Video_PERead16()
{
return PixelEngine::Read16;
}
writeFn16 VideoBackendHardware::Video_PEWrite16()
{
return PixelEngine::Write16;
}
writeFn32 VideoBackendHardware::Video_PEWrite32()
{
return PixelEngine::Write32;
}

View File

@ -4,6 +4,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D
ProjectSection(ProjectDependencies) = postProject
{8C60E805-0DA5-4E25-8F84-038DB504BB0D} = {8C60E805-0DA5-4E25-8F84-038DB504BB0D}
{69F00340-5C3D-449F-9A80-958435C6CF06} = {69F00340-5C3D-449F-9A80-958435C6CF06}
{9E9DA440-E9AD-413C-B648-91030E792211} = {9E9DA440-E9AD-413C-B648-91030E792211}
{93D73454-2512-424E-9CDA-4BB357FE13DD} = {93D73454-2512-424E-9CDA-4BB357FE13DD}
{B6398059-EBB6-4C34-B547-95F365B71FF4} = {B6398059-EBB6-4C34-B547-95F365B71FF4}
{AA862E5E-A993-497A-B6A0-0E8E94B10050} = {AA862E5E-A993-497A-B6A0-0E8E94B10050}
@ -131,7 +132,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoOGL", "Plugins\Plugin_
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoSoftware", "Plugins\Plugin_VideoSoftware\Plugin_VideoSoftware.vcxproj", "{9E9DA440-E9AD-413C-B648-91030E792211}"
ProjectSection(ProjectDependencies) = postProject
{3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF} = {3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF}
{69F00340-5C3D-449F-9A80-958435C6CF06} = {69F00340-5C3D-449F-9A80-958435C6CF06}
EndProjectSection
EndProject

View File

@ -7,7 +7,7 @@
namespace DX11
{
class VideoBackend : public VideoBackendHLE
class VideoBackend : public VideoBackendHardware
{
bool Initialize(void *&);
void Shutdown();

View File

@ -7,7 +7,7 @@
namespace DX9
{
class VideoBackend : public VideoBackendHLE
class VideoBackend : public VideoBackendHardware
{
bool Initialize(void *&);
void Shutdown();

View File

@ -293,7 +293,7 @@ void GLVertexFormat::EnableComponents(u32 components)
// TODO - Is this a good spot for this code?
if (g_ActiveConfig.bDisableLighting)
{
for (int i = 0; i < xfregs.numChan.numColorChans; i++)
for (u32 i = 0; i < xfregs.numChan.numColorChans; i++)
{
xfregs.alpha[i].enablelighting = false;
xfregs.color[i].enablelighting = false;

View File

@ -7,7 +7,7 @@
namespace OGL
{
class VideoBackend : public VideoBackendHLE
class VideoBackend : public VideoBackendHardware
{
bool Initialize(void *&);
void Shutdown();

View File

@ -203,7 +203,6 @@
<ClCompile Include="Src\TransformUnit.cpp" />
<ClCompile Include="Src\SWVertexLoader.cpp" />
<ClCompile Include="Src\VideoConfigDialog.cpp" />
<ClCompile Include="Src\Win32.cpp" />
<ClCompile Include="Src\XFMemLoader.cpp" />
</ItemGroup>
<ItemGroup>
@ -230,10 +229,8 @@
<ClInclude Include="Src\TransformUnit.h" />
<ClInclude Include="Src\Vec3.h" />
<ClInclude Include="Src\SWVertexLoader.h" />
<ClInclude Include="Src\VertexLoader_Position.h" />
<ClInclude Include="Src\VideoBackend.h" />
<ClInclude Include="Src\VideoConfigDialog.h" />
<ClInclude Include="Src\Win32.h" />
<ClInclude Include="Src\XFMemLoader.h" />
</ItemGroup>
<ItemGroup>

View File

@ -25,9 +25,6 @@
<ClCompile Include="Src\SWVertexLoader.cpp" />
<ClCompile Include="Src\VideoConfigDialog.cpp" />
<ClCompile Include="Src\XFMemLoader.cpp" />
<ClCompile Include="Src\Win32.cpp">
<Filter>Win32</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Src\BPMemLoader.h" />
@ -56,12 +53,6 @@
<ClInclude Include="Src\VideoBackend.h" />
<ClInclude Include="Src\VideoConfigDialog.h" />
<ClInclude Include="Src\XFMemLoader.h" />
<ClInclude Include="Src\Win32.h">
<Filter>Win32</Filter>
</ClInclude>
<ClInclude Include="Src\VertexLoader_Position.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
@ -71,8 +62,5 @@
<Filter Include="Win32">
<UniqueIdentifier>{081288cb-a63b-4ae9-93eb-e668568520b8}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{80e30848-1174-4168-a8f7-da2553f872b1}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>

View File

@ -15,18 +15,17 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "../../../Core/VideoCommon/Src/VideoCommon.h"
#include "VideoCommon.h"
#include "TextureDecoder.h"
#include "BPMemLoader.h"
#include "EfbCopy.h"
#include "Rasterizer.h"
#include "SWPixelEngine.h"
#include "Tev.h"
#include "../../../Core/VideoCommon/Src/TextureDecoder.h"
#include "HW/Memmap.h"
#include "Core.h"
extern BPMemory bpmem;
void InitBPMemory()
{

View File

@ -20,8 +20,7 @@
#include "Common.h"
#include "../../../Core/VideoCommon/Src/BPMemory.h"
#include "BPMemory.h"
void InitBPMemory();
void SWBPWritten(int address, int newvalue);

View File

@ -19,62 +19,52 @@
#include "CPMemLoader.h"
#include "HW/Memmap.h"
// CP state
static u8 *_cached_arraybases[16];
// STATE_TO_SAVE
static u32 _arraybases[16];
static u32 _arraystrides[16];
static TMatrixIndexA _MatrixIndexA;
static TMatrixIndexB _MatrixIndexB;
static TVtxDesc _g_VtxDesc;
static VAT _g_VtxAttr[8];
void SWLoadCPReg(u32 sub_cmd, u32 value)
{
switch (sub_cmd & 0xF0)
{
case 0x30:
_MatrixIndexA.Hex = value;
MatrixIndexA.Hex = value;
break;
case 0x40:
_MatrixIndexB.Hex = value;
MatrixIndexB.Hex = value;
break;
case 0x50:
_g_VtxDesc.Hex &= ~0x1FFFF; // keep the Upper bits
_g_VtxDesc.Hex |= value;
g_VtxDesc.Hex &= ~0x1FFFF; // keep the Upper bits
g_VtxDesc.Hex |= value;
break;
case 0x60:
_g_VtxDesc.Hex &= 0x1FFFF; // keep the lower 17Bits
_g_VtxDesc.Hex |= (u64)value << 17;
g_VtxDesc.Hex &= 0x1FFFF; // keep the lower 17Bits
g_VtxDesc.Hex |= (u64)value << 17;
break;
case 0x70:
_assert_((sub_cmd & 0x0F) < 8);
_g_VtxAttr[sub_cmd & 7].g0.Hex = value;
g_VtxAttr[sub_cmd & 7].g0.Hex = value;
break;
case 0x80:
_assert_((sub_cmd & 0x0F) < 8);
_g_VtxAttr[sub_cmd & 7].g1.Hex = value;
g_VtxAttr[sub_cmd & 7].g1.Hex = value;
break;
case 0x90:
_assert_((sub_cmd & 0x0F) < 8);
_g_VtxAttr[sub_cmd & 7].g2.Hex = value;
g_VtxAttr[sub_cmd & 7].g2.Hex = value;
break;
// Pointers to vertex arrays in GC RAM
case 0xA0:
_arraybases[sub_cmd & 0xF] = value;
_cached_arraybases[sub_cmd & 0xF] = Memory::GetPointer(value);
arraybases[sub_cmd & 0xF] = value;
cached_arraybases[sub_cmd & 0xF] = Memory::GetPointer(value);
break;
case 0xB0:
_arraystrides[sub_cmd & 0xF] = value & 0xFF;
arraystrides[sub_cmd & 0xF] = value & 0xFF;
break;
}
}

View File

@ -20,8 +20,7 @@
#include "Common.h"
#include "../../../Core/VideoCommon/Src/CPMemory.h"
#include "CPMemory.h"
void SWLoadCPReg(u32 sub_cmd, u32 value);

View File

@ -26,7 +26,7 @@
#include "HwRasterizer.h"
#include "StringUtil.h"
#include "SWCommandProcessor.h"
#include "../../../Core/VideoCommon/Src/ImageWrite.h"
#include "ImageWrite.h"
#include "FileUtil.h"
namespace DebugUtil

View File

@ -19,7 +19,7 @@
#include "EfbInterface.h"
#include "BPMemLoader.h"
#include "../../../Core/VideoCommon/Src/LookUpTables.h"
#include "LookUpTables.h"
#include "SWPixelEngine.h"

View File

@ -17,7 +17,7 @@
#include "Common.h"
#include "../../../Core/VideoCommon/Src/DataReader.h"
#include "DataReader.h"
#include "OpcodeDecoder.h"
#include "BPMemLoader.h"
@ -32,20 +32,20 @@
#include "HW/Memmap.h"
typedef void (*DecodingFunction)(u32);
DecodingFunction currentFunction = NULL;
u32 minCommandSize;
u16 streamSize;
u16 streamAddress;
bool readOpcode;
SWVertexLoader vertexLoader;
bool inObjectStream;
u8 lastPrimCmd;
namespace OpcodeDecoder
{
static DecodingFunction currentFunction = NULL;
static u32 minCommandSize;
static u16 streamSize;
static u16 streamAddress;
static bool readOpcode;
static SWVertexLoader vertexLoader;
static bool inObjectStream;
static u8 lastPrimCmd;
void DecodePrimitiveStream(u32 iBufferSize)
{
u32 vertexSize = vertexLoader.GetVertexSize();
@ -106,7 +106,7 @@ void ExecuteDisplayList(u32 addr, u32 count)
OpcodeDecoder::Run(count);
// if data was read by the opcode decoder then the video data pointer changed
u32 readCount = g_pVideoData - dlStart;
u32 readCount = (u32)(g_pVideoData - dlStart);
dlStart = g_pVideoData;
_assert_msg_(VIDEO, count >= readCount, "Display list underrun");

View File

@ -28,24 +28,8 @@
#include "SWCommandProcessor.h"
#include "ChunkFile.h"
#include "MathUtil.h"
bool fifoStateRun;
// set to 0 if using in video common
#define SW_BACKEND 1
#if (SW_BACKEND)
#include "OpcodeDecoder.h"
#else
#include "SWVideoConfig.h"
#include "OpcodeDecoding.h"
#include "VideoCommon.h"
extern u8* g_pVideoData;
#endif
namespace SWCommandProcessor
{
@ -425,7 +409,6 @@ bool RunBuffer()
u32 availableBytes = writePos - readPos;
#if (SW_BACKEND)
while (OpcodeDecoder::CommandRunnable(availableBytes))
{
cpreg.status.CommandIdle = 0;
@ -437,15 +420,6 @@ bool RunBuffer()
_dbg_assert_(VIDEO, writePos >= readPos);
availableBytes = writePos - readPos;
}
#else
cpreg.status.CommandIdle = 0;
OpcodeDecoder_Run(g_bSkipCurrentFrame);
// if data was read by the opcode decoder then the video data pointer changed
readPos = g_pVideoData - &commandBuffer[0];
_dbg_assert_(COMMANDPROCESSOR, writePos >= readPos);
availableBytes = writePos - readPos;
#endif
cpreg.status.CommandIdle = 1;
@ -464,69 +438,10 @@ bool RunBuffer()
return ranDecoder;
}
} // end of namespace SWCommandProcessor
// fifo functions
#if (SW_BACKEND)
void SWFifo_EnterLoop()
{
fifoStateRun = true;
while (fifoStateRun)
{
g_video_backend->PeekMessages();
if (!SWCommandProcessor::RunBuffer()) {
Common::YieldCPU();
}
}
}
#else
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
{
fifoStateRun = true;
while (fifoStateRun)
{
g_VideoInitialize.pPeekMessages();
if (g_ActiveConfig.bEFBAccessEnable)
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
if (!CommandProcessor::RunBuffer()) {
Common::YieldCPU();
}
}
}
#endif
#if 0
void Fifo_ExitLoop()
{
fifoStateRun = false;
}
void Fifo_SetRendering(bool enabled)
void SetRendering(bool enabled)
{
g_bSkipCurrentFrame = !enabled;
}
// for compatibility with video common
void Fifo_Init() {}
void Fifo_Shutdown() {}
void Fifo_DoState(PointerWrap &p) {}
} // end of namespace SWCommandProcessor
u8* FAKE_GetFifoStartPtr()
{
return SWCommandProcessor::commandBuffer;
}
u8* FAKE_GetFifoEndPtr()
{
return &SWCommandProcessor::commandBuffer[SWCommandProcessor::writePos];
}
#endif

View File

@ -25,20 +25,6 @@ class PointerWrap;
extern volatile bool g_bSkipCurrentFrame;
extern u8* g_pVideoData;
// for compatibility with video common
void Fifo_Init();
void Fifo_Shutdown();
void Fifo_DoState(PointerWrap &p);
void Fifo_EnterLoop();
void Fifo_ExitLoop();
void Fifo_SetRendering(bool bEnabled);
// Implemented by the Video Backend
void VideoFifo_CheckSwapRequest();
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void VideoFifo_CheckEFBAccess();
namespace SWCommandProcessor
{
// internal hardware addresses
@ -164,6 +150,7 @@ namespace SWCommandProcessor
void UpdateInterrupts(u64 userdata);
void UpdateInterruptsFromVideoBackend(u64 userdata);
void SetRendering(bool enabled);
} // end of namespace SWCommandProcessor

View File

@ -19,9 +19,9 @@
#include "SWVertexLoader.h"
#include "VertexLoader_Position.h"
#include "../../../Core/VideoCommon/Src/VertexLoader_Normal.h"
#include "../../../Core/VideoCommon/Src/VertexLoader_Color.h"
#include "../../../Core/VideoCommon/Src/VertexLoader_TextCoord.h"
#include "VertexLoader_Normal.h"
#include "VertexLoader_Color.h"
#include "VertexLoader_TextCoord.h"
#include "CPMemLoader.h"
#include "XFMemLoader.h"
@ -30,14 +30,15 @@
#include "SetupUnit.h"
#include "SWStatistics.h"
#include "VertexManagerBase.h"
#include "../../../Core/VideoCommon/Src/DataReader.h"
#include "DataReader.h"
// Vertex loaders read these
static int tcIndex;
static int colIndex;
static int colElements[2];
static float posScale;
static float tcScale[8];
extern int tcIndex;
extern int colIndex;
extern int colElements[2];
extern float posScale;
extern float tcScale[8];
SWVertexLoader::SWVertexLoader() :
m_VertexSize(0),
@ -165,7 +166,8 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
AddAttributeLoader(LoadPosition);
// Normals
if (g_VtxDesc.Normal != NOT_PRESENT) {
if (g_VtxDesc.Normal != NOT_PRESENT)
{
m_VertexSize += VertexLoader_Normal::GetSize(g_VtxDesc.Normal, m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3);
m_normalLoader = VertexLoader_Normal::GetFunction(g_VtxDesc.Normal, m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3, true);
if (m_normalLoader == 0)

View File

@ -22,6 +22,7 @@
#include "VideoConfigDialog.h"
#endif // HAVE_WX
#include "SWCommandProcessor.h"
#include "OpcodeDecoder.h"
#include "SWVideoConfig.h"
@ -31,20 +32,21 @@
#include "Clipper.h"
#include "Rasterizer.h"
#include "SWRenderer.h"
#include "../../../Core/VideoCommon/Src/LookUpTables.h"
#include "HwRasterizer.h"
#include "LogManager.h"
#include "EfbInterface.h"
#include "DebugUtil.h"
#include "FileUtil.h"
#include "VideoBackend.h"
#include "../../../Core/VideoCommon/Src/Fifo.h"
#include "Core.h"
namespace SW
{
std::string VideoBackend::GetName()
static bool fifoStateRun = false;
std::string VideoSoftware::GetName()
{
return "Software Renderer";
}
@ -54,7 +56,7 @@ void *DllDebugger(void *_hParent, bool Show)
return NULL;
}
void VideoBackend::ShowConfig(void *_hParent)
void VideoSoftware::ShowConfig(void *_hParent)
{
#if defined(HAVE_WX) && HAVE_WX
VideoConfigDialog diag((wxWindow*)_hParent, "Software", "gfx_software");
@ -62,7 +64,7 @@ void VideoBackend::ShowConfig(void *_hParent)
#endif
}
bool VideoBackend::Initialize(void *&window_handle)
bool VideoSoftware::Initialize(void *&window_handle)
{
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
@ -86,26 +88,27 @@ bool VideoBackend::Initialize(void *&window_handle)
return true;
}
void VideoBackend::DoState(PointerWrap&)
void VideoSoftware::DoState(PointerWrap&)
{
}
void VideoBackend::RunLoop(bool enable)
void VideoSoftware::RunLoop(bool enable)
{
//EmulatorState(true);
}
void VideoSoftware::EmuStateChange(EMUSTATE_CHANGE newState)
{
}
void VideoBackend::EmuStateChange(EMUSTATE_CHANGE newState)
{
}
void VideoBackend::Shutdown()
void VideoSoftware::Shutdown()
{
SWRenderer::Shutdown();
OpenGL_Shutdown();
}
// This is called after Video_Initialize() from the Core
void VideoBackend::Video_Prepare()
void VideoSoftware::Video_Prepare()
{
SWRenderer::Prepare();
@ -113,16 +116,16 @@ void VideoBackend::Video_Prepare()
}
// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackend::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
void VideoSoftware::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
}
// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackend::Video_EndField()
void VideoSoftware::Video_EndField()
{
}
u32 VideoBackend::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
u32 VideoSoftware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
{
u32 value = 0;
@ -152,7 +155,7 @@ u32 VideoBackend::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputDat
return value;
}
bool VideoBackend::Video_Screenshot(const char *_szFilename)
bool VideoSoftware::Video_Screenshot(const char *_szFilename)
{
return false;
}
@ -160,41 +163,77 @@ bool VideoBackend::Video_Screenshot(const char *_szFilename)
// -------------------------------
// Enter and exit the video loop
// -------------------------------
void VideoBackend::Video_EnterLoop()
void VideoSoftware::Video_EnterLoop()
{
EmulatorState(true);
fifoStateRun = true;
while (fifoStateRun)
{
g_video_backend->PeekMessages();
if (!SWCommandProcessor::RunBuffer()) {
Common::YieldCPU();
}
}
}
void VideoBackend::Video_ExitLoop()
void VideoSoftware::Video_ExitLoop()
{
ExitGpuLoop();
fifoStateRun = false;
}
void VideoBackend::Video_AddMessage(const char* pstr, u32 milliseconds)
{
// TODO : could use the OSD class in video common, we would need to implement the Renderer class
// however most of it is useless for the SW backend so we could as well move it to its own class
void VideoSoftware::Video_AddMessage(const char* pstr, u32 milliseconds)
{
}
void VideoBackend::Video_ClearMessages()
void VideoSoftware::Video_ClearMessages()
{
}
void VideoBackend::Video_SetRendering(bool bEnabled)
void VideoSoftware::Video_SetRendering(bool bEnabled)
{
Fifo_SetRendering(bEnabled);
SWCommandProcessor::SetRendering(bEnabled);
}
void VideoSoftware::Video_GatherPipeBursted()
{
SWCommandProcessor::GatherPipeBursted();
}
bool VideoBackend::Video_IsPossibleWaitingSetDrawDone(void)
bool VideoSoftware::Video_IsPossibleWaitingSetDrawDone(void)
{
return false;
}
void VideoBackend::Video_AbortFrame(void)
void VideoSoftware::Video_AbortFrame(void)
{
}
readFn16 VideoSoftware::Video_CPRead16()
{
return SWCommandProcessor::Read16;
}
writeFn16 VideoSoftware::Video_CPWrite16()
{
return SWCommandProcessor::Write16;
}
readFn16 VideoSoftware::Video_PERead16()
{
return SWPixelEngine::Read16;
}
writeFn16 VideoSoftware::Video_PEWrite16()
{
return SWPixelEngine::Write16;
}
writeFn32 VideoSoftware::Video_PEWrite32()
{
return SWPixelEngine::Write32;
}
// Draw messages on top of the screen
unsigned int VideoBackend::PeekMessages()
unsigned int VideoSoftware::PeekMessages()
{
#ifdef _WIN32
// TODO: peekmessage
@ -213,11 +252,11 @@ unsigned int VideoBackend::PeekMessages()
}
// Show the current FPS
void VideoBackend::UpdateFPSDisplay(const char *text)
void VideoSoftware::UpdateFPSDisplay(const char *text)
{
char temp[100];
snprintf(temp, sizeof temp, "%s | Software | %s", svn_rev_str, text);
OpenGL_SetWindowText(temp);
}
}
}

View File

@ -17,11 +17,11 @@
#include "TextureEncoder.h"
#include "EfbInterface.h"
#include "../../../Core/VideoCommon/Src/LookUpTables.h"
#include "BPMemLoader.h"
#include "../../../Core/VideoCommon/Src/TextureDecoder.h"
#include "LookUpTables.h"
#include "TextureDecoder.h"
namespace TextureEncoder
{

View File

@ -18,7 +18,7 @@
#include "TextureSampler.h"
#include "BPMemLoader.h"
#include "../../../Core/VideoCommon/Src/TextureDecoder.h"
#include "TextureDecoder.h"
#include "HW/Memmap.h"
#include <cmath>

View File

@ -1,20 +0,0 @@
// Copyright (C) 2003-2009 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 "NativeVertexFormat.h"
#include "../../../Core/VideoCommon/Src/VertexLoader_Position.h"

View File

@ -7,7 +7,7 @@
namespace SW
{
class VideoBackend : public VideoBackendLLE
class VideoSoftware : public VideoBackend
{
bool Initialize(void *&);
void Shutdown();
@ -35,9 +35,17 @@ class VideoBackend : public VideoBackendLLE
void Video_SetRendering(bool bEnabled);
void Video_GatherPipeBursted();
bool Video_IsPossibleWaitingSetDrawDone();
void Video_AbortFrame();
readFn16 Video_CPRead16();
writeFn16 Video_CPWrite16();
readFn16 Video_PERead16();
writeFn16 Video_PEWrite16();
writeFn32 Video_PEWrite32();
void UpdateFPSDisplay(const char*);
unsigned int PeekMessages();
};

View File

@ -1,313 +0,0 @@
// Copyright (C) 2003-2009 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 <windows.h>
#include <wx/wx.h>
#include <wx/filepicker.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
#include <wx/aboutdlg.h>
#include "ConfigManager.h"
#include "VideoBackend.h"
#include "SWVideoConfig.h"
#include "Win32.h"
#include "StringUtil.h"
// ----------------------
// The rendering window
// ----------------------
namespace EmuWindow
{
HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL;
WNDCLASSEX wndClass;
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
int g_winstyle;
// ------------------------------------------
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
an empty transparent cursor */
// ------------------
HCURSOR hCursor = NULL, hCursorBlank = NULL;
void CreateCursors(HINSTANCE hInstance)
{
BYTE ANDmaskCursor[] = { 0xff };
BYTE XORmaskCursor[] = { 0x00 };
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
hCursor = LoadCursor(NULL, IDC_ARROW);
}
HWND GetWnd()
{
return m_hWnd;
}
HWND GetParentWnd()
{
return m_hParent;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{
HDC hdc;
PAINTSTRUCT ps;
switch( iMsg )
{
case WM_CREATE:
PostMessage(m_hParent, WM_USER, WM_USER_CREATE, (int)m_hParent);
break;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
break;
case WM_SYSKEYDOWN:
switch( LOWORD( wParam ))
{
case VK_RETURN:
// Pressing Alt+Enter switch FullScreen/Windowed
if (m_hParent == NULL && !g_SWVideoConfig.renderToMainframe)
{
ToggleFullscreen(hWnd);
}
break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hParent, WM_SYSKEYDOWN, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
case WM_KEYDOWN:
switch (LOWORD( wParam ))
{
case VK_ESCAPE:
if (g_SWVideoConfig.bFullscreen)
{
// Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(hWnd);
}
// And pause the emulation when already in Windowed mode
PostMessage(m_hParent, WM_USER, WM_USER_PAUSE, 0);
break;
}
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
during gameplay. The alternative is to load one of the cursors when the plugin
is loaded and go with that. This should only produce a minimal performance hit
because SetCursor is not supposed to actually change the cursor if it's the
same as the one before. */
case WM_MOUSEMOVE:
/* Check rendering mode; child or parent. Then post the mouse moves to the main window
it's nessesary for both the chil dwindow and separate rendering window because
moves over the rendering window do not reach the main program then. */
if (GetParentWnd() == NULL) // Separate rendering window
PostMessage(m_hParent, iMsg, wParam, -1);
else
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
/* To support the separate window rendering we get the message back here. So we basically
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if necessary */
case WM_USER:
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == WIIMOTE_DISCONNECT)
PostMessage(m_hParent, WM_USER, wParam, lParam);
break;
/* Post these mouse events to the main window, it's nessesary becase in difference to the
keyboard inputs these events only appear here, not in the main WndProc() */
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
// This is called when we close the window when we render to a separate window
case WM_CLOSE:
if (m_hParent == NULL)
{
// Take it out of fullscreen and stop the game
if( g_SWVideoConfig.bFullscreen )
ToggleFullscreen(m_hParent);
PostMessage(m_hParent, WM_USER, WM_USER_STOP, 0);
}
break;
// Called when a screensaver wants to show up while this window is active
case WM_SYSCOMMAND:
switch (wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
return 0;
}
// This is called from Create()
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
{
wndClass.cbSize = sizeof( wndClass );
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
// To interfer less with SetCursor() later we set this to NULL
//wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndClass.hCursor = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = m_szClassName;
wndClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
//m_hInstance = hInstance;
RegisterClassEx( &wndClass );
CreateCursors(/*m_hInstance*/GetModuleHandle(0));
// Create child window
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title,
WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, hInstance, NULL);
ShowWindow(m_hWnd, SW_SHOWMAXIMIZED);
return m_hWnd;
}
void ToggleFullscreen(HWND hParent)
{
if (m_hParent == NULL)
{
int w_fs = 640, h_fs = 480;
if (g_SWVideoConfig.bFullscreen)
{
// Get out of fullscreen
g_SWVideoConfig.bFullscreen = false;
RECT rc = {0, 0, w_fs, h_fs};
// FullScreen -> Desktop
ChangeDisplaySettings(NULL, 0);
RECT rcdesktop; // Get desktop resolution
GetWindowRect(GetDesktopWindow(), &rcdesktop);
ShowCursor(TRUE);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// SetWindowPos to the center of the screen
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
// Set new window style FS -> Windowed
SetWindowLong(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
// Eventually show the window!
EmuWindow::Show();
}
else
{
// Get into fullscreen
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = w_fs;
dmScreenSettings.dmPelsHeight = h_fs;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return;
// Set new window style -> PopUp
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
g_SWVideoConfig.bFullscreen = true;
ShowCursor(FALSE);
// SetWindowPos to the upper-left corner of the screen
SetWindowPos(hParent, NULL, 0, 0, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
// Eventually show the window!
EmuWindow::Show();
}
}
}
void Show()
{
ShowWindow(m_hWnd, SW_SHOW);
BringWindowToTop(m_hWnd);
UpdateWindow(m_hWnd);
}
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
{
return OpenWindow(hParent, hInstance, 640, 480, title);
}
void Close()
{
if (!m_hParent)
DestroyWindow(m_hWnd);
UnregisterClass(m_szClassName, /*m_hInstance*/GetModuleHandle(0));
}
// ------------------------------------------
// Set the size of the child or main window
// ------------------------------------------
void SetSize(int width, int height)
{
RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
int w = rc.right - rc.left;
int h = rc.bottom - rc.top;
// Move and resize the window
rc.left = (1280 - w)/2;
rc.right = rc.left + w;
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
MoveWindow(m_hWnd, rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, TRUE);
}
} // EmuWindow

View File

@ -1,39 +0,0 @@
// Copyright (C) 2003-2009 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/
#ifndef _WIN32_H_
#define _WIN32_H_
#pragma once
#include "stdafx.h"
namespace EmuWindow
{
extern int g_winstyle;
HWND GetWnd();
HWND GetParentWnd();
HWND GetChildParentWnd();
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
void Show();
void Close();
void ToggleFullscreen(HWND hParent);
void SetSize(int displayWidth, int displayHeight);
}
#endif // _WIN32_H_

View File

@ -15,7 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "../../../Core/VideoCommon/Src/VideoCommon.h"
#include "VideoCommon.h"
#include "XFMemLoader.h"
#include "CPMemLoader.h"