From 3005adffc308960a357b7dc9a5d091682f88cced Mon Sep 17 00:00:00 2001 From: Twinaphex512 Date: Wed, 14 Nov 2012 01:13:08 +0100 Subject: [PATCH] (D3D driver) Add HAVE_CG defines --- gfx/d3d9/d3d9.cpp | 18 +++++++++++++++++- gfx/d3d9/d3d9.hpp | 5 +++++ gfx/d3d9/render_chain.hpp | 6 ++++++ msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 4 ++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gfx/d3d9/d3d9.cpp b/gfx/d3d9/d3d9.cpp index 2504715c7c..cf5b43c12c 100644 --- a/gfx/d3d9/d3d9.cpp +++ b/gfx/d3d9/d3d9.cpp @@ -1,5 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * Copyright (C) 2012 - OV2 * * RetroArch 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 Found- @@ -36,6 +38,9 @@ #define IDI_ICON 1 #define MAX_MONITORS 9 +/* TODO: Make Cg optional - same as in the GL driver where we can either bake in + * GLSL, Cg or HLSL shader support */ + namespace Monitor { static HMONITOR last_hm; @@ -170,8 +175,10 @@ void D3DVideo::init(const video_info_t &info) calculate_rect(screen_width, screen_height, info.force_aspect, g_settings.video.aspect_ratio); +#ifdef HAVE_CG if (!init_cg()) throw std::runtime_error("Failed to init Cg"); +#endif if (!init_chain(info)) throw std::runtime_error("Failed to init render chain"); if (!init_font()) @@ -547,6 +554,7 @@ void D3DVideo::process() } } +#ifdef HAVE_CG bool D3DVideo::init_cg() { cgCtx = cgCreateContext(); @@ -572,20 +580,26 @@ void D3DVideo::deinit_cg() cgCtx = nullptr; } } +#endif void D3DVideo::init_chain_singlepass(const video_info_t &video_info) { LinkInfo info = {0}; LinkInfo info_second = {0}; +#ifdef HAVE_CG if (cg_shader.empty()) { auto shader_type = g_settings.video.shader_type; - if ((shader_type == RARCH_SHADER_CG || shader_type == RARCH_SHADER_AUTO) && *g_settings.video.cg_shader_path) + if (( + shader_type == RARCH_SHADER_CG || + shader_type == RARCH_SHADER_AUTO) && *g_settings.video.cg_shader_path) cg_shader = g_settings.video.cg_shader_path; } info.shader_path = cg_shader; +#endif + bool second_pass = g_settings.video.render_to_texture; if (second_pass) @@ -1174,11 +1188,13 @@ static bool d3d9_read_viewport(void *data, uint8_t *buffer) static bool d3d9_set_shader(void *data, enum rarch_shader_type type, const char *path) { +#ifdef HAVE_CG if (type != RARCH_SHADER_CG) { RARCH_ERR("[D3D9]: Only Cg shaders supported.\n"); return false; } +#endif return reinterpret_cast(data)->set_shader(path); } diff --git a/gfx/d3d9/d3d9.hpp b/gfx/d3d9/d3d9.hpp index b0bda8f911..8e7d274fad 100644 --- a/gfx/d3d9/d3d9.hpp +++ b/gfx/d3d9/d3d9.hpp @@ -22,8 +22,11 @@ #include #include #include + +#ifdef HAVE_CG #include #include +#endif #include #include #include @@ -78,9 +81,11 @@ class D3DVideo bool needs_restore; bool restore(); +#ifdef HAVE_CG CGcontext cgCtx; bool init_cg(); void deinit_cg(); +#endif void init_imports(ConfigFile &conf, const std::string &basedir); void init_luts(ConfigFile &conf, const std::string &basedir); diff --git a/gfx/d3d9/render_chain.hpp b/gfx/d3d9/render_chain.hpp index 9a3055bb98..51231a126d 100644 --- a/gfx/d3d9/render_chain.hpp +++ b/gfx/d3d9/render_chain.hpp @@ -50,7 +50,9 @@ class RenderChain RenderChain(const video_info_t &video_info, IDirect3DDevice9 *dev, +#ifdef HAVE_CG CGcontext cgCtx, +#endif const LinkInfo &info, PixelFormat fmt, const D3DVIEWPORT9 &final_viewport); @@ -73,7 +75,9 @@ class RenderChain private: IDirect3DDevice9 *dev; +#ifdef HAVE_CG CGcontext cgCtx; +#endif unsigned pixel_size; const video_info_t &video_info; @@ -98,7 +102,9 @@ class RenderChain LinkInfo info; IDirect3DTexture9 *tex; IDirect3DVertexBuffer9 *vertex_buf; +#ifdef HAVE_CG CGprogram vPrg, fPrg; +#endif unsigned last_width, last_height; IDirect3DVertexDeclaration9 *vertex_decl; diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 719ed9cab2..52f34aad07 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -90,7 +90,7 @@ Level3 Disabled - WIN32;HAVE_WIN32_D3D9;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_CONFIGFILE;HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_DINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;PACKAGE_VERSION="0.9.8-beta2";_CRT_SECURE_NO_WARNINGS + WIN32;HAVE_WIN32_D3D9;HAVE_CG;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_CONFIGFILE;HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_DINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;PACKAGE_VERSION="0.9.8-beta2";_CRT_SECURE_NO_WARNINGS $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -126,7 +126,7 @@ MaxSpeed true true - WIN32;HAVE_WIN32_D3D9;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_CONFIGFILE;HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_DINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;PACKAGE_VERSION="0.9.8-beta2";_CRT_SECURE_NO_WARNINGS + WIN32;HAVE_WIN32_D3D9;HAVE_CG;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_CONFIGFILE;HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_DINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;PACKAGE_VERSION="0.9.8-beta2";_CRT_SECURE_NO_WARNINGS $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp