Load the d3dx11 dll at runtime instead of linking directly against it. Should make...
[dolphin.git] / Source / Plugins / Plugin_VideoDX11 / Src / D3DBase.h
blob4331b6e5244aecb72f6024844e3e61cb18cf5e8f
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 #pragma once
20 #include <d3dx11.h>
21 #include "Common.h"
22 #include "D3DBlob.h"
23 #include "GfxState.h"
25 #define SAFE_RELEASE(x) { if (x) (x)->Release(); (x) = NULL; }
26 #define SAFE_DELETE(x) { delete (x); (x) = NULL; }
27 #define SAFE_DELETE_ARRAY(x) { delete[] (x); (x) = NULL; }
28 #define CHECK(cond, Message, ...) if (!(cond)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: " Message, __FILE__, __LINE__, __VA_ARGS__); }
30 class D3DTexture2D;
31 namespace D3D
34 HRESULT Create(HWND wnd);
35 void Close();
37 extern ID3D11Device* device;
38 extern ID3D11DeviceContext* context;
39 extern IDXGISwapChain* swapchain;
40 extern bool bFrameInProgress;
42 void Reset();
43 bool BeginFrame();
44 void EndFrame();
45 void Present();
47 unsigned int GetBackBufferWidth();
48 unsigned int GetBackBufferHeight();
49 D3DTexture2D* &GetBackBuffer();
50 const char* PixelShaderVersionString();
51 const char* VertexShaderVersionString();
52 bool BGRATexturesSupported();
54 // Ihis function will assign a name to the given resource.
55 // The DirectX debug layer will make it easier to identify resources that way,
56 // e.g. when listing up all resources who have unreleased references.
57 inline void SetDebugObjectName(ID3D11DeviceChild* resource, const char* name)
59 #if defined(_DEBUG) || defined(DEBUGFAST)
60 resource->SetPrivateData( WKPDID_D3DDebugObjectName, strlen(name), name);
61 #endif
64 } // namespace
67 // Used to not require the SDK and runtime versions to match:
68 // Linking with d3dx11.lib makes the most recent d3dx11_xx.dll of the
69 // compiler's SDK a requirement, but this plugin works with DX11 runtimes
70 // back to August 2009 even if the plugin was built with June 2010.
71 // Add any d3dx11 functions which you want to use here and load them in Create()
72 typedef HRESULT (WINAPI* D3DX11FILTERTEXTURETYPE)(ID3D11DeviceContext*, ID3D11Resource*, UINT, UINT);
73 typedef HRESULT (WINAPI* D3DX11SAVETEXTURETOFILEATYPE)(ID3D11DeviceContext*, ID3D11Resource*, D3DX11_IMAGE_FILE_FORMAT, LPCSTR);
74 typedef HRESULT (WINAPI* D3DX11SAVETEXTURETOFILEWTYPE)(ID3D11DeviceContext*, ID3D11Resource*, D3DX11_IMAGE_FILE_FORMAT, LPCWSTR);
76 extern D3DX11FILTERTEXTURETYPE PD3DX11FilterTexture;
77 extern D3DX11SAVETEXTURETOFILEATYPE PD3DX11SaveTextureToFileA;
78 extern D3DX11SAVETEXTURETOFILEWTYPE PD3DX11SaveTextureToFileW;
80 #ifdef UNICODE
81 #define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileW
82 #else
83 #define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileA
84 #endif