added video_core project to solution

master
bunnei 2014-04-05 16:04:25 +07:00
parent 89fd6eb237
commit 23506defe3
9 changed files with 578 additions and 1 deletions

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "src\common\common.vcxproj", "{DFE335FC-755D-4BAA-8452-94434F8A1EDB}"
@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scm_rev_gen", "src\common\s
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "citra_qt", "src\citra_qt\citra_qt.vcxproj", "{A587F714-490F-407A-9E36-7AB7FA0D7BAB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "video_core", "src\video_core\video_core.vcxproj", "{6678D1A3-33A6-48A9-878B-48E5D2903D27}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -69,6 +71,14 @@ Global
{A587F714-490F-407A-9E36-7AB7FA0D7BAB}.Release|Win32.Build.0 = Release|Win32
{A587F714-490F-407A-9E36-7AB7FA0D7BAB}.Release|x64.ActiveCfg = Release|x64
{A587F714-490F-407A-9E36-7AB7FA0D7BAB}.Release|x64.Build.0 = Release|x64
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Debug|Win32.ActiveCfg = Debug|Win32
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Debug|Win32.Build.0 = Debug|Win32
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Debug|x64.ActiveCfg = Debug|x64
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Debug|x64.Build.0 = Debug|x64
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Release|Win32.ActiveCfg = Release|Win32
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Release|Win32.Build.0 = Release|Win32
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Release|x64.ActiveCfg = Release|x64
{6678D1A3-33A6-48A9-878B-48E5D2903D27}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,19 @@
set(SRCS
src/bp_mem.cpp
src/cp_mem.cpp
src/xf_mem.cpp
src/fifo.cpp
src/fifo_player.cpp
src/vertex_loader.cpp
src/vertex_manager.cpp
src/video_core.cpp
src/shader_manager.cpp
src/texture_decoder.cpp
src/texture_manager.cpp
src/utils.cpp
src/renderer_gl3/renderer_gl3.cpp
src/renderer_gl3/shader_interface.cpp
src/renderer_gl3/texture_interface.cpp
src/renderer_gl3/uniform_manager.cpp)
add_library(video_core STATIC ${SRCS})

@ -0,0 +1,116 @@
/**
* Copyright (C) 2014 Citra Emulator
*
* @file renderer_base.h
* @author bunnei
* @date 2014-04-05
* @brief Renderer base class for new video core
*
* @section LICENSE
* 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; either version 2 of
* the License, or (at your option) any later version.
*
* 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 for more details at
* http://www.gnu.org/copyleft/gpl.html
*
* Official project repository can be found at:
* http://code.google.com/p/gekko-gc-emu/
*/
#pragma once
#include "common.h"
#include "hash.h"
class RendererBase {
public:
/// Used to reference a framebuffer
enum kFramebuffer {
kFramebuffer_VirtualXFB = 0,
kFramebuffer_EFB,
kFramebuffer_Texture
};
/// Used for referencing the render modes
enum kRenderMode {
kRenderMode_None = 0,
kRenderMode_Multipass = 1,
kRenderMode_ZComp = 2,
kRenderMode_UseDstAlpha = 4
};
RendererBase() : current_fps_(0), current_frame_(0) {
}
~RendererBase() {
}
/**
* Blits the EFB to the external framebuffer (XFB)
* @param src_rect Source rectangle in EFB to copy
* @param dst_rect Destination rectangle in EFB to copy to
* @param dest_height Destination height in pixels
*/
virtual void CopyToXFB(const Rect& src_rect, const Rect& dst_rect) = 0;
/**
* Clear the screen
* @param rect Screen rectangle to clear
* @param enable_color Enable color clearing
* @param enable_alpha Enable alpha clearing
* @param enable_z Enable depth clearing
* @param color Clear color
* @param z Clear depth
*/
virtual void Clear(const Rect& rect, bool enable_color, bool enable_alpha, bool enable_z,
u32 color, u32 z) = 0;
/**
* Set a specific render mode
* @param flag Render flags mode to enable
*/
virtual void SetMode(kRenderMode flags) = 0;
/// Reset the full renderer API to the NULL state
virtual void ResetRenderState() = 0;
/// Restore the full renderer API state - As the game set it
virtual void RestoreRenderState() = 0;
/**
* Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering
*/
virtual void SetWindow(EmuWindow* window) = 0;
/// Initialize the renderer
virtual void Init() = 0;
/// Shutdown the renderer
virtual void ShutDown() = 0;
/// Converts EFB rectangle coordinates to renderer rectangle coordinates
//static Rect EFBToRendererRect(const Rect& rect) {
// return Rect(rect.x0_, kGCEFBHeight - rect.y0_, rect.x1_, kGCEFBHeight - rect.y1_);
//}
// Getter/setter functions:
// ------------------------
f32 current_fps() const { return current_fps_; }
int current_frame() const { return current_frame_; }
protected:
f32 current_fps_; ///< Current framerate, should be set by the renderer
int current_frame_; ///< Current frame, should be set by the renderer
private:
DISALLOW_COPY_AND_ASSIGN(RendererBase);
};

