diff options
| author | lbavoil <[email protected]> | 2016-03-25 13:01:54 +0100 |
|---|---|---|
| committer | lbavoil <[email protected]> | 2016-03-25 13:01:54 +0100 |
| commit | 99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c (patch) | |
| tree | fbcd4260d6c953d569a887505336a1c3f202e10f /samples/D3D11/src | |
| download | hbaoplus-99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c.tar.xz hbaoplus-99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c.zip | |
GFSDK_HBAO+_distro_r3.0_cl20573789
Diffstat (limited to 'samples/D3D11/src')
22 files changed, 4311 insertions, 0 deletions
diff --git a/samples/D3D11/src/BinMeshReader.h b/samples/D3D11/src/BinMeshReader.h new file mode 100644 index 0000000..6661ed0 --- /dev/null +++ b/samples/D3D11/src/BinMeshReader.h @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#pragma once +#include <DirectXMath.h> + +struct Vertex +{ + DirectX::XMFLOAT3 position; + DirectX::XMFLOAT3 normal; + DirectX::XMFLOAT2 textureCoordinate; +}; + +struct Mesh +{ + std::vector<Vertex> vertices; + std::vector<uint32_t> indices; +}; + +FILE *OpenFile(std::string Path, const char* Mode) +{ + FILE *fp = NULL; + if (fopen_s(&fp, Path.c_str(), Mode) || !fp) + { + MessageBox(NULL, L"Failed to open data file", L"Error", MB_OK | MB_ICONERROR); + exit(1); + } + return fp; +} + +bool LoadVertices(const char* FileName, std::vector<Vertex>& OutVertices) +{ + FILE* fp = OpenFile(FileName, "rb"); + + fseek(fp, 0L, SEEK_END); + UINT FileSize = ftell(fp); + fseek(fp, 0L, SEEK_SET); + + UINT NumVertices = FileSize / sizeof(Vertex::position); + + for (UINT Idx = 0; Idx < NumVertices; ++Idx) + { + Vertex vertex; + fread(&vertex.position, sizeof(DirectX::XMFLOAT3), 1, fp); + vertex.normal.x = vertex.normal.y = 0; + vertex.normal.z = 1.0; + vertex.textureCoordinate.x = vertex.textureCoordinate.y = 0; + OutVertices.push_back(vertex); + } + + fclose(fp); + return true; +} + +bool LoadIndices(const char* FileName, std::vector<uint32_t>& OutIndices) +{ + FILE* fp = OpenFile(FileName, "rb"); + + fseek(fp, 0L, SEEK_END); + UINT FileSize = ftell(fp); + fseek(fp, 0L, SEEK_SET); + + UINT NumIndices = FileSize / sizeof(uint32_t); + + for (UINT Idx = 0; Idx < NumIndices; ++Idx) + { + uint32_t index; + fread(&index, sizeof(index), 1, fp); + OutIndices.push_back(index); + } + + fclose(fp); + return true; +} diff --git a/samples/D3D11/src/DeviceManager.cpp b/samples/D3D11/src/DeviceManager.cpp new file mode 100644 index 0000000..55bf233 --- /dev/null +++ b/samples/D3D11/src/DeviceManager.cpp @@ -0,0 +1,608 @@ +// TAGRELEASE: PUBLIC + +#include "DeviceManager.h" +#include <WinUser.h> +#include <Windows.h> + +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } +#endif + +#define WINDOW_CLASS_NAME L"NvDX11" + +#define WINDOW_STYLE_NORMAL (WS_OVERLAPPEDWINDOW | WS_VISIBLE) +#define WINDOW_STYLE_FULLSCREEN (WS_POPUP | WS_SYSMENU | WS_VISIBLE) + +// A singleton, sort of... To pass the events from WindowProc to the object. +DeviceManager* g_DeviceManagerInstance = NULL; + +LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if(g_DeviceManagerInstance) + return g_DeviceManagerInstance->MsgProc(hWnd, uMsg, wParam, lParam); + else + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + + +HRESULT +DeviceManager::CreateWindowDeviceAndSwapChain(const DeviceCreationParameters& params, LPWSTR title) +{ + g_DeviceManagerInstance = this; + m_WindowTitle = title; + + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASSEX windowClass = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WindowProc, + 0L, 0L, hInstance, NULL, NULL, NULL, NULL, WINDOW_CLASS_NAME, NULL }; + + RegisterClassEx(&windowClass); + + UINT windowStyle = params.startFullscreen + ? WINDOW_STYLE_FULLSCREEN + : params.startMaximized + ? (WINDOW_STYLE_NORMAL | WS_MAXIMIZE) + : WINDOW_STYLE_NORMAL; + + RECT rect = { 0, 0, params.backBufferWidth, params.backBufferHeight }; + AdjustWindowRect(&rect, windowStyle, FALSE); + + m_hWnd = CreateWindowEx( + 0, + WINDOW_CLASS_NAME, + title, + windowStyle, + CW_USEDEFAULT, + CW_USEDEFAULT, + rect.right - rect.left, + rect.bottom - rect.top, + GetDesktopWindow(), + NULL, + hInstance, + NULL + ); + + if(!m_hWnd) + { +#ifdef DEBUG + DWORD errorCode = GetLastError(); + printf("CreateWindowEx error code = 0x%x\n", errorCode); +#endif + + MessageBox(NULL, L"Cannot create window", m_WindowTitle.c_str(), MB_OK | MB_ICONERROR); + return E_FAIL; + } + + UpdateWindow(m_hWnd); + + HRESULT hr = E_FAIL; + + RECT clientRect; + GetClientRect(m_hWnd, &clientRect); + UINT width = clientRect.right - clientRect.left; + UINT height = clientRect.bottom - clientRect.top; + + ZeroMemory(&m_SwapChainDesc, sizeof(m_SwapChainDesc)); + m_SwapChainDesc.BufferCount = params.swapChainBufferCount; + m_SwapChainDesc.BufferDesc.Width = width; + m_SwapChainDesc.BufferDesc.Height = height; + m_SwapChainDesc.BufferDesc.Format = params.swapChainFormat; + m_SwapChainDesc.BufferDesc.RefreshRate.Numerator = params.refreshRate; + m_SwapChainDesc.BufferDesc.RefreshRate.Denominator = 0; + m_SwapChainDesc.BufferUsage = params.swapChainUsage; + m_SwapChainDesc.OutputWindow = m_hWnd; + m_SwapChainDesc.SampleDesc.Count = params.swapChainSampleCount; + m_SwapChainDesc.SampleDesc.Quality = params.swapChainSampleQuality; + m_SwapChainDesc.Windowed = !params.startFullscreen; + m_SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + + hr = D3D11CreateDeviceAndSwapChain( + NULL, // pAdapter + params.driverType, // DriverType + NULL, // Software + params.createDeviceFlags, // Flags + ¶ms.featureLevel, // pFeatureLevels + 1, // FeatureLevels + D3D11_SDK_VERSION, // SDKVersion + &m_SwapChainDesc, // pSwapChainDesc + &m_SwapChain, // ppSwapChain + &m_Device, // ppDevice + NULL, // pFeatureLevel + &m_ImmediateContext // ppImmediateContext + ); + + if(FAILED(hr)) + return hr; + + m_DepthStencilDesc.ArraySize = 1; + m_DepthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; + m_DepthStencilDesc.CPUAccessFlags = 0; + m_DepthStencilDesc.Format = params.depthStencilFormat; + m_DepthStencilDesc.Width = width; + m_DepthStencilDesc.Height = height; + m_DepthStencilDesc.MipLevels = 1; + m_DepthStencilDesc.MiscFlags = 0; + m_DepthStencilDesc.SampleDesc.Count = params.swapChainSampleCount; + m_DepthStencilDesc.SampleDesc.Quality = 0; + m_DepthStencilDesc.Usage = D3D11_USAGE_DEFAULT; + + hr = CreateRenderTargetAndDepthStencil(); + + if(FAILED(hr)) + return hr; + + DeviceCreated(); + BackBufferResized(); + + return S_OK; +} + +void +DeviceManager::Shutdown() +{ + if(m_SwapChain && GetWindowState() == kWindowFullscreen) + m_SwapChain->SetFullscreenState(false, NULL); + + DeviceDestroyed(); + + SAFE_RELEASE(m_BackBufferRTV); + SAFE_RELEASE(m_DepthStencilDSV); + SAFE_RELEASE(m_DepthStencilBuffer); + + g_DeviceManagerInstance = NULL; + SAFE_RELEASE(m_SwapChain); + SAFE_RELEASE(m_Device); + + if(m_hWnd) + { + DestroyWindow(m_hWnd); + m_hWnd = NULL; + } +} + +HRESULT +DeviceManager::CreateRenderTargetAndDepthStencil() +{ + HRESULT hr; + + ID3D11Texture2D *backBuffer = NULL; + hr = m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBuffer); + if (FAILED(hr)) + return hr; + + hr = m_Device->CreateRenderTargetView(backBuffer, NULL, &m_BackBufferRTV); + backBuffer->Release(); + if (FAILED(hr)) + return hr; + + if(m_DepthStencilDesc.Format != DXGI_FORMAT_UNKNOWN) + { + hr = m_Device->CreateTexture2D(&m_DepthStencilDesc, NULL, &m_DepthStencilBuffer); + if (FAILED(hr)) + return hr; + + hr = m_Device->CreateDepthStencilView(m_DepthStencilBuffer, NULL, &m_DepthStencilDSV); + if (FAILED(hr)) + return hr; + } + + return S_OK; +} + +void +DeviceManager::MessageLoop() +{ + MSG msg = {0}; + + LARGE_INTEGER perfFreq, previousTime; + QueryPerformanceFrequency(&perfFreq); + QueryPerformanceCounter(&previousTime); + + while (WM_QUIT != msg.message) + { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else + { + LARGE_INTEGER newTime; + QueryPerformanceCounter(&newTime); + + double elapsedSeconds = (m_FixedFrameInterval >= 0) + ? m_FixedFrameInterval + : (double)(newTime.QuadPart - previousTime.QuadPart) / (double)perfFreq.QuadPart; + + if(m_SwapChain && GetWindowState() != kWindowMinimized) + { + Animate(elapsedSeconds); + Render(); + m_SwapChain->Present(m_SyncInterval, 0); + Sleep(0); + } + else + { + // Release CPU resources when idle + Sleep(1); + } + + { + m_vFrameTimes.push_back(elapsedSeconds); + double timeSum = 0; + for(auto it = m_vFrameTimes.begin(); it != m_vFrameTimes.end(); it++) + timeSum += *it; + + if(timeSum > m_AverageTimeUpdateInterval) + { + m_AverageFrameTime = timeSum / (double)m_vFrameTimes.size(); + m_vFrameTimes.clear(); + } + } + + previousTime = newTime; + } + } +} + +LRESULT +DeviceManager::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_DESTROY: + case WM_CLOSE: + PostQuitMessage(0); + return 0; + + case WM_SYSKEYDOWN: + if(wParam == VK_F4) + { + PostQuitMessage(0); + return 0; + } + break; + + case WM_SIZE: + // Ignore the WM_SIZE event if there is no device, + // or if the window has been minimized (size == 0), + // or if it has been restored to the previous size + if (m_Device + && (lParam != 0) + && (LOWORD(lParam) != m_SwapChainDesc.BufferDesc.Width || HIWORD(lParam) != m_SwapChainDesc.BufferDesc.Height)) + { + ID3D11RenderTargetView *nullRTV = NULL; + m_ImmediateContext->OMSetRenderTargets(1, &nullRTV, NULL); + SAFE_RELEASE(m_BackBufferRTV); + SAFE_RELEASE(m_DepthStencilDSV); + SAFE_RELEASE(m_DepthStencilBuffer); + + if (m_SwapChain) + { + // Resize the swap chain + m_SwapChainDesc.BufferDesc.Width = LOWORD(lParam); + m_SwapChainDesc.BufferDesc.Height = HIWORD(lParam); + m_SwapChain->ResizeBuffers(m_SwapChainDesc.BufferCount, m_SwapChainDesc.BufferDesc.Width, + m_SwapChainDesc.BufferDesc.Height, m_SwapChainDesc.BufferDesc.Format, + m_SwapChainDesc.Flags); + + m_DepthStencilDesc.Width = LOWORD(lParam); + m_DepthStencilDesc.Height = HIWORD(lParam); + + CreateRenderTargetAndDepthStencil(); + + BackBufferResized(); + } + } + } + + if( uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST || + uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST ) + { + // processing messages front-to-back + for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++) + { + if((*it)->IsEnabled()) + { + // for kb/mouse messages, 0 means the message has been handled + if(0 == (*it)->MsgProc(hWnd, uMsg, wParam, lParam)) + return 0; + } + } + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + +void +DeviceManager::Render() +{ + D3D11_VIEWPORT viewport = { 0.0f, 0.0f, (float)m_SwapChainDesc.BufferDesc.Width, (float)m_SwapChainDesc.BufferDesc.Height, 0.0f, 1.0f }; + + // rendering back-to-front + for(auto it = m_vControllers.rbegin(); it != m_vControllers.rend(); it++) + { + if((*it)->IsEnabled()) + { + m_ImmediateContext->OMSetRenderTargets(1, &m_BackBufferRTV, m_DepthStencilDSV); + m_ImmediateContext->RSSetViewports(1, &viewport); + + (*it)->Render(m_Device, m_ImmediateContext, m_BackBufferRTV, m_DepthStencilDSV); + } + } + + m_ImmediateContext->OMSetRenderTargets(0, NULL, NULL); +} + +void +DeviceManager::Animate(double fElapsedTimeSeconds) +{ + for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++) + { + if((*it)->IsEnabled()) + { + (*it)->Animate(fElapsedTimeSeconds); + } + } +} + +void +DeviceManager::DeviceCreated() +{ + for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++) + { + (*it)->DeviceCreated(m_Device); + } +} + +void +DeviceManager::DeviceDestroyed() +{ + for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++) + { + (*it)->DeviceDestroyed(); + } +} + +void +DeviceManager::BackBufferResized() +{ + if(m_SwapChain == NULL) + return; + + DXGI_SURFACE_DESC backSD; + backSD.Format = m_SwapChainDesc.BufferDesc.Format; + backSD.Width = m_SwapChainDesc.BufferDesc.Width; + backSD.Height = m_SwapChainDesc.BufferDesc.Height; + backSD.SampleDesc = m_SwapChainDesc.SampleDesc; + + for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++) + { + (*it)->BackBufferResized(m_Device, &backSD); + } +} + +HRESULT +DeviceManager::ChangeBackBufferFormat(DXGI_FORMAT format, UINT sampleCount) +{ + HRESULT hr = E_FAIL; + + if((format == DXGI_FORMAT_UNKNOWN || format == m_SwapChainDesc.BufferDesc.Format) && + (sampleCount == 0 || sampleCount == m_SwapChainDesc.SampleDesc.Count)) + return S_FALSE; + + if(m_Device) + { + bool fullscreen = (GetWindowState() == kWindowFullscreen); + if(fullscreen) + m_SwapChain->SetFullscreenState(false, NULL); + + IDXGISwapChain* newSwapChain = NULL; + DXGI_SWAP_CHAIN_DESC newSwapChainDesc = m_SwapChainDesc; + + if(format != DXGI_FORMAT_UNKNOWN) + newSwapChainDesc.BufferDesc.Format = format; + if(sampleCount != 0) + newSwapChainDesc.SampleDesc.Count = sampleCount; + + IDXGIAdapter* pDXGIAdapter = GetDXGIAdapter(); + + IDXGIFactory* pDXGIFactory = NULL; + pDXGIAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pDXGIFactory)); + + hr = pDXGIFactory->CreateSwapChain(m_Device, &newSwapChainDesc, &newSwapChain); + + pDXGIFactory->Release(); + pDXGIAdapter->Release(); + + if (FAILED(hr)) + { + if(fullscreen) + m_SwapChain->SetFullscreenState(true, NULL); + + return hr; + } + + SAFE_RELEASE(m_BackBufferRTV); + SAFE_RELEASE(m_SwapChain); + SAFE_RELEASE(m_DepthStencilBuffer); + SAFE_RELEASE(m_DepthStencilDSV); + + m_SwapChain = newSwapChain; + m_SwapChainDesc = newSwapChainDesc; + + m_DepthStencilDesc.SampleDesc.Count = sampleCount; + + if(fullscreen) + m_SwapChain->SetFullscreenState(true, NULL); + + CreateRenderTargetAndDepthStencil(); + BackBufferResized(); + } + + return S_OK; +} + +void +DeviceManager::AddControllerToFront(IVisualController* pController) +{ + m_vControllers.remove(pController); + m_vControllers.push_front(pController); +} + +void +DeviceManager::AddControllerToBack(IVisualController* pController) +{ + m_vControllers.remove(pController); + m_vControllers.push_back(pController); +} + +void +DeviceManager::RemoveController(IVisualController* pController) +{ + m_vControllers.remove(pController); +} + +HRESULT +DeviceManager::ResizeWindow(int width, int height) +{ + if(m_SwapChain == NULL) + return E_FAIL; + + RECT rect; + GetWindowRect(m_hWnd, &rect); + + ShowWindow(m_hWnd, SW_RESTORE); + + if(!MoveWindow(m_hWnd, rect.left, rect.top, width, height, true)) + return E_FAIL; + + // No need to call m_SwapChain->ResizeBackBuffer because MoveWindow will send WM_SIZE, which calls that function. + + return S_OK; +} + +HRESULT +DeviceManager::EnterFullscreenMode(int width, int height) +{ + if(m_SwapChain == NULL) + return E_FAIL; + + if(GetWindowState() == kWindowFullscreen) + return S_FALSE; + + if(width <= 0 || height <= 0) + { + width = m_SwapChainDesc.BufferDesc.Width; + height = m_SwapChainDesc.BufferDesc.Height; + } + + SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_FULLSCREEN); + MoveWindow(m_hWnd, 0, 0, width, height, true); + + HRESULT hr = m_SwapChain->SetFullscreenState(true, NULL); + + if(FAILED(hr)) + { + SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_NORMAL); + return hr; + } + + UpdateWindow(m_hWnd); + m_SwapChain->GetDesc(&m_SwapChainDesc); + + return S_OK; +} + +HRESULT +DeviceManager::LeaveFullscreenMode(int windowWidth, int windowHeight) +{ + if(m_SwapChain == NULL) + return E_FAIL; + + if(GetWindowState() != kWindowFullscreen) + return S_FALSE; + + HRESULT hr = m_SwapChain->SetFullscreenState(false, NULL); + if(FAILED(hr)) return hr; + + SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_NORMAL); + + if(windowWidth <= 0 || windowHeight <= 0) + { + windowWidth = m_SwapChainDesc.BufferDesc.Width; + windowHeight = m_SwapChainDesc.BufferDesc.Height; + } + + RECT rect = { 0, 0, windowWidth, windowHeight }; + AdjustWindowRect(&rect, WINDOW_STYLE_NORMAL, FALSE); + MoveWindow(m_hWnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, true); + UpdateWindow(m_hWnd); + + m_SwapChain->GetDesc(&m_SwapChainDesc); + + return S_OK; +} + +HRESULT +DeviceManager::ToggleFullscreen() +{ + if(GetWindowState() == kWindowFullscreen) + return LeaveFullscreenMode(); + else + return EnterFullscreenMode(); +} + +DeviceManager::WindowState +DeviceManager::GetWindowState() +{ + if(m_SwapChain && !m_SwapChainDesc.Windowed) + return kWindowFullscreen; + + if(m_hWnd == INVALID_HANDLE_VALUE) + return kWindowNone; + + if(IsZoomed(m_hWnd)) + return kWindowMaximized; + + if(IsIconic(m_hWnd)) + return kWindowMinimized; + + return kWindowNormal; +} + +HRESULT +DeviceManager::GetDisplayResolution(int& width, int& height) +{ + if(m_hWnd != INVALID_HANDLE_VALUE) + { + HMONITOR monitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTOPRIMARY); + MONITORINFO info; + info.cbSize = sizeof(MONITORINFO); + + if(GetMonitorInfo(monitor, &info)) + { + width = info.rcMonitor.right - info.rcMonitor.left; + height = info.rcMonitor.bottom - info.rcMonitor.top; + return S_OK; + } + } + + return E_FAIL; +} + +IDXGIAdapter* +DeviceManager::GetDXGIAdapter() +{ + if(!m_Device) + return NULL; + + IDXGIDevice* pDXGIDevice = NULL; + m_Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pDXGIDevice)); + + IDXGIAdapter* pDXGIAdapter = NULL; + pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pDXGIAdapter)); + + pDXGIDevice->Release(); + + return pDXGIAdapter; +} diff --git a/samples/D3D11/src/DeviceManager.h b/samples/D3D11/src/DeviceManager.h new file mode 100644 index 0000000..a6d5b88 --- /dev/null +++ b/samples/D3D11/src/DeviceManager.h @@ -0,0 +1,150 @@ +// 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; + + 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) + { } +}; + +#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; + 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; +private: + HRESULT CreateRenderTargetAndDepthStencil(); +public: + + DeviceManager() + : m_Device(NULL) + , m_ImmediateContext(NULL) + , m_SwapChain(NULL) + , m_BackBufferRTV(NULL) + , m_DepthStencilBuffer(NULL) + , m_DepthStencilDSV(NULL) + , m_hWnd(NULL) + , m_WindowTitle(L"") + , m_FixedFrameInterval(-1) + , m_SyncInterval(0) + , m_AverageFrameTime(0) + , m_AverageTimeUpdateInterval(0.5) + { } + + 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; } + + 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; } +}; diff --git a/samples/D3D11/src/GPUTimers.cpp b/samples/D3D11/src/GPUTimers.cpp new file mode 100644 index 0000000..c00b9f2 --- /dev/null +++ b/samples/D3D11/src/GPUTimers.cpp @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#include "GPUTimers.h" +#include <assert.h> + +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } +#endif + +#ifndef SAFE_D3D_CALL +#define SAFE_D3D_CALL(x) { if (x != S_OK) assert(0); } +#endif + +//-------------------------------------------------------------------------------- +void GPUTimers::Create(ID3D11Device* pD3DDevice, UINT NumTimers) +{ + m_Timers.resize(NumTimers); + + D3D11_QUERY_DESC queryDesc; + queryDesc.MiscFlags = 0; + + queryDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; + SAFE_D3D_CALL( pD3DDevice->CreateQuery(&queryDesc, &m_pDisjointTimestampQuery) ); + m_DisjointQueryInFlight = false; + + queryDesc.Query = D3D11_QUERY_TIMESTAMP; + for (UINT i = 0; i < m_Timers.size(); ++i) + { + SAFE_D3D_CALL( pD3DDevice->CreateQuery(&queryDesc, &m_Timers[i].pGPUTimersBegin) ); + SAFE_D3D_CALL( pD3DDevice->CreateQuery(&queryDesc, &m_Timers[i].pGPUTimersEnd) ); + m_Timers[i].TimestampQueryInFlight = false; + } +} + +//-------------------------------------------------------------------------------- +void GPUTimers::Release() +{ + SAFE_RELEASE(m_pDisjointTimestampQuery); + + for (UINT i = 0; i < m_Timers.size(); ++i) + { + SAFE_RELEASE(m_Timers[i].pGPUTimersBegin); + SAFE_RELEASE(m_Timers[i].pGPUTimersEnd); + } + + m_Timers.clear(); +} + +//-------------------------------------------------------------------------------- +void GPUTimers::BeginFrame(ID3D11DeviceContext* pDeviceContext) +{ + if (!m_DisjointQueryInFlight) + { + pDeviceContext->Begin(m_pDisjointTimestampQuery); + } +} + +//-------------------------------------------------------------------------------- +void GPUTimers::EndFrame(ID3D11DeviceContext* pDeviceContext) +{ + if (!m_DisjointQueryInFlight) + { + pDeviceContext->End(m_pDisjointTimestampQuery); + } + m_DisjointQueryInFlight = true; + + D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointTimestampValue; + if (pDeviceContext->GetData(m_pDisjointTimestampQuery, &disjointTimestampValue, sizeof(disjointTimestampValue), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK) + { + m_DisjointQueryInFlight = false; + + if (!disjointTimestampValue.Disjoint) + { + double InvFrequencyMS = 1000.0 / disjointTimestampValue.Frequency; + for (UINT i = 0; i < m_Timers.size(); ++i) + { + if (m_Timers[i].TimestampQueryInFlight) + { + UINT64 TimestampValueBegin; + UINT64 TimestampValueEnd; + if ((pDeviceContext->GetData(m_Timers[i].pGPUTimersBegin, &TimestampValueBegin, sizeof(UINT64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK) && + (pDeviceContext->GetData(m_Timers[i].pGPUTimersEnd, &TimestampValueEnd, sizeof(UINT64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK)) + { + m_Timers[i].TimestampQueryInFlight = false; + m_Timers[i].GPUTimeInMS = float(double(TimestampValueEnd - TimestampValueBegin) * InvFrequencyMS); + } + } + else + { + m_Timers[i].GPUTimeInMS = 0.f; + } + } + } + } +} + +//-------------------------------------------------------------------------------- +void GPUTimers::StartTimer(ID3D11DeviceContext* pDeviceContext, UINT i) +{ + if (!m_Timers[i].TimestampQueryInFlight) + { + pDeviceContext->End(m_Timers[i].pGPUTimersBegin); + } +} + +//-------------------------------------------------------------------------------- +void GPUTimers::StopTimer(ID3D11DeviceContext* pDeviceContext, UINT i) +{ + if (!m_Timers[i].TimestampQueryInFlight) + { + pDeviceContext->End(m_Timers[i].pGPUTimersEnd); + } + m_Timers[i].TimestampQueryInFlight = true; +} + +//-------------------------------------------------------------------------------- +float GPUTimers::GetGPUTimeInMS(UINT i) +{ + if (i < m_Timers.size()) + { + return m_Timers[i].GPUTimeInMS; + } + assert(0); + return 0.f; +} diff --git a/samples/D3D11/src/GPUTimers.h b/samples/D3D11/src/GPUTimers.h new file mode 100644 index 0000000..9fb2cdb --- /dev/null +++ b/samples/D3D11/src/GPUTimers.h @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#pragma once +#pragma warning( disable : 4995 ) +#include <d3d11.h> +#include <vector> + +typedef int RenderTimeId; + +//-------------------------------------------------------------------------------- +struct GPUTimerState +{ + bool TimestampQueryInFlight; + ID3D11Query* pGPUTimersBegin; + ID3D11Query* pGPUTimersEnd; + float GPUTimeInMS; +}; + +//-------------------------------------------------------------------------------- +class GPUTimers +{ +public: + void Create(ID3D11Device* pD3DDevice, UINT NumTimers); + void Release(); + + void BeginFrame(ID3D11DeviceContext* pDeviceContext); + void EndFrame(ID3D11DeviceContext* pDeviceContext); + + void StartTimer(ID3D11DeviceContext* pDeviceContext, UINT Id); + void StopTimer(ID3D11DeviceContext* pDeviceContext, UINT Id); + + float GetGPUTimeInMS(UINT Id); + +protected: + bool m_DisjointQueryInFlight; + ID3D11Query* m_pDisjointTimestampQuery; + std::vector<GPUTimerState> m_Timers; +}; + +//-------------------------------------------------------------------------------- +class GPUTimer +{ +public: + GPUTimer(GPUTimers* pGPUTimers, ID3D11DeviceContext* pDeviceContext, RenderTimeId Id) + : m_pGPUTimers(pGPUTimers) + , m_pDeviceContext(pDeviceContext) + , m_RenderTimeId(Id) + { + m_pGPUTimers->StartTimer(m_pDeviceContext, m_RenderTimeId); + } + ~GPUTimer() + { + m_pGPUTimers->StopTimer(m_pDeviceContext, m_RenderTimeId); + } + +private: + GPUTimers* m_pGPUTimers; + ID3D11DeviceContext* m_pDeviceContext; + RenderTimeId m_RenderTimeId; +}; diff --git a/samples/D3D11/src/InputDumpReader.h b/samples/D3D11/src/InputDumpReader.h new file mode 100644 index 0000000..fa8eee1 --- /dev/null +++ b/samples/D3D11/src/InputDumpReader.h @@ -0,0 +1,539 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008-2015 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once +#include "GFSDK_SSAO.h" +#include "InputDumpWriter.h" + +namespace GFSDK +{ +namespace SSAO +{ +namespace D3D11 +{ + +class InputDumpReader +{ +public: + InputDumpReader() + : m_pFile(NULL) + { + } + + ~InputDumpReader() + { + SafeCloseFile(); + } + + struct InputDumpData + { + InputDumpData() + { + memset(this, 0, sizeof(*this)); + } + void Release() + { + SAFE_RELEASE(InputData.DepthData.pFullResDepthTextureSRV); + SAFE_RELEASE(InputData.NormalData.pFullResNormalTextureSRV); + SAFE_RELEASE(pDepthTexture); + SAFE_RELEASE(pNormalTexture); + } + GFSDK_SSAO_InputData_D3D11 InputData; + GFSDK_SSAO_Parameters Parameters; + ID3D11Texture2D* pDepthTexture; + ID3D11Texture2D* pNormalTexture; + }; + + enum Status + { + STATUS_OK, + STATUS_NULL_ARGUMENT, + STATUS_FOPEN_ERROR, + STATUS_FREAD_ERROR, + STATUS_FILE_VERSION_MISMATCH, + STATUS_BUILD_VERSION_MISMATCH, + STATUS_STRUCT_SIZE_MISMATCH, + STATUS_CREATE_TEXTURE_ERROR, + STATUS_CREATE_SRV_ERROR, + }; + + #define READ_STRUCT(S, FP)\ + {\ + UINT StructSize = 0;\ + if (fread(&StructSize, sizeof(StructSize), 1, FP) != 1)\ + {\ + return STATUS_FREAD_ERROR;\ + }\ + if (StructSize != sizeof(S))\ + {\ + return STATUS_STRUCT_SIZE_MISMATCH;\ + }\ + if (fread(&S, sizeof(S), 1, FP) != 1)\ + {\ + return STATUS_FREAD_ERROR;\ + }\ + } + + Status Read( + ID3D11Device* pDevice, + InputDumpData* pInputDumpData, + const char* pDumpFilename) + { + InputDumpReader::Status Status = STATUS_OK; + + if (!pDevice || !pInputDumpData || !pDumpFilename) + { + return STATUS_NULL_ARGUMENT; + } + + SafeCloseFile(); + if (fopen_s(&m_pFile, pDumpFilename, "rb") || !m_pFile) + { + return STATUS_FOPEN_ERROR; + } + + UINT FileVersion = 0; + if (fread(&FileVersion, sizeof(FileVersion), 1, m_pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + if (FileVersion != InputDumpWriter::FILE_VERSION) + { + return STATUS_FILE_VERSION_MISMATCH; + } + + GFSDK_SSAO_Version Version; + READ_STRUCT(Version, m_pFile); + + const GFSDK_SSAO_Version BuildVersion; + if (BuildVersion.Major != Version.Major || + BuildVersion.Minor != Version.Minor) + { + return STATUS_BUILD_VERSION_MISMATCH; + } + + Status = ReadInputData(pDevice, pInputDumpData, m_pFile); + if (Status != STATUS_OK) + { + return Status; + } + + Status = ReadParameters(pDevice, pInputDumpData, m_pFile); + if (Status != STATUS_OK) + { + return Status; + } + + Status = ReadTexture(pDevice, pInputDumpData->pDepthTexture, pInputDumpData->InputData.DepthData.pFullResDepthTextureSRV, m_pFile); + if (Status != STATUS_OK) + { + return Status; + } + + if (pInputDumpData->InputData.NormalData.Enable) + { + Status = ReadTexture(pDevice, pInputDumpData->pNormalTexture, pInputDumpData->InputData.NormalData.pFullResNormalTextureSRV, m_pFile); + if (Status != STATUS_OK) + { + return Status; + } + } + + return STATUS_OK; + } + +private: + void SafeCloseFile() + { + if (m_pFile) + { + fclose(m_pFile); + m_pFile = NULL; + } + } + + static Status ReadInputData( + ID3D11Device* pDevice, + InputDumpData* pInputDumpData, + FILE *pFile) + { + GFSDK_SSAO_InputDepthData LoadedDepthData; + READ_STRUCT(LoadedDepthData, pFile); + + GFSDK_SSAO_InputNormalData LoadedNormalData; + READ_STRUCT(LoadedNormalData, pFile); + + GFSDK_SSAO_InputData_D3D11& InputData = pInputDumpData->InputData; + memset(&InputData, 0, sizeof(InputData)); + memcpy(&InputData.DepthData, &LoadedDepthData, sizeof(LoadedDepthData)); + memcpy(&InputData.NormalData, &LoadedNormalData, sizeof(LoadedNormalData)); + + return STATUS_OK; + } + + static Status ReadParameters( + ID3D11Device* pDevice, + InputDumpData* pInputDumpData, + FILE *pFile) + { + GFSDK_SSAO_Parameters LoadedParameters; + READ_STRUCT(LoadedParameters, pFile); + + GFSDK_SSAO_Parameters& Parameters = pInputDumpData->Parameters; + memset(&Parameters, 0, sizeof(Parameters)); + memcpy(&Parameters, &LoadedParameters, sizeof(LoadedParameters)); + + return STATUS_OK; + } + +protected: + static Status ReadTexture( + ID3D11Device* pDevice, + ID3D11Texture2D*& pOutTexture, + ID3D11ShaderResourceView*& pOutSRV, + FILE *pFile) + { + D3D11_TEXTURE2D_DESC TextureDesc; + if (fread(&TextureDesc, sizeof(TextureDesc), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + D3D11_SHADER_RESOURCE_VIEW_DESC SrvDesc; + if (fread(&SrvDesc, sizeof(SrvDesc), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + UINT RowPitch = 0; + if (fread(&RowPitch, sizeof(RowPitch), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + BYTE* pData = new BYTE[TextureDesc.Height * RowPitch]; + assert(pData); + + if (fread(pData, TextureDesc.Height * RowPitch, 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + TextureDesc.Usage = D3D11_USAGE_IMMUTABLE; + TextureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + TextureDesc.CPUAccessFlags = 0; + TextureDesc.MiscFlags = 0; + + D3D11_SUBRESOURCE_DATA SubresourceData; + SubresourceData.pSysMem = pData; + SubresourceData.SysMemPitch = RowPitch; + SubresourceData.SysMemSlicePitch = 0; + + assert(!pOutTexture); + if (pDevice->CreateTexture2D(&TextureDesc, &SubresourceData, &pOutTexture) != S_OK) + { + return STATUS_CREATE_TEXTURE_ERROR; + } + + delete[] pData; + + assert(!pOutSRV); + if (pDevice->CreateShaderResourceView(pOutTexture, &SrvDesc, &pOutSRV) != S_OK) + { + return STATUS_CREATE_SRV_ERROR; + } + + return STATUS_OK; + } + + FILE* m_pFile; +}; + +class InputDumpReader_2 : public InputDumpReader +{ +public: + static Status Read( + ID3D11Device* pDevice, + InputDumpReader::InputDumpData* pInputDumpData, + const char* pDumpFilename) + { + Status ReadStatus = STATUS_OK; + + if (!pDevice || !pInputDumpData || !pDumpFilename) + { + return STATUS_NULL_ARGUMENT; + } + + FILE *pFile = NULL; + if (fopen_s(&pFile, pDumpFilename, "rb") || !pFile) + { + return STATUS_FOPEN_ERROR; + } + + UINT FileVersion = 0; + if (fread(&FileVersion, sizeof(FileVersion), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + if (FileVersion != 2) + { + return STATUS_FILE_VERSION_MISMATCH; + } + + GFSDK_SSAO_Version Version; + if (fread(&Version, sizeof(Version), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + ReadStatus = ReadStructs(pFile, pInputDumpData); + if (ReadStatus != STATUS_OK) + { + return ReadStatus; + } + + ReadStatus = InputDumpReader::ReadTexture(pDevice, pInputDumpData->pDepthTexture, pInputDumpData->InputData.DepthData.pFullResDepthTextureSRV, pFile); + if (ReadStatus != STATUS_OK) + { + return ReadStatus; + } + + if (pInputDumpData->InputData.NormalData.Enable) + { + ReadStatus = InputDumpReader::ReadTexture(pDevice, pInputDumpData->pNormalTexture, pInputDumpData->InputData.NormalData.pFullResNormalTextureSRV, pFile); + if (ReadStatus != STATUS_OK) + { + return ReadStatus; + } + } + + fclose(pFile); + + return STATUS_OK; + } + +private: + struct InputViewport + { + GFSDK_SSAO_UINT TopLeftX; + GFSDK_SSAO_UINT TopLeftY; + GFSDK_SSAO_UINT Width; + GFSDK_SSAO_UINT Height; + GFSDK_SSAO_FLOAT MinDepth; + GFSDK_SSAO_FLOAT MaxDepth; + + InputViewport() + : TopLeftX(0) + , TopLeftY(0) + , Width(0) + , Height(0) + , MinDepth(0.f) + , MaxDepth(1.f) + { + } + }; + + struct Matrix + { + Matrix() + { + memset(this, 0, sizeof(*this)); + } + Matrix(const GFSDK_SSAO_FLOAT* pMatrix) + { + memcpy(&Data, pMatrix, sizeof(Data)); + } + GFSDK_SSAO_FLOAT Data[16]; + }; + + struct InputDepthData + { + GFSDK_SSAO_DepthTextureType DepthTextureType; // HARDWARE_DEPTHS, HARDWARE_DEPTHS_SUB_RANGE or VIEW_DEPTHS + Matrix ProjectionMatrix; // 4x4 perspective matrix from the depth generation pass + GFSDK_SSAO_MatrixLayout ProjectionMatrixLayout; // Memory layout of the projection matrix + GFSDK_SSAO_FLOAT MetersToViewSpaceUnits; // DistanceInViewSpaceUnits = MetersToViewSpaceUnits * DistanceInMeters + + InputDepthData() + : DepthTextureType(GFSDK_SSAO_HARDWARE_DEPTHS) + , ProjectionMatrixLayout(GFSDK_SSAO_ROW_MAJOR_ORDER) + , MetersToViewSpaceUnits(1.f) + { + } + }; + + struct InputDepthData_D3D11 : InputDepthData + { + ID3D11ShaderResourceView* pFullResDepthTextureSRV; // Full-resolution depth texture + InputViewport Viewport; // Viewport from the depth generation pass + + InputDepthData_D3D11() + : pFullResDepthTextureSRV(NULL) + { + } + }; + + struct InputNormalData + { + GFSDK_SSAO_BOOL Enable; // To use the provided normals (instead of reconstructed ones) + Matrix WorldToViewMatrix; // 4x4 WorldToView matrix from the depth generation pass + GFSDK_SSAO_MatrixLayout WorldToViewMatrixLayout; // Memory layout of the WorldToView matrix + GFSDK_SSAO_FLOAT DecodeScale; // Optional pre-matrix scale + GFSDK_SSAO_FLOAT DecodeBias; // Optional pre-matrix bias + + InputNormalData() + : Enable(false) + , WorldToViewMatrixLayout(GFSDK_SSAO_ROW_MAJOR_ORDER) + , DecodeScale(1.f) + , DecodeBias(0.f) + { + } + }; + + struct InputNormalData_D3D11 : InputNormalData + { + ID3D11ShaderResourceView* pFullResNormalTextureSRV; // Full-resolution world-space normal texture + + InputNormalData_D3D11() + : pFullResNormalTextureSRV(NULL) + { + } + }; + + struct InputData_D3D11 + { + InputDepthData_D3D11 DepthData; // Required + InputNormalData_D3D11 NormalData; // Optional GBuffer normals + }; + + + struct OutputParameters + { + GFSDK_SSAO_BlendMode BlendMode; // Blend mode used to composite the AO to the output render target + + OutputParameters() + : BlendMode(GFSDK_SSAO_OVERWRITE_RGB) + { + } + }; + + struct CustomBlendState_D3D11 + { + ID3D11BlendState* pBlendState; // Custom blend state to composite the AO with + const GFSDK_SSAO_FLOAT* pBlendFactor; // Relevant only if pBlendState uses D3D11_BLEND_BLEND_FACTOR + + CustomBlendState_D3D11() + : pBlendState(NULL) + , pBlendFactor(NULL) + { + } + }; + + struct Parameters_D3D11 + { + GFSDK_SSAO_FLOAT Radius; // The AO radius in meters + GFSDK_SSAO_FLOAT Bias; // To hide low-tessellation artifacts // 0.0~1.0 + GFSDK_SSAO_FLOAT DetailAO; // Scale factor for the detail AO, the greater the darker // 0.0~2.0 + GFSDK_SSAO_FLOAT CoarseAO; // Scale factor for the coarse AO, the greater the darker // 0.0~2.0 + GFSDK_SSAO_FLOAT PowerExponent; // The final AO output is pow(AO, powerExponent) + GFSDK_SSAO_DepthStorage DepthStorage; // Quality / performance tradeoff + GFSDK_SSAO_DepthClampMode DepthClampMode; // To hide possible false-occlusion artifacts near screen borders + GFSDK_SSAO_DepthThreshold DepthThreshold; // Optional Z threshold, to hide possible depth-precision artifacts + GFSDK_SSAO_BlurParameters Blur; // Optional AO blur, to blur the AO before compositing it + + Parameters_D3D11() + : Radius(1.f) + , Bias(0.1f) + , DetailAO(0.f) + , CoarseAO(1.f) + , PowerExponent(2.f) + , DepthStorage(GFSDK_SSAO_FP32_VIEW_DEPTHS) + , DepthClampMode(GFSDK_SSAO_CLAMP_TO_EDGE) + { + } + }; + + static Status ReadStructs(FILE *pFile, InputDumpReader::InputDumpData* pOut) + { + InputDepthData InputDepthData; + if (fread(&InputDepthData, sizeof(InputDepthData), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + InputViewport InputViewport; + if (fread(&InputViewport, sizeof(InputViewport), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + InputNormalData InputNormalData; + if (fread(&InputNormalData, sizeof(InputNormalData), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + GFSDK_SSAO_InputData_D3D11& OutInputData = pOut->InputData; + memset(&OutInputData, 0, sizeof(OutInputData)); + + OutInputData.DepthData.DepthTextureType = InputDepthData.DepthTextureType; + memcpy(&OutInputData.DepthData.ProjectionMatrix.Data, &InputDepthData.ProjectionMatrix, sizeof(InputDepthData.ProjectionMatrix)); + OutInputData.DepthData.ProjectionMatrix.Layout = InputDepthData.ProjectionMatrixLayout; + OutInputData.DepthData.MetersToViewSpaceUnits = InputDepthData.MetersToViewSpaceUnits; + OutInputData.DepthData.Viewport.Enable = 0; + + OutInputData.NormalData.Enable = InputNormalData.Enable; + memcpy(&OutInputData.NormalData.WorldToViewMatrix.Data, &InputNormalData.WorldToViewMatrix, sizeof(InputNormalData.WorldToViewMatrix)); + OutInputData.NormalData.WorldToViewMatrix.Layout = InputNormalData.WorldToViewMatrixLayout; + OutInputData.NormalData.DecodeScale = InputNormalData.DecodeScale; + OutInputData.NormalData.DecodeBias = InputNormalData.DecodeBias; + + Parameters_D3D11 Parameters; + if (fread(&Parameters, sizeof(Parameters), 1, pFile) != 1) + { + return STATUS_FREAD_ERROR; + } + + pOut->Parameters.Radius = Parameters.Radius; + pOut->Parameters.Bias = Parameters.Bias; + pOut->Parameters.DetailAO = Parameters.DetailAO; + pOut->Parameters.CoarseAO = Parameters.CoarseAO; + pOut->Parameters.DepthStorage = Parameters.DepthStorage; + pOut->Parameters.PowerExponent = Parameters.PowerExponent; + pOut->Parameters.DepthClampMode = Parameters.DepthClampMode; + pOut->Parameters.DepthThreshold = Parameters.DepthThreshold; + pOut->Parameters.Blur = Parameters.Blur; + + return STATUS_OK; + } +}; + +} // namespace D3D11 +} // namespace SSAO +} // namespace GFSDK diff --git a/samples/D3D11/src/InputDumpWriter.h b/samples/D3D11/src/InputDumpWriter.h new file mode 100644 index 0000000..f55f634 --- /dev/null +++ b/samples/D3D11/src/InputDumpWriter.h @@ -0,0 +1,265 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008-2015 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once +#include "GFSDK_SSAO.h" +#include <stdio.h> +#include <assert.h> + +namespace GFSDK +{ +namespace SSAO +{ +namespace D3D11 +{ + +class InputDumpWriter +{ +public: + static const UINT FILE_VERSION = 5; + + enum Status + { + STATUS_NULL_ARGUMENT, + STATUS_UNSUPPORTED_TEXTURE_SAMPLE_COUNT, + STATUS_UNSUPPORTED_TEXTURE_ARRAY_SIZE, + STATUS_UNSUPPORTED_TEXTURE_MIP_COUNT, + STATUS_FOPEN_FAILED, + STATUS_FWRITE_FAILED, + STATUS_CREATE_TEXTURE_FAILED, + STATUS_MAP_TEXTURE_FAILED, + STATUS_OK, + }; + + InputDumpWriter() + : m_pFile(NULL) + , m_pBaseTexture(NULL) + , m_pStagingTexture(NULL) + { + } + + ~InputDumpWriter() + { + SafeCloseFile(); + SAFE_RELEASE(m_pBaseTexture); + SAFE_RELEASE(m_pStagingTexture); + } + + #define WRITE_STRUCT(S)\ + {\ + UINT StructSize = sizeof(S);\ + if (fwrite(&StructSize, sizeof(StructSize), 1, m_pFile) != 1)\ + {\ + return STATUS_FWRITE_FAILED;\ + }\ + if (fwrite(&S, sizeof(S), 1, m_pFile) != 1)\ + {\ + return STATUS_FWRITE_FAILED;\ + }\ + } + + Status Write( + ID3D11Device* pDevice, + ID3D11DeviceContext* pDeviceContext, + const GFSDK_SSAO_InputData_D3D11* pInputData, + const GFSDK_SSAO_Parameters* pParameters, + const char* pFilename) + { + if (!pDevice || !pDeviceContext || !pInputData || !pParameters || !pFilename) + { + return STATUS_NULL_ARGUMENT; + } + + SafeCloseFile(); + if (fopen_s(&m_pFile, pFilename, "wb") || !m_pFile) + { + return STATUS_FOPEN_FAILED; + } + + const UINT FileVersion = FILE_VERSION; + if (fwrite(&FileVersion, sizeof(FileVersion), 1, m_pFile) != 1) + { + return STATUS_FWRITE_FAILED; + } + + const GFSDK_SSAO_Version BuildVersion; + WRITE_STRUCT(BuildVersion); + + GFSDK_SSAO_InputDepthData InputDepthData = pInputData->DepthData; + WRITE_STRUCT(InputDepthData); + + GFSDK_SSAO_InputNormalData InputNormalData = pInputData->NormalData; + WRITE_STRUCT(InputNormalData); + + GFSDK_SSAO_Parameters Parameters = *pParameters; + WRITE_STRUCT(Parameters); + + InputDumpWriter::Status Status = WriteTexture(pDevice, pDeviceContext, pInputData->DepthData.pFullResDepthTextureSRV); + if (Status != GFSDK_SSAO_OK) + { + return Status; + } + + if (pInputData->NormalData.Enable) + { + Status = WriteTexture(pDevice, pDeviceContext, pInputData->NormalData.pFullResNormalTextureSRV); + if (Status != GFSDK_SSAO_OK) + { + return Status; + } + } + + return STATUS_OK; + } + +private: + void SafeCloseFile() + { + if (m_pFile) + { + fclose(m_pFile); + m_pFile = NULL; + } + } + + static void GetTextureDesc(ID3D11ShaderResourceView* pSRV, D3D11_TEXTURE2D_DESC* pTextureDesc) + { + ID3D11Texture2D* pBaseTexture; + pSRV->GetResource((ID3D11Resource**)&pBaseTexture); + + pBaseTexture->GetDesc(pTextureDesc); + SAFE_RELEASE(pBaseTexture); + } + + bool CreateStagingTexture( + ID3D11Device* pDevice, + ID3D11DeviceContext* pDeviceContext, + ID3D11ShaderResourceView* pSRV) + { + SAFE_RELEASE(m_pBaseTexture); + pSRV->GetResource((ID3D11Resource**)&m_pBaseTexture); + + D3D11_TEXTURE2D_DESC TextureDesc; + m_pBaseTexture->GetDesc(&TextureDesc); + + assert(TextureDesc.SampleDesc.Count == 1); + assert(TextureDesc.ArraySize == 1); + assert(TextureDesc.MipLevels == 1); + + D3D11_TEXTURE2D_DESC StagingTextureDesc = TextureDesc; + StagingTextureDesc.Usage = D3D11_USAGE_STAGING; + StagingTextureDesc.BindFlags = 0; + StagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + StagingTextureDesc.MiscFlags = 0; + + SAFE_RELEASE(m_pStagingTexture); + if (pDevice->CreateTexture2D(&StagingTextureDesc, NULL, &m_pStagingTexture) != S_OK) + { + return false; + } + + pDeviceContext->CopyResource(m_pStagingTexture, m_pBaseTexture); + + return true; + } + + Status WriteTexture( + ID3D11Device* pDevice, + ID3D11DeviceContext* pDeviceContext, + ID3D11ShaderResourceView* pSRV) + { + if (!pSRV) + { + return STATUS_NULL_ARGUMENT; + } + + D3D11_SHADER_RESOURCE_VIEW_DESC SrvDesc; + pSRV->GetDesc(&SrvDesc); + + D3D11_TEXTURE2D_DESC TextureDesc; + GetTextureDesc(pSRV, &TextureDesc); + + if (TextureDesc.SampleDesc.Count != 1) + { + return STATUS_UNSUPPORTED_TEXTURE_SAMPLE_COUNT; + } + + if (TextureDesc.ArraySize != 1) + { + return STATUS_UNSUPPORTED_TEXTURE_ARRAY_SIZE; + } + + if (TextureDesc.MipLevels != 1) + { + return STATUS_UNSUPPORTED_TEXTURE_MIP_COUNT; + } + + if (!CreateStagingTexture(pDevice, pDeviceContext, pSRV)) + { + return STATUS_CREATE_TEXTURE_FAILED; + } + + D3D11_MAPPED_SUBRESOURCE LockedRect; + if (pDeviceContext->Map(m_pStagingTexture, 0, D3D11_MAP_READ, 0, &LockedRect) != S_OK) + { + return STATUS_MAP_TEXTURE_FAILED; + } + + if (fwrite(&TextureDesc, sizeof(TextureDesc), 1, m_pFile) != 1) + { + return STATUS_FWRITE_FAILED; + } + + if (fwrite(&SrvDesc, sizeof(SrvDesc), 1, m_pFile) != 1) + { + return STATUS_FWRITE_FAILED; + } + + if (fwrite(&LockedRect.RowPitch, sizeof(LockedRect.RowPitch), 1, m_pFile) != 1) + { + return STATUS_FWRITE_FAILED; + } + + if (fwrite(LockedRect.pData, TextureDesc.Height * LockedRect.RowPitch, 1, m_pFile) != 1) + { + return STATUS_FWRITE_FAILED; + } + + pDeviceContext->Unmap(m_pStagingTexture, 0); + + return STATUS_OK; + } + + FILE* m_pFile; + ID3D11Texture2D* m_pBaseTexture; + ID3D11Texture2D* m_pStagingTexture; +}; + +} // namespace D3D11 +} // namespace SSAO +} // namespace GFSDK diff --git a/samples/D3D11/src/SSAO11.cpp b/samples/D3D11/src/SSAO11.cpp new file mode 100644 index 0000000..4f43ee4 --- /dev/null +++ b/samples/D3D11/src/SSAO11.cpp @@ -0,0 +1,598 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#include <D3D11.h> +#include <DirectXMath.h> +#include <assert.h> +#include <stdexcept> +#include <vector> + +#include "GFSDK_SSAO.h" +#include "AntTweakBar.h" +#include "DeviceManager.h" +#include "GPUTimers.h" +#include "BinMeshReader.h" +#include "SceneRTs.h" + +#include "shaders/bin/GeometryVS.h" +#include "shaders/bin/GeometryPS.h" + +#define VERTEX_BIN_FILE_PATH "..\\src\\SibenikVertices.bin" +#define INDEX_BIN_FILE_PATH "..\\src\\SibenikIndices.bin" + +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } +#endif + +#ifndef SAFE_DELETE +#define SAFE_DELETE(p) { if (p) { delete (p); (p)=NULL; } } +#endif + +#ifndef SIZEOF_ARRAY +#define SIZEOF_ARRAY(A) (sizeof(A) / sizeof(A[0])) +#endif + +#ifndef SAFE_D3D_CALL +#define SAFE_D3D_CALL(x) { if(FAILED(x)) assert(0); } +#endif + +enum GPUTimeId +{ + GPU_TIME_Z, + GPU_TIME_AO, + GPU_TIME_UI, + NUM_GPU_TIMES +}; +GPUTimers g_GPUTimers; + +DeviceManager* g_DeviceManager = NULL; +bool g_bRenderHUD = true; + +using namespace DirectX; + +class VisualController : public IVisualController +{ +public: + VisualController() + : m_pAOContext(NULL) + , m_AORadius(2.f) + , m_AOBias(0.2f) + , m_BlurAO(true) + , m_BlurSharpness(32.f) + , m_PowerExponent(2.f) + , m_NearAO(1.f) + , m_pVB(NULL) + , m_pIB(NULL) + , m_pConstantBuffer(NULL) + , m_pInputLayout(NULL) + , m_pGeometryVS(NULL) + , m_pGeometryPS(NULL) + , m_pDepthStencilState_Enabled(NULL) + , m_pBlendState_Disabled(NULL) + , m_pRasterizerState_NoCull_NoScissor(NULL) + , m_pSceneRTs(NULL) + , m_UseGBufferNormals(false) + , m_DebugNormals(false) + { + m_BackBufferDesc = {}; + } + + virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + if (uMsg == WM_KEYDOWN) + { + int iKeyPressed = static_cast<int>(wParam); + + switch (iKeyPressed) + { + case VK_TAB: + g_bRenderHUD = !g_bRenderHUD; + return 0; + break; + + case VK_ESCAPE: + PostQuitMessage(0); + break; + + default: + break; + } + } + + if (g_bRenderHUD || uMsg == WM_KEYDOWN || uMsg == WM_CHAR) + { + if (TwEventWin(hWnd, uMsg, wParam, lParam)) + { + return 0; // Event has been handled by AntTweakBar + } + } + + return 1; + } + + virtual void Render(ID3D11Device* pDevice, ID3D11DeviceContext* pDeviceContext, ID3D11RenderTargetView* pRTV, ID3D11DepthStencilView* pDSV) + { + g_GPUTimers.BeginFrame(pDeviceContext); + + DrawGeometry(pDevice, pDeviceContext); + + DrawHBAO(pDevice, pDeviceContext, pRTV); + + DrawUI(pDevice, pDeviceContext, pRTV, pDSV); + + g_GPUTimers.EndFrame(pDeviceContext); + } + + static void TW_CALL CopyStdStringToClient(std::string& destinationClientString, const std::string& sourceLibraryString) + { + destinationClientString = sourceLibraryString; + } + + virtual HRESULT DeviceCreated(ID3D11Device* pDevice) + { + TwInit(TW_DIRECT3D11, pDevice); + TwCopyStdStringToClientFunc(CopyStdStringToClient); + InitGeometry(pDevice); + InitHBAO(pDevice); + InitUI(); + + return S_OK; + } + + virtual void DeviceDestroyed() + { + TwTerminate(); + ReleaseGeometry(); + ReleaseHBAO(); + SAFE_DELETE(m_pSceneRTs); + } + + virtual void BackBufferResized(ID3D11Device* pDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc) + { + TwWindowSize(pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height); + ReallocateSceneRTs(pDevice, pBackBufferSurfaceDesc); + m_BackBufferDesc = *pBackBufferSurfaceDesc; + } + +private: + void InitGeometry(ID3D11Device* pDevice) + { + if (!LoadVertices(VERTEX_BIN_FILE_PATH, m_Mesh.vertices)) + { + throw std::runtime_error("Failed to load " VERTEX_BIN_FILE_PATH); + } + if (!LoadIndices(INDEX_BIN_FILE_PATH, m_Mesh.indices)) + { + throw std::runtime_error("Failed to load " INDEX_BIN_FILE_PATH); + } + + SAFE_D3D_CALL(pDevice->CreateVertexShader(g_GeometryVS, sizeof(g_GeometryVS), NULL, &m_pGeometryVS)); + SAFE_D3D_CALL(pDevice->CreatePixelShader(g_GeometryPS, sizeof(g_GeometryPS), NULL, &m_pGeometryPS)); + } + + void ReallocateSceneRTs(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc) + { + SceneRTs::Desc desc; + desc.OutputWidth = pBackBufferSurfaceDesc->Width; + desc.OutputHeight = pBackBufferSurfaceDesc->Height; + desc.BorderPixels = 0; + desc.SampleCount = 1; + + SAFE_DELETE(m_pSceneRTs); + m_pSceneRTs = new SceneRTs(pd3dDevice, desc); + } + + void InitHBAO(ID3D11Device* pDevice) + { + GFSDK_SSAO_CustomHeap CustomHeap; + CustomHeap.new_ = ::operator new; + CustomHeap.delete_ = ::operator delete; + + GFSDK_SSAO_Status status; + status = GFSDK_SSAO_CreateContext_D3D11(pDevice, &m_pAOContext, &CustomHeap); + assert(status == GFSDK_SSAO_OK); + + g_GPUTimers.Create(pDevice, NUM_GPU_TIMES); + } + + void InitUI() + { + TwBar* bar = TwNewBar("barMain"); + + TwAddVarRW(bar, "Radius", TW_TYPE_FLOAT, &m_AORadius, "min=1.0 max=8.0 group=AO"); + TwAddVarRW(bar, "Bias", TW_TYPE_FLOAT, &m_AOBias, "min=0.0 max=0.5 group=AO"); + TwAddVarRW(bar, "NearAO", TW_TYPE_FLOAT, &m_NearAO, "min=1.0 max=4.0 group=AO"); + TwAddVarRW(bar, "Power Exponent", TW_TYPE_FLOAT, &m_PowerExponent, "min=0.0 max=4.0 group=AO"); + TwAddVarRW(bar, "Enable Blur", TW_TYPE_BOOLCPP, &m_BlurAO, "group=Blur"); + TwAddVarRW(bar, "Blur Sharpness", TW_TYPE_FLOAT, &m_BlurSharpness, "group=Blur min=0.0 max=100.0"); + TwAddVarRW(bar, "GBuffer Normals", TW_TYPE_BOOLCPP, &m_UseGBufferNormals, "group=Normals"); + TwAddVarRW(bar, "Debug Normals", TW_TYPE_BOOLCPP, &m_DebugNormals, "group=Normals"); + } + + void UpdateUI() + { + const int barWidth = 200; + const int barHeight = 200; + const int border = 20; + + char buffer[2048]; + _snprintf_s(buffer, sizeof(buffer), + "barMain label='HBAO+' color='19 25 19' alpha=128 size='%d %d' position='%d %d' valueswidth=fit", + barWidth, barHeight, + m_BackBufferDesc.Width - barWidth - border, border); + TwDefine(buffer); + } + + void DrawText() + { + char msg[1024]; + + TwBeginText(2, 0, 0, 220); + + GFSDK_SSAO_Version Version; + GFSDK_SSAO_Status Status; + Status = GFSDK_SSAO_GetVersion(&Version); + assert(Status == GFSDK_SSAO_OK); + + unsigned int Color = 0xFFFFFFFF; + unsigned int BgColor = 0xFF000000; + + _snprintf_s(msg, sizeof(msg), "D3D11 HBAO+ %d.%d.%d.%d", Version.Major, Version.Minor, Version.Branch, Version.Revision); + TwAddTextLine(msg, Color, BgColor); + + _snprintf_s(msg, sizeof(msg), "Resolution: %d x %d", m_BackBufferDesc.Width, m_BackBufferDesc.Height); + TwAddTextLine(msg, Color, BgColor); + + _snprintf_s(msg, sizeof(msg), "GPU times (ms): Z=%.2f AO=%.2f", + g_GPUTimers.GetGPUTimeInMS(GPU_TIME_Z), + g_GPUTimers.GetGPUTimeInMS(GPU_TIME_AO)); + TwAddTextLine(msg, Color, BgColor); + + _snprintf_s(msg, sizeof(msg), "Allocated Video Memory: %d MB", m_pAOContext->GetAllocatedVideoMemoryBytes() / (1024 * 1024)); + TwAddTextLine(msg, Color, BgColor); + + TwEndText(); + } + + void DrawUI(ID3D11Device* , ID3D11DeviceContext* pDeviceContext, ID3D11RenderTargetView* pRTV, ID3D11DepthStencilView* pDSV) + { + GPUTimer TimerScope(&g_GPUTimers, pDeviceContext, GPU_TIME_UI); + + if (!g_bRenderHUD) + { + return; + } + + pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV); + pDeviceContext->OMSetDepthStencilState(NULL, 0); + pDeviceContext->OMSetBlendState(NULL, NULL, 0xffffffff); + + UpdateUI(); + DrawText(); + TwDraw(); + } + + void DrawGeometry(ID3D11Device* pDevice, ID3D11DeviceContext* pDeviceContext) + { + GPUTimer TimerScope(&g_GPUTimers, pDeviceContext, GPU_TIME_Z); + + D3D11_VIEWPORT Viewport; + Viewport.TopLeftX = 0.f; + Viewport.TopLeftY = 0.f; + Viewport.MinDepth = 0.f; + Viewport.MaxDepth = 1.f; + Viewport.Width = FLOAT(m_pSceneRTs->Width); + Viewport.Height = FLOAT(m_pSceneRTs->Height); + pDeviceContext->RSSetViewports(1, &Viewport); + + float ClearColor[4] = { 1.f, 1.f, 1.f, 0.f }; + pDeviceContext->ClearRenderTargetView(m_pSceneRTs->ColorRTV, ClearColor); + pDeviceContext->ClearDepthStencilView(m_pSceneRTs->DepthStencilDSV, D3D11_CLEAR_DEPTH, 1.0, 0); + + if (m_UseGBufferNormals) + { + ID3D11RenderTargetView* pMRTs[] = { NULL, m_pSceneRTs->NormalRTV }; + pDeviceContext->OMSetRenderTargets(SIZEOF_ARRAY(pMRTs), pMRTs, m_pSceneRTs->DepthStencilDSV); + } + else + { + pDeviceContext->OMSetRenderTargets(0, NULL, m_pSceneRTs->DepthStencilDSV); + } + + if (!m_pDepthStencilState_Enabled) + { + static D3D11_DEPTH_STENCIL_DESC DepthStencilStateDesc = + { + FALSE, //DepthEnable + D3D11_DEPTH_WRITE_MASK_ZERO, //DepthWriteMask + D3D11_COMPARISON_NEVER, //DepthFunc + FALSE, //StencilEnable + 0, //StencilReadMask + 0xFF, //StencilWriteMask + + { D3D11_STENCIL_OP_REPLACE, //StencilFailOp + D3D11_STENCIL_OP_REPLACE, //StencilDepthFailOp + D3D11_STENCIL_OP_REPLACE, //StencilPassOp + D3D11_COMPARISON_ALWAYS //StencilFunc + }, //FrontFace + + { D3D11_STENCIL_OP_REPLACE, //StencilFailOp + D3D11_STENCIL_OP_REPLACE, //StencilDepthFailOp + D3D11_STENCIL_OP_REPLACE, //StencilPassOp + D3D11_COMPARISON_ALWAYS //StencilFunc + } //BackFace + }; + DepthStencilStateDesc.DepthEnable = TRUE; + DepthStencilStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + DepthStencilStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + DepthStencilStateDesc.StencilEnable = FALSE; + SAFE_D3D_CALL(pDevice->CreateDepthStencilState(&DepthStencilStateDesc, &m_pDepthStencilState_Enabled)); + } + pDeviceContext->OMSetDepthStencilState(m_pDepthStencilState_Enabled, 0); + + if (!m_pBlendState_Disabled) + { + D3D11_BLEND_DESC BlendStateDesc; + BlendStateDesc.AlphaToCoverageEnable = FALSE; + BlendStateDesc.IndependentBlendEnable = TRUE; + for (int i = 0; i < SIZEOF_ARRAY(BlendStateDesc.RenderTarget); ++i) + { + BlendStateDesc.RenderTarget[i].BlendEnable = FALSE; + BlendStateDesc.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + } + SAFE_D3D_CALL(pDevice->CreateBlendState(&BlendStateDesc, &m_pBlendState_Disabled)); + } + pDeviceContext->OMSetBlendState(m_pBlendState_Disabled, NULL, 0xFFFFFFFF); + + if (!m_pRasterizerState_NoCull_NoScissor) + { + static D3D11_RASTERIZER_DESC RasterStateDesc = + { + D3D11_FILL_SOLID, //FillMode + D3D11_CULL_NONE, //CullMode + 0x0, //FrontCounterClockwise + 0x0/*0.000000f*/, //DepthBias + 0.f, //DepthBiasClamp + 0.f, //SlopeScaledDepthBias + 0x1, //DepthClipEnable + 0x0, //ScissorEnable + 0x0, //MultisampleEnable + 0x0 //AntialiasedLineEnable + }; + SAFE_D3D_CALL(pDevice->CreateRasterizerState(&RasterStateDesc, &m_pRasterizerState_NoCull_NoScissor)); + } + pDeviceContext->RSSetState(m_pRasterizerState_NoCull_NoScissor); + + pDeviceContext->VSSetShader(m_pGeometryVS, NULL, 0); + pDeviceContext->PSSetShader(m_pGeometryPS, NULL, 0); + + struct GlobalConstantBuffer + { + XMMATRIX WorldView; + XMMATRIX WorldViewInverse; + XMMATRIX WorldViewProjection; + float IsWhite; + float Pad[3]; + }; + + if (!m_pConstantBuffer) + { + static D3D11_BUFFER_DESC desc = + { + sizeof(GlobalConstantBuffer), //ByteWidth + D3D11_USAGE_DEFAULT, //Usage + D3D11_BIND_CONSTANT_BUFFER, //BindFlags + 0, //CPUAccessFlags + 0 //MiscFlags + }; + SAFE_D3D_CALL(pDevice->CreateBuffer(&desc, NULL, &m_pConstantBuffer)); + } + + float NearPlane = .01f; + float FarPlane = 500.0f; + float AspectRatio = (float)m_BackBufferDesc.Width / (float)m_BackBufferDesc.Height; + m_ViewInfo.ProjectionMatrix = XMMatrixPerspectiveFovLH(40.f * 3.141592f / 180.f, AspectRatio, NearPlane, FarPlane); + m_ViewInfo.WorldViewMatrix = XMMatrixIdentity(); + + XMMATRIX WorldViewMatrix; + GlobalConstantBuffer Constants = {}; + Constants.WorldView = m_ViewInfo.WorldViewMatrix; + Constants.WorldViewProjection = m_ViewInfo.ProjectionMatrix; + Constants.IsWhite = true; + Constants.WorldViewInverse = XMMatrixInverse(NULL, Constants.WorldView); + pDeviceContext->UpdateSubresource(m_pConstantBuffer, 0, NULL, &Constants, 0, 0); + + pDeviceContext->VSSetConstantBuffers(0, 1, &m_pConstantBuffer); + pDeviceContext->PSSetConstantBuffers(0, 1, &m_pConstantBuffer); + + if (!m_pVB) + { + static D3D11_BUFFER_DESC BufferDesc = + { + UINT(m_Mesh.vertices.size() * sizeof(m_Mesh.vertices[0])), //ByteWidth + D3D11_USAGE_DEFAULT, //Usage + D3D11_BIND_VERTEX_BUFFER, //BindFlags + 0, //CPUAccessFlags + 0, //MiscFlags + 0 //StructureByteStride + }; + + D3D11_SUBRESOURCE_DATA SubResourceData = { m_Mesh.vertices.data() /*pSysMem*/, 0 /*SysMemPitch*/, 0 /*SysMemSlicePitch*/ }; + SAFE_D3D_CALL(pDevice->CreateBuffer(&BufferDesc, &SubResourceData, &m_pVB)); + } + + if (!m_pIB) + { + static D3D11_BUFFER_DESC BufferDesc = + { + UINT(m_Mesh.indices.size() * sizeof(m_Mesh.indices[0])), //ByteWidth + D3D11_USAGE_DEFAULT, //Usage + D3D11_BIND_INDEX_BUFFER, //BindFlags + 0, //CPUAccessFlags + 0, //MiscFlags + 0 //StructureByteStride + }; + + D3D11_SUBRESOURCE_DATA SubResourceData = { m_Mesh.indices.data() /*pSysMem*/, 0 /*SysMemPitch*/, 0 /*SysMemSlicePitch*/ }; + SAFE_D3D_CALL(pDevice->CreateBuffer(&BufferDesc, &SubResourceData, &m_pIB)); + } + + if (!m_pInputLayout) + { + D3D11_INPUT_ELEMENT_DESC VertexLayout[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + UINT NumElements = sizeof(VertexLayout) / sizeof(VertexLayout[0]); + SAFE_D3D_CALL(pDevice->CreateInputLayout(VertexLayout, NumElements, g_GeometryVS, sizeof(g_GeometryVS), &m_pInputLayout)); + } + + assert(sizeof(m_Mesh.indices[0]) == 4); + DXGI_FORMAT IBFormat = DXGI_FORMAT_R32_UINT; + UINT Stride = sizeof(m_Mesh.vertices[0]); + UINT Offset = 0; + pDeviceContext->IASetVertexBuffers(0, 1, &m_pVB, &Stride, &Offset); + pDeviceContext->IASetIndexBuffer(m_pIB, IBFormat, 0); + pDeviceContext->IASetInputLayout(m_pInputLayout); + pDeviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + + pDeviceContext->DrawIndexed(UINT(m_Mesh.indices.size()), 0, 0); + } + + void DrawHBAO(ID3D11Device*, ID3D11DeviceContext* pDeviceContext, ID3D11RenderTargetView* pRTV) + { + GPUTimer TimerScope(&g_GPUTimers, pDeviceContext, GPU_TIME_AO); + + GFSDK_SSAO_InputData_D3D11 Input; + + Input.DepthData.DepthTextureType = GFSDK_SSAO_HARDWARE_DEPTHS; + Input.DepthData.pFullResDepthTextureSRV = m_pSceneRTs->DepthStencilSRV; + Input.DepthData.ProjectionMatrix.Data = GFSDK_SSAO_Float4x4((CONST FLOAT*)&m_ViewInfo.ProjectionMatrix); + Input.DepthData.ProjectionMatrix.Layout = GFSDK_SSAO_ROW_MAJOR_ORDER; + Input.DepthData.MetersToViewSpaceUnits = 0.005f; + + if (m_UseGBufferNormals) + { + Input.NormalData.Enable = TRUE; + Input.NormalData.pFullResNormalTextureSRV = m_pSceneRTs->NormalSRV; + Input.NormalData.WorldToViewMatrix.Data = GFSDK_SSAO_Float4x4((CONST FLOAT*)&m_ViewInfo.WorldViewMatrix); + Input.NormalData.WorldToViewMatrix.Layout = GFSDK_SSAO_ROW_MAJOR_ORDER; + Input.NormalData.DecodeScale = 2.f; + Input.NormalData.DecodeBias = -1.f; + } + + GFSDK_SSAO_Output_D3D11 Output; + Output.pRenderTargetView = pRTV;// m_pSceneRTs->ColorRTV; + Output.Blend.Mode = GFSDK_SSAO_OVERWRITE_RGB; + + GFSDK_SSAO_Parameters AOParams; + AOParams.Radius = m_AORadius; + AOParams.Bias = m_AOBias; + AOParams.NearAO = m_NearAO; + AOParams.FarAO = 1.f; + AOParams.PowerExponent = m_PowerExponent; + AOParams.Blur.Enable = m_BlurAO; + AOParams.Blur.Sharpness = m_BlurSharpness; + AOParams.Blur.Radius = GFSDK_SSAO_BLUR_RADIUS_4; + + const GFSDK_SSAO_RenderMask RenderMask = m_DebugNormals ? GFSDK_SSAO_RENDER_DEBUG_NORMAL_Z : GFSDK_SSAO_RENDER_AO; + + GFSDK_SSAO_Status Status; + Status = m_pAOContext->RenderAO(pDeviceContext, Input, AOParams, Output, RenderMask); + assert(Status == GFSDK_SSAO_OK); + } + + void ReleaseHBAO() + { + SAFE_RELEASE(m_pAOContext); + + g_GPUTimers.Release(); + } + + void ReleaseGeometry() + { + SAFE_RELEASE(m_pVB); + SAFE_RELEASE(m_pIB); + SAFE_RELEASE(m_pConstantBuffer); + SAFE_RELEASE(m_pInputLayout); + + SAFE_RELEASE(m_pDepthStencilState_Enabled); + SAFE_RELEASE(m_pBlendState_Disabled); + SAFE_RELEASE(m_pRasterizerState_NoCull_NoScissor); + } + + DXGI_SURFACE_DESC m_BackBufferDesc; + GFSDK_SSAO_Context_D3D11* m_pAOContext; + float m_AORadius; + float m_AOBias; + bool m_BlurAO; + float m_BlurSharpness; + float m_PowerExponent; + float m_NearAO; + + Mesh m_Mesh; + ID3D11Buffer* m_pVB; + ID3D11Buffer* m_pIB; + ID3D11Buffer* m_pConstantBuffer; + ID3D11InputLayout* m_pInputLayout; + ID3D11VertexShader* m_pGeometryVS; + ID3D11PixelShader* m_pGeometryPS; + + struct ViewInfo + { + XMMATRIX WorldViewMatrix; + XMMATRIX ProjectionMatrix; + }; + ViewInfo m_ViewInfo; + + ID3D11DepthStencilState* m_pDepthStencilState_Enabled; + ID3D11BlendState* m_pBlendState_Disabled; + ID3D11RasterizerState* m_pRasterizerState_NoCull_NoScissor; + + SceneRTs* m_pSceneRTs; + bool m_UseGBufferNormals; + bool m_DebugNormals; +}; + +int WINAPI wWinMain(HINSTANCE , HINSTANCE , LPWSTR , int ) +{ + // Enable run-time memory check for debug builds. +#if defined(DEBUG) + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + + g_DeviceManager = new DeviceManager(); + VisualController Controller; + g_DeviceManager->AddControllerToFront(&Controller); + + DeviceCreationParameters DeviceParams; +#if _DEBUG + DeviceParams.createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + DeviceParams.swapChainFormat = DXGI_FORMAT_R8G8B8A8_UNORM; + DeviceParams.swapChainSampleCount = 1; + DeviceParams.startFullscreen = false; + DeviceParams.backBufferWidth = 1280; + DeviceParams.backBufferHeight = 720; + + if(FAILED(g_DeviceManager->CreateWindowDeviceAndSwapChain(DeviceParams, L"NVIDIA HBAO+"))) + { + MessageBox(NULL, L"Cannot initialize the D3D11 device with the requested parameters", L"Error", MB_OK | MB_ICONERROR); + return 1; + } + + g_DeviceManager->MessageLoop(); + + delete g_DeviceManager; // destructor calls Shutdown() + + return 0; +} diff --git a/samples/D3D11/src/SSAO11.manifest b/samples/D3D11/src/SSAO11.manifest new file mode 100644 index 0000000..504a407 --- /dev/null +++ b/samples/D3D11/src/SSAO11.manifest @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity + version="1.0.0.0" + processorArchitecture="*" + name="NVIDIA.DX11SDK.SSAO11" + type="win32" +/> + <description>SSAO11</description> + <dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="*" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/samples/D3D11/src/SSAO11.rc b/samples/D3D11/src/SSAO11.rc new file mode 100644 index 0000000..628e3ee --- /dev/null +++ b/samples/D3D11/src/SSAO11.rc @@ -0,0 +1,72 @@ +// Microsoft Visual C++ generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "WinResRc.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""WinResRc.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON1 ICON "..\\Media\\directx.ico" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/samples/D3D11/src/SSAO11_2015.sln b/samples/D3D11/src/SSAO11_2015.sln new file mode 100644 index 0000000..37ced06 --- /dev/null +++ b/samples/D3D11/src/SSAO11_2015.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo", "SSAO11_2015.vcxproj", "{A66D14E4-918C-493C-81C9-7661CCCE336D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A66D14E4-918C-493C-81C9-7661CCCE336D}.Debug|x86.ActiveCfg = Debug|Win32 + {A66D14E4-918C-493C-81C9-7661CCCE336D}.Debug|x86.Build.0 = Debug|Win32 + {A66D14E4-918C-493C-81C9-7661CCCE336D}.Release|x86.ActiveCfg = Release|Win32 + {A66D14E4-918C-493C-81C9-7661CCCE336D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/D3D11/src/SSAO11_2015.vcxproj b/samples/D3D11/src/SSAO11_2015.vcxproj new file mode 100644 index 0000000..e456aa6 --- /dev/null +++ b/samples/D3D11/src/SSAO11_2015.vcxproj @@ -0,0 +1,451 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectName>SampleApp_D3D11</ProjectName> + <ProjectGuid>{A66D14E4-918C-493C-81C9-7661CCCE336D}</ProjectGuid> + <RootNamespace>EmptyProject10</RootNamespace> + <Keyword>Win32Proj</Keyword> + <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v100</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v100</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v100</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <OutDir>..\Bin\</OutDir> + <IntDir>..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <LinkIncremental>true</LinkIncremental> + <GenerateManifest>true</GenerateManifest> + <EmbedManifest>true</EmbedManifest> + <TargetName>$(ProjectName)d.win32</TargetName> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <GenerateManifest>true</GenerateManifest> + <EmbedManifest>true</EmbedManifest> + <TargetName>$(ProjectName)d.win64</TargetName> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <OutDir>..\Bin\</OutDir> + <IntDir>..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <LinkIncremental>true</LinkIncremental> + <EmbedManifest>false</EmbedManifest> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>..\Bin\</OutDir> + <IntDir>..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <LinkIncremental>false</LinkIncremental> + <GenerateManifest>true</GenerateManifest> + <EmbedManifest>true</EmbedManifest> + <TargetName>$(ProjectName).win32</TargetName> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <GenerateManifest>true</GenerateManifest> + <EmbedManifest>true</EmbedManifest> + <TargetName>$(ProjectName).win64</TargetName> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <OutDir>..\Bin\</OutDir> + <IntDir>..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <LinkIncremental>false</LinkIncremental> + <EmbedManifest>false</EmbedManifest> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'"> + <OutDir>..\..\Bin\</OutDir> + <IntDir>..\..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <LinkIncremental>false</LinkIncremental> + <EmbedManifest>false</EmbedManifest> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'"> + <IntDir>..\Temp\$(Configuration)\$(ProjectName)\</IntDir> + <OutDir>..\Bin\</OutDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>Default</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <BufferSecurityCheck>false</BufferSecurityCheck> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <PrecompiledHeaderFile> + </PrecompiledHeaderFile> + <PrecompiledHeaderOutputFile> + </PrecompiledHeaderOutputFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <Culture>0x0000</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win32.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win32;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ManifestFile>$(IntDir)$(ProjectName).manifest</ManifestFile> + <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(TargetDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention /> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO_D3D11.win32.dll ..\Bin +copy /Y ..\external\AntTweakBar\1.16\lib\win32\AntTweakBar.dll ..\Bin</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>Default</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <BufferSecurityCheck>false</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderFile>DXUT.h</PrecompiledHeaderFile> + <PrecompiledHeaderOutputFile> + </PrecompiledHeaderOutputFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <Culture>0x0000</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win32.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win32;..\external\zlib\lib\x86;%OUTPUT_DIR_LIB%;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ManifestFile>$(IntDir)$(ProjectName).manifest</ManifestFile> + <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(TargetDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO_D3D11.win64.dll ..\Bin +copy /Y ..\external\AntTweakBar\1.16\lib\win64\AntTweakBar64.dll ..\Bin</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;PROFILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>Default</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <PrecompiledHeaderFile> + </PrecompiledHeaderFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win64.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)EmptyProject10.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention /> + <TargetMachine>MachineX64</TargetMachine> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win64;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <OmitFramePointers>true</OmitFramePointers> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <ExceptionHandling>Sync</ExceptionHandling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <BufferSecurityCheck>false</BufferSecurityCheck> + <FunctionLevelLinking>true</FunctionLevelLinking> + <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <PrecompiledHeaderFile> + </PrecompiledHeaderFile> + <PrecompiledHeaderOutputFile> + </PrecompiledHeaderOutputFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat /> + </ClCompile> + <ResourceCompile> + <Culture>0x0000</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win32.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win32;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ManifestFile>$(IntDir)$(ProjectName).manifest</ManifestFile> + <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention /> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO_D3D11.win32.dll ..\Bin +copy /Y ..\external\AntTweakBar\1.16\lib\win32\AntTweakBar.dll ..\Bin</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <OmitFramePointers>true</OmitFramePointers> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <ExceptionHandling>Sync</ExceptionHandling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <BufferSecurityCheck>false</BufferSecurityCheck> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderFile>DXUT.h</PrecompiledHeaderFile> + <PrecompiledHeaderOutputFile> + </PrecompiledHeaderOutputFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <Culture>0x0000</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win32.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(ProjectName).win32.exe</OutputFile> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win32;%OUTPUT_DIR_LIB%;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ManifestFile>$(IntDir)$(ProjectName).manifest</ManifestFile> + <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO_D3D11.win64.dll ..\Bin +copy /Y ..\external\AntTweakBar\1.16\lib\win64\AntTweakBar64.dll ..\Bin</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <OmitFramePointers>true</OmitFramePointers> + <AdditionalIncludeDirectories>..\external\AntTweakBar\1.16\include;..\external\zlib\1.2.8\src;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <ExceptionHandling>Async</ExceptionHandling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <PrecompiledHeaderFile> + </PrecompiledHeaderFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>GFSDK_SSAO_D3D11.win64.lib;dxguid.lib;d3d11.lib;winmm.lib;comctl32.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention /> + <TargetMachine>MachineX64</TargetMachine> + <AdditionalLibraryDirectories>..\external\AntTweakBar\1.16\Lib\Win64;..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <OmitFramePointers>true</OmitFramePointers> + <AdditionalIncludeDirectories>..\..\..\public\testapp\include\DXSDK;..\..\..\public\testapp\include\DXUT\Core;..\..\..\public\testapp\include\DXUT\Optional;..\..\..\public\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;PROFILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <ExceptionHandling /> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader>Create</PrecompiledHeader> + <PrecompiledHeaderFile>DXUT.h</PrecompiledHeaderFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>dxerr9.lib;dxguid.lib;d3dx9.lib;d3d9.lib;winmm.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)EmptyProject10.exe</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention /> + <TargetMachine>MachineX64</TargetMachine> + <AdditionalLibraryDirectories>..\..\lib\x64;..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'"> + <ClCompile> + <AdditionalIncludeDirectories>..\external\DXSDK\June_2010\Include;..\include\DXUT\Core;..\include\DXUT\Optional;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <AdditionalLibraryDirectories>..\external\DXSDK\June_2010\Lib\x86;%OUTPUT_DIR_LIB%;..\..\..\lib;..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO.win32.dll ..\Bin + </Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'"> + <ClCompile> + <AdditionalIncludeDirectories>..\external\DXSDK\June_2010\Include;..\include\DXUT\Core;..\include\DXUT\Optional;..\..\..\lib;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <AdditionalLibraryDirectories>..\external\DXSDK\June_2010\Lib\x86;%OUTPUT_DIR_LIB%;..\..\..\lib;..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PreBuildEvent> + <Command>copy /Y ..\..\..\lib\GFSDK_SSAO.win32.dll ..\Bin + </Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="DeviceManager.cpp" /> + <ClCompile Include="GPUTimers.cpp" /> + <ClCompile Include="SSAO11.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\..\lib\GFSDK_SSAO.h" /> + <ClInclude Include="..\external\AntTweakBar\1.16\include\AntTweakBar.h" /> + <ClInclude Include="BinMeshReader.h" /> + <ClInclude Include="DeviceManager.h" /> + <ClInclude Include="GPUTimers.h" /> + <ClInclude Include="SceneRTs.h" /> + </ItemGroup> + <ItemGroup> + <Image Include="..\..\Media\directx.ico" /> + </ItemGroup> + <ItemGroup> + <Manifest Include="SSAO11.manifest" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="SSAO11.rc" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> +</Project>
\ No newline at end of file diff --git a/samples/D3D11/src/SSAO11_2015.vcxproj.filters b/samples/D3D11/src/SSAO11_2015.vcxproj.filters new file mode 100644 index 0000000..2fad1ae --- /dev/null +++ b/samples/D3D11/src/SSAO11_2015.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClCompile Include="SSAO11.cpp" /> + <ClCompile Include="GPUTimers.cpp" /> + <ClCompile Include="DeviceManager.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="GPUTimers.h" /> + <ClInclude Include="DeviceManager.h" /> + <ClInclude Include="..\external\AntTweakBar\1.16\include\AntTweakBar.h" /> + <ClInclude Include="BinMeshReader.h" /> + <ClInclude Include="SceneRTs.h" /> + <ClInclude Include="..\..\..\lib\GFSDK_SSAO.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="SSAO11.rc" /> + </ItemGroup> + <ItemGroup> + <Manifest Include="SSAO11.manifest" /> + </ItemGroup> + <ItemGroup> + <Image Include="..\..\Media\directx.ico" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/samples/D3D11/src/SceneRTs.h b/samples/D3D11/src/SceneRTs.h new file mode 100644 index 0000000..7e40d85 --- /dev/null +++ b/samples/D3D11/src/SceneRTs.h @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#pragma once + +#include <D3D11.h> + +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } +#endif + +struct SceneRTs +{ + struct Desc + { + UINT OutputWidth; + UINT OutputHeight; + UINT BorderPixels; + UINT SampleCount; + }; + + SceneRTs(ID3D11Device* pDevice, Desc &desc) + : Width(desc.OutputWidth + 2 * desc.BorderPixels) + , Height(desc.OutputHeight + 2 * desc.BorderPixels) + , OutputWidth(desc.OutputWidth) + , OutputHeight(desc.OutputHeight) + , BorderPixels(desc.BorderPixels) + , SampleCount(desc.SampleCount) + { + CreateGBufferTextures(pDevice); + CreateOutputTexture(pDevice); + CreateDepthTexture(pDevice); + } + + void CreateGBufferTextures(ID3D11Device* pDevice) + { + D3D11_TEXTURE2D_DESC texDesc; + texDesc.Width = Width; + texDesc.Height = Height; + texDesc.ArraySize = 1; + texDesc.MiscFlags = 0; + texDesc.MipLevels = 1; + texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; + texDesc.Usage = D3D11_USAGE_DEFAULT; + texDesc.CPUAccessFlags = NULL; + + // Allocate MSAA color buffer + texDesc.SampleDesc.Count = SampleCount; + texDesc.SampleDesc.Quality = 0; + texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + + pDevice->CreateTexture2D(&texDesc, NULL, &ColorTexture); + pDevice->CreateRenderTargetView(ColorTexture, NULL, &ColorRTV); + pDevice->CreateShaderResourceView(ColorTexture, NULL, &ColorSRV); + + // Allocate MSAA normal buffer + texDesc.Format = DXGI_FORMAT_R11G11B10_FLOAT; + + pDevice->CreateTexture2D(&texDesc, NULL, &NormalTexture); + pDevice->CreateRenderTargetView(NormalTexture, NULL, &NormalRTV); + pDevice->CreateShaderResourceView(NormalTexture, NULL, &NormalSRV); + + // Allocate non-MSAA color buffer + texDesc.SampleDesc.Count = 1; + texDesc.SampleDesc.Quality = 0; + texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + + pDevice->CreateTexture2D(&texDesc, NULL, &ResolvedColorTexture); + pDevice->CreateRenderTargetView(ColorTexture, NULL, &ResolvedColorRTV); + pDevice->CreateShaderResourceView(ColorTexture, NULL, &ResolvedColorSRV); + } + + void CreateOutputTexture(ID3D11Device* pDevice) + { + D3D11_TEXTURE2D_DESC texDesc; + texDesc.Width = OutputWidth; + texDesc.Height = OutputHeight; + texDesc.ArraySize = 1; + texDesc.MiscFlags = 0; + texDesc.MipLevels = 1; + texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; + texDesc.Usage = D3D11_USAGE_DEFAULT; + texDesc.CPUAccessFlags = NULL; + texDesc.SampleDesc.Count = 1; + texDesc.SampleDesc.Quality = 0; + texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + + pDevice->CreateTexture2D(&texDesc, NULL, &OutputTexture); + pDevice->CreateRenderTargetView(OutputTexture, NULL, &OutputRTV); + pDevice->CreateShaderResourceView(OutputTexture, NULL, &OutputSRV); + } + + void CreateDepthTexture(ID3D11Device* pDevice) + { + // Create a hardware-depth texture that can be fetched from a shader. + // To do so, use a TYPELESS format and set the D3D11_BIND_SHADER_RESOURCE flag. + // D3D10.0 did not allow creating such a depth texture with SampleCount > 1. + // This is now possible since D3D10.1. + D3D11_TEXTURE2D_DESC texDesc; + texDesc.ArraySize = 1; + texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE; + texDesc.CPUAccessFlags = NULL; + texDesc.Width = Width; + texDesc.Height = Height; + texDesc.MipLevels = 1; + texDesc.MiscFlags = NULL; + texDesc.SampleDesc.Count = SampleCount; + texDesc.SampleDesc.Quality = 0; + texDesc.Usage = D3D11_USAGE_DEFAULT; + texDesc.Format = DXGI_FORMAT_R24G8_TYPELESS; + pDevice->CreateTexture2D(&texDesc, NULL, &DepthStencilTexture); + + // Create a depth-stencil view + D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; + dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + if (SampleCount > 1) + { + dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; + } + else + { + dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + } + dsvDesc.Texture2D.MipSlice = 0; + dsvDesc.Flags = 0; // new in D3D11 + pDevice->CreateDepthStencilView(DepthStencilTexture, &dsvDesc, &DepthStencilDSV); + + // Create a shader resource view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + if (SampleCount > 1) + { + srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS; + } + else + { + srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = 1; + srvDesc.Texture2D.MostDetailedMip = 0; + } + pDevice->CreateShaderResourceView(DepthStencilTexture, &srvDesc, &DepthStencilSRV); + } + + ~SceneRTs() + { + SAFE_RELEASE(ColorTexture); + SAFE_RELEASE(ColorRTV); + SAFE_RELEASE(ColorSRV); + + SAFE_RELEASE(ResolvedColorTexture); + SAFE_RELEASE(ResolvedColorRTV); + SAFE_RELEASE(ResolvedColorSRV); + + SAFE_RELEASE(NormalTexture); + SAFE_RELEASE(NormalRTV); + SAFE_RELEASE(NormalSRV); + + SAFE_RELEASE(OutputTexture); + SAFE_RELEASE(OutputRTV); + SAFE_RELEASE(OutputSRV); + + SAFE_RELEASE(DepthStencilTexture); + SAFE_RELEASE(DepthStencilSRV); + SAFE_RELEASE(DepthStencilDSV); + } + + UINT Width; + UINT Height; + UINT OutputWidth; + UINT OutputHeight; + UINT BorderPixels; + UINT SampleCount; + ID3D11Texture2D* ColorTexture; + ID3D11RenderTargetView* ColorRTV; + ID3D11ShaderResourceView* ColorSRV; + ID3D11Texture2D* ResolvedColorTexture; + ID3D11RenderTargetView* ResolvedColorRTV; + ID3D11ShaderResourceView* ResolvedColorSRV; + ID3D11Texture2D* NormalTexture; + ID3D11RenderTargetView* NormalRTV; + ID3D11ShaderResourceView* NormalSRV; + ID3D11Texture2D* OutputTexture; + ID3D11RenderTargetView* OutputRTV; + ID3D11ShaderResourceView* OutputSRV; + ID3D11Texture2D* DepthStencilTexture; + ID3D11ShaderResourceView* DepthStencilSRV; + ID3D11DepthStencilView* DepthStencilDSV; +}; diff --git a/samples/D3D11/src/SibenikIndices.bin b/samples/D3D11/src/SibenikIndices.bin Binary files differnew file mode 100644 index 0000000..8775c0c --- /dev/null +++ b/samples/D3D11/src/SibenikIndices.bin diff --git a/samples/D3D11/src/SibenikVertices.bin b/samples/D3D11/src/SibenikVertices.bin Binary files differnew file mode 100644 index 0000000..561d39e --- /dev/null +++ b/samples/D3D11/src/SibenikVertices.bin diff --git a/samples/D3D11/src/shaders/bin/CopyColorPS.h b/samples/D3D11/src/shaders/bin/CopyColorPS.h new file mode 100644 index 0000000..03a551e --- /dev/null +++ b/samples/D3D11/src/shaders/bin/CopyColorPS.h @@ -0,0 +1,168 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /O3 /T ps_5_0 src/Scene3D.hlsl /E CopyColorPS /Fh bin/CopyColorPS.h +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// PointSampler sampler NA NA 0 1 +// tColor texture float3 2d 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_Position 0 xyzw 0 POS float +// TexCoord 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 1 +sample_indexable(texture2d)(float,float,float,float) r0.xyz, v1.xyxx, t0.xyzw, s0 +mov o0.xyz, r0.xyzx +mov o0.w, l(1.000000) +ret +// Approximately 4 instruction slots used +#endif + +const BYTE g_CopyColorPS[] = +{ + 68, 88, 66, 67, 135, 247, + 240, 213, 242, 107, 236, 51, + 243, 123, 169, 205, 39, 122, + 55, 177, 1, 0, 0, 0, + 208, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 0, 1, 0, 0, 88, 1, + 0, 0, 140, 1, 0, 0, + 52, 2, 0, 0, 82, 68, + 69, 70, 196, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 129, 0, 0, + 144, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 124, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 137, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 9, 0, 0, 0, 80, 111, + 105, 110, 116, 83, 97, 109, + 112, 108, 101, 114, 0, 116, + 67, 111, 108, 111, 114, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 80, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 101, 120, 67, + 111, 111, 114, 100, 0, 171, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 69, 88, 160, 0, + 0, 0, 80, 0, 0, 0, + 40, 0, 0, 0, 106, 8, + 0, 1, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/samples/D3D11/src/shaders/bin/FullScreenTriangleVS.h b/samples/D3D11/src/shaders/bin/FullScreenTriangleVS.h new file mode 100644 index 0000000..64e3281 --- /dev/null +++ b/samples/D3D11/src/shaders/bin/FullScreenTriangleVS.h @@ -0,0 +1,168 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /O3 /T vs_5_0 src/Scene3D.hlsl /E FullScreenTriangleVS /Fh +// bin/FullScreenTriangleVS.h +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_VertexID 0 x 0 VERTID uint x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_Position 0 xyzw 0 POS float xyzw +// TexCoord 0 xy 1 NONE float xy +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_input_sgv v0.x, vertex_id +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +dcl_temps 1 +bfi r0.x, l(1), l(1), v0.x, l(0) +and r0.z, v0.x, l(2) +utof r0.xy, r0.xzxx +mad o0.xy, r0.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000) +mov o1.xy, r0.xyxx +mov o0.zw, l(0,0,0,1.000000) +ret +// Approximately 7 instruction slots used +#endif + +const BYTE g_FullScreenTriangleVS[] = +{ + 68, 88, 66, 67, 52, 104, + 138, 187, 33, 254, 6, 251, + 172, 170, 188, 203, 33, 161, + 7, 239, 1, 0, 0, 0, + 236, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 224, 0, + 0, 0, 56, 1, 0, 0, + 80, 2, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 129, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, + 0, 0, 83, 86, 95, 86, + 101, 114, 116, 101, 120, 73, + 68, 0, 79, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 101, 120, 67, 111, 111, + 114, 100, 0, 171, 171, 171, + 83, 72, 69, 88, 16, 1, + 0, 0, 80, 0, 1, 0, + 68, 0, 0, 0, 106, 8, + 0, 1, 96, 0, 0, 4, + 18, 16, 16, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 140, 0, 0, 11, 18, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 1, 0, 0, 0, 10, 16, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 2, 0, 0, 0, + 86, 0, 0, 5, 50, 0, + 16, 0, 0, 0, 0, 0, + 134, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 15, + 50, 32, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 192, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 191, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 8, 194, 32, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 7, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/samples/D3D11/src/shaders/bin/GeometryPS.h b/samples/D3D11/src/shaders/bin/GeometryPS.h new file mode 100644 index 0000000..8cbc839 --- /dev/null +++ b/samples/D3D11/src/shaders/bin/GeometryPS.h @@ -0,0 +1,315 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /O3 /T ps_5_0 src/Scene3D.hlsl /E GeometryPS /Fh bin/GeometryPS.h +// +// +// Buffer Definitions: +// +// cbuffer GlobalConstantBuffer +// { +// +// row_major float4x4 g_WorldView; // Offset: 0 Size: 64 [unused] +// row_major float4x4 g_WorldViewInverse;// Offset: 64 Size: 64 +// row_major float4x4 g_WorldViewProjection;// Offset: 128 Size: 64 [unused] +// float g_IsWhite; // Offset: 192 Size: 4 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// GlobalConstantBuffer cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyz 2 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// SV_Target 1 xyz 1 TARGET float xyz +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[13], immediateIndexed +dcl_input_ps linear centroid v1.xyz +dcl_output o0.xyzw +dcl_output o1.xyz +dcl_temps 3 +ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[12].x +movc o0.xyzw, r0.xxxx, l(1.000000,1.000000,1.000000,1.000000), l(0.457000,0.722000,0,1.000000) +deriv_rtx_coarse r0.xyz, v1.zxyz +deriv_rty_coarse r1.xyz, v1.yzxy +mul r2.xyz, r0.xyzx, r1.xyzx +mad r0.xyz, r0.zxyz, r1.yzxy, -r2.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[5].xyzx +mad r0.xyw, r0.xxxx, cb0[4].xyxz, r1.xyxz +mad r0.xyz, r0.zzzz, cb0[6].xyzx, r0.xywx +mad o1.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000) +ret +// Approximately 14 instruction slots used +#endif + +const BYTE g_GeometryPS[] = +{ + 68, 88, 66, 67, 166, 194, + 48, 172, 249, 92, 247, 65, + 27, 247, 154, 59, 213, 36, + 173, 34, 1, 0, 0, 0, + 176, 5, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 56, 2, 0, 0, 168, 2, + 0, 0, 244, 2, 0, 0, + 20, 5, 0, 0, 82, 68, + 69, 70, 252, 1, 0, 0, + 1, 0, 0, 0, 116, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 129, 0, 0, + 200, 1, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 71, 108, 111, 98, + 97, 108, 67, 111, 110, 115, + 116, 97, 110, 116, 66, 117, + 102, 102, 101, 114, 0, 171, + 171, 171, 92, 0, 0, 0, + 4, 0, 0, 0, 140, 0, + 0, 0, 208, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 44, 1, 0, 0, + 0, 0, 0, 0, 64, 0, + 0, 0, 0, 0, 0, 0, + 68, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 104, 1, 0, 0, 64, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 0, 0, 68, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 123, 1, + 0, 0, 128, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 68, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 145, 1, 0, 0, + 192, 0, 0, 0, 4, 0, + 0, 0, 2, 0, 0, 0, + 164, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 95, 87, 111, 114, 108, + 100, 86, 105, 101, 119, 0, + 102, 108, 111, 97, 116, 52, + 120, 52, 0, 171, 171, 171, + 2, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 56, 1, 0, 0, + 103, 95, 87, 111, 114, 108, + 100, 86, 105, 101, 119, 73, + 110, 118, 101, 114, 115, 101, + 0, 103, 95, 87, 111, 114, + 108, 100, 86, 105, 101, 119, + 80, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 103, + 95, 73, 115, 87, 104, 105, + 116, 101, 0, 102, 108, 111, + 97, 116, 0, 171, 171, 171, + 0, 0, 3, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 155, 1, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 104, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 92, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 68, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 56, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 8, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171, + 83, 72, 69, 88, 24, 2, + 0, 0, 80, 0, 0, 0, + 134, 0, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 98, 24, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 3, 0, + 0, 0, 57, 0, 0, 11, + 18, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 55, 0, + 0, 15, 242, 32, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 2, 64, 0, 0, + 231, 251, 233, 62, 254, 212, + 56, 63, 0, 0, 0, 0, + 0, 0, 128, 63, 122, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 38, 25, + 16, 0, 1, 0, 0, 0, + 124, 0, 0, 5, 114, 0, + 16, 0, 1, 0, 0, 0, + 150, 20, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 38, 9, 16, 0, 0, 0, + 0, 0, 150, 4, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 70, 8, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 3, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 15, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 14, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/samples/D3D11/src/shaders/bin/GeometryVS.h b/samples/D3D11/src/shaders/bin/GeometryVS.h new file mode 100644 index 0000000..3d3af34 --- /dev/null +++ b/samples/D3D11/src/shaders/bin/GeometryVS.h @@ -0,0 +1,293 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /O3 /T vs_5_0 src/Scene3D.hlsl /E GeometryVS /Fh bin/GeometryVS.h +// +// +// Buffer Definitions: +// +// cbuffer GlobalConstantBuffer +// { +// +// row_major float4x4 g_WorldView; // Offset: 0 Size: 64 +// row_major float4x4 g_WorldViewInverse;// Offset: 64 Size: 64 [unused] +// row_major float4x4 g_WorldViewProjection;// Offset: 128 Size: 64 +// float g_IsWhite; // Offset: 192 Size: 4 [unused] +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// GlobalConstantBuffer cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// NORMAL 0 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyz 2 NONE float xyz +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[12], immediateIndexed +dcl_input v0.xyz +dcl_input v1.xyz +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_output o2.xyz +dcl_temps 1 +mul r0.xyzw, v0.yyyy, cb0[9].xyzw +mad r0.xyzw, v0.xxxx, cb0[8].xyzw, r0.xyzw +mad r0.xyzw, v0.zzzz, cb0[10].xyzw, r0.xyzw +add o0.xyzw, r0.xyzw, cb0[11].xyzw +mul r0.xyz, v0.yyyy, cb0[1].xyzx +mad r0.xyz, v0.xxxx, cb0[0].xyzx, r0.xyzx +mad r0.xyz, v0.zzzz, cb0[2].xyzx, r0.xyzx +add o1.xyz, r0.xyzx, cb0[3].xyzx +mov o2.xyz, v1.xyzx +ret +// Approximately 10 instruction slots used +#endif + +const BYTE g_GeometryVS[] = +{ + 68, 88, 66, 67, 229, 202, + 254, 249, 218, 193, 230, 243, + 132, 191, 240, 223, 106, 250, + 79, 79, 1, 0, 0, 0, + 56, 5, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 56, 2, 0, 0, 136, 2, + 0, 0, 248, 2, 0, 0, + 156, 4, 0, 0, 82, 68, + 69, 70, 252, 1, 0, 0, + 1, 0, 0, 0, 116, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 129, 0, 0, + 200, 1, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 71, 108, 111, 98, + 97, 108, 67, 111, 110, 115, + 116, 97, 110, 116, 66, 117, + 102, 102, 101, 114, 0, 171, + 171, 171, 92, 0, 0, 0, + 4, 0, 0, 0, 140, 0, + 0, 0, 208, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 44, 1, 0, 0, + 0, 0, 0, 0, 64, 0, + 0, 0, 2, 0, 0, 0, + 68, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 104, 1, 0, 0, 64, 0, + 0, 0, 64, 0, 0, 0, + 0, 0, 0, 0, 68, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 123, 1, + 0, 0, 128, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 68, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 145, 1, 0, 0, + 192, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 164, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 95, 87, 111, 114, 108, + 100, 86, 105, 101, 119, 0, + 102, 108, 111, 97, 116, 52, + 120, 52, 0, 171, 171, 171, + 2, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 56, 1, 0, 0, + 103, 95, 87, 111, 114, 108, + 100, 86, 105, 101, 119, 73, + 110, 118, 101, 114, 115, 101, + 0, 103, 95, 87, 111, 114, + 108, 100, 86, 105, 101, 119, + 80, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 103, + 95, 73, 115, 87, 104, 105, + 116, 101, 0, 102, 108, 111, + 97, 116, 0, 171, 171, 171, + 0, 0, 3, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 155, 1, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 7, 7, + 0, 0, 65, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 78, + 79, 82, 77, 65, 76, 0, + 79, 83, 71, 78, 104, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 8, 0, 0, 92, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 83, 72, + 69, 88, 156, 1, 0, 0, + 80, 0, 1, 0, 103, 0, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 2, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 0, 0, 0, 0, 86, 21, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 86, 21, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 10, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/samples/D3D11/src/shaders/compile.bat b/samples/D3D11/src/shaders/compile.bat new file mode 100644 index 0000000..85e81d3 --- /dev/null +++ b/samples/D3D11/src/shaders/compile.bat @@ -0,0 +1,15 @@ +@echo off +cd %~dp0 +del /F /Q bin\* + +set FXC=fxc.exe + +%FXC% /O3 /T ps_5_0 src/Scene3D.hlsl /E GeometryPS /Fh bin/GeometryPS.h + +%FXC% /O3 /T ps_5_0 src/Scene3D.hlsl /E CopyColorPS /Fh bin/CopyColorPS.h + +%FXC% /O3 /T vs_5_0 src/Scene3D.hlsl /E FullScreenTriangleVS /Fh bin/FullScreenTriangleVS.h + +%FXC% /O3 /T vs_5_0 src/Scene3D.hlsl /E GeometryVS /Fh bin/GeometryVS.h + +pause diff --git a/samples/D3D11/src/shaders/src/Scene3D.hlsl b/samples/D3D11/src/shaders/src/Scene3D.hlsl new file mode 100644 index 0000000..460f4e6 --- /dev/null +++ b/samples/D3D11/src/shaders/src/Scene3D.hlsl @@ -0,0 +1,122 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008-2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma pack_matrix( row_major ) + +#define USE_DDX_DDY 1 +#define USE_PER_SAMPLE_SHADING 0 + +cbuffer GlobalConstantBuffer : register(b0) +{ + float4x4 g_WorldView; + float4x4 g_WorldViewInverse; + float4x4 g_WorldViewProjection; + float g_IsWhite; +}; + +Texture2D<float3> tColor : register(t0); +SamplerState PointSampler : register(s0); + +//----------------------------------------------------------------------------- +// Geometry-rendering shaders +//----------------------------------------------------------------------------- + +struct VS_INPUT +{ + float3 WorldPosition : POSITION; + float3 WorldNormal : NORMAL; +}; + +struct VS_OUTPUT +{ + float4 HPosition : SV_POSITION; + centroid float3 ViewPosition : TEXCOORD0; + centroid float3 WorldNormal : TEXCOORD1; +}; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float3 WorldNormal : SV_Target1; +}; + +VS_OUTPUT GeometryVS( VS_INPUT input ) +{ + VS_OUTPUT output; + output.HPosition = mul( float4(input.WorldPosition,1), g_WorldViewProjection ); + output.ViewPosition = mul( float4(input.WorldPosition,1), g_WorldView ).xyz; + output.WorldNormal = input.WorldNormal.xyz; + return output; +} + +PS_OUTPUT GeometryPS( VS_OUTPUT input +#if USE_PER_SAMPLE_SHADING + , uint SampleIndex : SV_SampleIndex +#endif + ) +{ + PS_OUTPUT output; + output.Color = g_IsWhite ? float4(1,1,1,1) : float4(.457,.722, 0.0, 1); + +#if USE_DDX_DDY + float3 ViewNormal = normalize(cross(ddx(input.ViewPosition.xyz), ddy(input.ViewPosition.xyz))); + output.WorldNormal = mul(ViewNormal, (float3x3)g_WorldViewInverse); +#else + output.WorldNormal = input.WorldNormal; +#endif + + // Lerp to [0,1]^3 to store in the non-signed R11G11B10_FLOAT format + output.WorldNormal = output.WorldNormal * 0.5 + 0.5; + return output; +} + +//----------------------------------------------------------------------------- +// Post-processing shaders +//----------------------------------------------------------------------------- + +struct PostProc_VSOut +{ + float4 pos : SV_Position; + float2 uv : TexCoord; +}; + +// Vertex shader that generates a full screen quad with texcoords +// To use draw 3 vertices with primitive type triangle list +PostProc_VSOut FullScreenTriangleVS( uint id : SV_VertexID ) +{ + PostProc_VSOut output = (PostProc_VSOut)0.0f; + output.uv = float2( (id << 1) & 2, id & 2 ); + output.pos = float4( output.uv * float2( 2.0f, -2.0f ) + float2( -1.0f, 1.0f), 0.0f, 1.0f ); + return output; +} + +float4 CopyColorPS( PostProc_VSOut IN ) : SV_TARGET +{ + float3 color = tColor.Sample(PointSampler, IN.uv); + return float4(color,1); +} |