Added GPU SoftBody constraint solvers for DirectX 11 (Direct Compute) and OpenCL, thanks to AMD.
See also http://code.google.com/p/bullet/issues/detail?id=390 Added Demos/DX11ClothDemo (an OpenCL cloth demo will follow soon)
This commit is contained in:
5846
Demos/DX11ClothDemo/DXUT/Core/DXUT.cpp
Normal file
5846
Demos/DX11ClothDemo/DXUT/Core/DXUT.cpp
Normal file
File diff suppressed because it is too large
Load Diff
378
Demos/DX11ClothDemo/DXUT/Core/DXUT.h
Normal file
378
Demos/DX11ClothDemo/DXUT/Core/DXUT.h
Normal file
@@ -0,0 +1,378 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: DXUT.h
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//--------------------------------------------------------------------------------------
|
||||
#pragma once
|
||||
#ifndef DXUT_H
|
||||
#define DXUT_H
|
||||
|
||||
#ifndef UNICODE
|
||||
#error "DXUT requires a Unicode build. See the nearby comments for details"
|
||||
//
|
||||
// If you are using Microsoft Visual C++ .NET, under the General tab of the project
|
||||
// properties change the Character Set to 'Use Unicode Character Set'.
|
||||
//
|
||||
// Windows XP and later are native Unicode so Unicode applications will perform better.
|
||||
// For Windows 98 and Windows Me support, consider using the Microsoft Layer for Unicode (MSLU).
|
||||
//
|
||||
// To use MSLU, link against a set of libraries similar to this
|
||||
// /nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib UnicoWS.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib dxerr.lib dxguid.lib d3dx9d.lib d3d9.lib comctl32.lib
|
||||
// and put the unicows.dll (available for download from msdn.microsoft.com) in the exe's folder.
|
||||
//
|
||||
// For more details see the MSDN article titled:
|
||||
// "MSLU: Develop Unicode Applications for Windows 9x Platforms with the Microsoft Layer for Unicode"
|
||||
// at http://msdn.microsoft.com/msdnmag/issues/01/10/MSLU/default.aspx
|
||||
//
|
||||
#endif
|
||||
|
||||
#include "dxsdkver.h"
|
||||
#if ( _DXSDK_PRODUCT_MAJOR < 9 || _DXSDK_BUILD_MAJOR < 1455 )
|
||||
#error The installed DXSDK is out of date.
|
||||
#endif
|
||||
|
||||
#ifndef STRICT
|
||||
#define STRICT
|
||||
#endif
|
||||
|
||||
// If app hasn't choosen, set to work with Windows 98, Windows Me, Windows 2000, Windows XP and beyond
|
||||
#ifndef WINVER
|
||||
#define WINVER 0x0500
|
||||
#endif
|
||||
#ifndef _WIN32_WINDOWS
|
||||
#define _WIN32_WINDOWS 0x0500
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
||||
// #define DXUT_AUTOLIB to automatically include the libs needed for DXUT
|
||||
#ifdef DXUT_AUTOLIB
|
||||
#pragma comment( lib, "dxerr.lib" )
|
||||
#pragma comment( lib, "dxguid.lib" )
|
||||
#pragma comment( lib, "d3d9.lib" )
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#pragma comment( lib, "d3dx9d.lib" )
|
||||
#else
|
||||
#pragma comment( lib, "d3dx9.lib" )
|
||||
#endif
|
||||
#pragma comment( lib, "winmm.lib" )
|
||||
#pragma comment( lib, "comctl32.lib" )
|
||||
#endif
|
||||
|
||||
#pragma warning( disable : 4100 ) // disable unreference formal parameter warnings for /W4 builds
|
||||
|
||||
// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.
|
||||
// This makes D3D objects work well in the debugger watch window, but slows down
|
||||
// performance slightly.
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#ifndef D3D_DEBUG_INFO
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Standard Windows includes
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
#include <mmsystem.h>
|
||||
#include <commctrl.h> // for InitCommonControls()
|
||||
#include <shellapi.h> // for ExtractIcon()
|
||||
#include <new.h> // for placement new
|
||||
#include <shlobj.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// CRT's memory leak detection
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
// Direct3D9 includes
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
|
||||
// Direct3D11 includes
|
||||
#include <dxgi.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3dCompiler.h>
|
||||
#include <d3dx11.h>
|
||||
|
||||
// XInput includes
|
||||
#include <xinput.h>
|
||||
|
||||
// HRESULT translation for Direct3D10 and other APIs
|
||||
#include <dxerr.h>
|
||||
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#ifndef V
|
||||
#define V(x) { hr = (x); if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
|
||||
#endif
|
||||
#ifndef V_RETURN
|
||||
#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
|
||||
#endif
|
||||
#else
|
||||
#ifndef V
|
||||
#define V(x) { hr = (x); }
|
||||
#endif
|
||||
#ifndef V_RETURN
|
||||
#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return hr; } }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(p) { if (p) { delete (p); (p)=NULL; } }
|
||||
#endif
|
||||
#ifndef SAFE_DELETE_ARRAY
|
||||
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p)=NULL; } }
|
||||
#endif
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Structs
|
||||
//--------------------------------------------------------------------------------------
|
||||
struct DXUTD3D9DeviceSettings
|
||||
{
|
||||
UINT AdapterOrdinal;
|
||||
D3DDEVTYPE DeviceType;
|
||||
D3DFORMAT AdapterFormat;
|
||||
DWORD BehaviorFlags;
|
||||
D3DPRESENT_PARAMETERS pp;
|
||||
};
|
||||
|
||||
struct DXUTD3D11DeviceSettings
|
||||
{
|
||||
UINT AdapterOrdinal;
|
||||
D3D_DRIVER_TYPE DriverType;
|
||||
UINT Output;
|
||||
DXGI_SWAP_CHAIN_DESC sd;
|
||||
UINT32 CreateFlags;
|
||||
UINT32 SyncInterval;
|
||||
DWORD PresentFlags;
|
||||
bool AutoCreateDepthStencil; // DXUT will create the depth stencil resource and view if true
|
||||
DXGI_FORMAT AutoDepthStencilFormat;
|
||||
D3D_FEATURE_LEVEL DeviceFeatureLevel;
|
||||
};
|
||||
|
||||
enum DXUTDeviceVersion
|
||||
{
|
||||
DXUT_D3D9_DEVICE,
|
||||
DXUT_D3D11_DEVICE
|
||||
};
|
||||
|
||||
struct DXUTDeviceSettings
|
||||
{
|
||||
DXUTDeviceVersion ver;
|
||||
D3D_FEATURE_LEVEL MinimumFeatureLevel;
|
||||
DXUTD3D9DeviceSettings d3d9; // only valid if ver == DXUT_D3D9_DEVICE
|
||||
DXUTD3D11DeviceSettings d3d11; // only valid if ver == DXUT_D3D11_DEVICE
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Error codes
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define DXUTERR_NODIRECT3D MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901)
|
||||
#define DXUTERR_NOCOMPATIBLEDEVICES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902)
|
||||
#define DXUTERR_MEDIANOTFOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903)
|
||||
#define DXUTERR_NONZEROREFCOUNT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904)
|
||||
#define DXUTERR_CREATINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905)
|
||||
#define DXUTERR_RESETTINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906)
|
||||
#define DXUTERR_CREATINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907)
|
||||
#define DXUTERR_RESETTINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908)
|
||||
#define DXUTERR_DEVICEREMOVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x090A)
|
||||
#define DXUTERR_NODIRECT3D11 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x090)
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Callback registration
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// General callbacks
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKFRAMEMOVE)( double fTime, float fElapsedTime, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKKEYBOARD)( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKMOUSE)( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext );
|
||||
typedef LRESULT (CALLBACK *LPDXUTCALLBACKMSGPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKTIMER)( UINT idEvent, void* pUserContext );
|
||||
typedef bool (CALLBACK *LPDXUTCALLBACKMODIFYDEVICESETTINGS)( DXUTDeviceSettings* pDeviceSettings, void* pUserContext );
|
||||
typedef bool (CALLBACK *LPDXUTCALLBACKDEVICEREMOVED)( void* pUserContext );
|
||||
|
||||
// Direct3D 9 callbacks
|
||||
typedef bool (CALLBACK *LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE)( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );
|
||||
typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D9DEVICECREATED)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
||||
typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D9DEVICERESET)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D9FRAMERENDER)( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D9DEVICELOST)( void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D9DEVICEDESTROYED)( void* pUserContext );
|
||||
|
||||
class CD3D11EnumAdapterInfo;
|
||||
class CD3D11EnumDeviceInfo;
|
||||
// Direct3D 11 callbacks
|
||||
typedef bool (CALLBACK *LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE)( const CD3D11EnumAdapterInfo *AdapterInfo, UINT Output, const CD3D11EnumDeviceInfo *DeviceInfo, DXGI_FORMAT BackBufferFormat, bool bWindowed, void* pUserContext );
|
||||
typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D11DEVICECREATED)( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
||||
typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D11SWAPCHAINRESIZED)( ID3D11Device* pd3dDevice, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D11FRAMERENDER)( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime, float fElapsedTime, void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D11SWAPCHAINRELEASING)( void* pUserContext );
|
||||
typedef void (CALLBACK *LPDXUTCALLBACKD3D11DEVICEDESTROYED)( void* pUserContext );
|
||||
|
||||
// General callbacks
|
||||
void WINAPI DXUTSetCallbackFrameMove( LPDXUTCALLBACKFRAMEMOVE pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackKeyboard( LPDXUTCALLBACKKEYBOARD pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackMouse( LPDXUTCALLBACKMOUSE pCallback, bool bIncludeMouseMove = false, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackMsgProc( LPDXUTCALLBACKMSGPROC pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackDeviceChanging( LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackDeviceRemoved( LPDXUTCALLBACKDEVICEREMOVED pCallback, void* pUserContext = NULL );
|
||||
|
||||
// Direct3D 9 callbacks
|
||||
void WINAPI DXUTSetCallbackD3D9DeviceAcceptable( LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D9DeviceCreated( LPDXUTCALLBACKD3D9DEVICECREATED pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D9DeviceReset( LPDXUTCALLBACKD3D9DEVICERESET pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D9FrameRender( LPDXUTCALLBACKD3D9FRAMERENDER pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D9DeviceLost( LPDXUTCALLBACKD3D9DEVICELOST pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D9DeviceDestroyed( LPDXUTCALLBACKD3D9DEVICEDESTROYED pCallback, void* pUserContext = NULL );
|
||||
|
||||
// Direct3D 11 callbacks
|
||||
void WINAPI DXUTSetCallbackD3D11DeviceAcceptable( LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D11DeviceCreated( LPDXUTCALLBACKD3D11DEVICECREATED pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D11SwapChainResized( LPDXUTCALLBACKD3D11SWAPCHAINRESIZED pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D11FrameRender( LPDXUTCALLBACKD3D11FRAMERENDER pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D11SwapChainReleasing( LPDXUTCALLBACKD3D11SWAPCHAINRELEASING pCallback, void* pUserContext = NULL );
|
||||
void WINAPI DXUTSetCallbackD3D11DeviceDestroyed( LPDXUTCALLBACKD3D11DEVICEDESTROYED pCallback, void* pUserContext = NULL );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT WINAPI DXUTInit( bool bParseCommandLine = true,
|
||||
bool bShowMsgBoxOnError = true,
|
||||
__in_opt WCHAR* strExtraCommandLineParams = NULL,
|
||||
bool bThreadSafeDXUT = false );
|
||||
|
||||
// Choose either DXUTCreateWindow or DXUTSetWindow. If using DXUTSetWindow, consider using DXUTStaticWndProc
|
||||
HRESULT WINAPI DXUTCreateWindow( const WCHAR* strWindowTitle = L"Direct3D Window",
|
||||
HINSTANCE hInstance = NULL, HICON hIcon = NULL, HMENU hMenu = NULL,
|
||||
int x = CW_USEDEFAULT, int y = CW_USEDEFAULT );
|
||||
HRESULT WINAPI DXUTSetWindow( HWND hWndFocus, HWND hWndDeviceFullScreen, HWND hWndDeviceWindowed, bool bHandleMessages = true );
|
||||
LRESULT CALLBACK DXUTStaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
// Choose either DXUTCreateDevice or DXUTSetD3D*Device or DXUTCreateD3DDeviceFromSettings
|
||||
|
||||
HRESULT WINAPI DXUTCreateDevice(D3D_FEATURE_LEVEL reqFL, bool bWindowed= true, int nSuggestedWidth =0, int nSuggestedHeight =0 );
|
||||
HRESULT WINAPI DXUTCreateDeviceFromSettings( DXUTDeviceSettings* pDeviceSettings, bool bPreserveInput = false, bool bClipWindowToSingleAdapter = true );
|
||||
HRESULT WINAPI DXUTSetD3D9Device( IDirect3DDevice9* pd3dDevice );
|
||||
HRESULT WINAPI DXUTSetD3D11Device( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain );
|
||||
|
||||
// Choose either DXUTMainLoop or implement your own main loop
|
||||
HRESULT WINAPI DXUTMainLoop( HACCEL hAccel = NULL );
|
||||
|
||||
// If not using DXUTMainLoop consider using DXUTRender3DEnvironment
|
||||
void WINAPI DXUTRender3DEnvironment();
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Common Tasks
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT WINAPI DXUTToggleFullScreen();
|
||||
HRESULT WINAPI DXUTToggleREF();
|
||||
HRESULT WINAPI DXUTToggleWARP();
|
||||
void WINAPI DXUTPause( bool bPauseTime, bool bPauseRendering );
|
||||
void WINAPI DXUTSetConstantFrameTime( bool bConstantFrameTime, float fTimePerFrame = 0.0333f );
|
||||
void WINAPI DXUTSetCursorSettings( bool bShowCursorWhenFullScreen = false, bool bClipCursorWhenFullScreen = false );
|
||||
void WINAPI DXUTSetD3DVersionSupport( bool bAppCanUseD3D9 = true, bool bAppCanUseD3D11 = true );
|
||||
void WINAPI DXUTSetHotkeyHandling( bool bAltEnterToToggleFullscreen = true, bool bEscapeToQuit = true, bool bPauseToToggleTimePause = true );
|
||||
void WINAPI DXUTSetMultimonSettings( bool bAutoChangeAdapter = true );
|
||||
void WINAPI DXUTSetShortcutKeySettings( bool bAllowWhenFullscreen = false, bool bAllowWhenWindowed = true ); // Controls the Windows key, and accessibility shortcut keys
|
||||
void WINAPI DXUTSetWindowSettings( bool bCallDefWindowProc = true );
|
||||
HRESULT WINAPI DXUTSetTimer( LPDXUTCALLBACKTIMER pCallbackTimer, float fTimeoutInSecs = 1.0f, UINT* pnIDEvent = NULL, void* pCallbackUserContext = NULL );
|
||||
HRESULT WINAPI DXUTKillTimer( UINT nIDEvent );
|
||||
void WINAPI DXUTResetFrameworkState();
|
||||
void WINAPI DXUTShutdown( int nExitCode = 0 );
|
||||
void WINAPI DXUTSetIsInGammaCorrectMode( bool bGammaCorrect );
|
||||
BOOL WINAPI DXUTGetMSAASwapChainCreated();
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// State Retrieval
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Direct3D 9
|
||||
IDirect3D9* WINAPI DXUTGetD3D9Object(); // Does not addref unlike typical Get* APIs
|
||||
IDirect3DDevice9* WINAPI DXUTGetD3D9Device(); // Does not addref unlike typical Get* APIs
|
||||
D3DPRESENT_PARAMETERS WINAPI DXUTGetD3D9PresentParameters();
|
||||
const D3DSURFACE_DESC* WINAPI DXUTGetD3D9BackBufferSurfaceDesc();
|
||||
const D3DCAPS9* WINAPI DXUTGetD3D9DeviceCaps();
|
||||
HRESULT WINAPI DXUTGetD3D9DeviceCaps( DXUTDeviceSettings* pDeviceSettings, D3DCAPS9* pCaps );
|
||||
bool WINAPI DXUTDoesAppSupportD3D9();
|
||||
bool WINAPI DXUTIsAppRenderingWithD3D9();
|
||||
|
||||
|
||||
// Direct3D 11
|
||||
IDXGIFactory1* WINAPI DXUTGetDXGIFactory(); // Does not addref unlike typical Get* APIs
|
||||
IDXGISwapChain* WINAPI DXUTGetDXGISwapChain(); // Does not addref unlike typical Get* APIs
|
||||
const DXGI_SURFACE_DESC* WINAPI DXUTGetDXGIBackBufferSurfaceDesc();
|
||||
bool WINAPI DXUTIsD3D11Available(); // If D3D11 APIs are availible
|
||||
ID3D11Device* WINAPI DXUTGetD3D11Device(); // Does not addref unlike typical Get* APIs
|
||||
ID3D11DeviceContext* WINAPI DXUTGetD3D11DeviceContext(); // Does not addref unlike typical Get* APIs
|
||||
HRESULT WINAPI DXUTSetupD3D11Views( ID3D11DeviceContext* pd3dDeviceContext ); // Supports immediate or deferred context
|
||||
D3D_FEATURE_LEVEL WINAPI DXUTGetD3D11DeviceFeatureLevel(); // Returns the D3D11 devices current feature level
|
||||
ID3D11RenderTargetView* WINAPI DXUTGetD3D11RenderTargetView(); // Does not addref unlike typical Get* APIs
|
||||
ID3D11DepthStencilView* WINAPI DXUTGetD3D11DepthStencilView(); // Does not addref unlike typical Get* APIs
|
||||
bool WINAPI DXUTDoesAppSupportD3D11();
|
||||
bool WINAPI DXUTIsAppRenderingWithD3D11();
|
||||
|
||||
|
||||
// General
|
||||
DXUTDeviceSettings WINAPI DXUTGetDeviceSettings();
|
||||
HINSTANCE WINAPI DXUTGetHINSTANCE();
|
||||
HWND WINAPI DXUTGetHWND();
|
||||
HWND WINAPI DXUTGetHWNDFocus();
|
||||
HWND WINAPI DXUTGetHWNDDeviceFullScreen();
|
||||
HWND WINAPI DXUTGetHWNDDeviceWindowed();
|
||||
RECT WINAPI DXUTGetWindowClientRect();
|
||||
LONG WINAPI DXUTGetWindowWidth();
|
||||
LONG WINAPI DXUTGetWindowHeight();
|
||||
RECT WINAPI DXUTGetWindowClientRectAtModeChange(); // Useful for returning to windowed mode with the same resolution as before toggle to full screen mode
|
||||
RECT WINAPI DXUTGetFullsceenClientRectAtModeChange(); // Useful for returning to full screen mode with the same resolution as before toggle to windowed mode
|
||||
double WINAPI DXUTGetTime();
|
||||
float WINAPI DXUTGetElapsedTime();
|
||||
bool WINAPI DXUTIsWindowed();
|
||||
bool WINAPI DXUTIsInGammaCorrectMode();
|
||||
float WINAPI DXUTGetFPS();
|
||||
LPCWSTR WINAPI DXUTGetWindowTitle();
|
||||
LPCWSTR WINAPI DXUTGetFrameStats( bool bIncludeFPS = false );
|
||||
LPCWSTR WINAPI DXUTGetDeviceStats();
|
||||
|
||||
bool WINAPI DXUTIsVsyncEnabled();
|
||||
bool WINAPI DXUTIsRenderingPaused();
|
||||
bool WINAPI DXUTIsTimePaused();
|
||||
bool WINAPI DXUTIsActive();
|
||||
int WINAPI DXUTGetExitCode();
|
||||
bool WINAPI DXUTGetShowMsgBoxOnError();
|
||||
bool WINAPI DXUTGetAutomation(); // Returns true if -automation parameter is used to launch the app
|
||||
bool WINAPI DXUTIsKeyDown( BYTE vKey ); // Pass a virtual-key code, ex. VK_F1, 'A', VK_RETURN, VK_LSHIFT, etc
|
||||
bool WINAPI DXUTWasKeyPressed( BYTE vKey ); // Like DXUTIsKeyDown() but return true only if the key was just pressed
|
||||
bool WINAPI DXUTIsMouseButtonDown( BYTE vButton ); // Pass a virtual-key code: VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2
|
||||
HRESULT WINAPI DXUTCreateState(); // Optional method to create DXUT's memory. If its not called by the application it will be automatically called when needed
|
||||
void WINAPI DXUTDestroyState(); // Optional method to destroy DXUT's memory. If its not called by the application it will be automatically called after the application exits WinMain
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// DXUT core layer includes
|
||||
//--------------------------------------------------------------------------------------
|
||||
#include "DXUTmisc.h"
|
||||
#include "DXUTDevice9.h"
|
||||
#include "DXUTDevice11.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
1154
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice11.cpp
Normal file
1154
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice11.cpp
Normal file
File diff suppressed because it is too large
Load Diff
210
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice11.h
Normal file
210
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice11.h
Normal file
@@ -0,0 +1,210 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: DXUTDevice11.h
|
||||
//
|
||||
// Enumerates D3D adapters, devices, modes, etc.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//--------------------------------------------------------------------------------------
|
||||
#pragma once
|
||||
#ifndef DXUT_DEVICE11_H
|
||||
#define DXUT_DEVICE11_H
|
||||
|
||||
void DXUTApplyDefaultDeviceSettings(DXUTDeviceSettings *modifySettings);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Functions to get bit depth from formats
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT WINAPI DXUTGetD3D11AdapterDisplayMode( UINT AdapterOrdinal, UINT Output, DXGI_MODE_DESC* pModeDesc );
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Optional memory create/destory functions. If not call, these will be called automatically
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT WINAPI DXUTCreateD3D11Enumeration();
|
||||
void WINAPI DXUTDestroyD3D11Enumeration();
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D11EnumAdapterInfo;
|
||||
class CD3D11EnumDeviceInfo;
|
||||
class CD3D11EnumOutputInfo;
|
||||
struct CD3D11EnumDeviceSettingsCombo;
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Enumerates available Direct3D10 adapters, devices, modes, etc.
|
||||
// Use DXUTGetD3D9Enumeration() to access global instance
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D11Enumeration
|
||||
{
|
||||
public:
|
||||
// These should be called before Enumerate().
|
||||
//
|
||||
// Use these calls and the IsDeviceAcceptable to control the contents of
|
||||
// the enumeration object, which affects the device selection and the device settings dialog.
|
||||
void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );
|
||||
void SetRefreshMinMax( UINT nMin, UINT nMax );
|
||||
void SetForceFeatureLevel( D3D_FEATURE_LEVEL forceFL) {
|
||||
g_forceFL = forceFL;
|
||||
};
|
||||
void SetMultisampleQualityMax( UINT nMax );
|
||||
CGrowableArray<D3DFORMAT>* GetPossibleDepthStencilFormatList();
|
||||
void ResetPossibleDepthStencilFormats();
|
||||
void SetEnumerateAllAdapterFormats( bool bEnumerateAllAdapterFormats );
|
||||
|
||||
// Call Enumerate() to enumerate available D3D11 adapters, devices, modes, etc.
|
||||
bool HasEnumerated() { return m_bHasEnumerated; }
|
||||
HRESULT Enumerate( LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE IsD3D11DeviceAcceptableFunc,
|
||||
void* pIsD3D11DeviceAcceptableFuncUserContext );
|
||||
|
||||
// These should be called after Enumerate() is called
|
||||
CGrowableArray<CD3D11EnumAdapterInfo*>* GetAdapterInfoList();
|
||||
CD3D11EnumAdapterInfo* GetAdapterInfo( UINT AdapterOrdinal );
|
||||
CD3D11EnumDeviceInfo* GetDeviceInfo( UINT AdapterOrdinal, D3D_DRIVER_TYPE DeviceType );
|
||||
CD3D11EnumOutputInfo* GetOutputInfo( UINT AdapterOrdinal, UINT Output );
|
||||
CD3D11EnumDeviceSettingsCombo* GetDeviceSettingsCombo( DXUTD3D11DeviceSettings* pDeviceSettings ) { return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DriverType, pDeviceSettings->Output, pDeviceSettings->sd.BufferDesc.Format, pDeviceSettings->sd.Windowed ); }
|
||||
CD3D11EnumDeviceSettingsCombo* GetDeviceSettingsCombo( UINT AdapterOrdinal, D3D_DRIVER_TYPE DeviceType, UINT Output, DXGI_FORMAT BackBufferFormat, BOOL Windowed );
|
||||
|
||||
~CD3D11Enumeration();
|
||||
|
||||
private:
|
||||
friend HRESULT WINAPI DXUTCreateD3D11Enumeration();
|
||||
|
||||
// Use DXUTGetD3D11Enumeration() to access global instance
|
||||
CD3D11Enumeration();
|
||||
|
||||
bool m_bHasEnumerated;
|
||||
LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE m_IsD3D11DeviceAcceptableFunc;
|
||||
void* m_pIsD3D11DeviceAcceptableFuncUserContext;
|
||||
|
||||
CGrowableArray<DXGI_FORMAT> m_DepthStencilPossibleList;
|
||||
|
||||
UINT m_nMinWidth;
|
||||
UINT m_nMaxWidth;
|
||||
UINT m_nMinHeight;
|
||||
UINT m_nMaxHeight;
|
||||
UINT m_nRefreshMin;
|
||||
UINT m_nRefreshMax;
|
||||
UINT m_nMultisampleQualityMax;
|
||||
bool m_bEnumerateAllAdapterFormats;
|
||||
D3D_FEATURE_LEVEL g_forceFL;
|
||||
|
||||
// Array of CD3D9EnumAdapterInfo* with unique AdapterOrdinals
|
||||
CGrowableArray<CD3D11EnumAdapterInfo*> m_AdapterInfoList;
|
||||
|
||||
HRESULT EnumerateOutputs( CD3D11EnumAdapterInfo *pAdapterInfo );
|
||||
HRESULT EnumerateDevices( CD3D11EnumAdapterInfo *pAdapterInfo );
|
||||
HRESULT EnumerateDeviceCombos( IDXGIFactory1 *pFactory, CD3D11EnumAdapterInfo* pAdapterInfo );
|
||||
HRESULT EnumerateDeviceCombosNoAdapter( CD3D11EnumAdapterInfo* pAdapterInfo );
|
||||
|
||||
HRESULT EnumerateDisplayModes( CD3D11EnumOutputInfo *pOutputInfo );
|
||||
void BuildMultiSampleQualityList( DXGI_FORMAT fmt, CD3D11EnumDeviceSettingsCombo* pDeviceCombo );
|
||||
void ClearAdapterInfoList();
|
||||
};
|
||||
|
||||
CD3D11Enumeration* WINAPI DXUTGetD3D11Enumeration(bool bForceEnumerate = false, bool EnumerateAllAdapterFormats = false, D3D_FEATURE_LEVEL forceFL = ((D3D_FEATURE_LEVEL )0) );
|
||||
|
||||
|
||||
#define DXGI_MAX_DEVICE_IDENTIFIER_STRING 128
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A class describing an adapter which contains a unique adapter ordinal
|
||||
// that is installed on the system
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D11EnumAdapterInfo
|
||||
{
|
||||
const CD3D11EnumAdapterInfo &operator = ( const CD3D11EnumAdapterInfo &rhs );
|
||||
|
||||
public:
|
||||
~CD3D11EnumAdapterInfo();
|
||||
|
||||
UINT AdapterOrdinal;
|
||||
DXGI_ADAPTER_DESC AdapterDesc;
|
||||
WCHAR szUniqueDescription[DXGI_MAX_DEVICE_IDENTIFIER_STRING];
|
||||
IDXGIAdapter *m_pAdapter;
|
||||
bool bAdapterUnavailable;
|
||||
|
||||
CGrowableArray<CD3D11EnumOutputInfo*> outputInfoList; // Array of CD3D11EnumOutputInfo*
|
||||
CGrowableArray<CD3D11EnumDeviceInfo*> deviceInfoList; // Array of CD3D11EnumDeviceInfo*
|
||||
// List of CD3D11EnumDeviceSettingsCombo* with a unique set
|
||||
// of BackBufferFormat, and Windowed
|
||||
CGrowableArray<CD3D11EnumDeviceSettingsCombo*> deviceSettingsComboList;
|
||||
};
|
||||
|
||||
|
||||
class CD3D11EnumOutputInfo
|
||||
{
|
||||
const CD3D11EnumOutputInfo &operator = ( const CD3D11EnumOutputInfo &rhs );
|
||||
|
||||
public:
|
||||
~CD3D11EnumOutputInfo();
|
||||
|
||||
UINT AdapterOrdinal;
|
||||
UINT Output;
|
||||
IDXGIOutput* m_pOutput;
|
||||
DXGI_OUTPUT_DESC Desc;
|
||||
|
||||
CGrowableArray <DXGI_MODE_DESC> displayModeList; // Array of supported D3DDISPLAYMODEs
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A class describing a Direct3D10 device that contains a
|
||||
// unique supported driver type
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D11EnumDeviceInfo
|
||||
{
|
||||
const CD3D11EnumDeviceInfo& operator =( const CD3D11EnumDeviceInfo& rhs );
|
||||
|
||||
public:
|
||||
~CD3D11EnumDeviceInfo();
|
||||
|
||||
UINT AdapterOrdinal;
|
||||
D3D_DRIVER_TYPE DeviceType;
|
||||
D3D_FEATURE_LEVEL SelectedLevel;
|
||||
D3D_FEATURE_LEVEL MaxLevel;
|
||||
BOOL ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A struct describing device settings that contains a unique combination of
|
||||
// adapter format, back buffer format, and windowed that is compatible with a
|
||||
// particular Direct3D device and the app.
|
||||
//--------------------------------------------------------------------------------------
|
||||
struct CD3D11EnumDeviceSettingsCombo
|
||||
{
|
||||
UINT AdapterOrdinal;
|
||||
D3D_DRIVER_TYPE DeviceType;
|
||||
DXGI_FORMAT BackBufferFormat;
|
||||
BOOL Windowed;
|
||||
UINT Output;
|
||||
|
||||
CGrowableArray <UINT> multiSampleCountList; // List of valid sampling counts (multisampling)
|
||||
CGrowableArray <UINT> multiSampleQualityList; // List of number of quality levels for each multisample count
|
||||
|
||||
CD3D11EnumAdapterInfo* pAdapterInfo;
|
||||
CD3D11EnumDeviceInfo* pDeviceInfo;
|
||||
CD3D11EnumOutputInfo* pOutputInfo;
|
||||
};
|
||||
|
||||
float DXUTRankD3D11DeviceCombo( CD3D11EnumDeviceSettingsCombo* pDeviceSettingsCombo,
|
||||
DXUTD3D11DeviceSettings* pOptimalDeviceSettings,
|
||||
DXGI_MODE_DESC* pAdapterDisplayMode,
|
||||
int &bestModeIndex,
|
||||
int &bestMSAAIndex
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1177
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice9.cpp
Normal file
1177
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice9.cpp
Normal file
File diff suppressed because it is too large
Load Diff
207
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice9.h
Normal file
207
Demos/DX11ClothDemo/DXUT/Core/DXUTDevice9.h
Normal file
@@ -0,0 +1,207 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: DXUTDevice9.h
|
||||
//
|
||||
// Enumerates D3D adapters, devices, modes, etc.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//--------------------------------------------------------------------------------------
|
||||
#pragma once
|
||||
#ifndef DXUT_DEVICE9_H
|
||||
#define DXUT_DEVICE9_H
|
||||
|
||||
//void DXUTApplyDefaultDeviceSettings(DXUTDeviceSettings *modifySettings);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Functions to get bit depth from formats
|
||||
//--------------------------------------------------------------------------------------
|
||||
UINT WINAPI DXUTGetD3D9ColorChannelBits( D3DFORMAT fmt );
|
||||
UINT WINAPI DXUTGetAlphaChannelBits( D3DFORMAT fmt );
|
||||
UINT WINAPI DXUTGetStencilBits( D3DFORMAT fmt );
|
||||
UINT WINAPI DXUTGetDepthBits( D3DFORMAT fmt );
|
||||
UINT WINAPI DXUTGetDXGIColorChannelBits( DXGI_FORMAT fmt );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
class CD3D9EnumAdapterInfo;
|
||||
class CD3D9EnumDeviceInfo;
|
||||
struct CD3D9EnumDeviceSettingsCombo;
|
||||
struct CD3D9EnumDSMSConflict;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Optional memory create/destory functions. If not call, these will be called automatically
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT WINAPI DXUTCreateD3D9Enumeration();
|
||||
void WINAPI DXUTDestroyD3D9Enumeration();
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Enumerates available Direct3D9 adapters, devices, modes, etc.
|
||||
// Use DXUTGetD3D9Enumeration() to access global instance
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D9Enumeration
|
||||
{
|
||||
public:
|
||||
// These should be called before Enumerate().
|
||||
//
|
||||
// Use these calls and the IsDeviceAcceptable to control the contents of
|
||||
// the enumeration object, which affects the device selection and the device settings dialog.
|
||||
void SetRequirePostPixelShaderBlending( bool bRequire ) { m_bRequirePostPixelShaderBlending = bRequire; }
|
||||
void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );
|
||||
void SetRefreshMinMax( UINT nMin, UINT nMax );
|
||||
void SetMultisampleQualityMax( UINT nMax );
|
||||
void GetPossibleVertexProcessingList( bool* pbSoftwareVP, bool* pbHardwareVP, bool* pbPureHarewareVP, bool* pbMixedVP );
|
||||
void SetPossibleVertexProcessingList( bool bSoftwareVP, bool bHardwareVP, bool bPureHarewareVP, bool bMixedVP );
|
||||
CGrowableArray<D3DFORMAT>* GetPossibleDepthStencilFormatList();
|
||||
CGrowableArray<D3DMULTISAMPLE_TYPE>* GetPossibleMultisampleTypeList();
|
||||
CGrowableArray<UINT>* GetPossiblePresentIntervalList();
|
||||
void ResetPossibleDepthStencilFormats();
|
||||
void ResetPossibleMultisampleTypeList();
|
||||
void ResetPossiblePresentIntervalList();
|
||||
|
||||
// Call Enumerate() to enumerate available D3D adapters, devices, modes, etc.
|
||||
bool HasEnumerated() { return m_bHasEnumerated; }
|
||||
HRESULT Enumerate( LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE IsD3D9DeviceAcceptableFunc = NULL,
|
||||
void* pIsD3D9DeviceAcceptableFuncUserContext = NULL );
|
||||
|
||||
// These should be called after Enumerate() is called
|
||||
CGrowableArray<CD3D9EnumAdapterInfo*>* GetAdapterInfoList();
|
||||
CD3D9EnumAdapterInfo* GetAdapterInfo( UINT AdapterOrdinal );
|
||||
CD3D9EnumDeviceInfo* GetDeviceInfo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType );
|
||||
CD3D9EnumDeviceSettingsCombo* GetDeviceSettingsCombo( DXUTD3D9DeviceSettings* pD3D9DeviceSettings ) { return GetDeviceSettingsCombo( pD3D9DeviceSettings->AdapterOrdinal, pD3D9DeviceSettings->DeviceType, pD3D9DeviceSettings->AdapterFormat, pD3D9DeviceSettings->pp.BackBufferFormat, pD3D9DeviceSettings->pp.Windowed ); }
|
||||
CD3D9EnumDeviceSettingsCombo* GetDeviceSettingsCombo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL Windowed );
|
||||
|
||||
~CD3D9Enumeration();
|
||||
|
||||
private:
|
||||
friend HRESULT WINAPI DXUTCreateD3D9Enumeration();
|
||||
|
||||
// Use DXUTGetD3D9Enumeration() to access global instance
|
||||
CD3D9Enumeration();
|
||||
|
||||
bool m_bHasEnumerated;
|
||||
IDirect3D9* m_pD3D;
|
||||
LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE m_IsD3D9DeviceAcceptableFunc;
|
||||
void* m_pIsD3D9DeviceAcceptableFuncUserContext;
|
||||
bool m_bRequirePostPixelShaderBlending;
|
||||
CGrowableArray<D3DFORMAT> m_DepthStencilPossibleList;
|
||||
CGrowableArray<D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
|
||||
CGrowableArray<UINT> m_PresentIntervalList;
|
||||
|
||||
bool m_bSoftwareVP;
|
||||
bool m_bHardwareVP;
|
||||
bool m_bPureHarewareVP;
|
||||
bool m_bMixedVP;
|
||||
|
||||
UINT m_nMinWidth;
|
||||
UINT m_nMaxWidth;
|
||||
UINT m_nMinHeight;
|
||||
UINT m_nMaxHeight;
|
||||
UINT m_nRefreshMin;
|
||||
UINT m_nRefreshMax;
|
||||
UINT m_nMultisampleQualityMax;
|
||||
|
||||
// Array of CD3D9EnumAdapterInfo* with unique AdapterOrdinals
|
||||
CGrowableArray<CD3D9EnumAdapterInfo*> m_AdapterInfoList;
|
||||
|
||||
HRESULT EnumerateDevices( CD3D9EnumAdapterInfo* pAdapterInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
|
||||
HRESULT EnumerateDeviceCombos( CD3D9EnumAdapterInfo* pAdapterInfo, CD3D9EnumDeviceInfo* pDeviceInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
|
||||
void BuildDepthStencilFormatList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
|
||||
void BuildMultiSampleTypeList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
|
||||
void BuildDSMSConflictList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
|
||||
void BuildPresentIntervalList( CD3D9EnumDeviceInfo* pDeviceInfo, CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
|
||||
void ClearAdapterInfoList();
|
||||
};
|
||||
|
||||
CD3D9Enumeration* WINAPI DXUTGetD3D9Enumeration( bool bForceEnumerate = false );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A class describing an adapter which contains a unique adapter ordinal
|
||||
// that is installed on the system
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D9EnumAdapterInfo
|
||||
{
|
||||
public:
|
||||
~CD3D9EnumAdapterInfo();
|
||||
|
||||
UINT AdapterOrdinal;
|
||||
D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
|
||||
WCHAR szUniqueDescription[256];
|
||||
|
||||
CGrowableArray <D3DDISPLAYMODE> displayModeList; // Array of supported D3DDISPLAYMODEs
|
||||
CGrowableArray <CD3D9EnumDeviceInfo*> deviceInfoList; // Array of CD3D9EnumDeviceInfo* with unique supported DeviceTypes
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A class describing a Direct3D device that contains a
|
||||
// unique supported device type
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CD3D9EnumDeviceInfo
|
||||
{
|
||||
public:
|
||||
~CD3D9EnumDeviceInfo();
|
||||
|
||||
UINT AdapterOrdinal;
|
||||
D3DDEVTYPE DeviceType;
|
||||
D3DCAPS9 Caps;
|
||||
|
||||
// List of CD3D9EnumDeviceSettingsCombo* with a unique set
|
||||
// of AdapterFormat, BackBufferFormat, and Windowed
|
||||
CGrowableArray <CD3D9EnumDeviceSettingsCombo*> deviceSettingsComboList;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A struct describing device settings that contains a unique combination of
|
||||
// adapter format, back buffer format, and windowed that is compatible with a
|
||||
// particular Direct3D device and the app.
|
||||
//--------------------------------------------------------------------------------------
|
||||
struct CD3D9EnumDeviceSettingsCombo
|
||||
{
|
||||
UINT AdapterOrdinal;
|
||||
D3DDEVTYPE DeviceType;
|
||||
D3DFORMAT AdapterFormat;
|
||||
D3DFORMAT BackBufferFormat;
|
||||
BOOL Windowed;
|
||||
|
||||
CGrowableArray <D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
|
||||
CGrowableArray <D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
|
||||
CGrowableArray <DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
|
||||
CGrowableArray <UINT> presentIntervalList; // List of D3DPRESENT flags
|
||||
CGrowableArray <CD3D9EnumDSMSConflict> DSMSConflictList; // List of CD3D9EnumDSMSConflict
|
||||
|
||||
CD3D9EnumAdapterInfo* pAdapterInfo;
|
||||
CD3D9EnumDeviceInfo* pDeviceInfo;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A depth/stencil buffer format that is incompatible with a
|
||||
// multisample type.
|
||||
//--------------------------------------------------------------------------------------
|
||||
struct CD3D9EnumDSMSConflict
|
||||
{
|
||||
D3DFORMAT DSFormat;
|
||||
D3DMULTISAMPLE_TYPE MSType;
|
||||
};
|
||||
|
||||
|
||||
|
||||
float DXUTRankD3D9DeviceCombo( CD3D9EnumDeviceSettingsCombo* pDeviceSettingsCombo,
|
||||
DXUTD3D9DeviceSettings* pOptimalDeviceSettings,
|
||||
D3DDISPLAYMODE* pAdapterDesktopDisplayMode,
|
||||
int &bestModeIndex,
|
||||
int &bestMSAAIndex
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
1785
Demos/DX11ClothDemo/DXUT/Core/DXUTmisc.cpp
Normal file
1785
Demos/DX11ClothDemo/DXUT/Core/DXUTmisc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
594
Demos/DX11ClothDemo/DXUT/Core/DXUTmisc.h
Normal file
594
Demos/DX11ClothDemo/DXUT/Core/DXUTmisc.h
Normal file
@@ -0,0 +1,594 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: DXUTMisc.h
|
||||
//
|
||||
// Helper functions for Direct3D programming.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved
|
||||
//--------------------------------------------------------------------------------------
|
||||
#pragma once
|
||||
#ifndef DXUT_MISC_H
|
||||
#define DXUT_MISC_H
|
||||
|
||||
#ifndef MAX_FVF_DECL_SIZE
|
||||
#define MAX_FVF_DECL_SIZE MAXD3DDECLLENGTH + 1 // +1 for END
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// XInput helper state/function
|
||||
// This performs extra processing on XInput gamepad data to make it slightly more convenient to use
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// DXUT_GAMEPAD gamepad[4];
|
||||
// for( DWORD iPort=0; iPort<DXUT_MAX_CONTROLLERS; iPort++ )
|
||||
// DXUTGetGamepadState( iPort, gamepad[iPort] );
|
||||
//
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define DXUT_MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
|
||||
|
||||
struct DXUT_GAMEPAD
|
||||
{
|
||||
// From XINPUT_GAMEPAD
|
||||
WORD wButtons;
|
||||
BYTE bLeftTrigger;
|
||||
BYTE bRightTrigger;
|
||||
SHORT sThumbLX;
|
||||
SHORT sThumbLY;
|
||||
SHORT sThumbRX;
|
||||
SHORT sThumbRY;
|
||||
|
||||
// Device properties
|
||||
XINPUT_CAPABILITIES caps;
|
||||
bool bConnected; // If the controller is currently connected
|
||||
bool bInserted; // If the controller was inserted this frame
|
||||
bool bRemoved; // If the controller was removed this frame
|
||||
|
||||
// Thumb stick values converted to range [-1,+1]
|
||||
float fThumbRX;
|
||||
float fThumbRY;
|
||||
float fThumbLX;
|
||||
float fThumbLY;
|
||||
|
||||
// Records which buttons were pressed this frame.
|
||||
// These are only set on the first frame that the button is pressed
|
||||
WORD wPressedButtons;
|
||||
bool bPressedLeftTrigger;
|
||||
bool bPressedRightTrigger;
|
||||
|
||||
// Last state of the buttons
|
||||
WORD wLastButtons;
|
||||
bool bLastLeftTrigger;
|
||||
bool bLastRightTrigger;
|
||||
};
|
||||
|
||||
HRESULT DXUTGetGamepadState( DWORD dwPort, DXUT_GAMEPAD* pGamePad, bool bThumbstickDeadZone = true,
|
||||
bool bSnapThumbstickToCardinals = true );
|
||||
HRESULT DXUTStopRumbleOnAllControllers();
|
||||
void DXUTEnableXInput( bool bEnable );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Takes a screen shot of a 32bit D3D9 back buffer and saves the images to a BMP file
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT DXUTSnapD3D9Screenshot( LPCTSTR szFileName );
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Takes a screen shot of a 32bit D3D11 back buffer and saves the images to a BMP file
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT DXUTSnapD3D11Screenshot( LPCTSTR szFileName, D3DX11_IMAGE_FILE_FORMAT iff = D3DX11_IFF_DDS );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// A growable array
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> class CGrowableArray
|
||||
{
|
||||
public:
|
||||
CGrowableArray() { m_pData = NULL; m_nSize = 0; m_nMaxSize = 0; }
|
||||
CGrowableArray( const CGrowableArray<TYPE>& a ) { for( int i=0; i < a.m_nSize; i++ ) Add( a.m_pData[i] ); }
|
||||
~CGrowableArray() { RemoveAll(); }
|
||||
|
||||
const TYPE& operator[]( int nIndex ) const { return GetAt( nIndex ); }
|
||||
TYPE& operator[]( int nIndex ) { return GetAt( nIndex ); }
|
||||
|
||||
CGrowableArray& operator=( const CGrowableArray<TYPE>& a ) { if( this == &a ) return *this; RemoveAll(); for( int i=0; i < a.m_nSize; i++ ) Add( a.m_pData[i] ); return *this; }
|
||||
|
||||
HRESULT SetSize( int nNewMaxSize );
|
||||
HRESULT Add( const TYPE& value );
|
||||
HRESULT Insert( int nIndex, const TYPE& value );
|
||||
HRESULT SetAt( int nIndex, const TYPE& value );
|
||||
TYPE& GetAt( int nIndex ) const { assert( nIndex >= 0 && nIndex < m_nSize ); return m_pData[nIndex]; }
|
||||
int GetSize() const { return m_nSize; }
|
||||
TYPE* GetData() { return m_pData; }
|
||||
bool Contains( const TYPE& value ){ return ( -1 != IndexOf( value ) ); }
|
||||
|
||||
int IndexOf( const TYPE& value ) { return ( m_nSize > 0 ) ? IndexOf( value, 0, m_nSize ) : -1; }
|
||||
int IndexOf( const TYPE& value, int iStart ) { return IndexOf( value, iStart, m_nSize - iStart ); }
|
||||
int IndexOf( const TYPE& value, int nIndex, int nNumElements );
|
||||
|
||||
int LastIndexOf( const TYPE& value ) { return ( m_nSize > 0 ) ? LastIndexOf( value, m_nSize-1, m_nSize ) : -1; }
|
||||
int LastIndexOf( const TYPE& value, int nIndex ) { return LastIndexOf( value, nIndex, nIndex+1 ); }
|
||||
int LastIndexOf( const TYPE& value, int nIndex, int nNumElements );
|
||||
|
||||
HRESULT Remove( int nIndex );
|
||||
void RemoveAll() { SetSize(0); }
|
||||
void Reset() { m_nSize = 0; }
|
||||
|
||||
protected:
|
||||
TYPE* m_pData; // the actual array of data
|
||||
int m_nSize; // # of elements (upperBound - 1)
|
||||
int m_nMaxSize; // max allocated
|
||||
|
||||
HRESULT SetSizeInternal( int nNewMaxSize ); // This version doesn't call ctor or dtor.
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Performs timer operations
|
||||
// Use DXUTGetGlobalTimer() to get the global instance
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CDXUTTimer
|
||||
{
|
||||
public:
|
||||
CDXUTTimer();
|
||||
|
||||
void Reset(); // resets the timer
|
||||
void Start(); // starts the timer
|
||||
void Stop(); // stop (or pause) the timer
|
||||
void Advance(); // advance the timer by 0.1 seconds
|
||||
double GetAbsoluteTime(); // get the absolute system time
|
||||
double GetTime(); // get the current time
|
||||
float GetElapsedTime(); // get the time that elapsed between Get*ElapsedTime() calls
|
||||
void GetTimeValues( double* pfTime, double* pfAbsoluteTime, float* pfElapsedTime ); // get all time values at once
|
||||
bool IsStopped(); // returns true if timer stopped
|
||||
|
||||
// Limit the current thread to one processor (the current one). This ensures that timing code runs
|
||||
// on only one processor, and will not suffer any ill effects from power management.
|
||||
void LimitThreadAffinityToCurrentProc();
|
||||
|
||||
protected:
|
||||
LARGE_INTEGER GetAdjustedCurrentTime();
|
||||
|
||||
bool m_bUsingQPF;
|
||||
bool m_bTimerStopped;
|
||||
LONGLONG m_llQPFTicksPerSec;
|
||||
|
||||
LONGLONG m_llStopTime;
|
||||
LONGLONG m_llLastElapsedTime;
|
||||
LONGLONG m_llBaseTime;
|
||||
};
|
||||
|
||||
CDXUTTimer* WINAPI DXUTGetGlobalTimer();
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Returns the string for the given D3DFORMAT.
|
||||
// bWithPrefix determines whether the string should include the "D3DFMT_"
|
||||
//--------------------------------------------------------------------------------------
|
||||
LPCWSTR WINAPI DXUTD3DFormatToString( D3DFORMAT format, bool bWithPrefix );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Returns the string for the given DXGI_FORMAT.
|
||||
// bWithPrefix determines whether the string should include the "DXGI_FORMAT_"
|
||||
//--------------------------------------------------------------------------------------
|
||||
LPCWSTR WINAPI DXUTDXGIFormatToString( DXGI_FORMAT format, bool bWithPrefix );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Device settings conversion
|
||||
//--------------------------------------------------------------------------------------
|
||||
void WINAPI DXUTConvertDeviceSettings11to9( DXUTD3D11DeviceSettings* pIn, DXUTD3D9DeviceSettings* pOut );
|
||||
void WINAPI DXUTConvertDeviceSettings9to11( DXUTD3D9DeviceSettings* pIn, DXUTD3D11DeviceSettings* pOut );
|
||||
|
||||
DXGI_FORMAT WINAPI ConvertFormatD3D9ToDXGI( D3DFORMAT fmt );
|
||||
D3DFORMAT WINAPI ConvertFormatDXGIToD3D9( DXGI_FORMAT fmt );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Debug printing support
|
||||
// See dxerr.h for more debug printing support
|
||||
//--------------------------------------------------------------------------------------
|
||||
void WINAPI DXUTOutputDebugStringW( LPCWSTR strMsg, ... );
|
||||
void WINAPI DXUTOutputDebugStringA( LPCSTR strMsg, ... );
|
||||
HRESULT WINAPI DXUTTrace( const CHAR* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, bool bPopMsgBox );
|
||||
void WINAPI DXUTTraceDecl( D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE] );
|
||||
WCHAR* WINAPI DXUTTraceD3DDECLUSAGEtoString( BYTE u );
|
||||
WCHAR* WINAPI DXUTTraceD3DDECLMETHODtoString( BYTE m );
|
||||
WCHAR* WINAPI DXUTTraceD3DDECLTYPEtoString( BYTE t );
|
||||
WCHAR* WINAPI DXUTTraceWindowsMessage( UINT uMsg );
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXUTOutputDebugString DXUTOutputDebugStringW
|
||||
#else
|
||||
#define DXUTOutputDebugString DXUTOutputDebugStringA
|
||||
#endif
|
||||
|
||||
// These macros are very similar to dxerr's but it special cases the HRESULT defined
|
||||
// by DXUT to pop better message boxes.
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#define DXUT_ERR(str,hr) DXUTTrace( __FILE__, (DWORD)__LINE__, hr, str, false )
|
||||
#define DXUT_ERR_MSGBOX(str,hr) DXUTTrace( __FILE__, (DWORD)__LINE__, hr, str, true )
|
||||
#define DXUTTRACE DXUTOutputDebugString
|
||||
#else
|
||||
#define DXUT_ERR(str,hr) (hr)
|
||||
#define DXUT_ERR_MSGBOX(str,hr) (hr)
|
||||
#define DXUTTRACE (__noop)
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Direct3D9 dynamic linking support -- calls top-level D3D9 APIs with graceful
|
||||
// failure if APIs are not present.
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
IDirect3D9 * WINAPI DXUT_Dynamic_Direct3DCreate9(UINT SDKVersion);
|
||||
int WINAPI DXUT_Dynamic_D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName );
|
||||
int WINAPI DXUT_Dynamic_D3DPERF_EndEvent( void );
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName );
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName );
|
||||
BOOL WINAPI DXUT_Dynamic_D3DPERF_QueryRepeatFrame( void );
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetOptions( DWORD dwOptions );
|
||||
DWORD WINAPI DXUT_Dynamic_D3DPERF_GetStatus( void );
|
||||
HRESULT WINAPI DXUT_Dynamic_CreateDXGIFactory1( REFIID rInterface, void** ppOut );
|
||||
|
||||
HRESULT WINAPI DXUT_Dynamic_D3D11CreateDevice( IDXGIAdapter* pAdapter,
|
||||
D3D_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT32 Flags,
|
||||
D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||
UINT FeatureLevels,
|
||||
UINT32 SDKVersion,
|
||||
ID3D11Device** ppDevice,
|
||||
D3D_FEATURE_LEVEL* pFeatureLevel,
|
||||
ID3D11DeviceContext** ppImmediateContext );
|
||||
|
||||
bool DXUT_EnsureD3D11APIs( void );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Profiling/instrumentation support
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Some D3DPERF APIs take a color that can be used when displaying user events in
|
||||
// performance analysis tools. The following constants are provided for your
|
||||
// convenience, but you can use any colors you like.
|
||||
//--------------------------------------------------------------------------------------
|
||||
const D3DCOLOR DXUT_PERFEVENTCOLOR = D3DCOLOR_XRGB( 200, 100, 100 );
|
||||
const D3DCOLOR DXUT_PERFEVENTCOLOR2 = D3DCOLOR_XRGB( 100, 200, 100 );
|
||||
const D3DCOLOR DXUT_PERFEVENTCOLOR3 = D3DCOLOR_XRGB( 100, 100, 200 );
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// The following macros provide a convenient way for your code to call the D3DPERF
|
||||
// functions only when PROFILE is defined. If PROFILE is not defined (as for the final
|
||||
// release version of a program), these macros evaluate to nothing, so no detailed event
|
||||
// information is embedded in your shipping program. It is recommended that you create
|
||||
// and use three build configurations for your projects:
|
||||
// Debug (nonoptimized code, asserts active, PROFILE defined to assist debugging)
|
||||
// Profile (optimized code, asserts disabled, PROFILE defined to assist optimization)
|
||||
// Release (optimized code, asserts disabled, PROFILE not defined)
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifdef PROFILE
|
||||
// PROFILE is defined, so these macros call the D3DPERF functions
|
||||
#define DXUT_BeginPerfEvent( color, pstrMessage ) DXUT_Dynamic_D3DPERF_BeginEvent( color, pstrMessage )
|
||||
#define DXUT_EndPerfEvent() DXUT_Dynamic_D3DPERF_EndEvent()
|
||||
#define DXUT_SetPerfMarker( color, pstrMessage ) DXUT_Dynamic_D3DPERF_SetMarker( color, pstrMessage )
|
||||
#else
|
||||
// PROFILE is not defined, so these macros do nothing
|
||||
#define DXUT_BeginPerfEvent( color, pstrMessage ) (__noop)
|
||||
#define DXUT_EndPerfEvent() (__noop)
|
||||
#define DXUT_SetPerfMarker( color, pstrMessage ) (__noop)
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// CDXUTPerfEventGenerator is a helper class that makes it easy to attach begin and end
|
||||
// events to a block of code. Simply define a CDXUTPerfEventGenerator variable anywhere
|
||||
// in a block of code, and the class's constructor will call DXUT_BeginPerfEvent when
|
||||
// the block of code begins, and the class's destructor will call DXUT_EndPerfEvent when
|
||||
// the block ends.
|
||||
//--------------------------------------------------------------------------------------
|
||||
class CDXUTPerfEventGenerator
|
||||
{
|
||||
public:
|
||||
CDXUTPerfEventGenerator( D3DCOLOR color, LPCWSTR pstrMessage )
|
||||
{
|
||||
DXUT_BeginPerfEvent( color, pstrMessage );
|
||||
}
|
||||
~CDXUTPerfEventGenerator( void )
|
||||
{
|
||||
DXUT_EndPerfEvent();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Multimon handling to support OSes with or without multimon API support.
|
||||
// Purposely avoiding the use of multimon.h so DXUT.lib doesn't require
|
||||
// COMPILE_MULTIMON_STUBS and cause complication with MFC or other users of multimon.h
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifndef MONITOR_DEFAULTTOPRIMARY
|
||||
#define MONITORINFOF_PRIMARY 0x00000001
|
||||
#define MONITOR_DEFAULTTONULL 0x00000000
|
||||
#define MONITOR_DEFAULTTOPRIMARY 0x00000001
|
||||
#define MONITOR_DEFAULTTONEAREST 0x00000002
|
||||
typedef struct tagMONITORINFO
|
||||
{
|
||||
DWORD cbSize;
|
||||
RECT rcMonitor;
|
||||
RECT rcWork;
|
||||
DWORD dwFlags;
|
||||
} MONITORINFO, *LPMONITORINFO;
|
||||
typedef struct tagMONITORINFOEXW : public tagMONITORINFO
|
||||
{
|
||||
WCHAR szDevice[CCHDEVICENAME];
|
||||
} MONITORINFOEXW, *LPMONITORINFOEXW;
|
||||
typedef MONITORINFOEXW MONITORINFOEX;
|
||||
typedef LPMONITORINFOEXW LPMONITORINFOEX;
|
||||
#endif
|
||||
|
||||
HMONITOR WINAPI DXUTMonitorFromWindow( HWND hWnd, DWORD dwFlags );
|
||||
HMONITOR WINAPI DXUTMonitorFromRect( LPCRECT lprcScreenCoords, DWORD dwFlags );
|
||||
BOOL WINAPI DXUTGetMonitorInfo( HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo );
|
||||
void WINAPI DXUTGetDesktopResolution( UINT AdapterOrdinal, UINT* pWidth, UINT* pHeight );
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Implementation of CGrowableArray
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// This version doesn't call ctor or dtor.
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetSizeInternal( int nNewMaxSize )
|
||||
{
|
||||
if( nNewMaxSize < 0 || ( nNewMaxSize > INT_MAX / sizeof( TYPE ) ) )
|
||||
{
|
||||
assert( false );
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if( nNewMaxSize == 0 )
|
||||
{
|
||||
// Shrink to 0 size & cleanup
|
||||
if( m_pData )
|
||||
{
|
||||
free( m_pData );
|
||||
m_pData = NULL;
|
||||
}
|
||||
|
||||
m_nMaxSize = 0;
|
||||
m_nSize = 0;
|
||||
}
|
||||
else if( m_pData == NULL || nNewMaxSize > m_nMaxSize )
|
||||
{
|
||||
// Grow array
|
||||
int nGrowBy = ( m_nMaxSize == 0 ) ? 16 : m_nMaxSize;
|
||||
|
||||
// Limit nGrowBy to keep m_nMaxSize less than INT_MAX
|
||||
if( ( UINT )m_nMaxSize + ( UINT )nGrowBy > ( UINT )INT_MAX )
|
||||
nGrowBy = INT_MAX - m_nMaxSize;
|
||||
|
||||
nNewMaxSize = __max( nNewMaxSize, m_nMaxSize + nGrowBy );
|
||||
|
||||
// Verify that (nNewMaxSize * sizeof(TYPE)) is not greater than UINT_MAX or the realloc will overrun
|
||||
if( sizeof( TYPE ) > UINT_MAX / ( UINT )nNewMaxSize )
|
||||
return E_INVALIDARG;
|
||||
|
||||
TYPE* pDataNew = ( TYPE* )realloc( m_pData, nNewMaxSize * sizeof( TYPE ) );
|
||||
if( pDataNew == NULL )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
m_pData = pDataNew;
|
||||
m_nMaxSize = nNewMaxSize;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetSize( int nNewMaxSize )
|
||||
{
|
||||
int nOldSize = m_nSize;
|
||||
|
||||
if( nOldSize > nNewMaxSize )
|
||||
{
|
||||
assert( m_pData );
|
||||
if( m_pData )
|
||||
{
|
||||
// Removing elements. Call dtor.
|
||||
|
||||
for( int i = nNewMaxSize; i < nOldSize; ++i )
|
||||
m_pData[i].~TYPE();
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust buffer. Note that there's no need to check for error
|
||||
// since if it happens, nOldSize == nNewMaxSize will be true.)
|
||||
HRESULT hr = SetSizeInternal( nNewMaxSize );
|
||||
|
||||
if( nOldSize < nNewMaxSize )
|
||||
{
|
||||
assert( m_pData );
|
||||
if( m_pData )
|
||||
{
|
||||
// Adding elements. Call ctor.
|
||||
|
||||
for( int i = nOldSize; i < nNewMaxSize; ++i )
|
||||
::new ( &m_pData[i] ) TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::Add( const TYPE& value )
|
||||
{
|
||||
HRESULT hr;
|
||||
if( FAILED( hr = SetSizeInternal( m_nSize + 1 ) ) )
|
||||
return hr;
|
||||
|
||||
// Construct the new element
|
||||
::new ( &m_pData[m_nSize] ) TYPE;
|
||||
|
||||
// Assign
|
||||
m_pData[m_nSize] = value;
|
||||
++m_nSize;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::Insert( int nIndex, const TYPE& value )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Validate index
|
||||
if( nIndex < 0 ||
|
||||
nIndex > m_nSize )
|
||||
{
|
||||
assert( false );
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
// Prepare the buffer
|
||||
if( FAILED( hr = SetSizeInternal( m_nSize + 1 ) ) )
|
||||
return hr;
|
||||
|
||||
// Shift the array
|
||||
MoveMemory( &m_pData[nIndex + 1], &m_pData[nIndex], sizeof( TYPE ) * ( m_nSize - nIndex ) );
|
||||
|
||||
// Construct the new element
|
||||
::new ( &m_pData[nIndex] ) TYPE;
|
||||
|
||||
// Set the value and increase the size
|
||||
m_pData[nIndex] = value;
|
||||
++m_nSize;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetAt( int nIndex, const TYPE& value )
|
||||
{
|
||||
// Validate arguments
|
||||
if( nIndex < 0 ||
|
||||
nIndex >= m_nSize )
|
||||
{
|
||||
assert( false );
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
m_pData[nIndex] = value;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Searches for the specified value and returns the index of the first occurrence
|
||||
// within the section of the data array that extends from iStart and contains the
|
||||
// specified number of elements. Returns -1 if value is not found within the given
|
||||
// section.
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> int CGrowableArray <TYPE>::IndexOf( const TYPE& value, int iStart, int nNumElements )
|
||||
{
|
||||
// Validate arguments
|
||||
if( iStart < 0 ||
|
||||
iStart >= m_nSize ||
|
||||
nNumElements < 0 ||
|
||||
iStart + nNumElements > m_nSize )
|
||||
{
|
||||
assert( false );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Search
|
||||
for( int i = iStart; i < ( iStart + nNumElements ); i++ )
|
||||
{
|
||||
if( value == m_pData[i] )
|
||||
return i;
|
||||
}
|
||||
|
||||
// Not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Searches for the specified value and returns the index of the last occurrence
|
||||
// within the section of the data array that contains the specified number of elements
|
||||
// and ends at iEnd. Returns -1 if value is not found within the given section.
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> int CGrowableArray <TYPE>::LastIndexOf( const TYPE& value, int iEnd, int nNumElements )
|
||||
{
|
||||
// Validate arguments
|
||||
if( iEnd < 0 ||
|
||||
iEnd >= m_nSize ||
|
||||
nNumElements < 0 ||
|
||||
iEnd - nNumElements < 0 )
|
||||
{
|
||||
assert( false );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Search
|
||||
for( int i = iEnd; i > ( iEnd - nNumElements ); i-- )
|
||||
{
|
||||
if( value == m_pData[i] )
|
||||
return i;
|
||||
}
|
||||
|
||||
// Not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<typename TYPE> HRESULT CGrowableArray <TYPE>::Remove( int nIndex )
|
||||
{
|
||||
if( nIndex < 0 ||
|
||||
nIndex >= m_nSize )
|
||||
{
|
||||
assert( false );
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
// Destruct the element to be removed
|
||||
m_pData[nIndex].~TYPE();
|
||||
|
||||
// Compact the array and decrease the size
|
||||
MoveMemory( &m_pData[nIndex], &m_pData[nIndex + 1], sizeof( TYPE ) * ( m_nSize - ( nIndex + 1 ) ) );
|
||||
--m_nSize;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Creates a REF or NULLREF D3D9 device and returns that device. The caller should call
|
||||
// Release() when done with the device.
|
||||
//--------------------------------------------------------------------------------------
|
||||
IDirect3DDevice9* WINAPI DXUTCreateRefDevice9( HWND hWnd, bool bNullRef = true );
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Creates a REF or NULLREF D3D10 device and returns the device. The caller should call
|
||||
// Release() when done with the device.
|
||||
//--------------------------------------------------------------------------------------
|
||||
//test d3d10 version ID3D10Device* WINAPI DXUTCreateRefDevice10( bool bNullRef = true );
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Helper function to launch the Media Center UI after the program terminates
|
||||
//--------------------------------------------------------------------------------------
|
||||
bool DXUTReLaunchMediaCenter();
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Helper functions to create SRGB formats from typeless formats and vice versa
|
||||
//--------------------------------------------------------------------------------------
|
||||
DXGI_FORMAT MAKE_SRGB( DXGI_FORMAT format );
|
||||
DXGI_FORMAT MAKE_TYPELESS( DXGI_FORMAT format );
|
||||
|
||||
#endif
|
||||
7
Demos/DX11ClothDemo/DXUT/Core/dpiaware.manifest
Normal file
7
Demos/DX11ClothDemo/DXUT/Core/dpiaware.manifest
Normal file
@@ -0,0 +1,7 @@
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user