Fix *BSD build.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7002 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-01-31 03:02:23 +00:00
parent fec5ed92ff
commit 8822674653
21 changed files with 36 additions and 34 deletions

View File

@ -15,7 +15,6 @@ set(SRCS Src/ABI.cpp
Src/Misc.cpp
Src/MsgHandler.cpp
Src/NandPaths.cpp
Src/OpenCL.cpp
Src/SDCardUtil.cpp
Src/StringUtil.cpp
Src/SymbolDB.cpp
@ -24,7 +23,6 @@ set(SRCS Src/ABI.cpp
Src/Thunk.cpp
Src/Timer.cpp
Src/Version.cpp
Src/VideoBackendBase.cpp
Src/x64Analyzer.cpp
Src/x64Emitter.cpp
Src/Crypto/aes_cbc.cpp

View File

@ -705,14 +705,6 @@
RelativePath=".\Src\NandPaths.h"
>
</File>
<File
RelativePath=".\Src\OpenCL.cpp"
>
</File>
<File
RelativePath=".\Src\OpenCL.h"
>
</File>
<File
RelativePath="..\..\PluginSpecs\PluginSpecs.h"
>
@ -853,14 +845,6 @@
RelativePath=".\Src\Version.cpp"
>
</File>
<File
RelativePath=".\Src\VideoBackendBase.cpp"
>
</File>
<File
RelativePath=".\Src\VideoBackendBase.h"
>
</File>
<File
RelativePath=".\Src\x64Analyzer.cpp"
>

View File

@ -254,7 +254,6 @@
<ClCompile Include="Src\Misc.cpp" />
<ClCompile Include="Src\MsgHandler.cpp" />
<ClCompile Include="Src\NandPaths.cpp" />
<ClCompile Include="Src\OpenCL.cpp" />
<ClCompile Include="Src\SDCardUtil.cpp" />
<ClCompile Include="Src\stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@ -271,7 +270,6 @@
<ClCompile Include="Src\Thunk.cpp" />
<ClCompile Include="Src\Timer.cpp" />
<ClCompile Include="Src\Version.cpp" />
<ClCompile Include="Src\VideoBackendBase.cpp" />
<ClCompile Include="Src\x64Analyzer.cpp" />
<ClCompile Include="Src\x64Emitter.cpp" />
</ItemGroup>
@ -311,8 +309,6 @@
<ClInclude Include="Src\MemoryUtil.h" />
<ClInclude Include="Src\MsgHandler.h" />
<ClInclude Include="Src\NandPaths.h" />
<ClInclude Include="Src\OpenCL.h" />
<ClInclude Include="Src\VideoBackendBase.h" />
<ClInclude Include="Src\SDCardUtil.h" />
<ClInclude Include="Src\Setup.h" />
<ClInclude Include="Src\stdafx.h" />
@ -334,4 +330,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -1,272 +0,0 @@
// Copyright (C) 2003 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/
// TODO: Make a more centralized version of this (for now every plugin that will use it will create its own context, which is weird). An object maybe?
#include "OpenCL.h"
#include "Common.h"
#include "Timer.h"
namespace OpenCL
{
cl_device_id device_id = NULL;
cl_context g_context = NULL;
cl_command_queue g_cmdq = NULL;
bool g_bInitialized = false;
bool Initialize()
{
if(g_bInitialized)
return true;
if(g_context)
return false;
int err; // error code returned from api calls
#ifdef __APPLE__
// If OpenCL is weakly linked and not found, its symbols will be NULL
if (clGetPlatformIDs == NULL)
return false;
#else
clrInit();
if(!clrHasOpenCL())
return false;
#endif
// Connect to a compute device
cl_uint numPlatforms;
cl_platform_id platform = NULL;
err = clGetPlatformIDs(0, NULL, &numPlatforms);
if (err != CL_SUCCESS)
{
HandleCLError(err, "clGetPlatformIDs failed.");
return false;
}
if (0 < numPlatforms)
{
cl_platform_id* platforms = new cl_platform_id[numPlatforms];
err = clGetPlatformIDs(numPlatforms, platforms, NULL);
if (err != CL_SUCCESS)
{
HandleCLError(err, "clGetPlatformIDs failed.");
return false;
}
char pbuf[100];
err = clGetPlatformInfo(platforms[0], CL_PLATFORM_VENDOR, sizeof(pbuf),
pbuf, NULL);
if (err != CL_SUCCESS)
{
HandleCLError(err, "clGetPlatformInfo failed.");
return false;
}
platform = platforms[0];
delete[] platforms;
}
else
{
PanicAlert("No OpenCL platform found.");
return false;
}
cl_context_properties cps[3] = {CL_CONTEXT_PLATFORM,
(cl_context_properties)platform, 0};
cl_context_properties* cprops = (NULL == platform) ? NULL : cps;
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, NULL);
if (err != CL_SUCCESS)
{
HandleCLError(err, "Failed to create a device group!");
return false;
}
// Create a compute context
g_context = clCreateContext(cprops, 1, &device_id, NULL, NULL, &err);
if (!g_context)
{
HandleCLError(err, "Failed to create a compute context!");
return false;
}
// Create a command commands
g_cmdq = clCreateCommandQueue(g_context, device_id, 0, &err);
if (!g_cmdq)
{
HandleCLError(err, "Failed to create a command commands!");
return false;
}
g_bInitialized = true;
return true;
}
cl_context GetContext()
{
return g_context;
}
cl_command_queue GetCommandQueue()
{
return g_cmdq;
}
cl_program CompileProgram(const char *Kernel)
{
u32 compileStart = Common::Timer::GetTimeMs();
cl_int err;
cl_program program;
program = clCreateProgramWithSource(OpenCL::g_context, 1,
(const char **) & Kernel, NULL, &err);
if (!program)
{
HandleCLError(err, "Error: Failed to create compute program!");
}
// Build the program executable
err = clBuildProgram(program , 0, NULL, NULL, NULL, NULL);
if(err != CL_SUCCESS) {
HandleCLError(err, "Error: failed to build program");
char *buildlog = NULL;
size_t buildlog_size = 0;
clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &buildlog_size);
buildlog = new char[buildlog_size + 1];
err = clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, buildlog_size, buildlog, NULL);
buildlog[buildlog_size] = 0;
if(err != CL_SUCCESS)
{
HandleCLError(err, "Error: can't get build log");
} else
{
ERROR_LOG(COMMON, "Error log:\n%s\n", buildlog);
}
delete[] buildlog;
return NULL;
}
INFO_LOG(COMMON, "OpenCL CompileProgram took %.3f seconds",
(float)(Common::Timer::GetTimeMs() - compileStart) / 1000.0);
return program;
}
cl_kernel CompileKernel(cl_program program, const char *Function)
{
u32 compileStart = Common::Timer::GetTimeMs();
int err;
// Create the compute kernel in the program we wish to run
cl_kernel kernel = clCreateKernel(program, Function, &err);
if (!kernel || err != CL_SUCCESS)
{
char buffer[1024];
sprintf(buffer, "Failed to create compute kernel '%s' !", Function);
HandleCLError(err, buffer);
return NULL;
}
INFO_LOG(COMMON, "OpenCL CompileKernel took %.3f seconds",
(float)(Common::Timer::GetTimeMs() - compileStart) / 1000.0);
return kernel;
}
void Destroy()
{
if (g_cmdq)
{
clReleaseCommandQueue(g_cmdq);
g_cmdq = NULL;
}
if (g_context)
{
clReleaseContext(g_context);
g_context = NULL;
}
g_bInitialized = false;
}
void HandleCLError(cl_int error, const char* str)
{
const char* name;
switch(error)
{
#define CL_ERROR(x) case (x): name = #x; break
CL_ERROR(CL_SUCCESS);
CL_ERROR(CL_DEVICE_NOT_FOUND);
CL_ERROR(CL_DEVICE_NOT_AVAILABLE);
CL_ERROR(CL_COMPILER_NOT_AVAILABLE);
CL_ERROR(CL_MEM_OBJECT_ALLOCATION_FAILURE);
CL_ERROR(CL_OUT_OF_RESOURCES);
CL_ERROR(CL_OUT_OF_HOST_MEMORY);
CL_ERROR(CL_PROFILING_INFO_NOT_AVAILABLE);
CL_ERROR(CL_MEM_COPY_OVERLAP);
CL_ERROR(CL_IMAGE_FORMAT_MISMATCH);
CL_ERROR(CL_IMAGE_FORMAT_NOT_SUPPORTED);
CL_ERROR(CL_BUILD_PROGRAM_FAILURE);
CL_ERROR(CL_MAP_FAILURE);
CL_ERROR(CL_INVALID_VALUE);
CL_ERROR(CL_INVALID_DEVICE_TYPE);
CL_ERROR(CL_INVALID_PLATFORM);
CL_ERROR(CL_INVALID_DEVICE);
CL_ERROR(CL_INVALID_CONTEXT);
CL_ERROR(CL_INVALID_QUEUE_PROPERTIES);
CL_ERROR(CL_INVALID_COMMAND_QUEUE);
CL_ERROR(CL_INVALID_HOST_PTR);
CL_ERROR(CL_INVALID_MEM_OBJECT);
CL_ERROR(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
CL_ERROR(CL_INVALID_IMAGE_SIZE);
CL_ERROR(CL_INVALID_SAMPLER);
CL_ERROR(CL_INVALID_BINARY);
CL_ERROR(CL_INVALID_BUILD_OPTIONS);
CL_ERROR(CL_INVALID_PROGRAM);
CL_ERROR(CL_INVALID_PROGRAM_EXECUTABLE);
CL_ERROR(CL_INVALID_KERNEL_NAME);
CL_ERROR(CL_INVALID_KERNEL_DEFINITION);
CL_ERROR(CL_INVALID_KERNEL);
CL_ERROR(CL_INVALID_ARG_INDEX);
CL_ERROR(CL_INVALID_ARG_VALUE);
CL_ERROR(CL_INVALID_ARG_SIZE);
CL_ERROR(CL_INVALID_KERNEL_ARGS);
CL_ERROR(CL_INVALID_WORK_DIMENSION);
CL_ERROR(CL_INVALID_WORK_GROUP_SIZE);
CL_ERROR(CL_INVALID_WORK_ITEM_SIZE);
CL_ERROR(CL_INVALID_GLOBAL_OFFSET);
CL_ERROR(CL_INVALID_EVENT_WAIT_LIST);
CL_ERROR(CL_INVALID_EVENT);
CL_ERROR(CL_INVALID_OPERATION);
CL_ERROR(CL_INVALID_GL_OBJECT);
CL_ERROR(CL_INVALID_BUFFER_SIZE);
CL_ERROR(CL_INVALID_MIP_LEVEL);
#undef CL_ERROR
default:
name = "Unknown error code";
}
if(!str)
str = "";
ERROR_LOG(COMMON, "OpenCL error: %s %s (%d)", str, name, error);
}
}