@ -0,0 +1,66 @@
/**
* Copyright (C) 2005-2012 Gekko Emulator
*
* @file utils.cpp
* @author ShizZy <shizzy247@gmail.com>
* @date 2012-12-28
* @brief Utility functions (in general, not related to emulation) useful for video core
*
* @section LICENSE
* 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; either version 2 of
* the License, or (at your option) any later version.
*
* 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 for more details at
* http://www.gnu.org/copyleft/gpl.html
*
* Official project repository can be found at:
* http://code.google.com/p/gekko-gc-emu/
*/
#include <stdio.h>
#include <string.h>
#include "utils.h"
namespace VideoCore {
/**
* Dumps a texture to TGA
* @param filename String filename to dump texture to
* @param width Width of texture in pixels
* @param height Height of texture in pixels
* @param raw_data Raw RGBA8 texture data to dump
* @todo This should be moved to some general purpose/common code
*/
void DumpTGA(std::string filename, int width, int height, u8* raw_data) {
TGAHeader hdr;
FILE* fout;
u8 r, g, b;
memset(&hdr, 0, sizeof(hdr));
hdr.datatypecode = 2; // uncompressed RGB
hdr.bitsperpixel = 24; // 24 bpp
hdr.width = width;
hdr.height = height;
fout = fopen(filename.c_str(), "wb");
fwrite(&hdr, sizeof(TGAHeader), 1, fout);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = raw_data[(4 * (i * width)) + (4 * j) + 0];
g = raw_data[(4 * (i * width)) + (4 * j) + 1];
b = raw_data[(4 * (i * width)) + (4 * j) + 2];
putc(b, fout);
putc(g, fout);
putc(r, fout);
}
}
fclose(fout);
}
} // namespace

@ -0,0 +1,83 @@
/**
* Copyright (C) 2005-2012 Gekko Emulator
*
* @file utils.h
* @author ShizZy <shizzy247@gmail.com>
* @date 2012-12-28
* @brief Utility functions (in general, not related to emulation) useful for video core
*
* @section LICENSE
* 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; either version 2 of
* the License, or (at your option) any later version.
*
* 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 for more details at
* http://www.gnu.org/copyleft/gpl.html
*
* Official project repository can be found at:
* http://code.google.com/p/gekko-gc-emu/
*/
#pragma once
#include "common_types.h"
#include <string>
namespace FormatPrecision {
/// Adjust RGBA8 color with RGBA6 precision
static inline u32 rgba8_with_rgba6(u32 src) {
u32 color = src;
color &= 0xFCFCFCFC;
color |= (color >> 6) & 0x03030303;
return color;
}
/// Adjust RGBA8 color with RGB565 precision
static inline u32 rgba8_with_rgb565(u32 src) {
u32 color = (src & 0xF8FCF8);
color |= (color >> 5) & 0x070007;
color |= (color >> 6) & 0x000300;
color |= 0xFF000000;
return color;
}
/// Adjust Z24 depth value with Z16 precision
static inline u32 z24_with_z16(u32 src) {
return (src & 0xFFFF00) | (src >> 16);
}
} // namespace
namespace VideoCore {
/// Structure for the TGA texture format (for dumping)
struct TGAHeader {
char idlength;
char colourmaptype;
char datatypecode;
short int colourmaporigin;
short int colourmaplength;
short int x_origin;
short int y_origin;
short width;
short height;
char bitsperpixel;
char imagedescriptor;
};
/**
* Dumps a texture to TGA
* @param filename String filename to dump texture to
* @param width Width of texture in pixels
* @param height Height of texture in pixels
* @param raw_data Raw RGBA8 texture data to dump
* @todo This should be moved to some general purpose/common code
*/
void DumpTGA(std::string filename, int width, int height, u8* raw_data);
} // namespace

