aboutsummaryrefslogtreecommitdiff
path: root/demo/DemoApp
diff options
context:
space:
mode:
authorAndrew Reidmeyer <[email protected]>2017-06-13 20:38:29 -0600
committerAndrew Reidmeyer <[email protected]>2017-06-13 20:38:29 -0600
commit62a1427154131f2387675957c1d2027061f354f0 (patch)
tree4efdcb7d3fe9722d46523a51bc5c90b96f25441e /demo/DemoApp
parentInitial 1.0.0 binary release (diff)
downloadflow-1.0.1.tar.xz
flow-1.0.1.zip
NvFlow 1.0.1v1.0.1
Diffstat (limited to 'demo/DemoApp')
-rw-r--r--demo/DemoApp/DemoApp.vcxproj25
-rw-r--r--demo/DemoApp/DemoApp.vcxproj.filters3
-rw-r--r--demo/DemoApp/NvFlowInteropLoader.cpp48
-rw-r--r--demo/DemoApp/NvFlowInteropLoaderGenerated.h96
-rw-r--r--demo/DemoApp/appGraphCtx.h7
-rw-r--r--demo/DemoApp/appGraphCtxLoader.cpp77
-rw-r--r--demo/DemoApp/appGraphCtxLoaderGenerated.h150
-rw-r--r--demo/DemoApp/computeContextLoader.cpp132
-rw-r--r--demo/DemoApp/computeContextLoaderGenerated.h249
-rw-r--r--demo/DemoApp/imguiGraphLoader.cpp109
-rw-r--r--demo/DemoApp/imguiGraphLoaderGenerated.h204
-rw-r--r--demo/DemoApp/loader.h66
-rw-r--r--demo/DemoApp/main.cpp12
-rw-r--r--demo/DemoApp/meshLoader.cpp67
-rw-r--r--demo/DemoApp/meshLoaderGenerated.h132
-rw-r--r--demo/DemoApp/preset0.h4
-rw-r--r--demo/DemoApp/preset1.h4
-rw-r--r--demo/DemoApp/scene.cpp84
-rw-r--r--demo/DemoApp/scene.h80
-rw-r--r--demo/DemoApp/scene2DTextureEmitter.cpp2
-rw-r--r--demo/DemoApp/sceneCustomEmit.cpp2
-rw-r--r--demo/DemoApp/sceneEmitSubStep.cpp204
-rw-r--r--demo/DemoApp/sceneFlow.cpp70
-rw-r--r--demo/DemoApp/sceneSDF.cpp4
-rw-r--r--demo/DemoApp/sceneSimpleFlame.cpp51
-rw-r--r--demo/DemoApp/sceneSimpleSmoke.cpp2
26 files changed, 1360 insertions, 524 deletions
diff --git a/demo/DemoApp/DemoApp.vcxproj b/demo/DemoApp/DemoApp.vcxproj
index 4cae61f..ba4e592 100644
--- a/demo/DemoApp/DemoApp.vcxproj
+++ b/demo/DemoApp/DemoApp.vcxproj
@@ -141,6 +141,12 @@ copy "$(SolutionDir)Lib\$(PlatformName)\*.dll" "$(outDir)"</Command>
<CustomBuildStep>
<Outputs>SDL2.dll</Outputs>
</CustomBuildStep>
+ <PreBuildEvent>
+ <Command>"$(outDir)DemoAppCodeGen$(Configuration)_$(PlatformName).exe"</Command>
+ </PreBuildEvent>
+ <PreBuildEvent>
+ <Message>Code Generation</Message>
+ </PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
@@ -172,6 +178,12 @@ copy "$(SolutionDir)Lib\$(PlatformName)\*.dll" "$(outDir)"</Command>
<CustomBuildStep>
<Outputs>SDL2.dll</Outputs>
</CustomBuildStep>
+ <PreBuildEvent>
+ <Command>"$(outDir)DemoAppCodeGen$(Configuration)_$(PlatformName).exe"</Command>
+ </PreBuildEvent>
+ <PreBuildEvent>
+ <Message>Code Generation</Message>
+ </PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@@ -207,6 +219,12 @@ copy "$(SolutionDir)Lib\$(PlatformName)\*.dll" "$(outDir)"</Command>
<CustomBuildStep>
<Outputs>SDL2.dll</Outputs>
</CustomBuildStep>
+ <PreBuildEvent>
+ <Command>"$(outDir)DemoAppCodeGen$(Configuration)_$(PlatformName).exe"</Command>
+ </PreBuildEvent>
+ <PreBuildEvent>
+ <Message>Code Generation</Message>
+ </PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -242,6 +260,12 @@ copy "$(SolutionDir)Lib\$(PlatformName)\*.dll" "$(outDir)"</Command>
<CustomBuildStep>
<Outputs>SDL2.dll</Outputs>
</CustomBuildStep>
+ <PreBuildEvent>
+ <Command>"$(outDir)DemoAppCodeGen$(Configuration)_$(PlatformName).exe"</Command>
+ </PreBuildEvent>
+ <PreBuildEvent>
+ <Message>Code Generation</Message>
+ </PreBuildEvent>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
@@ -276,6 +300,7 @@ copy "$(SolutionDir)Lib\$(PlatformName)\*.dll" "$(outDir)"</Command>
<ClCompile Include="scene.cpp" />
<ClCompile Include="scene2DTextureEmitter.cpp" />
<ClCompile Include="sceneCustomEmit.cpp" />
+ <ClCompile Include="sceneEmitSubStep.cpp" />
<ClCompile Include="sceneFlow.cpp" />
<ClCompile Include="sceneSDF.cpp" />
<ClCompile Include="sceneSimpleFlame.cpp" />
diff --git a/demo/DemoApp/DemoApp.vcxproj.filters b/demo/DemoApp/DemoApp.vcxproj.filters
index 94b9d93..b6bfb93 100644
--- a/demo/DemoApp/DemoApp.vcxproj.filters
+++ b/demo/DemoApp/DemoApp.vcxproj.filters
@@ -78,6 +78,9 @@
<ClCompile Include="sceneFlow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="sceneEmitSubStep.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<Manifest Include="app.manifest">
diff --git a/demo/DemoApp/NvFlowInteropLoader.cpp b/demo/DemoApp/NvFlowInteropLoader.cpp
index 6224373..082afcf 100644
--- a/demo/DemoApp/NvFlowInteropLoader.cpp
+++ b/demo/DemoApp/NvFlowInteropLoader.cpp
@@ -14,50 +14,6 @@
#include "NvFlowInterop.h"
-namespace
-{
- ModuleLoader<16u, SDL_LoadObject, SDL_UnloadObject, SDL_LoadFunction> g_loader;
-}
+#include <stdio.h>
-void loadNvFlowInterop(AppGraphCtxType type)
-{
- const char* moduleName = demoAppDLLName(type);
-
- g_loader.loadModule(moduleName);
-}
-
-void unloadNvFlowInterop()
-{
- g_loader.unloadModule();
-}
-
-// Functions
-NvFlowContext* NvFlowInteropCreateContext(AppGraphCtx* appctx)
-{
- return g_loader.function<0>(NvFlowInteropCreateContext, "NvFlowInteropCreateContext", appctx);
-}
-
-NvFlowDepthStencilView* NvFlowInteropCreateDepthStencilView(AppGraphCtx* appctx, NvFlowContext* flowctx)
-{
- return g_loader.function<1>(NvFlowInteropCreateDepthStencilView, "NvFlowInteropCreateDepthStencilView", appctx, flowctx);
-}
-
-NvFlowRenderTargetView* NvFlowInteropCreateRenderTargetView(AppGraphCtx* appctx, NvFlowContext* flowctx)
-{
- return g_loader.function<2>(NvFlowInteropCreateRenderTargetView, "NvFlowInteropCreateRenderTargetView", appctx, flowctx);
-}
-
-void NvFlowInteropUpdateContext(NvFlowContext* context, AppGraphCtx* appctx)
-{
- return g_loader.function<3>(NvFlowInteropUpdateContext, "NvFlowInteropUpdateContext", context, appctx);
-}
-
-void NvFlowInteropUpdateDepthStencilView(NvFlowDepthStencilView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
-{
- return g_loader.function<4>(NvFlowInteropUpdateDepthStencilView, "NvFlowInteropUpdateDepthStencilView", view, appctx, flowctx);
-}
-
-void NvFlowInteropUpdateRenderTargetView(NvFlowRenderTargetView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
-{
- return g_loader.function<5>(NvFlowInteropUpdateRenderTargetView, "NvFlowInteropUpdateRenderTargetView", view, appctx, flowctx);
-} \ No newline at end of file
+#include "NvFlowInteropLoaderGenerated.h" \ No newline at end of file
diff --git a/demo/DemoApp/NvFlowInteropLoaderGenerated.h b/demo/DemoApp/NvFlowInteropLoaderGenerated.h
new file mode 100644
index 0000000..dad9989
--- /dev/null
+++ b/demo/DemoApp/NvFlowInteropLoaderGenerated.h
@@ -0,0 +1,96 @@
+/*
+* 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.
+*/
+
+typedef NvFlowContext* (*NvFlowInteropCreateContext_ptr_t)(AppGraphCtx* appctx);
+typedef NvFlowDepthStencilView* (*NvFlowInteropCreateDepthStencilView_ptr_t)(AppGraphCtx* appctx, NvFlowContext* flowctx);
+typedef NvFlowRenderTargetView* (*NvFlowInteropCreateRenderTargetView_ptr_t)(AppGraphCtx* appctx, NvFlowContext* flowctx);
+typedef void (*NvFlowInteropUpdateContext_ptr_t)(NvFlowContext* context, AppGraphCtx* appctx);
+typedef void (*NvFlowInteropUpdateDepthStencilView_ptr_t)(NvFlowDepthStencilView* view, AppGraphCtx* appctx, NvFlowContext* flowctx);
+typedef void (*NvFlowInteropUpdateRenderTargetView_ptr_t)(NvFlowRenderTargetView* view, AppGraphCtx* appctx, NvFlowContext* flowctx);
+
+struct NvFlowInteropLoader
+{
+ void* module = nullptr;
+ const char* suffix = "";
+ char buf[1024u];
+
+ NvFlowInteropCreateContext_ptr_t NvFlowInteropCreateContext_ptr;
+ NvFlowInteropCreateDepthStencilView_ptr_t NvFlowInteropCreateDepthStencilView_ptr;
+ NvFlowInteropCreateRenderTargetView_ptr_t NvFlowInteropCreateRenderTargetView_ptr;
+ NvFlowInteropUpdateContext_ptr_t NvFlowInteropUpdateContext_ptr;
+ NvFlowInteropUpdateDepthStencilView_ptr_t NvFlowInteropUpdateDepthStencilView_ptr;
+ NvFlowInteropUpdateRenderTargetView_ptr_t NvFlowInteropUpdateRenderTargetView_ptr;
+
+}gNvFlowInteropLoader;
+
+NvFlowContext* NvFlowInteropCreateContext(AppGraphCtx* appctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropCreateContext_ptr(appctx);
+}
+
+NvFlowDepthStencilView* NvFlowInteropCreateDepthStencilView(AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropCreateDepthStencilView_ptr(appctx, flowctx);
+}
+
+NvFlowRenderTargetView* NvFlowInteropCreateRenderTargetView(AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropCreateRenderTargetView_ptr(appctx, flowctx);
+}
+
+void NvFlowInteropUpdateContext(NvFlowContext* context, AppGraphCtx* appctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropUpdateContext_ptr(context, appctx);
+}
+
+void NvFlowInteropUpdateDepthStencilView(NvFlowDepthStencilView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropUpdateDepthStencilView_ptr(view, appctx, flowctx);
+}
+
+void NvFlowInteropUpdateRenderTargetView(NvFlowRenderTargetView* view, AppGraphCtx* appctx, NvFlowContext* flowctx)
+{
+ return gNvFlowInteropLoader.NvFlowInteropUpdateRenderTargetView_ptr(view, appctx, flowctx);
+}
+
+void* nvFlowInteropLoaderLoadFunction(NvFlowInteropLoader* inst, const char* name)
+{
+ snprintf(inst->buf, 1024u, "%s%s", name, inst->suffix);
+
+ return SDL_LoadFunction(inst->module, inst->buf);
+}
+
+void loadNvFlowInterop(AppGraphCtxType type)
+{
+ const char* moduleName = demoAppDLLName(type);
+
+ gNvFlowInteropLoader.suffix = demoAppBackendSuffix(type);
+
+ gNvFlowInteropLoader.module = SDL_LoadObject(moduleName);
+
+ gNvFlowInteropLoader.NvFlowInteropCreateContext_ptr = (NvFlowInteropCreateContext_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropCreateContext"));
+ gNvFlowInteropLoader.NvFlowInteropCreateDepthStencilView_ptr = (NvFlowInteropCreateDepthStencilView_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropCreateDepthStencilView"));
+ gNvFlowInteropLoader.NvFlowInteropCreateRenderTargetView_ptr = (NvFlowInteropCreateRenderTargetView_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropCreateRenderTargetView"));
+ gNvFlowInteropLoader.NvFlowInteropUpdateContext_ptr = (NvFlowInteropUpdateContext_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropUpdateContext"));
+ gNvFlowInteropLoader.NvFlowInteropUpdateDepthStencilView_ptr = (NvFlowInteropUpdateDepthStencilView_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropUpdateDepthStencilView"));
+ gNvFlowInteropLoader.NvFlowInteropUpdateRenderTargetView_ptr = (NvFlowInteropUpdateRenderTargetView_ptr_t)(nvFlowInteropLoaderLoadFunction(&gNvFlowInteropLoader, "NvFlowInteropUpdateRenderTargetView"));
+}
+
+void unloadNvFlowInterop()
+{
+ gNvFlowInteropLoader.NvFlowInteropCreateContext_ptr = nullptr;
+ gNvFlowInteropLoader.NvFlowInteropCreateDepthStencilView_ptr = nullptr;
+ gNvFlowInteropLoader.NvFlowInteropCreateRenderTargetView_ptr = nullptr;
+ gNvFlowInteropLoader.NvFlowInteropUpdateContext_ptr = nullptr;
+ gNvFlowInteropLoader.NvFlowInteropUpdateDepthStencilView_ptr = nullptr;
+ gNvFlowInteropLoader.NvFlowInteropUpdateRenderTargetView_ptr = nullptr;
+
+ SDL_UnloadObject(gNvFlowInteropLoader.module);
+}
diff --git a/demo/DemoApp/appGraphCtx.h b/demo/DemoApp/appGraphCtx.h
index 2f41c36..f1f0f75 100644
--- a/demo/DemoApp/appGraphCtx.h
+++ b/demo/DemoApp/appGraphCtx.h
@@ -16,6 +16,11 @@ struct SDL_Window;
struct AppGraphCtx;
+struct AppGraphColor
+{
+ float r, g, b, a;
+};
+
APP_GRAPH_CTX_API AppGraphCtx* AppGraphCtxCreate(int deviceID);
APP_GRAPH_CTX_API bool AppGraphCtxUpdateSize(AppGraphCtx* context, SDL_Window* window, bool fullscreen);
@@ -24,7 +29,7 @@ APP_GRAPH_CTX_API void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context);
APP_GRAPH_CTX_API void AppGraphCtxRelease(AppGraphCtx* context);
-APP_GRAPH_CTX_API void AppGraphCtxFrameStart(AppGraphCtx* context, float clearColor[4]);
+APP_GRAPH_CTX_API void AppGraphCtxFrameStart(AppGraphCtx* context, AppGraphColor clearColor);
APP_GRAPH_CTX_API void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync);
diff --git a/demo/DemoApp/appGraphCtxLoader.cpp b/demo/DemoApp/appGraphCtxLoader.cpp
index f724a93..6aa0f67 100644
--- a/demo/DemoApp/appGraphCtxLoader.cpp
+++ b/demo/DemoApp/appGraphCtxLoader.cpp
@@ -14,79 +14,6 @@
#include "appGraphCtx.h"
-namespace
-{
- ModuleLoader<16u, SDL_LoadObject, SDL_UnloadObject, SDL_LoadFunction> g_loader;
-}
+#include <stdio.h>
-void loadAppGraphCtx(AppGraphCtxType type)
-{
- const char* moduleName = demoAppDLLName(type);
-
- g_loader.loadModule(moduleName);
-}
-
-void unloadAppGraphCtx()
-{
- g_loader.unloadModule();
-}
-
-AppGraphCtx* AppGraphCtxCreate(int deviceID)
-{
- return g_loader.function<0>(AppGraphCtxCreate, "AppGraphCtxCreate", deviceID);
-}
-
-bool AppGraphCtxUpdateSize(AppGraphCtx* context, SDL_Window* window, bool fullscreen)
-{
- return g_loader.function<1>(AppGraphCtxUpdateSize, "AppGraphCtxUpdateSize", context, window, fullscreen);
-}
-
-void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context)
-{
- return g_loader.function<2>(AppGraphCtxReleaseRenderTarget, "AppGraphCtxReleaseRenderTarget", context);
-}
-
-void AppGraphCtxRelease(AppGraphCtx* context)
-{
- return g_loader.function<3>(AppGraphCtxRelease, "AppGraphCtxRelease", context);
-}
-
-void AppGraphCtxFrameStart(AppGraphCtx* context, float clearColor[4])
-{
- return g_loader.function<4>(AppGraphCtxFrameStart, "AppGraphCtxFrameStart", context, clearColor);
-}
-
-void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync)
-{
- return g_loader.function<5>(AppGraphCtxFramePresent, "AppGraphCtxFramePresent", context, fullsync);
-}
-
-void AppGraphCtxWaitForFrames(AppGraphCtx* context, unsigned int maxFramesInFlight)
-{
- return g_loader.function<6>(AppGraphCtxWaitForFrames, "AppGraphCtxWaitForFrames", context, maxFramesInFlight);
-}
-
-void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled)
-{
- return g_loader.function<7>(AppGraphCtxProfileEnable, "AppGraphCtxProfileEnable", context, enabled);
-}
-
-void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label)
-{
- return g_loader.function<8>(AppGraphCtxProfileBegin, "AppGraphCtxProfileBegin", context, label);
-}
-
-void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label)
-{
- return g_loader.function<9>(AppGraphCtxProfileEnd, "AppGraphCtxProfileEnd", context, label);
-}
-
-bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index)
-{
- return g_loader.function<10>(AppGraphCtxProfileGet, "AppGraphCtxProfileGet", context, plabel, cpuTime, gpuTime, index);
-}
-
-size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context)
-{
- return g_loader.function<11>(AppGraphCtxDedicatedVideoMemory, "AppGraphCtxDedicatedVideoMemory", context);
-} \ No newline at end of file
+#include "appGraphCtxLoaderGenerated.h" \ No newline at end of file
diff --git a/demo/DemoApp/appGraphCtxLoaderGenerated.h b/demo/DemoApp/appGraphCtxLoaderGenerated.h
new file mode 100644
index 0000000..7983c29
--- /dev/null
+++ b/demo/DemoApp/appGraphCtxLoaderGenerated.h
@@ -0,0 +1,150 @@
+/*
+* 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.
+*/
+
+typedef AppGraphCtx* (*AppGraphCtxCreate_ptr_t)(int deviceID);
+typedef bool (*AppGraphCtxUpdateSize_ptr_t)(AppGraphCtx* context, SDL_Window* window, bool fullscreen);
+typedef void (*AppGraphCtxReleaseRenderTarget_ptr_t)(AppGraphCtx* context);
+typedef void (*AppGraphCtxRelease_ptr_t)(AppGraphCtx* context);
+typedef void (*AppGraphCtxFrameStart_ptr_t)(AppGraphCtx* context, AppGraphColor clearColor);
+typedef void (*AppGraphCtxFramePresent_ptr_t)(AppGraphCtx* context, bool fullsync);
+typedef void (*AppGraphCtxWaitForFrames_ptr_t)(AppGraphCtx* context, unsigned int maxFramesInFlight);
+typedef void (*AppGraphCtxProfileEnable_ptr_t)(AppGraphCtx* context, bool enabled);
+typedef void (*AppGraphCtxProfileBegin_ptr_t)(AppGraphCtx* context, const char* label);
+typedef void (*AppGraphCtxProfileEnd_ptr_t)(AppGraphCtx* context, const char* label);
+typedef bool (*AppGraphCtxProfileGet_ptr_t)(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index);
+typedef size_t (*AppGraphCtxDedicatedVideoMemory_ptr_t)(AppGraphCtx* context);
+
+struct AppGraphCtxLoader
+{
+ void* module = nullptr;
+ const char* suffix = "";
+ char buf[1024u];
+
+ AppGraphCtxCreate_ptr_t AppGraphCtxCreate_ptr;
+ AppGraphCtxUpdateSize_ptr_t AppGraphCtxUpdateSize_ptr;
+ AppGraphCtxReleaseRenderTarget_ptr_t AppGraphCtxReleaseRenderTarget_ptr;
+ AppGraphCtxRelease_ptr_t AppGraphCtxRelease_ptr;
+ AppGraphCtxFrameStart_ptr_t AppGraphCtxFrameStart_ptr;
+ AppGraphCtxFramePresent_ptr_t AppGraphCtxFramePresent_ptr;
+ AppGraphCtxWaitForFrames_ptr_t AppGraphCtxWaitForFrames_ptr;
+ AppGraphCtxProfileEnable_ptr_t AppGraphCtxProfileEnable_ptr;
+ AppGraphCtxProfileBegin_ptr_t AppGraphCtxProfileBegin_ptr;
+ AppGraphCtxProfileEnd_ptr_t AppGraphCtxProfileEnd_ptr;
+ AppGraphCtxProfileGet_ptr_t AppGraphCtxProfileGet_ptr;
+ AppGraphCtxDedicatedVideoMemory_ptr_t AppGraphCtxDedicatedVideoMemory_ptr;
+
+}gAppGraphCtxLoader;
+
+AppGraphCtx* AppGraphCtxCreate(int deviceID)
+{
+ return gAppGraphCtxLoader.AppGraphCtxCreate_ptr(deviceID);
+}
+
+bool AppGraphCtxUpdateSize(AppGraphCtx* context, SDL_Window* window, bool fullscreen)
+{
+ return gAppGraphCtxLoader.AppGraphCtxUpdateSize_ptr(context, window, fullscreen);
+}
+
+void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context)
+{
+ return gAppGraphCtxLoader.AppGraphCtxReleaseRenderTarget_ptr(context);
+}
+
+void AppGraphCtxRelease(AppGraphCtx* context)
+{
+ return gAppGraphCtxLoader.AppGraphCtxRelease_ptr(context);
+}
+
+void AppGraphCtxFrameStart(AppGraphCtx* context, AppGraphColor clearColor)
+{
+ return gAppGraphCtxLoader.AppGraphCtxFrameStart_ptr(context, clearColor);
+}
+
+void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync)
+{
+ return gAppGraphCtxLoader.AppGraphCtxFramePresent_ptr(context, fullsync);
+}
+
+void AppGraphCtxWaitForFrames(AppGraphCtx* context, unsigned int maxFramesInFlight)
+{
+ return gAppGraphCtxLoader.AppGraphCtxWaitForFrames_ptr(context, maxFramesInFlight);
+}
+
+void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled)
+{
+ return gAppGraphCtxLoader.AppGraphCtxProfileEnable_ptr(context, enabled);
+}
+
+void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label)
+{
+ return gAppGraphCtxLoader.AppGraphCtxProfileBegin_ptr(context, label);
+}
+
+void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label)
+{
+ return gAppGraphCtxLoader.AppGraphCtxProfileEnd_ptr(context, label);
+}
+
+bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index)
+{
+ return gAppGraphCtxLoader.AppGraphCtxProfileGet_ptr(context, plabel, cpuTime, gpuTime, index);
+}
+
+size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context)
+{
+ return gAppGraphCtxLoader.AppGraphCtxDedicatedVideoMemory_ptr(context);
+}
+
+void* appGraphCtxLoaderLoadFunction(AppGraphCtxLoader* inst, const char* name)
+{
+ snprintf(inst->buf, 1024u, "%s%s", name, inst->suffix);
+
+ return SDL_LoadFunction(inst->module, inst->buf);
+}
+
+void loadAppGraphCtx(AppGraphCtxType type)
+{
+ const char* moduleName = demoAppDLLName(type);
+
+ gAppGraphCtxLoader.suffix = demoAppBackendSuffix(type);
+
+ gAppGraphCtxLoader.module = SDL_LoadObject(moduleName);
+
+ gAppGraphCtxLoader.AppGraphCtxCreate_ptr = (AppGraphCtxCreate_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxCreate"));
+ gAppGraphCtxLoader.AppGraphCtxUpdateSize_ptr = (AppGraphCtxUpdateSize_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxUpdateSize"));
+ gAppGraphCtxLoader.AppGraphCtxReleaseRenderTarget_ptr = (AppGraphCtxReleaseRenderTarget_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxReleaseRenderTarget"));
+ gAppGraphCtxLoader.AppGraphCtxRelease_ptr = (AppGraphCtxRelease_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxRelease"));
+ gAppGraphCtxLoader.AppGraphCtxFrameStart_ptr = (AppGraphCtxFrameStart_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxFrameStart"));
+ gAppGraphCtxLoader.AppGraphCtxFramePresent_ptr = (AppGraphCtxFramePresent_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxFramePresent"));
+ gAppGraphCtxLoader.AppGraphCtxWaitForFrames_ptr = (AppGraphCtxWaitForFrames_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxWaitForFrames"));
+ gAppGraphCtxLoader.AppGraphCtxProfileEnable_ptr = (AppGraphCtxProfileEnable_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxProfileEnable"));
+ gAppGraphCtxLoader.AppGraphCtxProfileBegin_ptr = (AppGraphCtxProfileBegin_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxProfileBegin"));
+ gAppGraphCtxLoader.AppGraphCtxProfileEnd_ptr = (AppGraphCtxProfileEnd_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxProfileEnd"));
+ gAppGraphCtxLoader.AppGraphCtxProfileGet_ptr = (AppGraphCtxProfileGet_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxProfileGet"));
+ gAppGraphCtxLoader.AppGraphCtxDedicatedVideoMemory_ptr = (AppGraphCtxDedicatedVideoMemory_ptr_t)(appGraphCtxLoaderLoadFunction(&gAppGraphCtxLoader, "AppGraphCtxDedicatedVideoMemory"));
+}
+
+void unloadAppGraphCtx()
+{
+ gAppGraphCtxLoader.AppGraphCtxCreate_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxUpdateSize_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxReleaseRenderTarget_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxRelease_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxFrameStart_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxFramePresent_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxWaitForFrames_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxProfileEnable_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxProfileBegin_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxProfileEnd_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxProfileGet_ptr = nullptr;
+ gAppGraphCtxLoader.AppGraphCtxDedicatedVideoMemory_ptr = nullptr;
+
+ SDL_UnloadObject(gAppGraphCtxLoader.module);
+}
diff --git a/demo/DemoApp/computeContextLoader.cpp b/demo/DemoApp/computeContextLoader.cpp
index 593b2ce..396f8b5 100644
--- a/demo/DemoApp/computeContextLoader.cpp
+++ b/demo/DemoApp/computeContextLoader.cpp
@@ -14,134 +14,6 @@
#include "computeContext.h"
-namespace
-{
- ModuleLoader<32u, SDL_LoadObject, SDL_UnloadObject, SDL_LoadFunction> g_loader;
-}
+#include <stdio.h>
-void loadComputeContext(AppGraphCtxType type)
-{
- const char* moduleName = demoAppDLLName(type);
-
- g_loader.loadModule(moduleName);
-}
-
-void unloadComputeContext()
-{
- g_loader.unloadModule();
-}
-
-ComputeContext* ComputeContextCreate(ComputeContextDesc* desc)
-{
- return g_loader.function<0>(ComputeContextCreate, "ComputeContextCreate", desc);
-}
-
-void ComputeContextUpdate(ComputeContext* context, ComputeContextDesc* desc)
-{
- return g_loader.function<1>(ComputeContextUpdate, "ComputeContextUpdate", context, desc);
-}
-
-void ComputeContextRelease(ComputeContext* context)
-{
- return g_loader.function<2>(ComputeContextRelease, "ComputeContextRelease", context);
-}
-
-ComputeShader* ComputeShaderCreate(ComputeContext* context, const ComputeShaderDesc* desc)
-{
- return g_loader.function<3>(ComputeShaderCreate, "ComputeShaderCreate", context, desc);
-}
-
-void ComputeShaderRelease(ComputeShader* shader)
-{
- return g_loader.function<4>(ComputeShaderRelease, "ComputeShaderRelease", shader);
-}
-
-ComputeConstantBuffer* ComputeConstantBufferCreate(ComputeContext* context, const ComputeConstantBufferDesc* desc)
-{
- return g_loader.function<5>(ComputeConstantBufferCreate, "ComputeConstantBufferCreate", context, desc);
-}
-
-void ComputeConstantBufferRelease(ComputeConstantBuffer* constantBuffer)
-{
- return g_loader.function<6>(ComputeConstantBufferRelease, "ComputeConstantBufferRelease", constantBuffer);
-}
-
-void* ComputeConstantBufferMap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
-{
- return g_loader.function<7>(ComputeConstantBufferMap, "ComputeConstantBufferMap", context, constantBuffer);
-}
-
-void ComputeConstantBufferUnmap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
-{
- return g_loader.function<8>(ComputeConstantBufferUnmap, "ComputeConstantBufferUnmap", context, constantBuffer);
-}
-
-ComputeResource* ComputeResourceCreate(ComputeContext* context, const ComputeResourceDesc* desc)
-{
- return g_loader.function<9>(ComputeResourceCreate, "ComputeResourceCreate", context, desc);
-}
-
-void ComputeResourceUpdate(ComputeContext* context, ComputeResource* resource, const ComputeResourceDesc* desc)
-{
- return g_loader.function<10>(ComputeResourceUpdate, "ComputeResourceUpdate", context, resource, desc);
-}
-
-void ComputeResourceRelease(ComputeResource* resource)
-{
- return g_loader.function<11>(ComputeResourceRelease, "ComputeResourceRelease", resource);
-}
-
-ComputeResourceRW* ComputeResourceRWCreate(ComputeContext* context, const ComputeResourceRWDesc* desc)
-{
- return g_loader.function<12>(ComputeResourceRWCreate, "ComputeResourceRWCreate", context, desc);
-}
-
-void ComputeResourceRWUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, const ComputeResourceRWDesc* desc)
-{
- return g_loader.function<13>(ComputeResourceRWUpdate, "ComputeResourceRWUpdate", context, resourceRW, desc);
-}
-
-void ComputeResourceRWRelease(ComputeResourceRW* resourceRW)
-{
- return g_loader.function<14>(ComputeResourceRWRelease, "ComputeResourceRWRelease", resourceRW);
-}
-
-void ComputeContextDispatch(ComputeContext* context, const ComputeDispatchParams* params)
-{
- return g_loader.function<15>(ComputeContextDispatch, "ComputeContextDispatch", context, params);
-}
-
-ComputeContext* ComputeContextNvFlowContextCreate(NvFlowContext* flowContext)
-{
- return g_loader.function<16>(ComputeContextNvFlowContextCreate, "ComputeContextNvFlowContextCreate", flowContext);
-}
-
-void ComputeContextNvFlowContextUpdate(ComputeContext* computeContext, NvFlowContext* flowContext)
-{
- return g_loader.function<17>(ComputeContextNvFlowContextUpdate, "ComputeContextNvFlowContextUpdate", computeContext, flowContext);
-}
-
-ComputeResource* ComputeResourceNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResource* flowResource)
-{
- return g_loader.function<18>(ComputeResourceNvFlowCreate, "ComputeResourceNvFlowCreate", context, flowContext, flowResource);
-}
-
-void ComputeResourceNvFlowUpdate(ComputeContext* context, ComputeResource* resource, NvFlowContext* flowContext, NvFlowResource* flowResource)
-{
- return g_loader.function<19>(ComputeResourceNvFlowUpdate, "ComputeResourceNvFlowUpdate", context, resource, flowContext, flowResource);
-}
-
-ComputeResourceRW* ComputeResourceRWNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
-{
- return g_loader.function<20>(ComputeResourceRWNvFlowCreate, "ComputeResourceRWNvFlowCreate", context, flowContext, flowResourceRW);
-}
-
-void ComputeResourceRWNvFlowUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
-{
- return g_loader.function<21>(ComputeResourceRWNvFlowUpdate, "ComputeResourceRWNvFlowUpdate", context, resourceRW, flowContext, flowResourceRW);
-}
-
-ComputeResource* ComputeResourceRWGetResource(ComputeResourceRW* resourceRW)
-{
- return g_loader.function<22>(ComputeResourceRWGetResource, "ComputeResourceRWGetResource", resourceRW);
-} \ No newline at end of file
+#include "computeContextLoaderGenerated.h" \ No newline at end of file
diff --git a/demo/DemoApp/computeContextLoaderGenerated.h b/demo/DemoApp/computeContextLoaderGenerated.h
new file mode 100644
index 0000000..b15775e
--- /dev/null
+++ b/demo/DemoApp/computeContextLoaderGenerated.h
@@ -0,0 +1,249 @@
+/*
+* 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.
+*/
+
+typedef ComputeContext* (*ComputeContextCreate_ptr_t)(ComputeContextDesc* desc);
+typedef void (*ComputeContextUpdate_ptr_t)(ComputeContext* context, ComputeContextDesc* desc);
+typedef void (*ComputeContextRelease_ptr_t)(ComputeContext* context);
+typedef ComputeShader* (*ComputeShaderCreate_ptr_t)(ComputeContext* context, const ComputeShaderDesc* desc);
+typedef void (*ComputeShaderRelease_ptr_t)(ComputeShader* shader);
+typedef ComputeConstantBuffer* (*ComputeConstantBufferCreate_ptr_t)(ComputeContext* context, const ComputeConstantBufferDesc* desc);
+typedef void (*ComputeConstantBufferRelease_ptr_t)(ComputeConstantBuffer* constantBuffer);
+typedef void* (*ComputeConstantBufferMap_ptr_t)(ComputeContext* context, ComputeConstantBuffer* constantBuffer);
+typedef void (*ComputeConstantBufferUnmap_ptr_t)(ComputeContext* context, ComputeConstantBuffer* constantBuffer);
+typedef ComputeResource* (*ComputeResourceCreate_ptr_t)(ComputeContext* context, const ComputeResourceDesc* desc);
+typedef void (*ComputeResourceUpdate_ptr_t)(ComputeContext* context, ComputeResource* resource, const ComputeResourceDesc* desc);
+typedef void (*ComputeResourceRelease_ptr_t)(ComputeResource* resource);
+typedef ComputeResourceRW* (*ComputeResourceRWCreate_ptr_t)(ComputeContext* context, const ComputeResourceRWDesc* desc);
+typedef void (*ComputeResourceRWUpdate_ptr_t)(ComputeContext* context, ComputeResourceRW* resourceRW, const ComputeResourceRWDesc* desc);
+typedef void (*ComputeResourceRWRelease_ptr_t)(ComputeResourceRW* resourceRW);
+typedef ComputeResource* (*ComputeResourceRWGetResource_ptr_t)(ComputeResourceRW* resourceRW);
+typedef void (*ComputeContextDispatch_ptr_t)(ComputeContext* context, const ComputeDispatchParams* params);
+typedef ComputeContext* (*ComputeContextNvFlowContextCreate_ptr_t)(NvFlowContext* flowContext);
+typedef void (*ComputeContextNvFlowContextUpdate_ptr_t)(ComputeContext* computeContext, NvFlowContext* flowContext);
+typedef ComputeResource* (*ComputeResourceNvFlowCreate_ptr_t)(ComputeContext* context, NvFlowContext* flowContext, NvFlowResource* flowResource);
+typedef void (*ComputeResourceNvFlowUpdate_ptr_t)(ComputeContext* context, ComputeResource* resource, NvFlowContext* flowContext, NvFlowResource* flowResource);
+typedef ComputeResourceRW* (*ComputeResourceRWNvFlowCreate_ptr_t)(ComputeContext* context, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW);
+typedef void (*ComputeResourceRWNvFlowUpdate_ptr_t)(ComputeContext* context, ComputeResourceRW* resourceRW, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW);
+
+struct ComputeContextLoader
+{
+ void* module = nullptr;
+ const char* suffix = "";
+ char buf[1024u];
+
+ ComputeContextCreate_ptr_t ComputeContextCreate_ptr;
+ ComputeContextUpdate_ptr_t ComputeContextUpdate_ptr;
+ ComputeContextRelease_ptr_t ComputeContextRelease_ptr;
+ ComputeShaderCreate_ptr_t ComputeShaderCreate_ptr;
+ ComputeShaderRelease_ptr_t ComputeShaderRelease_ptr;
+ ComputeConstantBufferCreate_ptr_t ComputeConstantBufferCreate_ptr;
+ ComputeConstantBufferRelease_ptr_t ComputeConstantBufferRelease_ptr;
+ ComputeConstantBufferMap_ptr_t ComputeConstantBufferMap_ptr;
+ ComputeConstantBufferUnmap_ptr_t ComputeConstantBufferUnmap_ptr;
+ ComputeResourceCreate_ptr_t ComputeResourceCreate_ptr;
+ ComputeResourceUpdate_ptr_t ComputeResourceUpdate_ptr;
+ ComputeResourceRelease_ptr_t ComputeResourceRelease_ptr;
+ ComputeResourceRWCreate_ptr_t ComputeResourceRWCreate_ptr;
+ ComputeResourceRWUpdate_ptr_t ComputeResourceRWUpdate_ptr;
+ ComputeResourceRWRelease_ptr_t ComputeResourceRWRelease_ptr;
+ ComputeResourceRWGetResource_ptr_t ComputeResourceRWGetResource_ptr;
+ ComputeContextDispatch_ptr_t ComputeContextDispatch_ptr;
+ ComputeContextNvFlowContextCreate_ptr_t ComputeContextNvFlowContextCreate_ptr;
+ ComputeContextNvFlowContextUpdate_ptr_t ComputeContextNvFlowContextUpdate_ptr;
+ ComputeResourceNvFlowCreate_ptr_t ComputeResourceNvFlowCreate_ptr;
+ ComputeResourceNvFlowUpdate_ptr_t ComputeResourceNvFlowUpdate_ptr;
+ ComputeResourceRWNvFlowCreate_ptr_t ComputeResourceRWNvFlowCreate_ptr;
+ ComputeResourceRWNvFlowUpdate_ptr_t ComputeResourceRWNvFlowUpdate_ptr;
+
+}gComputeContextLoader;
+
+ComputeContext* ComputeContextCreate(ComputeContextDesc* desc)
+{
+ return gComputeContextLoader.ComputeContextCreate_ptr(desc);
+}
+
+void ComputeContextUpdate(ComputeContext* context, ComputeContextDesc* desc)
+{
+ return gComputeContextLoader.ComputeContextUpdate_ptr(context, desc);
+}
+
+void ComputeContextRelease(ComputeContext* context)
+{
+ return gComputeContextLoader.ComputeContextRelease_ptr(context);
+}
+
+ComputeShader* ComputeShaderCreate(ComputeContext* context, const ComputeShaderDesc* desc)
+{
+ return gComputeContextLoader.ComputeShaderCreate_ptr(context, desc);
+}
+
+void ComputeShaderRelease(ComputeShader* shader)
+{
+ return gComputeContextLoader.ComputeShaderRelease_ptr(shader);
+}
+
+ComputeConstantBuffer* ComputeConstantBufferCreate(ComputeContext* context, const ComputeConstantBufferDesc* desc)
+{
+ return gComputeContextLoader.ComputeConstantBufferCreate_ptr(context, desc);
+}
+
+void ComputeConstantBufferRelease(ComputeConstantBuffer* constantBuffer)
+{
+ return gComputeContextLoader.ComputeConstantBufferRelease_ptr(constantBuffer);
+}
+
+void* ComputeConstantBufferMap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
+{
+ return gComputeContextLoader.ComputeConstantBufferMap_ptr(context, constantBuffer);
+}
+
+void ComputeConstantBufferUnmap(ComputeContext* context, ComputeConstantBuffer* constantBuffer)
+{
+ return gComputeContextLoader.ComputeConstantBufferUnmap_ptr(context, constantBuffer);
+}
+
+ComputeResource* ComputeResourceCreate(ComputeContext* context, const ComputeResourceDesc* desc)
+{
+ return gComputeContextLoader.ComputeResourceCreate_ptr(context, desc);
+}
+
+void ComputeResourceUpdate(ComputeContext* context, ComputeResource* resource, const ComputeResourceDesc* desc)
+{
+ return gComputeContextLoader.ComputeResourceUpdate_ptr(context, resource, desc);
+}
+
+void ComputeResourceRelease(ComputeResource* resource)
+{
+ return gComputeContextLoader.ComputeResourceRelease_ptr(resource);
+}
+
+ComputeResourceRW* ComputeResourceRWCreate(ComputeContext* context, const ComputeResourceRWDesc* desc)
+{
+ return gComputeContextLoader.ComputeResourceRWCreate_ptr(context, desc);
+}
+
+void ComputeResourceRWUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, const ComputeResourceRWDesc* desc)
+{
+ return gComputeContextLoader.ComputeResourceRWUpdate_ptr(context, resourceRW, desc);
+}
+
+void ComputeResourceRWRelease(ComputeResourceRW* resourceRW)
+{
+ return gComputeContextLoader.ComputeResourceRWRelease_ptr(resourceRW);
+}
+
+ComputeResource* ComputeResourceRWGetResource(ComputeResourceRW* resourceRW)
+{
+ return gComputeContextLoader.ComputeResourceRWGetResource_ptr(resourceRW);
+}
+
+void ComputeContextDispatch(ComputeContext* context, const ComputeDispatchParams* params)
+{
+ return gComputeContextLoader.ComputeContextDispatch_ptr(context, params);
+}
+
+ComputeContext* ComputeContextNvFlowContextCreate(NvFlowContext* flowContext)
+{
+ return gComputeContextLoader.ComputeContextNvFlowContextCreate_ptr(flowContext);
+}
+
+void ComputeContextNvFlowContextUpdate(ComputeContext* computeContext, NvFlowContext* flowContext)
+{
+ return gComputeContextLoader.ComputeContextNvFlowContextUpdate_ptr(computeContext, flowContext);
+}
+
+ComputeResource* ComputeResourceNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResource* flowResource)
+{
+ return gComputeContextLoader.ComputeResourceNvFlowCreate_ptr(context, flowContext, flowResource);
+}
+
+void ComputeResourceNvFlowUpdate(ComputeContext* context, ComputeResource* resource, NvFlowContext* flowContext, NvFlowResource* flowResource)
+{
+ return gComputeContextLoader.ComputeResourceNvFlowUpdate_ptr(context, resource, flowContext, flowResource);
+}
+
+ComputeResourceRW* ComputeResourceRWNvFlowCreate(ComputeContext* context, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
+{
+ return gComputeContextLoader.ComputeResourceRWNvFlowCreate_ptr(context, flowContext, flowResourceRW);
+}
+
+void ComputeResourceRWNvFlowUpdate(ComputeContext* context, ComputeResourceRW* resourceRW, NvFlowContext* flowContext, NvFlowResourceRW* flowResourceRW)
+{
+ return gComputeContextLoader.ComputeResourceRWNvFlowUpdate_ptr(context, resourceRW, flowContext, flowResourceRW);
+}
+
+void* computeContextLoaderLoadFunction(ComputeContextLoader* inst, const char* name)
+{
+ snprintf(inst->buf, 1024u, "%s%s", name, inst->suffix);
+
+ return SDL_LoadFunction(inst->module, inst->buf);
+}
+
+void loadComputeContext(AppGraphCtxType type)
+{
+ const char* moduleName = demoAppDLLName(type);
+
+ gComputeContextLoader.suffix = demoAppBackendSuffix(type);
+
+ gComputeContextLoader.module = SDL_LoadObject(moduleName);
+
+ gComputeContextLoader.ComputeContextCreate_ptr = (ComputeContextCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextCreate"));
+ gComputeContextLoader.ComputeContextUpdate_ptr = (ComputeContextUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextUpdate"));
+ gComputeContextLoader.ComputeContextRelease_ptr = (ComputeContextRelease_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextRelease"));
+ gComputeContextLoader.ComputeShaderCreate_ptr = (ComputeShaderCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeShaderCreate"));
+ gComputeContextLoader.ComputeShaderRelease_ptr = (ComputeShaderRelease_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeShaderRelease"));
+ gComputeContextLoader.ComputeConstantBufferCreate_ptr = (ComputeConstantBufferCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeConstantBufferCreate"));
+ gComputeContextLoader.ComputeConstantBufferRelease_ptr = (ComputeConstantBufferRelease_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeConstantBufferRelease"));
+ gComputeContextLoader.ComputeConstantBufferMap_ptr = (ComputeConstantBufferMap_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeConstantBufferMap"));
+ gComputeContextLoader.ComputeConstantBufferUnmap_ptr = (ComputeConstantBufferUnmap_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeConstantBufferUnmap"));
+ gComputeContextLoader.ComputeResourceCreate_ptr = (ComputeResourceCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceCreate"));
+ gComputeContextLoader.ComputeResourceUpdate_ptr = (ComputeResourceUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceUpdate"));
+ gComputeContextLoader.ComputeResourceRelease_ptr = (ComputeResourceRelease_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRelease"));
+ gComputeContextLoader.ComputeResourceRWCreate_ptr = (ComputeResourceRWCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWCreate"));
+ gComputeContextLoader.ComputeResourceRWUpdate_ptr = (ComputeResourceRWUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWUpdate"));
+ gComputeContextLoader.ComputeResourceRWRelease_ptr = (ComputeResourceRWRelease_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWRelease"));
+ gComputeContextLoader.ComputeResourceRWGetResource_ptr = (ComputeResourceRWGetResource_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWGetResource"));
+ gComputeContextLoader.ComputeContextDispatch_ptr = (ComputeContextDispatch_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextDispatch"));
+ gComputeContextLoader.ComputeContextNvFlowContextCreate_ptr = (ComputeContextNvFlowContextCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextNvFlowContextCreate"));
+ gComputeContextLoader.ComputeContextNvFlowContextUpdate_ptr = (ComputeContextNvFlowContextUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeContextNvFlowContextUpdate"));
+ gComputeContextLoader.ComputeResourceNvFlowCreate_ptr = (ComputeResourceNvFlowCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceNvFlowCreate"));
+ gComputeContextLoader.ComputeResourceNvFlowUpdate_ptr = (ComputeResourceNvFlowUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceNvFlowUpdate"));
+ gComputeContextLoader.ComputeResourceRWNvFlowCreate_ptr = (ComputeResourceRWNvFlowCreate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWNvFlowCreate"));
+ gComputeContextLoader.ComputeResourceRWNvFlowUpdate_ptr = (ComputeResourceRWNvFlowUpdate_ptr_t)(computeContextLoaderLoadFunction(&gComputeContextLoader, "ComputeResourceRWNvFlowUpdate"));
+}
+
+void unloadComputeContext()
+{
+ gComputeContextLoader.ComputeContextCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeContextUpdate_ptr = nullptr;
+ gComputeContextLoader.ComputeContextRelease_ptr = nullptr;
+ gComputeContextLoader.ComputeShaderCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeShaderRelease_ptr = nullptr;
+ gComputeContextLoader.ComputeConstantBufferCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeConstantBufferRelease_ptr = nullptr;
+ gComputeContextLoader.ComputeConstantBufferMap_ptr = nullptr;
+ gComputeContextLoader.ComputeConstantBufferUnmap_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceUpdate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRelease_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWUpdate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWRelease_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWGetResource_ptr = nullptr;
+ gComputeContextLoader.ComputeContextDispatch_ptr = nullptr;
+ gComputeContextLoader.ComputeContextNvFlowContextCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeContextNvFlowContextUpdate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceNvFlowCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceNvFlowUpdate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWNvFlowCreate_ptr = nullptr;
+ gComputeContextLoader.ComputeResourceRWNvFlowUpdate_ptr = nullptr;
+
+ SDL_UnloadObject(gComputeContextLoader.module);
+}
diff --git a/demo/DemoApp/imguiGraphLoader.cpp b/demo/DemoApp/imguiGraphLoader.cpp
index 155e9f3..f628196 100644
--- a/demo/DemoApp/imguiGraphLoader.cpp
+++ b/demo/DemoApp/imguiGraphLoader.cpp
@@ -15,111 +15,6 @@
#include "imguiGraph.h"
#include "imguiInterop.h"
-namespace
-{
- ModuleLoader<24u, SDL_LoadObject, SDL_UnloadObject, SDL_LoadFunction> g_loader;
-}
+#include <stdio.h>
-void loadImgui(AppGraphCtxType type)
-{
- const char* moduleName = demoAppDLLName(type);
-
- g_loader.loadModule(moduleName);
-}
-
-void unloadImgui()
-{
- g_loader.unloadModule();
-}
-
-// Below are the functions that must be implemented per graphics API
-
-void imguiGraphContextInit(const ImguiGraphDesc* desc)
-{
- return g_loader.function<0>(imguiGraphContextInit, "imguiGraphContextInit", desc);
-}
-
-void imguiGraphContextUpdate(const ImguiGraphDesc* desc)
-{
- return g_loader.function<1>(imguiGraphContextUpdate, "imguiGraphContextUpdate", desc);
-}
-
-void imguiGraphContextDestroy()
-{
- return g_loader.function<2>(imguiGraphContextDestroy, "imguiGraphContextDestroy");
-}
-
-void imguiGraphRecordBegin()
-{
- return g_loader.function<3>(imguiGraphRecordBegin, "imguiGraphRecordBegin");
-}
-
-void imguiGraphRecordEnd()
-{
- return g_loader.function<4>(imguiGraphRecordEnd, "imguiGraphRecordEnd");
-}
-
-void imguiGraphVertex2f(float x, float y)
-{
- return g_loader.function<5>(imguiGraphVertex2f, "imguiGraphVertex2f", x, y);
-}
-
-void imguiGraphVertex2fv(const float* v)
-{
- return g_loader.function<6>(imguiGraphVertex2fv, "imguiGraphVertex2fv", v);
-}
-
-void imguiGraphTexCoord2f(float u, float v)
-{
- return g_loader.function<7>(imguiGraphTexCoord2f, "imguiGraphTexCoord2f", u, v);
-}
-
-void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
-{
- return g_loader.function<8>(imguiGraphColor4ub, "imguiGraphColor4ub", red, green, blue, alpha);
-}
-
-void imguiGraphColor4ubv(const uint8_t* v)
-{
- return g_loader.function<9>(imguiGraphColor4ubv, "imguiGraphColor4ubv", v);
-}
-
-void imguiGraphFontTextureEnable()
-{
- return g_loader.function<10>(imguiGraphFontTextureEnable, "imguiGraphFontTextureEnable");
-}
-
-void imguiGraphFontTextureDisable()
-{
- return g_loader.function<11>(imguiGraphFontTextureDisable, "imguiGraphFontTextureDisable");
-}
-
-void imguiGraphEnableScissor(int x, int y, int width, int height)
-{
- return g_loader.function<12>(imguiGraphEnableScissor, "imguiGraphEnableScissor", x, y, width, height);
-}
-
-void imguiGraphDisableScissor()
-{
- return g_loader.function<13>(imguiGraphDisableScissor, "imguiGraphDisableScissor");
-}
-
-void imguiGraphFontTextureInit(unsigned char* data)
-{
- return g_loader.function<14>(imguiGraphFontTextureInit, "imguiGraphFontTextureInit",data);
-}
-
-void imguiGraphFontTextureRelease()
-{
- return g_loader.function<15>(imguiGraphFontTextureRelease, "imguiGraphFontTextureRelease");
-}
-
-bool imguiInteropGraphInit(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx)
-{
- return g_loader.function<16>(imguiInteropGraphInit, "imguiInteropGraphInit", func, fontpath, appctx);
-}
-
-void imguiInteropGraphUpdate(imguiGraphUpdate_t func, AppGraphCtx* appctx)
-{
- return g_loader.function<17>(imguiInteropGraphUpdate, "imguiInteropGraphUpdate", func, appctx);
-} \ No newline at end of file
+#include "imguiGraphLoaderGenerated.h" \ No newline at end of file
diff --git a/demo/DemoApp/imguiGraphLoaderGenerated.h b/demo/DemoApp/imguiGraphLoaderGenerated.h
new file mode 100644
index 0000000..ab7ae55
--- /dev/null
+++ b/demo/DemoApp/imguiGraphLoaderGenerated.h
@@ -0,0 +1,204 @@
+/*
+* 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.
+*/
+
+typedef void (*imguiGraphContextInit_ptr_t)(const ImguiGraphDesc* desc);
+typedef void (*imguiGraphContextUpdate_ptr_t)(const ImguiGraphDesc* desc);
+typedef void (*imguiGraphContextDestroy_ptr_t)();
+typedef void (*imguiGraphRecordBegin_ptr_t)();
+typedef void (*imguiGraphRecordEnd_ptr_t)();
+typedef void (*imguiGraphVertex2f_ptr_t)(float x, float y);
+typedef void (*imguiGraphVertex2fv_ptr_t)(const float* v);
+typedef void (*imguiGraphTexCoord2f_ptr_t)(float u, float v);
+typedef void (*imguiGraphColor4ub_ptr_t)(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
+typedef void (*imguiGraphColor4ubv_ptr_t)(const uint8_t* v);
+typedef void (*imguiGraphFontTextureEnable_ptr_t)();
+typedef void (*imguiGraphFontTextureDisable_ptr_t)();
+typedef void (*imguiGraphEnableScissor_ptr_t)(int x, int y, int width, int height);
+typedef void (*imguiGraphDisableScissor_ptr_t)();
+typedef void (*imguiGraphFontTextureInit_ptr_t)(unsigned char* data);
+typedef void (*imguiGraphFontTextureRelease_ptr_t)();
+typedef bool (*imguiInteropGraphInit_ptr_t)(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx);
+typedef void (*imguiInteropGraphUpdate_ptr_t)(imguiGraphUpdate_t func, AppGraphCtx* appctx);
+
+struct ImguiLoader
+{
+ void* module = nullptr;
+ const char* suffix = "";
+ char buf[1024u];
+
+ imguiGraphContextInit_ptr_t imguiGraphContextInit_ptr;
+ imguiGraphContextUpdate_ptr_t imguiGraphContextUpdate_ptr;
+ imguiGraphContextDestroy_ptr_t imguiGraphContextDestroy_ptr;
+ imguiGraphRecordBegin_ptr_t imguiGraphRecordBegin_ptr;
+ imguiGraphRecordEnd_ptr_t imguiGraphRecordEnd_ptr;
+ imguiGraphVertex2f_ptr_t imguiGraphVertex2f_ptr;
+ imguiGraphVertex2fv_ptr_t imguiGraphVertex2fv_ptr;
+ imguiGraphTexCoord2f_ptr_t imguiGraphTexCoord2f_ptr;
+ imguiGraphColor4ub_ptr_t imguiGraphColor4ub_ptr;
+ imguiGraphColor4ubv_ptr_t imguiGraphColor4ubv_ptr;
+ imguiGraphFontTextureEnable_ptr_t imguiGraphFontTextureEnable_ptr;
+ imguiGraphFontTextureDisable_ptr_t imguiGraphFontTextureDisable_ptr;
+ imguiGraphEnableScissor_ptr_t imguiGraphEnableScissor_ptr;
+ imguiGraphDisableScissor_ptr_t imguiGraphDisableScissor_ptr;
+ imguiGraphFontTextureInit_ptr_t imguiGraphFontTextureInit_ptr;
+ imguiGraphFontTextureRelease_ptr_t imguiGraphFontTextureRelease_ptr;
+ imguiInteropGraphInit_ptr_t imguiInteropGraphInit_ptr;
+ imguiInteropGraphUpdate_ptr_t imguiInteropGraphUpdate_ptr;
+
+}gImguiLoader;
+
+void imguiGraphContextInit(const ImguiGraphDesc* desc)
+{
+ return gImguiLoader.imguiGraphContextInit_ptr(desc);
+}
+
+void imguiGraphContextUpdate(const ImguiGraphDesc* desc)
+{
+ return gImguiLoader.imguiGraphContextUpdate_ptr(desc);
+}
+
+void imguiGraphContextDestroy()
+{
+ return gImguiLoader.imguiGraphContextDestroy_ptr();
+}
+
+void imguiGraphRecordBegin()
+{
+ return gImguiLoader.imguiGraphRecordBegin_ptr();
+}
+
+void imguiGraphRecordEnd()
+{
+ return gImguiLoader.imguiGraphRecordEnd_ptr();
+}
+
+void imguiGraphVertex2f(float x, float y)
+{
+ return gImguiLoader.imguiGraphVertex2f_ptr(x, y);
+}
+
+void imguiGraphVertex2fv(const float* v)
+{
+ return gImguiLoader.imguiGraphVertex2fv_ptr(v);
+}
+
+void imguiGraphTexCoord2f(float u, float v)
+{
+ return gImguiLoader.imguiGraphTexCoord2f_ptr(u, v);
+}
+
+void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
+{
+ return gImguiLoader.imguiGraphColor4ub_ptr(red, green, blue, alpha);
+}
+
+void imguiGraphColor4ubv(const uint8_t* v)
+{
+ return gImguiLoader.imguiGraphColor4ubv_ptr(v);
+}
+
+void imguiGraphFontTextureEnable()
+{
+ return gImguiLoader.imguiGraphFontTextureEnable_ptr();
+}
+
+void imguiGraphFontTextureDisable()
+{
+ return gImguiLoader.imguiGraphFontTextureDisable_ptr();
+}
+
+void imguiGraphEnableScissor(int x, int y, int width, int height)
+{
+ return gImguiLoader.imguiGraphEnableScissor_ptr(x, y, width, height);
+}
+
+void imguiGraphDisableScissor()
+{
+ return gImguiLoader.imguiGraphDisableScissor_ptr();
+}
+
+void imguiGraphFontTextureInit(unsigned char* data)
+{
+ return gImguiLoader.imguiGraphFontTextureInit_ptr(data);
+}
+
+void imguiGraphFontTextureRelease()
+{
+ return gImguiLoader.imguiGraphFontTextureRelease_ptr();
+}
+
+bool imguiInteropGraphInit(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx)
+{
+ return gImguiLoader.imguiInteropGraphInit_ptr(func, fontpath, appctx);
+}
+
+void imguiInteropGraphUpdate(imguiGraphUpdate_t func, AppGraphCtx* appctx)
+{
+ return gImguiLoader.imguiInteropGraphUpdate_ptr(func, appctx);
+}
+
+void* imguiLoaderLoadFunction(ImguiLoader* inst, const char* name)
+{
+ snprintf(inst->buf, 1024u, "%s%s", name, inst->suffix);
+
+ return SDL_LoadFunction(inst->module, inst->buf);
+}
+
+void loadImgui(AppGraphCtxType type)
+{
+ const char* moduleName = demoAppDLLName(type);
+
+ gImguiLoader.suffix = demoAppBackendSuffix(type);
+
+ gImguiLoader.module = SDL_LoadObject(moduleName);
+
+ gImguiLoader.imguiGraphContextInit_ptr = (imguiGraphContextInit_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphContextInit"));
+ gImguiLoader.imguiGraphContextUpdate_ptr = (imguiGraphContextUpdate_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphContextUpdate"));
+ gImguiLoader.imguiGraphContextDestroy_ptr = (imguiGraphContextDestroy_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphContextDestroy"));
+ gImguiLoader.imguiGraphRecordBegin_ptr = (imguiGraphRecordBegin_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphRecordBegin"));
+ gImguiLoader.imguiGraphRecordEnd_ptr = (imguiGraphRecordEnd_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphRecordEnd"));
+ gImguiLoader.imguiGraphVertex2f_ptr = (imguiGraphVertex2f_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphVertex2f"));
+ gImguiLoader.imguiGraphVertex2fv_ptr = (imguiGraphVertex2fv_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphVertex2fv"));
+ gImguiLoader.imguiGraphTexCoord2f_ptr = (imguiGraphTexCoord2f_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphTexCoord2f"));
+ gImguiLoader.imguiGraphColor4ub_ptr = (imguiGraphColor4ub_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphColor4ub"));
+ gImguiLoader.imguiGraphColor4ubv_ptr = (imguiGraphColor4ubv_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphColor4ubv"));
+ gImguiLoader.imguiGraphFontTextureEnable_ptr = (imguiGraphFontTextureEnable_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphFontTextureEnable"));
+ gImguiLoader.imguiGraphFontTextureDisable_ptr = (imguiGraphFontTextureDisable_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphFontTextureDisable"));
+ gImguiLoader.imguiGraphEnableScissor_ptr = (imguiGraphEnableScissor_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphEnableScissor"));
+ gImguiLoader.imguiGraphDisableScissor_ptr = (imguiGraphDisableScissor_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphDisableScissor"));
+ gImguiLoader.imguiGraphFontTextureInit_ptr = (imguiGraphFontTextureInit_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphFontTextureInit"));
+ gImguiLoader.imguiGraphFontTextureRelease_ptr = (imguiGraphFontTextureRelease_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiGraphFontTextureRelease"));
+ gImguiLoader.imguiInteropGraphInit_ptr = (imguiInteropGraphInit_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiInteropGraphInit"));
+ gImguiLoader.imguiInteropGraphUpdate_ptr = (imguiInteropGraphUpdate_ptr_t)(imguiLoaderLoadFunction(&gImguiLoader, "imguiInteropGraphUpdate"));
+}
+
+void unloadImgui()
+{
+ gImguiLoader.imguiGraphContextInit_ptr = nullptr;
+ gImguiLoader.imguiGraphContextUpdate_ptr = nullptr;
+ gImguiLoader.imguiGraphContextDestroy_ptr = nullptr;
+ gImguiLoader.imguiGraphRecordBegin_ptr = nullptr;
+ gImguiLoader.imguiGraphRecordEnd_ptr = nullptr;
+ gImguiLoader.imguiGraphVertex2f_ptr = nullptr;
+ gImguiLoader.imguiGraphVertex2fv_ptr = nullptr;
+ gImguiLoader.imguiGraphTexCoord2f_ptr = nullptr;
+ gImguiLoader.imguiGraphColor4ub_ptr = nullptr;
+ gImguiLoader.imguiGraphColor4ubv_ptr = nullptr;
+ gImguiLoader.imguiGraphFontTextureEnable_ptr = nullptr;
+ gImguiLoader.imguiGraphFontTextureDisable_ptr = nullptr;
+ gImguiLoader.imguiGraphEnableScissor_ptr = nullptr;
+ gImguiLoader.imguiGraphDisableScissor_ptr = nullptr;
+ gImguiLoader.imguiGraphFontTextureInit_ptr = nullptr;
+ gImguiLoader.imguiGraphFontTextureRelease_ptr = nullptr;
+ gImguiLoader.imguiInteropGraphInit_ptr = nullptr;
+ gImguiLoader.imguiInteropGraphUpdate_ptr = nullptr;
+
+ SDL_UnloadObject(gImguiLoader.module);
+}
diff --git a/demo/DemoApp/loader.h b/demo/DemoApp/loader.h
index 3028325..f0c1aaf 100644
--- a/demo/DemoApp/loader.h
+++ b/demo/DemoApp/loader.h
@@ -28,6 +28,13 @@ namespace
"DemoAppD3D11" XDEMOAPP_STR(DLL_SUFFIX) ".dll";
}
+ const char* demoAppBackendSuffix(AppGraphCtxType type)
+ {
+ return (type == APP_CONTEXT_D3D12) ?
+ "D3D12" :
+ "D3D11";
+ }
+
const char* nvFlowDLLName(AppGraphCtxType type)
{
return (type == APP_CONTEXT_D3D12) ?
@@ -52,61 +59,4 @@ void loadImgui(AppGraphCtxType type);
void unloadImgui();
void loadComputeContext(AppGraphCtxType type);
-void unloadComputeContext();
-
-template<unsigned int maxFunctionCount, void* loadobject(const char*), void unloadobject(void*), void* loadfunction(void*,const char*)>
-struct ModuleLoader
-{
- static const int m_functionCount = maxFunctionCount;
- void** m_functionPtrs[m_functionCount] = { nullptr };
- const char* m_functionNames[m_functionCount] = { nullptr };
-
- void* m_module = nullptr;
-
- void* loadFunction(const char* name, int uid, void** ptr)
- {
- m_functionPtrs[uid] = ptr;
- m_functionNames[uid] = name;
- return SDL_LoadFunction(m_module, name);
- }
-
- template <int uid, class ret, class ...Args>
- ret function(ret(*)(Args...args), const char* name, Args...args)
- {
- static void* func = loadFunction(name, uid, &func);
-
- return ((ret(*)(Args...args))func)(args...);
- }
-
- void loadModule(const char* moduleName)
- {
- m_module = loadobject(moduleName);
-
- // load functions with non-null names
- for (int i = 0; i < m_functionCount; i++)
- {
- const char* name = m_functionNames[i];
- void** funcPtr = m_functionPtrs[i];
- if (name && funcPtr)
- {
- *funcPtr = loadfunction(m_module, name);
- }
- }
- }
-
- void unloadModule()
- {
- unloadobject(m_module);
-
- for (int i = 0; i < m_functionCount; i++)
- {
- void** funcPtr = m_functionPtrs[i];
- if (funcPtr)
- {
- *funcPtr = nullptr;
- }
- }
- }
-
- ModuleLoader() {}
-}; \ No newline at end of file
+void unloadComputeContext(); \ No newline at end of file
diff --git a/demo/DemoApp/main.cpp b/demo/DemoApp/main.cpp
index e35ea43..45ccfa8 100644
--- a/demo/DemoApp/main.cpp
+++ b/demo/DemoApp/main.cpp
@@ -67,24 +67,18 @@ bool gImguiActive = false;
bool g_imguiHide = false;
bool gClearDark = false;
-float gClearVal[4] = { 0.33f,0.33f,0.33f,1.f };
+AppGraphColor gClearVal = { 0.33f,0.33f,0.33f,1.f };
void toggleDark()
{
gClearDark = !gClearDark;
if (gClearDark)
{
- gClearVal[0] = 0.f;
- gClearVal[1] = 0.f;
- gClearVal[2] = 0.f;
- gClearVal[3] = 1.f;
+ gClearVal = { 0.f, 0.f, 0.f, 1.f };
}
else
{
- gClearVal[0] = 0.33f;
- gClearVal[1] = 0.33f;
- gClearVal[2] = 0.33f;
- gClearVal[3] = 1.f;
+ gClearVal = { 0.33f, 0.33f, 0.33f, 1.f };
}
}
diff --git a/demo/DemoApp/meshLoader.cpp b/demo/DemoApp/meshLoader.cpp
index 99e5e49..2d70414 100644
--- a/demo/DemoApp/meshLoader.cpp
+++ b/demo/DemoApp/meshLoader.cpp
@@ -15,69 +15,6 @@
#include "mesh.h"
#include "meshInterop.h"
-namespace
-{
- ModuleLoader<16u, SDL_LoadObject, SDL_UnloadObject, SDL_LoadFunction> g_loader;
-}
+#include <stdio.h>
-void loadMesh(AppGraphCtxType type)
-{
- const char* moduleName = demoAppDLLName(type);
-
- g_loader.loadModule(moduleName);
-}
-
-void unloadMesh()
-{
- g_loader.unloadModule();
-}
-
-MeshContext* MeshContextCreate(const MeshContextDesc* desc)
-{
- return g_loader.function<0>(MeshContextCreate, "MeshContextCreate", desc);
-}
-
-void MeshContextUpdate(MeshContext* context, const MeshContextDesc* desc)
-{
- return g_loader.function<1>(MeshContextUpdate, "MeshContextUpdate", context, desc);
-}
-
-void MeshContextRelease(MeshContext* context)
-{
- return g_loader.function<2>(MeshContextRelease, "MeshContextRelease", context);
-}
-
-MeshIndexBuffer* MeshIndexBufferCreate(MeshContext* context, MeshUint* indices, MeshUint numIndices)
-{
- return g_loader.function<3>(MeshIndexBufferCreate, "MeshIndexBufferCreate", context, indices, numIndices);
-}
-
-void MeshIndexBufferRelease(MeshIndexBuffer* buffer)
-{
- return g_loader.function<4>(MeshIndexBufferRelease, "MeshIndexBufferRelease", buffer);
-}
-
-MeshVertexBuffer* MeshVertexBufferCreate(MeshContext* context, MeshVertex* vertices, MeshUint numVertices)
-{
- return g_loader.function<5>(MeshVertexBufferCreate, "MeshVertexBufferCreate", context, vertices, numVertices);
-}
-
-void MeshVertexBufferRelease(MeshVertexBuffer* buffer)
-{
- return g_loader.function<6>(MeshVertexBufferRelease, "MeshVertexBufferRelease", buffer);
-}
-
-void MeshContextDraw(MeshContext* context, const MeshContextDrawParams* params)
-{
- return g_loader.function<7>(MeshContextDraw, "MeshContextDraw", context, params);
-}
-
-MeshContext* MeshInteropContextCreate(AppGraphCtx* appctx)
-{
- return g_loader.function<8>(MeshInteropContextCreate, "MeshInteropContextCreate", appctx);
-}
-
-void MeshInteropContextUpdate(MeshContext* context, AppGraphCtx* appctx)
-{
- return g_loader.function<9>(MeshInteropContextUpdate, "MeshInteropContextUpdate", context, appctx);
-} \ No newline at end of file
+#include "meshLoaderGenerated.h" \ No newline at end of file
diff --git a/demo/DemoApp/meshLoaderGenerated.h b/demo/DemoApp/meshLoaderGenerated.h
new file mode 100644
index 0000000..c931f4f
--- /dev/null
+++ b/demo/DemoApp/meshLoaderGenerated.h
@@ -0,0 +1,132 @@
+/*
+* 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.
+*/
+
+typedef MeshContext* (*MeshContextCreate_ptr_t)(const MeshContextDesc* desc);
+typedef void (*MeshContextUpdate_ptr_t)(MeshContext* context, const MeshContextDesc* desc);
+typedef void (*MeshContextRelease_ptr_t)(MeshContext* context);
+typedef MeshIndexBuffer* (*MeshIndexBufferCreate_ptr_t)(MeshContext* context, MeshUint* indices, MeshUint numIndices);
+typedef void (*MeshIndexBufferRelease_ptr_t)(MeshIndexBuffer* buffer);
+typedef MeshVertexBuffer* (*MeshVertexBufferCreate_ptr_t)(MeshContext* context, MeshVertex* vertices, MeshUint numVertices);
+typedef void (*MeshVertexBufferRelease_ptr_t)(MeshVertexBuffer* buffer);
+typedef void (*MeshContextDraw_ptr_t)(MeshContext* context, const MeshContextDrawParams* params);
+typedef MeshContext* (*MeshInteropContextCreate_ptr_t)(AppGraphCtx* appctx);
+typedef void (*MeshInteropContextUpdate_ptr_t)(MeshContext* context, AppGraphCtx* appctx);
+
+struct MeshLoader
+{
+ void* module = nullptr;
+ const char* suffix = "";
+ char buf[1024u];
+
+ MeshContextCreate_ptr_t MeshContextCreate_ptr;
+ MeshContextUpdate_ptr_t MeshContextUpdate_ptr;
+ MeshContextRelease_ptr_t MeshContextRelease_ptr;
+ MeshIndexBufferCreate_ptr_t MeshIndexBufferCreate_ptr;
+ MeshIndexBufferRelease_ptr_t MeshIndexBufferRelease_ptr;
+ MeshVertexBufferCreate_ptr_t MeshVertexBufferCreate_ptr;
+ MeshVertexBufferRelease_ptr_t MeshVertexBufferRelease_ptr;
+ MeshContextDraw_ptr_t MeshContextDraw_ptr;
+ MeshInteropContextCreate_ptr_t MeshInteropContextCreate_ptr;
+ MeshInteropContextUpdate_ptr_t MeshInteropContextUpdate_ptr;
+
+}gMeshLoader;
+
+MeshContext* MeshContextCreate(const MeshContextDesc* desc)
+{
+ return gMeshLoader.MeshContextCreate_ptr(desc);
+}
+
+void MeshContextUpdate(MeshContext* context, const MeshContextDesc* desc)
+{
+ return gMeshLoader.MeshContextUpdate_ptr(context, desc);
+}
+
+void MeshContextRelease(MeshContext* context)
+{
+ return gMeshLoader.MeshContextRelease_ptr(context);
+}
+
+MeshIndexBuffer* MeshIndexBufferCreate(MeshContext* context, MeshUint* indices, MeshUint numIndices)
+{
+ return gMeshLoader.MeshIndexBufferCreate_ptr(context, indices, numIndices);
+}
+
+void MeshIndexBufferRelease(MeshIndexBuffer* buffer)
+{
+ return gMeshLoader.MeshIndexBufferRelease_ptr(buffer);
+}
+
+MeshVertexBuffer* MeshVertexBufferCreate(MeshContext* context, MeshVertex* vertices, MeshUint numVertices)
+{
+ return gMeshLoader.MeshVertexBufferCreate_ptr(context, vertices, numVertices);
+}
+
+void MeshVertexBufferRelease(MeshVertexBuffer* buffer)
+{
+ return gMeshLoader.MeshVertexBufferRelease_ptr(buffer);
+}
+
+void MeshContextDraw(MeshContext* context, const MeshContextDrawParams* params)
+{
+ return gMeshLoader.MeshContextDraw_ptr(context, params);
+}
+
+MeshContext* MeshInteropContextCreate(AppGraphCtx* appctx)
+{
+ return gMeshLoader.MeshInteropContextCreate_ptr(appctx);
+}
+
+void MeshInteropContextUpdate(MeshContext* context, AppGraphCtx* appctx)
+{
+ return gMeshLoader.MeshInteropContextUpdate_ptr(context, appctx);
+}
+
+void* meshLoaderLoadFunction(MeshLoader* inst, const char* name)
+{
+ snprintf(inst->buf, 1024u, "%s%s", name, inst->suffix);
+
+ return SDL_LoadFunction(inst->module, inst->buf);
+}
+
+void loadMesh(AppGraphCtxType type)
+{
+ const char* moduleName = demoAppDLLName(type);
+
+ gMeshLoader.suffix = demoAppBackendSuffix(type);
+
+ gMeshLoader.module = SDL_LoadObject(moduleName);
+
+ gMeshLoader.MeshContextCreate_ptr = (MeshContextCreate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshContextCreate"));
+ gMeshLoader.MeshContextUpdate_ptr = (MeshContextUpdate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshContextUpdate"));
+ gMeshLoader.MeshContextRelease_ptr = (MeshContextRelease_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshContextRelease"));
+ gMeshLoader.MeshIndexBufferCreate_ptr = (MeshIndexBufferCreate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshIndexBufferCreate"));
+ gMeshLoader.MeshIndexBufferRelease_ptr = (MeshIndexBufferRelease_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshIndexBufferRelease"));
+ gMeshLoader.MeshVertexBufferCreate_ptr = (MeshVertexBufferCreate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshVertexBufferCreate"));
+ gMeshLoader.MeshVertexBufferRelease_ptr = (MeshVertexBufferRelease_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshVertexBufferRelease"));
+ gMeshLoader.MeshContextDraw_ptr = (MeshContextDraw_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshContextDraw"));
+ gMeshLoader.MeshInteropContextCreate_ptr = (MeshInteropContextCreate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshInteropContextCreate"));
+ gMeshLoader.MeshInteropContextUpdate_ptr = (MeshInteropContextUpdate_ptr_t)(meshLoaderLoadFunction(&gMeshLoader, "MeshInteropContextUpdate"));
+}
+
+void unloadMesh()
+{
+ gMeshLoader.MeshContextCreate_ptr = nullptr;
+ gMeshLoader.MeshContextUpdate_ptr = nullptr;
+ gMeshLoader.MeshContextRelease_ptr = nullptr;
+ gMeshLoader.MeshIndexBufferCreate_ptr = nullptr;
+ gMeshLoader.MeshIndexBufferRelease_ptr = nullptr;
+ gMeshLoader.MeshVertexBufferCreate_ptr = nullptr;
+ gMeshLoader.MeshVertexBufferRelease_ptr = nullptr;
+ gMeshLoader.MeshContextDraw_ptr = nullptr;
+ gMeshLoader.MeshInteropContextCreate_ptr = nullptr;
+ gMeshLoader.MeshInteropContextUpdate_ptr = nullptr;
+
+ SDL_UnloadObject(gMeshLoader.module);
+}
diff --git a/demo/DemoApp/preset0.h b/demo/DemoApp/preset0.h
index aba3666..5e37ac4 100644
--- a/demo/DemoApp/preset0.h
+++ b/demo/DemoApp/preset0.h
@@ -13,7 +13,9 @@ const ImserNode g_root[] = {
imserNodeValue1f("Velocity", 0.500000f),
imserNodeValue1f("Smoke", 0.500000f),
imserNodeGroupEnd(),
- imserNodeValue1f("Vorticity Strength", 9.000000f),
+ imserNodeGroupBegin("Vorticity Confinement"),
+ imserNodeValue1f("Strength", 9.000000f),
+ imserNodeGroupEnd(),
imserNodeGroupBegin("Combustion"),
imserNodeValue1f("Ignition Temp", 0.050000f),
imserNodeValue1f("Cooling Rate", 1.500000f),
diff --git a/demo/DemoApp/preset1.h b/demo/DemoApp/preset1.h
index dded481..2f502e6 100644
--- a/demo/DemoApp/preset1.h
+++ b/demo/DemoApp/preset1.h
@@ -13,7 +13,9 @@ const ImserNode g_root[] = {
imserNodeValue1f("Velocity", 0.500000f),
imserNodeValue1f("Smoke", 0.500000f),
imserNodeGroupEnd(),
- imserNodeValue1f("Vorticity Strength", 9.000000f),
+ imserNodeGroupBegin("Vorticity Confinement"),
+ imserNodeValue1f("Strength", 9.000000f),
+ imserNodeGroupEnd(),
imserNodeGroupBegin("Combustion"),
imserNodeValue1f("Ignition Temp", 0.050000f),
imserNodeValue1f("Cooling Rate", 1.500000f),
diff --git a/demo/DemoApp/scene.cpp b/demo/DemoApp/scene.cpp
index 3ad7cce..399d4d8 100644
--- a/demo/DemoApp/scene.cpp
+++ b/demo/DemoApp/scene.cpp
@@ -43,8 +43,9 @@ namespace Scenes
SceneSimpleFlameFuelMap sceneSimpleFlameFuelMap;
SceneSimpleFlameParticleSurface sceneParticleSurface;
SceneSimpleFlameBall sceneSimpleFlameBall;
+ SceneEmitSubStep sceneEmitSubStep;
- const int count = 18;
+ const int count = 19;
Scene* list[count] = {
&scene2DTextureEmitter1,
&scene2DTextureEmitter2,
@@ -64,7 +65,8 @@ namespace Scenes
&sceneSimpleFlame2,
&sceneSimpleFlameFuelMap,
&sceneParticleSurface,
- &sceneSimpleFlameBall
+ &sceneSimpleFlameBall,
+ &sceneEmitSubStep
};
};
@@ -115,6 +117,10 @@ void pointsToImage(NvFlowFloat4* image, int imageDim, const CurvePoint* pts, int
void Scene::update(float dt)
{
+ m_deltaTime = dt;
+
+ doFrameUpdate(m_deltaTime);
+
int numSteps = m_timeStepper.getNumSteps(dt);
for (int i = 0; i < numSteps; i++)
@@ -233,6 +239,22 @@ void SceneFluid::imguiDesc()
m_shouldGridReset = true;
}
+ if (imguiCheck("Auto Reset", m_autoResetMode, true))
+ {
+ m_autoResetMode = !m_autoResetMode;
+ m_autoResetTime = 0.f;
+ }
+ if (m_autoResetMode)
+ {
+ m_autoResetTime += m_deltaTime;
+ if (m_autoResetTime > m_autoResetThresh)
+ {
+ m_shouldReset = true;
+ m_autoResetTime = 0.f;
+ m_autoResetThresh = 5.f * (1.f / 255.f) * float((rand() & 255));
+ }
+ }
+
float cellSizeLogf = float(m_flowGridActor.m_cellSizeLogScale);
if (imguiserSlider("Cell Size Log Scale", &cellSizeLogf, -6.f, 6.f, 1.f, true))
{
@@ -271,6 +293,11 @@ void SceneFluid::imguiFluidSim()
imguiserSlider("Fuel", &m_flowGridActor.m_materialParams.fuel.fade, 0.f, 1.f, 0.01f, true);
imguiserEndGroup();
+ if (imguiCheck("Single Pass Advect", m_flowGridActor.m_gridParams.singlePassAdvection, true))
+ {
+ m_flowGridActor.m_gridParams.singlePassAdvection = !m_flowGridActor.m_gridParams.singlePassAdvection;
+ }
+
imguiSeparator();
imguiLabel("MacCormack Correction");
imguiserBeginGroup("MacCormack Correction", nullptr);
@@ -287,8 +314,16 @@ void SceneFluid::imguiFluidSim()
imguiserSlider("Fuel", &m_flowGridActor.m_materialParams.fuel.macCormackBlendThreshold, 0.f, 0.01f, 0.001f, true);
imguiserEndGroup();
- imguiserSlider("Vorticity Strength", &m_flowGridActor.m_materialParams.vorticityStrength, 0.f, 20.f, 0.1f, true);
- imguiserSlider("Vorticity Vel Mask", &m_flowGridActor.m_materialParams.vorticityVelocityMask, 0.f, 1.f, 0.01f, true);
+ imguiSeparator();
+ imguiLabel("Vorticity Confinement");
+ imguiserBeginGroup("Vorticity Confinement", nullptr);
+ imguiserSlider("Strength", &m_flowGridActor.m_materialParams.vorticityStrength, 0.f, 20.f, 0.1f, true);
+ imguiserSlider("Velocity Mask", &m_flowGridActor.m_materialParams.vorticityVelocityMask, -1.f, 1.f, 0.01f, true);
+ imguiserSlider("Temperature Mask", &m_flowGridActor.m_materialParams.vorticityTemperatureMask, -1.f, 1.f, 0.01f, true);
+ imguiserSlider("Smoke Mask", &m_flowGridActor.m_materialParams.vorticitySmokeMask, -1.f, 1.f, 0.01f, true);
+ imguiserSlider("Fuel Mask", &m_flowGridActor.m_materialParams.vorticityFuelMask, -1.f, 1.f, 0.01f, true);
+ imguiserSlider("Constant Mask", &m_flowGridActor.m_materialParams.vorticityConstantMask, -1.f, 1.f, 0.01f, true);
+ imguiserEndGroup();
if (imguiCheck("Legacy Pressure", m_flowGridActor.m_gridParams.pressureLegacyMode, true))
{
@@ -497,6 +532,21 @@ void SceneFluid::imguiFluidRender()
imguiserSlider("Vector Length", &m_flowGridActor.m_crossSectionParams.vectorLengthScale, 0.1f, 2.f, 0.01f, true);
}
+ imguiLabel("Grid Summary");
+ imguiserBeginGroup("Grid Summary", nullptr);
+ if (imguiserCheck("Enabled", m_flowGridActor.m_enableGridSummary, true))
+ {
+ m_flowGridActor.m_enableGridSummary = !m_flowGridActor.m_enableGridSummary;
+ }
+ if (m_flowGridActor.m_enableGridSummary)
+ {
+ if (imguiserCheck("Debug Render", m_flowGridActor.m_enableGridSummaryDebugVis, true))
+ {
+ m_flowGridActor.m_enableGridSummaryDebugVis = !m_flowGridActor.m_enableGridSummaryDebugVis;
+ }
+ }
+ imguiserEndGroup();
+
imguiFluidRenderExtra();
imguiserEndGroup();
}
@@ -549,6 +599,12 @@ void SceneFluid::imguiFluidAlloc()
imguiserSlider("Temp Threshold", &m_flowGridActor.m_materialParams.temperature.allocThreshold, 0.f, 1.f, 0.01f, true);
imguiserSlider("Fuel Threshold", &m_flowGridActor.m_materialParams.fuel.allocThreshold, 0.f, 1.f, 0.01f, true);
+ if (imguiCheck("Translation Test", m_flowGridActor.m_enableTranslationTest, true))
+ {
+ m_flowGridActor.m_enableTranslationTest = !m_flowGridActor.m_enableTranslationTest;
+ }
+ imguiSlider("Test Time Scale", &m_flowGridActor.m_translationTimeScale, 0.25f, 8.f, 0.1f, true);
+
imguiFluidAllocExtra();
imguiserEndGroup();
}
@@ -678,37 +734,45 @@ bool SceneFluid::getStats(int lineIdx, int statIdx, char* buf)
}
case 1:
{
+ float simRate = (1.f / m_flowContext.m_statUpdateDt) *
+ float(m_flowContext.m_statUpdateSuccessCount /
+ m_flowContext.m_statUpdateAttemptCount);
+ snprintf(buf, 79, "SimRate: %.3f Hz", simRate);
+ return true;
+ }
+ case 2:
+ {
NvFlowUint numLayers = m_flowGridActor.m_statNumLayers;
snprintf(buf, 79, "NumLayers: %d layers", numLayers);
return true;
}
- case 2:
+ case 3:
{
NvFlowUint numBlocks = m_flowGridActor.m_statNumDensityBlocks;
NvFlowUint maxBlocks = m_flowGridActor.m_statMaxDensityBlocks;
snprintf(buf, 79, "Density: %d blocks active of %d", numBlocks, maxBlocks);
return true;
}
- case 3:
+ case 4:
{
NvFlowUint numBlocks = m_flowGridActor.m_statNumVelocityBlocks;
NvFlowUint maxBlocks = m_flowGridActor.m_statMaxVelocityBlocks;
snprintf(buf, 79, "Velocity: %d blocks active of %d", numBlocks, maxBlocks);
return true;
}
- case 4:
+ case 5:
{
NvFlowUint numCells = m_flowGridActor.m_statNumDensityCells;
snprintf(buf, 79, "Density: %d cells active", numCells);
return true;
}
- case 5:
+ case 6:
{
NvFlowUint numCells = m_flowGridActor.m_statNumVelocityCells;
snprintf(buf, 79, "Velocity: %d cells active", numCells);
return true;
}
- case 6:
+ case 7:
{
if (m_flowGridActor.m_statVolumeShadowBlocks > 0u)
{
@@ -718,7 +782,7 @@ bool SceneFluid::getStats(int lineIdx, int statIdx, char* buf)
}
return false;
}
- case 7:
+ case 8:
{
if (m_flowGridActor.m_statVolumeShadowCells > 0u)
{
diff --git a/demo/DemoApp/scene.h b/demo/DemoApp/scene.h
index fee39e4..da88e1d 100644
--- a/demo/DemoApp/scene.h
+++ b/demo/DemoApp/scene.h
@@ -31,6 +31,7 @@ struct TimeStepper
float m_timeError = 0.f;
float m_fixedDt = (1.f / 60.f);
int m_maxSteps = 1;
+ int m_numSteps = 0;
TimeStepper() {}
@@ -41,14 +42,15 @@ struct TimeStepper
// compute time steps
m_timeError += m_deltaTime;
- int numSteps = int(m_timeError / m_fixedDt);
- if (numSteps < 0) numSteps = 0;
+ m_numSteps = int(floorf((m_timeError / m_fixedDt)));
- m_timeError -= m_fixedDt * float(numSteps);
+ if (m_numSteps < 0) m_numSteps = 0;
- if (numSteps > m_maxSteps) numSteps = m_maxSteps;
+ m_timeError -= m_fixedDt * float(m_numSteps);
- return numSteps;
+ if (m_numSteps > m_maxSteps) m_numSteps = m_maxSteps;
+
+ return m_numSteps;
}
};
@@ -82,7 +84,10 @@ struct Scene
int m_winw = 0;
int m_winh = 0;
+ float m_deltaTime = 0.f;
+
protected:
+ virtual void doFrameUpdate(float dt) {}
virtual void doUpdate(float dt) = 0;
AppGraphCtx* m_context = nullptr;
@@ -145,13 +150,17 @@ struct FlowContext
int m_maxFramesInFlight = 3u;
int m_framesInFlight = 0;
+ double m_statUpdateAttemptCount = 0.0;
+ double m_statUpdateSuccessCount = 0.0;
+ float m_statUpdateDt = 0.f;
+
FlowContext() {}
~FlowContext() {}
void init(AppGraphCtx* appctx);
void release();
- bool updateBegin();
+ bool updateBegin(float dt);
void updateEnd();
void preDrawBegin();
void preDrawEnd();
@@ -174,6 +183,8 @@ struct FlowGridActor
NvFlowVolumeRender* m_volumeRender = nullptr;
NvFlowVolumeShadow* m_volumeShadow = nullptr;
NvFlowCrossSection* m_crossSection = nullptr;
+ NvFlowGridSummary* m_gridSummary = nullptr;
+ NvFlowGridSummaryStateCPU* m_gridSummaryStateCPU = nullptr;
NvFlowGridDesc m_gridDesc;
NvFlowGridParams m_gridParams;
@@ -216,6 +227,16 @@ struct FlowGridActor
float m_crossSectionBackgroundColor = 0.f;
NvFlowFloat3 m_crossSectionLineColor = { 141.f / 255.f, 199.f / 255.f, 63.f / 255.f };
+ bool m_enableGridSummary = false;
+ bool m_enableGridSummaryDebugVis = false;
+
+ bool m_enableTranslationTest = false;
+ float m_translationTimeScale = 1.f;
+ bool m_enableTranslationTestOld = false;
+ float m_translationTestTime = 0.f;
+ NvFlowFloat3 m_translationOffsetA = { +4.f, 0.f, 0.f };
+ NvFlowFloat3 m_translationOffsetB = { -4.f, 0.f, 0.f };
+
NvFlowUint m_statNumLayers = 0u;
NvFlowUint m_statNumDensityBlocks = 0u;
NvFlowUint m_statNumDensityCells = 0u;
@@ -341,6 +362,10 @@ struct SceneFluid : public Scene
bool m_shouldGridReset = false;
bool m_shouldLoadPreset = false;
+ bool m_autoResetMode = false;
+ float m_autoResetTime = 0.f;
+ float m_autoResetThresh = 0.f;
+
virtual bool shouldReset() { return m_shouldReset; }
virtual void reset();
};
@@ -550,6 +575,22 @@ struct SceneSimpleFlameAnimated : public SceneSimpleFlame
m_emitParams.bounds.w.x = 2.f * cosf(rate * time);
m_emitParams.bounds.w.z = 2.f * sinf(rate * time);
+ // testing hack
+ //static int offset = 0;
+ //offset++;
+ //if (offset > 4)
+ //{
+ // offset = 0;
+ //}
+ //m_emitParams.bounds.w.z += float(offset) - 4.f;
+
+ //NvFlowFloat3 gridLocation = { m_emitParams.bounds.w.x, 0.f, m_emitParams.bounds.w.z };
+ //NvFlowGridSetTargetLocation(m_flowGridActor.m_grid, gridLocation);
+
+ //bool parity = (time - floorf(time)) > 0.5f;
+ //NvFlowFloat3 gridLocation = parity ? NvFlowFloat3{-4.f, 0.f, 0.f} : NvFlowFloat3{+4.f, 0.f, 0.f};
+ //NvFlowGridSetTargetLocation(m_flowGridActor.m_grid, gridLocation);
+
m_emitParams.velocityLinear.x = +8.f * sinf(rate * time);
m_emitParams.velocityLinear.y = -2.f;
m_emitParams.velocityLinear.z = -8.f * cosf(rate * time);
@@ -681,6 +722,8 @@ struct SceneSimpleFlameCapsule : public SceneSimpleFlame
float m_capsuleLength = 0.75f;
float m_distanceScale = 3.5f;
bool m_boxMode = false;
+ bool m_flameSpread = false;
+ bool m_flameSpreadOld = false;
};
struct Scene2DTextureEmitter : public SceneFluid
@@ -831,6 +874,31 @@ struct SceneCustomEmit : public SceneFluid
bool m_fullDomain = false;
};
+struct SceneEmitSubStep : public SceneFluid
+{
+ SceneEmitSubStep() : SceneFluid("Emit Sub Step") {}
+
+ virtual void initParams();
+ virtual void init(AppGraphCtx* context, int winw, int winh);
+ virtual void doFrameUpdate(float dt);
+ virtual void doUpdate(float dt);
+ virtual void preDraw();
+ virtual void draw(DirectX::CXMMATRIX projection, DirectX::CXMMATRIX view);
+ virtual void release();
+ virtual void imgui(int x, int y, int w, int h);
+
+ virtual void imguiFluidEmitterExtra();
+
+ void emitSubSteps(float t_old, float x_old, float t_new, float x_new, float frame_dt);
+ void emitImpulse(float x, float impulse_dt);
+
+ float anim_t = 0.f;
+ float anim_x = -1.f;
+ float anim_x_old = 0.f;
+
+ TimeStepper m_emitterTimeStepper;
+};
+
Scene* getScene(int index);
void pointsToImage(NvFlowFloat4* image, int imageDim, const CurvePoint* pts, int numPts);
diff --git a/demo/DemoApp/scene2DTextureEmitter.cpp b/demo/DemoApp/scene2DTextureEmitter.cpp
index c2d3984..c5b0197 100644
--- a/demo/DemoApp/scene2DTextureEmitter.cpp
+++ b/demo/DemoApp/scene2DTextureEmitter.cpp
@@ -130,7 +130,7 @@ void Scene2DTextureEmitter::init(AppGraphCtx* appctx, int winw, int winh)
void Scene2DTextureEmitter::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
diff --git a/demo/DemoApp/sceneCustomEmit.cpp b/demo/DemoApp/sceneCustomEmit.cpp
index c52db59..8c97150 100644
--- a/demo/DemoApp/sceneCustomEmit.cpp
+++ b/demo/DemoApp/sceneCustomEmit.cpp
@@ -120,7 +120,7 @@ void SceneCustomEmit::init(AppGraphCtx* appctx, int winw, int winh)
void SceneCustomEmit::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
ComputeContextNvFlowContextUpdate(m_customContext, m_flowContext.m_gridContext);
diff --git a/demo/DemoApp/sceneEmitSubStep.cpp b/demo/DemoApp/sceneEmitSubStep.cpp
new file mode 100644
index 0000000..76c0115
--- /dev/null
+++ b/demo/DemoApp/sceneEmitSubStep.cpp
@@ -0,0 +1,204 @@
+/*
+* 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 <stdio.h>
+#include <string.h>
+
+#include "loader.h"
+#include "imgui.h"
+#include "imguiser.h"
+
+namespace PresetFlame
+{
+#include "presetFlame.h"
+}
+
+#include "scene.h"
+
+#include <SDL.h>
+
+void SceneEmitSubStep::initParams()
+{
+ m_flowGridActor.initParams(AppGraphCtxDedicatedVideoMemory(m_appctx));
+
+ // set emitter defaults
+ NvFlowGridEmitParamsDefaults(&m_emitParams);
+
+ // configure emitter params
+ m_emitParams.bounds.x.x = 0.25f;
+ m_emitParams.bounds.y.y = 0.25f;
+ m_emitParams.bounds.z.z = 0.25f;
+ m_emitParams.velocityLinear.y = 8.f;
+ m_emitParams.fuel = 1.9f;
+ m_emitParams.smoke = 0.5f;
+
+ m_shouldLoadPreset = true;
+}
+
+void SceneEmitSubStep::init(AppGraphCtx* appctx, int winw, int winh)
+{
+ m_appctx = appctx;
+
+ if (!m_shouldReset || m_isFirstRun)
+ {
+ initParams();
+ m_isFirstRun = false;
+ }
+
+ m_flowContext.init(appctx);
+
+ m_flowGridActor.init(&m_flowContext, appctx);
+
+ // create default color map
+ {
+ const int numPoints = 5;
+ const CurvePoint pts[numPoints] = {
+ { 0.f, 0.f,0.f,0.f,0.f },
+ { 0.05f, 0.f,0.f,0.f,0.5f },
+ { 0.6f, 213.f / 255.f,100.f / 255.f,30.f / 255.f,0.8f },
+ { 0.85f, 255.f / 255.f,240.f / 255.f,0.f,0.8f },
+ { 1.f, 1.f,1.f,1.f,0.7f }
+ };
+
+ auto& colorMap = m_flowGridActor.m_colorMap;
+ colorMap.initColorMap(m_flowContext.m_renderContext, pts, numPoints, (colorMap.m_curvePointsDefault.size() == 0));
+ }
+
+ m_projectile.init(m_appctx, m_flowContext.m_gridContext);
+
+ resize(winw, winh);
+}
+
+void SceneEmitSubStep::emitImpulse(float x, float impulse_dt)
+{
+ NvFlowShapeDesc shapeDesc;
+ shapeDesc.sphere.radius = 0.8f;
+
+ m_emitParams.bounds.w.x = x;
+
+ m_emitParams.localToWorld = m_emitParams.bounds;
+ m_emitParams.shapeType = eNvFlowShapeTypeSphere;
+ m_emitParams.deltaTime = impulse_dt;
+
+ NvFlowGridEmit(m_flowGridActor.m_grid, &shapeDesc, 1u, &m_emitParams, 1u);
+}
+
+void SceneEmitSubStep::emitSubSteps(float t_old, float x_old, float t_new, float x_new, float frame_dt)
+{
+ float emitImpulse_dt = m_emitterTimeStepper.m_fixedDt;
+
+ int numSteps = m_emitterTimeStepper.getNumSteps(frame_dt);
+
+ for (int i = 0; i < numSteps; i++)
+ {
+ int substep_i = numSteps - 1 - i;
+
+ float substep_t = emitImpulse_dt * substep_i + m_emitterTimeStepper.m_timeError;
+
+ float s = (substep_t - t_new) / (t_old - t_new);
+ float x = (1.f - s) * x_new + s * x_old;
+
+ emitImpulse(x, emitImpulse_dt);
+ }
+}
+
+void SceneEmitSubStep::doFrameUpdate(float frame_dt)
+{
+ m_emitterTimeStepper.m_fixedDt = 1.f / 1200.f;
+ m_emitterTimeStepper.m_maxSteps = 1000;
+
+ anim_x_old = anim_x;
+
+ anim_t += frame_dt;
+
+ const float freq = 60.f;
+ const float k = 2.f * freq;
+ const float k_dt = 1.f / freq;
+
+ if (anim_t > (2.f * k_dt))
+ {
+ anim_t -= (2.f * k_dt);
+ }
+
+ anim_x = k * fabs(anim_t - k_dt) - 1.f;
+
+ float t_old = frame_dt;
+ float t_new = 0.f;
+
+ emitSubSteps(t_old, anim_x_old, t_new, anim_x, frame_dt);
+}
+
+void SceneEmitSubStep::doUpdate(float dt)
+{
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
+ if (shouldUpdate)
+ {
+ AppGraphCtxProfileBegin(m_appctx, "Simulate");
+
+ m_flowGridActor.updatePreEmit(&m_flowContext, dt);
+
+ // emit
+ {
+ m_projectile.update(m_flowContext.m_gridContext, m_flowGridActor.m_grid, dt);
+ }
+
+ m_flowGridActor.updatePostEmit(&m_flowContext, dt, shouldUpdate, m_shouldGridReset);
+
+ m_shouldGridReset = false;
+
+ AppGraphCtxProfileEnd(m_appctx, "Simulate");
+ }
+ m_flowContext.updateEnd();
+}
+
+void SceneEmitSubStep::preDraw()
+{
+ m_flowContext.preDrawBegin();
+
+ m_flowGridActor.preDraw(&m_flowContext);
+
+ m_flowContext.preDrawEnd();
+}
+
+void SceneEmitSubStep::draw(DirectX::CXMMATRIX projection, DirectX::CXMMATRIX view)
+{
+ m_projectile.draw(projection, view);
+
+ m_flowContext.drawBegin();
+
+ m_flowGridActor.draw(&m_flowContext, projection, view);
+
+ m_flowContext.drawEnd();
+}
+
+void SceneEmitSubStep::release()
+{
+ m_projectile.release();
+
+ m_flowGridActor.release();
+
+ m_flowContext.release();
+}
+
+void SceneEmitSubStep::imgui(int xIn, int yIn, int wIn, int hIn)
+{
+ SceneFluid::imgui(xIn, yIn, wIn, hIn);
+
+ if (m_shouldLoadPreset)
+ {
+ imguiserLoadC(PresetFlame::g_root, sizeof(PresetFlame::g_root));
+ m_shouldLoadPreset = false;
+ }
+}
+
+void SceneEmitSubStep::imguiFluidEmitterExtra()
+{
+
+} \ No newline at end of file
diff --git a/demo/DemoApp/sceneFlow.cpp b/demo/DemoApp/sceneFlow.cpp
index 80f87b1..5cdb70a 100644
--- a/demo/DemoApp/sceneFlow.cpp
+++ b/demo/DemoApp/sceneFlow.cpp
@@ -205,7 +205,7 @@ void FlowContext::computeContextEnd()
}
}
-bool FlowContext::updateBegin()
+bool FlowContext::updateBegin(float dt)
{
m_framesInFlight = computeContextBegin();
bool shouldFlush = (m_framesInFlight < m_maxFramesInFlight);
@@ -217,6 +217,12 @@ bool FlowContext::updateBegin()
NvFlowContextFlushRequestPush(m_renderCopyContext);
}
+ m_statUpdateAttemptCount += 1.0;
+ if (shouldFlush) m_statUpdateSuccessCount += 1.0;
+ m_statUpdateAttemptCount *= 0.99;
+ m_statUpdateSuccessCount *= 0.99;
+ m_statUpdateDt = dt;
+
return shouldFlush;
}
@@ -357,6 +363,12 @@ void FlowGridActor::init(FlowContext* flowContext, AppGraphCtx* appctx)
m_crossSection = NvFlowCreateCrossSection(flowContext->m_renderContext, &crossSectionDesc);
+ NvFlowGridSummaryDesc gridSummaryDesc = {};
+ gridSummaryDesc.gridExport = gridExport;
+
+ m_gridSummary = NvFlowCreateGridSummary(flowContext->m_gridContext, &gridSummaryDesc);
+ m_gridSummaryStateCPU = NvFlowCreateGridSummaryStateCPU(m_gridSummary);
+
NvFlowRenderMaterialPoolDesc materialPoolDesc = {};
materialPoolDesc.colorMapResolution = 64u;
m_colorMap.m_materialPool = NvFlowCreateRenderMaterialPool(flowContext->m_renderContext, &materialPoolDesc);
@@ -393,6 +405,8 @@ void FlowGridActor::release()
NvFlowReleaseGridProxy(m_gridProxy);
NvFlowReleaseVolumeRender(m_volumeRender);
NvFlowReleaseCrossSection(m_crossSection);
+ NvFlowReleaseGridSummary(m_gridSummary);
+ NvFlowReleaseGridSummaryStateCPU(m_gridSummaryStateCPU);
NvFlowReleaseRenderMaterialPool(m_colorMap.m_materialPool);
if (m_volumeShadow) NvFlowReleaseVolumeShadow(m_volumeShadow);
m_volumeShadow = nullptr;
@@ -405,6 +419,25 @@ void FlowGridActor::updatePreEmit(FlowContext* flowContext, float dt)
NvFlowRenderMaterialUpdate(m_colorMap.m_materialDefault, &m_renderMaterialDefaultParams);
NvFlowRenderMaterialUpdate(m_colorMap.m_material0, &m_renderMaterialMat0Params);
NvFlowRenderMaterialUpdate(m_colorMap.m_material1, &m_renderMaterialMat1Params);
+
+ if (m_enableTranslationTest)
+ {
+ m_enableTranslationTestOld = true;
+
+ m_translationTestTime += m_translationTimeScale * dt;
+ if (m_translationTestTime > 120.f) m_translationTestTime = 0.f;
+
+ bool parity = (m_translationTestTime - floorf(m_translationTestTime)) > 0.5f;
+ NvFlowFloat3 gridLocation = parity ? m_translationOffsetA : m_translationOffsetB;
+ NvFlowGridSetTargetLocation(m_grid, gridLocation);
+ }
+ else if(m_enableTranslationTestOld)
+ {
+ NvFlowFloat3 gridLocation = NvFlowFloat3{ 0.f, 0.f, 0.f };
+ NvFlowGridSetTargetLocation(m_grid, gridLocation);
+
+ m_enableTranslationTestOld = false;
+ }
}
void FlowGridActor::updatePostEmit(FlowContext* flowContext, float dt, bool shouldUpdate, bool shouldReset)
@@ -492,6 +525,27 @@ void FlowGridActor::updatePostEmit(FlowContext* flowContext, float dt, bool shou
}
auto gridExport = NvFlowGridGetGridExport(flowContext->m_gridContext, m_grid);
+
+ if (m_enableGridSummary)
+ {
+ NvFlowGridSummaryUpdateParams updateParams = {};
+ updateParams.gridExport = gridExport;
+ updateParams.stateCPU = m_gridSummaryStateCPU;
+
+ NvFlowGridSummaryUpdate(m_gridSummary, flowContext->m_gridContext, &updateParams);
+
+ NvFlowUint numLayers = NvFlowGridSummaryGetNumLayers(m_gridSummaryStateCPU);
+ for (NvFlowUint layerIdx = 0u; layerIdx < numLayers; layerIdx++)
+ {
+ NvFlowGridSummaryResult* results = nullptr;
+ NvFlowUint numResults = 0u;
+
+ NvFlowGridSummaryGetSummaries(m_gridSummaryStateCPU, &results, &numResults, layerIdx);
+
+ //printf("GridSummary layer(%d) numResults(%d)", layerIdx, numResults);
+ }
+ }
+
NvFlowGridProxyFlushParams flushParams = {};
flushParams.gridContext = flowContext->m_gridContext;
flushParams.gridCopyContext = flowContext->m_gridCopyContext;
@@ -686,6 +740,20 @@ void FlowGridActor::draw(FlowContext* flowContext, DirectX::CXMMATRIX projection
NvFlowVolumeShadowDebugRender(m_volumeShadow, flowContext->m_renderContext, &params);
}
+
+ if (m_enableGridSummary && m_enableGridSummaryDebugVis)
+ {
+ NvFlowGridSummaryDebugRenderParams params = {};
+
+ params.stateCPU = m_gridSummaryStateCPU;
+
+ params.renderTargetView = flowContext->m_rtv;
+
+ memcpy(&params.projectionMatrix, &projection, sizeof(NvFlowFloat4x4));
+ memcpy(&params.viewMatrix, &view, sizeof(NvFlowFloat4x4));
+
+ NvFlowGridSummaryDebugRender(m_gridSummary, flowContext->m_renderContext, &params);
+ }
}
// *********************** Flow Color Map *****************************************
diff --git a/demo/DemoApp/sceneSDF.cpp b/demo/DemoApp/sceneSDF.cpp
index 301e260..1e6ad08 100644
--- a/demo/DemoApp/sceneSDF.cpp
+++ b/demo/DemoApp/sceneSDF.cpp
@@ -138,7 +138,7 @@ void SceneSDFTest::init(AppGraphCtx* appctx, int winw, int winh)
void SceneSDFTest::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -285,7 +285,7 @@ void SceneCustomLighting::init(AppGraphCtx* context, int winw, int winh)
void SceneCustomLighting::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
ComputeContextNvFlowContextUpdate(m_computeContext, m_flowContext.m_renderContext);
diff --git a/demo/DemoApp/sceneSimpleFlame.cpp b/demo/DemoApp/sceneSimpleFlame.cpp
index 60b134b..5cd69cc 100644
--- a/demo/DemoApp/sceneSimpleFlame.cpp
+++ b/demo/DemoApp/sceneSimpleFlame.cpp
@@ -106,7 +106,7 @@ void SceneSimpleFlame::init(AppGraphCtx* appctx, int winw, int winh)
void SceneSimpleFlame::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -191,6 +191,7 @@ void SceneSimpleFlameDouble::init(AppGraphCtx* context, int winw, int winh)
materialParams.vorticityStrength = 5.f;
materialParams.vorticityVelocityMask = 0.f;
+ materialParams.vorticityConstantMask = 1.f;
materialParams.velocity.macCormackBlendFactor = 0.f;
materialParams.smoke.macCormackBlendFactor = 0.75f;
materialParams.buoyancyPerTemp *= 5.f;
@@ -203,13 +204,17 @@ void SceneSimpleFlameDouble::init(AppGraphCtx* context, int winw, int winh)
void SceneSimpleFlameDouble::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
m_flowGridActor.updatePreEmit(&m_flowContext, dt);
+ NvFlowGridMaterialHandle emitMaterials[2u] = { m_materialA, m_materialB };
+
+ NvFlowGridUpdateEmitMaterials(m_flowGridActor.m_grid, emitMaterials, 2u);
+
// emit
{
NvFlowShapeDesc shapeDesc;
@@ -220,14 +225,14 @@ void SceneSimpleFlameDouble::doUpdate(float dt)
m_emitParams.deltaTime = dt;
m_emitParamsA = m_emitParams;
- m_emitParamsA.material = m_materialA;
+ m_emitParamsA.emitMaterialIndex = 0u;
m_emitParamsA.bounds.w.x = +0.25f;
m_emitParamsA.localToWorld = m_emitParamsA.bounds;
m_emitParamsA.velocityLinear.x = -8.f;
NvFlowGridEmit(m_flowGridActor.m_grid, &shapeDesc, 1u, &m_emitParamsA, 1u);
m_emitParamsB = m_emitParams;
- m_emitParamsB.material = m_materialB;
+ m_emitParamsB.emitMaterialIndex = 1u;
m_emitParamsB.bounds.w.x = -0.25f;
m_emitParamsB.localToWorld = m_emitParamsB.bounds;
m_emitParamsB.velocityLinear.x = +8.f;
@@ -300,7 +305,7 @@ void SceneSimpleFlameFuelMap::init(AppGraphCtx* context, int winw, int winh)
void SceneSimpleFlameFuelMap::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -452,7 +457,7 @@ void SceneSimpleFlameParticleSurface::doEmitCustomEmitDensityFunc(NvFlowUint* da
void SceneSimpleFlameParticleSurface::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
// update emit params
@@ -892,7 +897,7 @@ void SceneSimpleFlameCulling::initParams()
void SceneSimpleFlameCulling::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -1005,7 +1010,7 @@ void SceneSimpleFlameConvex::initParams()
void SceneSimpleFlameConvex::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -1083,7 +1088,7 @@ void SceneSimpleFlameCapsule::initParams()
void SceneSimpleFlameCapsule::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");
@@ -1123,6 +1128,29 @@ void SceneSimpleFlameCapsule::doUpdate(float dt)
shapeDesc[0].box.halfSize.z = 0.5f * m_capsuleRadius;
}
+ if (m_flameSpread && !m_flameSpreadOld)
+ {
+ m_shouldGridReset = true;
+ }
+ m_flameSpreadOld = m_flameSpread;
+
+ if (m_flameSpread)
+ {
+ m_emitParams.fuel = 0.f;
+ m_emitParams.fuelRelease = 2.5f;
+ m_emitParams.temperature = 0.f;
+ m_emitParams.temperatureCoupleRate = 0.f;
+ m_emitParams.velocityLinear.y = 0.f;
+ }
+ else
+ {
+ m_emitParams.fuel = 2.5f;
+ m_emitParams.fuelRelease = 0.f;
+ m_emitParams.temperature = 2.f;
+ m_emitParams.temperatureCoupleRate = 0.5f;
+ m_emitParams.velocityLinear.y = 8.f;
+ }
+
NvFlowGridEmit(m_flowGridActor.m_grid, shapeDesc, 1u, &m_emitParams, 1u);
m_projectile.update(m_flowContext.m_gridContext, m_flowGridActor.m_grid, dt);
@@ -1152,5 +1180,10 @@ void SceneSimpleFlameCapsule::imguiFluidEmitterExtra()
m_boxMode = !m_boxMode;
}
+ if (imguiserCheck("Flame Spread", m_flameSpread, true))
+ {
+ m_flameSpread = !m_flameSpread;
+ }
+
imguiserEndGroup();
} \ No newline at end of file
diff --git a/demo/DemoApp/sceneSimpleSmoke.cpp b/demo/DemoApp/sceneSimpleSmoke.cpp
index da5440d..4c849b9 100644
--- a/demo/DemoApp/sceneSimpleSmoke.cpp
+++ b/demo/DemoApp/sceneSimpleSmoke.cpp
@@ -120,7 +120,7 @@ NvFlowFloat3 SceneSimpleSmoke::velocityFunc(float theta, float rate)
void SceneSimpleSmoke::doUpdate(float dt)
{
- bool shouldUpdate = m_flowContext.updateBegin();
+ bool shouldUpdate = m_flowContext.updateBegin(dt);
if (shouldUpdate)
{
AppGraphCtxProfileBegin(m_appctx, "Simulate");