aboutsummaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorMiles Macklin <[email protected]>2017-07-05 12:59:25 +1200
committerMiles Macklin <[email protected]>2017-07-05 12:59:25 +1200
commit7f669cec7c812a366eedaf0cdfe09d6a5bad84af (patch)
tree5744216f9f88788c88f07a69ad11a43d232c95f9 /demo
parent1.2.0.beta.1 (diff)
downloadflex-7f669cec7c812a366eedaf0cdfe09d6a5bad84af.tar.xz
flex-7f669cec7c812a366eedaf0cdfe09d6a5bad84af.zip
Flex 1.2 (beta 2)
Diffstat (limited to 'demo')
-rw-r--r--demo/compiler/vc12win32/flexDemoCUDA.vcxproj.user24
-rw-r--r--demo/compiler/vc12win32/flexDemoD3D.vcxproj.user24
-rw-r--r--demo/compiler/vc12win64/flexDemoCUDA.vcxproj.user24
-rw-r--r--demo/compiler/vc12win64/flexDemoD3D.vcxproj.user24
-rw-r--r--demo/compiler/vc14win32/flexDemoCUDA.vcxproj.user24
-rw-r--r--demo/compiler/vc14win32/flexDemoD3D.vcxproj.user24
-rw-r--r--demo/compiler/vc14win64/flexDemoCUDA.vcxproj.user24
-rw-r--r--demo/compiler/vc14win64/flexDemoD3D.vcxproj.user24
-rw-r--r--demo/d3d12/appD3D12Ctx.cpp10
-rw-r--r--demo/d3d12/demoContextD3D12.cpp52
-rw-r--r--demo/d3d12/demoContextD3D12.h12
-rw-r--r--demo/helpers.h9
-rw-r--r--demo/main.cpp38
13 files changed, 202 insertions, 111 deletions
diff --git a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.user b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.user
index 1860514..2fc5615 100644
--- a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.user
+++ b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc12win32/flexDemoD3D.vcxproj.user b/demo/compiler/vc12win32/flexDemoD3D.vcxproj.user
index 1860514..2fc5615 100644
--- a/demo/compiler/vc12win32/flexDemoD3D.vcxproj.user
+++ b/demo/compiler/vc12win32/flexDemoD3D.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.user b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.user
index 0c241a3..2273e49 100644
--- a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.user
+++ b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc12win64/flexDemoD3D.vcxproj.user b/demo/compiler/vc12win64/flexDemoD3D.vcxproj.user
index 0c241a3..2273e49 100644
--- a/demo/compiler/vc12win64/flexDemoD3D.vcxproj.user
+++ b/demo/compiler/vc12win64/flexDemoD3D.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.user b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.user
index 1860514..2fc5615 100644
--- a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.user
+++ b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc14win32/flexDemoD3D.vcxproj.user b/demo/compiler/vc14win32/flexDemoD3D.vcxproj.user
index 1860514..2fc5615 100644
--- a/demo/compiler/vc14win32/flexDemoD3D.vcxproj.user
+++ b/demo/compiler/vc14win32/flexDemoD3D.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|Win32&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.user b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.user
index 0c241a3..2273e49 100644
--- a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.user
+++ b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/compiler/vc14win64/flexDemoD3D.vcxproj.user b/demo/compiler/vc14win64/flexDemoD3D.vcxproj.user
index 0c241a3..2273e49 100644
--- a/demo/compiler/vc14win64/flexDemoD3D.vcxproj.user
+++ b/demo/compiler/vc14win64/flexDemoD3D.vcxproj.user
@@ -1,9 +1,15 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
- <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
-</PropertyGroup>
-</Project> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8" ?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release|x64&apos;">
+ <LocalDebuggerWorkingDirectory>$(OutputPath)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
diff --git a/demo/d3d12/appD3D12Ctx.cpp b/demo/d3d12/appD3D12Ctx.cpp
index 944453a..82aa56a 100644
--- a/demo/d3d12/appD3D12Ctx.cpp
+++ b/demo/d3d12/appD3D12Ctx.cpp
@@ -310,7 +310,7 @@ void AppGraphCtxInitRenderTargetD3D12(AppGraphCtx* contextIn, SDL_Window* window
hr = pFactory->CreateSwapChain(context->m_commandQueue, &desc, (IDXGISwapChain**)&context->m_swapChain);
- if(hr != S_OK)
+ if (hr != S_OK)
{
COMRelease(context->m_swapChain);
context->m_fullscreen = false;
@@ -378,7 +378,7 @@ void AppGraphCtxInitRenderTargetD3D12(AppGraphCtx* contextIn, SDL_Window* window
D3D12_RESOURCE_DESC desc = backBuffer->GetDesc();
DXGI_FORMAT resourceFormat;
-
+
if (desc.Format == DXGI_FORMAT_R32_FLOAT || desc.Format == DXGI_FORMAT_D32_FLOAT)
{
resourceFormat = DXGI_FORMAT_R32_TYPELESS;
@@ -449,7 +449,7 @@ void AppGraphCtxInitRenderTargetD3D12(AppGraphCtx* contextIn, SDL_Window* window
D3D12_RESOURCE_STATE_DEPTH_WRITE,
&clearValue,
IID_PPV_ARGS(&context->m_depthStencil)
- ))
+ ))
{
return;
}
@@ -457,7 +457,7 @@ void AppGraphCtxInitRenderTargetD3D12(AppGraphCtx* contextIn, SDL_Window* window
// create the depth stencil view
D3D12_DEPTH_STENCIL_VIEW_DESC viewDesc = {};
viewDesc.Format = context->m_dsv_format; // DXGI_FORMAT_D32_FLOAT;
- viewDesc.ViewDimension = (context->m_numMsaaSamples>1) ? D3D12_DSV_DIMENSION_TEXTURE2DMS : D3D12_DSV_DIMENSION_TEXTURE2D;
+ viewDesc.ViewDimension = (context->m_numMsaaSamples > 1) ? D3D12_DSV_DIMENSION_TEXTURE2DMS : D3D12_DSV_DIMENSION_TEXTURE2D;
viewDesc.Flags = D3D12_DSV_FLAG_NONE;
viewDesc.Texture2D.MipSlice = 0;
@@ -621,8 +621,10 @@ void AppGraphCtxFramePresentD3D12(AppGraphCtx* contextIn, bool fullsync)
auto context = cast_to_AppGraphCtxD3D12(contextIn);
// check if now is good time to present
+#if 0 // disable frame latency waitable object check because it will cause vsync to fail
bool shouldPresent = context->m_fullscreen ? true : WaitForSingleObjectEx(context->m_swapChainWaitableObject, 0, TRUE) != WAIT_TIMEOUT;
if (shouldPresent)
+#endif
{
context->m_swapChain->Present(fullsync, 0);
context->m_renderTargetID++;
diff --git a/demo/d3d12/demoContextD3D12.cpp b/demo/d3d12/demoContextD3D12.cpp
index 8a698f7..110aea1 100644
--- a/demo/d3d12/demoContextD3D12.cpp
+++ b/demo/d3d12/demoContextD3D12.cpp
@@ -74,11 +74,42 @@ DemoContextD3D12::DemoContextD3D12()
// Allocate space for all debug vertices
m_debugLineVertices.resize(MAX_DEBUG_LINE_SIZE);
+
+ m_renderStateManager = new RenderStateManagerD3D12;
+}
+
+template <class T>
+void inline COMRelease(T& t)
+{
+ if (t) t->Release();
+ t = nullptr;
}
DemoContextD3D12::~DemoContextD3D12()
{
imguiGraphDestroy();
+
+ AppGraphCtxRelease(m_appGraphCtx);
+
+ delete m_renderStateManager;
+
+ COMRelease(m_graphicsCompleteFence);
+ COMRelease(m_queryHeap);
+ COMRelease(m_queryResults);
+
+ // Explicitly delete these, so we can call D3D memory leak checker at bottom of this destructor
+ m_meshPipeline.reset();
+ m_pointPipeline.reset();
+ m_fluidPointPipeline.reset();
+ m_fluidSmoothPipeline.reset();
+ m_fluidCompositePipeline.reset();
+ m_diffusePointPipeline.reset();
+ m_linePipeline.reset();
+ m_fluidPointRenderTarget.reset();
+ m_fluidSmoothRenderTarget.reset();
+ m_fluidResolvedTarget.reset();
+ m_screenQuadMesh.reset();
+ m_shadowMap.reset();
}
bool DemoContextD3D12::initialize(const RenderInitOptions& options)
@@ -183,8 +214,8 @@ int DemoContextD3D12::_initRenderResources(const RenderInitOptions& options)
{
// Make enough space for largest _single_ dynamic buffer allocation
- NV_RETURN_ON_FAIL(m_renderStateManager.initialize(renderContext, 16 * 1024 * 1024));
- m_renderState = m_renderStateManager.getState();
+ NV_RETURN_ON_FAIL(m_renderStateManager->initialize(renderContext, 16 * 1024 * 1024));
+ m_renderState = m_renderStateManager->getState();
}
// Create the renderer
@@ -465,7 +496,7 @@ void DemoContextD3D12::startFrame(FlexVec4 colorIn)
AppGraphCtxD3D12* renderContext = getRenderContext();
// Work out what what can be recovered, as GPU no longer accessing
- m_renderStateManager.updateCompleted();
+ m_renderStateManager->updateCompleted();
AppGraphColor clearColor = { colorIn.x, colorIn.y, colorIn.z, colorIn.w };
AppGraphCtxFrameStart(cast_from_AppGraphCtxD3D12(renderContext), clearColor);
@@ -529,11 +560,11 @@ void DemoContextD3D12::endFrame()
renderContext->m_commandListOpenCount = 0;
// Inform the manager that the work has been submitted
- m_renderStateManager.onGpuWorkSubmitted(renderContext->m_commandQueue);
+ m_renderStateManager->onGpuWorkSubmitted(renderContext->m_commandQueue);
HANDLE completeEvent = m_graphicsCompleteEvent;
- renderContext->m_commandQueue->Signal(m_graphicsCompleteFence.Get(), m_graphicsCompleteFenceValue);
+ renderContext->m_commandQueue->Signal(m_graphicsCompleteFence, m_graphicsCompleteFenceValue);
}
void DemoContextD3D12::getRenderDevice(void** device, void** context)
@@ -1060,15 +1091,15 @@ void DemoContextD3D12::graphicsTimerBegin()
{
ID3D12GraphicsCommandList* commandList = m_renderContext->m_commandList;
- commandList->EndQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 0);
+ commandList->EndQuery(m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0);
}
void DemoContextD3D12::graphicsTimerEnd()
{
ID3D12GraphicsCommandList* commandList = m_renderContext->m_commandList;
- commandList->EndQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 1);
- commandList->ResolveQueryData(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, m_queryResults.Get(), 0);
+ commandList->EndQuery(m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 1);
+ commandList->ResolveQueryData(m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, m_queryResults, 0);
}
float DemoContextD3D12::rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq)
@@ -1086,10 +1117,9 @@ float DemoContextD3D12::rendererGetDeviceTimestamps(unsigned long long* begin, u
commandQueue->GetTimestampFrequency(&frequency);
}
- //Get render timestamps
+ // Get render timestamps
uint64_t* times;
- //m_queryResults->Map(0, nullptr, (void**)&times);
- D3D12_RANGE readRange = { 0, 1 };
+ D3D12_RANGE readRange = { 0, 2 };
m_queryResults->Map(0, &readRange, (void**)&times);
uint64_t renderBegin = times[0];
uint64_t renderEnd = times[1];
diff --git a/demo/d3d12/demoContextD3D12.h b/demo/d3d12/demoContextD3D12.h
index 5f43c31..894cb0d 100644
--- a/demo/d3d12/demoContextD3D12.h
+++ b/demo/d3d12/demoContextD3D12.h
@@ -232,7 +232,7 @@ public:
std::wstring m_executablePath;
std::wstring m_shadersPath;
- RenderStateManagerD3D12 m_renderStateManager;
+ RenderStateManagerD3D12* m_renderStateManager;
RenderStateD3D12 m_renderState;
SDL_Window* m_window;
@@ -241,11 +241,11 @@ public:
int m_msaaSamples;
// Synchronization and timing for async compute benchmarking
- ComPtr<ID3D12Fence> m_graphicsCompleteFence;
- HANDLE m_graphicsCompleteEvent;
- UINT64 m_graphicsCompleteFenceValue;
- ComPtr<ID3D12QueryHeap> m_queryHeap;
- ComPtr<ID3D12Resource> m_queryResults;
+ ID3D12Fence* m_graphicsCompleteFence;
+ HANDLE m_graphicsCompleteEvent;
+ UINT64 m_graphicsCompleteFenceValue;
+ ID3D12QueryHeap* m_queryHeap;
+ ID3D12Resource* m_queryResults;
bool m_inLineDraw;
std::vector<LineData::Vertex> m_debugLineVertices;
diff --git a/demo/helpers.h b/demo/helpers.h
index adc9af5..984883f 100644
--- a/demo/helpers.h
+++ b/demo/helpers.h
@@ -708,10 +708,15 @@ NvFlexTriangleMeshId CreateTriangleMesh(Mesh* m)
Vec3 lower, upper;
m->GetBounds(lower, upper);
- NvFlexVector<Vec3> positions(g_flexLib);
+ NvFlexVector<Vec4> positions(g_flexLib, m->m_positions.size());
+ positions.map();
NvFlexVector<int> indices(g_flexLib);
- positions.assign((Vec3*)&m->m_positions[0], m->m_positions.size());
+ for (int i = 0; i < int(m->m_positions.size()); ++i)
+ {
+ Vec3 vertex = Vec3(m->m_positions[i]);
+ positions[i] = Vec4(vertex, 0.0f);
+ }
indices.assign((int*)&m->m_indices[0], m->m_indices.size());
positions.unmap();
diff --git a/demo/main.cpp b/demo/main.cpp
index df05ef7..87ef326 100644
--- a/demo/main.cpp
+++ b/demo/main.cpp
@@ -559,6 +559,13 @@ void Init(int scene, bool centerCamera = true)
{
RandInit();
+ if (g_buffers)
+ {
+ // Wait for any running GPU work to finish
+ MapBuffers(g_buffers);
+ UnmapBuffers(g_buffers);
+ }
+
if (g_solver)
{
if (g_buffers)
@@ -2037,13 +2044,13 @@ void UpdateFrame()
// Getting timers causes CPU/GPU sync, so we do it after a map
float newSimLatency = NvFlexGetDeviceLatency(g_solver, &g_GpuTimers.computeBegin, &g_GpuTimers.computeEnd, &g_GpuTimers.computeFreq);
- float newGfxLatency = RendererGetDeviceTimestamps(&g_GpuTimers.renderBegin, &g_GpuTimers.renderEnd,&g_GpuTimers.renderFreq);
+ float newGfxLatency = RendererGetDeviceTimestamps(&g_GpuTimers.renderBegin, &g_GpuTimers.renderEnd, &g_GpuTimers.renderFreq);
(void)newGfxLatency;
UpdateCamera();
- if (!g_pause || g_step)
- {
+ if (!g_pause || g_step)
+ {
UpdateEmitters();
UpdateMouse();
UpdateWind();
@@ -2073,14 +2080,14 @@ void UpdateFrame()
// main scene render
RenderScene();
RenderDebug();
-
+
int newScene = DoUI();
EndFrame();
// If user has disabled async compute, ensure that no compute can overlap
// graphics by placing a sync between them
- if (!g_useAsyncCompute)
+ if (!g_useAsyncCompute)
NvFlexComputeWaitForGraphics(g_flexLib);
UnmapBuffers(g_buffers);
@@ -2111,7 +2118,7 @@ void UpdateFrame()
double renderEndTime = GetSeconds();
// if user requested a scene reset process it now
- if (g_resetScene)
+ if (g_resetScene)
{
Reset();
g_resetScene = false;
@@ -2196,7 +2203,7 @@ void UpdateFrame()
else
{
// read back just the new diffuse particle count, render buffers will be updated during rendering
- NvFlexGetDiffuseParticles(g_solver, NULL, NULL, g_buffers->diffuseCount.buffer);
+ NvFlexGetDiffuseParticles(g_solver, NULL, NULL, g_buffers->diffuseCount.buffer);
}
@@ -2216,8 +2223,12 @@ void UpdateFrame()
g_renderTime = (g_renderTime == 0.0f) ? newRenderTime : Lerp(g_renderTime, newRenderTime, timerSmoothing);
g_waitTime = (g_waitTime == 0.0f) ? newWaitTime : Lerp(g_waitTime, newWaitTime, timerSmoothing);
g_simLatency = (g_simLatency == 0.0f) ? newSimLatency : Lerp(g_simLatency, newSimLatency, timerSmoothing);
-
- if(g_benchmark) newScene = BenchmarkUpdate();
+
+ if (g_benchmark) newScene = BenchmarkUpdate();
+
+ // flush out the last frame before freeing up resources in the event of a scene change
+ // this is necessary for d3d12
+ PresentFrame(g_vsync);
// if gui or benchmark requested a scene change process it now
if (newScene != -1)
@@ -2225,8 +2236,6 @@ void UpdateFrame()
g_scene = newScene;
Init(g_scene);
}
-
- PresentFrame(g_vsync);
}
void ReshapeWindow(int width, int height)
@@ -2961,14 +2970,14 @@ int main(int argc, char* argv[])
SoftBody* plasticStackScene = new SoftBody("Plastic Stack");
plasticStackScene->AddInstance(stackBox);
plasticStackScene->AddInstance(stackSphere);
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++)
+ {
stackBox.mTranslation[1] += 2.0f;
stackSphere.mTranslation[1] += 2.0f;
plasticStackScene->AddInstance(stackBox);
plasticStackScene->AddInstance(stackSphere);
}
-
g_scenes.push_back(softOctopusSceneNew);
g_scenes.push_back(softTeapotSceneNew);
g_scenes.push_back(softRopeSceneNew);
@@ -2982,7 +2991,6 @@ int main(int argc, char* argv[])
g_scenes.push_back(plasticComparisonScene);
g_scenes.push_back(plasticStackScene);
-
// collision scenes
g_scenes.push_back(new FrictionRamp("Friction Ramp"));
g_scenes.push_back(new FrictionMovingShape("Friction Moving Box", 0));
@@ -2995,7 +3003,6 @@ int main(int argc, char* argv[])
g_scenes.push_back(new LocalSpaceCloth("Local Space Cloth"));
g_scenes.push_back(new CCDFluid("World Space Fluid"));
-
// cloth scenes
g_scenes.push_back(new EnvironmentalCloth("Env Cloth Small", 6, 6, 40, 16));
g_scenes.push_back(new EnvironmentalCloth("Env Cloth Large", 16, 32, 10, 3));
@@ -3006,7 +3013,6 @@ int main(int argc, char* argv[])
g_scenes.push_back(new Tearing("Tearing"));
g_scenes.push_back(new Pasta("Pasta"));
-
// game mesh scenes
g_scenes.push_back(new GameMesh("Game Mesh Rigid", 0));
g_scenes.push_back(new GameMesh("Game Mesh Particles", 1));