diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-12-11 15:15:55 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-12-11 15:15:55 -0600 |
| commit | eb3b933dd0c32c1db7e44a8292c3523927d9ef99 (patch) | |
| tree | 918dc3d6d1abd3814e3d28740de03bbabc9f8273 /Source/Core/VideoCommon | |
| parent | c016d02c661ba8d393327be4a82e545a2f6fb4e3 (diff) | |
Remove all instances of OpenCL in the Dolphin Project. A brief history of OpenCL in Dolphin. OpenCL was originally added to the Dolphin codebase 1 month after it was released with OS X Snow Leopard in 2009. OpenCL was one of the largest group projects that Dolphin ever has had. The OpenCL texture decoder was originally aded with version 1.0 of the OpenCL spec; This version didn't have the capability of a OpenCL-OpenGL interop which would allow for uploading textures once and have it decoded directly to a OpenGL texure. This was to be worked out when the OpenCL 1.1 spec was released and allowed the interop. This work has never been done, and no one in the team is willing to work on it for various reasons. OpenCL has had the unreasonable expectation that it increases the performance of video games that require a large amount of EFB copies like NSMBW. In reality, enabling OpenCL just put the graphics card in a higher power mode which increased the game speed. This is due to the unfortunate effect of Dolphin tending to not push GPUs out of their lower frequency power savings modes. Thanks to everyone that had contributed to the OpenCL texture decoder.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/OpenCL.rules | 18 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpcodeDecoding.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpenCL.cpp | 259 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpenCL.h | 40 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.cpp | 307 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.h | 15 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureDecoder_Generic.cpp | 17 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureDecoder_x64.cpp | 17 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoConfig.cpp | 3 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoConfig.h | 3 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoCommon.vcxproj | 7 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoCommon.vcxproj.filters | 15 |
13 files changed, 13 insertions, 703 deletions
diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index ac2e82bb6b..5d79730044 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -14,8 +14,6 @@ set(SRCS Src/BPFunctions.cpp Src/MainBase.cpp Src/OnScreenDisplay.cpp Src/OpcodeDecoding.cpp - Src/OpenCL.cpp - Src/OpenCL/TextureDecoder_OpenCL.cpp Src/PerfQueryBase.cpp Src/PixelEngine.cpp Src/PixelShaderGen.cpp diff --git a/Source/Core/VideoCommon/OpenCL.rules b/Source/Core/VideoCommon/OpenCL.rules deleted file mode 100644 index cf695455ef..0000000000 --- a/Source/Core/VideoCommon/OpenCL.rules +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<VisualStudioToolFile - Name="OpenCL" - Version="8,00" - > - <Rules> - <CustomBuildRule - Name="OpenCL source" - DisplayName="OpenCL" - CommandLine='xcopy /I /Y "$(InputPath)" "$(SolutionDir)\..\Binary\$(PlatformName)\User\OpenCL\"' - Outputs='"$(SolutionDir)\..\Binary\$(PlatformName)\User\OpenCL\$(InputFileName)"' - FileExtensions="*.cl" - > - <Properties> - </Properties> - </CustomBuildRule> - </Rules> -</VisualStudioToolFile> diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp index 839d3fd5f6..f469bc7f6d 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp @@ -33,8 +33,6 @@ #include "Fifo.h" #include "DataReader.h" -#include "OpenCL.h" -#include "OpenCL/TextureDecoder_OpenCL.h" #include "VideoConfig.h" u8* g_pVideoData = 0; @@ -478,22 +476,11 @@ void OpcodeDecoder_Init() DataReadU32xFuncs[i] = DataReadU32xFuncs_SSSE3[i]; } #endif - - if (g_Config.bEnableOpenCL) - { - OpenCL::Initialize(); - TexDecoder_OpenCL_Initialize(); - } } void OpcodeDecoder_Shutdown() { - if (g_Config.bEnableOpenCL) - { - TexDecoder_OpenCL_Shutdown(); - OpenCL::Destroy(); - } } u32 OpcodeDecoder_Run(bool skipped_frame) diff --git a/Source/Core/VideoCommon/Src/OpenCL.cpp b/Source/Core/VideoCommon/Src/OpenCL.cpp deleted file mode 100644 index 7781b04978..0000000000 --- a/Source/Core/VideoCommon/Src/OpenCL.cpp +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -// TODO: Make a more centralized version of this (for now every backend 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); - } -} diff --git a/Source/Core/VideoCommon/Src/OpenCL.h b/Source/Core/VideoCommon/Src/OpenCL.h deleted file mode 100644 index 4ba172bb9c..0000000000 --- a/Source/Core/VideoCommon/Src/OpenCL.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#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 diff --git a/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.cpp b/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.cpp deleted file mode 100644 index 02e720d4a3..0000000000 --- a/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.cpp +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include "TextureDecoder_OpenCL.h" - -#include "../OpenCL.h" -#include "CommonPaths.h" -#include "FileUtil.h" - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <sys/types.h> -#include <string> - -//#define DEBUG_OPENCL - -cl_program g_program; - -struct sDecoderParameter -{ - const char *name; - cl_kernel kernel; - float sizeOfSrc; - float sizeOfDst; - int xSkip; - int ySkip; - PC_TexFormat format; -}; - -sDecoderParameter g_DecodeParametersNative[] = { - /* GX_TF_I4 */ { "DecodeI4", NULL, 0.5f, 1, 8, 8, PC_TEX_FMT_I4_AS_I8 }, - /* GX_TF_I8 */ { "DecodeI8", NULL, 1, 1, 8, 4, PC_TEX_FMT_I8 }, - /* GX_TF_IA4 */ { "DecodeIA4", NULL, 1, 2, 8, 4, PC_TEX_FMT_IA4_AS_IA8 }, - /* GX_TF_IA8 */ { "DecodeIA8", NULL, 2, 2, 4, 4, PC_TEX_FMT_IA8 }, - /* GX_TF_RGB565 */ { "DecodeRGB565", NULL, 2, 2, 4, 4, PC_TEX_FMT_RGB565 }, - /* GX_TF_RGB5A3 */ { "DecodeRGB5A3", NULL, 2, 4, 4, 4, PC_TEX_FMT_BGRA32 }, - /* GX_TF_RGBA8 */ { "DecodeRGBA8", NULL, 4, 4, 4, 4, PC_TEX_FMT_BGRA32 }, - /* 7 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C4 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C8 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C14X2 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* B */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* C */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* D */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_CMPR */ { "DecodeCMPR", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_BGRA32 }, -}; - -sDecoderParameter g_DecodeParametersRGBA[] = { - /* GX_TF_I4 */ { "DecodeI4_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, - /* GX_TF_I8 */ { "DecodeI8_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_IA4 */ { "DecodeIA4_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_IA8 */ { "DecodeIA8_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGB565 */ { "DecodeRGB565_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGB5A3 */ { "DecodeRGB5A3_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGBA8 */ { "DecodeRGBA8_RGBA", NULL, 4, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* 7 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C4 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C8 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_C14X2 */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* B */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* C */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* D */ { NULL, NULL, 0, 0, 0, 0, PC_TEX_FMT_NONE }, - /* GX_TF_CMPR */ { "DecodeCMPR_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, -}; - -bool g_Inited = false; -cl_mem g_clsrc, g_cldst; // texture buffer memory objects - -#define HEADER_SIZE 32 - -void TexDecoder_OpenCL_Initialize() -{ - if(!g_Inited) - { - if(!OpenCL::Initialize()) - return; - - cl_int err = 1; - size_t binary_size = 0; - char *binary = NULL; - char *header = NULL; - size_t nDevices = 0; - cl_device_id *devices = NULL; - size_t *binary_sizes = NULL; - char **binaries = NULL; - std::string filename; - char dolphin_rev[HEADER_SIZE]; - - filename = File::GetUserPath(D_OPENCL_IDX) + "kernel.bin"; - snprintf(dolphin_rev, HEADER_SIZE, "%-31s", scm_rev_str); - - { - File::IOFile input(filename, "rb"); - if (!input) - { - binary_size = 0; - } - else - { - binary_size = input.GetSize(); - header = new char[HEADER_SIZE]; - binary = new char[binary_size]; - input.ReadBytes(header, HEADER_SIZE); - input.ReadBytes(binary, binary_size); - } - } - - if (binary_size > 0) - { - if (binary_size > HEADER_SIZE) - { - if (strncmp(header, dolphin_rev, HEADER_SIZE) == 0) - { - g_program = clCreateProgramWithBinary(OpenCL::GetContext(), 1, &OpenCL::device_id, &binary_size, (const unsigned char**)&binary, NULL, &err); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clCreateProgramWithBinary"); - } - - if (!err) - { - err = clBuildProgram(g_program, 1, &OpenCL::device_id, NULL, NULL, NULL); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clBuildProgram"); - } - } - } - } - delete [] header; - delete [] binary; - } - - // If an error occurred using the kernel binary, recompile the kernels - if (err) - { - std::string code; - filename = File::GetSysDirectory() + OPENCL_DIR DIR_SEP "TextureDecoder.cl"; - if (!File::ReadFileToString(filename.c_str(), code)) - { - ERROR_LOG(VIDEO, "Failed to load OpenCL code %s - file is missing?", filename.c_str()); - return; - } - - g_program = OpenCL::CompileProgram(code.c_str()); - - err = clGetProgramInfo(g_program, CL_PROGRAM_NUM_DEVICES, sizeof(nDevices), &nDevices, NULL); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clGetProgramInfo"); - } - devices = (cl_device_id *)malloc( sizeof(cl_device_id) *nDevices); - - err = clGetProgramInfo(g_program, CL_PROGRAM_DEVICES, sizeof(cl_device_id)*nDevices, devices, NULL); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clGetProgramInfo"); - } - - binary_sizes = (size_t *)malloc(sizeof(size_t)*nDevices); - err = clGetProgramInfo(g_program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*nDevices, binary_sizes, NULL); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clGetProgramInfo"); - } - - binaries = (char **)malloc(sizeof(char *)*nDevices); - for (u32 i = 0; i < nDevices; ++i) - { - if (binary_sizes[i] != 0) - { - binaries[i] = (char *)malloc(HEADER_SIZE + binary_sizes[i]); - } - else - { - binaries[i] = NULL; - } - } - err = clGetProgramInfo( g_program, CL_PROGRAM_BINARIES, sizeof(char *)*nDevices, binaries, NULL ); - if (err != CL_SUCCESS) - { - OpenCL::HandleCLError(err, "clGetProgramInfo"); - } - - if (!err) - { - filename = File::GetUserPath(D_OPENCL_IDX) + "kernel.bin"; - - File::IOFile output(filename, "wb"); - if (!output) - { - binary_size = 0; - } - else - { - // Supporting one OpenCL device for now - output.WriteBytes(dolphin_rev, HEADER_SIZE); - output.WriteBytes(binaries[0], binary_sizes[0]); - } - } - for (u32 i = 0; i < nDevices; ++i) - { - if (binary_sizes[i] != 0) - { - free(binaries[i]); - } - } - if (binaries != NULL) - free(binaries); - if (binary_sizes != NULL) - free(binary_sizes); - if (devices != NULL) - free(devices); - } - - for (int i = 0; i <= GX_TF_CMPR; ++i) - { - if (g_DecodeParametersNative[i].name) - g_DecodeParametersNative[i].kernel = - OpenCL::CompileKernel(g_program, - g_DecodeParametersNative[i].name); - - if (g_DecodeParametersRGBA[i].name) - g_DecodeParametersRGBA[i].kernel = - OpenCL::CompileKernel(g_program, - g_DecodeParametersRGBA[i].name); - } - - // Allocating maximal Wii texture size in advance, so that we don't have to allocate/deallocate per texture -#ifndef DEBUG_OPENCL - g_clsrc = clCreateBuffer(OpenCL::GetContext(), CL_MEM_READ_ONLY , 1024 * 1024 * sizeof(u32), NULL, NULL); - g_cldst = clCreateBuffer(OpenCL::GetContext(), CL_MEM_WRITE_ONLY, 1024 * 1024 * sizeof(u32), NULL, NULL); -#endif - - g_Inited = true; - } -} - -void TexDecoder_OpenCL_Shutdown() -{ - if (g_program) - clReleaseProgram(g_program); - - for (int i = 0; i < GX_TF_CMPR; ++i) { - if (g_DecodeParametersNative[i].kernel) - clReleaseKernel(g_DecodeParametersNative[i].kernel); - - if(g_DecodeParametersRGBA[i].kernel) - clReleaseKernel(g_DecodeParametersRGBA[i].kernel); - } - - if(g_clsrc) - clReleaseMemObject(g_clsrc); - - if(g_cldst) - clReleaseMemObject(g_cldst); - - g_Inited = false; -} - -PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt, bool rgba) -{ - cl_int err; - sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat]; - if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE) - return PC_TEX_FMT_NONE; - -#ifdef DEBUG_OPENCL - g_clsrc = clCreateBuffer(OpenCL::GetContext(), CL_MEM_READ_ONLY , 1024 * 1024 * sizeof(u32), NULL, NULL); - g_cldst = clCreateBuffer(OpenCL::GetContext(), CL_MEM_WRITE_ONLY, 1024 * 1024 * sizeof(u32), NULL, NULL); -#endif - - clEnqueueWriteBuffer(OpenCL::GetCommandQueue(), g_clsrc, CL_TRUE, 0, (size_t)(width * height * decoder.sizeOfSrc), src, 0, NULL, NULL); - - clSetKernelArg(decoder.kernel, 0, sizeof(cl_mem), &g_cldst); - clSetKernelArg(decoder.kernel, 1, sizeof(cl_mem), &g_clsrc); - clSetKernelArg(decoder.kernel, 2, sizeof(cl_int), &width); - - size_t global[] = { (size_t)(width / decoder.xSkip), (size_t)(height / decoder.ySkip) }; - - // No work-groups for now - /* - size_t local; - err = clGetKernelWorkGroupInfo(kernelToRun, OpenCL::device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(local), &local, NULL); - if(err) - PanicAlert("Error obtaining work-group information"); - */ - - err = clEnqueueNDRangeKernel(OpenCL::GetCommandQueue(), decoder.kernel, 2, NULL, global, NULL, 0, NULL, NULL); - if(err) - OpenCL::HandleCLError(err, "Failed to enqueue kernel"); - - clFinish(OpenCL::GetCommandQueue()); - - clEnqueueReadBuffer(OpenCL::GetCommandQueue(), g_cldst, CL_TRUE, 0, (size_t)(width * height * decoder.sizeOfDst), dst, 0, NULL, NULL); - -#ifdef DEBUG_OPENCL - clReleaseMemObject(g_clsrc); - clReleaseMemObject(g_cldst); -#endif - - return decoder.format; -} diff --git a/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.h b/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.h deleted file mode 100644 index aacccd3885..0000000000 --- a/Source/Core/VideoCommon/Src/OpenCL/TextureDecoder_OpenCL.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#ifndef OPENCL_TEXTURE_DECODER -#define OPENCL_TEXTURE_DECODER -#include "Common.h" -#include "../TextureDecoder.h" - -void TexDecoder_OpenCL_Initialize(); -void TexDecoder_OpenCL_Shutdown(); - -PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt, bool rgba); - -#endif diff --git a/Source/Core/VideoCommon/Src/TextureDecoder_Generic.cpp b/Source/Core/VideoCommon/Src/TextureDecoder_Generic.cpp index a8c34cfac7..4b24409ce3 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder_Generic.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder_Generic.cpp @@ -20,8 +20,6 @@ #include "CPUDetect.h" #include "TextureDecoder.h" -#include "OpenCL.h" -#include "OpenCL/TextureDecoder_OpenCL.h" #include "VideoConfig.h" #include "LookUpTables.h" @@ -1060,15 +1058,12 @@ void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center) PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt,bool rgbaOnly) { - PC_TexFormat retval = TexDecoder_Decode_OpenCL(dst, src, - width, height, texformat, tlutaddr, tlutfmt, rgbaOnly); - if (retval == PC_TEX_FMT_NONE) - retval = rgbaOnly ? TexDecoder_Decode_RGBA((u32*)dst, src, - width, height, texformat, tlutaddr, tlutfmt) - : TexDecoder_Decode_real(dst, src, - width, height, texformat, tlutaddr, tlutfmt); - - if ((!TexFmt_Overlay_Enable)|| (retval == PC_TEX_FMT_NONE)) + PC_TexFormat retval = rgbaOnly ? TexDecoder_Decode_RGBA((u32*)dst, src, + width, height, texformat, tlutaddr, tlutfmt) + : TexDecoder_Decode_real(dst, src, + width, height, texformat, tlutaddr, tlutfmt); + + if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE)) return retval; int w = min(width, 40); diff --git a/Source/Core/VideoCommon/Src/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/Src/TextureDecoder_x64.cpp index f15a498e24..3913513206 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder_x64.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder_x64.cpp @@ -7,8 +7,6 @@ #include "CPUDetect.h" #include "TextureDecoder.h" -#include "OpenCL.h" -#include "OpenCL/TextureDecoder_OpenCL.h" #include "VideoConfig.h" #include "LookUpTables.h" @@ -2039,15 +2037,12 @@ void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center) PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt,bool rgbaOnly) { - PC_TexFormat retval = TexDecoder_Decode_OpenCL(dst, src, - width, height, texformat, tlutaddr, tlutfmt, rgbaOnly); - if (retval == PC_TEX_FMT_NONE) - retval = rgbaOnly ? TexDecoder_Decode_RGBA((u32*)dst, src, - width, height, texformat, tlutaddr, tlutfmt) - : TexDecoder_Decode_real(dst, src, - width, height, texformat, tlutaddr, tlutfmt); - - if ((!TexFmt_Overlay_Enable)|| (retval == PC_TEX_FMT_NONE)) + PC_TexFormat retval = rgbaOnly ? TexDecoder_Decode_RGBA((u32*)dst, src, + width, height, texformat, tlutaddr, tlutfmt) + : TexDecoder_Decode_real(dst, src, + width, height, texformat, tlutaddr, tlutfmt); + + if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE)) return retval; int w = min(width, 40); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 93840d7586..bd9fc015ac 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -81,7 +81,6 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Settings", "WireFrame", &bWireFrame, 0); iniFile.Get("Settings", "DisableFog", &bDisableFog, 0); - iniFile.Get("Settings", "EnableOpenCL", &bEnableOpenCL, false); iniFile.Get("Settings", "OMPDecoder", &bOMPDecoder, false); iniFile.Get("Settings", "EnableShaderDebugging", &bEnableShaderDebugging, false); @@ -184,7 +183,6 @@ void VideoConfig::GameIniLoad() CHECK_SETTING("Video_Settings", "DstAlphaPass", bDstAlphaPass); CHECK_SETTING("Video_Settings", "DisableFog", bDisableFog); - CHECK_SETTING("Video_Settings", "EnableOpenCL", bEnableOpenCL); CHECK_SETTING("Video_Settings", "OMPDecoder", bOMPDecoder); CHECK_SETTING("Video_Enhancements", "ForceFiltering", bForceFiltering); @@ -265,7 +263,6 @@ void VideoConfig::Save(const char *ini_file) iniFile.Set("Settings", "DstAlphaPass", bDstAlphaPass); iniFile.Set("Settings", "DisableFog", bDisableFog); - iniFile.Set("Settings", "EnableOpenCL", bEnableOpenCL); iniFile.Set("Settings", "OMPDecoder", bOMPDecoder); iniFile.Set("Settings", "EnableShaderDebugging", bEnableShaderDebugging); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 4e597e6235..f53551d9a0 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -66,8 +66,7 @@ struct VideoConfig bool bUseXFB; bool bUseRealXFB; - // OpenCL/OpenMP - bool bEnableOpenCL; + // OpenMP bool bOMPDecoder; // Enhancements diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 264159def0..c1df8c2810 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -63,8 +63,6 @@ <ClCompile Include="Src\memcpy_amd.cpp" /> <ClCompile Include="Src\OnScreenDisplay.cpp" /> <ClCompile Include="Src\OpcodeDecoding.cpp" /> - <ClCompile Include="Src\OpenCL.cpp" /> - <ClCompile Include="Src\OpenCL\TextureDecoder_OpenCL.cpp" /> <ClCompile Include="Src\PerfQueryBase.cpp" /> <ClCompile Include="Src\PixelEngine.cpp" /> <ClCompile Include="Src\PixelShaderGen.cpp" /> @@ -116,8 +114,6 @@ <ClInclude Include="Src\NativeVertexFormat.h" /> <ClInclude Include="Src\OnScreenDisplay.h" /> <ClInclude Include="Src\OpcodeDecoding.h" /> - <ClInclude Include="Src\OpenCL.h" /> - <ClInclude Include="Src\OpenCL\TextureDecoder_OpenCL.h" /> <ClInclude Include="Src\PerfQueryBase.h" /> <ClInclude Include="Src\PixelEngine.h" /> <ClInclude Include="Src\PixelShaderGen.h" /> @@ -149,9 +145,6 @@ <Text Include="CMakeLists.txt" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\..\Externals\CLRun\clrun\CLRun.vcxproj"> - <Project>{aa862e5e-a993-497a-b6a0-0e8e94b10050}</Project> - </ProjectReference> <ProjectReference Include="..\..\..\Externals\libpng\png\png.vcxproj"> <Project>{4c9f135b-a85e-430c-bad4-4c67ef5fc12c}</Project> </ProjectReference> diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters index 96503ba0e0..c0fefdf7b1 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters @@ -7,9 +7,6 @@ <Filter Include="Decoding"> <UniqueIdentifier>{2baa29c2-a528-4981-abcb-e0842c311f63}</UniqueIdentifier> </Filter> - <Filter Include="Decoding\OpenCL"> - <UniqueIdentifier>{f32547ad-f1c1-4e47-9ded-c07f66de2100}</UniqueIdentifier> - </Filter> <Filter Include="Register Sections"> <UniqueIdentifier>{6a88e4a0-754c-43df-98e6-405c99cd2ca7}</UniqueIdentifier> </Filter> @@ -57,12 +54,6 @@ <ClCompile Include="Src\VertexManagerBase.cpp"> <Filter>Base</Filter> </ClCompile> - <ClCompile Include="Src\OpenCL.cpp"> - <Filter>Decoding\OpenCL</Filter> - </ClCompile> - <ClCompile Include="Src\OpenCL\TextureDecoder_OpenCL.cpp"> - <Filter>Decoding\OpenCL</Filter> - </ClCompile> <ClCompile Include="Src\Fifo.cpp"> <Filter>Decoding</Filter> </ClCompile> @@ -184,12 +175,6 @@ <ClInclude Include="Src\VertexManagerBase.h"> <Filter>Base</Filter> </ClInclude> - <ClInclude Include="Src\OpenCL\TextureDecoder_OpenCL.h"> - <Filter>Decoding\OpenCL</Filter> - </ClInclude> - <ClInclude Include="Src\OpenCL.h"> - <Filter>Decoding\OpenCL</Filter> - </ClInclude> <ClInclude Include="Src\Fifo.h"> <Filter>Decoding</Filter> </ClInclude> |
