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/
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__); }
34 HRESULT
Create(HWND wnd
);
37 extern ID3D11Device
* device
;
38 extern ID3D11DeviceContext
* context
;
39 extern IDXGISwapChain
* swapchain
;
40 extern bool bFrameInProgress
;
47 unsigned int GetBackBufferWidth();
48 unsigned int GetBackBufferHeight();
49 D3DTexture2D
* &GetBackBuffer();
50 const char* PixelShaderVersionString();
51 const char* VertexShaderVersionString();
52 bool BGRATexturesSupported();
54 unsigned int GetMaxTextureSize();
56 // Ihis function will assign a name to the given resource.
57 // The DirectX debug layer will make it easier to identify resources that way,
58 // e.g. when listing up all resources who have unreleased references.
59 inline void SetDebugObjectName(ID3D11DeviceChild
* resource
, const char* name
)
61 #if defined(_DEBUG) || defined(DEBUGFAST)
62 resource
->SetPrivateData( WKPDID_D3DDebugObjectName
, strlen(name
), name
);
69 // Used to not require the SDK and runtime versions to match:
70 // Linking with d3dx11.lib makes the most recent d3dx11_xx.dll of the
71 // compiler's SDK a requirement, but this plugin works with DX11 runtimes
72 // back to August 2009 even if the plugin was built with June 2010.
73 // Add any d3dx11 functions which you want to use here and load them in Create()
74 typedef HRESULT (WINAPI
* D3DX11COMPILEFROMMEMORYTYPE
)(LPCSTR
, SIZE_T
, LPCSTR
, const D3D10_SHADER_MACRO
*, LPD3D10INCLUDE
, LPCSTR
, LPCSTR
, UINT
, UINT
, ID3DX11ThreadPump
*, ID3D10Blob
**, ID3D10Blob
**, HRESULT
*);
75 typedef HRESULT (WINAPI
* D3DX11FILTERTEXTURETYPE
)(ID3D11DeviceContext
*, ID3D11Resource
*, UINT
, UINT
);
76 typedef HRESULT (WINAPI
* D3DX11SAVETEXTURETOFILEATYPE
)(ID3D11DeviceContext
*, ID3D11Resource
*, D3DX11_IMAGE_FILE_FORMAT
, LPCSTR
);
77 typedef HRESULT (WINAPI
* D3DX11SAVETEXTURETOFILEWTYPE
)(ID3D11DeviceContext
*, ID3D11Resource
*, D3DX11_IMAGE_FILE_FORMAT
, LPCWSTR
);
79 extern D3DX11COMPILEFROMMEMORYTYPE PD3DX11CompileFromMemory
;
80 extern D3DX11FILTERTEXTURETYPE PD3DX11FilterTexture
;
81 extern D3DX11SAVETEXTURETOFILEATYPE PD3DX11SaveTextureToFileA
;
82 extern D3DX11SAVETEXTURETOFILEWTYPE PD3DX11SaveTextureToFileW
;
85 #define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileW
87 #define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileA