aboutsummaryrefslogtreecommitdiff
path: root/demo/DemoAppD3D11
diff options
context:
space:
mode:
Diffstat (limited to 'demo/DemoAppD3D11')
-rw-r--r--demo/DemoAppD3D11/DemoAppD3D11.vcxproj269
-rw-r--r--demo/DemoAppD3D11/DemoAppD3D11.vcxproj.filters71
-rw-r--r--demo/DemoAppD3D11/NvFlowInteropD3D11.cpp66
-rw-r--r--demo/DemoAppD3D11/appD3D11Ctx.cpp766
-rw-r--r--demo/DemoAppD3D11/appD3D11Ctx.h43
-rw-r--r--demo/DemoAppD3D11/computeContextD3D11.cpp343
-rw-r--r--demo/DemoAppD3D11/computeContextD3D11.h30
-rw-r--r--demo/DemoAppD3D11/imguiGraphD3D11.cpp472
-rw-r--r--demo/DemoAppD3D11/imguiGraphD3D11.h33
-rw-r--r--demo/DemoAppD3D11/imguiInteropD3D11.cpp42
-rw-r--r--demo/DemoAppD3D11/imguiPS.hlsl.h195
-rw-r--r--demo/DemoAppD3D11/imguiVS.hlsl.h246
-rw-r--r--demo/DemoAppD3D11/meshD3D11.cpp260
-rw-r--r--demo/DemoAppD3D11/meshD3D11.h19
-rw-r--r--demo/DemoAppD3D11/meshInteropD3D11.cpp38
-rw-r--r--demo/DemoAppD3D11/meshPS.hlsl.h205
-rw-r--r--demo/DemoAppD3D11/meshVS.hlsl.h223
17 files changed, 3321 insertions, 0 deletions
diff --git a/demo/DemoAppD3D11/DemoAppD3D11.vcxproj b/demo/DemoAppD3D11/DemoAppD3D11.vcxproj
new file mode 100644
index 0000000..b3b19b3
--- /dev/null
+++ b/demo/DemoAppD3D11/DemoAppD3D11.vcxproj
@@ -0,0 +1,269 @@
+<?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="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Condition="'$(Platform)'=='Win32'">
+ <PlatformName>win32</PlatformName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Platform)'=='x64'">
+ <PlatformName>win64</PlatformName>
+ </PropertyGroup>
+ <ItemGroup>
+ <ClCompile Include="appD3D11Ctx.cpp" />
+ <ClCompile Include="computeContextD3D11.cpp" />
+ <ClCompile Include="imguiGraphD3D11.cpp" />
+ <ClCompile Include="imguiInteropD3D11.cpp" />
+ <ClCompile Include="meshD3D11.cpp" />
+ <ClCompile Include="meshInteropD3D11.cpp" />
+ <ClCompile Include="NvFlowInteropD3D11.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="appD3D11Ctx.h" />
+ <ClInclude Include="computeContextD3D11.h" />
+ <ClInclude Include="imguiGraphD3D11.h" />
+ <ClInclude Include="meshD3D11.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="..\Shaders\imguiPS.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\imguiVS.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\meshPS.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\meshVS.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
+ </FxCompile>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{A8C5329D-82CC-4D1A-971C-243B65AA3D7B}</ProjectGuid>
+ <RootNamespace>DemoAppD3D11</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>Static</UseOfMfc>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>Static</UseOfMfc>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>Static</UseOfMfc>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>Static</UseOfMfc>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)bin\$(PlatformName)\</OutDir>
+ <IntDir>interm\$(Configuration)_$(PlatformName)\</IntDir>
+ <IncludePath>$(SolutionDir)\include;$(SolutionDir)\NvFlowContextD3D11;$(SolutionDir)\NvFlow;$(SolutionDir)\NvFlowContext;$(SolutionDir)external\SDL2\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <LibraryPath>$(SolutionDir)lib\win64;$(SolutionDir)external\SDL2\lib\x64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64</LibraryPath>
+ <TargetName>$(ProjectName)$(Configuration)_$(PlatformName)</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)bin\$(PlatformName)\</OutDir>
+ <IntDir>interm\$(Configuration)_$(PlatformName)\</IntDir>
+ <IncludePath>$(SolutionDir)\include;$(SolutionDir)\NvFlowContextD3D11;$(SolutionDir)\NvFlow;$(SolutionDir)\NvFlowContext;$(SolutionDir)external\SDL2\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <LibraryPath>$(SolutionDir)lib\win64;$(SolutionDir)external\SDL2\lib\x64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64</LibraryPath>
+ <TargetName>$(ProjectName)$(Configuration)_$(PlatformName)</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IncludePath>$(SolutionDir)\include;$(SolutionDir)\NvFlowContextD3D11;$(SolutionDir)\NvFlow;$(SolutionDir)\NvFlowContext;$(SolutionDir)external\SDL2\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <LibraryPath>$(SolutionDir)lib\win32;$(SolutionDir)external\SDL2\lib\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
+ <OutDir>$(SolutionDir)bin\$(PlatformName)\</OutDir>
+ <IntDir>interm\$(Configuration)_$(PlatformName)\</IntDir>
+ <TargetName>$(ProjectName)$(Configuration)_$(PlatformName)</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <IncludePath>$(SolutionDir)\include;$(SolutionDir)\NvFlowContextD3D11;$(SolutionDir)\NvFlow;$(SolutionDir)\NvFlowContext;$(SolutionDir)external\SDL2\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <LibraryPath>$(SolutionDir)lib\win32;$(SolutionDir)external\SDL2\lib\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
+ <OutDir>$(SolutionDir)bin\$(PlatformName)\</OutDir>
+ <IntDir>interm\$(Configuration)_$(PlatformName)\</IntDir>
+ <TargetName>$(ProjectName)$(Configuration)_$(PlatformName)</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>NvFlowLib$(Configuration)_$(PlatformName).lib;SDL2.lib;SDL2main.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <FxCompile>
+ <EntryPointName>%(Filename)</EntryPointName>
+ </FxCompile>
+ <FxCompile>
+ <ShaderModel>5.0</ShaderModel>
+ </FxCompile>
+ <FxCompile>
+ <VariableName>
+ </VariableName>
+ </FxCompile>
+ <FxCompile>
+ <HeaderFileOutput>$(ProjectDir)%(Filename).hlsl.h</HeaderFileOutput>
+ </FxCompile>
+ <FxCompile>
+ <ObjectFileOutput />
+ </FxCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>NvFlowLib$(Configuration)_$(PlatformName).lib;SDL2.lib;SDL2main.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <FxCompile>
+ <EntryPointName>%(Filename)</EntryPointName>
+ </FxCompile>
+ <FxCompile>
+ <ShaderModel>5.0</ShaderModel>
+ </FxCompile>
+ <FxCompile>
+ <VariableName>
+ </VariableName>
+ </FxCompile>
+ <FxCompile>
+ <HeaderFileOutput>$(ProjectDir)%(Filename).hlsl.h</HeaderFileOutput>
+ </FxCompile>
+ <FxCompile>
+ <ObjectFileOutput />
+ </FxCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>NvFlowLib$(Configuration)_$(PlatformName).lib;SDL2.lib;SDL2main.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <FxCompile>
+ <EntryPointName>%(Filename)</EntryPointName>
+ </FxCompile>
+ <FxCompile>
+ <ShaderModel>5.0</ShaderModel>
+ </FxCompile>
+ <FxCompile>
+ <VariableName>
+ </VariableName>
+ </FxCompile>
+ <FxCompile>
+ <HeaderFileOutput>$(ProjectDir)%(Filename).hlsl.h</HeaderFileOutput>
+ </FxCompile>
+ <FxCompile>
+ <ObjectFileOutput />
+ </FxCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>NvFlowLib$(Configuration)_$(PlatformName).lib;SDL2.lib;SDL2main.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <FxCompile>
+ <EntryPointName>%(Filename)</EntryPointName>
+ </FxCompile>
+ <FxCompile>
+ <ShaderModel>5.0</ShaderModel>
+ </FxCompile>
+ <FxCompile>
+ <VariableName>
+ </VariableName>
+ </FxCompile>
+ <FxCompile>
+ <HeaderFileOutput>$(ProjectDir)%(Filename).hlsl.h</HeaderFileOutput>
+ </FxCompile>
+ <FxCompile>
+ <ObjectFileOutput />
+ </FxCompile>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/demo/DemoAppD3D11/DemoAppD3D11.vcxproj.filters b/demo/DemoAppD3D11/DemoAppD3D11.vcxproj.filters
new file mode 100644
index 0000000..469e1e0
--- /dev/null
+++ b/demo/DemoAppD3D11/DemoAppD3D11.vcxproj.filters
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ <Filter Include="Shaders">
+ <UniqueIdentifier>{154d623a-ffac-4ddd-a878-c4dc912a750d}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="appD3D11Ctx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="imguiGraphD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="meshD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="NvFlowInteropD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="meshInteropD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="imguiInteropD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="computeContextD3D11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="appD3D11Ctx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="imguiGraphD3D11.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="meshD3D11.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="computeContextD3D11.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="..\Shaders\imguiPS.hlsl">
+ <Filter>Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\imguiVS.hlsl">
+ <Filter>Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\meshPS.hlsl">
+ <Filter>Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\Shaders\meshVS.hlsl">
+ <Filter>Shaders</Filter>
+ </FxCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/demo/DemoAppD3D11/NvFlowInteropD3D11.cpp b/demo/DemoAppD3D11/NvFlowInteropD3D11.cpp
new file mode 100644
index 0000000..23aaf9c
--- /dev/null
+++ b/demo/DemoAppD3D11/NvFlowInteropD3D11.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014-2017, 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 "../DemoApp/NvFlowInterop.h"
+
+#include "NvFlowContextD3D11.h"
+#include "appD3D11Ctx.h"
+
+NvFlowContext* NvFlowInteropCreateContext(AppGraphCtx* appctx)
+{
+ NvFlowContextDescD3D11 desc = {};
+ desc.device = appctx->m_device;
+ desc.deviceContext = appctx->m_deviceContext;
+ return NvFlowCreateContextD3D11(NV_FLOW_VERSION, &desc);
+}
+
+NvFlowDepthStencilView* NvFlowInteropCreateDepthStencilView(AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ NvFlowDepthStencilViewDescD3D11 desc = {};
+ desc.dsv = appctx->m_dsv;
+ desc.srv = appctx->m_depthSRV;
+ desc.viewport = appctx->m_viewport;
+ return NvFlowCreateDepthStencilViewD3D11(flowctx, &desc);
+}
+
+NvFlowRenderTargetView* NvFlowInteropCreateRenderTargetView(AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ NvFlowRenderTargetViewDescD3D11 desc = {};
+ desc.rtv = appctx->m_rtv;
+ desc.viewport = appctx->m_viewport;
+ return NvFlowCreateRenderTargetViewD3D11(flowctx, &desc);
+}
+
+void NvFlowInteropUpdateContext(NvFlowContext* context, AppGraphCtx* appctx)
+{
+ NvFlowContextDescD3D11 desc = {};
+ desc.device = appctx->m_device;
+ desc.deviceContext = appctx->m_deviceContext;
+ NvFlowUpdateContextD3D11(context, &desc);
+}
+
+void NvFlowInteropUpdateDepthStencilView(NvFlowDepthStencilView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ NvFlowDepthStencilViewDescD3D11 desc = {};
+ desc.dsv = appctx->m_dsv;
+ desc.srv = appctx->m_depthSRV;
+ desc.viewport = appctx->m_viewport;
+ NvFlowUpdateDepthStencilViewD3D11(flowctx, view, &desc);
+}
+
+void NvFlowInteropUpdateRenderTargetView(NvFlowRenderTargetView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ NvFlowRenderTargetViewDescD3D11 desc = {};
+ desc.rtv = appctx->m_rtv;
+ desc.viewport = appctx->m_viewport;
+ NvFlowUpdateRenderTargetViewD3D11(flowctx, view, &desc);
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/appD3D11Ctx.cpp b/demo/DemoAppD3D11/appD3D11Ctx.cpp
new file mode 100644
index 0000000..959614c
--- /dev/null
+++ b/demo/DemoAppD3D11/appD3D11Ctx.cpp
@@ -0,0 +1,766 @@
+/*
+ * Copyright (c) 2014-2017, 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.
+ */
+
+//direct3d headers
+#include <d3d11.h>
+#include <dxgi.h>
+
+// include the Direct3D Library file
+#pragma comment (lib, "d3d11.lib")
+#pragma comment (lib, "DXGI.lib")
+
+#include "appD3D11Ctx.h"
+
+#include <stdio.h>
+
+#include <SDL.h>
+#include <SDL_video.h>
+#include <SDL_syswm.h>
+
+namespace
+{
+ // COM object release utilities
+ template <class T>
+ void inline COMRelease(T& t)
+ {
+ if (t) t->Release();
+ t = nullptr;
+ }
+
+ template <class T>
+ void inline COMRelease(T& t, UINT arraySize)
+ {
+ for (UINT i = 0; i < arraySize; i++)
+ {
+ if (t[i]) t[i]->Release();
+ t[i] = nullptr;
+ }
+ }
+}
+
+AppGraphProfiler* appGraphCreateProfiler(AppGraphCtx* ctx);
+void appGraphProfilerFrameBegin(AppGraphProfiler* profiler);
+void appGraphProfilerFrameEnd(AppGraphProfiler* profiler);
+void appGraphProfilerEnable(AppGraphProfiler* profiler, bool enabled);
+void appGraphProfilerBegin(AppGraphProfiler* profiler, const char* label);
+void appGraphProfilerEnd(AppGraphProfiler* profiler, const char* label);
+bool appGraphProfilerGet(AppGraphProfiler* profiler, const char** plabel, float* cpuTime, float* gpuTime, int index);
+void appGraphReleaseProfiler(AppGraphProfiler* profiler);
+
+void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool fullscreen);
+
+AppGraphCtx::AppGraphCtx()
+{
+ m_profiler = appGraphCreateProfiler(this);
+}
+
+AppGraphCtx::~AppGraphCtx()
+{
+ AppGraphCtxReleaseRenderTarget(this);
+
+ COMRelease(m_device);
+ COMRelease(m_deviceContext);
+ COMRelease(m_depthState);
+
+ appGraphReleaseProfiler(m_profiler);
+ m_profiler = nullptr;
+}
+
+AppGraphCtx* AppGraphCtxCreate(int deviceID)
+{
+ AppGraphCtx* context = new AppGraphCtx;
+
+ HRESULT hr = S_OK;
+
+ // enumerate devices
+ IDXGIFactory1* pFactory = NULL;
+ CreateDXGIFactory1(IID_PPV_ARGS(&pFactory));
+ IDXGIAdapter1* pAdapterTemp = NULL;
+ IDXGIAdapter1* pAdapter = NULL;
+ DXGI_ADAPTER_DESC1 adapterDesc;
+ int adapterIdx = 0;
+ while (S_OK == pFactory->EnumAdapters1(adapterIdx, &pAdapterTemp))
+ {
+ pAdapterTemp->GetDesc1(&adapterDesc);
+
+ context->m_dedicatedVideoMemory = (size_t)adapterDesc.DedicatedVideoMemory;
+
+ if (deviceID == adapterIdx)
+ {
+ pAdapter = pAdapterTemp;
+ break;
+ }
+ else
+ {
+ pAdapterTemp->Release();
+ }
+ adapterIdx++;
+ }
+
+ D3D_DRIVER_TYPE driverTypes[] =
+ {
+ D3D_DRIVER_TYPE_UNKNOWN,
+ D3D_DRIVER_TYPE_HARDWARE,
+ D3D_DRIVER_TYPE_WARP,
+ D3D_DRIVER_TYPE_REFERENCE,
+ };
+ UINT numDriverTypes = 4;
+
+ D3D_FEATURE_LEVEL featureLevels[] =
+ {
+ D3D_FEATURE_LEVEL_11_1,
+ D3D_FEATURE_LEVEL_11_0,
+ D3D_FEATURE_LEVEL_10_1,
+ D3D_FEATURE_LEVEL_10_0,
+ };
+ UINT numFeatureLevels = 4;
+
+ UINT createDeviceFlags = 0;
+#ifdef _DEBUG
+ createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
+#endif
+
+ for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
+ {
+ D3D_FEATURE_LEVEL featureLevel;
+ D3D_DRIVER_TYPE driverType = driverTypes[driverTypeIndex];
+ hr = D3D11CreateDevice(pAdapter, driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels,
+ D3D11_SDK_VERSION, &context->m_device, &featureLevel, &context->m_deviceContext);
+ if (SUCCEEDED(hr))
+ {
+ break;
+ }
+ }
+ if (FAILED(hr))
+ {
+ delete context;
+ return nullptr;
+ }
+
+ // cleanup adapter and factory
+ COMRelease(pAdapter);
+ COMRelease(pFactory);
+
+ // create depth state
+ D3D11_DEPTH_STENCIL_DESC depthStateDesc = {};
+ depthStateDesc.DepthEnable = TRUE;
+ depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
+ depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
+
+ if (hr = context->m_device->CreateDepthStencilState(&depthStateDesc, &context->m_depthState))
+ {
+ delete context;
+ return nullptr;
+ }
+
+ return context;
+}
+
+bool AppGraphCtxUpdateSize(AppGraphCtx* context, SDL_Window* window, bool fullscreen)
+{
+ // TODO: fix iflip fullscreen support
+ fullscreen = false;
+
+ bool sizeChanged = false;
+
+ // sync with window
+ {
+ HWND hWnd = nullptr;
+ // get Windows handle to this SDL window
+ SDL_SysWMinfo winInfo;
+ SDL_VERSION(&winInfo.version);
+ if (SDL_GetWindowWMInfo(window, &winInfo))
+ {
+ if (winInfo.subsystem == SDL_SYSWM_WINDOWS)
+ {
+ hWnd = winInfo.info.win.window;
+ }
+ }
+ context->m_hWnd = hWnd;
+ context->m_fullscreen = fullscreen;
+
+ HRESULT hr = S_OK;
+
+ RECT rc;
+ GetClientRect(context->m_hWnd, &rc);
+ UINT width = rc.right - rc.left;
+ UINT height = rc.bottom - rc.top;
+
+ if (context->m_winW != width || context->m_winH != height)
+ {
+ context->m_winW = width;
+ context->m_winH = height;
+ sizeChanged = true;
+ context->m_valid = (context->m_winW != 0 && context->m_winH != 0);
+ }
+ }
+
+ if (sizeChanged)
+ {
+ AppGraphCtxReleaseRenderTarget(context);
+ }
+ if (sizeChanged && context->m_valid)
+ {
+ AppGraphCtxInitRenderTarget(context, window, fullscreen);
+ }
+
+ return context->m_valid;
+}
+
+void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool fullscreen)
+{
+ HWND hWnd = nullptr;
+ // get Windows handle to this SDL window
+ SDL_SysWMinfo winInfo;
+ SDL_VERSION(&winInfo.version);
+ if (SDL_GetWindowWMInfo(window, &winInfo))
+ {
+ if (winInfo.subsystem == SDL_SYSWM_WINDOWS)
+ {
+ hWnd = winInfo.info.win.window;
+ }
+ }
+ context->m_hWnd = hWnd;
+ context->m_fullscreen = fullscreen;
+
+ HRESULT hr = S_OK;
+
+ // enumerate devices
+ IDXGIFactory1* pFactory = NULL;
+ CreateDXGIFactory1(IID_PPV_ARGS(&pFactory));
+
+ // create the swap chain
+ for (int i = 0; i < 2; i++)
+ {
+ DXGI_SWAP_CHAIN_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+ desc.BufferCount = 1;
+ desc.BufferDesc.Width = context->m_winW;
+ desc.BufferDesc.Height = context->m_winH;
+ desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ desc.BufferDesc.RefreshRate.Numerator = 0;
+ desc.BufferDesc.RefreshRate.Denominator = 0;
+ desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // DXGI_SWAP_EFFECT_FLIP_DISCARD;
+ desc.OutputWindow = context->m_hWnd;
+ desc.SampleDesc.Count = 1;
+ desc.SampleDesc.Quality = 0;
+ desc.Windowed = TRUE; // m_fullscreen ? FALSE : TRUE;
+ desc.Flags = 0u;
+
+ if (hr = pFactory->CreateSwapChain(context->m_device, &desc, (IDXGISwapChain**)&context->m_swapChain))
+ {
+ COMRelease(context->m_swapChain);
+ context->m_fullscreen = false;
+ continue;
+ }
+
+ if (!context->m_fullscreen)
+ {
+
+ }
+ else
+ {
+ hr = context->m_swapChain->SetFullscreenState(true, nullptr);
+ if (hr != S_OK)
+ {
+ COMRelease(context->m_swapChain);
+ context->m_fullscreen = false;
+ continue;
+ }
+ DXGI_SWAP_CHAIN_DESC desc = {};
+ context->m_swapChain->GetDesc(&desc);
+ context->m_swapChain->ResizeBuffers(1, context->m_winW, context->m_winH, desc.BufferDesc.Format, desc.Flags);
+ }
+ break;
+ }
+
+ // configure scissor and viewport
+ {
+ context->m_viewport.Width = float(context->m_winW);
+ context->m_viewport.Height = float(context->m_winH);
+ context->m_viewport.MaxDepth = 1.f;
+ }
+
+ COMRelease(pFactory);
+
+ // Create a render target view
+ ID3D11Texture2D* pBackBuffer = NULL;
+ hr = context->m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
+ if (FAILED(hr))
+ {
+ return;
+ }
+
+ hr = context->m_device->CreateRenderTargetView(pBackBuffer, NULL, &context->m_rtv);
+ pBackBuffer->Release();
+ if (FAILED(hr))
+ {
+ return;
+ }
+
+ context->m_deviceContext->OMSetRenderTargets(1, &context->m_rtv, NULL);
+
+ // viewport
+ context->m_deviceContext->RSSetViewports(1, &context->m_viewport);
+
+ {
+ D3D11_TEXTURE2D_DESC texDesc = {};
+ texDesc.Width = context->m_winW;
+ texDesc.Height = context->m_winH;
+ texDesc.MipLevels = 1;
+ texDesc.ArraySize = 1;
+ texDesc.Format = DXGI_FORMAT_R32_TYPELESS; // DXGI_FORMAT_R24G8_TYPELESS
+ texDesc.SampleDesc.Count = 1;
+ texDesc.SampleDesc.Quality = 0u;
+ texDesc.Usage = D3D11_USAGE_DEFAULT;
+ texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
+ texDesc.CPUAccessFlags = 0;
+ texDesc.MiscFlags = 0;
+
+ if (hr = context->m_device->CreateTexture2D(&texDesc, nullptr, &context->m_depthStencil))
+ {
+ return;
+ }
+
+ D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc = {};
+ viewDesc.Format = DXGI_FORMAT_D32_FLOAT;
+ viewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
+ viewDesc.Flags = 0u;
+ viewDesc.Texture2D.MipSlice = 0;
+
+ if (hr = context->m_device->CreateDepthStencilView(context->m_depthStencil, &viewDesc, &context->m_dsv))
+ {
+ return;
+ }
+
+ D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.Format = DXGI_FORMAT_R32_FLOAT;
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+ srvDesc.Texture2D.MipLevels = 1;
+ srvDesc.Texture2D.MostDetailedMip = 0;
+
+ if (hr = context->m_device->CreateShaderResourceView(context->m_depthStencil, &srvDesc, &context->m_depthSRV))
+ {
+ return;
+ }
+ }
+}
+
+void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context)
+{
+ if (context->m_swapChain == nullptr)
+ {
+ return;
+ }
+
+ BOOL bFullscreen = FALSE;
+ context->m_swapChain->GetFullscreenState(&bFullscreen, nullptr);
+ if (bFullscreen == TRUE) context->m_swapChain->SetFullscreenState(FALSE, nullptr);
+
+ COMRelease(context->m_swapChain);
+ COMRelease(context->m_rtv);
+ COMRelease(context->m_depthStencil);
+ COMRelease(context->m_dsv);
+ COMRelease(context->m_depthSRV);
+
+ context->m_valid = false;
+ context->m_winW = 0u;
+ context->m_winH = 0u;
+}
+
+void AppGraphCtxRelease(AppGraphCtx* context)
+{
+ if (context == nullptr) return;
+
+ delete context;
+}
+
+void AppGraphCtxFrameStart(AppGraphCtx* context, float clearColor[4])
+{
+ appGraphProfilerFrameBegin(context->m_profiler);
+
+ context->m_deviceContext->RSSetViewports(1, &context->m_viewport);
+ context->m_deviceContext->RSSetScissorRects(0, nullptr);
+
+ context->m_deviceContext->OMSetRenderTargets(1, &context->m_rtv, context->m_dsv);
+
+ context->m_deviceContext->ClearRenderTargetView(context->m_rtv, clearColor);
+ context->m_deviceContext->ClearDepthStencilView(context->m_dsv, D3D11_CLEAR_DEPTH, 1.f, 0u);
+
+ context->m_deviceContext->OMSetDepthStencilState(context->m_depthState, 0u);
+}
+
+void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync)
+{
+ context->m_swapChain->Present(0, 0);
+
+ appGraphProfilerFrameEnd(context->m_profiler);
+}
+
+void AppGraphCtxWaitForFrames(AppGraphCtx* context, unsigned int maxFramesInFlight)
+{
+ // TODO: Implement
+}
+
+void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled)
+{
+ appGraphProfilerEnable(context->m_profiler, enabled);
+}
+
+void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label)
+{
+ appGraphProfilerBegin(context->m_profiler, label);
+}
+
+void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label)
+{
+ appGraphProfilerEnd(context->m_profiler, label);
+}
+
+bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index)
+{
+ return appGraphProfilerGet(context->m_profiler, plabel, cpuTime, gpuTime, index);
+}
+
+// ******************************* Profiler *********************************
+
+namespace
+{
+ struct TimerCPU
+ {
+ LARGE_INTEGER oldCount;
+ LARGE_INTEGER count;
+ LARGE_INTEGER freq;
+ TimerCPU()
+ {
+ QueryPerformanceCounter(&count);
+ QueryPerformanceFrequency(&freq);
+ oldCount = count;
+ }
+ double getDeltaTime()
+ {
+ QueryPerformanceCounter(&count);
+ double dt = double(count.QuadPart - oldCount.QuadPart) / double(freq.QuadPart);
+ oldCount = count;
+ return dt;
+ }
+ };
+
+ struct TimerGPU
+ {
+ ID3D11Query* m_begin = nullptr;
+ ID3D11Query* m_end = nullptr;
+
+ TimerGPU() {}
+ ~TimerGPU()
+ {
+ COMRelease(m_begin);
+ COMRelease(m_end);
+ }
+ };
+
+ struct Timer
+ {
+ TimerCPU m_cpu;
+ TimerGPU m_gpu;
+
+ const char* m_label = nullptr;
+ float m_cpuTime = 0.f;
+ float m_gpuTime = 0.f;
+
+ Timer() {}
+ ~Timer() {}
+ };
+
+ struct TimerValue
+ {
+ const char* m_label = nullptr;
+ float m_cpuTime = 0.f;
+ float m_gpuTime = 0.f;
+
+ struct Stat
+ {
+ float m_time = 0.f;
+ float m_maxTime = 0.f;
+ float m_maxTimeAge = 0.f;
+
+ float m_smoothTime = 0.f;
+ float m_smoothTimeSum = 0.f;
+ float m_smoothTimeCount = 0.f;
+
+ Stat() {}
+ void push(float time)
+ {
+ m_time = time;
+
+ if (m_time > m_maxTime)
+ {
+ m_maxTime = m_time;
+ m_maxTimeAge = 0.f;
+ }
+
+ if (fabsf(m_time - m_maxTime) < 0.25f * m_maxTime)
+ {
+ m_smoothTimeSum += m_time;
+ m_smoothTimeCount += 1.f;
+ m_smoothTimeSum *= 0.98f;
+ m_smoothTimeCount *= 0.98f;
+ m_smoothTime = m_smoothTimeSum / m_smoothTimeCount;
+ }
+ }
+
+ float pull(float frameTime)
+ {
+ m_maxTimeAge += frameTime;
+
+ if (m_maxTimeAge > 1.f)
+ {
+ m_maxTimeAge = 0.f;
+ m_maxTime = m_time;
+ m_smoothTimeSum = 0.f;
+ m_smoothTimeCount = 0.f;
+ }
+ return m_smoothTime;
+ }
+ };
+
+ Stat m_cpu;
+ Stat m_gpu;
+
+ void push(float cpuTime, float gpuTime)
+ {
+ m_cpu.push(cpuTime);
+ m_gpu.push(gpuTime);
+ }
+
+ void pull(float frameTime)
+ {
+ m_cpuTime = m_cpu.pull(frameTime);
+ m_gpuTime = m_gpu.pull(frameTime);
+ }
+ };
+}
+
+struct AppGraphProfiler
+{
+ AppGraphCtx* m_context;
+
+ int m_state = 0;
+ bool m_enabled = false;
+
+ TimerCPU m_frameTimer;
+ float m_frameTime = 0.f;
+
+ ID3D11Query* m_disjoint = nullptr;
+
+ static const int m_timersCap = 64;
+ Timer m_timers[m_timersCap];
+ int m_timersSize = 0;
+
+ TimerValue m_timerValues[m_timersCap];
+ int m_timerValuesSize = 0;
+
+ AppGraphProfiler(AppGraphCtx* context);
+ ~AppGraphProfiler();
+};
+
+AppGraphProfiler::AppGraphProfiler(AppGraphCtx* context) : m_context(context)
+{
+}
+
+AppGraphProfiler::~AppGraphProfiler()
+{
+ COMRelease(m_disjoint);
+}
+
+AppGraphProfiler* appGraphCreateProfiler(AppGraphCtx* ctx)
+{
+ return new AppGraphProfiler(ctx);
+}
+
+void appGraphReleaseProfiler(AppGraphProfiler* profiler)
+{
+ delete profiler;
+}
+
+void appGraphProfilerFrameBegin(AppGraphProfiler* p)
+{
+ p->m_frameTime = (float)p->m_frameTimer.getDeltaTime();
+
+ if (p->m_state == 0 && p->m_enabled)
+ {
+ auto device = p->m_context->m_device;
+ auto deviceContext = p->m_context->m_deviceContext;
+
+ if (p->m_disjoint == nullptr)
+ {
+ D3D11_QUERY_DESC queryDesc;
+ queryDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
+ queryDesc.MiscFlags = 0u;
+ device->CreateQuery(&queryDesc, &p->m_disjoint);
+ }
+
+ deviceContext->Begin(p->m_disjoint);
+
+ p->m_timersSize = 0;
+
+ p->m_state = 1;
+ }
+}
+
+void appGraphProfilerFrameEnd(AppGraphProfiler* p)
+{
+ if (p->m_state == 1)
+ {
+ auto deviceContext = p->m_context->m_deviceContext;
+
+ deviceContext->End(p->m_disjoint);
+
+ p->m_state = 2;
+ }
+}
+
+void appGraphProfilerEnable(AppGraphProfiler* p, bool enabled)
+{
+ p->m_enabled = enabled;
+}
+
+void appGraphProfilerBegin(AppGraphProfiler* p, const char* label)
+{
+ if (p->m_state == 1 && p->m_timersSize < p->m_timersCap)
+ {
+ auto& timer = p->m_timers[p->m_timersSize++];
+ timer.m_label = label;
+ timer.m_cpu.getDeltaTime();
+
+ auto device = p->m_context->m_device;
+ auto deviceContext = p->m_context->m_deviceContext;
+
+ if (timer.m_gpu.m_begin == nullptr)
+ {
+ D3D11_QUERY_DESC queryDesc;
+ queryDesc.MiscFlags = 0u;
+ queryDesc.Query = D3D11_QUERY_TIMESTAMP;
+ device->CreateQuery(&queryDesc, &timer.m_gpu.m_begin);
+ device->CreateQuery(&queryDesc, &timer.m_gpu.m_end);
+ }
+
+ deviceContext->End(timer.m_gpu.m_begin);
+ }
+}
+
+void appGraphProfilerEnd(AppGraphProfiler* p, const char* label)
+{
+ if (p->m_state == 1)
+ {
+ Timer* timer = nullptr;
+ for (int i = 0; i < p->m_timersSize; i++)
+ {
+ if (strcmp(p->m_timers[i].m_label, label) == 0)
+ {
+ timer = &p->m_timers[i];
+ break;
+ }
+ }
+ if (timer)
+ {
+ auto deviceContext = p->m_context->m_deviceContext;
+
+ deviceContext->End(timer->m_gpu.m_end);
+
+ timer->m_cpuTime = (float)timer->m_cpu.getDeltaTime();
+ }
+ }
+}
+
+bool appGraphProfilerFlush(AppGraphProfiler* p)
+{
+ if (p->m_state == 2)
+ {
+ auto deviceContext = p->m_context->m_deviceContext;
+
+ // check disjoint for completion
+ if (deviceContext->GetData(p->m_disjoint, nullptr, 0u, 0u) != S_OK)
+ {
+ return false;
+ }
+
+ D3D11_QUERY_DATA_TIMESTAMP_DISJOINT tsDisjoint;
+ deviceContext->GetData(p->m_disjoint, &tsDisjoint, sizeof(tsDisjoint), 0u);
+ if (tsDisjoint.Disjoint)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < p->m_timersSize; i++)
+ {
+ Timer& timer = p->m_timers[i];
+
+ UINT64 tsBegin, tsEnd;
+ if (deviceContext->GetData(timer.m_gpu.m_begin, &tsBegin, sizeof(UINT64), 0) != S_OK)
+ {
+ return false;
+ }
+ if (deviceContext->GetData(timer.m_gpu.m_end, &tsEnd, sizeof(UINT64), 0) != S_OK)
+ {
+ return false;
+ }
+
+ timer.m_gpuTime = float(tsEnd - tsBegin) / float(tsDisjoint.Frequency);
+
+ // update TimerValue
+ int j = 0;
+ for (; j < p->m_timerValuesSize; j++)
+ {
+ TimerValue& value = p->m_timerValues[j];
+ if (strcmp(value.m_label, timer.m_label) == 0)
+ {
+ value.push(timer.m_cpuTime, timer.m_gpuTime);
+ break;
+ }
+ }
+ if (j >= p->m_timerValuesSize && p->m_timerValuesSize < p->m_timersCap)
+ {
+ TimerValue& value = p->m_timerValues[p->m_timerValuesSize++];
+ value.m_label = timer.m_label;
+ value.push(timer.m_cpuTime, timer.m_gpuTime);
+ }
+ }
+
+ p->m_state = 0;
+ }
+ return false;
+}
+
+bool appGraphProfilerGet(AppGraphProfiler* p, const char** plabel, float* cpuTime, float* gpuTime, int index)
+{
+ appGraphProfilerFlush(p);
+ {
+ if (index < p->m_timerValuesSize)
+ {
+ TimerValue& timer = p->m_timerValues[index];
+
+ timer.pull(p->m_frameTime);
+
+ if (plabel) *plabel = timer.m_label;
+ if (cpuTime) *cpuTime = timer.m_cpuTime;
+ if (gpuTime) *gpuTime = timer.m_gpuTime;
+
+ return true;
+ }
+ }
+ return false;
+}
+
+size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context)
+{
+ return context->m_dedicatedVideoMemory;
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/appD3D11Ctx.h b/demo/DemoAppD3D11/appD3D11Ctx.h
new file mode 100644
index 0000000..578413c
--- /dev/null
+++ b/demo/DemoAppD3D11/appD3D11Ctx.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014-2017, 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 "../DemoApp/appGraphCtx.h"
+
+struct AppGraphProfiler;
+
+struct AppGraphCtx
+{
+ HWND m_hWnd = nullptr;
+
+ int m_winW = 0;
+ int m_winH = 0;
+ bool m_fullscreen = false;
+ bool m_valid = false;
+
+ size_t m_dedicatedVideoMemory = 0u;
+
+ // D3D11 objects
+ D3D11_VIEWPORT m_viewport = {};
+ ID3D11Device* m_device = nullptr;
+ ID3D11DeviceContext* m_deviceContext = nullptr;
+ IDXGISwapChain* m_swapChain = nullptr;
+ ID3D11RenderTargetView* m_rtv = nullptr;
+ ID3D11Texture2D* m_depthStencil = nullptr;
+ ID3D11DepthStencilView* m_dsv = nullptr;
+ ID3D11ShaderResourceView* m_depthSRV = nullptr;
+ ID3D11DepthStencilState* m_depthState = nullptr;
+
+ AppGraphProfiler* m_profiler = nullptr;
+
+ AppGraphCtx();
+ ~AppGraphCtx();
+}; \ No newline at end of file
diff --git a/demo/DemoAppD3D11/computeContextD3D11.cpp b/demo/DemoAppD3D11/computeContextD3D11.cpp
new file mode 100644
index 0000000..2f25f95
--- /dev/null
+++ b/demo/DemoAppD3D11/computeContextD3D11.cpp
@@ -0,0 +1,343 @@
+/*
+* Copyright (c) 2014-2017, 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 "computeContextD3D11.h"
+
+// ************************** Compute Context Implementation ******************
+
+template <class T>
+void inline COMRelease(T& t)
+{
+ if (t) t->Release();
+ t = nullptr;
+}
+
+struct ComputeContext
+{
+ ComputeContextDesc m_desc = {};
+
+ ID3D11SamplerState* m_sampler0 = nullptr;
+ ID3D11SamplerState* m_sampler1 = nullptr;
+ ID3D11SamplerState* m_sampler2 = nullptr;
+ ID3D11SamplerState* m_sampler3 = nullptr;
+ ID3D11SamplerState* m_sampler4 = nullptr;
+ ID3D11SamplerState* m_sampler5 = nullptr;
+
+ ComputeContext(const ComputeContextDesc* desc)
+ {
+ m_desc = *desc;
+
+ auto createSampler = [&](D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE mode)
+ {
+ D3D11_SAMPLER_DESC samplerDesc;
+ samplerDesc.Filter = filter;
+ samplerDesc.AddressU = mode;
+ samplerDesc.AddressV = mode;
+ samplerDesc.AddressW = mode;
+ samplerDesc.MipLODBias = 0;
+ samplerDesc.MaxAnisotropy = 0;
+ samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
+ samplerDesc.BorderColor[0] = 0.f;
+ samplerDesc.BorderColor[1] = 0.f;
+ samplerDesc.BorderColor[2] = 0.f;
+ samplerDesc.BorderColor[3] = 0.f;
+ samplerDesc.MinLOD = 0.f;
+ samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
+ ID3D11SamplerState* sampler = nullptr;
+ m_desc.device->CreateSamplerState(&samplerDesc, &sampler);
+ return sampler;
+ };
+
+ m_sampler0 = createSampler(D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT, D3D11_TEXTURE_ADDRESS_BORDER);
+ m_sampler1 = createSampler(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_BORDER);
+ m_sampler2 = createSampler(D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP);
+ m_sampler3 = createSampler(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP);
+ m_sampler4 = createSampler(D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP);
+ m_sampler5 = createSampler(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP);
+ }
+ ~ComputeContext()
+ {
+ COMRelease(m_sampler0);
+ COMRelease(m_sampler1);
+ COMRelease(m_sampler2);
+ COMRelease(m_sampler3);
+ COMRelease(m_sampler4);
+ COMRelease(m_sampler5);
+ }
+};
+
+struct ComputeShader
+{
+ ID3D11ComputeShader* m_shader = nullptr;
+ ComputeShader(ID3D11ComputeShader* shader)
+ {
+ m_shader = shader;
+ }
+ ~ComputeShader()
+ {
+ COMRelease(m_shader);
+ }
+};
+
+struct ComputeConstantBuffer
+{
+ ID3D11Buffer* m_buffer;
+ ComputeConstantBuffer(ID3D11Buffer* buffer)
+ {
+ m_buffer = buffer;
+ }
+ ~ComputeConstantBuffer()
+ {
+ COMRelease(m_buffer);
+ }
+};
+
+struct ComputeResource
+{
+protected:
+ ID3D11ShaderResourceView* m_srv = nullptr;
+public:
+ void update(const ComputeResourceDesc* desc)
+ {
+ m_srv = desc->srv;
+ }
+
+ ComputeResource(const ComputeResourceDesc* desc)
+ {
+ update(desc);
+ }
+
+ ID3D11ShaderResourceView* SRV()
+ {
+ return m_srv;
+ }
+};
+
+struct ComputeResourceRW : public ComputeResource
+{
+protected:
+ ID3D11UnorderedAccessView* m_uav;
+public:
+ void update(const ComputeResourceRWDesc* descRW)
+ {
+ m_uav = descRW->uav;
+ ComputeResource::update(&descRW->resource);
+ }
+
+ ComputeResourceRW(const ComputeResourceRWDesc* descRW):
+ ComputeResource(&descRW->resource)
+ {
+ m_uav = descRW->uav;
+ }
+
+ ID3D11UnorderedAccessView* UAV()
+ {
+ return m_uav;
+ }
+};
+
+// ************* API functions ****************
+
+ComputeContext* ComputeContextCreate(ComputeContextDesc* desc)
+{
+ return new ComputeContext(desc);
+}
+
+void ComputeContextUpdate(ComputeContext* context, ComputeContextDesc* desc)
+{
+ context->m_desc = *desc;
+}
+
+void ComputeContextRelease(ComputeContext* context)
+{
+ delete context;
+}
+
+ComputeShader* ComputeShaderCreate(ComputeContext* context, const ComputeShaderDesc* desc)
+{
+ ID3D11ComputeShader* computeShader = nullptr;
+ context->m_desc.device->CreateComputeShader(desc->cs, desc->cs_length, nullptr, &computeShader);
+ return new ComputeShader(computeShader);
+}
+
+void ComputeShaderRelease(ComputeShader* shader)
+{
+ delete shader;
+}
+
+ComputeConstantBuffer* ComputeConstantBufferCreate(ComputeContext* context, const ComputeConstantBufferDesc* desc)
+{
+ ID3D11Buffer* constantBuffer = nullptr;
+ {
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = desc->sizeInBytes;
+ bufDesc.Usage = D3D11_USAGE_DYNAMIC;
+ bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+ bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ bufDesc.MiscFlags = 0;
+
+ context->m_desc.device->CreateBuffer(&bufDesc, nullptr, &constantBuffer);
+ }
+ return new ComputeConstantBuffer(constantBuffer);
+}
+
+void ComputeConstantBufferRelease(ComputeConstantBuffer* constantBuffer)
+{
+ delete constantBuffer;
+}
+
+void* ComputeConstantBufferMap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
+{
+ D3D11_MAPPED_SUBRESOURCE mapped = {};
+ context->m_desc.deviceContext->Map(constantBuffer->m_buffer, 0u, D3D11_MAP_WRITE_DISCARD, 0u, &mapped);
+ return mapped.pData;
+}
+
+void ComputeConstantBufferUnmap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
+{
+ context->m_desc.deviceContext->Unmap(constantBuffer->m_buffer, 0u);
+}
+
+ComputeResource* ComputeResourceCreate(ComputeContext* context, const ComputeResourceDesc* desc)
+{
+ return new ComputeResource(desc);
+}
+
+void ComputeResourceUpdate(ComputeContext* context, ComputeResource* resource, const ComputeResourceDesc* desc)
+{
+ resource->update(desc);
+}
+
+void ComputeResourceRelease(ComputeResource* resource)
+{
+ delete resource;
+}
+
+ComputeResourceRW* ComputeResourceRWCreate(ComputeContext* context, const ComputeResourceRWDesc* desc)
+{
+ return new ComputeResourceRW(desc);
+}
+
+void ComputeResourceRWUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, const ComputeResourceRWDesc* desc)
+{
+ resourceRW->update(desc);
+}
+
+void ComputeResourceRWRelease(ComputeResourceRW* resourceRW)
+{
+ delete resourceRW;
+}
+
+ComputeResource* ComputeResourceRWGetResource(ComputeResourceRW* resourceRW)
+{
+ return static_cast<ComputeResource*>(resourceRW);
+}
+
+void ComputeContextDispatch(ComputeContext* context, const ComputeDispatchParams* params)
+{
+ auto& deviceContext = context->m_desc.deviceContext;
+
+ if (params->shader) deviceContext->CSSetShader(params->shader->m_shader, nullptr, 0u);
+
+ ID3D11ShaderResourceView* srvs[ComputeDispatchMaxResources] = { nullptr };
+ ID3D11UnorderedAccessView* uavs[ComputeDispatchMaxResourcesRW] = { nullptr };
+ for (unsigned int i = 0u; i < ComputeDispatchMaxResources; i++)
+ {
+ if (params->resources[i]) srvs[i] = params->resources[i]->SRV();
+ }
+ for (unsigned int i = 0u; i < ComputeDispatchMaxResourcesRW; i++)
+ {
+ if (params->resourcesRW[i]) uavs[i] = params->resourcesRW[i]->UAV();
+ }
+ deviceContext->CSSetShaderResources(0u, ComputeDispatchMaxResources, srvs);
+ deviceContext->CSSetUnorderedAccessViews(0u, ComputeDispatchMaxResourcesRW, uavs, nullptr);
+
+ if (params->constantBuffer) deviceContext->CSSetConstantBuffers(0u, 1u, &params->constantBuffer->m_buffer);
+
+ ID3D11SamplerState* samplers[] = {
+ context->m_sampler0, context->m_sampler1, context->m_sampler2,
+ context->m_sampler3, context->m_sampler4, context->m_sampler5
+ };
+ deviceContext->CSSetSamplers(0u, 6u, samplers);
+
+ deviceContext->Dispatch(params->gridDim[0u], params->gridDim[1u], params->gridDim[2u]);
+
+ ID3D11ShaderResourceView* nullsrvs[ComputeDispatchMaxResources] = { nullptr };
+ ID3D11UnorderedAccessView* nulluavs[ComputeDispatchMaxResourcesRW] = { nullptr };
+ deviceContext->CSSetShaderResources(0, ComputeDispatchMaxResources, nullsrvs);
+ deviceContext->CSSetUnorderedAccessViews(0, ComputeDispatchMaxResourcesRW, nulluavs, nullptr);
+}
+
+// ******************************* NvFlow Interoperation ****************************************
+
+#include "NvFlow.h"
+#include "NvFlowContextD3D11.h"
+
+inline void updateComputeContextDesc(NvFlowContext* flowContext, ComputeContextDesc* desc)
+{
+ NvFlowContextDescD3D11 srcDesc = {};
+ NvFlowUpdateContextDescD3D11(flowContext, &srcDesc);
+ desc->device = srcDesc.device;
+ desc->deviceContext = srcDesc.deviceContext;
+}
+
+ComputeContext* ComputeContextNvFlowContextCreate(NvFlowContext* flowContext)
+{
+ ComputeContextDesc desc = {};
+ updateComputeContextDesc(flowContext, &desc);
+ return ComputeContextCreate(&desc);
+}
+
+void ComputeContextNvFlowContextUpdate(ComputeContext* computeContext, NvFlowContext* flowContext)
+{
+ ComputeContextDesc desc = {};
+ updateComputeContextDesc(flowContext, &desc);
+ ComputeContextUpdate(computeContext, &desc);
+}
+
+ComputeResource* ComputeResourceNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResource* flowResource)
+{
+ NvFlowResourceViewDescD3D11 flowViewDesc = {};
+ NvFlowUpdateResourceViewDescD3D11(flowContext, flowResource, &flowViewDesc);
+ ComputeResourceDesc desc = {};
+ desc.srv = flowViewDesc.srv;
+ return ComputeResourceCreate(context, &desc);
+}
+
+void ComputeResourceNvFlowUpdate(ComputeContext* context, ComputeResource* resource, NvFlowContext* flowContext, NvFlowResource* flowResource)
+{
+ NvFlowResourceViewDescD3D11 flowViewDesc = {};
+ NvFlowUpdateResourceViewDescD3D11(flowContext, flowResource, &flowViewDesc);
+ ComputeResourceDesc desc = {};
+ desc.srv = flowViewDesc.srv;
+ ComputeResourceUpdate(context, resource, &desc);
+}
+
+ComputeResourceRW* ComputeResourceRWNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
+{
+ NvFlowResourceRWViewDescD3D11 flowViewDesc = {};
+ NvFlowUpdateResourceRWViewDescD3D11(flowContext, flowResourceRW, &flowViewDesc);
+ ComputeResourceRWDesc desc = {};
+ desc.resource.srv = flowViewDesc.resourceView.srv;
+ desc.uav = flowViewDesc.uav;
+ return ComputeResourceRWCreate(context, &desc);
+}
+
+void ComputeResourceRWNvFlowUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
+{
+ NvFlowResourceRWViewDescD3D11 flowViewDesc = {};
+ NvFlowUpdateResourceRWViewDescD3D11(flowContext, flowResourceRW, &flowViewDesc);
+ ComputeResourceRWDesc desc = {};
+ desc.resource.srv = flowViewDesc.resourceView.srv;
+ desc.uav = flowViewDesc.uav;
+ ComputeResourceRWUpdate(context, resourceRW, &desc);
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/computeContextD3D11.h b/demo/DemoAppD3D11/computeContextD3D11.h
new file mode 100644
index 0000000..43ad5b1
--- /dev/null
+++ b/demo/DemoAppD3D11/computeContextD3D11.h
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2014-2017, 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 "../DemoApp/computeContext.h"
+
+struct ComputeContextDesc
+{
+ ID3D11Device* device;
+ ID3D11DeviceContext* deviceContext;
+};
+
+struct ComputeResourceDesc
+{
+ ID3D11ShaderResourceView* srv;
+};
+
+struct ComputeResourceRWDesc
+{
+ ComputeResourceDesc resource;
+ ID3D11UnorderedAccessView* uav;
+}; \ No newline at end of file
diff --git a/demo/DemoAppD3D11/imguiGraphD3D11.cpp b/demo/DemoAppD3D11/imguiGraphD3D11.cpp
new file mode 100644
index 0000000..a654cf2
--- /dev/null
+++ b/demo/DemoAppD3D11/imguiGraphD3D11.cpp
@@ -0,0 +1,472 @@
+/*
+ * Copyright (c) 2014-2017, 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 "imguiGraphD3D11.h"
+
+//direct3d headers
+#include <d3d11.h>
+
+#include "imguiVS.hlsl.h"
+#include "imguiPS.hlsl.h"
+
+namespace
+{
+ template <class T>
+ void inline COMRelease(T& t)
+ {
+ if (t) t->Release();
+ t = nullptr;
+ }
+}
+
+namespace
+{
+ ID3D11Device* m_device = nullptr;
+ ID3D11DeviceContext* m_deviceContext = nullptr;
+ int m_winW = 0;
+ int m_winH = 0;
+
+ uint32_t m_maxVertices = 0;
+
+ struct Vertex
+ {
+ float x, y;
+ float u, v;
+ uint8_t rgba[4];
+ };
+
+ ID3D11RasterizerState* m_rasterizerState = nullptr;
+ ID3D11SamplerState* m_samplerState = nullptr;
+ ID3D11InputLayout* m_inputLayout = nullptr;
+ ID3D11BlendState* m_blendState = nullptr;
+ ID3D11VertexShader* m_imguiVS = nullptr;
+ ID3D11PixelShader* m_imguiPS = nullptr;
+ ID3D11Buffer* m_constantBuffer = nullptr;
+ ID3D11Buffer* m_vertexBuffer = nullptr;
+ Vertex* m_vertexBufferData = nullptr;
+
+ struct Scissor
+ {
+ int beginIdx;
+ int stopIdx;
+ int x;
+ int y;
+ int width;
+ int height;
+ };
+ Scissor m_stateScissor = {};
+
+ ID3D11Texture2D* m_texture = nullptr;
+ ID3D11ShaderResourceView* m_textureSRV = nullptr;
+
+ Vertex m_stateVert;
+ uint32_t m_stateVertIdx = 0u;
+
+ struct Params
+ {
+ float projection[16];
+
+ float padding[64 - 16];
+ };
+}
+
+void imguiGraphContextDestroy()
+{
+ COMRelease(m_rasterizerState);
+ COMRelease(m_samplerState);
+ COMRelease(m_inputLayout);
+ COMRelease(m_blendState);
+ COMRelease(m_imguiVS);
+ COMRelease(m_imguiPS);
+ COMRelease(m_constantBuffer);
+ COMRelease(m_vertexBuffer);
+}
+
+void imguiGraphContextInit(const ImguiGraphDesc* desc)
+{
+ m_device = desc->device;
+ m_deviceContext = desc->deviceContext;
+ m_winW = desc->winW;
+ m_winH = desc->winH;
+
+ m_maxVertices = desc->maxVertices;
+
+ // create the rastersizer state
+ {
+ D3D11_RASTERIZER_DESC desc = {};
+ desc.FillMode = D3D11_FILL_SOLID;
+ desc.CullMode = D3D11_CULL_BACK;
+ desc.FrontCounterClockwise = TRUE; // This is non-default
+ desc.DepthBias = 0;
+ desc.DepthBiasClamp = 0.f;
+ desc.SlopeScaledDepthBias = 0.f;
+ desc.DepthClipEnable = TRUE;
+ desc.ScissorEnable = TRUE; // This is non-default
+ desc.MultisampleEnable = FALSE;
+ desc.AntialiasedLineEnable = FALSE;
+
+ m_device->CreateRasterizerState(&desc, &m_rasterizerState);
+ }
+
+ // create the sampler state
+ {
+ D3D11_SAMPLER_DESC sampler = {};
+ sampler.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
+ sampler.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
+ sampler.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
+ sampler.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
+ sampler.MipLODBias = 0;
+ sampler.MaxAnisotropy = 0;
+ sampler.ComparisonFunc = D3D11_COMPARISON_NEVER;
+ //sampler.BorderColor = D3D11_BORDER_COLOR_TRANSPARENT_BLACK;
+ sampler.MinLOD = 0.f;
+ sampler.MaxLOD = D3D11_FLOAT32_MAX;
+
+ m_device->CreateSamplerState(&sampler, &m_samplerState);
+ }
+
+ // create the input layout
+ {
+ D3D11_INPUT_ELEMENT_DESC inputElementDescs[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+
+ m_device->CreateInputLayout(inputElementDescs, 3, g_imguiVS, sizeof(g_imguiVS), &m_inputLayout);
+ }
+
+ // create the blend state
+ {
+ D3D11_BLEND_DESC blendDesc = {};
+ blendDesc.AlphaToCoverageEnable = false;
+ blendDesc.IndependentBlendEnable = false;
+ blendDesc.RenderTarget[0].BlendEnable = true;
+ blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
+ blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
+ blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
+ blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
+ blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
+ blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+ blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+
+ m_device->CreateBlendState(&blendDesc, &m_blendState);
+ }
+
+ // create the shaders
+ m_device->CreateVertexShader(g_imguiVS, sizeof(g_imguiVS), nullptr, &m_imguiVS);
+ m_device->CreatePixelShader(g_imguiPS, sizeof(g_imguiPS), nullptr, &m_imguiPS);
+
+ // create a constant buffer
+ {
+ Params params = {
+ 1.f, 0.f, 0.f, 0.f,
+ 0.f, 1.f, 0.f, 0.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f
+ };
+
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = sizeof(params);
+ bufDesc.Usage = D3D11_USAGE_DYNAMIC;
+ bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+ bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ bufDesc.MiscFlags = 0;
+
+ D3D11_SUBRESOURCE_DATA data = {};
+ data.pSysMem = &params;
+
+ m_device->CreateBuffer(&bufDesc, &data, &m_constantBuffer);
+ }
+
+ // create a vertex buffer
+ {
+ UINT bufferSize = (UINT)(m_maxVertices) * sizeof(Vertex);
+
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = bufferSize;
+ bufDesc.Usage = D3D11_USAGE_DYNAMIC;
+ bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+ bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ bufDesc.MiscFlags = 0;
+
+ m_device->CreateBuffer(&bufDesc, nullptr, &m_vertexBuffer);
+ }
+}
+
+void imguiGraphContextUpdate(const ImguiGraphDesc* desc)
+{
+ m_device = desc->device;
+ m_deviceContext = desc->deviceContext;
+ m_winW = desc->winW;
+ m_winH = desc->winH;
+}
+
+void imguiGraphRecordBegin()
+{
+ Params params = {
+ 2.f / float(m_winW), 0.f, 0.f, -1.f,
+ 0.f, 2.f / float(m_winH), 0.f, -1.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f
+ };
+
+ ID3D11DeviceContext* context = m_deviceContext;
+
+ // update constant buffer
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource = {};
+ if (S_OK == context->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))
+ {
+ memcpy(mappedResource.pData, &params, sizeof(Params));
+
+ context->Unmap(m_constantBuffer, 0u);
+ }
+ }
+
+ // clear state
+ m_stateVert = Vertex{ 0.f, 0.f, -1.f, -1.f, 0,0,0,0 };
+ m_stateVertIdx = 0u;
+
+ m_stateScissor = Scissor { 0, 0, 0, 0, m_winW, m_winH };
+
+ // configure for triangle renderering
+ context->VSSetShader(m_imguiVS, nullptr, 0u);
+ context->PSSetShader(m_imguiPS, nullptr, 0u);
+
+ context->IASetInputLayout(m_inputLayout);
+ context->OMSetBlendState(m_blendState, nullptr, 0xFFFFFFFF);
+ context->PSSetSamplers(0, 1, &m_samplerState);
+
+ context->VSSetConstantBuffers(0, 1, &m_constantBuffer);
+
+ context->PSSetShaderResources(0, 1, &m_textureSRV);
+
+ context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+
+ context->RSSetState(m_rasterizerState);
+
+ // trigger allocation of new vertex buffer as needed
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource = {};
+ if (S_OK == context->Map(m_vertexBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))
+ {
+ context->Unmap(m_vertexBuffer, 0u);
+ }
+ }
+
+ UINT vertexStride = sizeof(Vertex);
+ UINT offset = 0u;
+ context->IASetVertexBuffers(0, 1, &m_vertexBuffer, &vertexStride, &offset);
+
+ // map allocated vertex buffer
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource = {};
+ if (S_OK == context->Map(m_vertexBuffer, 0u, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource))
+ {
+ m_vertexBufferData = (Vertex*)mappedResource.pData;
+ }
+ else
+ {
+ m_vertexBufferData = nullptr;
+ }
+ }
+}
+
+static void imguiGraphFlush()
+{
+ ID3D11DeviceContext* context = m_deviceContext;
+
+ // unmap vertex buffer
+ context->Unmap(m_vertexBuffer, 0u);
+
+ Scissor& p = m_stateScissor;
+ if (p.beginIdx < p.stopIdx)
+ {
+ int winH = m_winH;
+ D3D11_RECT rect;
+ rect.left = p.x;
+ rect.right = p.x + p.width;
+ rect.top = (winH) - (p.y + p.height);
+ rect.bottom = (winH) - (p.y);
+ context->RSSetScissorRects(1, &rect);
+
+ UINT vertexCount = (p.stopIdx - p.beginIdx);
+ UINT startIndex = p.beginIdx;
+ context->DrawInstanced(vertexCount, 1, startIndex, 0);
+ }
+
+ // map allocated vertex buffer
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource = {};
+ if (S_OK == context->Map(m_vertexBuffer, 0u, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource))
+ {
+ m_vertexBufferData = (Vertex*)mappedResource.pData;
+ }
+ else
+ {
+ m_vertexBufferData = nullptr;
+ }
+ }
+}
+
+void imguiGraphRecordEnd()
+{
+ ID3D11DeviceContext* context = m_deviceContext;
+
+ context->OMSetBlendState(nullptr,nullptr,0xFFFFFFFF);
+
+ // unmap vertex buffer
+ context->Unmap(m_vertexBuffer, 0u);
+
+ // restore scissor
+ Scissor& p = m_stateScissor;
+ int winH = m_winH;
+ D3D11_RECT rect;
+ rect.left = p.x;
+ rect.right = p.x + p.width;
+ rect.top = (winH) - (p.y + p.height);
+ rect.bottom = (winH) - (p.y);
+ context->RSSetScissorRects(1, &rect);
+
+ context->RSSetState(nullptr);
+}
+
+void imguiGraphEnableScissor(int x, int y, int width, int height)
+{
+ // mark end of last region
+ m_stateScissor.stopIdx = m_stateVertIdx;
+
+ imguiGraphFlush();
+
+ m_stateScissor.beginIdx = m_stateVertIdx;
+ m_stateScissor.stopIdx = m_stateVertIdx;
+ m_stateScissor.x = x;
+ m_stateScissor.y = y;
+ m_stateScissor.width = width;
+ m_stateScissor.height = height;
+}
+
+void imguiGraphDisableScissor()
+{
+ if (m_stateVertIdx == 0) return;
+
+ // mark end of last region
+ m_stateScissor.stopIdx = m_stateVertIdx;
+
+ imguiGraphFlush();
+
+ m_stateScissor.beginIdx = m_stateVertIdx;
+ m_stateScissor.stopIdx = m_stateVertIdx;
+ m_stateScissor.x = 0;
+ m_stateScissor.y = 0;
+ m_stateScissor.width = m_winW;
+ m_stateScissor.height = m_winH;
+}
+
+void imguiGraphVertex2f(float x, float y)
+{
+ float v[2] = { x,y };
+ imguiGraphVertex2fv(v);
+}
+
+void imguiGraphVertex2fv(const float* v)
+{
+ // update state
+ m_stateVert.x = v[0];
+ m_stateVert.y = v[1];
+
+ Vertex* vdata = m_vertexBufferData;
+
+ // push vertex
+ if ((m_stateVertIdx) < m_maxVertices)
+ {
+ vdata[m_stateVertIdx++] = m_stateVert;
+ }
+}
+
+void imguiGraphTexCoord2f(float u, float v)
+{
+ m_stateVert.u = u;
+ m_stateVert.v = v;
+}
+
+void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
+{
+ m_stateVert.rgba[0] = red;
+ m_stateVert.rgba[1] = green;
+ m_stateVert.rgba[2] = blue;
+ m_stateVert.rgba[3] = alpha;
+}
+
+void imguiGraphColor4ubv(const uint8_t* v)
+{
+ m_stateVert.rgba[0] = v[0];
+ m_stateVert.rgba[1] = v[1];
+ m_stateVert.rgba[2] = v[2];
+ m_stateVert.rgba[3] = v[3];
+}
+
+void imguiGraphFontTextureEnable()
+{
+
+}
+
+void imguiGraphFontTextureDisable()
+{
+ m_stateVert.u = -1.f;
+ m_stateVert.v = -1.f;
+}
+
+void imguiGraphFontTextureInit(unsigned char* data)
+{
+ ID3D11DeviceContext* context = m_deviceContext;
+
+ // create texture
+ {
+ UINT width = 512;
+ UINT height = 512;
+
+ D3D11_TEXTURE2D_DESC texDesc = {};
+ texDesc.Width = width;
+ texDesc.Height = height;
+ texDesc.MipLevels = 1;
+ texDesc.ArraySize = 1;
+ texDesc.Format = DXGI_FORMAT_R8_UNORM;
+ texDesc.SampleDesc.Count = 1;
+ texDesc.SampleDesc.Quality = 0u;
+ texDesc.Usage = D3D11_USAGE_IMMUTABLE;
+ texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+ texDesc.CPUAccessFlags = 0;
+ texDesc.MiscFlags = 0;
+
+ D3D11_SUBRESOURCE_DATA initData = {};
+ initData.pSysMem = data;
+ initData.SysMemPitch = width;
+
+ if (m_device->CreateTexture2D(&texDesc, &initData, &m_texture))
+ {
+ return;
+ }
+
+ if (m_device->CreateShaderResourceView(m_texture, nullptr, &m_textureSRV))
+ {
+ return;
+ }
+ }
+
+}
+
+void imguiGraphFontTextureRelease()
+{
+ COMRelease(m_texture);
+ COMRelease(m_textureSRV);
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/imguiGraphD3D11.h b/demo/DemoAppD3D11/imguiGraphD3D11.h
new file mode 100644
index 0000000..54e022f
--- /dev/null
+++ b/demo/DemoAppD3D11/imguiGraphD3D11.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014-2017, 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.
+ */
+
+#ifndef IMGUI_GRAPH_D3D11_H
+#define IMGUI_GRAPH_D3D11_H
+
+#include <stdint.h>
+
+#include "../DemoApp/imguiGraph.h"
+
+struct ID3D11Device;
+struct ID3D11DeviceContext;
+
+struct ImguiGraphDesc
+{
+ ID3D11Device* device = nullptr;
+ ID3D11DeviceContext* deviceContext = nullptr;
+ int winW;
+ int winH;
+
+ uint32_t maxVertices = 64 * 4096u;
+
+ ImguiGraphDesc() {}
+};
+
+#endif \ No newline at end of file
diff --git a/demo/DemoAppD3D11/imguiInteropD3D11.cpp b/demo/DemoAppD3D11/imguiInteropD3D11.cpp
new file mode 100644
index 0000000..9989aeb
--- /dev/null
+++ b/demo/DemoAppD3D11/imguiInteropD3D11.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014-2017, 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.
+ */
+
+//direct3d headers
+#include <d3d11.h>
+
+// include the Direct3D Library file
+#pragma comment (lib, "d3d11.lib")
+
+#include "../DemoApp/imguiInterop.h"
+
+#include "appD3D11Ctx.h"
+#include "imguiGraphD3D11.h"
+
+bool imguiInteropGraphInit(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx)
+{
+ ImguiGraphDesc desc;
+ desc.device = appctx->m_device;
+ desc.deviceContext = appctx->m_deviceContext;
+ desc.winW = appctx->m_winW;
+ desc.winH = appctx->m_winH;
+
+ return func(fontpath, &desc);
+}
+
+void imguiInteropGraphUpdate(imguiGraphUpdate_t func, AppGraphCtx* appctx)
+{
+ ImguiGraphDesc desc;
+ desc.device = appctx->m_device;
+ desc.deviceContext = appctx->m_deviceContext;
+ desc.winW = appctx->m_winW;
+ desc.winH = appctx->m_winH;
+
+ return func(&desc);
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/imguiPS.hlsl.h b/demo/DemoAppD3D11/imguiPS.hlsl.h
new file mode 100644
index 0000000..d6fb74c
--- /dev/null
+++ b/demo/DemoAppD3D11/imguiPS.hlsl.h
@@ -0,0 +1,195 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Resource Bindings:
+//
+// Name Type Format Dim HLSL Bind Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// texSampler sampler NA NA s0 1
+// tex texture float 2d t0 1
+//
+//
+//
+// Input signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION 0 xyzw 0 POS float
+// TEXCOORD 0 xy 1 NONE float xy
+// COLOR 0 xyzw 2 NONE float xyzw
+//
+//
+// 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_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 1
+ge r0.x, v1.x, l(0.000000)
+if_nz r0.x
+ sample_l_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0, l(0.000000)
+ mul r0.x, r0.x, v2.w
+else
+ mov r0.x, v2.w
+endif
+mov r0.yzw, v2.xxyz
+mov o0.xyzw, r0.yzwx
+ret
+// Approximately 10 instruction slots used
+#endif
+
+const BYTE g_imguiPS[] =
+{
+ 68, 88, 66, 67, 254, 30,
+ 194, 112, 35, 29, 114, 31,
+ 28, 188, 13, 85, 22, 84,
+ 219, 9, 1, 0, 0, 0,
+ 80, 3, 0, 0, 5, 0,
+ 0, 0, 52, 0, 0, 0,
+ 240, 0, 0, 0, 100, 1,
+ 0, 0, 152, 1, 0, 0,
+ 180, 2, 0, 0, 82, 68,
+ 69, 70, 180, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 2, 0, 0, 0,
+ 60, 0, 0, 0, 0, 5,
+ 255, 255, 0, 1, 0, 0,
+ 139, 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, 135, 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,
+ 1, 0, 0, 0, 116, 101,
+ 120, 83, 97, 109, 112, 108,
+ 101, 114, 0, 116, 101, 120,
+ 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,
+ 49, 48, 46, 49, 0, 171,
+ 73, 83, 71, 78, 108, 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,
+ 3, 3, 0, 0, 101, 0,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 3, 0,
+ 0, 0, 2, 0, 0, 0,
+ 15, 15, 0, 0, 83, 86,
+ 95, 80, 79, 83, 73, 84,
+ 73, 79, 78, 0, 84, 69,
+ 88, 67, 79, 79, 82, 68,
+ 0, 67, 79, 76, 79, 82,
+ 0, 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, 20, 1,
+ 0, 0, 80, 0, 0, 0,
+ 69, 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,
+ 98, 16, 0, 3, 242, 16,
+ 16, 0, 2, 0, 0, 0,
+ 101, 0, 0, 3, 242, 32,
+ 16, 0, 0, 0, 0, 0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 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/demo/DemoAppD3D11/imguiVS.hlsl.h b/demo/DemoAppD3D11/imguiVS.hlsl.h
new file mode 100644
index 0000000..6c7ed54
--- /dev/null
+++ b/demo/DemoAppD3D11/imguiVS.hlsl.h
@@ -0,0 +1,246 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions:
+//
+// cbuffer params
+// {
+//
+// float4x4 transform; // Offset: 0 Size: 64
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name Type Format Dim HLSL Bind Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// params cbuffer NA NA cb0 1
+//
+//
+//
+// Input signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// POSITION 0 xy 0 NONE float xy
+// TEXCOORD 0 xy 1 NONE float xy
+// COLOR 0 xyzw 2 NONE float xyzw
+// SV_InstanceID 0 x 3 INSTID uint
+//
+//
+// Output signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION 0 xyzw 0 POS float xyzw
+// TEXCOORD 0 xy 1 NONE float xy
+// COLOR 0 xyzw 2 NONE float xyzw
+//
+vs_5_0
+dcl_globalFlags refactoringAllowed
+dcl_constantbuffer CB0[4], immediateIndexed
+dcl_input v0.xy
+dcl_input v1.xy
+dcl_input v2.xyzw
+dcl_output_siv o0.xyzw, position
+dcl_output o1.xy
+dcl_output o2.xyzw
+dcl_temps 1
+mov r0.xy, v0.xyxx
+mov r0.z, l(1.000000)
+dp3 o0.x, r0.xyzx, cb0[0].xywx
+dp3 o0.y, r0.xyzx, cb0[1].xywx
+dp3 o0.z, r0.xyzx, cb0[2].xywx
+dp3 o0.w, r0.xyzx, cb0[3].xywx
+mov o1.xy, v1.xyxx
+mov o2.xyzw, v2.xyzw
+ret
+// Approximately 9 instruction slots used
+#endif
+
+const BYTE g_imguiVS[] =
+{
+ 68, 88, 66, 67, 6, 20,
+ 203, 172, 109, 190, 55, 177,
+ 9, 228, 94, 38, 104, 254,
+ 183, 14, 1, 0, 0, 0,
+ 52, 4, 0, 0, 5, 0,
+ 0, 0, 52, 0, 0, 0,
+ 64, 1, 0, 0, 216, 1,
+ 0, 0, 76, 2, 0, 0,
+ 152, 3, 0, 0, 82, 68,
+ 69, 70, 4, 1, 0, 0,
+ 1, 0, 0, 0, 100, 0,
+ 0, 0, 1, 0, 0, 0,
+ 60, 0, 0, 0, 0, 5,
+ 254, 255, 0, 1, 0, 0,
+ 220, 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,
+ 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, 112, 97, 114, 97,
+ 109, 115, 0, 171, 92, 0,
+ 0, 0, 1, 0, 0, 0,
+ 124, 0, 0, 0, 64, 0,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 164, 0,
+ 0, 0, 0, 0, 0, 0,
+ 64, 0, 0, 0, 2, 0,
+ 0, 0, 184, 0, 0, 0,
+ 0, 0, 0, 0, 255, 255,
+ 255, 255, 0, 0, 0, 0,
+ 255, 255, 255, 255, 0, 0,
+ 0, 0, 116, 114, 97, 110,
+ 115, 102, 111, 114, 109, 0,
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1,260 @@
+/*
+ * Copyright (c) 2014-2017, 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.
+ */
+
+//direct3d headers
+#include <d3d11.h>
+
+// include the Direct3D Library file
+#pragma comment (lib, "d3d11.lib")
+
+#include <math.h>
+
+#include "meshD3D11.h"
+
+#include "meshVS.hlsl.h"
+#include "meshPS.hlsl.h"
+
+namespace
+{
+ template <class T>
+ void inline COMRelease(T& t)
+ {
+ if (t) t->Release();
+ t = nullptr;
+ }
+}
+
+struct MeshContext
+{
+ ID3D11Device* m_device = nullptr;
+ ID3D11DeviceContext* m_deviceContext = nullptr;
+
+ ID3D11InputLayout* m_inputLayout = nullptr;
+ ID3D11VertexShader* m_meshVS = nullptr;
+ ID3D11PixelShader* m_meshPS = nullptr;
+ ID3D11Buffer* m_constantBuffer = nullptr;
+ ID3D11RasterizerState* m_rasterizerStateRH = nullptr;
+
+ MeshContext() {}
+ ~MeshContext()
+ {
+ COMRelease(m_inputLayout);
+ COMRelease(m_meshVS);
+ COMRelease(m_meshPS);
+ COMRelease(m_constantBuffer);
+ COMRelease(m_rasterizerStateRH);
+ }
+};
+
+struct MeshIndexBuffer
+{
+ ID3D11Buffer* m_buffer = nullptr;
+ MeshUint m_numElements = 0u;
+
+ MeshIndexBuffer() {}
+ ~MeshIndexBuffer()
+ {
+ COMRelease(m_buffer);
+ }
+};
+
+struct MeshVertexBuffer
+{
+ ID3D11Buffer* m_buffer = nullptr;
+ MeshUint m_numElements = 0u;
+
+ MeshVertexBuffer() {}
+ ~MeshVertexBuffer()
+ {
+ COMRelease(m_buffer);
+ }
+};
+
+MeshContext* MeshContextCreate(const MeshContextDesc* desc)
+{
+ MeshContext* context = new MeshContext;
+
+ context->m_device = desc->device;
+ context->m_deviceContext = desc->context;
+
+ // create the input layout
+ {
+ D3D11_INPUT_ELEMENT_DESC inputElementDescs[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
+ };
+
+ context->m_device->CreateInputLayout(inputElementDescs, 2, g_meshVS, sizeof(g_meshVS), &context->m_inputLayout);
+ }
+
+ // create the shaders
+ context->m_device->CreateVertexShader(g_meshVS, sizeof(g_meshVS), nullptr, &context->m_meshVS);
+ context->m_device->CreatePixelShader(g_meshPS, sizeof(g_meshPS), nullptr, &context->m_meshPS);
+
+ // create a constant buffer
+ {
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = 64 * sizeof(float);
+ bufDesc.Usage = D3D11_USAGE_DYNAMIC;
+ bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+ bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ bufDesc.MiscFlags = 0;
+
+ context->m_device->CreateBuffer(&bufDesc, nullptr, &context->m_constantBuffer);
+ }
+
+ // create the rastersizer state
+ {
+ D3D11_RASTERIZER_DESC desc = {};
+ desc.FillMode = D3D11_FILL_SOLID;
+ desc.CullMode = D3D11_CULL_BACK;
+ desc.FrontCounterClockwise = TRUE; // This is non-default
+ desc.DepthBias = 0;
+ desc.DepthBiasClamp = 0.f;
+ desc.SlopeScaledDepthBias = 0.f;
+ desc.DepthClipEnable = TRUE;
+ desc.ScissorEnable = FALSE;
+ desc.MultisampleEnable = FALSE;
+ desc.AntialiasedLineEnable = FALSE;
+
+ context->m_device->CreateRasterizerState(&desc, &context->m_rasterizerStateRH);
+ }
+
+ return context;
+}
+
+void MeshContextUpdate(MeshContext* context, const MeshContextDesc* desc)
+{
+ context->m_device = desc->device;
+ context->m_deviceContext = desc->context;
+}
+
+void MeshContextRelease(MeshContext* context)
+{
+ if (context == nullptr) return;
+
+ delete context;
+}
+
+MeshIndexBuffer* MeshIndexBufferCreate(MeshContext* context, MeshUint* indices, MeshUint numIndices)
+{
+ MeshIndexBuffer* buffer = new MeshIndexBuffer;
+
+ buffer->m_numElements = numIndices;
+ // create an index buffer
+ {
+ UINT bufferSize = (UINT)(numIndices) * sizeof(UINT);
+
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = bufferSize;
+ bufDesc.Usage = D3D11_USAGE_IMMUTABLE;
+ bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
+ bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE;
+ bufDesc.MiscFlags = 0;
+
+ D3D11_SUBRESOURCE_DATA data = {};
+ data.pSysMem = indices;
+
+ context->m_device->CreateBuffer(&bufDesc, &data, &buffer->m_buffer);
+ }
+
+ return buffer;
+}
+
+void MeshIndexBufferRelease(MeshIndexBuffer* buffer)
+{
+ if (buffer == nullptr) return;
+
+ delete buffer;
+}
+
+MeshVertexBuffer* MeshVertexBufferCreate(MeshContext* context, MeshVertex* vertices, MeshUint numVertices)
+{
+ MeshVertexBuffer* buffer = new MeshVertexBuffer;
+
+ buffer->m_numElements = numVertices;
+ // create a vertex buffer
+ {
+ UINT bufferSize = (UINT)(numVertices * sizeof(MeshVertex));
+
+ D3D11_BUFFER_DESC bufDesc;
+ bufDesc.ByteWidth = bufferSize;
+ bufDesc.Usage = D3D11_USAGE_IMMUTABLE;
+ bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+ bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE;
+ bufDesc.MiscFlags = 0;
+
+ D3D11_SUBRESOURCE_DATA data = {};
+ data.pSysMem = vertices;
+
+ context->m_device->CreateBuffer(&bufDesc, &data, &buffer->m_buffer);
+ }
+
+ return buffer;
+}
+
+void MeshVertexBufferRelease(MeshVertexBuffer* buffer)
+{
+ if (buffer == nullptr) return;
+
+ delete buffer;
+}
+
+void MeshContextDraw(MeshContext* context, const MeshContextDrawParams* params)
+{
+ using namespace DirectX;
+
+ XMMATRIX matrix = XMMatrixTranspose(XMMatrixMultiply(XMMatrixMultiply(
+ params->params->model,
+ params->params->view),
+ params->params->projection)
+ );
+
+ ID3D11DeviceContext* deviceContext = context->m_deviceContext;
+
+ // update constant buffer
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource = {};
+ if (S_OK == deviceContext->Map(context->m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))
+ {
+ XMStoreFloat4x4((XMFLOAT4X4*)(mappedResource.pData), matrix);
+
+ deviceContext->Unmap(context->m_constantBuffer, 0u);
+ }
+ }
+
+ deviceContext->VSSetShader(context->m_meshVS, nullptr, 0u);
+ deviceContext->PSSetShader(context->m_meshPS, nullptr, 0u);
+
+ deviceContext->IASetInputLayout(context->m_inputLayout);
+
+ deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+
+ deviceContext->VSSetConstantBuffers(0, 1, &context->m_constantBuffer);
+
+ UINT vertexStride = sizeof(MeshVertex);
+ UINT offset = 0u;
+ deviceContext->IASetVertexBuffers(0, 1, &params->vertexBuffer->m_buffer, &vertexStride, &offset);
+ deviceContext->IASetIndexBuffer(params->indexBuffer->m_buffer, DXGI_FORMAT_R32_UINT, 0u);
+
+ float depthSign = DirectX::XMVectorGetW(params->params->projection.r[2]);
+ if (depthSign < 0.f)
+ {
+ deviceContext->RSSetState(context->m_rasterizerStateRH);
+ }
+
+ deviceContext->DrawIndexed((UINT)params->indexBuffer->m_numElements, 0, 0);
+
+ if (depthSign < 0.f)
+ {
+ deviceContext->RSSetState(nullptr);
+ }
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/meshD3D11.h b/demo/DemoAppD3D11/meshD3D11.h
new file mode 100644
index 0000000..86efe6b
--- /dev/null
+++ b/demo/DemoAppD3D11/meshD3D11.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2014-2017, 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 "../DemoApp/mesh.h"
+
+struct MeshContextDesc
+{
+ ID3D11Device* device;
+ ID3D11DeviceContext* context;
+}; \ No newline at end of file
diff --git a/demo/DemoAppD3D11/meshInteropD3D11.cpp b/demo/DemoAppD3D11/meshInteropD3D11.cpp
new file mode 100644
index 0000000..5ab9a90
--- /dev/null
+++ b/demo/DemoAppD3D11/meshInteropD3D11.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014-2017, 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.
+ */
+
+//direct3d headers
+#include <d3d11.h>
+
+// include the Direct3D Library file
+#pragma comment (lib, "d3d11.lib")
+
+#include "../DemoApp/meshInterop.h"
+
+#include "appD3D11Ctx.h"
+#include "meshD3D11.h"
+
+MeshContext* MeshInteropContextCreate(AppGraphCtx* appctx)
+{
+ MeshContextDesc desc = {};
+ desc.device = appctx->m_device;
+ desc.context = appctx->m_deviceContext;
+
+ return MeshContextCreate(&desc);
+}
+
+void MeshInteropContextUpdate(MeshContext* context, AppGraphCtx* appctx)
+{
+ MeshContextDesc desc = {};
+ desc.device = appctx->m_device;
+ desc.context = appctx->m_deviceContext;
+
+ return MeshContextUpdate(context, &desc);
+} \ No newline at end of file
diff --git a/demo/DemoAppD3D11/meshPS.hlsl.h b/demo/DemoAppD3D11/meshPS.hlsl.h
new file mode 100644
index 0000000..fcef532
--- /dev/null
+++ b/demo/DemoAppD3D11/meshPS.hlsl.h
@@ -0,0 +1,205 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+//
+// Input signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION 0 xyzw 0 POS float
+// NORMAL 0 xyz 1 NONE float xyz
+//
+//
+// Output signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET 0 xyzw 0 TARGET float xyzw
+//
+ps_5_0
+dcl_globalFlags refactoringAllowed
+dcl_input_ps linear v1.xyz
+dcl_output o0.xyzw
+dcl_temps 1
+dp3 r0.x, v1.xyzx, l(0.570000, 0.570000, 0.570000, 0.000000)
+max r0.x, r0.x, l(0.000000)
+mad r0.x, r0.x, l(0.400000), l(0.100000)
+dp3 r0.y, v1.xyzx, l(-0.570000, 0.570000, 0.570000, 0.000000)
+max r0.y, r0.y, l(0.000000)
+mad r0.x, r0.y, l(0.400000), r0.x
+dp3 r0.y, v1.xyzx, l(0.570000, 0.570000, -0.570000, 0.000000)
+max r0.y, r0.y, l(0.000000)
+mad r0.x, r0.y, l(0.400000), r0.x
+dp3 r0.y, v1.xzyx, l(-0.570000, -0.570000, 0.570000, 0.000000)
+max r0.y, r0.y, l(0.000000)
+mad o0.xyz, r0.yyyy, l(0.400000, 0.400000, 0.400000, 0.000000), r0.xxxx
+mov o0.w, l(1.000000)
+ret
+// Approximately 14 instruction slots used
+#endif
+
+const BYTE g_meshPS[] =
+{
+ 68, 88, 66, 67, 253, 169,
+ 122, 175, 25, 228, 25, 139,
+ 94, 18, 195, 68, 91, 159,
+ 92, 156, 1, 0, 0, 0,
+ 188, 3, 0, 0, 5, 0,
+ 0, 0, 52, 0, 0, 0,
+ 160, 0, 0, 0, 244, 0,
+ 0, 0, 40, 1, 0, 0,
+ 32, 3, 0, 0, 82, 68,
+ 69, 70, 100, 0, 0, 0,
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0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0
+};
diff --git a/demo/DemoAppD3D11/meshVS.hlsl.h b/demo/DemoAppD3D11/meshVS.hlsl.h
new file mode 100644
index 0000000..e2c1466
--- /dev/null
+++ b/demo/DemoAppD3D11/meshVS.hlsl.h
@@ -0,0 +1,223 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions:
+//
+// cbuffer params
+// {
+//
+// float4x4 projection; // Offset: 0 Size: 64
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name Type Format Dim HLSL Bind Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// params cbuffer NA NA cb0 1
+//
+//
+//
+// Input signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// POSITION 0 xyz 0 NONE float xyz
+// NORMAL 0 xyz 1 NONE float xyz
+// SV_InstanceID 0 x 2 INSTID uint
+//
+//
+// Output signature:
+//
+// Name Index Mask Register SysValue Format Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION 0 xyzw 0 POS float xyzw
+// NORMAL 0 xyz 1 NONE float xyz
+//
+vs_5_0
+dcl_globalFlags refactoringAllowed
+dcl_constantbuffer CB0[4], immediateIndexed
+dcl_input v0.xyz
+dcl_input v1.xyz
+dcl_output_siv o0.xyzw, position
+dcl_output o1.xyz
+dcl_temps 1
+mov r0.xyz, v0.xyzx
+mov r0.w, l(1.000000)
+dp4 o0.x, r0.xyzw, cb0[0].xyzw
+dp4 o0.y, r0.xyzw, cb0[1].xyzw
+dp4 o0.z, r0.xyzw, cb0[2].xyzw
+dp4 o0.w, r0.xyzw, cb0[3].xyzw
+mov o1.xyz, v1.xyzx
+ret
+// Approximately 8 instruction slots used
+#endif
+
+const BYTE g_meshVS[] =
+{
+ 68, 88, 66, 67, 146, 57,
+ 84, 204, 22, 172, 14, 230,
+ 119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