diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/externals/extensions/include | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'APEX_1.4/externals/extensions/include')
4 files changed, 305 insertions, 0 deletions
diff --git a/APEX_1.4/externals/extensions/include/nvidiautils/DeviceManager.h b/APEX_1.4/externals/extensions/include/nvidiautils/DeviceManager.h new file mode 100644 index 00000000..92685ee7 --- /dev/null +++ b/APEX_1.4/externals/extensions/include/nvidiautils/DeviceManager.h @@ -0,0 +1,166 @@ +// TAGRELEASE: PUBLIC + +#pragma once +#include <Windows.h> +#include <DXGI.h> +#include <D3D11.h> +#include <list> + + +struct DeviceCreationParameters +{ + bool startMaximized; + bool startFullscreen; + int backBufferWidth; + int backBufferHeight; + int refreshRate; + int swapChainBufferCount; + DXGI_FORMAT swapChainFormat; + DXGI_FORMAT depthStencilFormat; + DXGI_USAGE swapChainUsage; + int swapChainSampleCount; + int swapChainSampleQuality; + UINT createDeviceFlags; + D3D_DRIVER_TYPE driverType; + D3D_FEATURE_LEVEL featureLevel; + + // For use in the case of multiple adapters. If this is non-null, device creation will try to match + // the given string against an adapter name. If the specified string exists as a sub-string of the + // adapter name, the device and window will be created on that adapter. Case sensitive. + const WCHAR* adapterNameSubstring; + + DeviceCreationParameters() + : startMaximized(false) + , startFullscreen(false) + , backBufferWidth(1280) + , backBufferHeight(720) + , refreshRate(0) + , swapChainBufferCount(1) + , swapChainFormat(DXGI_FORMAT_R8G8B8A8_UNORM) + , depthStencilFormat(DXGI_FORMAT_D24_UNORM_S8_UINT) + , swapChainUsage(DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_RENDER_TARGET_OUTPUT) + , swapChainSampleCount(1) + , swapChainSampleQuality(0) + , createDeviceFlags(0) + , driverType(D3D_DRIVER_TYPE_HARDWARE) + , featureLevel(D3D_FEATURE_LEVEL_11_0) + , adapterNameSubstring(L"") + { } +}; + +#pragma warning(push) +#pragma warning(disable: 4100) // unreferenced formal parameter +class IVisualController +{ +private: + bool m_Enabled; +public: + IVisualController() : m_Enabled(true) { } + + virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return 1; } + virtual void Render(ID3D11Device* pDevice, ID3D11DeviceContext* pDeviceContext, ID3D11RenderTargetView* pRTV, ID3D11DepthStencilView* pDSV) { } + virtual void Animate(double fElapsedTimeSeconds) { } + virtual HRESULT DeviceCreated(ID3D11Device* pDevice) { return S_OK; } + virtual void DeviceDestroyed() { } + virtual void BackBufferResized(ID3D11Device* pDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc) { } + + virtual void EnableController() { m_Enabled = true; } + virtual void DisableController() { m_Enabled = false; } + virtual bool IsEnabled() { return m_Enabled; } +}; +#pragma warning(pop) + +class DeviceManager +{ +public: + enum WindowState + { + kWindowNone, + kWindowNormal, + kWindowMinimized, + kWindowMaximized, + kWindowFullscreen + }; + +protected: + ID3D11Device* m_Device; + ID3D11DeviceContext* m_ImmediateContext; + IDXGISwapChain* m_SwapChain; + ID3D11RenderTargetView* m_BackBufferRTV; + ID3D11Texture2D* m_DepthStencilBuffer; + ID3D11DepthStencilView* m_DepthStencilDSV; + DXGI_SWAP_CHAIN_DESC m_SwapChainDesc; + D3D11_TEXTURE2D_DESC m_DepthStencilDesc; + bool m_IsNvidia; + HWND m_hWnd; + std::list<IVisualController*> m_vControllers; + std::wstring m_WindowTitle; + double m_FixedFrameInterval; + UINT m_SyncInterval; + std::list<double> m_vFrameTimes; + double m_AverageFrameTime; + double m_AverageTimeUpdateInterval; + bool m_InSizingModalLoop; + SIZE m_NewWindowSize; +private: + HRESULT CreateRenderTargetAndDepthStencil(); + void ResizeSwapChain(); +public: + + DeviceManager() + : m_Device(NULL) + , m_ImmediateContext(NULL) + , m_SwapChain(NULL) + , m_BackBufferRTV(NULL) + , m_DepthStencilBuffer(NULL) + , m_DepthStencilDSV(NULL) + , m_IsNvidia(false) + , m_hWnd(NULL) + , m_WindowTitle(L"") + , m_FixedFrameInterval(-1) + , m_SyncInterval(0) + , m_AverageFrameTime(0) + , m_AverageTimeUpdateInterval(0.5) + , m_InSizingModalLoop(false) + { } + + virtual ~DeviceManager() + { Shutdown(); } + + virtual HRESULT CreateWindowDeviceAndSwapChain(const DeviceCreationParameters& params, LPWSTR windowTitle); + virtual HRESULT ChangeBackBufferFormat(DXGI_FORMAT format, UINT sampleCount); + virtual HRESULT ResizeWindow(int width, int height); + virtual HRESULT EnterFullscreenMode(int width = 0, int height = 0); + virtual HRESULT LeaveFullscreenMode(int windowWidth = 0, int windowHeight = 0); + virtual HRESULT ToggleFullscreen(); + + virtual void Shutdown(); + virtual void MessageLoop(); + virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + virtual void Render(); + virtual void Animate(double fElapsedTimeSeconds); + virtual void DeviceCreated(); + virtual void DeviceDestroyed(); + virtual void BackBufferResized(); + + void AddControllerToFront(IVisualController* pController); + void AddControllerToBack(IVisualController* pController); + void RemoveController(IVisualController* pController); + + void SetFixedFrameInterval(double seconds) { m_FixedFrameInterval = seconds; } + void DisableFixedFrameInterval() { m_FixedFrameInterval = -1; } + + bool IsNvidia() const { return m_IsNvidia; } + HWND GetHWND() { return m_hWnd; } + ID3D11Device* GetDevice() { return m_Device; } + WindowState GetWindowState(); + bool GetVsyncEnabled() { return m_SyncInterval > 0; } + void SetVsyncEnabled(bool enabled) { m_SyncInterval = enabled ? 1 : 0; } + HRESULT GetDisplayResolution(int& width, int& height); + IDXGIAdapter* GetDXGIAdapter(); + double GetAverageFrameTime() { return m_AverageFrameTime; } + void SetAverageTimeUpdateInterval(double value) { m_AverageTimeUpdateInterval = value; } +}; + + +DeviceManager* GetDeviceManager(); diff --git a/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMesh.h b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMesh.h new file mode 100644 index 00000000..debb6adf --- /dev/null +++ b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMesh.h @@ -0,0 +1,55 @@ +// TAGRELEASE: PUBLIC +#pragma once +#include <DirectXMath.h> + +class NvSimpleRawMesh; +class NvSimpleMeshLoader; + +class NvSimpleMesh +{ +public: + NvSimpleMesh(); + + HRESULT Initialize(ID3D11Device *pd3dDevice,NvSimpleRawMesh *pRawMesh); + HRESULT InitializeWithInputLayout(ID3D11Device *pd3dDevice,NvSimpleRawMesh *pRawMesh,BYTE*pIAsig, SIZE_T pIAsigSize); + HRESULT CreateInputLayout(ID3D11Device *pd3dDevice,BYTE*pIAsig, SIZE_T pIAsigSize); + void Release(); + + void SetupDraw(ID3D11DeviceContext *pd3dContext, int iDiffuseTexSlot=-1, int iNormalsTexSlot=-1); + void Draw(ID3D11DeviceContext *pd3dContext); + void DrawInstanced(ID3D11DeviceContext *pd3dContext, int iNumInstances); + + UINT iNumVertices; + UINT iNumIndices; + DXGI_FORMAT IndexFormat; + UINT VertexStride; + + DirectX::XMFLOAT3 Extents; + DirectX::XMFLOAT3 Center; + + ID3D11InputLayout *pInputLayout; + + ID3D11Buffer *pVB; + ID3D11Buffer *pIB; + ID3D11Texture2D *pDiffuseTexture; + ID3D11ShaderResourceView *pDiffuseSRV; + ID3D11Texture2D *pNormalsTexture; + ID3D11ShaderResourceView *pNormalsSRV; + char szName[260]; +}; + +class NvAggregateSimpleMesh +{ +public: + NvAggregateSimpleMesh(); + ~NvAggregateSimpleMesh(); + + HRESULT Initialize(ID3D11Device *pd3dDevice,NvSimpleMeshLoader *pMeshLoader); + HRESULT InitializeWithInputLayout(ID3D11Device *pd3dDevice,NvSimpleMeshLoader *pMeshLoader,BYTE*pIAsig, SIZE_T pIAsigSize); + void Release(); + + void Draw(ID3D11DeviceContext *pd3dContext, int iDiffuseTexSlot=-1, int iNormalsTexSlot=-1); + + int NumSimpleMeshes; + NvSimpleMesh *pSimpleMeshes; +};
\ No newline at end of file diff --git a/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMeshLoader.h b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMeshLoader.h new file mode 100644 index 00000000..e3820594 --- /dev/null +++ b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleMeshLoader.h @@ -0,0 +1,30 @@ +// TAGRELEASE: PUBLIC +#pragma once +#include <string> +#include <DirectXMath.h> + +struct aiScene; +struct aiNode; + +class NvSimpleRawMesh; + +/* + Allow loading of various mesh file formats and then simple extraction of various vertex/index streams +*/ +class NvSimpleMeshLoader +{ +public: + + NvSimpleMeshLoader(); + ~NvSimpleMeshLoader(); + + bool LoadFile(LPWSTR szFilename); + void XM_CALLCONV RecurseAddMeshes(const aiScene *scene, aiNode*pNode, DirectX::FXMMATRIX parentCompositeTransformD3D, bool bFlattenTransforms); + + int NumMeshes; + NvSimpleRawMesh *pMeshes; + +protected: + + std::string mediaPath; +}; diff --git a/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleRawMesh.h b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleRawMesh.h new file mode 100644 index 00000000..abdc382c --- /dev/null +++ b/APEX_1.4/externals/extensions/include/nvsimplemesh/NvSimpleRawMesh.h @@ -0,0 +1,54 @@ +// TAGRELEASE: PUBLIC +#pragma once + +class NvSimpleRawMesh +{ +public: + + class Vertex + { + public: + float Position[3]; + float Normal[3]; + float UV[2]; + float Tangent[3]; + }; + + NvSimpleRawMesh(); + ~NvSimpleRawMesh(); + + UINT GetIndexSize(); + INT GetVertexStride(); + INT GetNumVertices(); + INT GetNumIndices(); + + Vertex* GetVertices(); + BYTE* GetRawVertices(); + BYTE* GetRawIndices(); + + float* GetExtents() {return m_extents;} + float* GetCenter() {return m_center;} + + static HRESULT TryGuessFilename(WCHAR *szDestBuffer,WCHAR *szMeshFilename, WCHAR *szGuessSuffix); + ID3D11Texture2D *CreateD3D11DiffuseTextureFor(ID3D11Device *pd3dDevice); + ID3D11Texture2D *CreateD3D11NormalsTextureFor(ID3D11Device *pd3dDevice); + ID3D11Buffer *CreateD3D11IndexBufferFor(ID3D11Device *pd3dDevice); + ID3D11Buffer *CreateD3D11VertexBufferFor(ID3D11Device *pd3dDevice); + + Vertex *m_pVertexData; + BYTE *m_pIndexData; + UINT m_iNumVertices; + UINT m_iNumIndices; + UINT m_IndexSize; + + float m_extents[3]; + float m_center[3]; + + WCHAR m_szMeshFilename[MAX_PATH]; + WCHAR m_szDiffuseTexture[MAX_PATH]; + WCHAR m_szNormalTexture[MAX_PATH]; + + // Utils to wrap making d3d11 render buffers from a loader mesh + static const D3D11_INPUT_ELEMENT_DESC D3D11InputElements[]; + static const int D3D11ElementsSize; +};
\ No newline at end of file |