@ -0,0 +1,91 @@
/**
* Copyright (C) 2014 Citra Emulator
*
* @file video_core.cpp
* @author bunnei
* @date 2014-04-05
* @brief Main module for new video core
*
* @section LICENSE
* 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; either version 2 of
* the License, or (at your option) any later version.
*
* 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 for more details at
* http://www.gnu.org/copyleft/gpl.html
*
* Official project repository can be found at:
* http://code.google.com/p/gekko-gc-emu/
*/
#include "common.h"
#include "emu_window.h"
#include "log.h"
#include "core.h"
#include "video_core.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Video Core namespace
namespace VideoCore {
EmuWindow* g_emu_window = NULL; ///< Frontend emulator window
RendererBase* g_renderer = NULL; ///< Renderer plugin
int g_current_frame = 0;
int VideoEntry(void*) {
if (g_emu_window == NULL) {
ERROR_LOG(VIDEO, "VideoCore::VideoEntry called without calling Init()!");
}
g_emu_window->MakeCurrent();
//for(;;) {
// gp::Fifo_DecodeCommand();
//}
return 0;
}
/// Start the video core
void Start() {
if (g_emu_window == NULL) {
ERROR_LOG(VIDEO, "VideoCore::Start called without calling Init()!");
}
//if (common::g_config->enable_multicore()) {
// g_emu_window->DoneCurrent();
// g_video_thread = SDL_CreateThread(VideoEntry, NULL, NULL);
// if (g_video_thread == NULL) {
// LOG_ERROR(TVIDEO, "Unable to create thread: %s... Exiting\n", SDL_GetError());
// exit(1);
// }
//}
}
/// Initialize the video core
void Init(EmuWindow* emu_window) {
g_emu_window = emu_window;
//g_renderer = new RendererGL3();
//g_renderer->SetWindow(g_emu_window);
//g_renderer->Init();
//gp::Fifo_Init();
//gp::VertexManager_Init();
//gp::VertexLoader_Init();
//gp::BP_Init();
//gp::CP_Init();
//gp::XF_Init();
g_current_frame = 0;
NOTICE_LOG(VIDEO, "initialized ok");
}
/// Shutdown the video core
void Shutdown() {
//delete g_renderer;
}
} // namespace

@ -0,0 +1,48 @@
/*!
* Copyright (C) 2014 Citra Emulator
*
* @file video_core.h
* @author bunnei
* @date 2014-04-05
* @brief Main module for new video core
*
* @section LICENSE
* 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; either version 2 of
* the License, or (at your option) any later version.
*
* 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 for more details at
* http://www.gnu.org/copyleft/gpl.html
*
* Official project repository can be found at:
* http://code.google.com/p/gekko-gc-emu/
*/
#pragma once
#include "common.h"
#include "emu_window.h"
#include "renderer_base.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Video Core namespace
namespace VideoCore {
extern RendererBase* g_renderer; ///< Renderer plugin
extern int g_current_frame; ///< Current frame
/// Start the video core
void Start();
/// Initialize the video core
void Init(EmuWindow* emu_window);
/// Shutdown the video core
void ShutDown();
} // namespace

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\utils.cpp" />
<ClCompile Include="src\video_core.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\renderer_base.h" />
<ClInclude Include="src\utils.h" />
<ClInclude Include="src\video_core.h" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6678D1A3-33A6-48A9-878B-48E5D2903D27}</ProjectGuid>
<RootNamespace>input_common</RootNamespace>
<ProjectName>video_core</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\vsprops\Base.props" />
<Import Project="..\..\vsprops\code_generation_debug.props" />
<Import Project="..\..\vsprops\optimization_debug.props" />
<Import Project="..\..\vsprops\externals.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\vsprops\Base.props" />
<Import Project="..\..\vsprops\code_generation_debug.props" />
<Import Project="..\..\vsprops\optimization_debug.props" />
<Import Project="..\..\vsprops\externals.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\vsprops\Base.props" />
<Import Project="..\..\vsprops\code_generation_release.props" />
<Import Project="..\..\vsprops\optimization_release.props" />
<Import Project="..\..\vsprops\externals.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\vsprops\Base.props" />
<Import Project="..\..\vsprops\code_generation_release.props" />
<Import Project="..\..\vsprops\optimization_release.props" />
<Import Project="..\..\vsprops\externals.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile />
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile />
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile />
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<ClCompile />
<ClCompile />
<ClCompile />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile />
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="src\video_core.cpp" />
<ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\renderer_base.h" />
<ClInclude Include="src\video_core.h" />
<ClInclude Include="src\utils.h" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>