View File

@ -1,53 +0,0 @@
// Copyright (C) 2003 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 __OPENCL_H__
#define __OPENCL_H__
#include "Common.h"
#ifdef __APPLE__
#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE
#include <OpenCL/cl.h>
#else
// The CLRun library provides the headers and all the imports.
#include <CL/cl.h>
#include <clrun.h>
#endif
namespace OpenCL
{
extern cl_device_id device_id;
extern cl_context g_context;
extern cl_command_queue g_cmdq;
bool Initialize();
cl_context GetContext();
cl_command_queue GetCommandQueue();
void Destroy();
cl_program CompileProgram(const char *Kernel);
cl_kernel CompileKernel(cl_program program, const char *Function);
void HandleCLError(cl_int error, const char* str = 0);
}
#endif

View File

@ -29,7 +29,6 @@ files = [
"Misc.cpp",
"MsgHandler.cpp",
"NandPaths.cpp",
"OpenCL.cpp",
"SDCardUtil.cpp",
"StringUtil.cpp",
"SymbolDB.cpp",
@ -38,7 +37,6 @@ files = [
"Thunk.cpp",
"Timer.cpp",
"Version.cpp",
"VideoBackendBase.cpp",
"x64Emitter.cpp",
"x64Analyzer.cpp",
"Crypto/aes_cbc.cpp",

View File

@ -1,58 +0,0 @@
// Copyright (C) 2003 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 "VideoBackendBase.h"
// TODO: ugly
#ifdef _WIN32
#include "../Plugins/Plugin_VideoDX9/Src/VideoBackend.h"
#include "../Plugins/Plugin_VideoDX11/Src/VideoBackend.h"
#endif
#include "../Plugins/Plugin_VideoOGL/Src/VideoBackend.h"
//#include "../Plugins/Plugin_VideoSoftware/Src/VideoBackend.h"
std::vector<VideoBackend*> g_available_video_backends;
VideoBackend* g_video_backend = NULL;
void VideoBackend::PopulateList()
{
#ifdef _WIN32
g_available_video_backends.push_back(new DX9::VideoBackend);
// TODO: if (winver >= VISTA) :p
g_available_video_backends.push_back(new DX11::VideoBackend);
#endif
g_available_video_backends.push_back(new OGL::VideoBackend);
//g_available_video_backends.push_back(new SW::VideoBackend);
g_video_backend = g_available_video_backends.front();
}
void VideoBackend::ClearList()
{
while (!g_available_video_backends.empty())
{
delete g_available_video_backends.back();
g_available_video_backends.pop_back();
}
}
void VideoBackend::ActivateBackend(const std::string& name)
{
for (std::vector<VideoBackend*>::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it)
if (name == (*it)->GetName())
g_video_backend = *it;
}

View File

@ -1,156 +0,0 @@
// Copyright (C) 2003 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 VIDEO_BACKEND_H_
#define VIDEO_BACKEND_H_
#include <string>
#include <vector>
#include "PluginSpecs.h"
#include "ChunkFile.h"
enum FieldType
{
FIELD_PROGRESSIVE = 0,
FIELD_UPPER,
FIELD_LOWER
};
enum EFBAccessType
{
PEEK_Z = 0,
POKE_Z,
PEEK_COLOR,
POKE_COLOR
};
struct SCPFifoStruct
{
// fifo registers
volatile u32 CPBase;
volatile u32 CPEnd;
u32 CPHiWatermark;
u32 CPLoWatermark;
volatile u32 CPReadWriteDistance;
volatile u32 CPWritePointer;
volatile u32 CPReadPointer;
volatile u32 CPBreakpoint;
// Super Monkey Ball Adventure require this.
// Because the read&check-PEToken-loop stays in its JITed block I suppose.
// So no possiblity to ack the Token irq by the scheduler until some sort of PPC watchdog do its mess.
volatile u16 PEToken;
volatile u32 bFF_GPReadEnable;
volatile u32 bFF_BPEnable;
volatile u32 bFF_BPInt;
volatile u32 bFF_Breakpoint;
volatile u32 CPCmdIdle;
volatile u32 CPReadIdle;
volatile u32 bFF_LoWatermarkInt;
volatile u32 bFF_HiWatermarkInt;
volatile u32 bFF_LoWatermark;
volatile u32 bFF_HiWatermark;
// for GP watchdog hack
volatile u32 Fake_GPWDToken; // cicular incrementer
};
class VideoBackend
{
public:
virtual ~VideoBackend() {}
virtual void EmuStateChange(PLUGIN_EMUSTATE) = 0;
virtual void UpdateFPSDisplay(const char*) = 0;
virtual unsigned int PeekMessages() = 0;
virtual void Initialize() = 0;
virtual void Shutdown() = 0;
virtual void DoState(PointerWrap &p) = 0;
virtual std::string GetName() = 0;
virtual void ShowConfig(void*) {}
virtual void Video_Prepare() = 0;
virtual void Video_EnterLoop() = 0;
virtual void Video_ExitLoop() = 0;
virtual void Video_BeginField(u32, FieldType, u32, u32) = 0;
virtual void Video_EndField() = 0;
virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0;
virtual bool Video_Screenshot(const char* filename) = 0;
virtual void Video_SetRendering(bool bEnabled) = 0;
static void Video_GatherPipeBursted();
virtual void Video_WaitForFrameFinish() = 0;
virtual bool Video_IsFifoBusy() = 0;
virtual void Video_AbortFrame() = 0;
static void PopulateList();
static void ClearList();
static void ActivateBackend(const std::string& name);
};
extern std::vector<VideoBackend*> g_available_video_backends;
extern VideoBackend* g_video_backend;
// inherited by dx9/dx11/ogl backends
class VideoBackendHLE : public VideoBackend
{
void DoState(PointerWrap &p);
void EmuStateChange(PLUGIN_EMUSTATE);
void Video_EnterLoop();
void Video_ExitLoop();
void Video_BeginField(u32, FieldType, u32, u32);
void Video_EndField();
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
void Video_AddMessage(const char* pstr, unsigned int milliseconds);
bool Video_Screenshot(const char* filename);
void Video_SetRendering(bool bEnabled);
void Video_WaitForFrameFinish();
bool Video_IsFifoBusy();
void Video_AbortFrame();
};
// inherited by software renderer
class VideoBackendLLE : public VideoBackend
{
};
#endif